halohalo
bnmbnmbnhjkhjkhjkhjktyutyutyuytutyutyutyhgjgjghjgjghjguytutyry
/
home
/
aramiyarkai
/
public_html
/
admin
/
Upload FileeE
HOME
<?php //error_reporting (0); include("db.class.php"); $base="aramiyar_db"; $server="localhost"; $username="aramiyar_db"; $pass="ITk^HeRf;{BT"; //Connect Database $link = new mysqli($server, $username, $pass,$base) or die("Couldn't make connection."); global $link; mysqli_set_charset($link,'utf8'); //Profit Loss Sheet $projectcost = "10000"; $total_employee = "20"; $monthly_electricity = "20000"; $server_payment = "11500"; $office_rent = "17000"; $internet = "4000"; $others = "40000"; $no_of_days = "25"; $no_of_hours = "8"; //Attendance Time Limit //Present Thershold $vtime1 = "7:00:01 am"; $vtime2 = "9:50:00 am"; //Late Thershold $vtime3 = "9:50:01 am"; $vtime4 = "10:30:00 am"; //Half Day Thershold $vtime5 = "10:30:01 am"; $vtime6 = "1:00:00 pm"; //Absent Thershold $vtime7 = "1:00:01 pm"; $vtime8 = "10:00:00 pm"; //for leave calculation $adjust = "172";//value for adjusting the leave calculation for 2015 and default value is 0 $cur_month = date('m'); $from_month = "1";//enter value from 1-12 $year = "2015"; //SMS Panel Details //Normal Login Details $sms_user="ragadesigners"; //your username $sms_password="shreeraga12"; //your password $sms_senderid="016069"; //Your senderid $sms_messagetype="N"; //Type Of Your Message $sms_DReports="N"; //Delivery Reports $sms_url="http://sms.ragadesigners.com/WebServiceSMS.aspx?"; //Trancational SMS Login Details $sms1_user="ragadesigners"; //your username $sms1_password="shreeraga12"; //your password $sms1_senderid="016069"; //Your senderid $sms1_messagetype="N"; //Type Of Your Message $sms1_DReports="N"; //Delivery Reports $sms1_url="http://sms1.ragadesigners.com/WebServiceSMS.aspx?"; $monthnames = array( '01'=>'January', '02'=>'February', '03'=>'March', '04'=>'April', '05'=>'May', '06'=>'June', '07'=>'July', '08'=>'August', '09'=>'September', '10'=>'October', '11'=>'November', '12'=>'December', '1'=>'January', '2'=>'February', '3'=>'March', '4'=>'April', '5'=>'May', '6'=>'June', '7'=>'July', '8'=>'August', '9'=>'September' ); $monthdays = array( 'January'=>'31', 'February'=>'28', 'March'=>'31', 'April'=>'30', 'May'=>'31', 'June'=>'30', 'July'=>'31', 'August'=>'31', 'September'=>'30', 'October'=>'31', 'November'=>'30', 'December'=>'31' ); /* Registration Type (Automatic or Manual) 1 -> Automatic Registration (Users will receive activation code and they will be automatically approved after clicking activation link) 0 -> Manual Approval (Users will not receive activation code and you will need to approve every user manually) */ $user_registration = 1; // set 0 or 1 $sendemail = 1; $sendsms = 0; define("COOKIE_TIME_OUT", 10); //specify cookie timeout in days (default is 10 days) define('SALT_LENGTH', 9); // salt for password //define ("ADMIN_NAME", "admin"); // sp /* Specify user levels */ define ("ADMIN_LEVEL", 5); define ("USER_LEVEL", 1); define ("EMPLOYEE_LEVEL", 2); define ("SELLER_LEVEL", 3); /*************** reCAPTCHA KEYS****************/ $publickey = "6LchkM4SAAAAAF1n0zYoHy_Umv1niH1JddGshDzx"; $privatekey = "6LchkM4SAAAAAG7BAPaXEl8C0y8_TF4TpyfSBV3O"; /**** PAGE PROTECT CODE ******************************** This code protects pages to only logged in users. If users have not logged in then it will redirect to login page. If you want to add a new page and want to login protect, COPY this from this to END marker. Remember this code must be placed on very top of any html or php page. ********************************************************/ function page_protect() { session_start(); global $db; /* Secure against Session Hijacking by checking user agent */ if (isset($_SESSION['HTTP_USER_AGENT'])) { if ($_SESSION['HTTP_USER_AGENT'] != md5($_SERVER['HTTP_USER_AGENT'])) { logout(); exit; } } // before we allow sessions, we need to check authentication key - ckey and ctime stored in database /* If session not set, check for cookies set by Remember me */ if (!isset($_SESSION['user_id']) && !isset($_SESSION['user_name']) ) { if(isset($_COOKIE['user_id']) && isset($_COOKIE['user_key'])){ /* we double check cookie expiry time against stored in database */ $cookie_user_id = filter($_COOKIE['user_id']); $rs_ctime = mysqli_query($link,"select `ckey`,`ctime` from `users` where `id` ='$cookie_user_id'") or die(mysqli_error($link)); list($ckey,$ctime) = mysqli_fetch_row($rs_ctime); // coookie expiry if( (time() - $ctime) > 60*60*24*COOKIE_TIME_OUT) { logout(); } /* Security check with untrusted cookies - dont trust value stored in cookie. /* We also do authentication check of the `ckey` stored in cookie matches that stored in database during login*/ if( !empty($ckey) && is_numeric($_COOKIE['user_id']) && isUserID($_COOKIE['user_name']) && $_COOKIE['user_key'] == sha1($ckey) ) { session_regenerate_id(); //against session fixation attacks. $_SESSION['user_id'] = $_COOKIE['user_id']; $_SESSION['user_name'] = $_COOKIE['user_name']; /* query user level from database instead of storing in cookies */ list($user_level) = mysqli_fetch_row(mysqli_query($link,"select user_level from users where id='$_SESSION[user_id]'")); $_SESSION['user_level'] = $user_level; $_SESSION['HTTP_USER_AGENT'] = md5($_SERVER['HTTP_USER_AGENT']); } else { logout(); } } else { header("Location: index.php"); exit(); } } } function filter($data) { $data = trim(htmlentities(strip_tags($data))); global $link; if (get_magic_quotes_gpc()) $data = stripslashes($data); $data = mysqli_real_escape_string($link,$data); return $data; } function EncodeURL($url) { $new = strtolower(ereg_replace(' ','_',$url)); return($new); } function DecodeURL($url) { $new = ucwords(ereg_replace('_',' ',$url)); return($new); } function ChopStr($str, $len) { if (strlen($str) < $len) return $str; $str = substr($str,0,$len); if ($spc_pos = strrpos($str," ")) $str = substr($str,0,$spc_pos); return $str . "..."; } function isEmail($email){ return preg_match('/^\S+@[\w\d.-]{2,}\.[\w]{2,6}$/iU', $email) ? TRUE : FALSE; } function isUserID($username) { if (preg_match('/^[a-z\d_]{5,20}$/i', $username)) { return true; } else { return false; } } function isURL($url) { if (preg_match('/^(http|https|ftp):\/\/([A-Z0-9][A-Z0-9_-]*(?:\.[A-Z0-9][A-Z0-9_-]*)+):?(\d+)?\/?/i', $url)) { return true; } else { return false; } } function checkPwd($x,$y) { if(empty($x) || empty($y) ) { return false; } if (strlen($x) < 4 || strlen($y) < 4) { return false; } if (strcmp($x,$y) != 0) { return false; } return true; } function GenPwd($length = 7) { $password = ""; $possible = "0123456789bcdfghjkmnpqrstvwxyz"; //no vowels $i = 0; while ($i < $length) { $char = substr($possible, mt_rand(0, strlen($possible)-1), 1); if (!strstr($password, $char)) { $password .= $char; $i++; } } return $password; } function GenKey($length = 7) { $password = ""; $possible = "0123456789abcdefghijkmnopqrstuvwxyz"; $i = 0; while ($i < $length) { $char = substr($possible, mt_rand(0, strlen($possible)-1), 1); if (!strstr($password, $char)) { $password .= $char; $i++; } } return $password; } function logout() { global $db; global $link; session_start(); if(isset($_SESSION['user_id']) || isset($_COOKIE['user_id'])) { mysqli_query($link,"update `users` set `ckey`= '', `ctime`= '' where `id`='$_SESSION[user_id]' OR `id` = '$_COOKIE[user_id]'") or die(mysqli_error($link)); } /************ Delete the sessions****************/ unset($_SESSION['user_id']); unset($_SESSION['raga_id']); unset($_SESSION['user_name']); unset($_SESSION['user_level']); unset($_SESSION['HTTP_USER_AGENT']); session_unset(); session_destroy(); /* Delete the cookies*******************/ setcookie("user_id", '', time()-60*60*24*COOKIE_TIME_OUT, "/"); setcookie("raga_id", '', time()-60*60*24*COOKIE_TIME_OUT, "/"); setcookie("user_name", '', time()-60*60*24*COOKIE_TIME_OUT, "/"); setcookie("user_key", '', time()-60*60*24*COOKIE_TIME_OUT, "/"); header("Location: index.php"); } // Password and salt generation function PwdHash($pwd, $salt = null) { if ($salt === null) { $salt = substr(md5(uniqid(rand(), true)), 0, SALT_LENGTH); } else { $salt = substr($salt, 0, SALT_LENGTH); } return $salt . sha1($pwd . $salt); } function checkAdmin() { if($_SESSION['user_level'] == ADMIN_LEVEL) { return 1; } else { return 0 ; } } function checkCoadmin() { if($_SESSION['user_level'] == EMPLOYEE_LEVEL) { return 1; } else { return 0 ; } } function checkSeller() { if($_SESSION['user_level'] == SELLER_LEVEL) { return 1; } else { return 0 ; } } function checkuser() { if($_SESSION['user_level'] == USER_LEVEL) { return 1; } else { return 0 ; } } function checkadmin_function(){ session_start(); global $db; /* Secure against Session Hijacking by checking user agent */ if (isset($_SESSION['HTTP_USER_AGENT'])) { if ($_SESSION['HTTP_USER_AGENT'] != md5($_SERVER['HTTP_USER_AGENT'])) { logout(); exit; } } // before we allow sessions, we need to check authentication key - ckey and ctime stored in database /* If session not set, check for cookies set by Remember me */ if (!isset($_SESSION['user_id']) && !isset($_SESSION['user_name']) ) { if(isset($_COOKIE['user_id']) && isset($_COOKIE['user_key'])){ /* we double check cookie expiry time against stored in database */ $cookie_user_id = filter($_COOKIE['user_id']); $rs_ctime = mysqli_query($link,"select `ckey`,`ctime` from `users` where `id` ='$cookie_user_id'") or die(mysqli_error($link)); list($ckey,$ctime) = mysqli_fetch_row($rs_ctime); // coookie expiry if( (time() - $ctime) > 60*60*24*COOKIE_TIME_OUT) { logout(); } /* Security check with untrusted cookies - dont trust value stored in cookie. /* We also do authentication check of the `ckey` stored in cookie matches that stored in database during login*/ if( !empty($ckey) && is_numeric($_COOKIE['user_id']) && isUserID($_COOKIE['user_name']) && $_COOKIE['user_key'] == sha1($ckey) ) { session_regenerate_id(); //against session fixation attacks. $_SESSION['user_id'] = $_COOKIE['user_id']; $_SESSION['user_name'] = $_COOKIE['user_name']; /* query user level from database instead of storing in cookies */ list($user_level) = mysqli_fetch_row(mysqli_query($link,"select user_level from users where id='$_SESSION[user_id]'")); $_SESSION['user_level'] = $user_level; $_SESSION['HTTP_USER_AGENT'] = md5($_SERVER['HTTP_USER_AGENT']); } else { logout(); } } } } ?>