⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 user.class.php

📁 网络硬盘_支持1GB文件上传和续传_无错版
💻 PHP
📖 第 1 页 / 共 2 页
字号:
<?php
/*
+--------------------------------------------------------------------------
|   Mega File Hosting Script v1.2
|   ========================================
|   by Stephen Yabziz
|   (c) 2005-2006 YABSoft Services
|   http://www.yabsoft.com
|   ========================================
|   Web: http://www.yabsoft.com
|   Email: ywyhnchina@163.com
+--------------------------------------------------------------------------
|
|   > Script written by Stephen Yabziz
|   > Date started: 1th March 2006
+--------------------------------------------------------------------------
*/
/**
* @package MFHS
* User class
*/
$DATASTORE       = array();
class user {
	/** basic infomation */
    var $uid         = 0;
    var $last_click  = 0;
    var $running_type= 'cookie';
    var $sess_id     = null;
    var $sess_timeout= 3600;
    var $username    = 'Guest';
    var $email       = '';
    var $reg_date    = 0;
    var $last_login  = 0;
    var $logined     = 0;

    /**system setting*/
    var $setting=array();

    /**host package infomation*/
    var $package             = '';
    var $package_id          = 0;
    var $account_expired     = false;
    var $account_expire_date = 0;
    var $server_id           = 0;
    /**1:Active,0:Unconfirmed,-1:Suspended*/
    var $account_status      = 0;

    /**limition on user! */
    var $allowed_filetypes   = array();
    var $disabled_filetypes  = array();
    var $allowed_filesize    = 0;
    var $max_uploads         = 1;
    var $webspace            = 0;
    var $hosted_files        = 0;
    
    /**download options*/
    var $dl_resume       = 0;
    var $dl_speed        = 100;
    var $dl_threads      = 0;
    var $dl_password     = 0;
    var $dl_waittime     = 30;
    var $dl_timeout      = 0;
    var $dl_captcha      = 1;

    /**what user can do!*/
    var $upload_method   = array('can_formupload','can_ftpupload','can_urlupload','can_flashupload');
    var $can_formupload  = 1;
    var $can_urlupload   = 1;
    var $can_ftpupload   = 1;
    var $can_flashupload = 1;

    /**upload url*/
    var $php_upload_url  = '';
    var $cgi_upload_url  = '';
    var $swf_upload_url  = '';
    var $upload_mode     = 0;
    var $servers         = array();
    var $upload_servers  = array();

    /**package list preload*/
    var $groups          = array();
    var $guest_group     = array();
    var $USER            = array();
  	/**
	* user object constructor
	*/
	function user($type='cookie')
    {
    global $db;
        $this->running_type=$type;
        #no valid sess_id stored,create new one for visitor
        if(strlen($this->sess_id = $this->getValue('sess_id'))!=32)
        {
            $this->newSession();
        }

        #load site setting
        $this->setting=$this->loadSetting();

        #checking the banned ips
        if($this->isBanedByIP())
        {
            die("baned by ip!");
        }

        #if logged
        if($this->getValue('logined')==1)
        {
            $nowtime=time();
            $timediff=$nowtime-$this->getValue('last_click');

            $this->uid=intval($this->getValue('uid'));
            if(($timediff>$this->sess_timeout||!$this->uid)&&$this->getValue('autologin')==0)
            {
                $this->uid     = 0;
                $this->logined = 0;
            }
            else
            {
                # last update or visit
                if($timediff>$this->sess_timeout)
                {
                    $db->setQuery("update users set last_login='$nowtime' where id='$this->uid' limit 1");
                    $db->query();
                }
                # check against the user table to confirm user exists
                if($this->uid)
                {
                    $db->setQuery("select * from users where id='$this->uid' limit 1");
                    $db->query();
                    $this->USER=$db->loadRow();
                }
                if(is_array($this->USER))
                {
                    $checked=1;
                    # is auto login?
                    if($this->getValue('autologin')==1)
                    {
                        # pass hash doesn't match!
                        if(md5($this->USER[pass])!=$this->getValue('passhash'))
                        {
                            $checked=0;
                            $this->uid       = 0;
                            $this->logined   = 0;
                            $this->autologin = 0;
                        }
                        else
                        {
                            $this->autologin = 1;
                        }
                    }
                    else
                    {
                        $this->autologin = 0;
                    }
                   
                    if($checked)
                    {
                        $this->logined   = 1;
                        $this->setValue('passhash',md5($this->USER[pass]));
                    }
                }
                else
                {
                    $this->uid     = 0;
                    $this->logined = 0;
                }
            }
        }
        else
        {
            $this->uid     = 0;
            $this->logined = 0;
        }
        # set value
        $this->setValue('logined',$this->logined);
        $this->setValue('uid',$this->uid);
        $this->setValue('last_click',time());
	}
    /**
	* create a new session id
    * @return void
	*/
    function newSession()
    {
        $seed = md5(microtime());
        $this->setValue('sess_id',$seed);
        $this->sess_id = $seed;
    }
    /**
	* init user:guest or member
    * @return void
	*/
	function initiate()
    {
        global $db,$input,$template,$baseWeb,$LANG,$DATASTORE;
        if(!is_array($DATASTORE[groups]))
        {
           # grab all groups for future use
            $db->setQuery("select * from groups");
            $db->query();
            $this->groups=$groups=$db->loadRowList('id');
           
            # store data
            $DATASTORE[groups]  = $groups;
        }
        else
        {
            $this->groups=$groups=$DATASTORE[groups];
        }
        
        # expired package for expired users
        $this->expired_group=$groups[$this->setting[expired_package]];
        
        # initiate a group for guest use
        $this->guest_group=$groups[1];
        foreach($groups as $row)
        {
            if($row[guest]==1) {$this->guest_group=$row;break;}
        }

        # logined?
        if($this->uid)
        {
            $USER=$this->USER;
            $old_group=$groups[$USER['gid']];
            $account_expired = $USER[expire_date]>time()||$old_group[subscr_fee]==''?false:true;
            $group = $account_expired ? $this->expired_group : $old_group;
            # custom group?overide the normal group
            $custom_group = $USER[custom]=='yes' ?unserialize($USER[data]):$group;
            if(is_array($custom_group))$group = array_merge($group,$custom_group);
        }
        else
        {
            $group=$this->guest_group;
            $USER=$this->USER=array('user'=>'Guest','email'=>'','regdate'=>time());
        }
        # format user data
        $this->username             = $USER[user];
        $this->email                = $USER[email];
        $this->reg_date             = $USER[regdate];
        $this->last_login           = $USER[last_login];
        $this->last_update          = $USER[last_update];
        $this->hosted_files         = $USER[files];
        $this->total_downloads      = $USER[totaldownloads];
        $this->total_points         = $USER[totalpoints];
       
        # upload setting
        $this->allowed_filetypes    = $group[allowed_filetype]?split(',',$group[allowed_filetype]):array();
        $this->disabled_filetypes   = $group[disabled_filetype]?split(',',$group[disabled_filetype]):array();
        $this->allowed_filesize     = $group[sizelimit];
        $this->max_uploads          = $group[max_uploads];

        $this->validate_type        = $group[validate_type];
       
        # upload method setting
        $this->can_formupload       = $group[formupload];
        $this->can_urlupload        = $group[urlupload];
        $this->can_ftpupload        = $group[ftpupload];
        $this->can_flashupload      = $group[flashupload];
       
        # download setting
        $this->dl_resume            = $group[dl_resume];
        $this->dl_speed             = $group[dl_speed];
        $this->dl_threads           = $group[dl_threads];
        $this->dl_password          = $group[dl_password];
        $this->dl_waittime          = $group[dl_waittime];
        $this->dl_timeout           = $group[dl_timeout];
        $this->dl_captcha           = $group[dl_captcha];

        # cronjob setting
        $this->cron_enabled         = $group[cron_enabled];
        $this->cron_days            = $group[cron_days];
        $this->cron_views           = $group[cron_views];
       
        # ad setting
        $this->show_site_ads        = $group[show_site_ads];
        $this->show_sponser_ads     = $group[show_sponser_ads];
       
        $this->can_create_folder    = $group[folder];

        if(IN_MAIN_SERVER)
        {
            $template->assign_var('shakeTime',$this->setting[shaketime]);
            $template->assign_var('startShow',$this->setting[startshow]);
            $template->assign_var('AdTop',$this->setting[adtop]);
            $template->assign_var('AdLeft',$this->setting[adleft]);
            $template->assign_var('slideStep',$this->setting[slidestep]);
            $template->assign_var('slideInternal',$this->setting[slideinternal]);

            $template->assign_var('show_site_ads',$this->show_site_ads);
            $template->assign_var('show_sponser_ads',$this->show_sponser_ads);
        }
        
        # host package
        $this->package              = $old_group[name];
        $this->is_custom            = $USER[custom]=='yes';
        $this->package_id           = $group[id];
        $this->package_server_id    = $group[server_id];

        # include language
        if(IN_MAIN_SERVER)
        {
            require_once(ROOT.'/language/'.$this->setting[language].'/lang.php');
            # assign lang vars into template
            if(is_array($LANG))foreach($LANG as $text=>$translation) $template->assign_vars(array('L_'.$text=>$translation));
            # define time format
            $LANG[Units] = array('D'=>$LANG[Days],'M'=>$LANG[Months],'Y'=>$LANG[Years]);
            define('DateFormat', $LANG[DateFormat]);
            define('DateFormat2',$LANG[DateFormat2]);
            define('TimeStamp',  $LANG[TimeStamp]);
        }
       
        # account status
        $this->account_status       = $USER[status];
        $this->account_expired      = $account_expired;
        $this->account_expire_date  = $old_group[subscr_fee]=='' ? $LANG["NeverExpired"] : date(DateFormat,$USER[expire_date]);

        # select server based package,note a valid package id is required
        if($this->setting[server]==-2)
        {
            if($this->package_server_id) $this->server_id = $this->package_server_id;
            else $this->setting[server]=0;
        }
        # specify server by admin
        if($this->setting[server]>0)
        {
            $this->server_id = $this->setting[server];
        }
        # the last one is random server

        # below code moved function showUploadForm()
        # get upload server details
        # $this->getServer();
	}
    /**
    *get upload method:form upload,ftp upload,url upload
    */
    function getServer()
    {
    global $db,$input;
        # check available servers
        if($this->setting[site_offline] == 1) return ;
        $this->checkServer();
        if($this->setting[site_offline] == 1) return ;
    
        $server = array();
        # sepcify by admin or get it at package based
        if($this->setting[server]>0 || $this->setting[server]==-2)
        {
            if(!is_array($this->upload_servers[$this->server_id]))
            {
                #switch to random selection
                $this->setting[server] = 0;
            }
            else
            {
                $server=$this->upload_servers[$this->server_id];
            }
        }
        #select a server randonly to upload
        if($this->setting[server]==0)
        {

            $server = $this->upload_servers[array_rand($this->upload_servers)];

        }
        #build a server list to select by uploader!
        elseif($this->setting[server]==-1)
        {

            $server = current($this->upload_server);
            $this->server_id = $server[server_id];
        }

        #$this->cgi_upload_url   = $server[http].$server[cgiurl].'/upload.cgi';
        $this->cgi_upload_url   = $server[http].$server[cgiurl].($server[iswin]=='yes'?'/upload.cgi':'/upload.cgi');
        $this->php_upload_url   = $server[http].$server[domain].'/uploading.php';
        $this->php_progress_url = $server[http].$server[domain].'/progress.php';

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -