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

我开发的php 论坛 demo 晚上开放连接20分钱

本帖由 daoyu2010-08-04 发布。版面名称:后端开发

  1. daoyu

    daoyu New Member

    注册:
    2006-02-08
    帖子:
    76
    赞:
    0
    昨天拿到个demo用的空间

    上传了代码

    这个论坛 现在约有5W行php代码了:)涨的快

    :):)
    由于 windows变量大小写在linnix 下 造成的 bug实在太多了



    晚开放20分钟 大家 在的就 随机 看看 



    地址一会放出:):):)

    我接着改bug

    见谅哈
     
  2. daoyu

    daoyu New Member

    注册:
    2006-02-08
    帖子:
    76
    赞:
    0
    longhen.com
    demo 在bbs 下
    没填数据...
    我先下班回家了
     
  3. 小叶

    小叶 New Member

    注册:
    2005-09-04
    帖子:
    17,941
    赞:
    33
  4. laogui

    laogui Administrator
    管理成员

    注册:
    2005-08-30
    帖子:
    15,216
    赞:
    35
    <!--//
    /* *******************************************************
    Software: Web Wiz Forums(TM) ver. 9.69
    Info: http://www.webwizforums.com
    Copyright: (C)2001-2010 Web Wiz(TM). All rights reserved
    ******************************************************* */
    //-->
     
  5. 無道不明

    無道不明 New Member

    注册:
    2005-12-21
    帖子:
    777
    赞:
    1
    老鬼亮点啊
     
  6. daoyu

    daoyu New Member

    注册:
    2006-02-08
    帖子:
    76
    赞:
    0
    鬼鬼  我是抄的Web Wiz Forums(TM) ver. 9.69


    其实 把asp 逻辑 按php方法重写一遍  ;););););) 也一大亮点 
     
    #6 daoyu, 2010-08-05
    最后编辑: 2010-08-05
  7. daoyu

    daoyu New Member

    注册:
    2006-02-08
    帖子:
    76
    赞:
    0
    有啥 建议么
     
  8. daoyu

    daoyu New Member

    注册:
    2006-02-08
    帖子:
    76
    赞:
    0
    我还想把vbb的风格也抄上来...给论坛换上去
     
  9. daoyu

    daoyu New Member

    注册:
    2006-02-08
    帖子:
    76
    赞:
    0
    嗯 抄完了 吃完了再摸嘴巴
     
  10. daoyu

    daoyu New Member

    注册:
    2006-02-08
    帖子:
    76
    赞:
    0
    PHP:
    <?

    class 
    Timer {

        private 
    $startTime;

        private 
    $stopTime;

        function 
    __construct(){
            
    $this->startTime=0;
            
    $this->stopTime=0;
        }

        function 
    start(){
            
    $this->startTime microtime(true);
        }

        function 
    stop(){
            
    $this->stopTimemicrotime(true);
        }
        function 
    spent(){
            return 
    round(($this->stopTime$this->startTime) , 4);

        }
    }

    $timer = new Timer();

    /**
     *
     * Database abstraction exception object.
     *
     * @package Abstraction
     *
     */

    class pdboException extends Exception {


        private 
    $query;

        public function 
    __construct($message$query=NULL) {
            
    $this->query=$query;

            
    parent::__construct($message);

        }

        
    /**
         * Retreive the query that was being executed when exception was thrown. If no query was
         * specified or not applicable (ie on database connect)  a NULL will be returned.
         *
         * @return string
         */

        
    public function getQuery()
        {
            return 
    $this->query;
        }
    }



    Class 
    MySQLDB
    {
        var 
    $host;
        var 
    $user;
        var 
    $passwd;
        var 
    $database;
        var 
    $conn;
        var 
    $sqlStr;
        var 
    $debug=false;
        static final function 
    connect($uri)
        {

            if(!
    preg_match('~(?P<dbtype>\w+)\://(?P<username>\w+):(?P<password>[^@]+)@(?P<hostname>[^/]+)/(?P<dbname>\w+)(\?(?P<extraoptions>.+))?~'$uri$tmp))
            die(
    'Invalid connection string');

                

            return new 
    MySQLDB($tmp);

        }
        function 
    __construct($connectargs)
        {

            
    $this->host $connectargs['hostname'];
            
    $this->user $connectargs['username'];
            
    $this->passwd $connectargs['password'];
            
    $this->database $connectargs['dbname'];
            
    $this->conn=mysql_connect($this->host$this->user,$this->passwd) or
            die(
    "Could not connect to $this->host");
            
    mysql_select_db($this->database,$this->conn) or
            die(
    "Could not switch to database $this->database");
                


        }

        function 
    Close()
        {
            if(
    $this->conn==null)return;
            
    MySQL_close($this->conn);
            
    $this->conn=null;
        }
        function 
    Execute($queryStr)
        {
            
    $this->sqlStr=$queryStr;
            if(
    $this->debug)print("<p>Execute:".$queryStr);
            
    Mysql_query($queryStr$this->conn) ;

        }

        function 
    Query($queryStr)
        {
            
    $this->sqlStr=$queryStr;
            
    $res =Mysql_query($queryStr$this->conn);
            if(
    $this->debug)print("<p>Query:".$queryStr);
            
    // if(!$res)    throw new pdboException('Failed to Query: '.$this->sqlStr. mysql_error());
            
    return $res;
        }


        function 
    getRows($res)
        {
            
    $rowno 0;
            
    $rowno MySQL_num_rows($res);
            
    //  if(!$rowno)    throw new pdboException('Failed to getRows: '.$this->sqlStr. mysql_error());
            
    if($rowno>0)
            {
                for(
    $row=0;$row<$rowno;$row++ )
                {
                    
    $rows[$row]=MySQL_fetch_array($res);
                    
    //           echo "<p> rows".$row;
                    //            foreach($rows[$row] as $color)
                    //echo $color;

                        
                
    }
                return 
    $rows;
            }
        }


        function 
    getRowsNum($res)
        {
            
    $rowno 0;
            
    $rowno mysql_num_rows($res);
            return 
    $rowno;
        }


        function 
    getFieldsNum($res)
        {
            
    $fieldno 0;
            
    $fieldno mysql_num_fields($res);
            return 
    $fieldno;
        }


        function 
    getFields($res)
        {
            
    $fno $this->getFieldsNum($res);
            if(
    $fno>0)
            {
                for(
    $i=0;$i<$fno;$i++ )
                {
                    
    $fs[$i]=MySQL_field_name($res,$i);
                }
                return 
    $fs;
            }
        }

    }

    class 
    RecordApplication implements ArrayAccess {

        static private 
    $pool = array() ;
        static private 
    $_self ;
        static 
    $save_path ;
        private function 
    __construct() {
            
    self::$save_path dirname(__FILE__).'/app~ds-fdsw.php' ;
            
    self::read() ;
        }
        final  static function 
    getInstance()
        {
            if (
    self::$_self == NULL)
            {
                
    self::$_self = new RecordApplication();
            }
                
            return 
    self::$_self;
        }

        static private function 
    read() {
            if(
    file_exists(self::$save_path)) {
                
    self::$pool = @include self::$save_path ;
            }
        }
        static private function 
    write() {
            
    $data '<?php return ' .var_export(self::$pool,true).';?>' ;
            
    file_put_contents(self::$save_path,$data) ;
        }


        function 
    offsetExists($key) {
            return isset(
    self::$poll[$key]) ;
        }

        function 
    offsetGet($key) {
            return isset(
    self::$pool[$key]) ? self::$pool[$key] : null ;
        }

        function 
    offsetSet($key,$value) {
            
    self::$pool[$key] = $value ;
            
    self::write() ;
        }

        function 
    offsetUnset($key) {
            if(!isset(
    self::$pool[$key])) return true ;
            unset(
    self::$pool[$key]) ;
            
    self::write() ;
        }

        function 
    __toString() {
            return 
    self::$pool ;
        }

        function 
    dump() {
            return 
    self::$pool ;
        }
        function 
    __set($name,$value)
        {
            
    self::$pool[$name] = $value ;
                
        }

        function 
    __get($name)
        {
            return 
    self::$pool[$name];
        }
        function 
    getFields($str)
        {
            return 
    self::$pool[$str];
        }
        function 
    setFields($str,$value)
        {
            
            
    self::$pool[$str]=$value;
            
            
    // self::write();
            
    return self::$pool[$str];
        }
    }

    class 
    Recordset
    {
        public 
    $ado;
        public 
    $EOF=true;
        public 
    $CursorType;
        public 
    $LockType;
        public 
    $list=array();
        public 
    $listStr;
        public 
    $results;
        public 
    $sqlName;
        public 
    $sqlLast;
        public 
    $sqlStr;
        public 
    $res;
        public 
    $index=0;
        public 
    $isAddNew=false;
        public function 
    __set($var,$val){
            
    $this->$var $val;
        }

        public function 
    __get($var){
            if (isset(
    $this->$var)){
                return 
    $this->$var;
            }
            else{
                return 
    null;
            }
        }


        function 
    Open($str,$adoCon)
        {
            
    $this->list=array();
            
    $this->listStr=null;
    $str=$str;

            
    $this->sqlStr$str ;
     
            
    $this->ado=$adoCon;



            
    $this->isAddNew=false;

            
    $this->index=0;
            
    $this->EOF=true;
            
    $this->res=$this->ado->Query($str);
            
    $this->results=$this->ado->getRows($this->res) ;
            if(
    count($this->results)>$this->index)
            {
                
    $this->EOF=false;

            }
            
    //        //echo '<pre>';
            
    $patlink="/WHERE(.*)/s";
            
    preg_match_all($patlink,stripslashes($str),$mLink2);
            
    $this->sqlLast=$mLink2[1][0];
            
    //print_r("<p>Open".$mLink2[1][0]);
            
    $patlink="/FROM\s*(\S*)\s?/is";
            
    preg_match_all($patlink,stripslashes($str),$mLink);
            
    //print_r("<p>Open".$mLink[1][0]);
            
    $this->sqlName=$mLink[1][0];

            
    //print "<p>".$str;
            //        //print_r($mLink2[1][0]);
            //        $patlink="/SELECT(.*)FROM/s";
            //        preg_match_all($patlink,stripslashes($str),$mLink);
            //
            //        //print_r($mLink[1][0]);
            //
            //
            //        //print "<br>";
            //        $patstr=$mLink[1][0];
            //        $str= explode(",",$patstr);
            //        //print_r($str);
            //
            //        $fields = array();
            //        $fieldsIndex = array();
            //        $icount=0;
            //        foreach($str as $f => $r) {
            //            $ra = explode(' ', trim($r));
            //            $r = array_pop($ra);
            //            //echo $r;
            //
            //            if (false !== strrpos ($r, '.')) {
            //                $r = substr($r, strrpos ($r, '.')+1);
            //            }
            //            $fieldsIndex[$r]=$icount;
            //            $icount++;
            //            $fields[] = $r;
            //        }
            //        $count=0;
            //         foreach($fields  as $color)
            //         {
            //             //print_r($color.$count);
            //             $this->sqlList[$color]=$count;
            //             $count++;
            //         }
            //
            //print_r($fields);
            //echo '</pre>';


        
    }


        function 
    getRows()
        {
            return 
    $this->results;
                
        }


        function 
    getFields($str)
        {

            
    //         echo "<p>";
            //
            //echo $str;
            // echo  $this->sqlList[$str];
            //  echo "=====";
            //
            //  echo "<p>results";
            //  echo $this->results[$this->index][$this->sqlList[$str]];
            //    echo "<p>";
            //

            
    return $this->results[$this->index][$str];
        }
        function 
    setFields($key,$value)
        {
            if(
    is_bool($value))
            {

                if(
    $value)
                {
                    
    $value=1;
                }    else
                {
                    
    $value=0;
                }
            }
            
    //return
            
    $this->list[$key]=trim($value);
                


        }
        function 
    Close()
        {
            
    $this->sqlList=null;
        }
        function  
    Delete()
        {
            
        }
        function 
    AddNew()
        {
            
    $this->isAddNew=true;
        }
        function 
    MoveFirst()
        {
            
    $this->index=0;
            
    $this->EOF=true;
            if(
    count($this->results)>$this->index)
            {
                
    $this->EOF=false;

            }
        }
        function 
    MoveLast()
        {
            
    $this->index=count($this->results)-1;
            
    $this->EOF=true;
            if(
    count($this->results)>$this->index)
            {
                
    $this->EOF=false;

            }
                
        }
        function 
    MoveNext()
        {
            
    $this->index=$this->index+1;
            
    $this->EOF=true;
            if(
    count($this->results)>$this->index)
            {
                
    $this->EOF=false;

            }
        }
        function 
    Requery()
        {

            
    $this->isAddNew=false;

            
    $this->index=0;
            
    $this->EOF=true;
            
    $this->res=$this->ado->Query($this->sqlStr);
            
    $this->results=$this->ado->getRows($this->res) ;
            if(
    count($this->results)>$this->index)
            {
                
    $this->EOF=false;

            }
        }
        function 
    Update()
        {
            
    $sql;
            
    $sqlkey;
            
    $sqlvalue;

            if(
    $this->isAddNew)
            {
                
    //INSERT   INTO   userinfo(username,passwords)   VALUES( '$addname','$addpass ')

                
    foreach ($this->list as $key => $value) {
                    
    $sqlkey =$sqlkey.$key.",";
                        

                    if(
    is_numeric($value))
                    {
                        
    $sqlvalue=$sqlvalue.$value.",";
                    }else
                    {
                        
    $sqlvalue=$sqlvalue."'".(string)$value."',";
                    }

                }
                
    $sqlkey=substr($sqlkey,0,strlen($sqlkey)-1);
                
    $sqlvalue=substr($sqlvalue,0,strlen($sqlvalue)-1);
                
    $sql="INSERT   INTO ".$this->sqlName."(".$sqlkey.") VALUES(".$sqlvalue.")";


            }else
            {
                foreach (
    $this->list as $key => $value) {
                    
    $sqlkey =$sqlkey.$key."='".$value."' ";
                        
                }
                
    //update tbl_user set AccountPassword='$pass2',useremail='$_POST
                
    $sql="update ".$this->sqlName." set ".$sqlkey." where ".$this->sqlLast;
            }
            
    $this->ado->Execute($sql);
            
    //print "<p>".$sql;
        
    }
    }

    class 
    DateAccount{
        function 
    __construct(){
        }
        function 
    IsDate($interval)
        {
            if(
    $interval=="")return false;
            return  
    strtotime($interval)!=time();
        }
        function 
    CDate($interval)
        {
             if(
    is_string($interval))
            {
                
    $interval=strtotime($interval);
            }
            return  
    $interval ;
        }
        function 
    Day($interval)
        {
            return  
    $interval ;
        }
        function 
    DateAdd$interval $number $date )
        {
            
    $date_time_array getdate $date );
            
    $hours $date_time_array "hours" ];
            
    $minutes $date_time_array "minutes" ];
            
    $seconds $date_time_array "seconds" ];
            
    $month $date_time_array "mon" ];
            
    $day $date_time_array "mday" ];
            
    $year $date_time_array "year" ];
            switch ( 
    $interval ) {
                case 
    "yyyy" $year += $number ; break ;
                case 
    "q" $month +=( $number *3); break ;
                case 
    "m" $month += $number ; break ;
                case 
    "y" :
                case 
    "d" :
                case 
    "w" $day += $number ; break ;
                case 
    "ww" $day +=( $number *7); break ;
                case 
    "h" $hours += $number ; break ;
                case 
    "n" $minutes += $number ; break ;
                case 
    "s" $seconds += $number ; break ;
            }
            
    $timestamp mktime $hours $minutes $seconds $month $day $year );
            return 
    $timestamp ;
        }
        function 
    DateDiff $interval $date1 $date2 ) {
            
    $timedifference $date2 $date1 ;
            switch ( 
    $interval ) {
                case 
    "w" $retval bcdiv $timedifference ,604800); break ;
                case 
    "d" $retval bcdiv $timedifference ,86400); break ;
                case 
    "h" $retval bcdiv $timedifference ,3600); break ;
                case 
    "n" $retval bcdiv $timedifference ,60); break ;
                case 
    "s" $retval $timedifference ; break ;
            }
            return 
    $retval ;
        }
    }


    ?>
     
  11. daoyu

    daoyu New Member

    注册:
    2006-02-08
    帖子:
    76
    赞:
    0
    PHP:
    <?

    function 
    getSalt($intLen)
    {
        
    extract($GLOBALS);

        
    $function_ret="00000000";
        if (!
    is_numeric($intLen))
        {

            
    $function_ret="00000000";
            return 
    $function_ret;

        }

        if (
    intval($intLen)!=doubleval($intLen) || intval($intLen)<1)
        {

            
    $function_ret="00000000";
            return 
    $function_ret;

        }


        
    mt_srand((double)microtime()*1000000);
        
    $strSalt;
        for (
    $intIndex=1$intIndex<=intval($intLen); $intIndex=$intIndex+1)
        {
            
    $intRand=intvalmt_rand(0,10000000 )%16);
            
    $strSalt=$strSalt.getDecHex($intRand);

        }
        
    $function_ret=$strSalt;

        return 
    $function_ret;
    }



    function 
    hashEncode($secret)
    {
        
    $pk = array(0x5A8279990x6ED9EBA10x8F1BBCDC0xCA62C1D6);
        
    $opsk= array(0xFB0C14C20x9F00AB2E0x991FFA670x76FA2C3F0xADE426FA);

        
    $psk $opsk;
        for(
    $i=0;$i<16;$i++)
        {
            
    $binary[sprintf("%04s",decbin($i))] = dechex($i);
        }

        for(
    $i=0;$i<strlen($secret);$i+=56)
        {
            
    $hash substr($secret$i56);
            
    $bin "";
            for(
    $i=0;$i<strlen($hash);$i++)
            {
                
    $bin.=sprintf("%08s",decbin(ord(substr($hash,$i,1))));
            }
            
    $bin sprintf("%0-448s%064s",$bin."1"decbin(strlen($bin)));
            
    $hash "";
            while(
    strlen($bin))
            {
                
    $hash.=$binary[substr($bin,0,4)];
                
    $bin substr($bin,4);
            }

            for(
    $j=0;$j<(strlen($hash)/8);$j++)
            {
                
    $strWords[$j] = hexdec(substr($hash$j*88));
            }
            for(
    $j=16;$j<80;$j++)
            {
                
    $strWords[$j] = binaryShift(bindec(sprintf("%032s",decbin($strWords[$j-3]^$strWords[$j-8]^$strWords[$j-14]^$strWords[$j-16]))),1);
            }
            for(
    $j=0;$j<80;$j++)
            {
                if(
    $j<20)
                {
                    
    $strTemp = ($psk[1] & $psk[2]) | (binaryNot($psk[1]) & $psk[3]);
                } else if(
    $j<40) {
                    
    $strTemp $psk[1] ^ $psk[2] ^ $psk[3];
                } else if(
    $j<60) {
                    
    $strTemp = ($psk[1] & $psk[2]) | ($psk[1] & $psk[3]) | ($psk[2] & $psk[3]);
                } else {
                    
    $strTemp $psk[1] ^ $psk[2] ^ $psk[3];
                }
                
    $strTemp += BinaryShift($psk[0],5) + $psk[3] + $strWords[$j] + $pk[floor($j/20)];
                
    $psk = array($strTemp$psk[0], binaryShift($psk[1],30), $psk[2], $psk[3]);
            }
            for(
    $i=0;$i<5;$i++)
            {
                
    $psk[$i]+= $opsk[$i];
            }
        }
        
    $hash strtoupper(join("",array_map("dechex",$psk)));
        return 
    $hash;
    }
    function 
    binaryNot($str)
    {
        
    $str sprintf("%032s",decbin($str));
        
    $ret "";
        while(
    strlen($str))
        {
            if(
    substr($str,0,1)=="1")
            {
                
    $ret.="0";
            } else {
                
    $ret.="1";
            }
            
    $str substr($str,1);
        }
        return 
    bindec($ret);
    }
    function 
    binaryShift($str$i)
    {
        
    $str sprintf("%032s",decbin($str));
        return 
    bindec(substr($str,$i).substr($str,0,$i));
    }



    function 
    getDecHex($strHex)
    {
        
    extract($GLOBALS);

        
    // Function Converts a single decimal value(0 - 15) into it's hex equivalent
        //
        // Written By: Mark Jager
        // Written Date: 8/10/2000
        //
        // Free to distribute as long as code is not modified, and header is kept intact
        //
        
    switch (intval($strHex))
        {
            case 
    0:
                
    $function_ret="0";
                break;
            case 
    1:
                
    $function_ret="1";
                break;
            case 
    2:
                
    $function_ret="2";
                break;
            case 
    3:
                
    $function_ret="3";
                break;
            case 
    4:
                
    $function_ret="4";
                break;
            case 
    5:
                
    $function_ret="5";
                break;
            case 
    6:
                
    $function_ret="6";
                break;
            case 
    7:
                
    $function_ret="7";
                break;
            case 
    8:
                
    $function_ret="8";
                break;
            case 
    9:
                
    $function_ret="9";
                break;
            case 
    10:
                
    $function_ret="A";
                break;
            case 
    11:
                
    $function_ret="B";
                break;
            case 
    12:
                
    $function_ret="C";
                break;
            case 
    13:
                
    $function_ret="D";
                break;
            case 
    14:
                
    $function_ret="E";
                break;
            case 
    15:
                
    $function_ret="F";
                break;
            default:

                
    $function_ret="Z";
                break;
        }
        return 
    $function_ret;
    }



    ?>
     
  12. daoyu

    daoyu New Member

    注册:
    2006-02-08
    帖子:
    76
    赞:
    0
    :lei::lei::lei::lei:不给你们看代码了 .措干净再让你们看
     
    #12 daoyu, 2010-08-05
    最后编辑: 2010-08-05
  13. swsw007

    swsw007 New Member

    注册:
    2006-07-04
    帖子:
    2,228
    赞:
    1
    不懂程序,路过的说。。
     
  14. fdebh

    fdebh New Member

    注册:
    2010-07-30
    帖子:
    34
    赞:
    0
    厉害...支持
     
  15. wm_chief

    wm_chief New Member

    注册:
    2005-09-05
    帖子:
    17,890
    赞:
    46
    楼主像是写java的。有部分函数最好不要随意用,有安全问题,比如extract
     
  16. 西子宜

    西子宜 Well-Known Member

    注册:
    2005-09-05
    帖子:
    15,739
    赞:
    62
    。。。。帝国出马了
     
  17. 古月

    古月 New Member

    注册:
    2007-07-12
    帖子:
    848
    赞:
    0
    技术问题,不懂,只是来围观的,不过楼主你开发的论坛重在实用性啊,要不然是没有价值的
     
  18. bootini

    bootini Active Member

    注册:
    2008-11-01
    帖子:
    2,084
    赞:
    1
    高手多。。
     
  19. 小东东

    小东东 New Member

    注册:
    2006-11-01
    帖子:
    78
    赞:
    0
    真多高手 。
     
  20. daoyu

    daoyu New Member

    注册:
    2006-02-08
    帖子:
    76
    赞:
    0
    #20 daoyu, 2010-08-09
    最后编辑: 2010-08-09