function main() { if (isset($_GET['lang']) && $_GET['lang'] == 'en') { $lang = 'en'; } else { $lang = 'no'; } $json = getJson($lang); $form = parsePost($json); if (strlen($form['result']) > 0) { // If all fields in $_POST were valid saveForm($form['name'], $form['email'], $form['message']); } require 'cvLayout.php'; }
function lottery() { global $lotteryCount; global $cookie_jar; $uri = "http://127.0.0.1/tomlib/nandu/src/php/main.php?op=lottery"; $lotteryCount += 1; $data = array('name' => 'tanteng'); $ch = curl_init(); // print_r($ch); curl_setopt($ch, CURLOPT_COOKIEJAR, $cookie_jar); curl_setopt($ch, CURLOPT_URL, $uri); curl_setopt($ch, CURLOPT_POST, 1); curl_setopt($ch, CURLOPT_HEADER, 0); //curl_setopt ( $ch, CURLOPT_USERAGENT, "monitor" ); curl_setopt($ch, CURLOPT_HTTPHEADER, array('Content-Type: text/plain', 'User-Agent: monitor')); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); curl_setopt($ch, CURLOPT_POSTFIELDS, $data); $return = curl_exec($ch); $http_code = curl_getinfo($ch, CURLINFO_HTTP_CODE); curl_close($ch); /*-----使用COOKIE-----*/ //$return = json_encode($return); //$temp=utf8_decode('{"result":"0","code":"1","id":"0","path":"","msg":"\u624b\u6c14\u4e0d\u592a\u597d"}'); //echo json_decode("\u624b\u6c14\u4e0d\u592a\u597d", JSON_UNESCAPED_UNICODE); print_r("第" . $lotteryCount . "次抽奖"); //echo "-------";print_r(json_decode($return));echo "-------"; //$return='{"result":"0","code":"1","id":"0","path":"","msg":"\u624b\u6c14\u4e0d\u592a\u597d"}'; //echo json_last_error_msg(); //echo "<br>http_code==" . $http_code; if ($http_code == 200) { $data = getJsonByText($return); echo $data->msg; if ($data->prizeNum != 0) { saveForm(); } } echo '<br/>'; return array(); }
/** * This file is part of the SysCP project. * Copyright (c) 2003-2009 the SysCP Team (see authors). * * For the full copyright and license information, please view the COPYING * file that was distributed with this source code. You can also view the * COPYING file online at http://files.syscp.org/misc/COPYING.txt * * @copyright (c) the authors * @author Florian Lippert <*****@*****.**> * @license GPLv2 http://files.syscp.org/misc/COPYING.txt * * @version $Id$ */ function processForm($form, $input, $url_params = array()) { if (validateFormDefinition($form)) { $submitted_fields = array(); $changed_fields = array(); $saved_fields = array(); foreach ($form['groups'] as $groupname => $groupdetails) { if (validateFieldDefinition($groupdetails)) { // Prefetch form fields foreach ($groupdetails['fields'] as $fieldname => $fielddetails) { $groupdetails['fields'][$fieldname] = array_merge_prefix($fielddetails, $fielddetails['type'], prefetchFormFieldData($fieldname, $fielddetails)); $form['groups'][$groupname]['fields'][$fieldname] = $groupdetails['fields'][$fieldname]; } } } foreach ($form['groups'] as $groupname => $groupdetails) { if (validateFieldDefinition($groupdetails)) { // Validate fields foreach ($groupdetails['fields'] as $fieldname => $fielddetails) { $newfieldvalue = getFormFieldData($fieldname, $fielddetails, $input); if (isset($fielddetails['value']) && $newfieldvalue != $fielddetails['value']) { if (($error = validateFormField($fieldname, $fielddetails, $newfieldvalue)) !== true) { standard_error($error, $fieldname); } else { $changed_fields[$fieldname] = $newfieldvalue; } } $submitted_fields[$fieldname] = $newfieldvalue; } } } foreach ($form['groups'] as $groupname => $groupdetails) { if (validateFieldDefinition($groupdetails)) { // Check fields for plausibility foreach ($groupdetails['fields'] as $fieldname => $fielddetails) { if (($plausibility_check = checkPlausibilityFormField($fieldname, $fielddetails, $submitted_fields[$fieldname], $submitted_fields)) !== false) { if (is_array($plausibility_check) && isset($plausibility_check[0])) { if ($plausibility_check[0] == FORMFIELDS_PLAUSIBILITY_CHECK_OK) { // Nothing to do here, everything's okay } elseif ($plausibility_check[0] == FORMFIELDS_PLAUSIBILITY_CHECK_ERROR) { unset($plausibility_check[0]); $error = $plausibility_check[1]; unset($plausibility_check[1]); $targetname = implode(' ', $plausibility_check); standard_error($error, $targetname); } elseif ($plausibility_check[0] == FORMFIELDS_PLAUSIBILITY_CHECK_QUESTION) { unset($plausibility_check[0]); $question = $plausibility_check[1]; unset($plausibility_check[1]); $targetname = implode(' ', $plausibility_check); if (!isset($input[$question])) { if (is_array($url_params) && isset($url_params['filename'])) { $filename = $url_params['filename']; unset($url_params['filename']); } else { $filename = ''; } ask_yesno($question, $filename, array_merge($url_params, $submitted_fields, array($question => $question)), $targetname); } } else { standard_error('plausibilitychecknotunderstood'); } } } } } } foreach ($form['groups'] as $groupname => $groupdetails) { if (validateFieldDefinition($groupdetails)) { // Save fields foreach ($groupdetails['fields'] as $fieldname => $fielddetails) { if (isset($changed_fields[$fieldname])) { if (($saved_field = saveFormField($fieldname, $fielddetails, manipulateFormFieldData($fieldname, $fielddetails, $changed_fields[$fieldname]))) !== false) { $saved_fields = array_merge($saved_fields, $saved_field); } else { standard_error('errorwhensaving', $fieldname); } } } } } // Save form return saveForm($form, $saved_fields); } }
<?php require "../../../cgi_bin/phpFun.php"; require "../languages/language.php"; jCnn(); if (isset($_REQUEST["eliminar"])) { $strsql = "delete from [stocks] where id=" . $_REQUEST["eliminar"]; $results = $GLOBALS['db']->exec($strsql); } if (isset($_REQUEST["insertar"])) { $strsql = "insert into [stocks] (idProduct) values(" . $_SESSION['idProduct'] . ");"; $results = $GLOBALS['db']->exec($strsql); } if (isset($_REQUEST["salvar"])) { saveForm("stocks", "id", $_REQUEST["salvar"]); } //------------------------------------------------- //Establece las Condiciones y Abre el Recordset //------------------------------------------------- $strsql = "select * from [stocks] where idProduct=" . $_SESSION['idProduct'] . " order by idStore limit 50"; $GLOBALS['rst'] = $GLOBALS['db']->query($strsql); ?> <html> <head> <meta content="text/html; charset=UTF-8" http-equiv="Content-Type"> <meta content="es" http-equiv="Content-Language"> <link href="../../../cgi_bin/jss/jss.css" rel="stylesheet" type="text/css"> <title>Tabla de Precios</title> <base target="_self"> </head>
$strsql = base64_decode($strsql); } jCnn(); header('Content-type: image/jpeg'); echo jGet($strsql); exit; } // SAVEFORM //********************************************** if (isset($_REQUEST['saveForm'])) { $strsql = $_REQUEST['strsql']; if ($_REQUEST['saveForm'] == 'base64') { $strsql = base64_decode($strsql); } jCnn(); echo saveForm($_REQUEST['table'], $_REQUEST['idKey'], $_REQUEST['key']); exit; } // JSGETARRAY //********************************************** if (isset($_REQUEST['jsgetArray'])) { $strsql = $_REQUEST['strsql']; $jsFun = $_REQUEST['jsgetArray']; if ($jsFun == 'base64' || $jsFun == 'gz') { $strsql = base64_decode($strsql); } if ($jsFun == 'gz') { $strsql = gzuncompress($strsql); } jCnn(); echo jsgetArray($strsql);
//$results->execute(); } //------------------------------------------------- //Salva los Cambios //------------------------------------------------- if (isset($_POST["idModel"])) { $idModel = $_POST["idModel"]; saveForm('docsModel', "idModel", $idModel); unset($_REQUEST["eliminar"]); unset($_REQUEST["insertar"]); } //------------------------------------------------- //Inserta //------------------------------------------------- if (isset($_REQUEST["insertar"])) { saveForm('docsModel', "idModel", "0"); $idModel = $_SESSION['id']; unset($_REQUEST["eliminar"]); } //------------------------------------------------- //Eliminar //------------------------------------------------- if (isset($_REQUEST["eliminar"])) { $strCommand = 'delete from docsModel where idModel=' . $_REQUEST["eliminar"]; $res = $GLOBALS['db']->exec($strCommand); } //------------------------------------------------- //SQL //------------------------------------------------- if ($idModel) { $strSql = "select * from docsModel where idModel=" . $idModel;
<?php //------------------------------------------------- //Salva los Cambios //------------------------------------------------- if (isset($_REQUEST["save"])) { $_SESSION[$keyMaster] = saveForm($table, $keyMaster, $_SESSION[$keyMaster]); } //------------------------------------------------- //Eliminar //------------------------------------------------- if (isset($_REQUEST["eliminar"])) { $strCommand = 'delete from ' . $table . ' where ' . $keyMaster . '=' . $_SESSION[$keyMaster]; $res = $GLOBALS['db']->exec($strCommand); header("Location: " . $_SERVER['PHP_SELF']); exit; } if ($_SESSION[$keyMaster] == '0') { $strsql = "INSERT INTO [{$table}] ({$buscaPor}) VALUES('-');"; $results = $GLOBALS['db']->exec($strsql); if (!$results) { $err = $GLOBALS['db']->errorInfo(); echo '<hr>' . $strsql . '<hr>Error: ' . $err[2]; exit; } $_SESSION[$keyMaster] = $GLOBALS['db']->lastInsertId(); } if (isset($editsql)) { $strsql = $editsql; } else { $strsql = "select * from {$table} where {$keyMaster}=" . $_SESSION[$keyMaster];
$url = urldecode($_GET['url']); } $jssdk = new JSSDK(APPID, APPSECRET); $signPackage = $jssdk->GetSignPackage($url); echo json_encode($signPackage); return; //end } elseif ($action == "saveform") { $result = array('result' => '0', 'id' => 0, 'path' => '', 'message' => '提交失败'); $form = array(); $form["name"] = $_POST['name']; $form['phone'] = $_POST['phone']; $form['province'] = $_POST['province']; $form['agency'] = $_POST['agency']; $form['city'] = $_POST['city']; $id = saveForm($form); if (!empty($id)) { $result['result'] = 1; $result['message'] = '提交成功'; } echo json_encode($result); return; } elseif ($action == 'testXss') { $result = testXss($_GET); $table = "<table><tr><th>name</th><th>phone</th>"; while ($row = $result->fetch_array()) { $table .= '<tr><td>' . $row['name'] . '</td><td>' . $row['phone'] . '</td><tr>'; } $table .= '</table>'; echo $table; }
<?php require "../../../cgi_bin/phpFun.php"; require "../languages/language.php"; jCnn(); //------------------------------------------------- //Salva los Cambios //------------------------------------------------- if (isset($_REQUEST["save"])) { if (!isset($_REQUEST['showImages'])) { $_REQUEST['showImages'] = '0'; } if (!isset($_REQUEST['showChange'])) { $_REQUEST['showChange'] = '0'; } saveForm('Home', "idHome", $_REQUEST["idHome"]); } //------------------------------------------------- //Abre el Recordset //------------------------------------------------- $strsql = "select * from [Home] order by idHome limit 1"; ?> <html> <head> <meta content="text/html; charset=UTF-8" http-equiv="Content-Type"> <meta content="es" http-equiv="Content-Language"> <link href="../../../cgi_bin/jss/jss.css" rel="stylesheet" type="text/css"> <script src="../../../cgi_bin/jss/jss.js" type="text/javascript"></script> <title>Home</title> <base target="_self">
<?php require "../../../cgi_bin/phpFun.php"; require "../languages/language.php"; jCnn(); if (isset($_REQUEST["eliminar"])) { $strsql = "delete from [ratesByProduct] where id=" . $_REQUEST["eliminar"]; $results = $GLOBALS['db']->exec($strsql); } if (isset($_REQUEST["insertar"])) { $strsql = "insert into [ratesByProduct] (idProduct) values(" . $_SESSION['idProduct'] . ");"; $results = $GLOBALS['db']->exec($strsql); } if (isset($_REQUEST["salvar"])) { saveForm("ratesByProduct", "id", $_REQUEST["salvar"]); } //------------------------------------------------- //Establece las Condiciones y Abre el Recordset //------------------------------------------------- $strsql = "select idBy, idRate, rate, price, vatValue, vatPrice from [prices] where idProduct=" . $_SESSION['idProduct'] . " order by idRate limit 50"; $results = $GLOBALS['db']->query($strsql); $gv = $results->fetch(); if (!$gv['idBy'] && $_SESSION['idProduct'] > '0') { $strsqlRates = "select idRate from [rates] order by rate limit 50"; $resultsRate = $GLOBALS['db']->query($strsqlRates); while ($gvRate = $resultsRate->fetch()) { $strsqlins = 'INSERT INTO [ratesByProduct] (idProduct, idRate) VALUES(' . $_SESSION['idProduct'] . ',' . $gvRate['idRate'] . ')'; $results = $GLOBALS['db']->exec($strsqlins); if (!$strsqlins) { $err = $GLOBALS['db']->errorInfo(); echo '<hr>' . $strsqlins . '<hr>Error: ' . $err[2];
if (isset($_REQUEST['tabla'])) { $tabla = $_REQUEST['tabla']; $strsql = "select * from [{$tabla}] order by 2"; } if (isset($_REQUEST['$strsql'])) { $strsql = $_REQUEST['$strsql']; } //Abre SQL //--------------------------------------------- $rst = $GLOBALS['db']->query($strsql); $meta = $rst->getColumnMeta(0); $keyMaster = $meta["name"]; //Funciones //--------------------------------------------- if (isset($_REQUEST["salvar"])) { saveForm($tabla, $keyMaster, $_REQUEST["salvar"]); } elseif (isset($_REQUEST["eliminar"])) { $strCommand = 'delete from ' . $tabla . ' where ' . $keyMaster . '=' . $_REQUEST["eliminar"]; $res = $GLOBALS['db']->exec($strCommand); } elseif (isset($_REQUEST["insertar"])) { $strCommand = "insert into [" . $tabla . "] default values"; $res = $GLOBALS['db']->exec($strCommand); } //Ancho de Columna //--------------------------------------------- function retLen($col) { global $rst; switch ($rst->columnType($col)) { case SQLITE3_INTEGER || SQLITE3_FLOAT: $valRet = 8;
//------------------------------------------------- //Eliminar //------------------------------------------------- if (isset($_REQUEST["eliminar"])) { $strCommand = 'delete from products where idProduct=' . $_SESSION['idProduct']; $res = $GLOBALS['db']->exec($strCommand); $strCommand = 'delete from ratesByProduct where idProduct=' . $_SESSION['idProduct']; $res = $GLOBALS['db']->exec($strCommand); header("Location: search.php"); exit; } //------------------------------------------------- //Salva los Cambios //------------------------------------------------- if (isset($_REQUEST["save"])) { $_SESSION['idProduct'] = saveForm('products', 'idProduct', $_SESSION['idProduct']); } //------------------------------------------------- //Abre el Recordset //------------------------------------------------- $strsql = "SELECT * from products where idProduct = " . $_SESSION['idProduct']; $strImg = '../../../cgi_bin/phpFun.php?getImg=base64&strsql=' . base64_encode('SELECT [image] from [images] WHERE [tableName]=\'products\' and [id] = ' . $_SESSION['idProduct']); ?> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8"> <meta content="es" http-equiv="Content-Language"> <link href="../../../cgi_bin/jss/jss.css" rel="stylesheet" type="text/css"> <script src="../../../cgi_bin/jss/jss.js" type="text/javascript"></script> <title>Productos</title>
<?php require "../../../cgi_bin/phpFun.php"; require "../languages/language.php"; jCnn(); if (isset($_REQUEST["eliminar"])) { $strsql = "delete from [fees] where idFee=" . $_REQUEST["eliminar"]; $results = $GLOBALS['db']->exec($strsql); } if (isset($_REQUEST["insertar"])) { $strsql = "insert into [fees] (idMember) values(" . $_SESSION['idMember'] . ");"; $results = $GLOBALS['db']->exec($strsql); } if (isset($_REQUEST["salvar"])) { saveForm("fees", "idFee", $_REQUEST["salvar"]); } //------------------------------------------------- //Establece las Condiciones y Abre el Recordset //------------------------------------------------- $strsql = "select * from [feesBymembersByproducts] where idMember=" . $_SESSION['idMember'] . " order by periodicity limit 50"; $results = $GLOBALS['db']->query($strsql); //$gv = $results->fetch(); ?> <html> <head> <meta content="text/html; charset=UTF-8" http-equiv="Content-Type"> <meta content="es" http-equiv="Content-Language"> <link href="../../../cgi_bin/jss/jss.css" rel="stylesheet" type="text/css"> <script src="../../../cgi_bin/jss/jss.js" type="text/javascript"></script> <script src="../../../cgi_bin/jss/jssCalendar.js" type="text/javascript"></script>
} if ($_FILES && isset($_FILES['photo'])) { // Для одного файла, если только один //move_uploaded_file($_FILES['photo']['tmp_name'], $dir . DIRECTORY_SEPARATOR . $_FILES['photo']['name']); foreach ($_FILES['photo']['tmp_name'] as $key => $tmp_name) { move_uploaded_file($tmp_name, $dir . DS . $_FILES['photo']['name'][$key]); } } die; function saveForm($data, $serialize = 0) { if (!$serialize) { $str = ''; foreach ($data as $key => $value) { $str .= "{$key}={$value}" . PHP_EOL; } file_put_contents('forms.dat', $str, FILE_APPEND); } else { $str = serialize($data); file_put_contents('serialize.dat', $str); } } if ($_GET) { if (!isset($_POST['agree'])) { die('Вы не согласились'); } echo "Привет, " . $_POST['name']; saveForm($_GET); } else { echo "Пустой"; }