1. 论坛系统升级为Xenforo,欢迎大家测试!
    排除公告

气功猪的下载系统,在PHP安全模式下,后台生成静态页出这个

本帖由 lane2006-06-20 发布。版面名称:后端开发

  1. lane

    lane New Member

    注册:
    2005-09-05
    帖子:
    6,548
    赞:
    29
    气功猪的下载系统,在PHP安全模式下,后台生成静态页出这个

    Warning: set_time_limit(): Cannot set time limit in safe mode in D:\www\phproot\down\admin\make.php on line 7

    请问如何修正?
     
  2. lane

    lane New Member

    注册:
    2005-09-05
    帖子:
    6,548
    赞:
    29
    把第7行去掉就没事了,会影响使用么?
    代码:
    set_time_limit(0);
     
  3. lane

    lane New Member

    注册:
    2005-09-05
    帖子:
    6,548
    赞:
    29
    make.php

    PHP:
    <?php
    // ========================== 文件说明 ==========================// 
    // 本文件说明:生成htm页
    // 作者:小猪会气功
    // =============================================================// 
    error_reporting(7);
    set_time_limit(0);
    // 加载后台函数集合
    require_once ("global.php");
    require_once (
    "inc/make_inc.php");
    cpheader();
    //生成软件页
    if($_GET['action'] == "soft"){
        if (!empty(
    $_GET['softid'])){
            
    $row $DB->fetch_one_array("SELECT * FROM ".$db_prefix."down WHERE softid='".intval($softid)."'");
            
    $MK->makesoft($row['softid'],$row['pid'],$row['sortid'],$row['title'],$row['author'],$row['img'],$row['empower'],$row['os'],$row['grade'],$row['homepage'],$row['demo'],$row['intro'],$row['size'],$row['addtime'],$row['view'],$row['down'],$row['iscommend'],$row['ishtml']);
            
    redirect("生成".$configuration[htmldir]."/".$softid.".html成功!""javascript:history.go(-1);");
        }
        !
    $d && $d=0;
        !
    $step && $step=1;
        !
    $percount && $percount=100;
        
    $sstart=($step-1)*$percount;
        
    $next=$sstart+$percount;
        
    $step++;
        
    $goon=0;
        if (!empty(
    $_GET['sortid'])){
            
    $maketype "WHERE sortid='".$sortid."' and visible='1'";
        } else {
            
    $maketype "WHERE visible='1'";
        }
        if (
    $_GET['type']=="date"){
            
    $Ddate $Ddaymktime (00,,$Dmonth$Dday,$Dyear):mktime (00,,$Dmonth1,$Dyear);
            
    $Ddate1 $Ddaymktime (00,,$Dmonth$Dday+1,$Dyear):mktime (00,,$Dmonth+11,$Dyear);
            
    $maketype "WHERE addtime>'".$Ddate."' and addtime<'".$Ddate1."' and visible='1'";
        }
        
    $softs="SELECT softid FROM ".$db_prefix."down $maketype";
        
    $maketotal=$DB->num_rows($DB->query($softs));
        if(
    $new 0$maketotal=$new;
        
    $makefile $DB->query("SELECT * FROM ".$db_prefix."down $maketype order by softid desc LIMIT $sstart,$percount");
        if(
    $maketotal $next){
            
    $next=$maketotal;
        }
        
    $i=0;
        while (
    $row=$DB->fetch_array($makefile)) 
        {
            
    $i++;
            if((
    $i+$sstart) <= $maketotal && $row['softid']) {
           
    $goon=1;
    $MK->makesoft($row['softid'],$row['pid'],$row['sortid'],$row['title'],$row['author'],$row['img'],$row['empower'],$row['os'],$row['grade'],$row['homepage'],$row['demo'],$row['intro'],$row['size'],$row['addtime'],$row['view'],$row['down'],$row['iscommend'],$row['ishtml']);          
            }
        }
        
    $db=debuginfo();
        
    $ds=$db+$d;
        if(
    $goon){
    $jumpurl="make.php?action=soft&type=$type&Dyear=$Dyear&Dmonth=$Dmonth&Dday=$Dday&sortid=$sortid&new=$new&step=$step&percount=$percount&d=$ds";
            echo 
    "<font color=red><b>正在生成软件的Html页,请等待......</b></font><br><br>";
            echo 
    "正在生成(".$sstart."-".$next.")个页面&nbsp;&nbsp;&nbsp;&nbsp;共<font color=red><b>$maketotal</b></font> 个";
            echo 
    "<META HTTP-EQUIV='Refresh' CONTENT='0; URL=$jumpurl'>";
        } else {
            echo 
    "<b>操作成功!共生成<font color=red>".$maketotal."</font>个页面! 总费时<font color=red>".$d."</font>秒 <a href=./soft.php?action=makehtml>[返回]</a></b>";
        }

    }
    //生成软件页结束
    //生成分类页
    if($_GET['action'] == "sort"){
        
    $sortid=$_GET['sortid'];
        !
    $step && $step=0;
        !
    $d && $d=time();
        
    $goon=0;
        if (!empty(
    $_GET['sortid'])){
            
    $maketype "WHERE sortid='$sortid'";
        }
        else
        {
            
    $maketype "order by sortid LIMIT $step,1";
            
    $makesorts="SELECT * FROM ".$db_prefix."sort";
            
    $maketotal=$DB->num_rows($DB->query($makesorts));
        }
        
    $makefile $DB->query("SELECT * FROM ".$db_prefix."sort $maketype");
        while (
    $row=$DB->fetch_array($makefile)) 
        {
            
    $sid=$row['sortid'];
            if (
    $row['parentid']=='0'){
              
    $type "WHERE pid = '$sid' or sortid = '$sid' and visible='1'";
            } else {
              
    $type "WHERE sortid = '$sid' and visible='1'";
            }
            
    $pagequery="SELECT * FROM ".$db_prefix."down $type";
            
    $total=$DB->num_rows($DB->query($pagequery));
            
    $show  =  $configuration[softnum];  
            
    $totalPage  =  ceil($total/$show);
            if (
    $totalPage=="0"$totalPage="1";
            if(!
    $row['sortid'])continue;
            
    $goon=1;
         echo 
    "<span id=showImport></span><IE:Download ID=\"oDownload\" STYLE=\"behavior:url(#default#download)\">";
            for (
    $i 1;$i<=$totalPage$i++){
    echo 
    "<script>function onDownloadDone(downDate){showImport.innerHTML=downDate}oDownload.startDownload('makesort.php?total=".$total."&pid=".$row['parentid']."&sortid=".$row['sortid']."&i=".$i."',onDownloadDone)</script>";
            }
        }
        
    cpheader();
        if (!empty(
    $_GET['sortid']))
        {
            echo 
    "<b>生成该分类页成功!共<font color=red>".($i-1)."</font>个页面! <a href=./soft.php?action=makehtml>[返回]</a></b>";
            exit;
        }
        
    $step++;
        
    $page=$page+$i-1;
        if(
    $goon){
            
    $jumpurl="make.php?action=sort&sortid=$sortid&step=$step&page=$page&d=$d";
            echo 
    "<font color=red><b>正在生成分类列表Html页,请等待......</b></font><br><br>";
            echo 
    "(".($i-1)."页)<b><font color=red>".$step."</font>/<font color=red>".$maketotal."</font><b>";
            echo 
    "<META HTTP-EQUIV='Refresh' CONTENT='0; URL=$jumpurl'>";
        } else {
            echo 
    "<b>操作成功!共生成分类<font color=red>".$maketotal."</font>个,页面<font color=red>".($page+1)."</font>个,总费时<font color=red>".(time()-$d)."</font>秒 <a href=./soft.php?action=makehtml>[返回]</a></b>";
        }
    }
    //生成首页
    if($_GET['action'] == "index"){
        
    $MK->makeindex();
        
    redirect("生成index.html成功""./soft.php?action=makehtml");
    }
    //生成热门软件JS
    if($_POST['action'] == "hot"){
        
    $content $_POST['content'];
        
    $jstemplate "../templates/".$configuration[template]."/hot.html";
        @
    write_file($jstemplate,$content); 
        if (!
    $MK->makejs(""$content,"hot")) echo "生成../hot_js/hot.js失败!";
        
    $query $DB->query("SELECT sortid FROM ".$db_prefix."sort");
        while (
    $row=$DB->fetch_array($query)) 
        {
            if (!
    $MK->makejs($row['sortid'], $content"hot")) echo "生成../hot_js/hot_".$row['sortid'].".js失败!";
        }
        
    redirect("生成热门软件js成功""./soft.php?action=makejs");
    }
    //生成推荐软件JS
    if($_POST['action'] == "commend"){
        
    $content $_POST['content'];
        
    $jstemplate "../templates/".$configuration[template]."/commend.html";
        @
    write_file($jstemplate,$content); 
        if (!
    $MK->makejs(""$content,"commend")) echo "生成../commend_js/commend.js失败!";
        
    $query $DB->query("SELECT sortid FROM ".$db_prefix."sort");
        while (
    $row=$DB->fetch_array($query)) 
        {
            if (!
    $MK->makejs($row['sortid'], $content"commend")) echo "生成../commend_js/commend_".$row['sortid'].".js失败!";
        }
        
    redirect("生成推荐软件js成功""./soft.php?action=makejs");
    }
    ?>
     
  4. 小叶

    小叶 New Member

    注册:
    2005-09-04
    帖子:
    17,941
    赞:
    33
    试试就知道可以不.
     
  5. yeshou

    yeshou New Member

    注册:
    2005-09-06
    帖子:
    7,067
    赞:
    34
    安全模式下set_time_limit()无效的 两个方法 关闭安全模式 或直接修改php.ini

    限制最大执行时间的 一般情况下没问题