public function dointsql() { $this->checksafeauth(); $sql = trim($_POST['sql']); if (empty($sql)) { $this->error('SQL语句不能为空!'); } else { $sql = trim(stripslashes($sql)); $rs = new Model(); $rs->query($sql); $lastsql = $rs->getLastSql(); $this->assign("waitSecond", 5); $this->success('SQL语句成功运行!<br>' . $lastsql); } }
/** *导出城市指南内容 *@date 2010-5-12 *@time 下午04:58:29 */ function get_cityguide() { load("extend"); $cid = array(1 => '2', 2 => '3', 27 => '1', 28 => '4'); $p = $_GET['page']; //导出城市指南内容 $dao = new Model(); //$sql="SELECT a.*,b.my_content FROM bfc_article AS a LEFT JOIN bfc_article_content_4 AS b ON a.aid=b.aid"; $p1 = empty($p) ? 0 : $p * 50; $p2 = ($p + 1) * 50; $sqlc = "SELECT count(*) c FROM bfc_article AS a LEFT JOIN bfc_article_content_4 AS b ON a.aid=b.aid LEFT JOIN bfc_reply AS r ON b.rid=r.rid"; $list = $dao->query($sqlc); if ($list[0]['c'] > $p2) { $np = empty($p) ? 2 : $p + 1; $limit = "LIMIT {$p1},50"; echo $limit . "<hr>"; $sql = "SELECT a.*,b.my_content,r.content FROM bfc_article AS a LEFT JOIN bfc_article_content_4 AS b ON a.aid=b.aid LEFT JOIN bfc_reply AS r ON b.rid=r.rid ORDER BY a.aid {$limit}"; echo $sql . '<br>'; echo '<a href="' . __URL__ . '/get_cityguide/page/' . $np . '">下一页</a>'; $list = $dao->query($sql); echo $dao->getLastSql(); $i = 1; //dump(empty($list)); if (!empty($list)) { foreach ($list as $v) { $t = time(); $v['fid'] = $v['fid'] + 1000; $data = array(); $data['typeid'] = $v['fid']; //$data['cid']=$cid[$v['city_id']]; $data['uid'] = $v['uid']; $data['channel'] = 2; $data['click'] = $v['hits']; $data['title'] = $v['title']; $data['pubdate'] = $v['posttime']; $data['senddate'] = $v['posttime']; $data['senddate'] = $v['posttime']; $data['showstart'] = $v['posttime']; $kw = str_word_count($v['title'], 1); $keywords = ""; foreach ($kw as $vkw) { $keywords .= $vkw . ','; } $data['keywords'] = empty($v['keywords']) ? trim($keywords, ',') : $v['keywords']; $data['comments'] = $v['comments']; $data['picurl'] = $v['picurl']; $data['my_content'] = empty($v['my_content']) ? '' : nl2br(strip_tags($v['my_content'])); $data['uip'] = $v['ip']; $data['uid'] = $v['uid']; $data['lastview'] = $v['lastview']; $data['editpwd'] = $v['edittime']; $data['ismake'] = $v['yz']; $data['description'] = msubstr(strip_tags($v['my_content']), 0, 200); $aid = $dao->Table('iic_archives')->add($data); if ($aid) { $article = array(); $article['aid'] = $aid; $article['content'] = $v['content']; $article_id = $dao->Table('iic_addon_article')->add($article); if ($article_id) { echo '执行成功!<br>'; } else { echo '<b>附加表写入失败!!<b><br>'; //$this->error('附加表写入失败!'); } } else { echo '<b>档案表写入失败!!<b><br>'; } } echo '<script>setTimeout(window.location.href="' . __URL__ . '/get_cityguide/page/' . $np . '",300000);</script>'; echo '<a href="' . __URL__ . '/get_cityguide/page/' . $np . '">下一页</a>'; } else { echo '<b>数据查询失败!!<b><br>'; } } else { exit('导出结束'); } }
function clear() { set_time_limit(0); $basepath = ROOT . '/Dynamicconf/truncate'; $clearLogPath = 'clear_dynamic_' . date('Y-m-d', time()); // 单个文件 $file = file_get_contents($basepath . '/file.log'); // 文件夹 $folder = file_get_contents($basepath . '/folder.log'); // 数据表格 $datatable = file_get_contents($basepath . '/dt.log'); // 动态建模生成表 $table = file_get_contents($basepath . '/table.log'); if ($file) { // 开始删除文件 foreach (explode(',', $file) as $k => $v) { $ret = unlink($v); $ret = $ret === false ? '失败' : '成功'; logs('文件删除 :' . $v . $ret, $clearLogPath, '', __CLASS__, __FUNCTION__, __METHOD__); // sleep(1); // 百万分之一秒 //usleep(10000); } } if ($folder) { // 开始删除文件夹 foreach (explode(',', $folder) as $k => $v) { $ret = deldir($v); $ret = $ret === false ? '失败' : '成功'; logs('删除文件夹 :' . $v . $ret, $clearLogPath, '', __CLASS__, __FUNCTION__, __METHOD__); } } $model = new Model(); $model->startTrans(); if ($datatable) { // 删除数据表格 $dropSql = "DROP TABLE {$datatable}"; $ret = $model->query($dropSql); logs('删除表状态 :' . $ret === false ? '失败' : '成功', $clearLogPath, '', __CLASS__, __FUNCTION__, __METHOD__); logs('删除表 :' . $model->getLastSql(), $clearLogPath, '', __CLASS__, __FUNCTION__, __METHOD__); } if ($table) { // 动态建模生成表 // 删除数据表格 $dropSql = "DROP TABLE {$table}"; $ret = $model->query($dropSql); logs('删除表状态 :' . $ret === false ? '失败' : '成功', $clearLogPath, '', __CLASS__, __FUNCTION__, __METHOD__); logs('删除表 :' . $model->getLastSql(), $clearLogPath, '', __CLASS__, __FUNCTION__, __METHOD__); } // 清空动态建模核心表 $truncateCoreTable[] = "TRUNCATE TABLE `mis_dynamic_calculate`"; $truncateCoreTable[] = "TRUNCATE TABLE `mis_dynamic_controll_record`"; $truncateCoreTable[] = "TRUNCATE TABLE `mis_dynamic_database_mas`"; $truncateCoreTable[] = "TRUNCATE TABLE `mis_dynamic_database_sub`"; $truncateCoreTable[] = "TRUNCATE TABLE `mis_dynamic_form_datatable`"; $truncateCoreTable[] = "TRUNCATE TABLE `mis_dynamic_form_datatable_oprate`"; $truncateCoreTable[] = "TRUNCATE TABLE `mis_dynamic_form_field`"; $truncateCoreTable[] = "TRUNCATE TABLE `mis_dynamic_form_indatatable`"; $truncateCoreTable[] = "TRUNCATE TABLE `mis_dynamic_form_manage`"; $truncateCoreTable[] = "TRUNCATE TABLE `mis_dynamic_form_propery`"; $truncateCoreTable[] = "TRUNCATE TABLE `mis_dynamic_form_record`"; $truncateCoreTable[] = "TRUNCATE TABLE `mis_dynamic_form_template`"; foreach ($truncateCoreTable as $k => $v) { $model->execute($v); logs('删除表 :' . $model->getLastSql(), $clearLogPath, '', __CLASS__, __FUNCTION__, __METHOD__); } $model->commit(); deldir($basepath); }