function index_main() { global $_G; $url = URL . 'a=all'; $sql = make_sql(); $sql['and'] .= " AND `check` =1 "; $index_goods = D(array('and' => $sql['and'], 'all' => true, 'order' => $sql[order]), array('url' => $url . $sql[url], 'size' => 90)); foreach ($index_goods[goods] as $k => $v) { $index_goods[goods][$k][title] .= '(' . $v[yh_price] . ($v[baoyou] == 1 ? '包邮' : '') . ')'; } return array('goods' => $index_goods[goods]); }
function index_main() { global $_G; $tomorrow2 = dmktime(dgmdate(TIMESTAMP + 86400 * 2, 'd') . ' 00:00'); $and = ' AND `check` =1 AND start_time>' . TIMESTAMP . ' AND start_time<' . $tomorrow2; $url = URL . 'a=all'; $sql = make_sql(); $size = $_G['setting']['cate_page']; $index = D(array('and' => $sql['and'], 'order' => $sql[order], 'key' => 'index_goods'), array('url' => $url . $sql[url], 'size' => $size)); $h = dmktime(dgmdate(TIMESTAMP, 'H')); $img = D(array('and' => '', 'table' => 'img', 'order' => 'id DESC', 'limit' => 7, 'key' => 'index_img')); $index['img'] = $img; //$index['tag_kw'] = $this->get_tags(); //$index['tag_shop'] = $this->get_shop(); return $index; }
function main() { global $_G; $fid = intval($_GET['fid']); $_G['channel'] = $channel = $_G['channels'][$fid] ? $_G['channels'][$fid] : $_G['all_channel']['k' . $fid]; if ($fid < 1 || !$channel && !$_G[mobile]) { showmessage('抱歉FID不存在'); return false; } $size = $channel['page'] > 0 ? intval($channel['page']) : $_G[setting][cate_page]; $url = URL; $and = ""; $sql = make_sql(); if ($_G['setting']['main_table'] && array_key_exists($_G['setting']['main_table'], table())) { $rs = D(array('and' => $and . $sql['and'], 'order' => $sql[order], 'table' => $_G['setting']['main_table'], 'key' => 'channel_' . $_G['fid']), array('url' => $url . $sql[url], 'size' => $size)); $this->add($rs); } $this->add(array('channel' => $channel)); seo($channel['title'], $channel['name'] . ',' . $channel['keywords'], $channel['description']); $this->show($channel['channel_tpl'] ? $channel['channel_tpl'] : ''); }
<?php echo show_header(); if (!$user[perm]) { die(redirect_js("index.php")); } echo "<span class='name'>Запросы</span><br>\n<center><form method='POST'>\nSELECT <br>\n<textarea name='sql' cols=30 rows=4>" . ($_POST[sql] ?: "* FROM rt_merchant") . "</textarea><br>\n<input type=submit value='OK'>\n</form>\n</center>\n"; if ($_POST[sql]) { $sql = make_sql($_POST[sql]); echo "<table><tr>"; if ($sql) { foreach ($sql[0] as $k => $v) { echo "<td>{$k}</td>"; } echo "</tr>"; foreach ($sql as $r) { echo "<tr>"; foreach ($r as $k => $v) { echo "<td>{$v}</td>"; } echo "</tr>"; } } else { echo "Ничего нет!"; } echo "</center>"; } echo show_footer();
} } set_time_limit(0); $handle = opendir($text_dir); if (!is_resource($handle)) { echo "Can't open {$DBInfo->text_dir}\n"; exit; } $fp = fopen('titleindex_init.sql', 'w'); if (!is_resource($fp)) { echo 'Unable to open titleindex_init.sql', "\n"; exit; } $date = gmdate("Y-m-d H:i:s", time()) . ' KST'; dump("-- titleindex dump at {$date}\n"); $schema = make_sql(dirname(__FILE__) . '/../lib/schemas/titleindex.sql', '', $type); dump($schema); dump("\n"); $progress = array('\\', '|', '/', '-'); $idx = 0; $buffer = array(); $tablename = 'titleindex'; if ($dumpmode) { $fields = array('title', 'body', '`mtime`'); } else { $fields = array('title', '`mtime`'); } $vals = implode(',', $fields); beginTransaction($type); echo ' '; $j = 0;
} $fp = fopen($editlog, 'r'); if (!is_resource($fp)) { echo "Can't open {$editlog}\n"; exit; } $date = gmdate("Y-m-d-Hi", time()); $dumpfile = 'editlog-' . $date . '.sql'; $outfp = fopen($dumpfile, 'w'); if (!is_resource($outfp)) { echo 'Unable to open ' . $dumpfile, "\n"; exit; } $date = gmdate("Y-m-d H:i:s", time()) . ' KST'; dump("-- dumped at {$date}\n"); $schema = make_sql(dirname(__FILE__) . '/../lib/schemas/editlog.sql', '', $type); dump($schema); dump("\n"); $idx = 0; $buffer = array(); $actions = array('SAVE' => 0, 'CREATE' => 1, 'DELETE' => 2, 'RENAME' => 3, 'REVERT' => 4, 'UPLOAD' => 8, 'SAVESTRANGE' => 16); beginTransaction($type); $j = 0; $curid = 1; $time = ''; while (($line = fgets($fp, 65535)) !== false) { $line = str_replace("\t\t", "\t", $line); $parts = explode("\t", $line); $page_key = $parts[0]; $addr = $parts[1]; $mtime = $parts[2];
function download_tar() { $name = $GLOBALS['form_name']; $data = array(".htaccess" => make_htaccess(), "run.php ->" => 'code/wfpl/run.php', "style.css" => read_whole_file('code/wfpl/metaform/style.css'), "{$name}.html" => make_html(), "{$name}.php" => make_php()); if ($GLOBALS['opt_db'] == 'Yes') { $data["{$name}.sql"] = make_sql(); } if ($GLOBALS['opt_email'] == 'Yes') { $data["{$name}.email.txt"] = make_email(); } make_tar($name, $data); }
function goods() { global $_G; $sql = make_sql(); $url = 'm=ajax&a=goods'; $size = $_G[setting][cate_page] ? $_G[setting][cate_page] : 120; if ($_GET['field']) { $sql['field'] = trim($_GET['field']); } $and = ''; if ($_GET['kw']) { $string = stripsearchkey(trim($_GET['kw'])); if (preg_match("/^%+\$|^_+\$|^\\*+\$/is", $string)) { msg('非法搜索关键字'); } $string = safe_output($string); if (dstrlen($string) < 2) { msg('要搜索的关键字长度不能小于2'); } $_GET[kw] = $string; $and .= " AND title like '%{$string}%' "; $url .= "&kw=" . urlencode_utf8($string); } if ($_GET[tag]) { $tag = trim_html($tag, 1); $tag = daddslashes($_GET[tag]); $and .= "AND FIND_IN_SET('" . $tag . "', keywords) "; $url .= "&tag=" . urlencode_utf8($tag); $sql['and'] .= $and; $sql['url'] .= $url; } $rs = D(array('and' => $and . $sql['and'], 'all' => false, 'order' => $sql[order]), array('url' => $url . $sql[url], 'size' => $size)); $goods = array(); foreach ($rs['goods'] as $k => $v) { $tmp = array(); $tmp['picurl'] = $v['picurl']; $tmp['url'] = $v['url']; $tmp['id_url'] = $v['id_url']; $tmp['num_iid'] = $v['num_iid']; $tmp['aid'] = $v['aid']; $tmp['yh_price'] = $v['yh_price']; $tmp['sum'] = $v['sum']; $tmp['like'] = $v['like']; $tmp['title'] = $v['title']; $tmp['username'] = $v['username']; $goods[] = $tmp; } json(array('data' => $goods, 'status' => 'success')); }
function init_module() { if (file_exists($this->dbname) && filesize($this->dbname) > 0) { return; } // init SQLite3 database. require_once dirname(__FILE__) . '/../tools/utils.php'; $schema = make_sql(dirname(__FILE__) . '/../lib/schemas/titleindex.sql', '', 'sqlite'); $lines = explode("\n", $schema); foreach ($lines as $i => $line) { $line = rtrim($line); if (isset($line[2]) && $line[2] == ' ' && $line[0] == '-' && $line[1] == '-') { unset($lines[$i]); } else { $lines[$i] = $line; } } $striped = implode("\n", $lines); $lines = explode(";\n", $striped); $this->_connect(); foreach ($lines as $q) { // ignore DROP statement if (preg_match('@^drop\\s@i', $q)) { continue; } $ret = $this->db->exec($q); if (!$ret) { trigger_error(sprintf(_("Fail to init SQLite3 with '%s' statement."), $q)); return; } } }
$no_instand_submit = true; $y++; field_param($query_part, $query_sql); // $field['name']=$query_part->name; // $field['type']=$query_part->type; // $field['descr']=$query_part->descr; // $field['value']=generate_values($query_part->value); // $field['loop']=0; // $fields[0][$y]=$field; } } } $smarty->assign('fields', $fields); if ($submit or !$no_instand_submit) { // replace placeholder with data from params $sql = make_sql($HTTP_POST_VARS['returns']); //clear content array # echo $sql; unset($contents); if (!($result = $db->sql_query($sql))) { message_die(GENERAL_ERROR, "Error in sql", '', __LINE__, __FILE__, $sql); } //fill content array with result from query while ($row = $db->sql_fetchrow($result)) { if (is_object(get_content_object_from_id($row[0]))) { $new_content = get_content_object_from_id($row[0]); $arr_keys = array_keys($row); for ($i = 3; $i < sizeof($arr_keys); $i += 2) { $new_content->add_params[$arr_keys[$i]] = $row[$arr_keys[$i]]; } $contents[] = $new_content;
set_time_limit(0); $handle = opendir($text_dir); if (!is_resource($handle)) { echo "Can't open {$DBInfo->text_dir}\n"; exit; } $date = gmdate("Y-m-d-His", time()); $dumpfile = 'dump-' . $date . '.sql'; $fp = fopen($dumpfile, 'w'); if (!is_resource($fp)) { echo 'Unable to open ' . $dumpfile, "\n"; exit; } $date = gmdate("Y-m-d H:i:s", time()) . ' KST'; dump("-- dumped at {$date}\n"); $schema = make_sql(dirname(__FILE__) . '/../lib/schemas/dump.sql', '', $type); dump($schema); dump("\n"); $idx = 0; $buffer = array(); $j = 0; echo ' '; while (($file = readdir($handle)) !== false) { print "" . $progress[$j % 4]; $j++; if ($file[0] == '.' || in_array($file, array('RCS', 'CVS'))) { continue; } $pagefile = $text_dir . '/' . $file; if (is_dir($pagefile)) { continue;
function main() { global $_G; if ($_GET['onsubmit'] && check()) { foreach ($_GET[ids] as $k => $v) { $id = intval($v); if ($_GET[del][$k] == 0) { continue; } if ($_GET['_del_all'] == 1 && $_GET['del'][$k]) { delete_member($id); } } cpmsg('操作成功', 'success', 'm=' . __CLASS__ . '&a=' . __FUNCTION__); return false; } $size = 30; $start = ($_G['page'] - 1) * $size; $url = ''; $and = ''; if ($_GET[groupid] > 0) { $groupid = intval($_GET[groupid]); $and .= " AND groupid = " . $groupid; $url .= "&groupid=" . $groupid; } if ($_GET[uid] > 0) { $uid = intval($_GET[uid]); $and .= " AND uid = " . $uid; $url .= "&uid=" . $uid; } if ($_GET[phone]) { $phone = trim_html($_GET[phone], 1); $and .= " AND phone = " . $phone; $url .= "&phone=" . $phone; } if ($_GET[jf_min] > 0) { $jf_min = intval($_GET[jf_min]); $and .= " AND jf >= " . $jf_min; $url .= "&jf_min=" . $jf_min; } if ($_GET[jf_max] > 0) { $jf_max = intval($_GET[jf_max]); $and .= " AND jf <= " . $jf_max; $url .= "&jf_max=" . $jf_max; } if (isset($_GET[check])) { $check = intval($_GET[check]); $and .= " AND `check` = " . $check; $url .= "&check=" . $check; } if ($_GET[wangwang]) { $wangwang = $_GET[wangwang]; $and .= " AND `wangwang` = " . $wangwang; $url .= "&wangwang=" . $wangwang; } if ($_GET[qq]) { $qq = intval($_GET[qq]); $and .= " AND `qq` = " . $qq; $url .= "&qq=" . $qq; } if ($_GET[email]) { $email = trim($_GET[email]); $and .= " AND `email` = '{$email}'"; $url .= "&email=" . $email; } if ($_GET[phone]) { $phone = trim($_GET[phone]); $and .= " AND `phone` = '{$phone}'"; $url .= "&phone=" . $phone; } if ($_GET[alipay]) { $alipay = trim($_GET[alipay]); $and .= " AND `alipay` = '{$alipay}'"; $url .= "&alipay=" . $alipay; } if ($_GET[order_number]) { $order_number = trim($_GET[order_number]); $and .= " AND `order_number` = '{$order_number}'"; $url .= "&order_number=" . $order_number; } if ($_GET[t_user_name]) { $t_user_name = trim($_GET[t_user_name]); $t_uid = DB::result_first("SELECT uid FROM " . DB::table('member') . " WHERE username = '******'"); if ($t_uid > 0) { $and .= " AND `t_uid` = " . $t_uid; $url .= "&t_uid=" . $t_uid; } } if ($_GET[t_uid]) { $t_uid = intval($_GET[t_uid]); $and .= " AND `t_uid` = " . $t_uid; $url .= "&t_uid=" . $t_uid; } if ($_GET['username']) { $username = trim_html(trim($_GET[username])); //$and .= " AND (username = '******' or `nick` = '$username' )"; $and .= " AND ( `username` LIKE '%" . $username . "%' )"; $url .= "&username="******"SELECT * FROM ".DB::table(__CLASS__)." where 1 $and ORDER BY uid DESC LIMIT $start,$size"); $member_list = D($sql, array('size' => 40, 'url' => $sql[url])); //$count = getcount(__CLASS__,$and); //$showpage = multi($count,$size,$_G[page],URL."m=member&a=main".$url); if (!isset($_GET[order])) { $sql['order'] = ' uid DESC '; } foreach ($member_list[goods] as $k => $v) { $member_list[goods][$k][regdate] = dgmdate($v[regdate], 'u'); $member_list[goods][$k][login_time] = dgmdate($v[login_time], 'u'); if (array_key_exists('sign', table('member'))) { $member_list[$k][sign] = getcount('sign', "uid = " . $v[uid] . " AND type = 'sign'"); } else { $member_list[$k][sign] = 0; } } $this->add($member_list); $this->show('member/main'); }
$fname = $db_name; $sql_file = $file_header; $sql_file .= "# --------------------------------------------------------\n"; } // if ($db_backup_sql_single_file) // Process the tables to backup for ($i = 0; $i < mysql_num_rows($tables); $i++) { $curr_table = mysql_tablename($tables, $i); if (!in_array($curr_table, $excluded_tables)) { log_msg(date("H:i:s") . ": Starting backup of table {$db_name}.{$curr_table} ...\n"); // Increase script execution time-limit to 15 min for every table. if (!ini_get('safe_mode')) { @set_time_limit(15 * 60); } // Create the SQL statements $sql_statements = make_sql($curr_table, $sql_drop_table); // Do we use separate sql-files for every table? if ($sql_single_file == FALSE) { $fname = $curr_table; if ($fp = open_daily($fname)) { $sql_file = $file_header; $sql_file .= "\n"; $sql_file .= "# --------------------------------------------------------\n"; $sql_file .= "# Table: " . backquote($curr_table) . "\n"; $sql_file .= "# --------------------------------------------------------\n"; $sql_file .= $sql_statements; // Write the SQL statements to file (separate sql-file for every table) write_daily($fp, $sql_file); close_daily($fp, $keep_days); // Do we have to do a weekly backup? (separate sql-file for every table) if (date("w") == $weekday) {
function search() { global $_G; $and = ''; $url = URL . 'a=search'; $rs = array(); if ($_GET['kw']) { $string = stripsearchkey(trim($_GET['kw'])); if (preg_match("/^%+\$|^_+\$|^\\*+\$/is", $string)) { msg('非法搜索关键字'); } $string = safe_output($string); if (dstrlen($string) < 2) { msg('要搜索的关键字长度不能小于2'); } $_GET[kw] = $string; $and .= " AND title like '%{$string}%' "; $url .= "&kw=" . urlencode_utf8($string); $and .= " AND `check`=1 AND `hide`=0 "; $and .= " AND ( end_time = 0 or end_time > " . TIMESTAMP . ")"; $sql = make_sql(); $size = 60; $rs = D(array('and' => $and . $sql['and'], 'order' => $sql[order]), array('url' => $url . $sql[url], 'size' => $size)); //dump($and .$sql['and'],1); } else { if ($_GET['price1'] && $_GET['price2']) { $sql = make_sql(); $size = 60; $rs = D(array('and' => $and . $sql['and'], 'all' => true, 'order' => $sql[order], 'key' => 'search'), array('url' => $url . $sql[url], 'size' => $size)); } } seo($string . ' - 商品搜索'); $this->add($rs); $this->show(); }