/** * Register the new install with the LC API * * @access private * @return string */ private function _doRegister($data) { global $lC_Database, $lC_Cache; if (isset($data['activation_email']) && $data['activation_email'] != NULL) { $storeEmail = $data['activation_email']; } else { $storeEmail = STORE_OWNER_EMAIL_ADDRESS; } if (isset($data['activation_serial']) && $data['activation_serial'] != NULL) { $storeSerial = $data['activation_serial']; } else { $storeSerial = ''; } // register the install with LC API $registerArr = array('serial' => $storeSerial, 'storeName' => STORE_NAME, 'storeEmail' => $storeEmail, 'storeWWW' => HTTP_SERVER . DIR_WS_HTTP_CATALOG, 'storeSSL' => HTTPS_SERVER . DIR_WS_HTTPS_CATALOG, 'systemMetaData' => base64_encode(json_encode(lc_get_system_information())), 'serverMetaData' => isset($_SERVER) && is_array($_SERVER) ? base64_encode(json_encode($_SERVER)) : NULL, 'envMetaData' => isset($_ENV) && is_array($_ENV) ? base64_encode(json_encode($_ENV)) : NULL); $checksum = hash('sha256', json_encode($registerArr)); $registerArr['checksum'] = $checksum; $api_version = defined('API_VERSION') && API_VERSION != NULL ? API_VERSION : '1_0'; $registerArr['ver'] = utility::getVersion(); $request_type = getRequestType(); $resultXML = transport::getResponse(array('url' => $request_type . '://api.loadedcommerce.com/' . $api_version . '/register/install/', 'method' => 'post', 'parameters' => $registerArr, 'timeout' => 10)); $newInstallationID = preg_match("'<installationID[^>]*?>(.*?)</installationID>'i", $resultXML, $regs) == 1 ? $regs[1] : NULL; $products = preg_match("'<products[^>]*?>(.*?)</products>'i", $resultXML, $regs) == 1 ? $regs[1] : NULL; if (lC_Server_info_Admin::updateInstallID($newInstallationID)) { return utility::arr2xml(array('error' => FALSE, 'installationID' => $newInstallationID, 'products' => $products)); } else { return utility::arr2xml(array('error' => TRUE, 'message' => 'error processing the request')); } }
/** * Create a oracle connection and return it **/ function openDatabaseConnection() { $request = getRequestType('user-name'); $user_name = array_key_exists('user-name', $request) ? $request['user-name'] : ""; $password = array_key_exists('password', $request) ? $request['password'] : ""; $connectionString = array_key_exists('connection-string', $request) ? $request['connection-string'] : ""; $conn = oci_connect($user_name, $password, $connectionString); return $conn; }
public function actionCreateConvey() { if (getRequestType() == "POST") { $filename = ROOT . "/upload/" . time() . rand(1, 9999) . ".json"; move_uploaded_file($_FILES['config']['tmp_name'], $filename); $data = file_get_contents($filename); $obj = json_decode($data); $res = $this->createConvey($obj, $filename); $obj->id = $res['insert_id']; $this->createQuestion($obj->questions, $res['insert_id']); //更新json文件 file_put_contents($filename, json_encode($obj)); } else { $this->render($this->action); } }
/** * Curl Transport * * @param array $parameters The parameters to process * @access public * @return mixed */ public static function execute($parameters) { $request_type = getRequestType($parameters['server']['scheme']); $curl = curl_init($request_type . '://' . $parameters['server']['host'] . $parameters['server']['path'] . (isset($parameters['server']['query']) ? '?' . $parameters['server']['query'] : '')); $curl_options = array(CURLOPT_PORT => $parameters['server']['port'], CURLOPT_HEADER => true, CURLOPT_SSL_VERIFYPEER => false, CURLOPT_RETURNTRANSFER => true, CURLOPT_FORBID_REUSE => true, CURLOPT_FRESH_CONNECT => true, CURLOPT_FOLLOWLOCATION => false); if (!empty($parameters['timeout'])) { $curl_options[CURLOPT_TIMEOUT] = $parameters['timeout']; } if (!empty($parameters['header'])) { $curl_options[CURLOPT_HTTPHEADER] = $parameters['header']; } if (!empty($parameters['certificate'])) { $curl_options[CURLOPT_SSLCERT] = $parameters['certificate']; } if ($parameters['method'] == 'post') { $curl_options[CURLOPT_POST] = true; $curl_options[CURLOPT_POSTFIELDS] = $parameters['parameters']; } // added support for curl proxy if (defined('CURL_PROXY_HOST') && defined('CURL_PROXY_PORT') && CURL_PROXY_HOST != NULL && CURL_PROXY_PORT != NULL) { $curl_options[CURLOPT_HTTPPROXYTUNNEL] = true; $curl_options[CURLOPT_PROXY] = CURL_PROXY_HOST . ":" . CURL_PROXY_PORT; } if (defined('CURL_PROXY_USER') && defined('CURL_PROXY_PASSWORD') && CURL_PROXY_USER != NULL && CURL_PROXY_PASSWORD != NULL) { $curl_options[CURLOPT_PROXYUSERPWD] = CURL_PROXY_USER . ':' . CURL_PROXY_PASSWORD; } curl_setopt_array($curl, $curl_options); $result = curl_exec($curl); $http_code = curl_getinfo($curl, CURLINFO_HTTP_CODE); $http_code = curl_getinfo($curl, CURLINFO_HTTP_CODE); curl_close($curl); if ($parameters['rawResponse'] === true) { $body = $result; } else { list($headers, $body) = explode("\r\n\r\n", $result, 2); } if ($http_code > 299) { // there was some sort of error // log the error self::log('cURL Error: (' . $http_code . ') requesting ' . $parameters['url']); } return $body; }
/** @package catalog::install::templates @author Loaded Commerce @copyright Copyright 2003-2014 Loaded Commerce, LLC @copyright Portions Copyright 2003 osCommerce @license https://github.com/loadedcommerce/loaded7/blob/master/LICENSE.txt @version $Id: index.php v1.0 2013-08-08 datazen $ */ function cURLTest() { $testText = 'data'; $ch = curl_init(); $request_type = getRequestType(); curl_setopt($ch, CURLOPT_URL, $request_type . '://api.loadedcommerce.com/1_0/check/serial/'); curl_setopt($ch, CURLOPT_USERAGENT, "Mozilla/5.0 (compatible; MSIE 9.0; Windows NT 6.1; WOW64; Trident/5.0)"); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); curl_setopt($ch, CURLOPT_TIMEOUT, 10); curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 10); $response = curl_exec($ch); $errmsg = curl_error($ch); $cInfo = curl_getinfo($ch); curl_close($ch); if (strlen($response) > 0) { return true; } else { return false; } }
public static function apiCheck() { $api_version = defined('API_VERSION') && API_VERSION != NULL ? API_VERSION : '1_0'; $request_type = getRequestType(); $apiCheck = transport::getResponse(array('url' => $request_type . '://api.loadedcommerce.com/' . $api_version . '/updates/available/?ver=' . utility::getVersion() . '&ref=' . $_SERVER['SCRIPT_FILENAME'], 'method' => 'get', 'timeout' => 10)); $versions = utility::xml2arr($apiCheck); $error = false; if (count($versions) == 0) { // there was an error with the api $error = true; $errorMsg = preg_match("'<title[^>]*?>.*?</title>'si", $versions, $regs); $errorMsg = is_array($regs) ? strip_tags(end($regs)) : NULL; if ($errorMsg == '') { $errorMsg = 'Resource Unavailable at ' . $request_type . '://api.loadedcommerce.com/' . $api_version . '/updates/available/?ver=' . utility::getVersion() . '&ref=' . $_SERVER['SCRIPT_FILENAME']; } $error = true; // log the error self::log('Error: ' . $errorMsg); } if ($versions == null || $error) { // set the error flag return -1; } return 1; }
} else { die('Install directory does not exist!'); } } // set the level of error reporting error_reporting(E_ALL & ~E_STRICT & ~E_NOTICE); //ini_set("display_errors", 1); ini_set('log_errors', true); ini_set('error_log', DIR_FS_WORK . 'php_errors.log'); // virtual hook system require_once DIR_FS_CATALOG . 'ext/vqmod/vqmod.php'; $lC_Vqmod = new VQMod(); // compatibility work-around logic require $lC_Vqmod->modCheck(DIR_FS_CATALOG . 'includes/functions/compatibility.php'); // set the type of request (secure or not) $request_type = getRequestType(); if ($request_type == 'https') { define('DIR_WS_CATALOG', DIR_WS_HTTPS_CATALOG); } else { define('DIR_WS_CATALOG', DIR_WS_HTTP_CATALOG); } define('API_VERSION', '1_0'); // include the list of project filenames require $lC_Vqmod->modCheck(DIR_FS_CATALOG . 'includes/filenames.php'); // include the list of project database tables require $lC_Vqmod->modCheck(DIR_FS_CATALOG . 'includes/database_tables.php'); // include the utility class require $lC_Vqmod->modCheck(DIR_FS_CATALOG . 'includes/classes/utility.php'); // initialize the message stack for output messages require $lC_Vqmod->modCheck(DIR_FS_CATALOG . 'includes/classes/message_stack.php'); $lC_MessageStack = new lC_MessageStack();
/** * Download the package * * @access public * @return mixed */ public static function downloadPackage($version = null, $type = null) { if (empty($version)) { $link = self::getAvailablePackageInfo('update_package'); } else { $versions = self::getAvailablePackages(); foreach ($versions['entries'] as $v) { if ($v['version'] == $version) { $link = $v['update_package']; break; } } } $api_version = defined('API_VERSION') && API_VERSION != NULL ? API_VERSION : '1_0'; $request_type = getRequestType(); if ($link == null) { $link = $request_type . '://api.loadedcommerce.com/' . $api_version . '/get/' . str_replace(".", "", $version) . '?ver=' . utility::getVersion() . '&ref=' . urlencode($_SERVER['SCRIPT_FILENAME']); } if ($type != null) { $link .= '&type=' . $type; } $response = file_get_contents($link); return file_put_contents(DIR_FS_WORK . 'updates/update.phar', $response); }
switch ($key) { case "set": return ProtocolCached_Request_RequestType::SET; break; case "get": return ProtocolCached_Request_RequestType::GET; break; default: throw new Exception("GET or SET only"); } } $c = uv_tcp_init(); uv_tcp_connect6($c, uv_ip6_addr('::1', 9999), function ($client, $stat) { if ($stat == 0) { $request = new ProtocolCached_Request(); $type = getRequestType($_SERVER['argv'][1]); $request->setType($type); if ($type == ProtocolCached_Request_RequestType::SET) { $set = new ProtocolCached_SetRequest(); $set->setKey($_SERVER['argv'][2]); $set->setValue($_SERVER['argv'][3]); $request->setSet($set); } else { if ($type == ProtocolCached_Request_RequestType::GET) { $set = new ProtocolCached_GetRequest(); $set->setKey($_SERVER['argv'][2]); $request->setGet($set); } } uv_write($client, $request->serializeToString(), function ($socket, $stat) use($type) { if ($type == ProtocolCached_Request_RequestType::GET) {
public function actionRcvAns() { $this->authenticate(); if (getRequestType() == "POST") { $ans = $_POST; array_walk_recursive($ans, function (&$val) { if ($val == "false") { $val = false; } if ($val == "true") { $val = true; } }); $fl = $this->getConveyFile(self::SURVEYID); $data = json_decode($fl); if (is_array($data->questions)) { foreach ($data->questions as $k => $v) { if (!$this->validateAnswer($v, $ans)) { if ($v->required) { RS("错误", "", false); } } } } else { foreach ($data->questions as $part => $questions) { foreach ($questions as $q) { if (!$this->validateAnswer($q, $ans)) { if ($q->required) { RS("错误", "", false); } } } } } $ans_filtered = $this->afterValidate($ans); $this->saveAnswer($ans_filtered); setcookie("SJIELQPLMCUHUSEUWPHED", md5(time() . rand(1, 999)), time() + 3600 * 24 * 365); RS("感谢您参与该调查,我们会认真审阅您提供的信息,并保证不泄漏您的任何隐私", "", true); } }
public static function getAddonPhar($key, $type = 'addon') { // remove the old phar if it exists if (file_exists(DIR_FS_WORK . 'addons/' . $key . '.phar')) { unlink(DIR_FS_WORK . 'addons/' . $key . '.phar'); } $api_version = defined('API_VERSION') && API_VERSION != NULL ? API_VERSION : '1_0'; // add the pubkey $pubkey = file_get_contents(DIR_FS_WORK . 'addons/update.phar.pubkey'); file_put_contents(DIR_FS_WORK . 'addons/' . $key . '.phar.pubkey', $pubkey); $request_type = getRequestType(); $response = transport::getResponse(array('url' => $request_type . '://api.loadedcommerce.com/' . $api_version . '/get/' . $key . '?type=addon&ver=' . utility::getVersion() . '&ref=' . urlencode($_SERVER['SCRIPT_FILENAME']), 'method' => 'get', 'timeout' => 10)); if (strlen($response) == 0) { $response = file_get_contents($request_type . '://api.loadedcommerce.com/' . $api_version . '/get/' . $key . '?type=addon&ver=' . utility::getVersion() . '&ref=' . urlencode($_SERVER['SCRIPT_FILENAME'])); } return file_put_contents(DIR_FS_WORK . 'addons/' . $key . '.phar', $response); }