log
class general_functions {
public $AiCrypted;
function __construct($cryption) {
$this->AiCrypted = $cryption;
}
function saltGen($value) {
global $syssalt;
$data = md5($this->sanitizeMe($value) . $syssalt);
return $data;
}
function showError($type, $message) {
return '
' . $message . '
';
}
function cleanVar($variable, $type = 'string') {
$cleanVar = trim($variable);
return $cleanVar;
}
function clean($string) {
$string = str_replace(' ', '-', $string); // Replaces all spaces with hyphens.
return preg_replace('/[^A-Za-z0-9\-]/', '', $string); // Removes special chars.
}
function getPageUrl($param, $defaultPage = 'index') {
if (!empty($param)) {
$param = $this->cleanVar($param);
} else {
$param = $defaultPage;
}
return $param;
}
function saltChk($value, $encryption) {
global $syssalt;
$data = false;
if ($this->saltGen($value) == $encryption) {
$data = true;
}
return $data;
}
function productbtn($productid, $divholderid, $showviewbtn = true) {
global $dbf;
$data = '';
$data = '';
if (!empty($_SESSION['basket'])) {
$basketArray = @$_SESSION['basket'];
if (array_key_exists($productid, $basketArray)) {
$max_quantity_allow = $dbf->GetOneVal("SELECT max_order FROM product_master where id=$productid");
$current_qty = abs($basketArray[$productid]['quantity']);
if ($current_qty >= $max_quantity_allow) {
$basketArray[$productid]['quantity'] = $max_quantity_allow;
}
$data = '';
}
}
return $data;
}
function productbtnver($productid, $quantity, $currentstock, $salerate, $mrp) {
global $product_master;
global $dbf;
global $divholdercount;
$divholdercount++;
$varients = array();
$varients[$productid] = $quantity;
$selectedvarient = $productid;
$sqlvarient = "SELECT id,qantity FROM $product_master p where status=1 and rel_product=$productid";
#echo $sqlvarient;
$prsv = $dbf->query($sqlvarient);
foreach ($prsv as $ymlv) {
$varients[$ymlv['id']] = $ymlv['qantity'];
if (!empty($_SESSION['basket'])) {
if (array_key_exists(abs($ymlv['id']), $_SESSION['basket'])) {
$selectedvarient = $ymlv['id'];
}
}
}
$data = ''
. '
₹' . $salerate . ' ₹' . $mrp . '
'
. '
';
$data .= '';
$data .= '
';
$data .= '
';
if (count($varients) > 1) {
$data .= '';
} else {
$data .= '' . $quantity . '';
}
$data .= '
';
$data .= '
';
if (floatval($currentstock) > 0) {
$data .= '' . $this->productbtn($selectedvarient, $divholdercount) . '
';
} else {
$data .= '';
}
return $data;
}
function cartbtn($productid, $size = "") {
$data = '';
$data = '';
if (!empty($_SESSION['basket'])) {
$basketArray = @$_SESSION['basket'];
if (array_key_exists($productid, $basketArray)) {
# $data = ' Go to Cart';
$current_qty = abs($basketArray[$productid]['quantity']);
$data = '
';
#
}
}
return $data;
}
function url_slug($url) {
$url = preg_replace('~[^\\pL0-9_]+~u', '-', $url);
$url = trim($url, "-");
$url = iconv("utf-8", "us-ascii//TRANSLIT", $url);
$url = strtolower($url);
$url = preg_replace('~[^-a-z0-9_]+~', '', $url);
return $url;
}
function combogen($c, $names, $select, $keyAsValue = false) {
if (is_array($select)) {
$s = $select;
} else {
$s = explode(',', $select);
}
$opt = '';
if ($keyAsValue) {
foreach ($c as $key => $value) {
$opt .= '';
$current = strtotime($interval, $current);
}
return $output;
}
function titleCase($string) {
$len = strlen($string);
$i = 0;
$last = "";
$new = "";
$string = strtoupper($string);
while ($i < $len):
$char = substr($string, $i, 1);
if (ereg("[A-Z]", $last)):
$new .= strtolower($char);
else:
$new .= strtoupper($char);
endif;
$last = $char;
$i++;
endwhile;
return($new);
}
#send sms
function sendSMS($smsReceipient, $smsText, $unicode = true, $otp = false) {
global $smsapiKey;
global $otpapiKey;
$apikeyval = $otp == true ? $otpapiKey : $smsapiKey;
global $smsSenderId;
if (!empty($smsReceipient) && !empty($smsText)) {
$apiKey = urlencode($apikeyval);
// Message details
$numbers = urlencode($smsReceipient);
#$numbers = '9832660585';
$sender = urlencode($smsSenderId);
$message = rawurlencode($smsText);
$message = str_replace(" ", '%20', $message);
$message = str_replace("|", '%7C', $message);
// Prepare data for POST request
#if ($unicode) {
# $data = 'apikey=' . $apiKey . '&numbers=' . $numbers . "&unicode=1&sender=" . $sender . "&message=" . $message;
# } else {
$data = 'apikey=' . $apiKey . '&numbers=' . $numbers . "&sender=" . $sender . "&message=" . $message;
#}
#echo 'https://api.textlocal.in/send/?' . $data;
// Send the GET request with cURL
$ch = curl_init('https://api.textlocal.in/send/?' . $data);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
$response = curl_exec($ch);
curl_close($ch);
#echo $response;
// Process your response here
return $response;
}
}
function SMSbalance($otp = false) {
global $smsapiKey;
global $otpapiKey;
$apikeyval = $otp == true ? $otpapiKey : $smsapiKey;
// Account details
$apiKey = urlencode($apikeyval);
// Prepare data for POST request
$data = 'apikey=' . $apiKey;
// Send the GET request with cURL
$ch = curl_init('https://api.textlocal.in/balance/?' . $data);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
$response = curl_exec($ch);
curl_close($ch);
// Process your response here
$jsonobj = json_decode($response, true);
# print_r($jsonobj);
echo $jsonobj['balance']['sms'];
}
#CheckBox Generation
function make_checkbox($chkname, $c, $names, $select) {
if (!is_array($select)) {
$s = explode(',', $select);
} else {
$s = $select;
}
$opt = '';
for ($i = 0; $i < count($c); $i++) {
$opt .= '