job.php
来自「一个可以实时查看股票行情的小程序,真是一个好程序哦,直得大家」· PHP 代码 · 共 466 行
PHP
466 行
<?php
require_once("./global.php");
if($action=='delimg'){
$imgdb=$db->get_one("SELECT icon FROM pw_members WHERE uid='$winduid'");
Add_S($imgdb);
if($imgdb){
$deldb=explode("|",$imgdb['icon']);
if($deldb[1] && !ereg("^http",$deldb[1]) && strpos($deldb[1],'..')===false){
@unlink("./$imgpath/upload/$deldb[1]");
$db->update("UPDATE pw_members SET icon='$deldb[0]' WHERE uid='$winduid'");
} else{
Showmsg('job_delimg_error');
}
}
refreshto("profile.php",'operate_success');
}elseif($action=='report'){
!$gp_allowreport && Showmsg('report_right');
$pid=(int)$pid;
if(!$winduid || !is_numeric($tid) && !is_numeric($pid)){
Showmsg('undefined_action');
}
$rt=$db->get_one("SELECT tid FROM pw_report WHERE uid='$winduid' AND tid='$tid' AND pid='$pid'");
if($rt){
Showmsg('have_report');
}
if(!$step){
require_once('./header.php');
require_once PrintEot('report');footer();
} elseif($step==2){
$reason=Char_cv($reason);
$db->update("INSERT INTO pw_report(tid,pid,uid,type,reason) VALUES('$tid','$pid','$winduid','$type','$reason')");
Showmsg('report_success');
}
}elseif($action=='sign'){
$db->update("UPDATE pw_memberdata SET lastvisit='$timestamp' WHERE uid='$winduid'");
refreshto("$db_bfn",'operate_success');
}elseif($action=='switch'){
$cur=$cur==0 ? 1 : 0;
$db->update("UPDATE pw_memberdata SET editor='$cur' WHERE uid='$winduid'");
refreshto($_SERVER['HTTP_REFERER'],'operate_success');
}elseif($previewjob=='preview'){
require_once('./require/bbscode.php');
require_once('./header.php');
$preatc=Char_cv($preatc);
$preatc=str_replace("\n","<br>",$preatc);
$preatc=convert($preatc,$db_windpost);
require_once PrintEot('preview');footer();
} elseif($rd_previous==1){
if(!is_numeric($tid)){
require_once(R_P.'require/url_error.php');
}
$rs = $db->get_one("SELECT fid,postdate,lastpost FROM pw_threads WHERE tid='$tid'");
if($url){
$lastpost = $rs['postdate'];
$by='postdate';
}else{
$lastpost = $rs['lastpost'];
$by='lastpost';
$url='read.php';
}
$fid=$rs['fid'];
if($goto=="previous"){
$next = $db->get_one("SELECT tid,postdate FROM pw_threads WHERE fid='$fid' AND $by>'$lastpost' ORDER BY $by ASC LIMIT 0, 1");
if($next) {
$headurl="$url?tid=$next[tid]";
header("Location: $headurl");exit;
} else {
header("Location: $url?tid=$tid");exit;
}
} elseif($goto=="next"){
$last = $db->get_one("SELECT tid,postdate FROM pw_threads WHERE fid='$fid' AND $by<'$lastpost' ORDER BY $by DESC LIMIT 0, 1");
if($last) {
$headurl="$url?tid=$last[tid]";
header("Location: $headurl");exit;
} else {
header("Location: $url?tid=$tid");exit;
}
}
} elseif($action=='download'){
if(is_numeric($aid)){
if(is_numeric($pid)){
$table = 'pw_posts';
$where = "pid='$pid'";
$post = $db->get_one("SELECT fid,aid FROM pw_posts WHERE pid='$pid'");
} else{
$table = 'pw_tmsgs';
$where = "tid='$tid'";
$post = $db->get_one("SELECT t.fid,tm.aid FROM pw_threads t LEFT JOIN pw_tmsgs tm USING(tid) WHERE t.tid='$tid'");
}
$attach = unserialize(stripslashes($post['aid']));
$fid = $post['fid'];
@extract($attach[$aid]);
if(!$attachurl || strpos($attachurl,'../')!==false || strpos($attachurl,"..\\")!==false){
Showmsg('job_attach_error');
}
} else{
Showmsg('job_attach_error');
}
require_once(R_P.'require/forum.php');
$foruminfo=$db->get_one("SELECT f_type,style,password,allowvisit,forumadmin,allowdownload FROM pw_forums WHERE fid='$fid'");
if(!$foruminfo){
require_once(R_P.'require/url_error.php');
}
wind_forumcheck($foruminfo);
/*
* 获取管理权限
*/
if($windid==$manager || ($foruminfo['forumadmin'] && strpos($foruminfo['forumadmin'],','.$windid.',')!==false)){
$admincheck=1;
} else{
$admincheck=0;
}
/**
* 版块权限判断
*/
if($foruminfo['allowdownload'] && strpos($foruminfo['allowdownload'],','.$groupid.',')===false && !$admincheck){
Showmsg('job_attach_forum');
}
/**
* 用户组权限判断
*/
if(!$allowdownload && $gp_allowdownload==0 && !$admincheck){
Showmsg('job_attach_group');
}
if($needrvrc && $userrvrc<$needrvrc && !$admincheck){
Showmsg('job_attach_rvrc');
}
if(!$attach_url && !is_readable("$attachpath/$attachurl")){
Showmsg('job_attach_error');
}
$db->update("UPDATE pw_attachs SET hits=hits+1 WHERE aid='$aid'");
$attach[$aid]['hits']++;
$attach=addslashes(serialize($attach));
$db->update("UPDATE $table SET aid='$attach' WHERE $where");
$filename =basename("$attachpath/$attachurl");
$fileext = substr(strrchr($attachurl,'.'),1);
if(strpos($_SERVER['HTTP_USER_AGENT'], 'MSIE')!==false && $fileext=='torrent' ){
$attachment='inline';
} else{
$attachment='attachment';
}
ob_end_clean();
//header('Expires: Mon, 26 Jul 1997 05:00:00 GMT');
header('Last-Modified: '.gmdate('D, d M Y H:i:s',$timestamp+31536000).' GMT');
header('Pragma: no-cache');
header('Content-Encoding: none');
header('Content-Disposition: '.$attachment.'; filename='.$name);
header('Content-type: '.$fileext);
if($attach_url && !file_exists("$attachpath/$attachurl") && function_exists('file_get_contents')){
$downcontent=file_get_contents($attach_url."/$attachurl");
}else{
$filesize = filesize($attachpath.'/'.$attachurl);
header('Content-Length: '.$filesize);
$downcontent=readover("$attachpath/$attachurl");
}
echo $downcontent;
exit;
} elseif($action=='deldownfile'){
if(is_numeric($aid)){
if(is_numeric($pid)){
$table = 'pw_posts';
$where = "pid='$pid'";
$post = $db->get_one("SELECT fid,tid,aid AS oldaid,authorid FROM pw_posts WHERE pid='$pid'");
} else{
$table = 'pw_tmsgs';
$where = "tid='$tid'";
$post = $db->get_one("SELECT t.tid,t.fid,t.authorid,tm.aid AS oldaid FROM pw_threads t LEFT JOIN pw_tmsgs tm USING(tid) WHERE t.tid='$tid'");
}
$tid = $post['tid'];
$fid = $post['fid'];
$attach = unserialize(stripslashes($post['oldaid']));
@extract($attach[$aid]);
if(!$attachurl || strpos($attachurl,'../')!==false || strpos($attachurl,"..\\")!==false){
Showmsg('job_attach_error');
}
} else{
Showmsg('job_attach_error');
}
require_once(R_P.'require/forum.php');
require_once(R_P.'require/updateforum.php');
$foruminfo=$db->get_one("SELECT f_type,style,password,allowvisit,forumadmin,allowhtm FROM pw_forums WHERE fid='$fid'");
if(!$foruminfo){
require_once(R_P.'require/url_error.php');
}
wind_forumcheck($foruminfo);
/*
* 获取管理权限
*/
if($windid==$manager || ($foruminfo['forumadmin'] && strpos($foruminfo['forumadmin'],','.$windid.',')!==false)){
$admincheck=1;
} else{
$admincheck=0;
}
if ($groupid!='guest' && ($admincheck || $post['authorid']==$winduid || $SYSTEM['delattach'])){
@unlink("$attachpath/$attachurl");
$attach=unserialize(stripslashes($post['oldaid']));
unset($attach[$aid]);
if($attach){
$attach=addslashes(serialize($attach));
} else{
$attach='';
}
$db->update("UPDATE $table SET aid='$attach' WHERE $where");
$db->update("DELETE FROM pw_attachs WHERE aid='$aid'");
$ifupload=getattachtype($tid);
$db->update("UPDATE pw_threads SET ifupload='$ifupload' WHERE tid='$tid'");
if($foruminfo['allowhtm']){
require_once R_P.'require/template.php';
refreshto($jumpurl,'operate_success');
} else{
refreshto("read.php?fid=$fid&tid=$tid",'operate_success');
}
} else{
Showmsg('job_attach_right');
}
} elseif($action=='favor'){
if($groupid=='guest'){
Showmsg('not_login');
}
if(!$job){
include_once(R_P.'data/bbscache/forum_cache.php');
require R_P.'require/forum.php';
require './header.php';
$favordb=array();
$favor=$db->get_one("SELECT tids FROM pw_favors WHERE uid='$winddb[uid]'");
if($favor['tids']){
$query=$db->query("SELECT t.fid,t.tid,t.subject,t.postdate,t.author,t.replies,t.hits FROM pw_threads t WHERE t.tid IN($favor[tids]) ORDER BY t.postdate DESC");
while($favor=$db->fetch_array($query)){
$newtids.=$favor['tid'].',';
$favor['postdate']=get_date($favor['postdate']);
$favor['forum']=$forum[$favor['fid']]['name'];
$favordb[]=$favor;
}
$newtids=substr($newtids,0,-1);
$newtids==$favor['tids'] || $db->update("UPDATE pw_favors SET tids='$newtids' WHERE uid='$winddb[uid]'");
}
require_once PrintEot('favor');footer();
} elseif($job=='add'){
if(empty($tid)||!is_numeric($tid)){
Showmsg('illegal_tid');
}
$rs=$db->get_one("SELECT tids FROM pw_favors WHERE uid='$winddb[uid]'");
if($rs){
$tids=$rs['tids'];
$favornum=50;
$tid_db=explode(",",$tids);
if(count($tid_db)>$favornum){
Showmsg('job_favor_full');
}
$olddb=','.$tids.',';
if(strpos($olddb,','.$tid.',')!==false){
Showmsg('job_favor_error');
}
$tids.=','.$tid;
$db->update("UPDATE pw_favors SET tids='$tids' WHERE uid='$winddb[uid]'");
}else{
$db->update("INSERT INTO pw_favors(uid,tids) VALUES('$winddb[uid]','$tid')");
}
refreshto("job.php?action=favor",'operate_success');
} elseif($job=='clear'){
$rs=$db->get_one("SELECT tids FROM pw_favors WHERE uid='$winddb[uid]'");
if($rs){
$tids=$rs['tids'];
$tid_db=explode(",",$tids);
$t_count=count($tid_db);
for($i=0;$i<$t_count;$i++){
if(@in_array($tid_db[$i],$delid)){
unset($tid_db[$i]);
}
}
$new_tids=implode(",",$tid_db);
if($new_tids!=$tids){
if($new_tids){
$db->update("UPDATE pw_favors SET tids='$new_tids' WHERE uid='$winddb[uid]'");
}else{
$db->update("DELETE FROM pw_favors WHERE uid='$winddb[uid]'");
}
refreshto("job.php?action=favor",'operate_success');
}else{
Showmsg('job_favor_del');
}
}else{
Showmsg('job_favor_del');
}
}
} elseif($action=='viewtody'){
$wind_in='vt';
if($db_today==0){
Showmsg('job_viewtody_close');
}
require_once('./header.php');
require_once(R_P.'require/forum.php');
$check_admin="N";
if ($windid==$manager)
$check_admin="Y";
if (empty($page)){
$page=1;
}
$filename=R_P.'data/bbscache/today.php';
$dbtdsize=100+1;
$seed=$page*$db_perpage;$count=0;
if($fp=@fopen($filename,"rb")){
flock($fp,LOCK_SH);
$node=fread($fp,$dbtdsize);
$nodedb=explode("\t",$node);/*头结点在第二个数据段*/
$nodefp=$dbtdsize*$nodedb[1];
fseek($fp,$nodefp,SEEK_SET);
$todayshow=fseeks($fp,$dbtdsize,$seed);/*传回数组*/
fseek($fp,0,SEEK_END);
$count=floor(ftell($fp)/$dbtdsize)-1;
fclose($fp);
}
if ($count%$db_perpage==0){
$numofpage=$count/$db_perpage; //$numofpage为 一共多少页
} else{
$numofpage=floor($count/$db_perpage)+1;
}
if ($page>$numofpage)
$page=$numofpage;
$pagemin=min(($page-1)*$db_perpage , $count-1);
$pagemax=min($pagemin+$db_perpage-1, $count-1);
$fenye=numofpage($count,$page,$numofpage,"job.php?action=viewtody&");
$inbbsdb=array();
for ($i=$pagemin; $i<=$pagemax; $i++) {
if (!trim($todayshow[$i]))
continue;
list($inbbs['user'],$null1,$null2,$inbbs['rgtime'],$inbbs['logintime'],$inbbs['intime'],$inbbs['ip'],$inbbs['post'],$inbbs['rvrc'],$null)=explode("\t",$todayshow[$i]);
$inbbs['rawuser']=rawurlencode($inbbs['user']);
$inbbs['rvrc']=floor($inbbs['rvrc']/10);
$inbbs['rgtime']=get_date($inbbs['rgtime']);
$inbbs['logintime']=get_date($inbbs['logintime']);
$inbbs['intime']=get_date($inbbs['intime']);
if ($check_admin=="N")
{
$inbbs['ip']="secret";
}
$inbbsdb[]=$inbbs;
}
require_once PrintEot('todayinbbs');footer();
}elseif($action=='buytopic'){
$tpcs=$db->get_one("SELECT authorid,content FROM pw_threads t LEFT JOIN pw_tmsgs tm ON tm.tid=t.tid WHERE t.tid='$tid'");
$tpcs['content']=substr($tpcs['content'],strpos($tpcs['content'],'[sell=')+6);
$sellmoney=substr($tpcs['content'],0,strpos($tpcs['content'],']'));
$money=$winddb['money'];
if (empty($windid) || $winduid==$tpcs['authorid'] || $sellmoney>1000 || $sellmoney<0){
Showmsg('undefined_action');
}
if($sellmoney > 1000){
$sellmoney = 1000;
}
$money < $sellmoney && Showmsg('job_buy_noenough');
$rs=$db->get_one("SELECT buy FROM pw_tmsgs WHERE tid='$tid'");
if($rs['buy'] && strpos($rs['buy'].',',','.$windid.',')!==false){
Showmsg('job_havebuy');
}
$money=$money-$sellmoney;
$sellmoney>10 && $sellmoney=$sellmoney*0.9;
$db->update("UPDATE pw_memberdata SET money='$money' WHERE uid='$winduid'");
$db->update("UPDATE pw_memberdata SET money=money+'$sellmoney' WHERE uid='$tpcs[authorid]'");
$buy=$rs['buy'].",".$windid;
$db->update("UPDATE pw_tmsgs SET buy='".addslashes($buy)."' WHERE tid='$tid'");
refreshto("read.php?tid=$tid",'operate_success');
}elseif($votejop=='vote'){
require_once(R_P.'require/forum.php');
@extract($db->get_one("SELECT t.fid,t.tid,t.postdate,t.locked,t.ifcheck,p.voteopts FROM pw_polls p LEFT JOIN pw_threads t ON p.pollid=t.pollid WHERE p.pollid='$pollid'"));
/**
* 得到版块基本信息,版块权限验证
*/
$foruminfo=$db->get_one("SELECT name,f_type,style,password,allowvisit,forumadmin,allowhtm FROM pw_forums WHERE fid='$fid'");
if(!$foruminfo){
require_once(R_P.'require/url_error.php');
}
wind_forumcheck($foruminfo);
/*
* 获取管理权限
*/
if($windid==$manager || ($foruminfo['forumadmin'] && strpos($foruminfo['forumadmin'],','.$windid.',')!==false)){
$admincheck=1;
} else{
$admincheck=0;
}
/*
*用户组权限验证
*/
$gp_allowvote==0 && Showmsg('job_vote_right');
if(!$admincheck && $locked>0){
Showmsg('job_vote_lock');
}
$votearray = unserialize($voteopts);
if(!$voteaction){
foreach($votearray['options'] as $option){
if(@in_array($windid,$option[2])){
Showmsg('job_havevote');
}
}
}
if(empty($voteid)){
Showmsg('job_vote_sel');
}
if(count($voteid)>$votearray['multiple'][1]){
Showmsg('job_vote_num');
}
if($voteaction=='modify'){
if ($gp_edittime && ($timestamp-$postdate)>$gp_edittime){
Showmsg('modify_timelimit');
}
foreach($votearray['options'] as $key=>$option){
foreach($option[2] as $vid=>$value){
if($value==$windid){
$votearray['options'][$key][1]--;
unset($votearray['options'][$key][2][$vid]);
}
}
}
}
foreach($voteid as $id){
$votearray['options'][$id][1]++;
$votearray['options'][$id][2][]=$windid;
}
$voteopts = addslashes(serialize($votearray));
$db->update("UPDATE pw_polls SET voteopts='$voteopts' WHERE pollid='$pollid'");
$db->update("UPDATE pw_threads SET lastpost='$timestamp' WHERE tid='$tid'");
if($foruminfo['allowhtm']==1){
include_once R_P.'require/template.php';
}
empty($j_p) && $j_p="read.php?tid=$tid";
refreshto($j_p,'operate_success');
}
//elseif($s_user=='htm'){
//$
//}
function fseeks($fp,$dbtdsize,$seed){
$num=0;
while($break!=1 && $num<$seed){
$num++;
$sdata=fread($fp,$dbtdsize);
$sdb=explode("\t",$sdata);
$sdbnext=$sdb[2]*$dbtdsize;
if($sdbnext!='NULL'){
fseek($fp,$sdbnext,SEEK_SET);
}else{
$break=1;
}
$todayshow[]=$sdata;
}
return $todayshow;
}
?>
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?