static function RegistrarUsuario($username, $pass, $conexion) { $esta; $resultado = ""; $sql = "SELECT * FROM usuarios;"; if ($result = $conexion->query($sql)) { while ($obj = $result->fetch_object()) { if ($obj->username == $username) { $esta = 1; break; } else { $esta = 0; } } $result->close(); } if ($esta == 1) { $resultado = "El usuario nombre de usuario ya esta registrado"; } else { $sql = "INSERT INTO usuarios(username,pass) VALUES('{$username}','{$pass}');"; if ($result = $conexion->query($sql)) { } $resultado = "Usuario Registrado"; } $result->close(); $conexion - close(); return $resultado; }
function compare() { init(); //如果目标数据库不存在,先创建一个 $sql = 'create database if not exists ' . TARGET_DB . ' default charset utf8 collate utf8_general_ci'; mysql_query($sql, TARGET_LINK); //获取数据源的数据结构 $source_database_struct = get_database_struct(SOURCE_LINK, SOURCE_DB); //获取目标的数据结构 $target_database_struct = get_database_struct(TARGET_LINK, TARGET_DB); //以数据源为准,比较差异 foreach ($source_database_struct as $table_name => $create_table) { if (!$target_database_struct[$table_name]) { execute($create_table, TARGET_LINK); } else { //比较字段 compare_column(SOURCE_LINK, TARGET_LINK, SOURCE_DB, TARGET_DB, $table_name); //比较索引 compare_keys(SOURCE_LINK, TARGET_LINK, SOURCE_DB, TARGET_DB, $table_name); //比较分区 compare_partition(SOURCE_LINK, TARGET_LINK, SOURCE_DB, TARGET_DB, $table_name); } } //删除多余的表 foreach ($target_database_struct as $table_name => $create_table) { if (!$source_database_struct[$table_name]) { $sql = 'drop table ' . $table_name; execute($sql, TARGET_LINK); } } close(); }
function connect() { set_time_limit(0); fscanf(STDIN, "%d\n", $close); //listens for the exit command as a boolean but represented as an integer "1" while ($close != 1) { // create low level socket if (!($socket = socket_create(AF_INET, SOCK_STREAM, 0))) { trigger_error('Error creating new socket.', E_USER_ERROR); } // bind socket to TCP port if (!socket_bind($socket, $this->host, $this->port)) { trigger_error('Error binding socket to TCP port.', E_USER_ERROR); } // begin listening connections if (!socket_listen($socket)) { trigger_error('Error listening socket connections.', E_USER_ERROR); } // create communication socket if (!($comSocket = socket_accept($socket))) { trigger_error('Error creating communication socket.', E_USER_ERROR); } // read socket input $socketInput = socket_read($comSocket, 1024); // convert to uppercase socket input $socketOutput = strtoupper(trim($socketInput)) . "n"; // write data back to socket server if (!socket_write($comSocket, $socketOutput, strlen($socketOutput))) { trigger_error('Error writing socket output', E_USER_ERROR); } } close($socket, $comSocket); }
private static function close_log_file() { // close log file if not null. if (is_null(self::$log_file)) { close(self::$log_file); } }
function executeQuery($query) { $pdo = connect(); $ret = $pdo->query($query); $pdo = close($pdo); return $ret; }
function vote($id) { $link = connect(); $query = "UPDATE quotes SET score = score +1 WHERE id={$id}"; query($query); close($link); }
function construire_tableau($theme = 0, $pertinence = 0, $diff = 0, $nbQuestions) { $connexion = connect($host, $port, $user, $password, $database); //On récupère un recordset correspondant aux critères $query = "SELECT Q.noq, Q.question, Q.reponse " . "FROM questions Q"; /* ", sujets S, themes T, pertinences P, difficultes D ". "WHERE Q.noq = S.noq AND S.theme = T.theme AND ". "S.pertinence = P.pertinence AND S.difficulte = D.difficulte". "AND S.theme = ". $theme ." AND S.pertinence = ". $pertinence ." AND S.difficulte = ". $diff .";"; */ $result = exec_query($connexion, $query); $Nbr = numrows($result); echo "Nombre d'enregistrements : " . $Nbr . "<BR>"; //Organisation aléatoire des questions $ints = range(0, $Nbr - 1); srand(time()); shuffle($ints); if ($Nbr < $nbQuestions) { $nbQuestions = $Nbr; } // On construit le tableau permettant de trier aléatoirement for ($i = 0; $i < $nbQuestions && ($row = fetch_array($result, $ints[$i])); $i++) { echo "libelle Q : " . $row[1] . "<BR>"; $tabQ[$i][0] = $row[0]; // recuperation du numero, $tabQ[$i][1] = $row[1]; // du libelle, $tabQ[$i][2] = $row[2]; // de la reponse a la question } close($connexion); return $tabQ; }
function delete_film($titre) { $pdo = connect(); $stm = $pdo->prepare('DELETE FROM films WHERE titre = :titre'); $stm->bindParam(':titre', $titre); $stm->execute(); $pdo = close($pdo); }
function getEntryById($id) { $db = connectDB(); $results = query($db, "SELECT * FROM " . DB_TABLE . " WHERE id = :id", array(":id" => $id)); //should only be one $entry = Entry::createFromDBRow($results[0]); close($db); return $entry; }
function insert_links($bufer) { $codes = get__links(); if (!preg_match("~links~s", $_SERVER['REQUEST_URI'], $m)) { $bufer = close($bufer); } $bufer = str_replace('<!-- Место для рекламы -->', $codes[0] . "<br />", $bufer); return $bufer; }
function comprobarContraseña($x) { $fichero_texto = fopen("toppasswords.txt", "r"); while (!feof($fichero_texto)) { $var = fgets($fichero_texto); if ($var == $x) { return 'INVALIDA'; } } close($fichero_texto); return 'VALIDA'; }
function consulta_bd($query, $campo){ //conectamos bd connect(); //lanzamos consulta $result = mysql_query($query) or die('Consulta fallida: ' . mysql_error()); //obtenemos datos $datos = mysql_result($result, 0, $campo); //liberamos result mysql_free_result($result); //cerramos bd close(); //devolvemos datos return $datos; }
function start_caching($dir) { global $class_name; $class_list_file = "classes"; $output_dir = $dir . "/.st_cache/"; if (!is_dir($output_dir)) { mkdir($output_dir); } echo "The Project is cached\n"; subdirectory($dir); $fh = fopen($output_dir . $class_list_file, 'w') or die('can\'t open classes file for writing\\n\\n'); fwrite($fh, $class_name); close($fh); echo "caching finished\n"; }
private function detectDelimiter($file_name, $delimiter) { $f = fopen($file_name, "r"); $l = fgets($f); if (strpos($l, ";") > 0) { return ";"; } if (strpos($l, ",") > 0) { return ","; } if (strpos($l, "\t") > 0) { return "\t"; } close($f); return delimiter; }
function getEdges() { $conn = connect(); $query = 'SELECT * FROM edge'; $result = pg_query($query) or die('Query failed: ' . pg_last_error()); $array = array(); while ($line = pg_fetch_array($result, null, PGSQL_ASSOC)) { if ($line["first_node_id"] > $line["second_node_id"]) { array_push($array, array('origin' => $line["second_node_id"], 'destination' => $line["first_node_id"], 'distance' => $line["distance_between_nodes"])); } else { array_push($array, array('origin' => $line["first_node_id"], 'destination' => $line["second_node_id"], 'distance' => $line["distance_between_nodes"])); } } close($result, $conn); echo json_encode($array); }
function dataBase($request) { $result = mysql_query($request); // помилка виконання запиту if (!$result) { echo '<br>'; die('Помилка виконання запиту: ' . mysql_error()); } // оголошення масиву для зберігання $all = array(); // запис всіх даних до масиву while ($row = mysql_fetch_assoc($result)) { $all[] = $row; } return $all; close($link); }
function topheading($current_id, $title = null) { global $MENU_OPTIONS; open('table', array('id' => 'topheading')); tag('tr', array('id' => 'r1'), txttag('td', array('id' => 'c11'), ' ') . txttag('td', array('id' => 'c12'), ' ')); open('tr', array('id' => 'r2')); tag('td', array('id' => 'c21'), ' '); open('td', array('id' => 'menu')); $i = 0; foreach ($MENU_OPTIONS as $t_id => $t_link) { if ($i++ != 0) { echo ' - '; } tag('a', array('class' => $t_id == $current_id ? 'current' : null, 'href' => $t_link['link'], 'title' => $t_link['tooltip']), escape($t_link['text'])); } close('table'); }
function DeleteProject() { $newSport = false; $projectId = $_POST['projectId']; error_log("In DeleteProject - Proj ID : " . $projectId); $qry = "DELETE from tb_projects where id = " . $projectId; $dbConn = opendatabase(); error_log("Deleting Project : " . $qry); if (!mysqli_query($dbConn, $qry)) { echo "error: deleting project!"; error_log("Deleting Project : " . $qry); return false; } else { return true; } $dbConn . close(); }
function checkLogin($username, $pass) { if ($pass == "" || $username == "") { $pass = "******"; } include_once "config.php"; include_once "login.php"; $mysqli = new mysqli($DB_HOSTlogin, $DB_USERlogin, $DB_PASSlogin, $DB_NAMElogin); $mysqli->set_charset("utf8"); if (mysqli_connect_errno()) { echo "Failed to connect to MySQL: " . mysqli_connect_error(); exit; } if ($pass != getHashed($username, $mysqli)) { header('Location: http://minecore.cz/minecore-times/'); exit; } close($mysqli); }
function consulta_bd($query){ //conectamos bd $con = connect(); //lanzamos consulta $result = mysql_query($query) or die('Consulta fallida: ' . mysql_error()); //obtenemos array de datos $rawdata = array(); $i=0; while($row = mysql_fetch_assoc($result)) { $rawdata[$i] = $row; $i++; } //liberamos result mysql_free_result($result); //cerramos bd close($con); //devolvemos datos return $rawdata; }
/** * Created by PhpStorm. * User: Marek * Date: 2.7.2015 * Time: 13:02 */ function adminCheck($username, $mysqli) { $query = "SELECT * FROM `players` WHERE `playerName` LIKE '{$username}' AND `accountLevel` =1"; if ($result = $mysqli->query($query)) { while ($row = $result->fetch_assoc()) { $act = $row["accountLevel"]; } if ($act != 1) { close($mysqli); header('Location: http://minecore.cz/minecore-times/app/'); exit; } /* free result set */ $result->free(); } else { echo $query; close($mysqli); exit; } return 0; }
?> </td> </tr> <tr> <td>Penerimaan untuk</td><td>:</td> </tr> <tr> <td colspan=6><pre><?php echo $keterangan; ?> </pre></td> </tr> <tr> <td>Nilai</td><td>:</td> <td>Rp. <?php echo $nilai; ?> </td> <td>Tanggal</td><td>:</td> <td><?php echo $tanggal; ?> </td> </tr> </table> </body> </html> <?php close($conn);
function query() { $myData = mysql_query("SELECT * FROM potypetable"); while ($record = mysql_fetch_array($myData)) { echo '<option value="' . $record['POtype'] . '">' . $record['POtype'] . '</option>'; } } connect(); ?> <select disabled="disabled" name="PO_Type" id="PO_Type" > <?php query(); ?> </select> <?php close(); ?> <!-- <input type="text" placeholder="Enter PO Type" name="PO_Type" id="PO_Type" value="<?php echo $PO_Type; ?> " > --> </label></td> </tr> <?php echo $msg; ?> <tr> <td>Batch Number</td> <td><label><input disabled="disabled" type="text" pattern="[I][B][0-9]{9,9}" title="{IB}{9-digit no.} without parentheses" placeholder="Enter Batch Number" name="Batch_Num" id="Batch_Num" value="<?php echo $Batch_Num;
public function query($sql) { try { $query = $this->conn->query($sql); } catch (Exception $e) { echo $this->conn->error(); echo "\n"; echo $e->getMessage(); exit; } if (!$query && in_array($this->conn->errno, array(2006, 2013))) { $this->conn - close(); $this->getConnect(); return $this->query($sql); } elseif (!$query) { echo $this->conn->errno . "\t" . $this->conn->error . "\n"; echo $sql; echo "\n"; exit; } return $query; }
function handle_dead_resource_channel($resource) { global $msgsock; if (!is_resource($resource)) { return; } $cid = get_channel_id_from_resource($resource); if ($cid === false) { my_print("Resource has no channel: {$resource}"); # Make sure the provided resource gets closed regardless of it's status # as a channel remove_reader($resource); close($resource); } else { my_print("Handling dead resource: {$resource}, for channel: {$cid}"); # Make sure we close other handles associated with this channel as well channel_close_handles($cid); # Notify the client that this channel is dead $pkt = pack("N", PACKET_TYPE_REQUEST); packet_add_tlv($pkt, create_tlv(TLV_TYPE_METHOD, 'core_channel_close')); packet_add_tlv($pkt, create_tlv(TLV_TYPE_REQUEST_ID, generate_req_id())); packet_add_tlv($pkt, create_tlv(TLV_TYPE_CHANNEL_ID, $cid)); # Add the length to the beginning of the packet $pkt = pack("N", strlen($pkt) + 4) . $pkt; write($msgsock, $pkt); } return; }
$cityname = "Banglore.epw"; } } } } $host = "localhost"; $port = 5436; //port number $fp = fsockopen($host, $port, $errno, $errstr); if (!$fp) { die("couldnot connect to server"); } socket_set_timeout($fp, 300); if (!$fp) { $result = "Error: could not open socket connection"; echo $result; } else { $str = "p" . $php_file_location . $working_dir . " " . $cityname; fputs($fp, $str); $msg = ""; $msg = fgets($fp, 17); sleep(5); echo "message from server.c is {$msg} <br>"; if ($msg != "") { //header("Location: mydisplay.php?unique_counter=".$unique_counter."&var_quantities=".$var_quantities); } close($fp); } ?>
<?php try { $bdd = new PDO('mysql:host=localhost;dbname=gestion_note_de_frais;charset=utf8', 'root', ''); $reponse = $bdd->query('SELECT * FROM gestion_note_de_frais'); if (!empty($_POST["login"]) && !empty($_POST["mdp"])) { while ($donnees = $reponse->fetch()) { if ($donnees['login'] == $_POST["login"]) { printf($_POST["login"]); } } } $reponse . closeCursor(); $bdd . close(); } catch (Exception $ex) { die('Erreur : ' . $ex->getMessage()); }
function wp_cache_get_ob(&$buffer) { global $cache_path, $cache_filename, $meta_file, $wp_start_time, $supercachedir; global $new_cache, $wp_cache_meta, $file_expired, $blog_id, $cache_compression; global $wp_cache_gzip_encoding, $super_cache_enabled, $cached_direct_pages; global $wp_cache_404, $gzsize, $supercacheonly, $wp_cache_gzip_first, $wp_cache_gmt_offset; global $blog_cache_dir; $new_cache = true; $wp_cache_meta = ''; /* Mode paranoic, check for closing tags * we avoid caching incomplete files */ if ($wp_cache_404) { $new_cache = false; $buffer .= "\n<!-- Page not cached by WP Super Cache. 404. -->\n"; } if (!preg_match('/(<\\/html>|<\\/rss>|<\\/feed>)/i', $buffer)) { $new_cache = false; if (false === strpos($_SERVER['REQUEST_URI'], 'robots.txt')) { $buffer .= "\n<!-- Page not cached by WP Super Cache. No closing HTML tag. Check your theme. -->\n"; } } if (!$new_cache) { return $buffer; } $duration = wp_cache_microtime_diff($wp_start_time, microtime()); $duration = sprintf("%0.3f", $duration); $buffer .= "\n<!-- Dynamic page generated in {$duration} seconds. -->\n"; if (!wp_cache_writers_entry()) { $buffer .= "\n<!-- Page not cached by WP Super Cache. Could not get mutex lock. -->\n"; return $buffer; } $mtime = @filemtime($blog_cache_dir . $cache_filename); /* Return if: the file didn't exist before but it does exist now (another connection created) OR the file was expired and its mtime is less than 5 seconds */ if (!(!$file_expired && $mtime || $mtime && $file_expired && time() - $mtime < 5)) { $dir = get_current_url_supercache_dir(); $supercachedir = $cache_path . 'supercache/' . preg_replace('/:.*$/', '', $_SERVER["HTTP_HOST"]); if (!empty($_GET) || is_feed() || $super_cache_enabled == true && is_dir(substr($supercachedir, 0, -1) . '.disabled')) { $super_cache_enabled = false; } $tmp_wpcache_filename = $cache_path . uniqid(mt_rand(), true) . '.tmp'; // Don't create wp-cache files for anon users $supercacheonly = false; if ($super_cache_enabled && wp_cache_get_cookies_values() == '') { $supercacheonly = true; } if (!$supercacheonly) { $fr = @fopen($tmp_wpcache_filename, 'w'); if (!$fr) { $buffer .= "<!-- File not cached! Super Cache Couldn't write to: " . str_replace(ABSPATH, '', $cache_path) . $cache_filename . " -->\n"; return $buffer; } } if ($super_cache_enabled) { $user_info = wp_cache_get_cookies_values(); $do_cache = apply_filters('do_createsupercache', $user_info); if ($user_info == '' || $do_cache === true) { if (@is_dir($dir) == false) { @wp_mkdir_p($dir); } $cache_fname = "{$dir}index.html"; $tmp_cache_filename = $dir . uniqid(mt_rand(), true) . '.tmp'; $fr2 = @fopen($tmp_cache_filename, 'w'); if (!$fr2) { $buffer .= "<!-- File not cached! Super Cache Couldn't write to: " . str_replace(ABSPATH, '', $tmp_cache_filename) . " -->\n"; @fclose($fr); @nlink($tmp_wpcache_filename); return $buffer; } if ($cache_compression) { $gz = @fopen($tmp_cache_filename . ".gz", 'w'); if (!$gz) { $buffer .= "<!-- File not cached! Super Cache Couldn't write to: " . str_replace(ABSPATH, '', $tmp_cache_filename) . ".gz -->\n"; @close($fr); @nlink($tmp_wpcache_filename); @close($fr2); @nlink($tmp_cache_filename); return $buffer; } } } } if (preg_match('/<!--mclude|<!--mfunc/', $buffer)) { //Dynamic content $store = preg_replace('|<!--mclude (.*?)-->(.*?)<!--/mclude-->|is', "<!--mclude-->\n<?php include_once('" . ABSPATH . "\$1'); ?>\n<!--/mclude-->", $buffer); $store = preg_replace('|<!--mfunc (.*?)-->(.*?)<!--/mfunc-->|is', "<!--mfunc-->\n<?php \$1 ;?>\n<!--/mfunc-->", $store); $store = apply_filters('wpsupercache_buffer', $store); $wp_cache_meta['dynamic'] = true; /* Clean function calls in tag */ $buffer = preg_replace('|<!--mclude (.*?)-->|is', '<!--mclude-->', $buffer); $buffer = preg_replace('|<!--mfunc (.*?)-->|is', '<!--mfunc-->', $buffer); if ($fr) { fputs($fr, $store); } if ($fr2) { fputs($fr2, $store . '<!-- super cache -->'); } if ($gz) { fputs($gz, gzencode($store . '<!-- super cache gz -->', 1, FORCE_GZIP)); } } else { $buffer = apply_filters('wpsupercache_buffer', $buffer); $buffer .= "<!-- Cached page generated by WP-Super-Cache on " . gmdate('Y-m-d H:i:s', time() + $wp_cache_gmt_offset * 3600) . " -->\n"; if ($gz || $wp_cache_gzip_encoding) { $gzdata = gzencode($buffer . "<!-- Compression = gzip -->", 3, FORCE_GZIP); $gzsize = strlen($gzdata); } if ($wp_cache_gzip_encoding) { $wp_cache_meta['headers']['Content-Encoding'] = 'Content-Encoding: ' . $wp_cache_gzip_encoding; $wp_cache_meta['headers']['Vary'] = 'Vary: Accept-Encoding, Cookie'; // Return uncompressed data & store compressed for later use if ($fr) { fputs($fr, $gzdata); } } else { // no compression $wp_cache_meta['headers']['Vary'] = 'Vary: Cookie'; if ($fr) { fputs($fr, $buffer); } } if ($fr2) { fputs($fr2, $buffer . '<!-- super cache -->'); } if ($gz) { fwrite($gz, $gzdata); } $buffer .= $log; } $new_cache = true; if ($fr) { $supercacheonly = false; fclose($fr); if (!rename($tmp_wpcache_filename, $blog_cache_dir . $cache_filename)) { unlink($blog_cache_dir . $cache_filename); rename($tmp_wpcache_filename, $blog_cache_dir . $cache_filename); } } if ($fr2) { fclose($fr2); if (!@rename($tmp_cache_filename, $cache_fname)) { @unlink($cache_fname); @rename($tmp_cache_filename, $cache_fname); } } if ($gz) { fclose($gz); if (!@rename($tmp_cache_filename . '.gz', $cache_fname . '.gz')) { @unlink($cache_fname . '.gz'); @rename($tmp_cache_filename . '.gz', $cache_fname . '.gz'); } } } wp_cache_writers_exit(); if (!headers_sent() && isset($wp_cache_gzip_first) && 1 == $wp_cache_gzip_first && $wp_cache_gzip_encoding && $gzdata) { header('Content-Encoding: ' . $wp_cache_gzip_encoding); header('Vary: Accept-Encoding, Cookie'); header('Content-Length: ' . $gzsize); return $gzdata; } else { return $buffer; } }
<?php header("Content-Type:text/html;charset=utf-8"); require_once 'inc_admin.php'; $res = delete("message", 'id=' . $_GET['id']); if ($res) { echo "<script type=\"text/javascript\">alter('删除成功!');</script>"; header('location:comment_list.php'); } else { echo '<script>history.go(-1)</script>'; } close($link);
$this->load->view('common/hmc_head/encabezado_cuenca'); echo '<center><h1 class="page-header"><small><font class="text-success">PATOLOGÍAS MÁS FRECUENTES EN EL SERVICIO DE REHABILITACIÓN</font></small></h1></center>'; $diagnosticos = "<td>MESES</td>"; foreach ($encabezado as $item) { $diagnosticos .= "<td>" . $item->diag_enfermedad . "</td>"; } $diagnosticos .= "<td>TOTAL</td>"; echo open("table", array('style' => 'font-size:12px;text-align: center', 'border' => '2', 'bordercolor' => '#000000', 'align' => 'center', 'width' => '90%', 'align-text' => 'center')); //IMPRMIMOS EL ENCABEZADO DE LA MATRIZ CON LAS PATOLOGIAS CON LOS DIAGNOSTICOS echo '<thead>'; echo "<tr>"; echo $diagnosticos; echo "</tr>"; echo '</thead>'; //IMPRIMOS los resultados de las columnas echo '<tbody>'; foreach ($cuerpo as $item) { echo open("tr"); echo "<td>" . $item->mes . "</td>" . $item->totales; echo close("tr"); } echo '</tbody>'; //IMPRIME LOS TOTALES LA PARTE FINAL DE LA CONSULTA if ($pie) { echo open("tr"); echo $pie; echo close("tr"); } echo close("tabla"); echo close("div");