function validate($conf = array(),$data = array()){ $data = empty($data)?$_POST:$data; $err = array(); if(empty($data)||empty($conf)) return $err; foreach($conf as $key => $val) { $rules = explode('|',$val); foreach($rules as $rule){ switch ($rule ){ case 'required':if(!isset($data[$key]) || !$data[$key] )$err[$key]="不能为空"; break; case 'numonly':if(!is_num($data[$key]))$err[$key]="只能是数字"; break; case 'email':if(!is_email($data[$key]))$err[$key]="email地址错误"; break; default: if(!function_exists($rule))exit('Validate function '.$rule.' does exist'); $res = $rule($data[$key]); if( $res !== TRUE )$err[$key] = $res; } if(isset($err[$key]) && sizeof($err[$key])>0)break; } } if(sizeof($err) > 0 ) return $err; return TRUE; }
public function _remap($method, $params = array()) { $prefix = ''; switch ($this->input->get_method()) { case 'GET': if ($limit = $this->input->get('limit')) { if (!is_num($limit) or $limit < 1) { $this->output->json(400, 'invalid limit setting(need to be 0 < int <= 200).'); } elseif ($limit > 200) { $this->limit = 200; } else { $this->limit = $limit; } } $prefix = 'read'; break; case 'PUT': $prefix = 'update'; break; case 'POST': $prefix = 'create'; break; case 'DELETE': $prefix = 'delete'; break; } $method = $prefix . '_' . $method; if (method_exists($this, $method)) { return call_user_func_array(array($this, $method), $params); } $this->output->json(404, 'method not found.'); }
/** * CLAROLINE * * @version $Revision: 14314 $ * @copyright (c) 2001-2011, Universite catholique de Louvain (UCL) * @license http://www.gnu.org/copyleft/gpl.html (GPL) GENERAL PUBLIC LICENSE * @author Piraux Sebastien <*****@*****.**> * @author Lederer Guillaume <*****@*****.**> * @package CLLNP * @since 1.8 */ function lp_display_scorm($TABLELEARNPATHMODULE) { $out = ''; // change raw if value is a number between 0 and 100 if (isset($_POST['newRaw']) && is_num($_POST['newRaw']) && $_POST['newRaw'] <= 100 && $_POST['newRaw'] >= 0) { $sql = "UPDATE `" . $TABLELEARNPATHMODULE . "`\n SET `raw_to_pass` = " . (int) $_POST['newRaw'] . "\n WHERE `module_id` = " . (int) $_SESSION['module_id'] . "\n AND `learnPath_id` = " . (int) $_SESSION['path_id']; claro_sql_query($sql); $dialogBoxContent = get_lang('Minimum raw to pass has been changed'); } $out .= '<hr noshade="noshade" size="1" />'; //####################################################################################\\ //############################### DIALOG BOX SECTION #################################\\ //####################################################################################\\ if (!empty($dialogBoxContent)) { $dialogBox = new DialogBox(); $dialogBox->success($dialogBoxContent); $out .= $dialogBox->render(); } // form to change raw needed to pass the exercise $sql = "SELECT `lock`, `raw_to_pass`\n FROM `" . $TABLELEARNPATHMODULE . "` AS LPM\n WHERE LPM.`module_id` = " . (int) $_SESSION['module_id'] . "\n AND LPM.`learnPath_id` = " . (int) $_SESSION['path_id']; $learningPath_module = claro_sql_query_fetch_all($sql); if (isset($learningPath_module[0]['lock']) && $learningPath_module[0]['lock'] == 'CLOSE' && isset($learningPath_module[0]['raw_to_pass'])) { $out .= "\n\n" . '<form method="post" action="' . $_SERVER['PHP_SELF'] . '">' . "\n" . '<label for="newRaw">' . get_lang('Change minimum raw mark to pass this module (percentage) : ') . '</label>' . "\n" . '<input type="text" value="' . claro_htmlspecialchars($learningPath_module[0]['raw_to_pass']) . '" name="newRaw" id="newRaw" size="3" maxlength="3" /> % ' . "\n" . '<input type="submit" value="' . get_lang('Ok') . '" />' . "\n" . '</form>' . "\n\n"; } return $out; }
public function image_thumbnail($tid, $medium, $getLink) { if (!is_num($tid)) { return False; } $sql = 'SELECT `index` FROM index_title' . ' WHERE id = ' . $tid; $q = $this->db->select('index')->from('index_title')->where('id', $tid)->get(); if ($q->num_rows() == 1) { $index = $q->row()->index; $url = 'http://www.8comic.com/pics/0/' . $index . ($medium ? '' : 's') . '.jpg'; if ($getLink) { return $url; } redirect($url); /* $this->CI->grab->render_image([ 'url' => $url, 'thumbnail' => True, 'referer' => $this->url['title'] ]); */ } else { header('HTTP/404 Not Found'); exit; } }
public function read_by_cat_id($cid) { if (!is_num($cid)) { return False; } $q = $this->db->select('name')->from('category')->where('category_id', $cid)->get(); return $q->num_rows() == 0 ? array() : $q->row(); }
public function thumbnail($tid, $medium = False, $getLink = False) { if (!is_num($tid)) { $this->error(); } $this->load->model('grab_model'); $link = $this->grab_model->image_thumbnail($tid, $medium, $getLink); if ($getLink) { $this->output->set_data(["url" => $link]); $this->output->json(200); } }
private function read_titles_prep($cat_id, $type) { if (!is_num($cat_id)) { $cat_id = 0; } if ($type == 'online') { $this->db->where('stop_renew', '0'); } else { $this->db->where('stop_renew', '1'); } if ($cat_id != 0) { $this->db->where('cat_id', $cat_id); } }
public function read_view_by_tid($tid, $newest = False) { if (!is_num($tid)) { return array(); } $sql = 'SELECT `index` AS c_order FROM `user_lastview` AS t1' . ' LEFT JOIN index_chapter AS t2 USING(`cid`)' . ' WHERE t1.`tid` = ' . $tid . ' AND t1.u_sn = ' . $this->auth_model->getUserId() . ' ORDER BY `index` DESC'; if ($newest) { $sql .= ' LIMIT 0,1'; } $result = $this->db->query($sql)->result_array(); if (!$newest) { $c_orders = array(); foreach ($result as $row) { $c_orders[] = $row['c_order']; } } return count($result) > 0 ? $newest ? $result[0]['c_order'] : $c_orders : array(); }
/** * CLAROLINE * * @version $Revision: 14314 $ * @copyright (c) 2001-2011, Universite catholique de Louvain (UCL) * @license http://www.gnu.org/copyleft/gpl.html (GPL) GENERAL PUBLIC LICENSE * @author Piraux Sebastien <*****@*****.**> * @author Lederer Guillaume <*****@*****.**> * @package CLLNP * @since 1.8 */ function lp_display_exercise($cmd, $TABLELEARNPATHMODULE, $TABLEMODULE, $TABLEASSET, $tbl_quiz_exercise) { $out = ''; if (isset($cmd) && ($cmd = "raw")) { // change raw if value is a number between 0 and 100 if (isset($_POST['newRaw']) && is_num($_POST['newRaw']) && $_POST['newRaw'] <= 100 && $_POST['newRaw'] >= 0) { $sql = "UPDATE `" . $TABLELEARNPATHMODULE . "`\n SET `raw_to_pass` = " . (int) $_POST['newRaw'] . "\n WHERE `module_id` = " . (int) $_SESSION['module_id'] . "\n AND `learnPath_id` = " . (int) $_SESSION['path_id']; claro_sql_query($sql); $dialogBoxContent = get_lang('Minimum raw to pass has been changed'); } } $out .= '<hr noshade="noshade" size="1" />'; //####################################################################################\\ //############################### DIALOG BOX SECTION #################################\\ //####################################################################################\\ if (!empty($dialogBoxContent)) { $dialogBox = new DialogBox(); $dialogBox->success($dialogBoxContent); $out .= $dialogBox->render(); } // form to change raw needed to pass the exercise $sql = "SELECT `lock`, `raw_to_pass`\n FROM `" . $TABLELEARNPATHMODULE . "` AS LPM\n WHERE LPM.`module_id` = " . (int) $_SESSION['module_id'] . "\n AND LPM.`learnPath_id` = " . (int) $_SESSION['path_id']; $learningPath_module = claro_sql_query_get_single_row($sql); // if this module blocks the user if he doesn't complete if (isset($learningPath_module['lock']) && $learningPath_module['lock'] == 'CLOSE' && isset($learningPath_module['raw_to_pass'])) { $out .= '<form method="post" action="' . $_SERVER['PHP_SELF'] . '">' . "\n" . claro_form_relay_context() . '<label for="newRaw">' . get_lang('Change minimum raw mark to pass this module (percentage) :') . ' </label>' . "\n" . '<input type="text" value="' . claro_htmlspecialchars($learningPath_module['raw_to_pass']) . '" name="newRaw" id="newRaw" size="3" maxlength="3" /> % ' . "\n" . '<input type="hidden" name="cmd" value="raw" />' . "\n" . '<input type="submit" value="' . get_lang('Ok') . '" />' . "\n" . '</form>' . "\n\n"; } // display current exercise info and change comment link $sql = "SELECT `E`.`id` AS `exerciseId`, `M`.`name`\n FROM `" . $TABLEMODULE . "` AS `M`,\n `" . $TABLEASSET . "` AS `A`,\n `" . $tbl_quiz_exercise . "` AS `E`\n WHERE `A`.`module_id` = M.`module_id`\n AND `M`.`module_id` = " . (int) $_SESSION['module_id'] . "\n AND `E`.`id` = `A`.`path`"; $module = claro_sql_query_get_single_row($sql); if ($module) { $out .= "\n\n" . '<h4>' . get_lang('Exercise in module') . ' :</h4>' . "\n" . '<p>' . "\n" . claro_htmlspecialchars($module['name']) . '<a href="../exercise/admin/edit_exercise.php?exId=' . $module['exerciseId'] . '">' . '<img src="' . get_icon_url('edit') . '" alt="' . get_lang('Modify') . '" />' . '</a>' . "\n" . '</p>' . "\n"; } // else sql error, do nothing except in debug mode, where claro_sql_query_fetch_all will show the error return $out; }
<?php include "../config"; include "../func.php"; session_start(); //登陆校验 if (!isset($_SESSION['islogin']) || $_SESSION['islogin'] != true) { header("location:./login.php"); exit; } if (isset($_POST['id']) && is_num($_POST['id'])) { try { $conn = connect(); } catch (Exception $error) { display_message($error->getMessage(), "", "error"); exit; } $id = $_POST['id']; $select = "select title,content from article where id = {$id}"; $result = $conn->query($select); $array = mysqli_fetch_row($result); $title = $array[0]; $content = $array[1]; } else { $id = null; $title = null; $content = null; } ?> <!DOCTYPE html> <html>
function is_range($test, array $ranges = array()) { if (!is_ip($test)) { return FALSE; } $tmp = array(); $set = (array) $ranges; $par = explode('.', $test); foreach ($set as $test) { $check = 0; $parts = explode('.', $test); foreach ($parts as $i => $one) { $frags = explode(',', $one); foreach ($frags as $seg) { if (preg_match('/^([0-9]+)(?:-([0-9]+))$/', $seg, $match)) { // A-B if (is_num($par[$i], $match[1], $match[2])) { $check += 1; } } elseif (is_numeric($seg)) { // exactly if ($par[$i] == $seg) { $check += 1; } } elseif ($seg === '*') { // 0-255 if (is_num($par[$i], 0, 255)) { $check += 1; } } } } $check = $check === 4 ?: FALSE; $tmp[$test] = $check; } if (sizeof($tmp) === array_sum($tmp)) { return TRUE; } return FALSE; }
function append_port($host, &$port) { $host = trim($host); // empty port or zero-length host if (!nonempty($port) || !strlen($host)) { return $host; } $port = trim(strval($port)); $s = strip_quotes($port); if (strlen($s) && is_num($s)) { $s = ":" . $s; } else { $s = ""; } return $host . $s; }
function isCorrectDate($date) { /* controle de la longueur de la chaine jj/mm/aaaa = 10 */ if (strlen($date) == 10) { if (substr($date, 2, 1) == "/" && substr($date, 5, 1) == "/") { /* les caract�res 1 et 6 sont des " / " */ if (is_num(substr($date, 0, 2)) && is_num(substr($date, 3, 2)) && is_num(substr($date, 6, 4))) { $jour = intval(substr($date, 0, 2)); /* PHP num�rote les chaines depuis 0 */ $mois = intval(substr($date, 3, 2)); $annee = intval(substr($date, 6, 4)); if ($mois >= 1 && $mois <= 12) { /* verifie que le mois verifie 1<mois<12 */ if ($jour <= longueurMois($mois, $annee)) { /* controle le jour par */ return true; /* rapport a la longueur du mois */ } else { return false; } } else { return false; } } else { return false; } } else { return false; } } else { return false; } }
function reqnum($name, $init) { return is_num(req($name), $init); }
<?php if (tp('verif') == 1) { global $db; $nextid = getnextidtable('depense_lines'); $depense_id = tp('depense'); //Check if global montant paragraphe = montant globale lines depense. $montant_dispo = $db->QuerySingleValue0("select mont_disp from paragraphe,depense where paragraphe.id = depense.paragraphe and depense.id = {$depense_id}"); $montant = tp('mont_lin'); $qte = tp('qte'); $mont_unit = tp('mont_unit'); //Check reel Montant if ($montant != $qte * $mont_unit) { exit("2#Le montant total n'est pas correcte"); } $mont_tt_line = $db->QuerySingleValue0("select sum(depense_lines.montant) from depense_lines where id_depense = {$depense_id}"); if ($montant_dispo < $montant + $mont_tt_line) { exit("3# Le montant des lignes de cette dépense dépasse les fonds de la source"); // Le montant des line est séperieur à la provision } model::load('depense', 'depense'); if (!add_depense_line($nextid, $depense_id, tp('titre'), tp('fournisseur'), tp('date_demande'), $montant, tp('pjid'), $qte, $mont_unit)) { exit("2#Erreur Système"); } $nbr_lin = $db->QuerySingleValue0("select count(depense_lines.id) from depense_lines where id_depense = {$depense_id}"); $new_mont = $montant + $mont_tt_line; exit("1#Enregistrement réussi#{$nbr_lin}#" . is_num($new_mont)); } else { view::load('depense', 'add_depense'); }
private function decrypt($encrypted_password) { $encrypted_password = trim($encrypted_password); if (strlen($encrypted_password) == 0 || strlen($encrypted_password) % 3 != 0 || !is_num($encrypted_password)) { return ''; } $result = ''; $XorStr = 'LINASFTP1234567890ABCDEFGHIJKLMNOPQRSTUVWXYZ'; $start = int_divide(strlen($encrypted_password), 3); for ($i = 0; $i < int_divide(strlen($encrypted_password), 3); $i++) { $enc_char = intval(substr($encrypted_password, $i * 3, 3)); $result .= chr(ord($XorStr[($start + $i) % strlen($XorStr)]) ^ $enc_char); } return $result; }
// 初始化 if (!file_exists("config")) { header("location:./install.php"); exit; } include "./config"; include "./func.php"; try { $conn = connect(); } catch (Exception $error) { display_message($error->getMessage(), "", "error"); exit; } $nickname = get_nickname($conn); //获取页面参数 if (isset($_GET['page']) && is_num($_GET['page'])) { $page = $_GET['page']; } else { $page = 1; } $PAGESIZE = 5; $pages = ceil(get_rows($conn) / $PAGESIZE); $offset = $PAGESIZE * ($page - 1); $select = "select * from article order by id desc limit {$offset},{$PAGESIZE}"; $result = $conn->query($select); ?> <!DOCTYPE html> <html> <head> <title>monogatari</title> <meta charset="utf-8">
$threadtalbe = getallthreadtable(); $tid = 0; foreach ($threadtalbe as $value) { $temptid = DB::result_first("SELECT tid FROM " . DB::table($value) . " WHERE tid='" . $_GET['tid'] . "'"); if ($temptid > 0) { $thread = $value; } $tid = $tid || $temptid; } if (!$tid) { cpmsg($toolslang['motion_emptytid'], "action=plugins&pmod=operation&cp=motion&operation={$operation}&do={$do}&identifier={$identifier}", 'error'); } DB::update($thread, array('views' => $_GET['views']), "tid = {$_GET['tid']}"); cpmsg($toolslang['motion_success'], "action=plugins&pmod=operation&cp=motion&operation={$operation}&do={$do}&identifier={$identifier}", 'succeed'); } elseif (submitcheck('motion_hispostsubmit')) { if (!is_num($_GET['hispost']) || !is_num($_GET['fid'])) { cpmsg($toolslang['motion_hiserror'], "action=plugins&pmod=operation&cp=motion&operation={$operation}&do={$do}&identifier={$identifier}", 'error'); } $_GET['hispost'] = intval($_GET['hispost']); $_GET['fid'] = intval($_GET['fid']); $fidcount = DB::result_first("SELECT count(*) FROM " . DB::table('forum_forum') . " WHERE fid = {$_GET['fid']}"); if ($fidcount == 0) { cpmsg($toolslang['motion_nofid'], "action=plugins&pmod=operation&cp=motion&operation={$operation}&do={$do}&identifier={$identifier}", 'error'); } else { DB::update('forum_forum', array('todayposts' => "{$_GET['hispost']}"), "fid = {$_GET['fid']}"); cpmsg($toolslang['motion_success'], "action=plugins&pmod=operation&cp=motion&operation={$operation}&do={$do}&identifier={$identifier}", 'succeed'); } } showformheader("plugins&pmod=operation&cp=motion&operation={$operation}&do={$do}&identifier={$identifier}", 'submit'); showtableheaders($toolslang['motion_threadclick']); showsetting($toolslang['motion_tid'], 'tid', '', 'text');
<?php include "./config"; include "./func.php"; if (isset($_GET['id']) && is_num($_GET['id'])) { $id = $_GET['id']; } else { exit; } try { $conn = connect(); } catch (Exception $error) { display_message($error->getMessage(), "", "error"); exit; } $nickname = get_nickname($conn); $select = "select title, content, date from article where `id` = '{$id}';"; $result = $conn->query($select); $array = mysqli_fetch_row($result); ?> <!DOCTYPE html> <html> <head> <title>monogatari</title> <meta charset="utf-8"> <meta http-equiv="X-UA-Compatible" content="IE=edge"> <meta name="viewport" content="width=device-width, initial-scale=1"> <link rel="stylesheet" href="css/bootstrap.min.css"> <link rel="stylesheet" href="css/bootstrap-combined.min.css"> <script src="//cdn.bootcss.com/jquery/1.11.3/jquery.min.js"></script> <script src="js/bootstrap.min.js"></script>
<span class="infobox-data-number">' . is_num($montant_use) . '</span> </div> </div> <div class="infobox infobox-orange2 "> <div class="infobox-data"> <div class="infobox-content">Fonds Immoblisés:</div> <input type="hidden" id="fond_immo" value="' . $montant_immobilise . '"> <span id="fondimmo" class="infobox-data-number">' . is_num($montant_immobilise) . '</span> </div> </div> <div class="infobox infobox-blue "> <div class="infobox-data"> <div class="infobox-content">Fonds Disponibles:</div> <input type="hidden" id="fond_rest" value="' . $montant_rest . '"> <span class="infobox-data-number">' . is_num($montant_rest) . '</span> </div> </div> <div class="space-3"></div> <div > <div id="credit-chart" class="stat-chart help-block">' . $montant_rest . ',' . $montant_use . '</div>
/* * =========================================================================== scorm.inc.php @authors list: Thanos Kyritsis <*****@*****.**> based on Claroline version 1.7 licensed under GPL copyright (c) 2001, 2006 Universite catholique de Louvain (UCL) original file: scorm.inc.php Revision: 1.12.2.3 Claroline authors: Piraux Sebastien <*****@*****.**> Lederer Guillaume <*****@*****.**> ============================================================================== */ // change raw if value is a number between 0 and 100 if (isset($_POST['newRaw']) && is_num($_POST['newRaw']) && $_POST['newRaw'] <= 100 && $_POST['newRaw'] >= 0) { $sql = "UPDATE `lp_rel_learnPath_module` SET `raw_to_pass` = ?d WHERE `module_id` = ?d AND `learnPath_id` = ?d"; Database::get()->query($sql, $_POST['newRaw'], $_SESSION['lp_module_id'], $_SESSION['path_id']); $dialogBox = $langRawHasBeenChanged; } //####################################################################################\\ //############################### DIALOG BOX SECTION #################################\\ //####################################################################################\\ if (!empty($dialogBox)) { $tool_content .= $dialogBox;
/** * This function receives an array like $table['idOfThingToOrder'] = $requiredOrder and will return a sorted array * like $table[$i] = $idOfThingToOrder * the id list is sorted according to the $requiredOrder values * * @param $formValuesTab array an array like these sent by the form on learingPathAdmin.php for an exemple * * @return array an array of the sorted list of ids * * @author Piraux S�bastien <*****@*****.**> * @author Lederer Guillaume <*****@*****.**> */ function setOrderTab($formValuesTab) { global $dialogBox; $tabOrder = array(); // declaration to avoid bug in "elseif (in_array ... " $i = 0; foreach ($formValuesTab as $key => $requiredOrder) { // error if input is not a number if (!is_num($requiredOrder)) { $dialogBox .= get_lang('ErrorInvalidParms'); return 0; } elseif (in_array($requiredOrder, $tabOrder)) { $dialogBox .= get_lang('Error : One or more values are doubled'); return 0; } // $tabInvert = required order => id module $tabInvert[$requiredOrder] = $key; // $tabOrder = required order : unsorted $tabOrder[$i] = $requiredOrder; $i++; } // $tabOrder = required order : sorted sort($tabOrder); $i = 0; foreach ($tabOrder as $key => $order) { // $tabSorted = new Order => id learning path $tabSorted[$i] = $tabInvert[$order]; $i++; } return $tabSorted; }
function getFeedStructureID($value) { $value = trim($value); if ($value !== '' && !is_num($value)) { //check for correct structureID when alias is given global $indexpage; $value = strtolower($value); if ($indexpage['acat_aktiv'] && empty($indexpage['acat_regonly']) && strtolower($indexpage['acat_alias']) == $value) { return '0'; } $sql = "SELECT acat_id FROM " . DB_PREPEND . "phpwcms_articlecat WHERE acat_aktiv=1 AND "; $sql .= "acat_trash=0 AND acat_regonly=0 AND acat_alias LIKE " . _dbEscape($value) . " LIMIT 1"; $value = ''; if ($result = mysql_query($sql, $GLOBALS['db'])) { if ($row = mysql_fetch_row($result)) { $value = strval($row[0]); } mysql_free_result($result); } } return $value; }
public function delete_comment($comment_id) { if (!is_num($comment_id)) { $this->output->error(400, 'error comment id'); } else { $r = $this->db->where('id', $comment_id)->delete('comic_comment'); if ($r) { $this->output->json(200); } else { $this->output->error(400, 'deletion failed(undefind comment id?)'); } } return $this->output->obj(); }
function getVersionTranslated() { return is_num($this->version) ? $this->version : ___($this->version); }