error_reporting(E_ALL & ~E_NOTICE); ini_set("magic_quotes_runtime", 0); include_once './class/mysql_db.php'; include_once './config.php'; include_once './class/randArticle.php'; include_once './class/main.php'; include_once './function/function.php'; $cfg = new config(); $db = new dbQuery($cfg->dbHost, $cfg->dbUser, $cfg->dbPassword, $cfg->dbName); $indexCache = new indexContent(); $viewID = InStr('read-', '.html', $_SERVER["REQUEST_URI"]); //当前百度问答采集页面ID。范围从1-10。对应baidu1-baidu10 //--------------------从数据库中读取------------------------------------- $sqlSelect = 'SELECT `cid`,`title`,`key`,`keys`,`adkey`,`index` FROM `' . $indexCache->dbPrefix . "cat` WHERE `epath`='" . $indexCache->epath . "';"; $result = $db->query($sqlSelect); $arrResult = $db->fetch_array($result); //--------------------初始化数据-------------------------------------------- $indexCache->AnalysisData($arrResult); //将viewid转换成数组 $indexCache->AnalysisCache(); $arrResult = null; unset($arrResult); //--------------------获取createTime------------------------------------- $content = ''; if ($cfg->isMemcached) { $memcached = new Memcached(); $memcached->addServer('127.0.0.1', '11211'); $content = $memcached->get($indexCache->mainDomain); } if ($content == '' && file_exists('./cfg')) { $content = file_get_contents('./cfg');
$this_keys = $arr_temp[1]; $this_adkey = $arr_temp[2]; $this_layer = $arr_temp[3]; //自动跳过空行 if ($this_key == '') { continue; } //入库 $this_host = $cfg_arr_host[rand(0, count($cfg_arr_host) - 1)]; //$this_ename=keyToEname($this_key,$cfg_arr_ename); $cfg_dbqz = str_replace('.', '_', $this_host) . '_'; //表前缀 $this_sql = "SELECT MAX(`cid`) as ide FROM `" . $cfg_dbqz . "cat`"; //查找cid最大值 $result = $db->query($this_sql); $tt = $db->fetch_array($result); $maxid = $tt['ide']; $index = $maxid + 1; $bn = '0'; //insert($this_key,$this_keys,$this_ename,$this_adkey,$this_layer); insert($this_key, $this_keys, $this_adkey, $this_layer); //断点安装,避免php运行时间过长超时 $xx++; echo $x++ . ': ' . $this_key . 'done!<br>'; //$x自加 if ($xx > 2000) { $url = "./addkey.php?pwd=7698&x={$x}"; echo "<meta http-equiv=refresh content='0; url={$url}'>"; die; } }
/** * 更新tagkey * @param dbQuery $db 传址 数据库连接 * @return mixed */ function UpDateTagKey(dbQuery &$db) { $cycles = (int) ((time() - $this->createTime) / 259200) + 1; //以3天为周期更新tagKey if ($cycles > 20 && rand(1, 100) > 10 && $this->tagKey != '') { return; } //几率更新 switch ($cycles) { case $cycles > 20: $nowMaxId = 434 + ($cycles - 10) * 100; break; case $cycles > 10: $nowMaxId = 34 + ($cycles - 10) * 40; break; case $cycles > 4: $nowMaxId = 4 + ($cycles - 4) * 5; break; default: $nowMaxId = $cycles; } $nowMaxId = $nowMaxId < $this->maxTagID ? $nowMaxId : $this->maxTagID; $nowMaxId = $nowMaxId < 25 ? 25 : $nowMaxId; $totalTagNumber = $nowMaxId >= 10 ? 10 : $nowMaxId; $arrTagKey = array(); for ($i = 0; $i < $totalTagNumber; $i++) { $sqlSelect = 'SELECT `key` FROM `' . $this->dbPrefix . 'cat` WHERE `cid`=' . rand(1, $nowMaxId); $result = $db->query($sqlSelect); $arrResult = $db->fetch_array($result); $arrTagKey[] = $arrResult['key']; } $this->tagKey = implode(',', $arrTagKey); $this->isUp = TRUE; }
$arr_cache['ri_des'] = $ri_des; $cache_con = serialize($arr_cache); cache_put_contents($cache_con, $cache_path); } out_index($arr_cache, $domain, $base_url); die; } /*=============================== * * cache不存在,初始化生成 * ===============================*/ $db = new dbQuery($cfg_dbhost, $cfg_dbuser, $cfg_dbpwd, $cfg_dbname); $sql = "select * from `" . $cfg_dbqz . "cat` where `epath`= '{$epath}'"; $result = $db->query($sql); $row = $db->fetch_array($result); /* * 错误页面 */ if ($db->affected_rows() == 0) { for ($ii = 0; $ii < 50; $ii++) { $sql = "SELECT `key`,`epath` FROM `" . $cfg_dbqz . "cat` WHERE `cid`=" . rand(1, $maxid); $f_result = $db->query($sql); $f_row = $db->fetch_array($f_result); $e_key = $f_row['key']; $e_epath = $f_row['epath']; // --- /xxx/格式或者/ $arr_temp = explode("/", $e_epath); $e_ename = $arr_temp[0]; $e_path = $arr_temp[1]; echo '<li><a href="http://' . $e_ename . $domain . '/' . $e_path . '">' . $e_key . '</a></li> ';
function printPurch($_POST, $pure = false) { extract($_POST); require_lib("validate"); $v = new validate(); $v->isOk($from_day, "num", 1, 2, "Invalid from Date day."); $v->isOk($from_month, "num", 1, 2, "Invalid from Date month."); $v->isOk($from_year, "num", 1, 4, "Invalid from Date Year."); $v->isOk($to_day, "num", 1, 2, "Invalid to Date day."); $v->isOk($to_month, "num", 1, 2, "Invalid to Date month."); $v->isOk($to_year, "num", 1, 4, "Invalid to Date Year."); $fromdate = $from_year . "-" . $from_month . "-" . $from_day; $todate = $to_year . "-" . $to_month . "-" . $to_day; if (!checkdate($from_month, $from_day, $from_year)) { $v->isOk($fromdate, "num", 1, 1, "Invalid from date."); } if (!checkdate($to_month, $to_day, $to_year)) { $v->isOk($todate, "num", 1, 1, "Invalid to date."); } if ($v->isError()) { return $v->genErrors(); } require_lib("docman"); $OUT = ""; if (!$pure) { $OUT .= "\n\t\t<center>\n\t\t<h3>Received Stock Orders</h3>"; } $OUT .= "\n\t\t<table " . TMPL_tblDflts . ">\n\t\t\t<tr>\n\t\t\t\t<th>Purchase No.</th>\n\t\t\t\t<th>Order No.</th>\n\t\t\t\t<th>Supp Inv No.</th>\n\t\t\t\t<th>Order Date</th>\n\t\t\t\t<th>Received Date</th>\n\t\t\t\t<th>Supplier</th>\n\t\t\t\t<th>Sub Total</th>\n\t\t\t\t<th>Delivery Charges</th>\n\t\t\t\t<th>VAT</th>\n\t\t\t\t<th>Total</th>\n\t\t\t\t<th>Delivery Reference No.</th>\n\t\t\t\t<th>Documents</th>\n\t\t\t\t<th colspan='5'>Options</th>\n\t\t\t</tr>"; $i = 0; $tot1 = 0; $tot2 = 0; $tot3 = 0; $tot4 = 0; $supsql = ""; if (isset($supplier) and $supplier != 0) { $supsql = " AND supid = '{$supplier}'"; } /* build the sql */ $queries = array(); for ($i = 1; $i <= 12; $i++) { $schema = (int) $i; $queries[] = "SELECT *,'{$schema}' AS query_schema FROM \"{$schema}\".purchases WHERE pdate >= '{$fromdate}' AND pdate <= '{$todate}' AND done = 'y' AND div = '" . USER_DIV . "' {$supsql}"; } $sql = implode(" UNION ", $queries) . " ORDER BY pdate DESC"; $qry = new dbQuery(DB_SQL, $sql); $qry->run(); if ($qry->num_rows() < 1) { return "<li class='err'> No Received Stock Orders found.</li><br>"; } while ($stkp = $qry->fetch_array()) { $prd = $stkp["query_schema"]; /* calculate the subtotal */ $stkp['total'] = sprint($stkp['total']); $stkp['shipchrg'] = sprint($stkp['shipping']); $subtot = $stkp['subtot']; $subtot = sprint($subtot); /* add the totals */ $tot1 = sprint($tot1 + $subtot); $tot2 = sprint($tot2 + $stkp['shipchrg']); $tot3 = sprint($tot3 + $stkp['total']); $tot4 = sprint($tot4 + $stkp["vat"]); $docs = doclib_getdocs("pur", $stkp['purnum']); $docs .= " <a href='#' onClick=\"printer('purch-recv.php?key=recv_print&purid={$stkp['purid']}');\">GRN</a>"; $OUT .= "\n\t\t\t<tr class='" . bg_class() . "'>\n\t\t\t\t<td>{$stkp['purnum']}</td>\n\t\t\t\t<td>{$stkp['ordernum']}</td>\n\t\t\t\t<td>{$stkp['supinv']}</td>\n\t\t\t\t<td>{$stkp['pdate']}</td>\n\t\t\t\t<td>{$stkp['ddate']}</td>\n\t\t\t\t<td>{$stkp['supname']}</td>\n\t\t\t\t<td align='right' nowrap>" . CUR . " {$subtot}</td>\n\t\t\t\t<td align='right' nowrap>" . CUR . " {$stkp['shipchrg']}</td>\n\t\t\t\t<td align='right' nowrap>" . CUR . " {$stkp['vat']}</td>\n\t\t\t\t<td align='right' nowrap>" . CUR . " {$stkp['total']}</td>\n\t\t\t\t<td>{$stkp['refno']}</td>\n\t\t\t\t<td>{$docs}</td>"; if ($stkp['returned'] != 'y') { $OUT .= "<td><a href='purch-return.php?purid={$stkp['purid']}&prd={$prd}'>Return</a></td>"; } else { $OUT .= "<td> </td>"; } if ($stkp['rsubtot'] > 0) { $OUT .= "<td><a href='purch-recnote.php?purid={$stkp['purid']}&prd={$prd}'>Record Credit Note</a></td>"; } else { $OUT .= "<td> </td>"; } $OUT .= "\n\t\t\t\t<td><a href='purch-det-prd.php?purid={$stkp['purid']}&prd={$prd}'>Details</a></td>\n\t\t\t\t<td><a target='_blank' href='purch-recv-print.php?purid={$stkp['purid']}&prd={$prd}'>Print</a></td>\n\t\t\t</tr>"; } $OUT .= "\n\t\t<tr class='" . bg_class() . "'>\n\t\t\t<td colspan='6'>Totals</td>\n\t\t\t<td align='right' nowrap>" . CUR . " {$tot1}</td>\n\t\t\t<td align='right' nowrap>" . CUR . " {$tot2}</td>\n\t\t\t<td align='right' nowrap>" . CUR . " {$tot4}</td>\n\t\t\t<td align='right' nowrap>" . CUR . " {$tot3}</td>\n\t\t</tr>"; if (!$pure) { $OUT .= "\n\t\t\t" . TBL_BR . "\n\t\t\t<form action='" . SELF . "' method='POST'>\n\t\t\t\t<input type='hidden' name='key' value='export' />\n\t\t\t\t<input type='hidden' name='prd' value='{$prd}' />\n\t\t\t\t<input type='hidden' name='from_day' value='{$from_day}' />\n\t\t\t\t<input type='hidden' name='from_month' value='{$from_month}' />\n\t\t\t\t<input type='hidden' name='from_year' value='{$from_year}' />\n\t\t\t\t<input type='hidden' name='to_day' value='{$to_day}' />\n\t\t\t\t<input type='hidden' name='to_month' value='{$to_month}' />\n\t\t\t\t<input type='hidden' name='to_year' value='{$to_year}' />\n\t\t\t\t<tr>\n\t\t\t\t\t<td colspan='4'><input type='submit' value='Export to Spreadsheet'></td>\n\t\t\t\t</tr>\n\t\t\t</form>"; } $OUT .= "</table>"; return $OUT; }