| Current Path : /var/www/html/mmishra/iws8/html/ipay/ |
| Current File : /var/www/html/mmishra/iws8/html/ipay/config.inc |
<?php
function dbConnect($db) {
$con = mysql_connect("localhost", "root", "irp2015");
if (!$con) die('Could not connect: ' . mysql_error());
mysql_select_db($db);
return $con;
}
function localAuth($uid, $pwd) {
$role = 'student';
if ($uid) {
$rs = mysql_query("select * from webusers where userid='$uid'");
if (mysql_num_rows($rs)) {
$o = mysql_fetch_object($rs);
$role = $o->role;
}
}
return $role;
}
function ldapAuth($uid, $pwd) {
if ($uid && $pwd) {
$ds = ldap_connect("172.31.1.42");
ldap_set_option($ds, LDAP_OPT_PROTOCOL_VERSION, 3);
$a = ldap_search($ds, "dc=iiita,dc=ac,dc=in", "uid=$uid");
$b = ldap_get_entries($ds, $a);
$dn = $b[0]["dn"];
//******************************************************
$flag = (ldap_bind($ds, $dn, $pwd) ? TRUE : FALSE);
ldap_close($ds);
} else
$flag = FALSE;
return $flag;
}
function accessLog($user, $referer, $url, $remoteip) {
$tbl = 'weblogs';
if (!$user) $user = 'guest';
if (!$referer) $referer = 'direct';
if ($url == '/') $url = 'index.php';
mysql_query("insert into $tbl(userid,referer,weburl,remoteip,dateaccess)
values('$user', '$referer', '$url','$remoteip',now())");
}
function checkEmail($email) {
if (eregi("^[a-zA-Z0-9_]+@[a-zA-Z0-9\-]+\.[a-zA-Z0-9\-\.]+$]", $email)) {
return FALSE;
}
list($Username, $Domain) = split("@",$email);
if (getmxrr($Domain, $MXHost)) {
return TRUE;
} else {
if (fsockopen($Domain, 25, $errno, $errstr, 30)) {
return TRUE;
} else {
return FALSE;
}
}
}
function checkAbuser($message, $name, $email, $systemip) {
$tbl = 'abusers';
if (mysql_num_rows(mysql_query("select * from $tbl where systemip='$ip' or email='$email' or name='$name'"))) {
return TRUE;
} else {
$abuses = array('nude','teen','www','url','sex','suck','fuck','xxx','pussy','penis','hotty','sexual','porn','movie');
foreach ($abuses as $abuse) {
if (stristr($message, $abuse)) {
mysql_query("insert into $tbl(name,email,systemip,datecreation) values('$name','$email','$systemip',now())");
return TRUE;
}
}
return FALSE;
}
}
function getIP() {
//Just get the headers if we can or else use the SERVER global
if ( function_exists( 'apache_request_headers' ) ) {
$headers = apache_request_headers();
} else {
$headers = $_SERVER;
}
//Get the forwarded IP if it exists
if ( array_key_exists( 'X-Forwarded-For', $headers ) && filter_var( $headers['X-Forwarded-For'], FILTER_VALIDATE_IP, FILTER_FLAG_IPV4 ) ) {
$the_ip = $headers['X-Forwarded-For'];
} elseif ( array_key_exists( 'HTTP_X_FORWARDED_FOR', $headers ) && filter_var( $headers['HTTP_X_FORWARDED_FOR'], FILTER_VALIDATE_IP, FILTER_FLAG_IPV4 )) {
$the_ip = $headers['HTTP_X_FORWARDED_FOR'];
} else {
$the_ip = filter_var( $_SERVER['REMOTE_ADDR'], FILTER_VALIDATE_IP, FILTER_FLAG_IPV4 );
}
return $the_ip;
}
function ajax() {
$str = "<script language=\"javascript\">
function GetXmlHttpObject() {
var xmlHttp = null;
try {
// Firefox, Opera 8.0+, Safari
xmlHttp = new XMLHttpRequest();
} catch (e) {
// Internet Explorer
try {
xmlHttp = new ActiveXObject(\"Msxml2.XMLHTTP\");
} catch (e) {
xmlHttp = new ActiveXObject(\"Microsoft.XMLHTTP\");
}
}
return xmlHttp;
}
function showPage(uri, task, query) {
if (task.length < 1 || query.length < 3) {
document.getElementById('ajax').innerHTML='';
document.getElementById('ajax').style.visibility = 'hidden';
return;
} else
document.getElementById('ajax').style.visibility = 'visible';
xmlHttp=GetXmlHttpObject()
if (xmlHttp == null) {
alert ('Your browser does not support AJAX!');
return;
}
var url = uri; //+'?task='+task+'&query='+query;
alert(url);
xmlHttp.onreadystatechange = stateChanged;
xmlHttp.open('GET', url, true);
xmlHttp.send(null);
}
function stateChanged() {
if (xmlHttp.readyState==4) {
document.getElementById('ajax').innerHTML=xmlHttp.responseText;
}
}
</script>";
return $str;
}
function automailer($email, $subject, $body) {
//SMTP needs accurate times, and the PHP time zone MUST be set
//This should be done in your php.ini, but this is how to do it if you don't have access to that
date_default_timezone_set('Asia/Kolkata');
//Create a new PHPMailer instance
$mail = new PHPMailer();
//Tell PHPMailer to use SMTP
$mail->isSMTP();
//Tell PHPMailer to use SMTP
$mail->isHTML(true);
//Set the hostname of the mail server
$mail->Host = 'smtp.gmail.com';
//Set the SMTP port number - 587 for authenticated TLS, a.k.a. RFC4409 SMTP submission
$mail->Port = 465;
//Set the encryption system to use - ssl (deprecated) or tls
$mail->SMTPSecure = 'ssl';
//Whether to use SMTP authentication
$mail->SMTPAuth = true;
//Username to use for SMTP authentication - use full email address for gmail
$mail->Username = "ipay@iiita.ac.in";
//Password to use for SMTP authentication
$mail->Password = "ipay@2016";
//Set who the message is to be sent from
$mail->setFrom('ipay@iiita.ac.in', 'iPay@IIITA');
//Set an alternative reply-to address
//$mail->addReplyTo('ipay@iiita.ac.in', 'iPay@IIITA');
//Set who the message is to be sent to
$mail->addAddress($email, $email);
//$mail->addBCC('mmishra@iiita.ac.in', 'Mmishra');
//Set the subject line
$mail->Subject = $subject;
$mail->Body = $body."With thanks,
<br><br><br>
\niPay@IIITA\n\n
<br><br>
<hr>
Visit iPay portal at https://ipay.iiita.ac.in for online payment of fees.
<br><br>
(Automailer)";
$mail->WordWrap = 75;
//send the message, check for errors
if (!$mail->send()) {
echo "<div>Automailer Error: " . $mail->ErrorInfo."</div>";
} else {
echo "<div>Automailer Said: OK</div>";
}
}
function upload($gallery=0) {
$maxsize = 90998860800;
$uploadfile = basename($_FILES['userfile']['name']);
$tempfile = $_FILES['userfile']['tmp_name'];
$filesize = $_FILES["userfile"]["size"];
$uploadfile = str_replace(" ","-",$uploadfile);
$uploadfile = str_replace("'","",$uploadfile);
$uploadfile = str_replace('"',"",$uploadfile);
$uploadfile = str_replace('(',"",$uploadfile);
$uploadfile = strtolower(str_replace(')',"",$uploadfile));
if ($uploadfile && $filesize < $maxsize) {
$filename = explode(".", $uploadfile);
$ext = $filename[count($filename)-1];
$aPath = 'images';
$rPath = 'images';
if (move_uploaded_file($tempfile, "$aPath/$uploadfile")) {
shell_exec("chmod -R 755 $aPath");
//echo "<div>Thanks! $uploadfile file has successfully been uploaded.</div>";
return "$rPath/$uploadfile";
} else {
echo "<div>Oops! $aPath/$uploadfile ($tempfile) file could not be uploaded due to system error.</div>";
return "Error: system problem";
}
} else {
//echo "<div>Oops! either file name is missing or file size exceeds the max. limit of 10 MB.</div>";
return "Error: filesize > 10 MB";
}
}
function text2image($str) {
Header ("Content-type: image/png");
putenv('GDFONTPATH=' . realpath('.'));
$font = 'arial.ttf';
$fontSize = 80;//in point;
$onecharwidth = imagefontwidth($font)*($fontSize/8);
$totalwidth = $onecharwidth * strlen($str);
$height = (imagefontheight($font)*($fontSize/8))*2;
$img_handle = imagecreatetruecolor($totalwidth, $height);
$white = imagecolorallocate($img_handle, 255, 255, 255);
imagefill($img_handle, 0, 0, $white);
$black = imagecolorallocate ($img_handle, 0, 0, 0);
$gray = imagecolorallocate ($img_handle, 100, 100, 100);
imagettftext($img_handle, 20, 0, 10, 20, $black, $font, $title1);
$posarr=imagettfbbox(20, 0,$font, $title1);
imagettftext($img_handle, 20, 0, $posarr[2]+$onecharwidth, 20, $gray, $font, $title2);
imagepng ($img_handle);
imagedestroy ($img_handle);
}
function ReplaceBadWords($str, $bad_words, $replace_str){
if (!is_array($bad_words)){
$bad_words = explode(',', $bad_words);
}
for ($x=0; $x < count($bad_words); $x++){
$fix = isset($bad_words[$x]) ? $bad_words[$x] : '';
$_replace_str = $replace_str;
if (strlen($replace_str)==1){
$_replace_str = str_pad($_replace_str, strlen($fix), $replace_str);
}
$str = preg_replace('/'.$fix.'/i', $_replace_str, $str);
}
return $str;
}
?>