function __construct() { $res = DB::query('SELECT * FROM `' . PREFIX . 'payment` WHERE id in (2,3,7,4) ORDER BY `sort`'); $i = 0; while ($row = DB::fetchAssoc($res)) { $newparam = array(); $param = json_decode($row['paramArray']); foreach ($param as $key => $value) { if ($value != '') { $value = CRYPT::mgDecrypt($value); } $newparam[$key] = $value; } $row['paramArray'] = CRYPT::json_encode_cyr($newparam); $this->_paymentArray[$row['id']] = $row; } }
require SERVER_ROOT . '/classes/cache.class.php'; //Require the caching class require SERVER_ROOT . '/classes/encrypt.class.php'; //Require the encryption class require SERVER_ROOT . '/classes/time.class.php'; //Require the time class require SERVER_ROOT . '/classes/paranoia.class.php'; //Require the paranoia check_paranoia function require SERVER_ROOT . '/classes/regex.php'; require SERVER_ROOT . '/classes/util.php'; $Debug = new DEBUG(); $Debug->handle_errors(); $Debug->set_flag('Debug constructed'); $DB = new DB_MYSQL(); $Cache = new CACHE($MemcachedServers); $Enc = new CRYPT(); // Autoload classes. require SERVER_ROOT . '/classes/classloader.php'; // Note: G::initialize is called twice. // This is necessary as the code inbetween (initialization of $LoggedUser) makes use of G::$DB and G::$Cache. // TODO: remove one of the calls once we're moving everything into that class G::initialize(); //Begin browser identification $Browser = UserAgent::browser($_SERVER['HTTP_USER_AGENT']); $OperatingSystem = UserAgent::operating_system($_SERVER['HTTP_USER_AGENT']); //$Mobile = UserAgent::mobile($_SERVER['HTTP_USER_AGENT']); $Mobile = in_array($_SERVER['HTTP_HOST'], array('m.' . NONSSL_SITE_URL, 'm.' . NONSSL_SITE_URL)); $Debug->set_flag('start user handling'); // Get classes // TODO: Remove these globals, replace by calls into Users list($Classes, $ClassLevels) = Users::get_classes();
require(SERVER_ROOT.'/classes/class_debug.php'); //Require the debug class require(SERVER_ROOT.'/classes/class_mysql.php'); //Require the database wrapper require(SERVER_ROOT.'/classes/class_cache.php'); //Require the caching class require(SERVER_ROOT.'/classes/class_encrypt.php'); //Require the encryption class require(SERVER_ROOT.'/classes/class_useragent.php'); //Require the useragent class require(SERVER_ROOT.'/classes/class_time.php'); //Require the time class require(SERVER_ROOT.'/classes/class_search.php'); //Require the searching class $Debug = new DEBUG; $Debug->handle_errors(); $DB = new DB_MYSQL; $Cache = new CACHE; $Enc = new CRYPT; $UA = new USER_AGENT; $SS = new SPHINX_SEARCH; //resource_type://username:password@domain:port/path?query_string#anchor define('RESOURCE_REGEX','(https?|ftps?):\/\/'); define('IP_REGEX','(\d{1,3}\.){3}\d{1,3}'); define('DOMAIN_REGEX','(ssl.)?(www.)?[a-z0-9-\.]{1,255}\.[a-zA-Z]{2,6}'); define('PORT_REGEX', '\d{1,5}'); define('URL_REGEX','('.RESOURCE_REGEX.')('.IP_REGEX.'|'.DOMAIN_REGEX.')(:'.PORT_REGEX.')?(\/\S+)*'); define('EMAIL_REGEX','[_a-z0-9-]+([.+][_a-z0-9-]+)*@'.DOMAIN_REGEX); define('IMAGE_REGEX', URL_REGEX.'\/\S+\.(jpg|jpeg|tif|tiff|png|gif|bmp)'); define('SITELINK_REGEX', RESOURCE_REGEX.'(ssl.)?'.preg_quote(NONSSL_SITE_URL, '/').'');
function reset($form) { $usr = $_SESSION['username']; $checknumber = array('id' => null, 'ran' => null, 'email' => null); if ($form['password'] == null && $form['password2'] == null) { $checknumber = array('id' => '27'); return $checknumber; } if ($form['password'] != $form['password2']) { $checknumber = array('id' => '28'); return $checknumber; } $length = strlen($form['password']); if ($length > 10 || $length < 6) { $checknumber = array('id' => '29'); return $checknumber; } $code = new CRYPT(); $encodepsw = $code->encrypt($form['password']); $sql = "update login set password='******'where email='{$usr}'"; $con = mysql_connect(SAE_MYSQL_HOST_M . ':' . SAE_MYSQL_PORT, SAE_MYSQL_USER, SAE_MYSQL_PASS); if (!$con) { die('Could not connect:' . mysql_error()); } mysql_query("set names utf8"); mysql_select_db(SAE_MYSQL_DB, $con); if (!mysql_query($sql, $con)) { mysql_close($con); die('Error:' . mysql_error); } mysql_close($con); $checknumber = array('id' => '30'); return $checknumber; }
<?php require 'config.php'; //The config contains all site wide configuration information as well as memcached rules require SERVER_ROOT . '/classes/debug.class.php'; require SERVER_ROOT . '/classes/cache.class.php'; //Require the caching class require SERVER_ROOT . '/classes/encrypt.class.php'; //Require the caching class $Debug = new DEBUG(); $Cache = new CACHE($MemcachedServers); //Load the caching class $Enc = new CRYPT(); //Load the encryption class $SSL = $_SERVER['SERVER_PORT'] === '443'; if (isset($_COOKIE['session'])) { $LoginCookie = $Enc->decrypt($_COOKIE['session']); } if (isset($LoginCookie)) { list($SessionID, $UserID) = explode("|~|", $Enc->decrypt($LoginCookie)); if (!$UserID || !$SessionID) { die('Not logged in!'); } if (!($Enabled = $Cache->get_value("enabled_{$UserID}"))) { require SERVER_ROOT . '/classes/mysql.class.php'; //Require the database wrapper $DB = new DB_MYSQL(); //Load the database wrapper $DB->query("\n\t\t\tSELECT Enabled\n\t\t\tFROM users_main\n\t\t\tWHERE ID = '{$UserID}'"); list($Enabled) = $DB->next_record(); $Cache->cache_value("enabled_{$UserID}", $Enabled, 0);
/** * Сохраняет способ оплаты. */ public function savePaymentMethod() { $paymentParam = str_replace("'", "\\'", $_POST['paymentParam']); $deliveryMethod = $_POST['deliveryMethod']; $deliveryArray = json_decode($deliveryMethod, true); $paymentActivity = $_POST['paymentActivity']; $paymentId = $_POST['paymentId']; if (is_array($deliveryArray)) { foreach ($deliveryArray as $deliveryId => $compare) { $sql = "\r\n UPDATE `" . PREFIX . "delivery_payment_compare`\r\n SET `compare` = " . DB::quote($compare) . "\r\n WHERE `payment_id` = " . DB::quote($paymentId) . "\r\n AND `delivery_id` = " . DB::quote($deliveryId); $result = DB::query($sql); } } $newparam = array(); $param = json_decode($paymentParam); foreach ($param as $key => $value) { if ($value != '') { $value = CRYPT::mgCrypt($value); } $newparam[$key] = $value; } $paymentParamEncoded = CRYPT::json_encode_cyr($newparam); $sql = "\r\n UPDATE `" . PREFIX . "payment`\r\n SET `name` = " . DB::quote($_POST['name']) . ", \r\n `paramArray` = " . DB::quote($paymentParamEncoded) . ",\r\n `activity` = " . DB::quote($paymentActivity) . "\r\n WHERE id = " . $paymentId; $result = DB::query($sql); if ($result) { $status = 'success'; $msg = $this->lang['ACT_SUCCESS']; } else { $status = 'error'; $msg = $this->lang['ACT_ERROR']; } $sql = "\r\n SELECT *\r\n FROM `" . PREFIX . "payment` \r\n WHERE id = " . $paymentId; $result = DB::query($sql); if ($row = DB::fetchAssoc($result)) { $newparam = array(); $param = json_decode($row['paramArray']); foreach ($param as $key => $value) { if ($value != '') { $value = CRYPT::mgDecrypt($value); } $newparam[$key] = $value; } $paymentParam = CRYPT::json_encode_cyr($newparam); } $response = array('status' => $status, 'msg' => $msg, 'data' => array('paymentParam' => $paymentParam)); echo json_encode($response); }