Файл: Update 2.1.2/includes/functions.php
Строк: 422
<?php
function protect($string) {
$protection = htmlspecialchars(trim($string), ENT_QUOTES);
return $protection;
}
function randomHash($lenght = 7) {
$random = substr(md5(rand()),0,$lenght);
return $random;
}
function isValidURL($url) {
return preg_match('|^http(s)?://[a-z0-9-]+(.[a-z0-9-]+)*(:[0-9]+)?(/.*)?$|i', $url);
}
function checkAdminSession() {
if(isset($_SESSION['s_adm_username']) and isset($_SESSION['s_adm_uid'])) {
return true;
} else {
return false;
}
}
function getTotalPayed() {
global $db;
$earnings = 0;
$query = $db->query("SELECT * FROM withdrawals WHERE status='2'");
if($query->num_rows>0) {
while($row = $query->fetch_assoc()) {
$rows[] = $row;
}
foreach($rows as $row) {
$earnings = $earnings+$row['amount'];
}
}
return $earnings;
}
function isValidUsername($str) {
return preg_match('/^[a-zA-Z0-9-_]+$/',$str);
}
function isValidEmail($str) {
return filter_var($str, FILTER_VALIDATE_EMAIL);
}
function checkSession() {
if(isset($_SESSION['susername']) and isset($_SESSION['suid'])) {
return true;
} else {
return false;
}
}
function success($text) {
return '<div class="alert alert-success"><i class="fa fa-check"></i> '.$text.'</div>';
}
function error($text) {
return '<div class="alert alert-danger"><i class="fa fa-times"></i> '.$text.'</div>';
}
function info($text) {
return '<div class="alert alert-info"><i class="fa fa-info-circle"></i> '.$text.'</div>';
}
function admin_pagination($query,$ver,$per_page = 10,$page = 1, $url = '?') {
global $db;
$query = $db->query("SELECT * FROM $query");
$total = $query->num_rows;
$adjacents = "2";
$page = ($page == 0 ? 1 : $page);
$start = ($page - 1) * $per_page;
$prev = $page - 1;
$next = $page + 1;
$lastpage = ceil($total/$per_page);
$lpm1 = $lastpage - 1;
$pagination = "";
if($lastpage > 1)
{
$pagination .= "<ul class='pagination'>";
if ($lastpage < 7 + ($adjacents * 2))
{
for ($counter = 1; $counter <= $lastpage; $counter++)
{
if ($counter == $page)
$pagination.= "<li><a class='active'>$counter</a></li>";
else
$pagination.= "<li><a href='$ver&page=$counter'>$counter</a></li>";
}
}
elseif($lastpage > 5 + ($adjacents * 2))
{
if($page < 1 + ($adjacents * 2))
{
for ($counter = 1; $counter < 4 + ($adjacents * 2); $counter++)
{
if ($counter == $page)
$pagination.= "<li><a class='active'>$counter</a></li>";
else
$pagination.= "<li><a href='$ver&page=$counter'>$counter</a></li>";
}
$pagination.= "<li class='disabled'>...</li>";
$pagination.= "<li><a href='$ver&page=$lpm1'>$lpm1</a></li>";
$pagination.= "<li><a href='$ver&page=$lastpage'>$lastpage</a></li>";
}
elseif($lastpage - ($adjacents * 2) > $page && $page > ($adjacents * 2))
{
$pagination.= "<li><a href='$ver&page=1'>1</a></li>";
$pagination.= "<li><a href='$ver&page=2'>2</a></li>";
$pagination.= "<li class='disabled'><a>...</a></li>";
for ($counter = $page - $adjacents; $counter <= $page + $adjacents; $counter++)
{
if ($counter == $page)
$pagination.= "<li><a class='active'>$counter</a></li>";
else
$pagination.= "<li><a href='$ver&page=$counter'>$counter</a></li>";
}
$pagination.= "<li class='disabled'><a>..</a></li>";
$pagination.= "<li><a href='$ver&page=$lpm1'>$lpm1</a></li>";
$pagination.= "<li><a href='$ver&page=$lastpage'>$lastpage</a></li>";
}
else
{
$pagination.= "<li><a href='$ver&page=1'>1</a></li>";
$pagination.= "<li><a href='$ver&page=2'>2</a></li>";
$pagination.= "<li class='disabled'><a>..</a></li>";
for ($counter = $lastpage - (2 + ($adjacents * 2)); $counter <= $lastpage; $counter++)
{
if ($counter == $page)
$pagination.= "<li><a class='active'>$counter</a></li>";
else
$pagination.= "<li><a href='$ver&page=$counter'>$counter</a></li>";
}
}
}
if ($page < $counter - 1){
$pagination.= "<li><a href='$ver&page=$next'>Next</a></li>";
$pagination.= "<li><a href='$ver&page=$lastpage'>Last</a></li>";
}else{
$pagination.= "<li><a class='disabled'>Next</a></li>";
$pagination.= "<li><a class='disabled'>Last</a></li>";
}
$pagination.= "</ul>n";
}
return $pagination;
}
function web_pagination($query,$ver,$per_page = 10,$page = 1, $url = '?') {
global $db;
$query = $db->query("SELECT * FROM $query");
$total = $query->num_rows;
$adjacents = "2";
$page = ($page == 0 ? 1 : $page);
$start = ($page - 1) * $per_page;
$prev = $page - 1;
$next = $page + 1;
$lastpage = ceil($total/$per_page);
$lpm1 = $lastpage - 1;
$pagination = "";
if($lastpage > 1)
{
$pagination .= "<ul class='pagination'>";
if ($lastpage < 7 + ($adjacents * 2))
{
for ($counter = 1; $counter <= $lastpage; $counter++)
{
if ($counter == $page)
$pagination.= "<li><a class='active'>$counter</a></li>";
else
$pagination.= "<li><a href='$ver/$counter'>$counter</a></li>";
}
}
elseif($lastpage > 5 + ($adjacents * 2))
{
if($page < 1 + ($adjacents * 2))
{
for ($counter = 1; $counter < 4 + ($adjacents * 2); $counter++)
{
if ($counter == $page)
$pagination.= "<li><a class='active'>$counter</a></li>";
else
$pagination.= "<li><a href='$ver/$counter'>$counter</a></li>";
}
$pagination.= "<li class='disabled'>...</li>";
$pagination.= "<li><a href='$ver/$lpm1'>$lpm1</a></li>";
$pagination.= "<li><a href='$ver/$lastpage'>$lastpage</a></li>";
}
elseif($lastpage - ($adjacents * 2) > $page && $page > ($adjacents * 2))
{
$pagination.= "<li><a href='$ver/1'>1</a></li>";
$pagination.= "<li><a href='$ver/2'>2</a></li>";
$pagination.= "<li class='disabled'><a>...</a></li>";
for ($counter = $page - $adjacents; $counter <= $page + $adjacents; $counter++)
{
if ($counter == $page)
$pagination.= "<li><a class='active'>$counter</a></li>";
else
$pagination.= "<li><a href='$ver/$counter'>$counter</a></li>";
}
$pagination.= "<li class='disabled'><a>..</a></li>";
$pagination.= "<li><a href='$ver/$lpm1'>$lpm1</a></li>";
$pagination.= "<li><a href='$ver/$lastpage'>$lastpage</a></li>";
}
else
{
$pagination.= "<li><a href='$ver/1'>1</a></li>";
$pagination.= "<li><a href='$ver/2'>2</a></li>";
$pagination.= "<li class='disabled'><a>..</a></li>";
for ($counter = $lastpage - (2 + ($adjacents * 2)); $counter <= $lastpage; $counter++)
{
if ($counter == $page)
$pagination.= "<li><a class='active'>$counter</a></li>";
else
$pagination.= "<li><a href='$ver/$counter'>$counter</a></li>";
}
}
}
if ($page < $counter - 1){
$pagination.= "<li><a href='$ver/$next'>Next</a></li>";
$pagination.= "<li><a href='$ver/$lastpage'>Last</a></li>";
}else{
$pagination.= "<li><a class='disabled'>Next</a></li>";
$pagination.= "<li><a class='disabled'>Last</a></li>";
}
$pagination.= "</ul>n";
}
return $pagination;
}
function idinfo($uid,$value) {
global $db;
$query = $db->query("SELECT * FROM users WHERE id='$uid'");
$row = $query->fetch_assoc();
return $row[$value];
}
function check_unpayed() {
global $db;
$query = $db->query("SELECT * FROM exchanges WHERE status='1' ORDER BY id");
if($query->num_rows>0) {
while($row = $query->fetch_assoc()) {
$time = $row['created']+86400;
if(time() > $time) {
$update = $db->query("UPDATE exchanges SET status='6' WHERE id='$row[id]'");
}
}
}
}
function getLanguage($url, $ln = null, $type = null) {
// Type 1: Output the available languages
// Type 2: Change the path for the /requests/ folder location
// Set the directory location
if($type == 2) {
$languagesDir = '../languages/';
} else {
$languagesDir = './languages/';
}
// Search for pathnames matching the .png pattern
$language = glob($languagesDir . '*.php', GLOB_BRACE);
if($type == 1) {
// Add to array the available images
foreach($language as $lang) {
// The path to be parsed
$path = pathinfo($lang);
// Add the filename into $available array
$available .= '<a href="'.$url.'index.php?lang='.$path['filename'].'">'.ucfirst(strtolower($path['filename'])).'</a> - ';
}
return substr($available, 0, -3);
} else {
// If get is set, set the cookie and stuff
$lang = 'English'; // DEFAULT LANGUAGE
if($type == 2) {
$path = '../languages/';
} else {
$path = './languages/';
}
if(isset($_GET['lang'])) {
if(in_array($path.$_GET['lang'].'.php', $language)) {
$lang = $_GET['lang'];
setcookie('lang', $lang, time() + (10 * 365 * 24 * 60 * 60)); // Expire in one month
} else {
setcookie('lang', $lang, time() + (10 * 365 * 24 * 60 * 60)); // Expire in one month
}
} elseif(isset($_COOKIE['lang'])) {
if(in_array($path.$_COOKIE['lang'].'.php', $language)) {
$lang = $_COOKIE['lang'];
}
} else {
setcookie('lang', $lang, time() + (10 * 365 * 24 * 60 * 60)); // Expire in one month
}
if(in_array($path.$lang.'.php', $language)) {
return $path.$lang.'.php';
}
}
}
function getIcon($name) {
global $db, $settings;
$width = "25px";
$height = "25px";
$path = "assets/icons/";
if($name == "PayPal") { $icon = 'PayPal.png'; }
elseif($name == "Payeer") { $icon = 'Payeer.png'; }
elseif($name == "Perfect Money") { $icon = 'PerfectMoney.png'; }
elseif($name == "AdvCash") { $icon = 'AdvCash.png'; }
elseif($name == "OKPay") { $icon = 'OKPay.png'; }
elseif($name == "Entromoney") { $icon = 'Entromoney.png'; }
elseif($name == "Payza") { $icon = 'Payza.png'; }
elseif($name == "Bitcoin") { $icon = 'Bitcoin.png'; }
elseif($name == "Bank Transfer") { $icon = 'BankTransfer.png'; }
elseif($name == "Western union") { $icon = 'Westernunion.png'; }
elseif($name == "Moneygram") { $icon = 'Moneygram.png'; }
else { $icon = ''; }
return '<img src="'.$settings[url].$path.$icon.'" width="'.$width.'" height="'.$height.'">';
}
?>