1 Star 0 Fork 77

苗金辉 / ebookapp

forked from aming / ebookapp 
加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
chapter_ctx_next.php 2.45 KB
一键复制 编辑 原始数据 按行查看 历史
lixiaoming 提交于 2015-04-09 19:39 . 增加了点击数目的统计
<?php
include_once "init.php";
include_once WEB_ROOT."util/mysql_class.php";
include_once WEB_ROOT."smarty_inc.php";
include_once WEB_ROOT."admin/funcs/make_article_func.php";
include_once WEB_ROOT."admin/funcs/app_util_func.php";
include_once WEB_ROOT."admin/funcs/make_single_chapter_func.php";
include_once WEB_ROOT."util/util.php";
include_once WEB_ROOT."util/Model_class.php";
include_once WEB_ROOT.'admin/Parser_class.php';
include_once 'third_part/simple_html_dom.php';
include_once 'util/mobile_redirect.php';
//$db = new mysql();
if(@$_GET["chapter_id"]){
$chapter_id = str_check($_GET["chapter_id"]);
$article_id = str_check($_GET["article_id"]);
$flag = $_GET["flag"];
if(strcmp($flag,"next")==0){
//echo "1";
update_clicktimes($article_id);
$next_id = next_chapter_func($chapter_id,$article_id);
}else{
//echo "2";
$next_id = last_chapter_func($chapter_id,$article_id);
update_clicktimes($article_id);
}
//echo $next_id;
navToChapter($next_id);
}else{
echo "artileid missing";
}
function update_clicktimes($article_id){
try{
$db = new mysql();
$sql_select="update t_article set click_times = click_times+1 where id=".$article_id;
$query = $db->query($sql_select);
}catch (Exception $e){
}
}
function next_chapter_func($chapter_id,$article_id){
$db = new mysql();
$sql_select="select * from t_chapter where id > ".$chapter_id." and artile_id=".$article_id." order by id limit 0,1";
$query = $db->query($sql_select);
$count = 0;
$row=$db->fetch_row_array($query);
if($row){
return $row["id"];
}else{
return -1;
}
}
function last_chapter_func($chapter_id,$article_id){
$db = new mysql();
$sql_select="select * from t_chapter where id < ".$chapter_id." and artile_id=".$article_id." order by id desc limit 0,1";
$query = $db->query($sql_select);
$count = 0;
$row=$db->fetch_row_array($query);
if($row){
return $row["id"];
}else{
return -1;
}
}
function navToChapter($chapter_id){
if($chapter_id<0){
echo "<head><meta charset=\"gb2312\"></head>ѵҳ ";
return;
}
$local_url="/data/chapters/".$chapter_id.".htm";
setcookie('history',$local_url,time()+3600*24*7,"/");
$act_file = WEB_ROOT.$local_url;
if(!file_exists($act_file)){
try{
make_chapter_func($chapter_id,false);
}catch(Exception $e){
}
}
if(file_exists($act_file)){
echo read_file_content($act_file);
}else{
showErrorPage($chapter_id);
}
}
?>
PHP
1
https://gitee.com/mmmjh/ebookapp.git
git@gitee.com:mmmjh/ebookapp.git
mmmjh
ebookapp
ebookapp
master

搜索帮助