当前位置: 首页>>代码示例>>PHP>>正文


PHP cpg_error函数代码示例

本文整理汇总了PHP中cpg_error函数的典型用法代码示例。如果您正苦于以下问题:PHP cpg_error函数的具体用法?PHP cpg_error怎么用?PHP cpg_error使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了cpg_error函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: install

   function install()
   {
       global $installer;
       if (!$installer->table_exists('bbattachments_config') || !$installer->table_exists('bbconfig') || !$installer->table_exists('bbthemes') || !$installer->table_exists('bbwords')) {
           cpg_error($this->modname . ' still depends on the Forums module. Install forums first', 'Install ERROR');
       }
       $installer->add_query('CREATE', 'bbprivmsgs', '
 privmsgs_id mediumint(8) NOT NULL auto_increment,
 privmsgs_type tinyint(4) NOT NULL default "0",
 privmsgs_subject varchar(255) NOT NULL default "0",
 privmsgs_from_userid mediumint(8) NOT NULL default "0",
 privmsgs_to_userid mediumint(8) NOT NULL default "0",
 privmsgs_date int(11) NOT NULL default "0",
 privmsgs_ip varchar(16) binary NOT NULL default "",
 privmsgs_enable_bbcode tinyint(1) NOT NULL default "1",
 privmsgs_enable_html tinyint(1) NOT NULL default "0",
 privmsgs_enable_smilies tinyint(1) NOT NULL default "1",
 privmsgs_attach_sig tinyint(1) NOT NULL default "1",
 privmsgs_attachment TINYINT(1) DEFAULT "0" NOT NULL,
 PRIMARY KEY (privmsgs_id),
 KEY privmsgs_from_userid (privmsgs_from_userid),
 KEY privmsgs_to_userid (privmsgs_to_userid)', 'bbprivmsgs');
       $installer->add_query('CREATE', 'bbprivmsgs_text', '
 privmsgs_text_id mediumint(8) NOT NULL default "0",
 privmsgs_text text,
 PRIMARY KEY (privmsgs_text_id)', 'bbprivmsgs_text');
       return true;
   }
开发者ID:cbsistem,项目名称:nexos,代码行数:28,代码来源:cpg_inst.php

示例2: DownloadsAddCat

function DownloadsAddCat()
{
    global $downloadsprefix, $db, $op;
    $title = Fix_Quotes($_POST['title']);
    $parentid = intval($_POST['parentid']);
    $result = $db->sql_query("select cid from " . $downloadsprefix . "_categories where title='{$title}' AND parentid='{$parentid}'");
    if ($db->sql_numrows($result) > 0) {
        require_once 'header.php';
        GraphicAdmin('_AMENU6');
        cpg_error(_ERRORTHESUBCATEGORY . " {$title} " . _ALREADYEXIST);
    } else {
        $db->sql_query("insert into " . $downloadsprefix . "_categories values (NULL, '{$title}', '" . Fix_Quotes($_POST['cdescription']) . "', '" . Fix_Quotes($_POST['ldescription']) . "', '{$parentid}')");
        url_redirect(adminlink($op));
    }
}
开发者ID:cbsistem,项目名称:nexos,代码行数:15,代码来源:download.modCat.php

示例3: __construct

 function __construct($name = 'CMSSESSID', $time = 180)
 {
     global $CPG_SESS, $MAIN_CFG;
     $this->sess_name = $name;
     $this->sess_time = $time;
     $this->start = time();
     $expired = time() - $time * 60;
     $new_session = true;
     if (ini_get('session.auto_start')) {
         session_destroy();
         session_write_close();
     }
     session_name($name);
     // http://www.php.net/session_set_cookie_params
     session_set_cookie_params(0, $MAIN_CFG['cookie']['path'], $MAIN_CFG['cookie']['domain']);
     // [, bool secure]
     /*
     			session_cache_limiter('private_no_expire');
     			// Setting new_cache_expire is of value only,
     			// if session.cache_limiter is set to a value different from nocache
     			session_cache_expire($time);
     */
     if (CAN_MOD_INI) {
         $this->old_handler = ini_set('session.save_handler', 'files');
         //				ini_set('session.gc_maxlifetime', $expired); # bug not deleting ?
         ini_set('session.use_trans_sid', 0);
         ini_set('session.use_only_cookies', '1');
         ini_set('url_rewriter.tags', 'nourlrewrite');
     }
     $this->started = session_start();
     if (empty($_SESSION['CPG_SESS']) && isset($_COOKIE[$name]) && $_COOKIE[$name] == session_id()) {
         $sid = $_COOKIE[$name];
         $this->destroy();
         $this->started = session_start();
         if ($sid == session_id()) {
             $this->destroy();
             cpg_error('Your cookie has expired, the page will be refreshed to set a new cookie.', 'Cookie expired', URL::uri());
         }
     }
     $this->sess_id = session_id();
     $CPG_SESS = empty($_SESSION['CPG_SESS']) ? array() : $_SESSION['CPG_SESS'];
     $this->new = empty($_SESSION);
     return $this->sess_id;
 }
开发者ID:cbsistem,项目名称:nexos,代码行数:44,代码来源:session.php

示例4: del_folder

function del_folder($folder)
{
    if (file_exists('language/' . $folder)) {
        $dir = dir('language/' . $folder);
        while ($file = $dir->read()) {
            if ($file != '.' && $file != '..') {
                if (is_dir('language/' . $folder . '/' . $file)) {
                    del_folder($folder . '/' . $file);
                } else {
                    if (!unlink('language/' . $folder . '/' . $file)) {
                        cpg_error('Cannot remove file ' . $file);
                    }
                }
            }
        }
        $dir->close();
        if (!rmdir('language/' . $folder)) {
            cpg_error('Cannot remove folder language/' . $folder);
        }
    }
}
开发者ID:cbsistem,项目名称:nexos,代码行数:21,代码来源:l10n.php

示例5: df_compile_cache

function df_compile_cache()
{
    global $AdminCache;
    $source = $AdminCache->file;
    # path level too high eg "/"
    if (empty($source) || preg_match('#(classes)/$#', $source)) {
        return;
    }
    # will backup any file before compile them
    if (!backup_create($source, 'bcompiler_backup/' . $source) && !defined('DF_BACKUP_SKIP_ERRORS')) {
        cpg_error('File backup could not be completed, see footer warning for more infos');
    } else {
        if (preg_match('#/$#', $source)) {
            df_bcompile_dir(BASEDIR . $source, BASEDIR . 'bcompiler_backup/' . $source);
        } else {
            if (preg_match('#\\.(php[\\d]?|inc)$#', $source)) {
                df_bcompile_file(BASEDIR . $source, BASEDIR . 'bcompiler_backup/' . $source);
            }
        }
    }
}
开发者ID:cbsistem,项目名称:nexos,代码行数:21,代码来源:bcompiler.php

示例6: check_fields

function check_fields(&$fieldlist, &$valuelist, &$fields, $post = true)
{
    global $db, $user_prefix;
    $input = $post ? $_POST : $fields;
    $content = '';
    $result = $db->sql_uquery("SELECT * FROM " . $user_prefix . "_users_fields WHERE visible > 0");
    while ($row = $db->sql_fetchrow($result)) {
        $var = $row['field'] == 'name' ? 'realname' : $row['field'];
        $info = $row['langdef'];
        if ($info[0] == '_' && defined($info)) {
            $info = constant($info);
        }
        if (empty($input[$var]) && $row['visible'] == 2) {
            cpg_error('Required field "' . $info . '" can\'t be empty');
        } else {
            $val = Fix_Quotes($input[$var], 1);
            //if (strlen($val) > 0) {
            if ($row['type'] == 1 || $row['type'] == 4) {
                $val = intval($val);
            } elseif ($row['type'] != 3) {
                $val = substr($val, 0, $row['size']);
            }
            $fieldlist .= ", " . $row['field'];
            $valuelist .= ", '{$val}'";
            $fields[$var] = htmlprepare($val);
            if ($row['type'] == 1) {
                $val = $val ? _YES : _NO;
            }
            $content .= "<tr><td><b>{$info}:</b></td><td>{$val}</td></tr>\n";
            if ($row['field'] == 'user_timezone') {
                $fields['user_dst'] = intval($input['user_dst']);
                $fieldlist .= ', user_dst';
                $valuelist .= ', ' . $fields['user_dst'];
            }
            //}
        }
    }
    return $content;
}
开发者ID:cbsistem,项目名称:nexos,代码行数:39,代码来源:functions.php

示例7: sql_db

 function sql_db($server, $user, $password, $database, $persistent = false)
 {
     if (!function_exists('mysql_connect')) {
         cpg_error('MySQL extension not loaded in PHP.<br />Recompile PHP, edit php.ini or choose a different SQL layer.');
     }
     $stime = get_microtime();
     $this->persistent = $persistent;
     $this->connect_id = $persistent ? mysql_pconnect($server, $user, $password) : mysql_connect($server, $user, $password);
     if ($this->connect_id) {
         if (!empty($database) && !mysql_select_db($database) && !defined('INSTALL')) {
             mysql_close($this->connect_id);
             $this->connect_id = false;
             define('NO_DB', 'It seems that the database doesn\'t exist');
         }
         $this->time += get_microtime() - $stime;
         # http://dev.mysql.com/doc/refman/5.0/en/charset-connection.html
         if (DB_CHARSET) {
             mysql_query('SET NAMES \'' . DB_CHARSET . "'", $this->connect_id);
             mysql_query('SET CHARACTER SET \'' . DB_CHARSET . "'", $this->connect_id);
         }
     } else {
         define('NO_DB', 'The connection to the database server failed');
     }
 }
开发者ID:cbsistem,项目名称:nexos,代码行数:24,代码来源:mysql.php

示例8: sql_db

 function sql_db($server, $user, $password, $database, $persistent = false)
 {
     if (!function_exists('pg_connect')) {
         cpg_error('PostgreSQL extension not loaded in PHP.<br />Recompile PHP, edit php.ini or choose a different SQL layer.');
     }
     $stime = get_microtime();
     $this->persistent = $persistent;
     $connect_string = '';
     if ($server) {
         if (strpos($server, ':')) {
             $server = explode(':', $server, 2);
             $connect_string .= "host={$server['0']} port={$server['1']} ";
         } else {
             if ($server != 'localhost') {
                 $connect_string .= "host={$server} ";
             }
         }
     }
     if (!empty($database)) {
         $connect_string .= "dbname=" . pg_escape_string($database) . " ";
     }
     if ($user) {
         $connect_string .= "user=" . pg_escape_string($user) . " ";
     }
     if ($password) {
         $connect_string .= "password=" . pg_escape_string($password);
     }
     $this->connect_id = $this->persistent ? pg_pconnect($connect_string) : pg_connect($connect_string);
     if ($this->connect_id) {
         //pg_set_client_encoding($this->connect_id, 'UNICODE');
         pg_query($this->connect_id, "SET client_encoding = 'UTF8'");
         $this->time += get_microtime() - $stime;
     } else {
         define('NO_DB', 'Connection to the database server failed.');
     }
 }
开发者ID:cbsistem,项目名称:nexos,代码行数:36,代码来源:postgresql.php

示例9: __construct

 public function __construct()
 {
     self::parseCompilers();
     if (Security::check_post()) {
         foreach ($_POST as $key => $val) {
             if (!preg_match('#^[a-z_/]+$#i', $key) || !preg_match('#^[a-z0-9\\-_\\s]+$#i', $val)) {
                 break;
             }
             $this->post[] = $key;
             $this->post[] = $val;
         }
         if (!isset($this->installed[$this->post[0]])) {
             cpg_error('No such compiler');
         }
         $this->compiler = $this->post[0];
         $this->call = strtolower($this->post[1]);
         if ($this->post[0] === 'tpl' && $this->post[1] === 'show') {
             $this->current_file = $this->post[2];
         }
     }
     /*else {*/
     self::index();
     /*}*/
 }
开发者ID:cbsistem,项目名称:nexos,代码行数:24,代码来源:cache.php

示例10: file_exists

    case 'posts':
        $order_by = 'user_posts';
        break;
    case 'website':
        $order_by = 'user_website';
        break;
    default:
        $order_by = 'user_id';
        break;
}
$order_by .= " {$sort_order}";
$template_name = file_exists("themes/{$CPG_SESS['theme']}/template/forums/images.cfg") ? $CPG_SESS['theme'] : 'default';
$current_template_path = 'themes/' . $template_name . '/images/forums';
include 'themes/' . $template_name . '/template/forums/images.cfg';
if (!defined('TEMPLATE_CONFIG')) {
    cpg_error("Could not open {$template_name} template config file");
}
$img_lang = file_exists(realpath($current_template_path . '/lang_' . $MAIN_CFG['global']['language'])) ? $MAIN_CFG['global']['language'] : 'english';
while (list($key, $value) = each($images)) {
    if (!is_array($value)) {
        $images[$key] = str_replace('{LANG}', 'lang_' . $img_lang, $value);
    }
}
$ranksrow = $db->sql_ufetchrowset("SELECT * FROM " . $prefix . "_bbranks\n\tORDER BY rank_special, rank_min", SQL_ASSOC);
$sql = "SELECT username, user_id, user_posts, user_rank, user_regdate, user_from, user_website, user_icq, user_aim, user_yim, user_msnm, user_avatar, user_avatar_type, user_allowavatar\n\tFROM " . $user_prefix . "_users\n\tWHERE username!='Anonymous'\n\tAND user_level > 0\n\tORDER BY {$order_by}\n\tLIMIT {$members_per_page} OFFSET {$start}";
$result = $db->sql_query($sql);
if ($row = $db->sql_fetchrow($result)) {
    $i = 0;
    do {
        $username = $row['username'];
        $user_id = $row['user_id'];
开发者ID:cbsistem,项目名称:nexos,代码行数:31,代码来源:index.php

示例11: show

     show($mode, $tablelist, $query);
     break;
 case 'RestoreDB':
     require_once 'header.php';
     GraphicAdmin('_AMENU0');
     require_once CORE_PATH . 'classes/sqlctrl.php';
     if (!SQLCtrl::query_file($_FILES['sqlfile'], $error)) {
         cpg_error($error);
     }
     OpenTable();
     echo '<span class="genmed"><strong>' . _DATABASE . ': ' . $dbname . '</strong></span><br /><br />Importation of <em>' . $_FILES['sqlfile']['name'] . '</em> was successful';
     CloseTable();
     break;
 case 'Installer':
     if (!is_dir('cache') || !is_writable('cache')) {
         cpg_error('Cache directory doesn\'t exists or not writable');
     }
     require_once 'header.php';
     GraphicAdmin('_AMENU0');
     foreach ($tablelist as $table) {
         $list = $db->list_columns($table);
         if (0 === strpos($table, $prefix . '_')) {
             $table = str_replace($prefix . '_', '', $table);
         } else {
             if (0 === strpos($table, $user_prefix . '_')) {
                 $table = str_replace($user_prefix . '_', '', $table);
             }
         }
         $ids = false;
         $space = '  ';
         $filename = "cache/installer_{$table}.php";
开发者ID:cbsistem,项目名称:nexos,代码行数:31,代码来源:database.php

示例12: isset

        $gfxid = isset($_POST['gfxid']) ? $_POST['gfxid'] : 0;
        $code = $CPG_SESS['gfx'][$gfxid];
        $gfx_check = isset($_POST['gfx_contact_check']) ? $_POST['gfx_contact_check'] : '';
        if (strlen($gfx_check) < 2 || $code != $gfx_check) {
            $error = _SECURITYCODE . ' incorrect';
        }
    }
    if (isset($error)) {
        cpg_error('<div style="text-align:center;">' . $error . '</div>');
    } else {
        if (!send_mail($mailer_message, $personal_message, $html, $subject, $recipient_email, $recipient_name, $sender_email, $sender_name)) {
            cpg_error('<div style="text-align:center;"><strong>' . $mailer_message . '</strong></div>');
        } else {
            $CPG_SESS['tell_friend'] = false;
            unset($CPG_SESS['tell_friend']);
            cpg_error(_MESSAGESENT, _Tell_a_FriendLANG, $mainindex);
        }
    }
} else {
    $CPG_SESS['tell_friend'] = true;
    $sender_name = $sender_email = '';
    if (is_user()) {
        $sender_name = !empty($userinfo['name']) ? $userinfo['name'] : $userinfo['username'];
        $sender_email = $userinfo['user_email'];
    }
    $message_insert = _HEY . " {recipient},\n\n" . _OURSITE . "\n\n" . _ITSCALLED . " {sitename} " . _SOMESTATS . "\n\n" . _SLOGAN . " {slogan}\n" . _FOUNDEDON . " {founded}\n" . _REGISTEREDUSERS . " {users}\n" . _TOTALSITEHITS . " {hits}\n\n" . _VISITTHEM . ($html ? ' [url={url}]{url}[/url]' : ' {url}') . "\n\n" . _KINDREGARDS . ",\n\n{sender}";
    if ($html) {
        require_once 'includes/nbbcode.php';
        $bbcode = bbcode_table('personal_message', 'tell_friend', 0);
    } else {
        $bbcode = '<div style="color: #ff0000"><strong>.: ' . _BBCODEDISABLED . ' :.</strong></div><br />';
开发者ID:cbsistem,项目名称:nexos,代码行数:31,代码来源:index.php

示例13: loginadmin

 private function loginadmin()
 {
     $aid = isset($_POST['alogin']) ? Fix_Quotes($_POST['alogin']) : NULL;
     $pwd = isset($_POST['pwd']) ? $_POST['pwd'] : NULL;
     if ($aid && $pwd) {
         global $sec_code, $CPG_SESS;
         if ($sec_code & 1) {
             $gfxid = isset($_POST['gfxid']) ? $_POST['gfxid'] : 0;
             $code = $CPG_SESS['gfx'][$gfxid];
             $gfx_check = isset($_POST['gfx_check']) ? $_POST['gfx_check'] : '';
             if (strlen($gfx_check) < 2 || $code != $gfx_check) {
                 return false;
             }
         }
         global $db, $prefix;
         $pwd = md5($pwd);
         $result = $db->sql_query('SELECT * FROM ' . $prefix . "_admins WHERE aid='{$aid}'");
         $row = $db->sql_fetchrow($result, SQL_ASSOC);
         if (isset($row['admin_id'])) {
             if (!($login = Cache::array_load('login', 'a', false)) || !isset($login[$row['admin_id']])) {
                 $login[$row['admin_id']] = 1;
             } else {
                 if ($login[$row['admin_id']] >= 5) {
                     cpg_error('Too many failed login attempts');
                 } else {
                     $login[$row['admin_id']]++;
                 }
             }
             if ($row['pwd'] == $pwd && $row['pwd'] != '') {
                 $this->setadmcookie(true, $row['admin_id'], $pwd, isset($_POST['persistent']));
                 unset($row['pwd']);
                 $this->admin = $row;
                 $this->admin_id = $row['aid'];
                 $this->demo = CPGN_DEMO && false !== strpos($this->admin_id, 'demo');
                 unset($CPG_SESS['admin']);
                 $login[$row['admin_id']] = 1;
             }
             Cache::array_save('login', 'a', $login);
         }
     }
     return $this->admin_id;
 }
开发者ID:cbsistem,项目名称:nexos,代码行数:42,代码来源:cpg_member.php

示例14: query_file

 public static function query_file($file, &$error, $replace_prefix = false)
 {
     $error = false;
     if (!is_array($file)) {
         $tmp['name'] = $tmp['tmp_name'] = $file;
         $tmp['type'] = preg_match("/\\.gz\$/is", $file) ? 'application/x-gzip' : 'text/plain';
         $file = $tmp;
     }
     if (empty($file['tmp_name']) || empty($file['name'])) {
         cpg_error('ERROR no file specified!');
     }
     // Most servers identify a .gz as x-tar
     if (preg_match("/^(text\\/[a-zA-Z]+)|(application\\/(x\\-)?(gzip|tar)(\\-compressed)?)|(application\\/octet-stream)\$/is", $file['type'])) {
         $filedata = '';
         $open = 'gzopen';
         $eof = 'gzeof';
         $read = 'gzgets';
         $close = 'gzclose';
         if (!GZIPSUPPORT) {
             if (preg_match("/\\.gz\$/is", $file['name'])) {
                 $error = "Can't decompress file";
                 return false;
             }
             $open = 'fopen';
             $eof = 'feof';
             $read = 'fread';
             $close = 'fclose';
         }
         $rc = $open($file['tmp_name'], 'rb');
         if ($rc) {
             while (!$eof($rc)) {
                 $filedata .= $read($rc, 100000);
             }
             $close($rc);
         } else {
             $error = 'Couldn\'t open ' . $file['tmp_name'] . ' for processing';
         }
     } else {
         $error = "Invalid filename: {$file['type']} {$file['name']}";
     }
     if ($error) {
         return false;
     }
     $filedata = DBCtrl::remove_remarks($filedata);
     $queries = DBCtrl::split_sql_file($filedata, ";\n");
     if (count($queries) < 1) {
         $error = 'There are no queries in ' . $file['name'];
         return false;
     }
     global $db, $prefix;
     set_time_limit(0);
     foreach ($queries as $query) {
         if (!$replace_prefix) {
             $query = preg_replace('#(TABLE|INTO|EXISTS|ON) ([a-zA-Z]*?(_))#i', "\\1 {$prefix}" . '_', $query);
         } else {
             foreach ($replace_prefix as $oldprefix => $newprefix) {
                 if ($oldprefix != $newprefix) {
                     $query = preg_replace("/{$oldprefix}/", $newprefix, $query);
                 }
             }
         }
         if (SQL_LAYER == 'mysql' && preg_match('#^CREATE TABLE #', $query) && false === stripos($query, 'ENGINE=MyISAM')) {
             $query .= ' ENGINE=MyISAM';
         }
         $db->sql_query($query);
     }
     return true;
 }
开发者ID:cbsistem,项目名称:nexos,代码行数:68,代码来源:sqlctrl.php

示例15: send_file_to_browser

function send_file_to_browser($attachment, $upload_dir)
{
    global $_SERVER, $lang, $db, $attach_config, $board_config;
    $filename = $upload_dir == '' ? $attachment['physical_filename'] : $upload_dir . '/' . $attachment['physical_filename'];
    $gotit = FALSE;
    if (!intval($attach_config['allow_ftp_upload'])) {
        if (!file_exists(amod_realpath($filename))) {
            message_die(GENERAL_ERROR, $lang['Error_no_attachment'] . "<br /><br /><b>404 File Not Found:</b> The File <i>" . $filename . "</i> does not exist.");
        } else {
            $gotit = TRUE;
        }
    }
    //
    // Determine the Browser the User is using, because of some nasty incompatibilities.
    // Most of the methods used in this function are from phpMyAdmin. :)
    //
    $HTTP_USER_AGENT = isset($_SERVER['HTTP_USER_AGENT']) ? $_SERVER['HTTP_USER_AGENT'] : '';
    if (preg_match('#Opera(/| )([0-9].[0-9]{1,2})#', $HTTP_USER_AGENT)) {
        $browser_agent = 'opera';
    } else {
        if (preg_match('#MSIE ([0-9].[0-9]{1,2})#', $HTTP_USER_AGENT)) {
            $browser_agent = 'ie';
        } else {
            if (preg_match('#OmniWeb/([0-9].[0-9]{1,2})#', $HTTP_USER_AGENT)) {
                $browser_agent = 'omniweb';
            } else {
                if (preg_match('#Netscape([0-9]{1})#', $HTTP_USER_AGENT)) {
                    $browser_agent = 'netscape';
                } else {
                    if (preg_match('#Mozilla/([0-9].[0-9]{1,2})#', $HTTP_USER_AGENT)) {
                        $browser_agent = 'mozilla';
                    } else {
                        if (preg_match('#Konqueror/([0-9].[0-9]{1,2})#', $HTTP_USER_AGENT)) {
                            $browser_agent = 'konqueror';
                        } else {
                            $browser_agent = 'other';
                        }
                    }
                }
            }
        }
    }
    if (GZIPSUPPORT) {
        while (ob_end_clean()) {
        }
        header('Content-Encoding: none');
    }
    // Now the tricky part... let's dance
    /*
    	header('Pragma: public');
    	header('Content-Transfer-Encoding: none');
    	header("Expires: 0"); // set expiration time
    	header("Cache-Control: must-revalidate, post-check=0, pre-check=0");
    */
    //
    // Now send the File Contents to the Browser
    //
    if ($gotit) {
        $size = filesize($filename);
        if ($attachment['mimetype'] == 'application/x-zip-compressed') {
            if (intval($attach_config['allow_ftp_upload'])) {
                if (trim($attach_config['download_path']) == '') {
                    message_die(GENERAL_ERROR, 'Physical Download not possible with the current Attachment Setting');
                }
                $url = trim($attach_config['download_path']) . '/' . $attachment['physical_filename'];
                $redirect_path = $url;
            } else {
                $redirect_path = '/' . $upload_dir . '/' . $attachment['physical_filename'];
            }
            URL::redirect($redirect_path);
        } else {
            // Correct the mime type - we force application/octetstream for all files, except images
            // Please do not change this, it is a security precaution
            if (false === stripos($attachment['mimetype'], 'image')) {
                $attachment['mimetype'] = $browser_agent == 'ie' || $browser_agent == 'opera' ? 'application/octetstream' : 'application/octet-stream';
            }
            if (!($fp = fopen($filename, 'rb'))) {
                cpg_error('Could not open file for sending');
            }
            // Send out the Headers
            header('Content-Type: ' . $attachment['mimetype'] . '; name="' . $attachment['real_filename'] . '"');
            header('Content-Disposition: inline; filename="' . $attachment['real_filename'] . '"');
            print fread($fp, $size);
            fclose($fp);
        }
    } else {
        if (!$gotit && intval($attach_config['allow_ftp_upload'])) {
            $tmp_path = !ini_get('safe_mode') ? '/tmp' : $upload_dir . '/tmp';
            $tmp_filename = tempnam($tmp_path, 't0000');
            unlink($tmp_filename);
            include_once 'includes/classes/cpg_ftp.php';
            $ftp = new cpg_ftp($attach_config['ftp_server'], $attach_config['ftp_user'], $attach_config['ftp_pass'], $attach_config['ftp_path'], $attach_config['ftp_pasv_mode']);
            $mode = FTP_BINARY;
            if (preg_match("/text/i", $attachment['mimetype']) || preg_match("/html/i", $attachment['mimetype'])) {
                $mode = FTP_ASCII;
            }
            $result = ftp_get($ftp->connect_id, $tmp_filename, $filename, $mode);
            $ftp->close();
            if (!$result) {
                message_die(GENERAL_ERROR, $lang['Error_no_attachment'] . "<br /><br /><b>404 File Not Found:</b> The File <i>" . $filename . "</i> does not exist.");
//.........这里部分代码省略.........
开发者ID:cbsistem,项目名称:nexos,代码行数:101,代码来源:download.php


注:本文中的cpg_error函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。