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

📄 function.php

📁 网络硬盘_支持1GB文件上传和续传_无错版
💻 PHP
📖 第 1 页 / 共 4 页
字号:
<?/*+--------------------------------------------------------------------------|   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+--------------------------------------------------------------------------*//*** load downlaod rules based on $group_id,$country_code*/function loadDownloadRules($group_id,$country_code){global $input,$db,$user;    # clean input    $group_id = intval($group_id);    $country_code = strtoupper($country_code);    $default_rule = array(        'rule_id'=>0,        'dl_gid'=>0,        'dl_area'=>'NA',        'dl_points'=>0,        'dl_maxbyday'=>0,        'dl_donebytes'=>0,        'dl_maxbytes'=>0,    );        ($hook = YABPlugin::fetch_hook('dlrule_loading',__FILE__,__LINE__)) ? eval($hook) : '';    # load rules by host package    $db->setQuery("select * from downloadrules where dl_gid='$group_id'");    $db->query();    $rows=$db->loadRowList();    # load rules    foreach($rows as $row)    {        $codes = split(',', strtoupper($row[dl_area]));        # if a NA rule loaded, set it as default rule!        if($row[area]=='UN')$default_rule = $row;        # if a match rule is found, ignore the default rule        if(in_array($country_code,$codes)) return $row;    }    return $default_rule;}/*** Show uplaod form*/function showUploadForm(){global $input, $user, $template, $server_id, $baseWeb, $_SERVER;    ($hook = YABPlugin::fetch_hook('uploadform_prepare',__FILE__,__LINE__)) ? eval($hook) : '';        # get upload server details    $server = $user->getServer();    # initiate the uploader class and create the upload session    $uploader = new uploader($server_id);    $uploader->create_session($user->uid);    $uploadmode = getCookies('uploadmode')?getCookies('uploadmode'):$input[uploadmode];    if(!in_array($uploadmode,array(1,2,3,4))) $uploadmode=1;    # cross domain access:Javscript and Ajax Use!    $localhost=$_SERVER[HTTP_HOST];    $parts=parse_url($baseWeb);    # assign vars    $template->assign_vars(array(    'allowed_filesize'   => $user->allowed_filesize,    'allowed_types'      => implode(',',$user->allowed_filetypes),    'disabled_types'     => implode(',',$user->disabled_filetypes),    'format_filesize'    => convertsize($user->allowed_filesize),    'max_uploads'        => $user->max_uploads,    'use_flash_progress' => $user->setting[use_flash_progress],    'upload_session'     => $uploader->upload_session,    'AccessKey'          => $uploader->access_code,    'ServerID'           => $server[server_id],    'uploadmode'         => $uploadmode,    'show_options'       => $user->setting[show_options]==1?'block':'none',    'password_disabled'  => $user->dl_password==1?'':' onclick="RegisterNow()"',    # set php uploader script as action url for url and ftp upload if the progress bar is ajax    'cgi_upload_url'     => $user->cgi_upload_url,    'url_upload_url'     => $server[url_prog_mode]=='ajax'?$user->php_upload_url:$baseWeb.'/cross.php',    'ftp_upload_url'     => $server[ftp_prog_mode]=='ajax'?$user->php_upload_url:$baseWeb.'/cross.php',    'php_upload_url'     => $user->php_upload_url,    'php_progress_url'   => $user->php_progress_url,    'flash_progress_url' => $baseWeb.'/skin/'.$user->setting[skin_dir].'/images/progress_bar.swf',    # url on main site:    'swf_upload_url'     => $baseWeb.'/includes/uploader.swf',//$user->swf_upload_url,    'return_url'         => $baseWeb.'/cross.php',    ));        # select the upload method    $template->assign_var('file_selected', $uploadmode==1&&$user->can_formupload!=-1?'checked':' ');    $template->assign_var('url_selected',  $uploadmode==2&&$user->can_urlupload!=-1?'checked':' ');    $template->assign_var('ftp_selected',  $uploadmode==3&&$user->can_ftpupload!=-1?'checked':' ');    $template->assign_var('flash_selected',$uploadmode==4&&$user->can_flashupload!=-1?'checked':' ');    # site offline    if($user->setting[site_offline]==1)    {        $template->assign_var('IS_siteoffline',1);        $template->assign_block_vars('siteoffline', array());                ($hook = YABPlugin::fetch_hook('site_offline',__FILE__,__LINE__)) ? eval($hook) : '';    }    else    {        # show or not        $template->assign_var('show_formupload',  $user->can_formupload!=-1);        $template->assign_var('show_urlupload',   $user->can_urlupload!=-1);        $template->assign_var('show_ftpupload',   $user->can_ftpupload!=-1);        $template->assign_var('show_flashupload', $user->can_flashupload!=-1);        # enabled or not        $template->assign_var('can_formupload',  $user->can_formupload);        $template->assign_var('can_urlupload',   $user->can_urlupload);        $template->assign_var('can_ftpupload',   $user->can_ftpupload);        $template->assign_var('can_flashupload', $user->can_flashupload);                # enabled or not        $template->assign_var('cgi_prog_mode',  $server[cgi_prog_mode]);        $template->assign_var('url_prog_mode',  $server[url_prog_mode]);        $template->assign_var('ftp_prog_mode',  $server[ftp_prog_mode]);                # set upload interface status        $template->assign_var('file_block',  $uploadmode==1&&$user->can_formupload!=-1?'block':'none');        $template->assign_var('url_block',   $uploadmode==2&&$user->can_urlupload!=-1?'block':'none');        $template->assign_var('ftp_block',   $uploadmode==3&&$user->can_ftpupload!=-1?'block':'none');        $template->assign_var('flash_block', $uploadmode==4&&$user->can_flashupload!=-1?'block':'none');    }    ($hook = YABPlugin::fetch_hook('uploadform_display',__FILE__,__LINE__)) ? eval($hook) : '';}function PHPunescape ($source){    $decodedStr = "";    $pos = 0;    $len = strlen ($source);    while ($pos < $len) {        $charAt = substr ($source, $pos, 1);        if ($charAt == '%') {            $pos++;            $charAt = substr ($source, $pos, 1);            if ($charAt == 'u') {                // we got a unicode character                $pos++;                $unicodeHexVal = substr ($source, $pos, 4);                $unicode = hexdec ($unicodeHexVal);                $entity = "&#". $unicode . ';';                $decodedStr .= utf8_encode ($entity);                $pos += 4;            }            else {                // we have an escaped ascii character                $hexVal = substr ($source, $pos, 2);                $decodedStr .= chr (hexdec ($hexVal));                $pos += 2;            }        } else {            $decodedStr .= $charAt;            $pos++;        }    }    return $decodedStr;}/*** Show links for files*/function showFileLinks(){global $input,$baseUrl,$baseWeb,$db,$user,$template;    $per_num=10;    $input[s]=intval($input[s]);    $db->setQuery("select count(*) as nums from files as f where f.uid='$user->uid' and f.deleted=0");    $db->query();    $tmp=$db->loadRow();    $db->setQuery("select f.*,s.name as server,s.http,s.domain,s.mod_status from files as f                  left join server as s on s.server_id=f.server_id                  where f.uid='$user->uid' and f.deleted=0                  order by f.time DESC limit $input[s],$per_num");    $db->query();    $rows=$db->loadRowList();    $cur_page=@($input[s]/$per_num);    $info=array('total'      =>$tmp[nums],                'page'       =>$per_num,                'cur_page'   =>$cur_page,                'baseUrl'    =>$baseUrl."&showlinks=1"                );                    $pageLinks=buildPageLinks($info);    $template->assign_vars(array('pageLinks'=>$pageLinks,'filenums'=>$tmp[nums],'pages'=>$per_num));    buildLinksCode($rows);}/***  generate links code*/function buildLinksCode($images){global $LANG,$input,$baseWeb,$db,$user,$template,$ThumbFile;    $ImageFile         = array('jpg','jpeg','gif','png');    $ImageFile2        = array('bmp','tiff','tif');    $VideoFile         = array('mpeg','mpg','avi','wmv');        ($hook = YABPlugin::fetch_hook('showfiles_begin',__FILE__,__LINE__)) ? eval($hook) : '';    $i=0;    foreach($images as $image)    {        $i++;        # retrieve the urls        $urls=getDownloadUrl($image);        extract($urls);               $filetype = getExt($image[file],'_') ? getExt($image[file],'_') : getExt($image[file]);        list($im,$mplayer,$ffmpeg) = split(',',$image[mod_status]);        $image[can_makethumb] = (in_array($filetype,$ImageFile))                                ||(($im)&&in_array($filetype,$ImageFile2))                                ||(($mplayer||$ffmpeg)&&in_array($filetype,$VideoFile));                $image[showthumb] = $image['thumb'];               $image[remoteWeb] = $image[http].$image['domain'];        $image[accessKey] = base64_encode(encryptStr("$user->uid",$input[IP_CLIENT]));        $image[size]=convertsize($image[size]);        $image[s]=$input[s];               $image[thumb_url]    = $thumburl;        $image[delete_url]   = $deleteurl;        $image[download_url] = $downloadurl;        $image[upload_date]  = date(TimeStamp,$image['time']);        /*$image[hasdescr]=strlen($image[descr])!=0;        $image[descr]=$image[descr]==''?$LANG[ClickEditDescr]:htmlspecialchars($image[descr]);        $image[haspw]=strlen($image[password])!=0;        $image[password]=$image[password]==''?$LANG[ClickEditPW]:$image[password];        */        ($hook = YABPlugin::fetch_hook('showfiles_row',__FILE__,__LINE__)) ? eval($hook) : '';        $template->assign_block_vars('row', $image);    }    ($hook = YABPlugin::fetch_hook('showfiles_end',__FILE__,__LINE__)) ? eval($hook) : '';}/*** build nice package information for users and output*/function showPackageInfo(){global $user,$baseUrl,$db,$LANG,$template;    ($hook = YABPlugin::fetch_hook('packageinfo_display',__FILE__,__LINE__)) ? eval($hook) : '';    $template->assign_vars(array(    'format_sizelimit'=> convertsize($user->allowed_filesize),    'sizelimit'=>$user->allowed_filesize,    'format_userwebspace'=> convertsize($user->webspace),    'format_webspace'=>convertsize($user->allowed_max_webspace),    'hosted_files'=>$user->hosted_files,    'total_downloads'=>$user->total_downloads,    'total_points'=>$user->total_points,    'last_update'=>date(DateFormat,$user->last_update),    'account_reg_date'=>date(DateFormat,$user->reg_date),    'package_name'=>$user->package,    'is_custom'=>$user->is_custom,    'account_expire_date'=>$user->account_expire_date,    'account_expired'=>$user->account_expired,    'username'=>$user->username,    'max_uploads'=>$user->max_uploads,    ));}/*** show all package information*/function ListHostPackages($group_id=0){global $db,$template,$user,$LANG,$baseWeb,$DATASTORE;    ($hook = YABPlugin::fetch_hook('packages_loading',__FILE__,__LINE__)) ? eval($hook) : '';    # load package list    if(!is_array($DATASTORE[groups]))    {        $db->setQuery("select * from groups ".($group_id? " where id = '$group_id'": ''));        $db->query();        $rows=$db->loadRowList();    }    else    {        $rows=$group_id?array($DATASTORE[groups][$group_id]):$DATASTORE[groups];    }    # image template    $tick_img = '<img src="'.$baseWeb.'/skin/'.$user->setting[skin_dir].'/images/tick.png">';    $x_img = '<img src="'.$baseWeb.'/skin/'.$user->setting[skin_dir].'/images/x.png">';    # assign vars of host package to template    foreach($rows as $row)    {        ($hook = YABPlugin::fetch_hook('packages_option',__FILE__,__LINE__)) ? eval($hook) : '';        if(!$user->setting[show_guest_package]&&$row[guest]==1) continue;                # build subscription info        $ps=split(',',$row[subscr_period]);        $fs=split(',',$row[subscr_fee]);        $price_list='';        if($row[subscr_fee]=='')        {            $price_list=$LANG['Free'];        }        else        {            for($i=0;$i<count($ps);$i++)            {                $price_list.=$LANG[CurrencySymbol].($fs[$i]).'/'.$ps[$i].' '.$LANG[Units][$row[subscr_unit]].'<br>';            }        }        # upload limitions        $template->assign_block_vars('name',array('var'=>$row[name]));        $template->assign_block_vars('sizelimit',array('var'=>convertsize($row[sizelimit])));        $template->assign_block_vars('max_uploads',array('var'=>$row[max_uploads]));        $filetype = $row[allowed_filetype]?$LANG[AllowedFiletypes].':'.$row[allowed_filetype]:($row[disabled_filetype]?$LANG[DisabledFiletypes].':'.$row[disabled_filetype]:$LANG[AllFiletypeAllowed]);                $template->assign_block_vars('filetype',array('var'=>$filetype));        $template->assign_block_vars('allow_filetype',array('var'=>$row[allow_filetype]));        $template->assign_block_vars('disabled_filetype',array('var'=>$row[disabled_filetype]));        # download options        $template->assign_block_vars('dl_speed',array('var'=>$row[dl_speed]==0?$LANG['Unlimited']:$row[dl_speed].'kb/s'));        $template->assign_block_vars('dl_ips',array('var'=>$row[dl_ips]==0?$LANG['Unlimited']:$row[dl_ips]));        $template->assign_block_vars('dl_resume',array('var'=>$row[dl_resume]==1?$tick_img:$x_img));        $template->assign_block_vars('dl_captcha',array('var'=>$row[dl_captcha]==0?$tick_img:$x_img));        # upload method        $template->assign_block_vars('formupload',array('var'=>$row[formupload]==1?$tick_img:$x_img));        $template->assign_block_vars('urlupload',array('var'=>$row[urlupload]==1?$tick_img:$x_img));        $template->assign_block_vars('ftpupload',array('var'=>$row[ftpupload]==1?$tick_img:$x_img));        $template->assign_block_vars('flashupload',array('var'=>$row[flashupload]==1?$tick_img:$x_img));        # ads setting        $template->assign_block_vars('show_sponser_ads',array('var'=>$row[show_sponser_ads]==1?$tick_img:$x_img));        $template->assign_block_vars('show_site_ads',array('var'=>$row[show_site_ads]==1?$tick_img:$x_img));        $template->assign_block_vars('folder',array('var'=>$row[folder]==1?$tick_img:$x_img));        # delete days        $template->assign_block_vars('cron_days',array('var'=>$row[cron_enabled]?$row[cron_days].$LANG[NoDownloads]:$LANG['NeverDelete']));        # order        $template->assign_block_vars('price',array('var'=>$price_list));        $template->assign_block_vars('order',array('group_id'=>$row[id]));    }}/*** list files by condition*/function ListFiles($orderby='f.time',$ads_nums=1,$limit=5,$cols=1,$start=0){global $user,$db,$template;    ($hook = YABPlugin::fetch_hook('topfiles_prepare',__FILE__,__LINE__)) ? eval($hook) : '';    $nowtime=time();    $condiftion = ($user->setting[featured_type]?"f.validate=1 AND" : "") . " f.thumb=1";        $db->setQuery("select f.*,s.http,s.domain from files as f              left join server as s on s.server_id=f.server_id              where $condiftion and f.deleted=0              order by $orderby DESC              limit $start,$limit");    $db->query();    $rows=$db->loadRowList();    if(!$rows) return 0;    $nums = count($rows);        # mixed the ads unit!    for($i=0;$i<$ads_nums;$i++)    array_splice($rows, rand(1, $nums), 0,array(array("is_ads"=>1)));    $nums = count($rows);    ($hook = YABPlugin::fetch_hook('topfiles_begin',__FILE__,__LINE__)) ? eval($hook) : '';

⌨️ 快捷键说明

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