⚠️ **YÜKSEK GÜVENLİK RİSKİ:** Bu dosya herkese açık ve şifresizdir. Lütfen sadece **yerel ortamınızda** kullanın ve işiniz bittiğinde **silin**.
Aktif Dizin:
/home/dltain/public_html/Backup/library
Dosya Düzenle: functions.php
<?php defined('PATH_LIB') or die("Restricted Access"); function redirect($url = NULL) { if (is_null($url)) $url = curPageURL(); if (headers_sent()) { echo "<script>window.location='" . $url . "'</script>"; } else { header("Location:" . $url); } exit; } function msg($msg) { if (count($msg)) foreach ($msg as $type => $content) if ($msg[$type] != '') { return '<div class="status ' . $type . '"> <p class="closestatus"><a href="javascript:void(0);" onclick="$(\'.status\').remove()" title="Close">x</a></p> <p><img src="images/icon_' . $type . '.png" align="absmiddle" > ' . $content . '</p> </div>'; } } function chkHeader() { if (strpos($_SERVER['HTTP_REFERER'], URL_ROOT) == 0) return true; return false; } function setMsgPage($mod, $sec, $type, $note) { //possible values for type //success //information //warning //error if (!isset($_SESSION['msg_er'])) $_SESSION['msg_er'] = array(); if (!isset($_SESSION['msg_er'][$mod])) $_SESSION['msg_er'][$mod] = array(); if (!isset($_SESSION['msg_er'][$mod][$sec])) $_SESSION['msg_er'][$mod][$sec] = array(); $_SESSION['msg_er'][$mod][$sec]['page'] = array( 'type' => $type, 'note' => $note ); } function getMsgPage($mod, $sec) { $return = ''; if (isset($_SESSION['msg_er'][$mod][$sec]['page']) && is_array($_SESSION['msg_er'][$mod][$sec]['page']) && count($_SESSION['msg_er'][$mod][$sec]['page']) > 0) { $class = $_SESSION['msg_er'][$mod][$sec]['page']['type']; $return = "<div class=\"notification " . $class . "\">"; $return .= $_SESSION['msg_er'][$mod][$sec]['page']['note']; $return .= "</div>"; unset($_SESSION['msg_er'][$mod][$sec]['page']); } clearErMsg($mod, $sec); return $return; } function setMsgField($mod, $sec, $field, $type, $note) { //possible values for type //success //information //warning //error if (!isset($_SESSION['msg_er'])) $_SESSION['msg_er'] = array(); if (!isset($_SESSION['msg_er'][$mod])) $_SESSION['msg_er'][$mod] = array(); if (!isset($_SESSION['msg_er'][$mod][$sec])) $_SESSION['msg_er'][$mod][$sec] = array(); if (!isset($_SESSION['msg_er'][$mod][$sec]['field'])) $_SESSION['msg_er'][$mod][$sec]['field'] = array(); $_SESSION['msg_er'][$mod][$sec]['field'][$field] = array( 'type' => $type, 'note' => $note ); } function getMsgField($mod, $sec, $field) { $return = ''; if (isset($_SESSION['msg_er'][$mod][$sec]['field'][$field]) && is_array($_SESSION['msg_er'][$mod][$sec]['field'][$field]) && count($_SESSION['msg_er'][$mod][$sec]['field'][$field]) > 0) { $class = $_SESSION['msg_er'][$mod][$sec]['field'][$field]['type']; $return = "<span class=\"notification " . $class . "\">"; $return .= $_SESSION['msg_er'][$mod][$sec]['field'][$field]['note']; $return .= "</span>"; unset($_SESSION['msg_er'][$mod][$sec]['field'][$field]); } if (isset($_SESSION['msg_er'][$mod][$sec]['field']) && is_array($_SESSION['msg_er'][$mod][$sec]['field']) && count($_SESSION['msg_er'][$mod][$sec]['field']) === 0) unset($_SESSION['msg_er'][$mod][$sec]['field']); clearErMsg($mod, $sec); return $return; } function clearErMsg($mod, $sec) { if (isset($_SESSION['msg_er'][$mod][$sec]) && is_array($_SESSION['msg_er'][$mod][$sec]) && count($_SESSION['msg_er'][$mod][$sec]) === 0) unset($_SESSION['msg_er'][$mod][$sec]); if (isset($_SESSION['msg_er'][$mod]) && is_array($_SESSION['msg_er'][$mod]) && count($_SESSION['msg_er'][$mod]) === 0) unset($_SESSION['msg_er'][$mod]); if (isset($_SESSION['msg_er']) && is_array($_SESSION['msg_er']) && count($_SESSION['msg_er']) === 0) unset($_SESSION['msg_er']); } function setSort($mod, $sec, $val) { if (!isset($_SESSION['sort'])) $_SESSION['sort'] = array(); if (!isset($_SESSION['sort'][$mod])) $_SESSION['sort'][$mod] = array(); $_SESSION['sort'][$mod][$sec] = $val; } function getSort($mod, $sec) { return $_SESSION['sort'][$mod][$sec]; } function curPageURL() { $pageURL = 'http'; if ($_SERVER["HTTPS"] == "on") { $pageURL .= "s"; } $pageURL .= "://"; if ($_SERVER["SERVER_PORT"] != "80") { $pageURL .= $_SERVER["SERVER_NAME"] . ":" . $_SERVER["SERVER_PORT"] . $_SERVER["REQUEST_URI"]; } else { $pageURL .= $_SERVER["SERVER_NAME"] . $_SERVER["REQUEST_URI"]; } return $pageURL; } function getQueryString($aryQueryStr) { $aryMatch = array(); foreach ($aryQueryStr as $opt => $val) { $aryMatch[] = $opt . '=' . urlencode($val); } return '?' . implode('&', $aryMatch); } function selected($needle, $haystack) { if (is_array($haystack) && in_array($needle, $haystack)) { return 'selected="selected"'; } elseif (!is_array($haystack) && $needle === $haystack) { return 'selected="selected"'; } else { return ''; } } function checked($needle, $haystack) { if (is_array($haystack) && in_array($needle, $haystack)) { return 'checked="checked"'; } elseif (!is_array($haystack) && $needle === $haystack) { return 'checked="checked"'; } else { return ''; } } function isValidDate($val) { if (preg_match(REGX_DATE, $val)) { list($year, $month, $date) = explode("-", $val); if (checkdate($month, $date, $year)) return true; } return false; } function getPaging($refUrl, $aryOpts, $pgCnt, $curPg) { // echo $aryOpts." ".$pgCnt." ".$curPg; $return = ''; $return .= '<div class="box-bottom"><div class="paginate">'; if ($curPg > 1) { $aryOpts['pg'] = 1; $return .= '<a href="' . $refUrl . getQueryString($aryOpts) . '">First</a>'; $aryOpts['pg'] = $curPg - 1; $return .= '<a href="' . $refUrl . getQueryString($aryOpts) . '">Prev</a>'; } for ($i = 1; $i <= $pgCnt; $i++) { $aryOpts['pg'] = $i; $return .= '<a href="' . $refUrl . getQueryString($aryOpts) . '" class="'; if ($curPg == $i) $return .= ' active'; $return .= '" >' . $i . '</a>'; } if ($curPg < $pgCnt) { $aryOpts['pg'] = $curPg + 1; $return .= '<a href="' . $refUrl . getQueryString($aryOpts) . '">Next</a>'; $aryOpts['pg'] = $pgCnt; $return .= '<a href="' . $refUrl . getQueryString($aryOpts) . '">Last</a>'; } $return .= '<div class="clearfix"></div></div></div>'; return $return; } function isAdmin() { if (isset($_SESSION[LOGIN_ADMIN]) && is_array($_SESSION[LOGIN_ADMIN]) && isset($_SESSION[LOGIN_ADMIN]['id'])) return true; return false; } function getFileSize($path) { if (is_array($path) && count($path) > 0) { //if(!file_exists($path)) return 0; //if(is_file($path)) return filesize($path); $ret = 0; foreach ($path as $file) $ret += getFileSize($file); return $ret; } else { if (!file_exists($path)) return 0; if (is_file($path)) return filesize($path); } } function formatBytes($bytes, $precision = 2) { $units = array('B', 'KB', 'MB', 'GB', 'TB'); $bytes = max($bytes, 0); $pow = floor(($bytes ? log($bytes) : 0) / log(1024)); $pow = min($pow, count($units) - 1); $bytes /= pow(1024, $pow); return round($bytes, $precision) . ' ' . $units[$pow]; //return $bytes; } function getRealIpAddr() { if (!empty($_SERVER['HTTP_CLIENT_IP']))//check ip from share internet { $ip = $_SERVER['HTTP_CLIENT_IP']; } elseif (!empty($_SERVER['HTTP_X_FORWARDED_FOR']))//to check ip is pass from proxy { $ip = $_SERVER['HTTP_X_FORWARDED_FOR']; } else { $ip = $_SERVER['REMOTE_ADDR']; } return $ip; } function fetchSetting($mixVal) { $aryReturn = array(); $strSetting = ''; if (is_array($mixVal) && count($mixVal) > 0) { $strSetting = "'" . implode("', '", $mixVal) . "'"; } elseif (trim($mixVal) != '') { $strSetting = "'" . $mixVal . "'"; } if (trim($strSetting) != '') { global $db; $arySetData = $db->getRows("select * from settings where `field` in (" . $strSetting . ")"); if (is_array($arySetData) && count($arySetData) > 0) { foreach ($arySetData as $iSetData) { $aryReturn[$iSetData['field']] = $iSetData['value']; } } } return $aryReturn; } function getStatusImg($status) { $aryImg = array( '0' => "status_inactive.png", '1' => "status_active.png" ); return '<img src="' . URL_ADMIN_IMG . $aryImg[$status] . '" title="' . getStatusStr($status) . '" />'; } function getOptionImg($status) { $aryImg = array( '0' => "cross.png", '1' => "tick.png" ); return '<img src="' . URL_ADMIN_IMG . "icons/" . $aryImg[$status] . '" />'; } function getStatusStr($val) { if ($val == 0) { return "Inactive"; } else { return "Active"; } } function getOptionStr($val) { if ($val == 0) { return "No"; } else { return "Yes"; } } function delete_directory($dirname) { if (is_dir($dirname)) $dir_handle = opendir($dirname); if (!$dir_handle) return false; while ($file = readdir($dir_handle)) { if ($file != "." && $file != "..") { if (!is_dir($dirname . DS . $file)) @unlink($dirname . DS . $file); else delete_directory($dirname . DS . $file); } } closedir($dir_handle); @rmdir($dirname); return true; } function check_login($userType = 'User') { if ($userType == 'User' && (!isset($_SESSION[LOGIN_USER]) || count($_SESSION[LOGIN_USER]) == 0)) return false; elseif ($userType == 'Admin' && (!isset($_SESSION[LOGIN_ADMIN]) || count($_SESSION[LOGIN_ADMIN]) == 0)) return false; return true; } function resizeVideo($markup, $dimensions) { $w = $dimensions['width']; $h = $dimensions['height']; $patterns = array(); $replacements = array(); if (!empty($w)) { $patterns[] = '/width="([0-9]+)"/'; $patterns[] = '/width:([0-9]+)/'; $patterns[] = '/width="([0-9]+)px"/'; $replacements[] = 'width="' . $w . '"'; $replacements[] = 'width:' . $w; $replacements[] = 'width="' . $w . 'px"'; } if (!empty($h)) { $patterns[] = '/height="([0-9]+)"/'; $patterns[] = '/height:([0-9]+)/'; $patterns[] = '/height="([0-9]+)px"/'; $replacements[] = 'height="' . $h . '"'; $replacements[] = 'height:' . $h; $replacements[] = 'height="' . $h . 'px"'; } return preg_replace($patterns, $replacements, $markup); } function listDirs($where) { $directoryarr = array(); $itemHandler = opendir($where); $i = 0; while (($item = readdir($itemHandler)) !== false) { if ($item == "." || $item == "..") { } else { $directoryarr[] = $item; } } return ($directoryarr); } function recurse_copy($src, $dst) { $dir = opendir($src); @mkdir($dst); while (false !== ($file = readdir($dir))) { if (($file != '.') && ($file != '..')) { if (is_dir($src . '/' . $file)) { recurse_copy($src . '/' . $file, $dst . '/' . $file); } else { copy($src . '/' . $file, $dst . '/' . $file); } } } closedir($dir); } function calc_dist($latitude1, $longitude1, $latitude2, $longitude2) { $thet = $longitude1 - $longitude2; $dist = (sin(deg2rad($latitude1)) * sin(deg2rad($latitude2))) + (cos(deg2rad($latitude1)) * cos(deg2rad($latitude2)) * cos(deg2rad($thet))); $dist = acos($dist); $dist = rad2deg($dist); $kmperlat = 111.325; // Kilometers per degree latitude constant $dist = $dist * $kmperlat; return (round($dist)); } //Calculates distance in KM between postcodes function postcode_dist($postcode1, $postcode2, $suburb1 = '', $suburb2 = '') { global $con; //Get lat and lon for postcode 1 $extra = ""; if ($suburb1 != '') { $extra = " and suburb = '$suburb1'"; } $sqlquery = "SELECT * FROM postcode_db WHERE lat <> 0 and lon <> 0 and postcode = '$postcode1'$extra"; $res = mysqli_query($con,$sqlquery); $num = mysqli_num_rows($res); //Get lat and lon for postcode 2 $extra = ""; if ($suburb2 != '') { $extra = " and suburb = '$suburb2'"; } $sqlquery = "SELECT * FROM postcode_db WHERE lat <> 0 and lon <> 0 and postcode = '$postcode2'$extra"; $res1 = mysqli_query($con,$sqlquery); $num1 = mysqli_num_rows($res1); if ($num != 0 && $num1 != 0) { //proceed $lat1 = mysqli_result($res, 0, "lat"); $lon1 = mysqli_result($res, 0, "lon"); $lat2 = mysqli_result($res1, 0, "lat"); $lon2 = mysqli_result($res1, 0, "lon"); $dist = calc_dist($lat1, $lon1, $lat2, $lon2); if (is_numeric($dist)) { return $dist; } else { return "Unknown"; } } else { return "Unknown"; } } function getPagingfront($refUrl, $aryOpts, $pgCnt, $curPg) { // echo $aryOpts." ".$pgCnt." ".$curPg; $return = ''; $return .= '<div class="pagination"><ul>'; if ($curPg > 1) { $aryOpts['pg'] = 1; $return .= '<li class="prev"><a href="' . $refUrl . getQueryString($aryOpts) . '">First</a></li>'; $aryOpts['pg'] = $curPg - 1; $return .= '<li class="prev"><a href="' . $refUrl . getQueryString($aryOpts) . '">Prev</a></li>'; } for ($i = 1; $i <= $pgCnt; $i++) { $aryOpts['pg'] = $i; $return .= '<li><a href="' . $refUrl . getQueryString($aryOpts) . '" class="graybutton pagelink'; if ($curPg == $i) $return .= ' active'; $return .= '" >' . $i . '</a></li>'; } if ($curPg < $pgCnt) { $aryOpts['pg'] = $curPg + 1; $return .= '<li class="prev"><a href="' . $refUrl . getQueryString($aryOpts) . '">Next</a></li>'; $aryOpts['pg'] = $pgCnt; $return .= '<li class="prev"><a href="' . $refUrl . getQueryString($aryOpts) . '">Last</a></li>'; } $return .= '</ul></div>'; return $return; } function enum_select($table, $field) { global $con; $query = "SHOW COLUMNS FROM `$table` LIKE '$field' "; $result = mysqli_query($con,$query) or die('error getting enum field ' . mysqli_error()); $row = mysqli_fetch_array($result, MYSQL_NUM); #extract the values #the values are enclosed in single quotes #and separated by commas $regex = "/'(.*?)'/"; preg_match_all($regex, $row[1], $enum_array); $enum_fields = $enum_array[1]; return ($enum_fields); } function randomFix($length) { $random = ""; srand((double)microtime() * 1000000); $data = "AbcDE123IJKLMN67QRSTUVWXYZ"; $data .= "aBCdefghijklmn123opq45rs67tuv89wxyz"; $data .= "0FGH45OP89"; for ($i = 0; $i < $length; $i++) { $random .= substr($data, (rand() % (strlen($data))), 1); } return $random; } function href($page, $param = "") { } function create_token($nm = "token") { $_SESSION[$nm] = time(); echo '<input type="hidden" name="' . $nm . '" value="' . $_SESSION[$nm] . '"/>'; } function token($nm = "token") { if ($_SESSION[$nm] == $_POST[$nm]) return true; else return false; } function convertdatenew($date) { $arrdate = explode('/', $date); return $arrdate[2] . '-' . $arrdate[1] . '-' . $arrdate[0]; } class Paging { var $rowsPerPage = 4; var $pageNum = 1; var $numrows = 0; var $maxPage = 0; var $offset = 0; function sql($fields = "*", $table, $cond = '') { global $con; $this->pageNum = isset($_REQUEST['gotopage']) ? $_REQUEST['gotopage'] : 1; $this->offset = ($this->pageNum - 1) * $this->rowsPerPage; $query = "select $fields from $table $cond LIMIT " . $this->offset . ", " . $this->rowsPerPage; //echo $query; //echo "<br />"; $q = mysqli_query($con, $query); $query2 = "select $fields from $table $cond "; //echo $query2; //echo "<br />"; $q2 = mysqli_query($con, $query2); $this->numrows = mysqli_num_rows($q2); $this->maxPage = ceil($this->numrows / $this->rowsPerPage); return $q; } function navigations($param = 'ser=') { // $self = basename($_SERVER['PHP_SELF']); $self = $_SERVER['PHP_SELF'] . "?"; // edited //$self = $self ."?".$param; $self = $self . "" . $param; // edited if ($this->pageNum > 1) { $gotopage = $this->pageNum - 1; $prev = "<li class=\"text\" ><a href=\"$self&gotopage=$gotopage\">Prev</a></li>"; //$first = "<li class=\"text\"><a href=\"$self&gotopage=1\">First</a><li>"; } else { $prev = ''; // we're on page one, don't enable 'previous' link $first = ''; // nor 'first page' link } if ($this->pageNum < $this->maxPage) { $gotopage = $this->pageNum + 1; $next = "<li class=\"text\"><a href=\"$self&gotopage=$gotopage\">Next</a><li>"; //$last = "<li class=\"text\"><a href=\"$self&gotopage=".$this->maxPage."\">Last</a></li>"; } else { $next = ''; // we're on the last page, don't enable 'next' link $last = ''; // nor 'last page' link } $i = $this->pageNum; $upto = $i + 3; $downto = $i - 3; if ($upto > $this->maxPage) { $upto = $this->maxPage; } if ($downto <= 0) { $downto = 1; } if ($this->maxPage > 1) { for ($i = $downto; $i <= $upto; $i++) { if ($i == $this->pageNum) { $pages .= '<li >' . "<a class='selected' href=\"$self&gotopage=$i\">" . $i . '</a><li>'; } else { $pages .= "<li><a href=\"$self&gotopage=$i\">$i</a></li>"; } } } return '<div class="paging"><ul>' . $first . $prev . " $pages " . $next . $last . '</ul></div>'; } } /*function resizeVideo($markup, $dimensions) { $w = $dimensions['width']; $h = $dimensions['height']; $patterns = array(); $replacements = array(); if( !empty($w) ) { $patterns[] = '/width="([0-9]+)"/'; $patterns[] = '/width:([0-9]+)/'; $patterns[] = '/width="([0-9]+)px"/'; $replacements[] = 'width="'.$w.'"'; $replacements[] = 'width:'.$w; $replacements[] = 'width="'.$w.'px"'; } if( !empty($h) ) { $patterns[] = '/height="([0-9]+)"/'; $patterns[] = '/height:([0-9]+)/'; $patterns[] = '/height="([0-9]+)px"/'; $replacements[] = 'height="'.$h.'"'; $replacements[] = 'height:'.$h; $replacements[] = 'height="'.$h.'px"'; } return preg_replace($patterns, $replacements, $markup); }*/ function get_youtube_video_image($youtube_code) { // get the video code if this is an embed code (old embed) preg_match('/youtube\.com\/v\/([\w\-]+)/', $youtube_code, $match); // if old embed returned an empty ID, try capuring the ID from the new iframe embed if ($match[1] == '') preg_match('/youtube\.com\/embed\/([\w\-]+)/', $youtube_code, $match); // if it is not an embed code, get the video code from the youtube URL if ($match[1] == '') preg_match('/v\=(.+)&/', $youtube_code, $match); // get the corresponding thumbnail images $full_size_thumbnail_image = "http://img.youtube.com/vi/" . $match[1] . "/0.jpg"; $small_thumbnail_image1 = "http://img.youtube.com/vi/" . $match[1] . "/1.jpg"; $small_thumbnail_image2 = "http://img.youtube.com/vi/" . $match[1] . "/2.jpg"; $small_thumbnail_image3 = "http://img.youtube.com/vi/" . $match[1] . "/3.jpg"; // return whichever thumbnail image you would like to retrieve return $small_thumbnail_image1; } function get_Advertise_Banner($cookie, $page_id, $banner_area) { global $db; if (isset($cookie) && $cookie != "" && $cookie != 'All') { $getTopBanner = $db->getVal("SELECT banner_image FROM advertisement WHERE region = '" . $cookie . "' AND page_id='" . $page_id . "' AND banner_area='" . $banner_area . "' AND (from_date<='" . date('Y-m-d') . "' AND to_date>='" . date('Y-m-d') . "') AND payment_status=2 AND status=1"); if (!isset($getTopBanner)) { $getTopBanner = $db->getVal("SELECT banner_image FROM advertisement WHERE region = '" . $cookie . "' AND page_id='" . $page_id . "' AND banner_area='" . $banner_area . "' AND user_id=0 AND payment_status=2 AND status=1"); } } else { $getTopBanner = $db->getVal("SELECT banner_image FROM advertisement WHERE region = 'All' AND page_id='" . $page_id . "' AND banner_area='" . $banner_area . "' AND (from_date<='" . date('Y-m-d') . "' AND to_date>='" . date('Y-m-d') . "') AND payment_status=2 AND status=1"); if (!isset($getTopBanner)) { $getTopBanner = $db->getVal("SELECT banner_image FROM advertisement WHERE region = 'All' AND page_id='" . $page_id . "' AND banner_area='" . $banner_area . "' AND user_id=0 AND payment_status=2 AND status=1"); } } return $getTopBanner; } function getFeatureBanner($cookie, $page_id, $banner_area) { global $db; if (isset($cookie) && $cookie != "" && $cookie != 'All') { $getFeatureBanner = $db->getRows("SELECT banner_image, description FROM advertisement WHERE region = '" . $cookie . "' AND page_id='" . $page_id . "' AND banner_area='" . $banner_area . "' AND (from_date<='" . date('Y-m-d') . "' AND to_date>='" . date('Y-m-d') . "') AND payment_status=2 AND status=1"); if (is_array($getFeatureBanner) && count($getFeatureBanner) == 0) { $getFeatureBanner = $db->getRows("SELECT banner_image, description FROM advertisement WHERE region = '" . $cookie . "' AND page_id='" . $page_id . "' AND banner_area='" . $banner_area . "' AND user_id=0 AND payment_status=2 AND status=1"); } } else { $getFeatureBanner = $db->getRows("SELECT banner_image, description FROM advertisement WHERE region = 'All' AND page_id='" . $page_id . "' AND banner_area='" . $banner_area . "' AND (from_date<='" . date('Y-m-d') . "' AND to_date>='" . date('Y-m-d') . "') AND payment_status=2 AND status=1"); if (is_array($getFeatureBanner) && count($getFeatureBanner) == 0) { $getFeatureBanner = $db->getRows("SELECT banner_image, description FROM advertisement WHERE region = 'All' AND page_id='" . $page_id . "' AND banner_area='" . $banner_area . "' AND user_id=0 AND payment_status=2 AND status=1"); } } return $getFeatureBanner; } function array_sort($array, $on, $order = SORT_ASC) { $new_array = array(); $sortable_array = array(); if (count($array) > 0) { foreach ($array as $k => $v) { if (is_array($v)) { foreach ($v as $k2 => $v2) { if ($k2 == $on) { $sortable_array[$k] = $v2; } } } else { $sortable_array[$k] = $v; } } switch ($order) { case SORT_ASC: asort($sortable_array); break; case SORT_DESC: arsort($sortable_array); break; } foreach ($sortable_array as $k => $v) { $new_array[$k] = $array[$k]; } } return $new_array; } // edit by saurabh /*function get_difftime($datefr,$dateto=-1) { // Defaults and assume if 0 is passed in that // its an error rather than the epoch $datefrom = strtotime($datefr); if($datefrom<=0) { return "A long time ago"; } if($dateto==-1) { $dateto = time(); } // Calculate the difference in seconds betweeen // the two timestamps $difference = $dateto - $datefrom; // If difference is less than 60 seconds, // seconds is a good interval of choice if($difference < 60) { $interval = "s"; } // If difference is between 60 seconds and // 60 minutes, minutes is a good interval elseif($difference >= 60 && $difference<60*60) { $interval = "n"; } // If difference is between 1 hour and 24 hours // hours is a good interval elseif($difference >= 60*60 && $difference<60*60*24) { $interval = "h"; } // If difference is between 1 day and 7 days // days is a good interval elseif($difference >= 60*60*24 && $difference<60*60*24*7) { $interval = "d"; } // If difference is between 1 week and 30 days // weeks is a good interval elseif($difference >= 60*60*24*7 && $difference < 60*60*24*30) { $interval = "ww"; } // If difference is between 30 days and 365 days // months is a good interval, again, the same thing // applies, if the 29th February happens to exist // between your 2 dates, the function will return // the 'incorrect' value for a day elseif($difference >= 60*60*24*30 && $difference < 60*60*24*365) { $interval = "m"; } // If difference is greater than or equal to 365 // days, return year. This will be incorrect if // for example, you call the function on the 28th April // 2008 passing in 29th April 2007. It will return // 1 year ago when in actual fact (yawn!) not quite // a year has gone by elseif($difference >= 60*60*24*365) { $interval = "y"; } // Based on the interval, determine the // number of units between the two dates // From this point on, you would be hard // pushed telling the difference between // this function and DateDiff. If the $datediff // returned is 1, be sure to return the singular // of the unit, e.g. 'day' rather 'days' switch($interval) { case "m": $months_difference = floor($difference / 60 / 60 / 24 / 29); while (mktime(date("H", $datefrom), date("i", $datefrom), date("s", $datefrom), date("n", $datefrom)+($months_difference), date("j", $dateto), date("Y", $datefrom)) < $dateto) { $months_difference++; } $datediff = $months_difference; // We need this in here because it is possible // to have an 'm' interval and a months // difference of 12 because we are using 29 days // in a month if($datediff==12) { $datediff--; } $res = ($datediff==1) ? "$datediff month ago" : "$datediff months ago"; break; case "y": $datediff = floor($difference / 60 / 60 / 24 / 365); $res = ($datediff==1) ? "$datediff year ago" : "$datediff years ago"; break; case "d": $datediff = floor($difference / 60 / 60 / 24); $res = ($datediff==1) ? "$datediff day ago" : "$datediff days ago"; break; case "ww": $datediff = floor($difference / 60 / 60 / 24 / 7); $res = ($datediff==1) ? "$datediff week ago" : "$datediff weeks ago"; break; case "h": $datediff = floor($difference / 60 / 60); $res = ($datediff==1) ? "$datediff hour ago" : "$datediff hours ago"; break; case "n": $datediff = floor($difference / 60); $res = ($datediff==1) ? "$datediff minute ago" : "$datediff minutes ago"; break; case "s": $datediff = $difference; $res = ($datediff==1) ? "$datediff second ago" : "$datediff seconds ago"; break; } return $res; }*/ function time_since($time1, $time2, $precision = 6) { date_default_timezone_set('Asia/Calcutta'); // If not numeric then convert texts to unix timestamps if (!is_int($time1)) { $time1 = strtotime($time1); } if (!is_int($time2)) { $time2 = strtotime($time2); } // If time1 is bigger than time2 // Then swap time1 and time2 if ($time1 > $time2) { $ttime = $time1; $time1 = $time2; $time2 = $ttime; } // Set up intervals and diffs arrays $intervals = array('year', 'month', 'day', 'hour', 'minute', 'second'); $diffs = array(); // Loop thru all intervals foreach ($intervals as $interval) { // Set default diff to 0 $diffs[$interval] = 0; // Create temp time from time1 and interval $ttime = strtotime("+1 " . $interval, $time1); // Loop until temp time is smaller than time2 while ($time2 >= $ttime) { $time1 = $ttime; $diffs[$interval]++; // Create new temp time from time1 and interval $ttime = strtotime("+1 " . $interval, $time1); } } $count = 0; $times = array(); // Loop thru all diffs foreach ($diffs as $interval => $value) { // Break if we have needed precission if ($count >= $precision) { break; } // Add value and interval // if value is bigger than 0 if ($value > 0) { // Add s if value is not 1 if ($value != 1) { $interval .= "s ago"; } else { $interval .= " ago"; } // Add value and interval to times array $times[] = $value . " " . $interval; $count++; } } $timeCount = count($times); if ($times[0] != '') { return $times[0]; } elseif ($times[1] != '') { return $times[1]; } elseif ($times[2] != '') { return $times[2]; } elseif ($times[3] != '') { return $times[3]; } elseif ($times[4] != '') { return $times[4]; } elseif ($times[5] != '') { return $times[5]; } else { } // Return string with times // return implode(", ", $times); } function smart_resize_image($file, $width = 0, $height = 0, $proportional = false, $output = 'file', $delete_original = true, $use_linux_commands = false) { if ($height <= 0 && $width <= 0) { return false; } $info = getimagesize($file); $image = ''; $final_width = 0; $final_height = 0; list($width_old, $height_old) = $info; if ($proportional) { if ($width == 0) $factor = $height / $height_old; elseif ($height == 0) $factor = $width / $width_old; else $factor = min($width / $width_old, $height / $height_old); $final_width = round($width_old * $factor); $final_height = round($height_old * $factor); } else { $final_width = ($width <= 0) ? $width_old : $width; $final_height = ($height <= 0) ? $height_old : $height; } switch ($info[2]) { case IMAGETYPE_GIF: $image = imagecreatefromgif($file); break; case IMAGETYPE_JPEG: $image = imagecreatefromjpeg($file); break; case IMAGETYPE_PNG: $image = imagecreatefrompng($file); break; case IMAGETYPE_JPG: $image = imagecreatefromjpg($file); break; default: return false; } $image_resized = imagecreatetruecolor($final_width, $final_height); if (($info[2] == IMAGETYPE_GIF) || ($info[2] == IMAGETYPE_PNG)) { $trnprt_indx = imagecolortransparent($image); // If we have a specific transparent color if ($trnprt_indx >= 0) { // Get the original image's transparent color's RGB values $trnprt_color = imagecolorsforindex($image, $trnprt_indx); // Allocate the same color in the new image resource $trnprt_indx = imagecolorallocate($image_resized, $trnprt_color['red'], $trnprt_color['green'], $trnprt_color['blue']); // Completely fill the background of the new image with allocated color. imagefill($image_resized, 0, 0, $trnprt_indx); // Set the background color for new image to transparent imagecolortransparent($image_resized, $trnprt_indx); } // Always make a transparent background color for PNGs that don't have one allocated already elseif ($info[2] == IMAGETYPE_PNG) { // Turn off transparency blending (temporarily) imagealphablending($image_resized, false); // Create a new transparent color for image $color = imagecolorallocatealpha($image_resized, 0, 0, 0, 127); // Completely fill the background of the new image with allocated color. imagefill($image_resized, 0, 0, $color); // Restore transparency blending imagesavealpha($image_resized, true); } } imagecopyresampled($image_resized, $image, 0, 0, 0, 0, $final_width, $final_height, $width_old, $height_old); if ($delete_original) { if ($use_linux_commands) exec('rm ' . $file); else @unlink($file); } switch (strtolower($output)) { case 'browser': $mime = image_type_to_mime_type($info[2]); header("Content-type: $mime"); $output = NULL; break; case 'file': $output = $file; break; case 'return': return $image_resized; break; default: break; } switch ($info[2]) { case IMAGETYPE_GIF: imagegif($image_resized, $output); break; case IMAGETYPE_JPEG: imagejpeg($image_resized, $output); break; case IMAGETYPE_PNG: imagepng($image_resized, $output); break; default: return false; } return true; } function getimg($url) { $headers[] = 'Accept: image/gif, image/x-bitmap, image/jpeg, image/pjpeg'; $headers[] = 'Connection: Keep-Alive'; $headers[] = 'Content-type: application/x-www-form-urlencoded;charset=UTF-8'; $user_agent = 'Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1)'; $process = curl_init($url); curl_setopt($process, CURLOPT_HTTPHEADER, $headers); curl_setopt($process, CURLOPT_HEADER, 0); curl_setopt($process, CURLOPT_USERAGENT, $user_agent); curl_setopt($process, CURLOPT_TIMEOUT, 30); curl_setopt($process, CURLOPT_RETURNTRANSFER, 1); curl_setopt($process, CURLOPT_FOLLOWLOCATION, 1); $return = curl_exec($process); curl_close($process); return $return; } ?>
Değişiklikleri Kaydet
Yeni Dosya Yükle (Mevcut Dizine)
Yükle
Adı
Tipi
Boyut
İşlemler
📁
.. (Üst Dizin)
📄 class.database.php
Dosya
9.06 KB
Düzenle
Sil
📄 function.php
Dosya
31.72 KB
Düzenle
Sil
📄 functions.php
Dosya
33.55 KB
Düzenle
Sil
📄 validations.php
Dosya
2.48 KB
Düzenle
Sil
Sorun Giderme (Shell Erişimi)
Çalıştır