function insert_to_vm_panda($id_category, $UURRLL) { global $conn; pq_page($UURRLL); $res_items = pq('ul.products-grid>li'); foreach ($res_items as $item) { try { $ii = pq($item); $hhq = $ii->html(); $productUrl = $ii->find('a.product-image')->attr('href'); $sql1 = "select count(*) as count from _products where url='{$productUrl}' limit 1"; $res = run_sql($sql1); // $res = mysql_query($sql1, $conn)or die("Invalid query: " . mysql_error());; $data = mysql_fetch_assoc($res); if ($data[count] == 0) { $imgSmallUrl = $ii->find("img")->attr('taikoo_lazy_src'); $product_name = $ii->find('.product-name>a')->text(); $product_sql = "INSERT _products (url, ids_category, name, img_small, status)\n VALUES ('{$productUrl}', {$id_category}, '{$product_name}', '{$imgSmallUrl}', 1)"; run_sql($product_sql); } else { $sql1 = "select * from _products where url='{$productUrl}' limit 1"; $res = run_sql($sql1); $data2 = mysql_fetch_assoc($res); $category_old_value = (string) $data2[ids_category]; $sql = " UPDATE _products SET ids_category='{$category_old_value},{$id_category}' WHERE url='{$productUrl}'"; run_sql($sql); } } catch (Exception $exc) { echo $exc->getTraceAsString(); } } return $res; }
function clean_tables() { run_sql("TRUNCATE TABLE jsh_jshopping_categories;"); run_sql("TRUNCATE TABLE\tjsh_jshopping_products;"); run_sql("TRUNCATE TABLE\tjsh_jshopping_products_to_categories;"); run_sql("TRUNCATE TABLE\tjsh_jshopping_products_images;"); }
function print_story($sid, $ipos = "right") { global $server_name; global $auth_user; $story = db_get_rec("story", $sid); $pipe = db_get_rec("pipe", $story["pid"]); $topic = db_get_rec("topic", $story["tid"]); $a["story"] = $story["story"]; $a["time"] = $story["time"]; $a["sid"] = $sid; $a["ipos"] = $ipos; $a["topic"] = $topic["topic"]; $a["icon"] = $story["icon"]; $a["title"] = $story["title"]; $a["pid"] = $story["pid"]; $a["ipos"] = $ipos; $a["zid"] = $pipe["zid"]; if ($sid > 0) { $row = run_sql("select count(cid) as comments from comment where sid = ?", array($sid)); $a["comments"] = $row[0]["comments"]; } else { $a["comments"] = 0; } print_article($a); }
function get_captcha_fallback() { $row = run_sql("select min(captcha_id) as min_id, max(captcha_id) as max_id from captcha"); $min_id = $row[0]["min_id"]; $max_id = $row[0]["max_id"]; $captcha_id = rand($min_id, $max_id); $row = run_sql("select captcha_id, question, answer from captcha where captcha_id = ?", array($captcha_id)); return array($row[0]["captcha_id"], $row[0]["question"], $row[0]["answer"]); }
function getLastReportRun($report) { $db = db_connect(); $sql = "SELECT *\n FROM reporting.report_log\n WHERE report_name='" . $report . "'\n AND report_code=0\n AND report_endts IS NOT NULL\n\t\t\tAND date(report_startts)=curdate()\n ORDER BY report_endts DESC\n LIMIT 1"; $result = run_sql($db, $sql); $row = db_fetch_assoc($result[0]); mysqli_close($db); return $row; }
function plugin_mycss_save() { $css = z(t(v('css'))); $sql = "REPLACE INTO `css` ( `uid` , `css` ) VALUES ( '" . intval(uid()) . "' , '" . s($css) . "' )"; run_sql($sql); $location = '?c=plugin&a=mycss'; if (db_errno() != 0) { return info_page('数据保存失败,请稍后重试。<a href="' . $location . '">点击返回</a>'); } else { header("Location:" . $location); } }
function plugin_mycss_save() { $css = z(t(v('css'))); $sql = "REPLACE INTO `css` ( `uid` , `css` ) VALUES ( '" . intval(uid()) . "' , '" . s($css) . "' )"; run_sql($sql); $location = '?c=plugin&a=mycss'; if (db_errno() != 0) { return info_page(__('PL_CSS_MODIFIER_DATE_UPDATE_ERROR', $location)); } else { header("Location:" . $location); } }
function make_atom($topic) { global $server_name; global $server_title; global $server_slogan; global $cache_enabled; $row = run_sql("select sid, pipe.zid, story.time, story.title, story.ctitle, story.story from story inner join pipe on story.pid = pipe.pid order by sid desc limit 10"); if (count($row) > 0) { $updated = $row[0]["time"]; } else { $updated = time(); } $body = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n"; $body .= "<feed xmlns=\"http://www.w3.org/2005/Atom\">\n"; $body .= "\t<title type=\"text\">{$server_title}</title>\n"; $body .= "\t<subtitle type=\"text\">{$server_slogan}</subtitle>\n"; $body .= "\t<updated>" . gmdate(DATE_ATOM, $updated) . "</updated>\n"; $body .= "\t<id>http://{$server_name}/atom</id>\n"; $body .= "\t<link rel=\"alternate\" type=\"text/html\" hreflang=\"en\" href=\"http://{$server_name}/\"/>\n"; $body .= "\t<link rel=\"self\" type=\"application/atom+xml\" href=\"http://{$server_name}/atom\"/>\n"; $body .= "\t<icon>http://{$server_name}/favicon.ico</icon>\n"; $body .= "\t<logo>http://{$server_name}/images/logo-feed.png</logo>\n"; for ($i = 0; $i < count($row); $i++) { $body .= "\t<entry>\n"; $body .= "\t\t<id>http://{$server_name}/story/" . $row[$i]["sid"] . "</id>\n"; $body .= "\t\t<title>" . $row[$i]["title"] . "</title>\n"; $body .= "\t\t<updated>" . gmdate(DATE_ATOM, $row[$i]["time"]) . "</updated>\n"; $body .= "\t\t<link rel=\"alternate\" type=\"text/html\" href=\"http://{$server_name}/story/" . gmdate("Y-m-d", $row[$i]["time"]) . "/" . $row[$i]["ctitle"] . "\"/>\n"; $body .= "\t\t<author>\n"; if ($row[$i]["zid"] == "") { $body .= "\t\t\t<name>Anonymous Coward</name>\n"; } else { $body .= "\t\t\t<name>" . $row[$i]["zid"] . "</name>\n"; $body .= "\t\t\t<uri>" . user_page_link($row[$i]["zid"]) . "</uri>\n"; } $body .= "\t\t</author>\n"; $body .= "\t\t<content type=\"html\">" . htmlspecialchars($row[$i]["story"]) . "</content>\n"; $body .= "\t</entry>\n"; } $body .= "</feed>\n"; //$date = gmdate("D, j M Y H:i:s") . " GMT"); $time = time(); $etag = md5($body); if ($cache_enabled) { //cache_set("atom.$topic.time", $time); //cache_set("atom.$topic.etag", $etag); //cache_set("atom.$topic.body", $body); cache_set(array("atom.{$topic}.time" => $time, "atom.{$topic}.etag" => $etag, "atom.{$topic}.body" => $body)); } return array($time, $etag, $body); }
function db_init() { $password = substr(md5(time() . rand(1, 9999)), rand(1, 20), 12); $sql_contents = preg_replace("/(#.+[\r|\n]*)/", '', file_get_contents(AROOT . 'misc' . DS . 'install.sql')); // 更换变量 $sql_contents = str_replace('{password}', md5($password), $sql_contents); $sqls = split_sql_file($sql_contents); foreach ($sqls as $sql) { run_sql($sql); } if (db_errno() == 0) { info_page(__('DATABASE_INIT_FINISHED', $password)); exit; } else { info_page(db_error()); exit; } }
function dbup() { $sql = "ALTER TABLE `feed` ADD `comment_count` int(11) NOT NULL DEFAULT '0' "; run_sql($sql); $sql = "ALTER TABLE `comment` ADD `device` varchar(16) NOT NULL "; run_sql($sql); $sql = "ALTER TABLE `keyvalue` CHANGE `key` `key` VARCHAR( 64 ) NOT NULL"; run_sql($sql); $sql = "ALTER TABLE `user` ADD `groups` VARCHAR( 255 ) NOT NULL AFTER `desp` ,\nADD INDEX ( `groups` )"; run_sql($sql); $sql = "CREATE TABLE IF NOT EXISTS `online` (\n `uid` int(11) NOT NULL,\n `last_active` datetime NOT NULL,\n `session` varchar(32) NOT NULL,\n `device` varchar(32) DEFAULT NULL,\n `place` varchar(32) DEFAULT NULL,\n PRIMARY KEY (`uid`),\n KEY `last_active` (`last_active`)\n) ENGINE=MyISAM DEFAULT CHARSET=utf8"; run_sql($sql); $sql = "CREATE TABLE IF NOT EXISTS `plugin` (\n`folder_name` VARCHAR( 32 ) NOT NULL ,\n`on` TINYINT( 1 ) NOT NULL DEFAULT '0',\nPRIMARY KEY ( `folder_name` )\n) ENGINE = MYISAM DEFAULT CHARSET=utf8"; run_sql($sql); $sql = "ALTER TABLE `todo` ADD `comment_count` INT NOT NULL DEFAULT '0' "; run_sql($sql); return info_page(__('DB_UPGRADE_SUCCESS')); }
function db_init() { $password = substr(md5(time() . rand(1, 9999)), rand(1, 20), 12); $sql_contents = preg_replace("/(#.+[\r|\n]*)/", '', file_get_contents(AROOT . 'misc' . DS . 'install.sql')); // 更换变量 $sql_contents = str_replace('{password}', md5($password), $sql_contents); $sqls = split_sql_file($sql_contents); foreach ($sqls as $sql) { run_sql($sql); } if (db_errno() == 0) { info_page('数据库初始化成功,请使用【member@teamtoy.net】和【' . $password . '】<a href="/" target="new">登入并添加用户</a>'); exit; } else { info_page(db_error()); exit; } }
function turn() { if (!is_admin()) { return render(array('code' => LR_API_FORBIDDEN, 'message' => __('API_MESSAGE_ONLY_ADMIN')), 'rest'); } $on = intval(v('on')); $folder_name = z(t(v('folder_name'))); if (strlen($folder_name) < 1) { return render(array('code' => LR_API_ARGS_ERROR, 'message' => 'FOLDER NAME CANNOT BE EMPTY'), 'rest'); } $sql = "REPLACE `plugin` (`folder_name` , `on`) VALUES ( '" . s($folder_name) . "' , '" . intval($on) . "' )"; run_sql($sql); if (db_errno() == 0) { return render(array('code' => 0, 'message' => 'ok'), 'rest'); } else { return render(array('code' => LR_API_DB_ERROR, 'message' => db_error()), 'rest'); } }
function plugin_simple_token() { $do = z(t(v('do'))); switch ($do) { case 'create': case 'refresh': $new_token = substr(md5(uid() . time("Y h j G") . rand(1, 9999)), 0, rand(9, 20)); $new_token = uid() . substr(md5($new_token), 0, 10); $sql = "REPLACE INTO `stoken` ( `uid` , `token` , `on` ) VALUES ( '" . intval(uid()) . "' , '" . s($new_token) . "' , '1' )"; run_sql($sql); if (db_errno() == 0) { return ajax_echo('done'); } else { return ajax_echo('error'); } break; case 'close': $sql = "UPDATE `stoken` SET `on` = '0' WHERE `uid` = '" . intval(uid()) . "' LIMIT 1"; run_sql($sql); if (db_errno() == 0) { return ajax_echo('done'); } else { return ajax_echo('error'); } break; case 'reopen': $sql = "UPDATE `stoken` SET `on` = '1' WHERE `uid` = '" . intval(uid()) . "' LIMIT 1"; run_sql($sql); if (db_errno() == 0) { return ajax_echo('done'); } else { return ajax_echo('error'); } break; default: $data['tinfo'] = get_line("SELECT * FROM `stoken` WHERE `uid` = '" . intval(uid()) . "' LIMIT 1"); render($data, 'ajax', 'plugin', 'simple_token'); } }
function plugin_system_setting_save() { $new_lang = z(t(v('new_lang'))); $sql = "UPDATE `user` SET `language`='" . $new_lang . "' WHERE `id`='" . intval(uid()) . "'"; run_sql($sql); $sql = "UPDATE ip_br_os_lang SET language='" . $new_lang . "' WHERE ip = '" . $GLOBALS['sys']['ip'] . "' AND browser = '" . $GLOBALS['sys']['browser'] . "' AND browser_ver='" . $GLOBALS['sys']['browser_version'] . "' AND platform= '" . $GLOBALS['sys']['platform'] . "' AND uid='" . intval(uid()) . "'"; run_sql($sql); plugin_system_setting(); $script = ' <script type="text/javascript" src="static/script/jquery.tablesorter.js"></script> <script type="text/javascript"> $(function(){ $("#sys_confirm").tablesorter(); toastr.options = { "closeButton": true, "debug": false, "newestOnTop": true, "progressBar": false, "positionClass": "toast-top-full-width", "preventDuplicates": false, "showDuration": "300", "hideDuration": "1000", "timeOut": "5000", "extendedTimeOut": "1000", "showEasing": "swing", "hideEasing": "linear", "showMethod": "fadeIn", "hideMethod": "fadeOut", } toastr.options.onHidden = function() { location.reload(); } toastr["success"]("' . __('PL_SYS_SUCCESS') . '", "' . __('PL_SYS_RELOADING') . '"); });</script>'; return ajax_echo($script); }
function get_add_to_waitlist_sql($UnityId, $conn) { $sql = "SELECT DISTINCT\n p.\"TYPE\",\n p.\"IDENTIFIER\",\n p.\"Location\",\n p.\"IsAvailable\"\n FROM PUBLICATIONS p\n WHERE p.\"IsAvailable\" = 'N'\n AND (p.\"TYPE\",p.\"IDENTIFIER\") NOT IN\n \t\t(SELECT p3.\"TYPE\",p3.\"IDENTIFIER\" \n \t\t FROM PUBLICATIONS p3\n \t\t WHERE p3.\"IsAvailable\" = 'Y')\n MINUS\n SELECT DISTINCT\n p1.\"TYPE\",\n p1.\"IDENTIFIER\",\n p1.\"Location\",\n p1.\"IsAvailable\"\n FROM PUBLICATIONS p1\n WHERE (p1.\"TYPE\", p1.\"IDENTIFIER\") IN\n (SELECT w.\"Type\", w.\"Identifier\"\n FROM ALAKSHM6.PUBLICATION_WAITLIST w\n WHERE w.\"UnityId\" = '{$UnityId}'\n UNION\n SELECT d.\"Type\", d.\"Identifier\"\n FROM PUBLICATION_DETAILS d\n WHERE d.\"IsReserved\" = 'Y'\n AND d.\"Identifier\" IN\n (SELECT r.\"Title\"\n FROM RESERVES r\n WHERE SYSTIMESTAMP BETWEEN r.\"StartTime\"\n AND r.\"ExpiryTime\"\n AND r.\"CourseId\" NOT IN\n (SELECT e.\"CourseID\"\n FROM ENROLLS e\n WHERE e.\"UnityID\" =\n '{$UnityId}'\n AND SYSTIMESTAMP BETWEEN e.\"StartDate\"\n AND e.\"EndDate\"))\n UNION\n SELECT p2.\"TYPE\", p2.\"IDENTIFIER\"\n FROM ALAKSHM6.PUBLICATIONS p2\n WHERE p2.\"ID\" IN\n (SELECT c.\"ID\"\n FROM PUBLICATION_CHECKOUT c\n WHERE c.\"UnityId\" = '{$UnityId}'\n AND c.\"ReturnDate\" = CAST('31/DEC/9999' AS TIMESTAMP)))"; return run_sql($conn, $sql); }
function api_check_list_assign($data) { $sql = "UPDATE `checklist` SET `uid` = '" . intval($data['owner_uid']) . "' WHERE `tid` = '" . intval($data['tid']) . "' LIMIT 100"; run_sql($sql); return $data; }
require_once __ROOT__ . '/inc/db.php'; require_once __ROOT__ . '/inc/config.php'; $db = db_connect(); // If no parameters passed, set default report for testing if (!isset($_GET['_report'])) { echo "ERROR: No report name passed.<br>\n"; exit; } else { // Create report and pass the parameters if any $reportName = $_GET['_report']; if (isset($_GET['_cache'])) { $report_startts = $_GET['_cache']; $sql = "SELECT report_html from reporting.report_log\n\t\t\t\tWHERE report_name='" . $reportName . "'\n\t\t\t\tAND report_startts='" . $report_startts . "';"; $result = run_sql($db, $sql); while ($row = $result[0]->fetch_assoc()) { echo $row['report_html']; exit; } } } // Connect to DB and set connection pointers // Header require_once __ROOT__ . '/tpl/view_hdr.tpl'; $sql = "SELECT * from reporting.report_log\n\t\tWHERE report_name='" . $reportName . "'\n\t\tORDER by report_startts desc"; $result = run_sql($db, $sql); echo "<table>\n"; while ($row = $result[0]->fetch_assoc()) { echo "<tr><td><a href='report_log.php?_report=" . $reportName . "&_cache=" . $row['report_startts'] . "'>" . $row['report_startts'] . "</td></tr>\n"; } echo "</table>\n"; require_once __ROOT__ . '/tpl/view_ftr.tpl';
function db_set_rec($table, $rec) { global $db_table; global $cache_enabled; if (!array_key_exists($table, $db_table)) { die("unknown table [{$table}]"); } $key = $db_table[$table]["key"]; $col = $db_table[$table]["col"]; if (is_array($key)) { $id = array(); for ($i = 0; $i < count($key); $i++) { $id[$key[$i]] = $rec[$key[$i]]; } } else { $id = $rec[$key]; } $insert = true; $auto = false; if ($id === 0 && array_key_exists("auto", $db_table[$table])) { $auto = true; } else { if (db_has_rec($table, $id)) { $insert = false; } } $a = array(); if ($insert) { $sql = "insert into {$table} ("; for ($i = 0; $i < count($col); $i++) { if (!$auto || $col[$i] != $key) { $sql .= $col[$i] . ", "; $a[] = $rec[$col[$i]]; } } if ($auto) { $count = count($col) - 2; } else { $count = count($col) - 1; } $sql = substr($sql, 0, -2) . ") values (" . str_repeat("?, ", $count) . "?)"; run_sql($sql, $a); } else { $sql = "update {$table} set "; for ($i = 0; $i < count($col); $i++) { $is_key = false; if (is_array($key)) { if (in_array($col[$i], $key)) { $is_key = true; } } else { if ($col[$i] == $key) { $is_key = true; } } if (!$is_key) { $sql .= $col[$i] . " = ?, "; $a[] = $rec[$col[$i]]; } } $sql = substr($sql, 0, -2) . " where "; if (is_array($key)) { for ($i = 0; $i < count($key); $i++) { $sql .= $key[$i] . " = ? and "; $a[] = $rec[$key[$i]]; } $sql = substr($sql, 0, -5); } else { $sql .= "{$key} = ?"; $a[] = $id; } run_sql($sql, $a); } if ($cache_enabled) { $cache_key = "{$table}.rec.{$id}"; cache_set($cache_key, map_to_conf_string($rec)); } }
// This file is part of Pipecode. // // Pipecode is free software: you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundation, either version 3 of the License, or // (at your option) any later version. // // Pipecode is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. // // You should have received a copy of the GNU General Public License // along with Pipecode. If not, see <http://www.gnu.org/licenses/>. // include "feed.php"; header("Content-Type: text/plain"); header_expires(); $row = run_sql("select fid, uri, time from feed"); for ($i = 0; $i < count($row); $i++) { $fid = $row[$i]["fid"]; $uri = $row[$i]["uri"]; $time = $row[$i]["time"]; if (time() > $time + 60 * 5) { print "downloading fid [{$fid}] uri [{$uri}] "; $data = download_feed($uri); print "len [" . strlen($data) . "]\n"; save_feed($fid, $data); } } print "done";
else if (preg_match('/'.$to.'/i',$file)) // First test may be false if we migrate from x.y.* to x.y.* { $filelist[]=$file; } } # Boucle sur chaque fichier foreach($filelist as $file) { print '<tr><td nowrap>'; print $langs->trans("ChoosedMigrateScript").'</td><td align="right">'.$file.'</td></tr>'."\n"; $name = substr($file, 0, dol_strlen($file) - 4); // Run sql script $ok=run_sql($dir.$file, 0, '', 1); } } print '</table>'; if ($db->connected) $db->close(); } if (empty($actiondone)) { print '<div class="error">'.$langs->trans("ErrorWrongParameters").'</div>'; } pFooter(! $ok && empty($_GET["ignoreerrors"]),$setuplang);
die("not your page"); } print_header(); writeln('<table class="fill">'); writeln('<tr>'); writeln('<td class="left_col">'); print_left_bar("account", "feed"); writeln('</td>'); writeln('<td class="fill">'); writeln('<table class="fill">'); writeln(' <tr>'); for ($c = 0; $c < 3; $c++) { writeln(' <td class="feed_box">'); writeln(' <table class="zebra">'); $r = 0; $row = run_sql("select feed_user.fid, title from feed_user inner join feed on feed_user.fid = feed.fid where zid = ? and col = ? order by pos", array($auth_zid, $c)); if (count($row) == 0) { writeln(' <tr><td>(no feeds)</td></tr>'); } for ($i = 0; $i < count($row); $i++) { writeln(' <tr>'); writeln(' <td>' . $row[$i]["title"] . '</td>'); writeln(' <td class="right"><a href="remove?fid=' . $row[$i]["fid"] . '"><span class="icon_16" style="background-image: url(/images/remove-16.png)">Remove</span></a></td>'); writeln(' </tr>'); $r = $r ? 0 : 1; } writeln(' </table>'); writeln(' <div class="right"><a href="add?col=' . $c . '"><span class="icon_16" style="background-image: url(/images/add-16.png)">Add</span></a></div>'); writeln(' </td>'); } writeln(' </tr>');
/** * 快捷删除表 * @param string $table * @param string $wheres * @param $db * @return bool */ function delete($table, $wheres, $db = NULL) { is_null($db) && ($db = db()); $delete_where = array(); if (!empty($wheres)) { foreach ($wheres as $field => $value) { array_push($delete_where, sprintf('`%s` = "%s"', $field, s($value, $db))); } $delete_where = 'WHERE ' . implode(' AND ', $delete_where); } else { $delete_where = ''; } $delete = run_sql("DELETE FROM `{$table}` {$delete_where}", $db); return $delete; }
/** * 创建激活码 * * 普通成员通过创建激活码,邀请其他用户注册 * * @param string token , 必填 * @return array('activecode'=>$string) * @author EasyChen */ public function team_activecode() { $string = substr(md5(rand(1000, 9999) . time()), 0, 4); //$string = md5(rand( 1000 , 9999 ) . time()); $sql = "REPLACE INTO `activecode` ( `code` , `creator_uid` , `timeline` ) VALUES ( '" . s($string) . "' , '" . uid() . "' , NOW() )"; run_sql($sql); if (db_errno() != 0) { return self::send_error(LR_API_DB_ERROR, __('API_MESSAGE_DATABASE_ERROR') . db_error()); } else { return self::send_result(array('activecode' => $string)); } }
while (($filemodule = readdir($handlemodule)) !== false) { if (!preg_match('/\\./', $filemodule) && is_dir($dirroot . '/' . $filemodule . '/sql')) { //print "Scan for ".$dirroot . '/' . $filemodule . '/sql/'.$file; if (is_file($dirroot . '/' . $filemodule . '/sql/' . $file)) { $modulesfile[$dirroot . '/' . $filemodule . '/sql/' . $file] = '/' . $filemodule . '/sql/' . $file; } } } closedir($handlemodule); } } foreach ($modulesfile as $modulefilelong => $modulefileshort) { print '<tr><td colspan="2"><hr></td></tr>'; print '<tr><td class="nowrap">' . $langs->trans("ChoosedMigrateScript") . ' (external modules)</td><td align="right">' . $modulefileshort . '</td></tr>' . "\n"; // Run sql script $okmodule = run_sql($modulefilelong, 0, '', 1); // Note: Result of migration of external module should not decide if we continue migration of Dolibarr or not. } } } } print '</table>'; if ($db->connected) { $db->close(); } } if (empty($actiondone)) { print '<div class="error">' . $langs->trans("ErrorWrongParameters") . '</div>'; } $ret = 0; if (!$ok && isset($argv[1])) {
$err++; echo "Insert error: " . var_export(array($pgdb->errorInfo(), $table, $fields, $row), true) . "\nResume with {$argv[0]} --resume {$table} {$crow}\n"; exit; } else { $n++; } $crow++; if ($crow % 10 == 0 || $crow == $nrows) { echo "[255DTABLE: {$table} [{$c} fields] {$crow}/{$nrows} (" . number_format($crow / $nrows * 100, 2) . "%)[K"; } } $res->closeCursor(); echo "\n"; } echo "Done with {$err} errors and {$n} inserts.\n"; if ($err) { echo "Migration had errors. Aborting.\n"; exit; } run_sql('install/migrate_mypg_fixseq.sql', $pgdb, $err, $n); echo "Sequences updated with {$err} errors and {$n} inserts.\n"; if ($err) { exit; } $r = ask_question("Everything successful. Once you connect up the pg database there is no going back. Do you want to make it live (N,y)?", array('y', 'n'), 'n'); if ($r == 'n') { echo "You can make active by renaming .htconfig.php-pgsql to .htconfig.php, or start over by renaming .htconfig.php-mysql to .htconfig.php\n"; exit; } rename('.htconfig.php-pgsql', '.htconfig.php'); echo "Done. {$W}Red{$M}(#){$W}Matrix{$N} now running on postgres.\n";
} else { die("unknown haystack [{$haystack}]"); } } } } print_header("{$needle} - Search"); writeln('<table class="fill">'); writeln('<tr>'); writeln('<td class="left_col">'); print_left_bar("main", "search"); writeln('</td>'); writeln('<td class="fill">'); search_box($needle, $haystack); writeln('<main class="search">'); $row = run_sql($sql, array($needle, $needle)); if (count($row) == 0) { writeln('(no results)'); } //var_dump($row); for ($i = 0; $i < count($row); $i++) { if ($haystack == "comments") { $title = $row[$i]["subject"]; $link = "/comment/" . $row[$i]["cid"]; $body = $row[$i]["comment"]; $zid = $row[$i]["zid"]; } else { if ($haystack == "stories") { $title = $row[$i]["title"]; $link = "/story/" . $row[$i]["sid"]; $body = $row[$i]["story"];
/** * Create tables and keys required by module. * Files module.sql and module.key.sql with create table and create keys * commands must be stored in directory reldir='/module/sql/' * This function is called by this->init * * @param string $reldir Relative directory where to scan files * @return int <=0 if KO, >0 if OK */ function _load_tables($reldir) { global $conf; $error = 0; $dirfound = 0; if (empty($reldir)) { return 1; } include_once DOL_DOCUMENT_ROOT . '/core/lib/admin.lib.php'; $ok = 1; foreach ($conf->file->dol_document_root as $dirroot) { if ($ok) { $dir = $dirroot . $reldir; $ok = 0; $handle = @opendir($dir); // Dir may not exists if (is_resource($handle)) { $dirfound++; // Run llx_mytable.sql files, then llx_mytable_*.sql $files = array(); while (($file = readdir($handle)) !== false) { $files[] = $file; } sort($files); foreach ($files as $file) { if (preg_match('/\\.sql$/i', $file) && !preg_match('/\\.key\\.sql$/i', $file) && substr($file, 0, 4) == 'llx_' && substr($file, 0, 4) != 'data') { $result = run_sql($dir . $file, 1, '', 1); if ($result <= 0) { $error++; } } } rewinddir($handle); // Run llx_mytable.key.sql files (Must be done after llx_mytable.sql) then then llx_mytable_*.key.sql $files = array(); while (($file = readdir($handle)) !== false) { $files[] = $file; } sort($files); foreach ($files as $file) { if (preg_match('/\\.key\\.sql$/i', $file) && substr($file, 0, 4) == 'llx_' && substr($file, 0, 4) != 'data') { $result = run_sql($dir . $file, 1, '', 1); if ($result <= 0) { $error++; } } } rewinddir($handle); // Run data_xxx.sql files (Must be done after llx_mytable.key.sql) $files = array(); while (($file = readdir($handle)) !== false) { $files[] = $file; } sort($files); foreach ($files as $file) { if (preg_match('/\\.sql$/i', $file) && !preg_match('/\\.key\\.sql$/i', $file) && substr($file, 0, 4) == 'data') { $result = run_sql($dir . $file, 1, '', 1); if ($result <= 0) { $error++; } } } rewinddir($handle); // Run update_xxx.sql files $files = array(); while (($file = readdir($handle)) !== false) { $files[] = $file; } sort($files); foreach ($files as $file) { if (preg_match('/\\.sql$/i', $file) && !preg_match('/\\.key\\.sql$/i', $file) && substr($file, 0, 6) == 'update') { $result = run_sql($dir . $file, 1, '', 1); if ($result <= 0) { $error++; } } } closedir($handle); } if ($error == 0) { $ok = 1; } } } if (!$dirfound) { dol_syslog("A module ask to load sql files into " . $reldir . " but this directory was not found.", LOG_WARNING); } return $ok; }
public function action_save() { $action = z(t(v('action'))); $table = z(t(v('table'))); $code = t(v('code')); if (strlen($action) < 1 || strlen($table) < 1) { return ajax_echo('参数不完整'); } $sql = "REPLACE INTO `__meta_code` ( `table` , `action` , `code` ) VALUES ( '" . s($table) . "' , '" . s($action) . "' , '" . s($code) . "' ) "; run_sql($sql); return ajax_echo('<script>window.location.reload();</script>'); }
function publish_feed($content, $uid, $type = 0, $tid = 0) { if (is_mobile_request()) { $device = 'mobile'; } else { $device = 'web'; } $tid = intval($tid); if ($type == 2 && $tid > 0) { $comment_count = get_var("SELECT COUNT(*) FROM `todo_history` WHERE `tid` = '" . intval($tid) . "' AND `type` = 2 ", db()); } else { $comment_count = 0; } $sql = "INSERT INTO `feed` ( `content` , `tid` , `uid` , `type` ,`timeline` , `device` , `comment_count` ) VALUES ( '" . s($content) . "' , '" . intval($tid) . "', '" . intval($uid) . "' , '" . intval($type) . "' , NOW() , '" . s($device) . "' , '" . intval($comment_count) . "' )"; run_sql($sql); $lid = last_id(); if (db_errno() != 0) { return false; } else { if ($comment_count > 0 && $type == 2 && $tid > 0) { $sql = "UPDATE `feed` SET `comment_count` = '" . intval($comment_count) . "' WHERE `tid` = '" . intval($tid) . "' AND `comment_count` != '" . intval($comment_count) . "' "; run_sql($sql); } return $lid; } }
echo $_SESSION['USER']; echo "<br><br>"; $conn = null; require_once '../../connections/Connection.php'; require_once 'publications/checkoutPublicationsUtil.php'; $UnityId = $_SESSION['NAME']; $userType = $_SESSION['USER']; var_dump($conn); echo "<br><br>"; $identifier = $_GET['id']; $type = $_GET['type']; $id_sql = "SELECT min(p.\"ID\") as ID FROM PUBLICATIONS p WHERE p.\"IDENTIFIER\"='{$identifier}'\n\t\tAND p.\"TYPE\" = '{$type}' AND p.\"IsAvailable\"='Y'"; $result = run_sql($conn, $id_sql); var_dump($result); $reserved_sql = "SELECT pd.\"IsReserved\" as isReserved,pd.\"CopyType\" as CopyType FROM PUBLICATION_DETAILS pd WHERE pd.\"Type\" = '{$type}'\n\t\t\t\tAND pd.\"Identifier\"='{$identifier}'"; $is_reserved_result = run_sql($conn, $reserved_sql); var_dump($is_reserved_result); if (sizeof($is_reserved_result) > 0) { $is_reserved = $is_reserved_result[0]['ISRESERVED']; $copy_type = $is_reserved_result[0]['COPYTYPE']; } $duration = get_checkout_duration($type, $userType, $copy_type, $is_reserved); if (sizeof($result) == 1) { $id = $result[0]['ID']; $insert_sql = "INSERT INTO PUBLICATION_CHECKOUT VALUES('{$UnityId}',{$id},SYSTIMESTAMP," . $duration . ",CAST('31/DEC/9999' AS TIMESTAMP))"; $parsed = oci_parse($conn, $insert_sql); oci_execute($parsed); $update_sql = "UPDATE PUBLICATIONS SET \"IsAvailable\"='N' where \"ID\"='{$id}'"; $parsedUpdate = oci_parse($conn, $update_sql); oci_execute($parsedUpdate); }