/** * returns $number news items from class $type */ function get_news($type, $number) { $news = "SELECT `ID`, `timestamp`, `subject`, `body` FROM `news` WHERE `class`='{$type}' ORDER BY `ID` DESC LIMIT {$number}"; connect_sql(); $news = @query($news) or die("Error getting the news."); // see if we don't have any news if (num_rows($news) == 0) { return "No news."; } else { $to_return = ""; while ($row = result($news)) { $id = $row->ID; $timestamp = $row->timestamp; $subject = stripslashes($row->subject); $body = $row->body; // convert line breaks to <br />'s $body = str_replace("\\r\\n", "<br />", $body); // for windows and IP protocols $body = str_replace("\\n", "<br />", $body); // for nix $body = str_replace("\\r", "<br />", $body); // for mac $body = stripslashes($body); $to_return .= $id . "::::" . $timestamp . "::::" . $subject . "::::" . $body . "_____"; } return $to_return; } disconnect_sql(); }
function turn($arg, $mode1, $mode2) { switch (result($arg, $mode1)) { case 0 . "": return "零" . turn2($mode2); case 1 . "": return "壹" . turn2($mode2); case 2 . "": return "贰" . turn2($mode2); case 3 . "": return "叁" . turn2($mode2); case 4 . "": return "肆" . turn2($mode2); case 5 . "": return "伍" . turn2($mode2); case 6 . "": return "陆" . turn2($mode2); case 7 . "": return "柒" . turn2($mode2); case 8 . "": return "捌" . turn2($mode2); case 9 . "": return "玖" . turn2($mode2); default: return " "; } }
function isFree() { $rs = qdb("SELECT IS_FREE_LOCK('" . $this->lockname . "')"); $lock = (bool) result($rs, 0); mysqli_free_result($rs); return $lock; }
/** * Gets a dot-notated key from an array, with a default value if it does * not exist. * * @param array $array The search array * @param mixed $key The dot-notated key or array of keys * @param string $default The default value * @return mixed */ public static function get($array, $key, $default = null) { if (!is_array($array) and !$array instanceof \ArrayAccess) { throw new \InvalidArgumentException('First parameter must be an array or ArrayAccess object.'); } if (is_null($key)) { return $array; } if (is_array($key)) { $return = array(); foreach ($key as $k) { $return[$k] = static::get($array, $k, $default); } return $return; } foreach (explode('.', $key) as $key_part) { if (($array instanceof \ArrayAccess and isset($array[$key_part])) === false) { if (!is_array($array) or !array_key_exists($key_part, $array)) { return result($default); } } $array = $array[$key_part]; } return $array; }
/** * Provides a helper in various ways. * * @return mixed Could be object, boolean, or callback result. */ public static function __callStatic($fn, $args = array()) { if (isset(static::$helpers[$fn]) || static::load($fn)) { return result(static::$helpers[$fn], $args); } trigger_error("Cannot load helper {$fn}", E_USER_NOTICE); }
/** * Get the specified URI segment, return default if it doesn't exist. * * Segment index is 1 based, not 0 based * * @param string $segment The 1-based segment index * @param mixed $default The default value * @return mixed */ public function getSegment($segment, $default = null) { if (isset($this->segments[$segment - 1])) { return $this->segments[$segment - 1]; } return result($default); }
public function val() { $this->db->select('*'); $this->db->from('regi'); $query = $this->db->val(); return $query->result(); print_r(result()); }
function query($sql, $callback){ $result = result($sql); echo "<br>"; while ($row = mysql_fetch_array($result)) { call_user_func($callback, $row); } }
function validate($name, $password) { $CI =& get_instance(); $query = $this->db->query("SELECT id, username, password FROM USERS WHERE username = '******' && password = '******'"); if (count($query) > 0) { return $query . result(); } return false; }
function loginit($logfile) { global $lang; showjsmessage($lang['init_log'] . ' ' . $logfile); $fp = @fopen('./forumdata/logs/' . $logfile . '.php', 'w'); @fwrite($fp, '<' . '?PHP exit(); ?' . ">\n"); @fclose($fp); result(1, 1, 0); }
function getFormno() { $reg = result("SELECT formno as reg FROM `formgen` "); if (isset($reg[0]['reg'])) { mysql_query("UPDATE `formgen` SET `formno`='" . (int) ($reg[0]['reg'] + 1) . "'"); return $reg[0]['reg'] + 1; } else { return 100001; } }
function fib($x, $y, $term) { $fib = bcadd($x, $y); $term += 1; if (strlen($fib) >= 1000) { echo "Term is " . $term . "\n"; result('4782', $term); } else { fib($y, $fib, $term); } }
function main($argv) { $time_start_all = microtime(true); $save = getcwd(); $argument_list = get_args($argv); //print_r($argument_list); if ($argument_list == 0) { return 0; } if (isset($argument_list['argv']['clean'])) { if (chdir($_SERVER['TMPDIR']) == TRUE) { if (file_exists($_SERVER['TMPDIR'] . 'no_x')) { system("rm -R no_x"); echo 'Succès de la suppression', "\n"; } else { echo 'Echec de la suppression. Le dossier n\'éxiste peut être pas ?' . "\n"; } } else { echo 'Echec de la suppression des fichiers temporaires' . "\n"; } return 0; } $exist = false; chdir($_SERVER['TMPDIR']); if (!file_exists($_SERVER['TMPDIR'] . 'no_x')) { mkdir($_SERVER['TMPDIR'] . 'no_x'); } chdir($_SERVER['TMPDIR'] . 'no_x/'); if (!is_writable('~' . $argument_list['cible'] . '_' . $argument_list['source']) || !isset($argument_list['argv']['fast'])) { chdir($save); $list_dico = get_dico_array($time_start_message, $time_end_message, $argument_list['source']); $messages = get_message_array_and_display($sort_time_start, $sort_time_end, $time_end_all, $result, $time_start, $time_end, $time_start_display, $time_end_display, $argument_list['cible'], $list_dico); $time_end_all = microtime(true); $time = $time_end - $time_start; $time_all = $time_end_all - $time_start_all; $time_message = $time_end_message - $time_start_message; $time_display = $time_end_display - $time_start_display; $sort_time = $sort_time_end - $sort_time_start; result($sort_time, $time, $time_all, $time_message, $time_display); echo count($list_dico), ' valeurs trouve dans le dictionnaire.', "\n"; echo $messages; cache_generator("~" . $argument_list['cible'] . '_' . $argument_list['source'], $result); } else { chdir($_SERVER['TMPDIR']); if (!file_exists($_SERVER['TMPDIR'] . 'no_x')) { mkdir($_SERVER['TMPDIR'] . 'no_x'); } chdir($_SERVER['TMPDIR'] . 'no_x/'); cache_receiver('~' . $argument_list['cible'] . '_' . $argument_list['source'], $select_time, $display_time); $time_end_all = microtime(true); $time_all = $time_end_all - $time_start_all; result_cache($select_time, $display_time, $time_all); } }
public function cargarAgente() { $query = $this->db->query("SELECT * \r\n FROM agente where estatus=1"); $resultado = array(); if ($query->num_rows() > 0) { foreach ($query->result() as $row) { $resultado[] = $row; } return $resultado; $query->free - result(); } }
public function obtenerProcedimientoTicket($ticket, $sector, $ente) { $sql = "SELECT DISTINCT act.id actividadid, act.descripcion actividad, actf.funcionario idfuncionario, CASE tact.estatus\r\n WHEN 0 THEN 'ELIMINADO'\r\n WHEN 1 THEN 'PENDIENTE'\r\n WHEN 3 THEN 'EN ESPERA'\r\n WHEN 2 THEN 'RECIBIDO'\r\n\t\t\t\t WHEN 4 THEN 'APROBADO'\r\n WHEN 5 THEN 'RECHAZADO' END as estatus, \r\n tact.observacionresponsable observacionfuncionario, tact.observacionrespuesta respuestafuncionario, \r\n CONCAT(p.nombre, ' ', p.apellido) encargado\r\n FROM ticket_actividad tact \r\n INNER JOIN actividad act ON tact.actividad=act.id \r\n INNER JOIN actividad_funcionario actf ON act.id=actf.actividad \r\n INNER JOIN funcionario f ON f.id=actf.funcionario\r\n INNER JOIN persona p ON p.id=f.persona\r\n INNER JOIN tramite t ON t.id=act.tramite\r\n INNER JOIN sector_tipoayuda sta ON t.sector_tipoayuda=sta.id \r\n INNER JOIN ente_sector es on es.sector= sta.sector \r\n INNER JOIN tramite_funcionario tfn on tfn.tramite=t.id\r\n INNER JOIN funcionario fn on tfn.funcionario=fn.id \r\n WHERE tact.ticket={$ticket} and sta.sector={$sector} and fn.ente={$ente} "; $query = $this->db->query($sql); if ($query->num_rows() > 0) { foreach ($query->result() as $row) { $resultado[] = $row; } return $resultado; $query->free - result(); } }
public function cargarTipoUsuario() { $query = $this->db->query("SELECT * \r\n FROM bdgenerica.tipousuario where estatus=1"); $resultado = array(); $resultdb = array(); if ($query->num_rows() > 0) { foreach ($query->result() as $row) { $resultado[] = $row; } return $resultado; $query->free - result(); } }
public function cargarDivisiones($dependencia) { $query = $this->db->query("SELECT * \r\n FROM bdgenerica.division where dependencia={$dependencia} "); $resultado = array(); $resultdb = array(); if ($query->num_rows() > 0) { foreach ($query->result() as $row) { $resultado[] = $row; } return $resultado; $query->free - result(); } }
public function cargarMenuConPermiso($id) { $query = $this->db->query("SELECT id, text as nombre, padre as padre \r\n FROM bdgenerica.menu \r\n inner join bdgenerica.permiso on bdgenerica.menu.id= bdgenerica.permiso.menu\r\n where bdgenerica.menu.padre!='' and bdgenerica.menu.sistema=2 and bdgenerica.permiso.tipousuario={$id}"); $resultado = array(); $resultdb = array(); if ($query->num_rows() > 0) { foreach ($query->result() as $row) { $resultado[] = $row; } return $resultado; $query->free - result(); } }
function tipousuario() { $db_generica = $this->load->database('bdgenerica', TRUE); $query1 = $this->db->query("SELECT * FROM tipousuario"); $tipo = array(); if ($query1->num_rows() > 0) { foreach ($query1->result() as $tipousuario) { $tipo[] = $tipousuario; } return $tipo; $query1->free - result(); } }
function cargarTipoCargo() { $db_generica = $this->load->database('bdgenerica', TRUE); //Inicia la BD generica $query1 = $db_generica->query("SELECT * FROM cargo Order by id"); $tipo = array(); if ($query1->num_rows() > 0) { foreach ($query1->result() as $institucion) { $tipo[] = $institucion; } return $tipo; $query1->free - result(); } }
public function consultarInstitucion() { $db_generica = $this->load->database('bdgenerica', TRUE); $sql = 'SELECT * FROM institucion'; $query = $db_generica->query($sql); $resultado = array(); if ($query->num_rows() > 0) { foreach ($query->result() as $row) { $resultado[] = $row; } return $resultado; $query->free - result(); } }
function cargarestado() { $db_generica = $this->load->database('bdgenerica', TRUE); //Inicia la BD generica $query1 = $db_generica->query("SELECT * FROM estado Order by id"); $estado = array(); if ($query1->num_rows() > 0) { foreach ($query1->result() as $esta) { $estado[] = $esta; } return $estado; $query1->free - result(); } }
function dir_clear($dir) { global $lang; showjsmessage($lang['clear_dir'] . ' ' . $dir); $directory = dir($dir); while ($entry = $directory->read()) { $filename = $dir . '/' . $entry; if (is_file($filename)) { @unlink($filename); } } $directory->close(); result(1, 1, 0); }
function reducer($num, $sieve, $primes, $target) { $negSieve = sieve($num, $primes); $new = $primes; foreach ($negSieve as $key => $value) { if ($value == 0 && isPrime($key, $primes)) { if (!in_array($key, $primes)) { $new[] = $key; if (count($new) - 1 == $target) { result(104743, $new[$target - 1]); die; } } } } return $new; }
public function consultarDependencias($id) { $db_generica = $this->load->database('bdgenerica', TRUE); $sql = 'SELECT d . * FROM dependencia d JOIN piso_dependencia ps ON ps.dependencia = d.id JOIN piso p ON ps.piso = p.id AND p.institucion=' . $id; $query = $db_generica->query($sql); if ($query->num_rows() > 0) { foreach ($query->result() as $row) { $resultado[] = $row; } return $resultado; $query->free - result(); } }
/** * Component definition (generator) * * Because it contains yield, it returns a new instance of Generator when called. */ function gitHubContribution($name) { global $httpClient; // ugly hack, DO NOT try this at home list($data) = (yield $httpClient->get("https://github.com/{$name}.json")); $events = json_decode($data, JSON_OBJECT_AS_ARRAY); if (!isset($events[0])) { (yield result("No info")); } $event = $events[0]; $composerUrl = str_replace('https://', 'https://raw.', $event['repository']['url']) . '/master/composer.json'; list($composerData) = (yield $httpClient->get($composerUrl)); if ($composer = json_decode($composerData, JSON_OBJECT_AS_ARRAY)) { (yield result("Last change to composer project {$composer['name']}")); } else { (yield result("Last change to github repo {$event['repository']['url']}")); } }
function cargarParroquia($i) { $db_generica = $this->load->database('bdgenerica', TRUE); //Inicia la BD generica // if ($i != '') { $query1 = $db_generica->query("SELECT * FROM parroquia where municipio={$i} Order by id"); } else { $query1 = $db_generica->query("SELECT * FROM parroquia Order by id"); } $estado = array(); if ($query1->num_rows() > 0) { foreach ($query1->result() as $esta) { $estado[] = $esta; } return $estado; $query1->free - result(); } }
/** * Return the user's type * * if $id is submitted, return what type the user is; else, get the user from the session. * Can return "user," "parent," "teacher," or "admin" */ function user_type($id = "") { // look up the user's type in the database if ($id != "") { $user_type = @query("SELECT `type` FROM `users` WHERE `ID`='{$id}' LIMIT 1") or die("Error checking the database."); while ($row = result($user_type)) { switch ($row->type) { case 1: return "user"; break; case 2: return "teacher"; break; case 3: return "admin"; break; case 4: return "parent"; break; } } } else { if (isset($_SESSION['type'])) { switch ($_SESSION['type']) { case 1: return "user"; break; case 2: return "teacher"; break; case 3: return "admin"; break; case 4: return "parent"; break; } } else { return ""; } } }
function cargarMunicipio($id) { $db_generica = $this->load->database('bdgenerica', TRUE); //Inicia la BD generica // //console.log($id); if ($id != '') { $query1 = $db_generica->query("SELECT * FROM municipio where estado={$id} Order by id"); } else { $query1 = $db_generica->query("SELECT * FROM municipio Order by id"); } $estado = array(); if ($query1->num_rows() > 0) { foreach ($query1->result() as $esta) { $estado[] = $esta; } return $estado; $query1->free - result(); } }
function factorize(&$target, &$primes, &$factor) { $multiplier = 2; $factored = true; $sieve = range($primes[count($primes) - 1] + 1, $factor); for ($i = 0; $i < count($primes); $i++) { if ($target % $primes[$i] == 0) { $target = $target / $primes[$i]; if (isPrime($target)) { result(6857, $target); die; } } if ($i == count($primes) - 1) { $factored = false; $factor *= $multiplier; $primes = reducer($factor, $sieve, $primes, $target); factorize($target, $primes, $factor); } } }