]]jkjjgdjffksdkdxdsghfghdfghfgdfsdsdfsdfsfdsbcxvxcbccwewqeqwewqskfgj
במ12[cxvbcxvbxcvbcxvcxvbcvxcvbsdfsdfsdfsdfsdfsdfxcvbxcvxbbxqwqewqewv;'
/
home
/
u506006416
/
domains
/
crystalmiracle.co.in
/
public_html
/
admin
/
include
/
Upload FileeE
HOME
<?php date_default_timezone_set("Asia/Kolkata"); define("BASE_URL", "https://crystalmiracle.co.in/"); class config { private $dbhost = "localhost"; private $dbusername = "u506006416_crystal"; private $dbpass = "#pkvXrwmtR5"; private $dbname = "u506006416_crystal"; public $con; public function __construct() { $this->con = mysqli_connect($this->dbhost, $this->dbusername, $this->dbpass, $this->dbname); if (!$this->con) { return false; } } /*=========== Created tAble ====================*/ public function create_table($table_name) { $result = mysqli_query($this->con, "CREATE TABLE $table_name (id INT(11) UNSIGNED AUTO_INCREMENT PRIMARY KEY, user_id INT(11), product_id INT(11), rating FLOAT(11), question TEXT(500), answer TEXT(500), created_at timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, status INT(11)) "); return $result; } /*==========================================*/ //get this last id form table public function last_id($conection) { return mysqli_insert_id($conection); } // public function run_sms_api($number) // { // $ch = curl_init(); // $mobile = $number; // $sms_text = urlencode("HI Office Product Needs, Get test or Free Delivery on Your First order on crystalmiracle.co.in, or download the App from Google Play Store (A4paper) https://play.google.com/store/apps/details?id=com.a4paper vdcpper"); // $url = "http://sms.lwditsolutions.com/API/pushsms.aspx?loginID=P1a4paper&password=Delhi@1234&mobile=$mobile&text=$sms_text&senderid=vdcppr&route_id=2&Unicode=0&IP=x.x.x.x&Template_id=1207163135150535549"; // curl_setopt($ch, CURLOPT_URL, $url); // curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); // $result = curl_exec($ch); // if (curl_errno($ch)) // { // echo "Error:" . curl_error($ch); // } // curl_close($ch); // return $result; // } // public function registration_sms_api($number, $email) // { // $ch = curl_init(); // $mobile = $number; // $sms_text = urlencode("Dear " . $email . ", Thankyou for registration on crystalmiracle.co.in"); // $url = "http://sms.lwditsolutions.com/API/pushsms.aspx?loginID=P1a4paper&password=Delhi@1234&mobile=$mobile&text=$sms_text&senderid=APFOUR&route_id=2&Unicode=0&IP=x.x.x.x&Template_id=1207163773926581679"; // curl_setopt($ch, CURLOPT_URL, $url); // curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); // $result = curl_exec($ch); // if (curl_errno($ch)) // { // echo "Error:" . curl_error($ch); // } // curl_close($ch); // return $result; // } // public function order_status_sms_api($number, $customer_name, $order_id, $status) // { // $ch = curl_init(); // $mobile = $number; // $sms_text = urlencode("Hi " . $customer_name . " Your crystalmiracle.co.in order" . " #" . $order_id . " has been " . $status); // $url = "http://sms.lwditsolutions.com/API/pushsms.aspx?loginID=P1a4paper&password=Delhi@1234&mobile=$mobile&text=$sms_text&senderid=APFOUR&route_id=2&Unicode=0&IP=x.x.x.x&Template_id=1207163773921921755"; // curl_setopt($ch, CURLOPT_URL, $url); // curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); // $result = curl_exec($ch); // if (curl_errno($ch)) // { // echo "Error:" . curl_error($ch); // } // curl_close($ch); // return $result; // } // public function order_confirmation($number, $username, $order_id) // { // $ch = curl_init(); // $mobile = $number; // $sms_text = urlencode("Hello " . $username . ", Thank you for your order , We" . '"' . "ll send the confirmation when your order ships.Your order Id " . $order_id . ", expected delivery in 2-3 days, crystalmiracle.co.in"); // $url = "http://sms.lwditsolutions.com/API/pushsms.aspx?loginID=P1a4paper&password=Delhi@1234&mobile=$mobile&text=$sms_text&senderid=APFOUR&route_id=2&Unicode=0&IP=x.x.x.x&Template_id=1207163913442909326"; // curl_setopt($ch, CURLOPT_URL, $url); // curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); // $result = curl_exec($ch); // if (curl_errno($ch)) // { // echo "Error:" . curl_error($ch); // } // curl_close($ch); // return $result; // } // for username availblty public function usernameavailblty($uname) { $result = mysqli_query($this->con, "SELECT phonenumber FROM tblusers WHERE phonenumber='$uname'"); return $result; } // Function for registration public function registration($number,$FullName='', $last_name='', $UserEmail='', $Password='') { $status = 1; $queryreg = "insert into tblusers(FullName, last_name, UserEmail, Password, phonenumber, status) values('$FullName', '$last_name', '$UserEmail', '$Password', '$number', '$status')"; $ret = mysqli_query($this->con, $queryreg); return $ret; } // Function for Gmail registration public function registrationwithgmail($email, $user_google_id, $picture, $FullName, $last_name) { $status = 1; $queryreg = "insert into tblusers(UserEmail,user_google_id,picture,status,FullName,last_name) values('$email','$user_google_id','$picture','$status','$FullName','$last_name')"; $ret = mysqli_query($this->con, $queryreg); return $ret; } // Function for signin public function signin($uname) { $result = mysqli_query($this->con, "select id,Username from tblusers where phonenumber='$uname' and status='1'"); return $result; } // Function for Gmail signin public function signinwithgmail($user_google_id, $email) { $result = mysqli_query($this->con, "select id,Username from tblusers where user_google_id='$user_google_id' and UserEmail='$email' and status='1'"); return $result; } public function insert($tablename, $data) { $field_set = ""; foreach ($data as $f_key => $f_value) { $field_set = $field_set . "$f_key='$f_value',"; } $field_set = rtrim($field_set, ","); $query = "INSERT INTO $tablename SET $field_set"; $query_fire = mysqli_query($this->con, $query); if ($query_fire == "TRUE") { return $query_fire; } else { return false; } } function error() { $error = mysqli_error($this->con); return $error; } function sumall($field, $tablename) { $query = "SELECT SUM(" . $field . ") as total FROM " . $tablename . ""; $query_sumall = mysqli_query($this->con, $query); while ($row = mysqli_fetch_array($query_sumall)) { return $row["total"]; } } function sumall_where($field, $tablename, $where) { $query = "SELECT SUM(" . $field . ") as total FROM " . $tablename . " WHERE " . $where . ""; $query_sumall = mysqli_query($this->con, $query); while ($row = mysqli_fetch_array($query_sumall)) { return $row["total"]; } } function get_old_cat_quantity($t, $ar) { $rows = $this ->con ->select_where($t, $ar); if (is_array($rows) || is_object($rows)) { foreach ($rows as $r) { return $r->quantity; } } else { return 0; } } public function changepassword($tablename, $old_pass, $new_pass) { $query = "SELECT * FROM " . $tablename . " WHERE `upass` = '$old_pass'"; $result = mysqli_query($this->con, $query); while ($row = mysqli_fetch_array($result)) { $adminpass = $row["upass"]; } if ($old_pass == $adminpass) { $update_fileds = ["upass" => $new_pass, ]; $where_co = ["upass" => $old_pass, ]; $update = $this->update("users", $update_fileds, $where_co); if ($update) { echo "<script>alert('Password Updated');</script>"; } else { echo "<script>alert('error');</script>"; } } else { echo "<script>alert('Password Not matched');</script>"; } } public function display_rcd($tablename, $condition) { if($condition!=""){ $array = []; $query = "SELECT * FROM " . "`$tablename`" . " WHERE " . $condition; $result = mysqli_query($this->con, $query); $count = mysqli_num_rows($result); if ($count >= 1) { while ($row = mysqli_fetch_array($result)) { $array[] = $row; } return $array; } else { return 0; } }else { return 0; } } public function customeQryBuilder($quert){ $result = mysqli_query($this->con, $quert); $count = mysqli_num_rows($result); if ($count >= 1) { while ($row = mysqli_fetch_array($result)) { $array[] = $row; } return $array; } else { return 0; } } /*=========UKP=========*/ public function display_rcd_desc($tablename, $condition) { $array = []; $query = "SELECT * FROM $tablename WHERE " . $condition . "ORDER BY id DESC"; $result = mysqli_query($this->con, $query); $count = mysqli_num_rows($result); if ($count >= 1) { while ($row = mysqli_fetch_array($result)) { $array[] = $row; } return $array; } else { return 0; } } public function display_rcd_desc_by_key($tablename, $condition, $key) { $array = []; $query = "SELECT * FROM $tablename WHERE " . $condition . "ORDER BY $key DESC"; $result = mysqli_query($this->con, $query); $count = mysqli_num_rows($result); if ($count >= 1) { while ($row = mysqli_fetch_array($result)) { $array[] = $row; } return $array; } else { return 0; } } public function get_best_selling_productList($select_key, $group_by_key, $limit) { $array = []; $query = "SELECT $select_key, COUNT(*) FROM `temp_cart` WHERE status = 0 AND user_id !=0 GROUP BY $group_by_key ORDER BY COUNT(*) DESC LIMIT $limit"; $result = mysqli_query($this->con, $query); $count = mysqli_num_rows($result); if ($count >= 1) { while ($row = mysqli_fetch_array($result, true)) { $array[] = $row; } return $array; } else { return 0; } } public function uniquevalue($colname, $tblname, $wherecon) { $array = []; $query = "SELECT DISTINCT " . $colname . " FROM " . $tblname . " WHERE " . $wherecon; $result = mysqli_query($this->con, $query); $count = mysqli_num_rows($result); if ($count >= 1) { while ($row = mysqli_fetch_array($result)) { $array[] = $row; } return $array; } else { return 0; } } function sumallwhere($field, $tablename, $where) { $query = "SELECT SUM(" . $field . ") as total FROM " . $tablename . " WHERE " . $where; $query_sumall = mysqli_query($this->con, $query); while ($row = mysqli_fetch_array($query_sumall)) { return $row["total"]; } } public function all_count($tablename) { $query = "SELECT COUNT(*) as total FROM " . $tablename; $result = mysqli_query($this->con, $query); while ($row = mysqli_fetch_array($result)) { $all = $row["total"]; } return $all; } public function all_count_where($tablename, $where_condition) { $all = []; $query = "SELECT COUNT(*) FROM " . $tablename . " WHERE " . $where_condition; $result = mysqli_query($this->con, $query); while ($row = mysqli_fetch_array($result)) { $all = $row; } return $all; } public function all_count_row($tablename, $where_condition) { $query = "SELECT COUNT(*) as total FROM " . $tablename . " WHERE " . $where_condition; $result = mysqli_query($this->con, $query); while ($row = mysqli_fetch_array($result)) { $s = $row["total"]; return $s; } } public function select($tablename) { $fetchdata = []; $query = "SELECT * FROM " . $tablename . ""; $result = mysqli_query($this->con, $query); while ($row = mysqli_fetch_assoc($result)) { $fetchdata[] = $row; } return $fetchdata; } /*=========UKP============*/ public function select_desc($tablename) { $fetchdata = []; $query = "SELECT * FROM $tablename ORDER BY id DESC"; $result = mysqli_query($this->con, $query); while ($row = mysqli_fetch_assoc($result)) { $fetchdata[] = $row; } return $fetchdata; } /*======================*/ public function select_where($table_name, $where_condition) { $condition = ""; $array = []; foreach ($where_condition as $key => $value) { // $condition = $value; // $condition .= $key . "= " . $value . " "; $condition .= $key . "= '" . $value . "' "; } $query = "SELECT * FROM " . $table_name . " WHERE " . $condition; $result = mysqli_query($this->con, $query); while ($row = mysqli_fetch_array($result)) { $array[] = $row; } return $array; } public function input_check($data) { $data = trim($data); $data = addslashes($data); $data = stripslashes($data); $data = htmlspecialchars($data); $data = filter_var($data, FILTER_SANITIZE_STRING); $data = $this ->con ->real_escape_string($data); return $data; } public function join_and($check) { if (is_array($check) || is_object($check)) { $where = null; foreach ($check as $k => $v) { $where .= $k . "='" . $this->input_check($v) . "' and "; } $where = rtrim($where, " and"); return $where; } else { return $where = null; } } //FETCH ALL public function all_fetch($table, $check = [], $other = null) { if (count($check) >= 1) { $condition = " WHERE " . $this->join_and($check); } else { $condition = null; } $sql = "select * from $table $condition $other"; $run = $this ->con ->query($sql); $compare = $run->num_rows; $arr = []; if ($compare >= 1) { while ($row = $run->fetch_object()) { $arr[] = $row; } return $arr; } else { return 0; } } public function all_select($table, $check = [], $other = null) { if (count($check) >= 1) { $condition = " WHERE " . $this->join_and($check); } else { $condition = null; } $sql = "select * from $table $condition $other"; $run = $this ->con ->query($sql); $compare = $run->num_rows; $arr = []; if ($compare >= 1) { while ($row = $run->fetch_array()) { $arr[] = $row; } return $arr; } else { return 0; } } // ==================================================================== public function update($table_name, $fields, $where_condition) { $query = ""; $condition = ""; foreach ($fields as $key => $value) { $query .= $key . "='" . $value . "', "; } $query = substr($query, 0, -2); foreach ($where_condition as $key => $value) { $condition .= $key . "='" . $value . "' AND "; } $condition = substr($condition, 0, -5); $query = "UPDATE " . $table_name . " SET " . $query . " WHERE " . $condition . ""; if (mysqli_query($this->con, $query)) { return true; } } public function delete($table_name, $where_condition) { $condition = ""; foreach ($where_condition as $key => $value) { $condition .= $key . " = '" . $value . "' AND "; $condition = substr($condition, 0, -5); $query = "DELETE FROM " . $table_name . " WHERE " . $condition . ""; if (mysqli_query($this->con, $query)) { return true; } } } public function delete_all($table_name) { $query = "DELETE FROM " . $table_name; if (mysqli_query($this->con, $query)) { return true; } } public function delete_where($table_name, $where) { $query = "DELETE FROM " . $table_name. " WHERE " . $where; if (mysqli_query($this->con, $query)) { return true; } } public function validation($data) { $data = trim($data); $data = addslashes($data); $data = stripslashes($data); $data = htmlspecialchars($data); $data = filter_var($data, FILTER_SANITIZE_STRING); $data = $this ->con ->real_escape_string($data); return $data; } function getPercentOfNumber($number, $percent) { return ($number * $percent) / (100 + $percent); } function get_percentage($total, $number) { if ($total > 0) { return round($number * ($total / 100) , 2); } else { return 0; } } public function discount($r_p, $d_p) { $substract = $r_p - $d_p; $multiple = $substract * 100; $percentage = $multiple / $r_p; return round($percentage,1) . "%"; } function uniqidReal($lenght = 5) { // uniqid gives 13 chars, but you could adjust it to your needs. if (function_exists("random_bytes")) { $bytes = random_bytes(ceil($lenght / 2)); } elseif (function_exists("openssl_random_pseudo_bytes")) { $bytes = openssl_random_pseudo_bytes(ceil($lenght / 2)); } else { throw new Exception("no cryptographically secure random function available"); } return substr(bin2hex($bytes) , 0, $lenght); } //fetch single subsctipiton array function fs($table, $where, $other = null) { $row = $this->all_fetch($table, $where, $other); return $row[0]; } /*** for login process ***/ public function check_login($emailusername, $password) { $password = md5($password); $sql2 = "SELECT uid from users WHERE uemail='$emailusername' and upass='$password'"; //checking if the username is available in the table $result = mysqli_query($this->con, $sql2); $user_data = mysqli_fetch_array($result); $count_row = $result->num_rows; if ($count_row == 1) { // this login var will use for the session thing $_SESSION["login"] = true; // $_SESSION['uid'] = $user_data['uid']; $_SESSION["admin_uid"] = $user_data["uid"]; return true; } else { return false; } } /*** for showing the username or fullname ***/ public function get_fullname($uid) { $sql3 = "SELECT fullname FROM users WHERE uid = $uid"; $result = mysqli_query($this->con, $sql3); $user_data = mysqli_fetch_array($result); echo $user_data["fullname"]; } /*** starting the session ***/ public function get_session() { return $_SESSION["login"]; } public function user_logout() { $_SESSION["login"] = false; session_destroy(); } public function alert($redirect) { echo "<script>window.location.href='$redirect';</script>"; } /*========== Push Notification =============*/ public function send_push_notification($contentData,$url,$image) { $content = array( "en" =>$contentData ); $hashes_array = array(); array_push($hashes_array, array( "id" => "like-button", "text" => "Open", "url" => $url )); $fields = array( 'app_id' => "2e4f0255-b180-4417-a0d2-6bc6665004c1", 'included_segments' => array( 'Subscribed Users' ), 'data' => array( "Image" =>$image ), 'chrome_web_image'=>$image, //'chrome_web_icon'=>$image, 'chrome_big_picture'=>$image, 'contents' => $content, 'big_picture' => $image, 'large_icon' => $image, 'web_buttons' => $hashes_array, 'url' => $url ); $fields = json_encode($fields); // print("\nJSON sent:\n"); // print($fields); /*$ch = curl_init(); curl_setopt($ch, CURLOPT_URL, "https://onesignal.com/api/v1/notifications"); curl_setopt($ch, CURLOPT_HTTPHEADER, array( 'Content-Type: application/json; charset=utf-8', 'Authorization: Basic ZjAyN2E2ZTgtYWQyNi00MWNlLWEyNmYtNjY5MTIzYzIyYmEx' )); curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE); curl_setopt($ch, CURLOPT_HEADER, FALSE); curl_setopt($ch, CURLOPT_POST, TRUE); curl_setopt($ch, CURLOPT_POSTFIELDS, $fields); curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE); $response = curl_exec($ch); curl_close($ch); return $response;*/ } /*=========== Social Communication =============*/ public function social() { $array = []; $query = "SELECT * FROM social_communication"; $result = mysqli_query($this->con, $query); while ($row = mysqli_fetch_array($result)) { $array = $row; } return $array; } /*============= Whatsapp API ==============*/ function sendWhatsappMessage($phone,$userName,$campaign,$file,$msessageArr){ $url="https://backend.aisensy.com/campaign/t1/api"; $apiKey = "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpZCI6IjYzMjJmMTY5YzMyNDI3NzU0OWFiYzg2YSIsIm5hbWUiOiJhNHBhcGVyLmluIiwiYXBwTmFtZSI6IkFpU2Vuc3kiLCJjbGllbnRJZCI6IjYzMjJmMTU4ZTY3YzA1NzUzMzU0MmJjZCIsImFjdGl2ZVBsYW4iOiJCQVNJQ19UUklBTCIsImlhdCI6MTY2MzIzNDQwOX0.1UhlwV0ktmTXqkCGgYXrALO1xweL4JUOtfNU6Kw7QuA"; $JsonBody = array( 'apiKey' => $apiKey, 'campaignName' => $campaign, 'destination' => $phone, 'userName' => $userName, ); if(!empty($msessageArr)){ $JsonBody["templateParams"] = $msessageArr; } if(!empty($file)){ $JsonBody["media"] = array('url' => $file, "filename" =>"Invoice"); } // json encode $JsonBody = json_encode($JsonBody); /* $ch=curl_init(); curl_setopt($ch,CURLOPT_URL,$url); curl_setopt($ch,CURLOPT_POST,true); curl_setopt($ch,CURLOPT_RETURNTRANSFER,1); curl_setopt($ch,CURLOPT_POSTFIELDS,$JsonBody); curl_setopt($ch,CURLOPT_HTTPHEADER,array( 'Content-type:application/json', 'Content-length:'.strlen($JsonBody) )); $result=curl_exec($ch); curl_close($ch); $rData = json_decode($result,true);*/ // print_r($rData); } /*============== //Whatsapp API ===============*/ } //custom code by rohit singh function url($path) { echo "<script>window.location.href='$path'</script>"; } $invoice = "IN" . substr(rand(1, 10) . mt_rand() . time() . microtime() , 0, 10); $all_order_id = "GW" . substr(rand(1, 10) . mt_rand() . time() . microtime() , 0, 10); $all_transtion_id = substr(hash("sha256", mt_rand() . microtime()) , 0, 20); define("BASE_URL", ""); $MERCHANT_KEY = "p7aEWy"; $SALT = "tfDFDO7x"; $PAYU_BASE_URL = "https://secure.payu.in"; $add_date = date("Y-m-d H:i:s"); /*============ Base URL ==============*/ $base_url = (isset($_SERVER["HTTPS"]) ? "https://" : "http://") . $_SERVER["HTTP_HOST"] . preg_replace('@/+$@', "", dirname($_SERVER["SCRIPT_NAME"])) . "/"; /*===================================*/ ?>