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


PHP amod_realpath函数代码示例

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


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

示例1: send_file_to_browser

function send_file_to_browser($attachment, $upload_dir)
{
    global $bb_cfg, $lang, $userdata;
    $filename = $upload_dir == '' ? $attachment['physical_filename'] : $upload_dir . '/' . $attachment['physical_filename'];
    $gotit = false;
    if (@(!file_exists(@amod_realpath($filename)))) {
        bb_die($lang['ERROR_NO_ATTACHMENT'] . "<br /><br />" . $filename . "<br /><br />" . $lang['TOR_NOT_FOUND']);
    } else {
        $gotit = true;
    }
    // Correct the mime type - we force application/octet-stream for all files, except images
    // Please do not change this, it is a security precaution
    if (!strstr($attachment['mimetype'], 'image')) {
        $attachment['mimetype'] = 'application/octet-stream';
    }
    //bt
    if (!(isset($_GET['original']) && !IS_USER)) {
        include INC_DIR . 'functions_torrent.php';
        send_torrent_with_passkey($filename);
    }
    // Now the tricky part... let's dance
    header('Pragma: public');
    $real_filename = clean_filename(basename($attachment['real_filename']));
    $mimetype = $attachment['mimetype'] . ';';
    $charset = "charset={$bb_cfg['lang'][$userdata['user_lang']]['encoding']};";
    // Send out the Headers
    header("Content-Type: {$mimetype} {$charset} name=\"{$real_filename}\"");
    header("Content-Disposition: inline; filename=\"{$real_filename}\"");
    unset($real_filename);
    // Now send the File Contents to the Browser
    if ($gotit) {
        $size = @filesize($filename);
        if ($size) {
            header("Content-length: {$size}");
        }
        readfile($filename);
    } else {
        bb_die($lang['ERROR_NO_ATTACHMENT'] . "<br /><br />" . $filename . "<br /><br />" . $lang['TOR_NOT_FOUND']);
    }
    exit;
}
开发者ID:ErR163,项目名称:torrentpier,代码行数:41,代码来源:dl.php

示例2: thumbnail_exists

/**
* Check if Thumbnail exist
*/
function thumbnail_exists($filename)
{
    global $upload_dir, $config;
    $filename = basename($filename);
    if (!intval($config['allow_ftp_upload'])) {
        if (!@file_exists(@amod_realpath($upload_dir . '/' . THUMB_DIR . '/t_' . $filename))) {
            return false;
        } else {
            return true;
        }
    } else {
        $found = false;
        $conn_id = attach_init_ftp(MODE_THUMBNAIL);
        $file_listing = array();
        $filename = 't_' . $filename;
        $file_listing = @ftp_rawlist($conn_id, $filename);
        for ($i = 0, $size = sizeof($file_listing); $i < $size; $i++) {
            if (ereg("([-d])[rwxst-]{9}.* ([0-9]*) ([a-zA-Z]+[0-9: ]*[0-9]) ([0-9]{2}:[0-9]{2}) (.+)", $file_listing[$i], $regs)) {
                if ($regs[1] == 'd') {
                    $dirinfo[0] = 1;
                    // Directory == 1
                }
                $dirinfo[1] = $regs[2];
                // Size
                $dirinfo[2] = $regs[3];
                // Date
                $dirinfo[3] = $regs[4];
                // Filename
                $dirinfo[4] = $regs[5];
                // Time
            }
            if ($dirinfo[0] != 1 && $dirinfo[4] == $filename) {
                $found = true;
            }
        }
        @ftp_quit($conn_id);
        return $found;
    }
}
开发者ID:GabrielAnca,项目名称:icy_phoenix,代码行数:42,代码来源:functions_admin.php

示例3: move_uploaded_attachment

 function move_uploaded_attachment($upload_mode, $file)
 {
     global $error, $error_msg, $lang, $upload_dir;
     if (!is_uploaded_file($file)) {
         message_die(GENERAL_ERROR, 'Unable to upload file. The given source has not been uploaded.', __LINE__, __FILE__);
     }
     switch ($upload_mode) {
         case 'copy':
             /*
             				$ini_val = ( phpversion() >= '4.0.0' ) ? 'ini_get' : 'get_cfg_var';
             
             				$tmp_path = ( !@$ini_val('safe_mode') ) ? '' : $upload_dir . '/tmp';
             
             				if ($tmp_path != '')
             				{
             					$tmp_filename = tempnam($tmp_path, 't0000');
             
             					$fd = fopen($file, 'r');
             					$data = fread ($fd, $this->filesize);
             					fclose ($fd);
             
             					$fptr = @fopen($tmp_filename, 'wb');
             					$bytes_written = @fwrite($fptr, $data, $this->filesize);
             					@fclose($fptr);
             					$file = $tmp_filename;
             				}
             */
             if (!@copy($file, $upload_dir . '/' . $this->attach_filename)) {
                 if (!@move_uploaded_file($file, $upload_dir . '/' . $this->attach_filename)) {
                     $error = TRUE;
                     if (!empty($error_msg)) {
                         $error_msg .= '<br />';
                     }
                     $error_msg .= sprintf($lang['General_upload_error'], './' . $upload_dir . '/' . $this->attach_filename);
                     return;
                 }
             }
             @chmod($upload_dir . '/' . $this->attach_filename, 0666);
             break;
         case 'move':
             if (!@move_uploaded_file($file, $upload_dir . '/' . $this->attach_filename)) {
                 if (!@copy($file, $upload_dir . '/' . $this->attach_filename)) {
                     $error = TRUE;
                     if (!empty($error_msg)) {
                         $error_msg .= '<br />';
                     }
                     $error_msg .= sprintf($lang['General_upload_error'], './' . $upload_dir . '/' . $this->attach_filename);
                     return;
                 }
             }
             @chmod($upload_dir . '/' . $this->attach_filename, 0666);
             /*				if ($tmp_path != '')
             				{
             					unlink_attach($file);
             				}*/
             break;
         case 'ftp':
             ftp_file($file, $this->attach_filename, $this->type);
             break;
     }
     if (!$error && $this->thumbnail == 1) {
         if ($upload_mode == 'ftp') {
             $source = $file;
             $dest_file = THUMB_DIR . '/t_' . $this->attach_filename;
         } else {
             $source = $upload_dir . '/' . $this->attach_filename;
             $dest_file = amod_realpath($upload_dir);
             $dest_file .= '/' . THUMB_DIR . '/t_' . $this->attach_filename;
         }
         if (!create_thumbnail($source, $dest_file, $this->type)) {
             if (!$file || !create_thumbnail($file, $dest_file, $this->type)) {
                 $this->thumbnail = 0;
             }
         }
     }
 }
开发者ID:forummaks,项目名称:forum_maks,代码行数:76,代码来源:posting_attachments.php

示例4: move_uploaded_attachment

 function move_uploaded_attachment($upload_mode, $file)
 {
     global $error, $error_msg, $lang, $upload_dir;
     if (!is_uploaded_file($file)) {
         message_die(GENERAL_ERROR, 'Unable to upload file. The given source has not been uploaded.', __LINE__, __FILE__);
     }
     switch ($upload_mode) {
         case 'copy':
             if (!@copy($file, $upload_dir . '/' . basename($this->attach_filename))) {
                 if (!@move_uploaded_file($file, $upload_dir . '/' . basename($this->attach_filename))) {
                     $error = TRUE;
                     if (!empty($error_msg)) {
                         $error_msg .= '<br />';
                     }
                     $error_msg .= sprintf($lang['General_upload_error'], './' . $upload_dir . '/' . $this->attach_filename);
                     return;
                 }
             }
             @chmod($upload_dir . '/' . basename($this->attach_filename), 0666);
             break;
         case 'move':
             if (!@move_uploaded_file($file, $upload_dir . '/' . basename($this->attach_filename))) {
                 if (!@copy($file, $upload_dir . '/' . basename($this->attach_filename))) {
                     $error = TRUE;
                     if (!empty($error_msg)) {
                         $error_msg .= '<br />';
                     }
                     $error_msg .= sprintf($lang['General_upload_error'], './' . $upload_dir . '/' . $this->attach_filename);
                     return;
                 }
             }
             @chmod($upload_dir . '/' . $this->attach_filename, 0666);
             break;
         case 'ftp':
             ftp_file($file, basename($this->attach_filename), $this->type);
             break;
     }
     if (!$error && $this->thumbnail == 1) {
         if ($upload_mode == 'ftp') {
             $source = $file;
             $dest_file = THUMB_DIR . '/t_' . basename($this->attach_filename);
         } else {
             $source = $upload_dir . '/' . basename($this->attach_filename);
             $dest_file = amod_realpath($upload_dir);
             $dest_file .= '/' . THUMB_DIR . '/t_' . basename($this->attach_filename);
         }
         if (!create_thumbnail($source, $dest_file, $this->type)) {
             if (!$file || !create_thumbnail($file, $dest_file, $this->type)) {
                 $this->thumbnail = 0;
             }
         }
     }
 }
开发者ID:BackupTheBerlios,项目名称:flushcms,代码行数:53,代码来源:posting_attachments.php

示例5: thumbnail_exists

function thumbnail_exists($filename)
{
    global $upload_dir, $attach_config;
    if (!intval($attach_config['allow_ftp_upload'])) {
        $found = file_exists(amod_realpath($upload_dir . '/' . THUMB_DIR . '/t_' . $filename));
    } else {
        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'] . '/' . THUMB_DIR, $attach_config['ftp_pasv_mode']);
        $found = $ftp->exists($filename);
        $ftp->close();
    }
    return $found;
}
开发者ID:cbsistem,项目名称:nexos,代码行数:13,代码来源:functions_attach.php

示例6: move_uploaded_attachment

 private function move_uploaded_attachment($file, $filename)
 {
     global $error, $error_msg, $lang, $upload_dir, $attach_config;
     if (intval($attach_config['allow_ftp_upload'])) {
         ftp_file($filename, $this->attach_filename, $this->type);
     } else {
         require_once 'includes/classes/cpg_file.php';
         if (!CPG_File::move_upload($file, $upload_dir . '/' . $this->attach_filename)) {
             $error = TRUE;
             if (!empty($error_msg)) {
                 $error_msg .= '<br />';
             }
             $error_msg .= sprintf($lang['General_upload_error'], './' . $upload_dir . '/' . $this->attach_filename);
             return;
         }
     }
     if (!$error && $this->thumbnail == 1) {
         if (intval($attach_config['allow_ftp_upload'])) {
             $source = $file;
             $dest_file = THUMB_DIR . '/t_' . $this->attach_filename;
         } else {
             $source = $upload_dir . '/' . $this->attach_filename;
             $dest_file = amod_realpath($upload_dir);
             $dest_file .= '/' . THUMB_DIR . '/t_' . $this->attach_filename;
         }
         if (!create_thumbnail($file, $dest_file, $this->type)) {
             if (!create_thumbnail($source, $dest_file, $this->type)) {
                 $this->thumbnail = 0;
             }
         }
     }
 }
开发者ID:cbsistem,项目名称:nexos,代码行数:32,代码来源:class.attachments.main.php

示例7: trim

 for ($i = 0; $i < $num_rows; $i++) {
     $attach_config[$row[$i]['config_name']] = trim($row[$i]['config_value']);
 }
 if ($attach_config['upload_dir'][0] == '/' || $attach_config['upload_dir'][0] != '/' && $attach_config['upload_dir'][1] == ':') {
     $upload_dir = $attach_config['upload_dir'];
 } else {
     $upload_dir = $phpbb_root_path . $attach_config['upload_dir'];
 }
 $upload_dir = $upload_dir . '/' . THUMB_DIR;
 $error = false;
 // Does the target directory exist, is it a directory and writeable. (only test if ftp upload is disabled)
 if (intval($attach_config['allow_ftp_upload']) == 0 && intval($attach_config['img_create_thumbnail']) == 1) {
     if (!@file_exists(@amod_realpath($upload_dir))) {
         @mkdir($upload_dir, 0755);
         @chmod($upload_dir, 0777);
         if (!@file_exists(@amod_realpath($upload_dir))) {
             $error = TRUE;
             $error_msg = sprintf($lang['Directory_does_not_exist'], $upload_dir) . '<br />';
         }
     }
     if (!$error && !is_dir($upload_dir)) {
         $error = TRUE;
         $error_msg = sprintf($lang['Directory_is_not_a_dir'], $upload_dir) . '<br />';
     }
     if (!$error) {
         if (!($fp = @fopen($upload_dir . '/0_000000.000', 'w'))) {
             $error = TRUE;
             $error_msg = sprintf($lang['Directory_not_writeable'], $upload_dir) . '<br />';
         } else {
             @fclose($fp);
             @unlink($upload_dir . '/0_000000.000');
开发者ID:nmpetkov,项目名称:ZphpBB2,代码行数:31,代码来源:admin_attachments.php

示例8: trim

     $attach_config[$row[$i]['config_name']] = trim($row[$i]['config_value']);
 }
 if ($attach_config['upload_dir'][0] == '/' || $attach_config['upload_dir'][0] != '/' && $attach_config['upload_dir'][1] == ':') {
     $upload_dir = $attach_config['upload_dir'];
 } else {
     $upload_dir = $attach_config['upload_dir'];
 }
 $upload_dir = $upload_dir . '/' . THUMB_DIR;
 $error = FALSE;
 //
 // Does the target directory exist, is it a directory and writeable. (only test if ftp upload is disabled)
 //
 if (intval($attach_config['allow_ftp_upload']) == 0 && intval($attach_config['img_create_thumbnail']) == 1) {
     if (!file_exists(amod_realpath($upload_dir))) {
         mkdir($upload_dir, PHP_AS_NOBODY ? 0777 : 0755);
         if (!file_exists(amod_realpath($upload_dir))) {
             $error = TRUE;
             $error_msg = sprintf($lang['Directory_does_not_exist'], $upload_dir) . '<br />';
         }
     }
     if (!$error && !is_dir($upload_dir)) {
         $error = TRUE;
         $error_msg = sprintf($lang['Directory_is_not_a_dir'], $upload_dir) . '<br />';
     }
     if (!$error) {
         if (!($fp = fopen($upload_dir . '/0_000000.000', 'w'))) {
             $error = TRUE;
             $error_msg = sprintf($lang['Directory_not_writeable'], $upload_dir) . '<br />';
         } else {
             fclose($fp);
             unlink($upload_dir . '/0_000000.000');
开发者ID:cbsistem,项目名称:nexos,代码行数:31,代码来源:admin_attachments.php

示例9: send_file_to_browser

function send_file_to_browser($attachment, $upload_dir)
{
    global $HTTP_USER_AGENT, $HTTP_SERVER_VARS, $lang, $db, $attach_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. :)
    //
    if (!empty($HTTP_SERVER_VARS['HTTP_USER_AGENT'])) {
        $HTTP_USER_AGENT = $HTTP_SERVER_VARS['HTTP_USER_AGENT'];
    } else {
        if (!isset($HTTP_USER_AGENT)) {
            $HTTP_USER_AGENT = '';
        }
    }
    if (ereg('Opera(/| )([0-9].[0-9]{1,2})', $HTTP_USER_AGENT, $log_version)) {
        $browser_version = $log_version[2];
        $browser_agent = 'opera';
    } else {
        if (ereg('MSIE ([0-9].[0-9]{1,2})', $HTTP_USER_AGENT, $log_version)) {
            $browser_version = $log_version[1];
            $browser_agent = 'ie';
        } else {
            if (ereg('OmniWeb/([0-9].[0-9]{1,2})', $HTTP_USER_AGENT, $log_version)) {
                $browser_version = $log_version[1];
                $browser_agent = 'omniweb';
            } else {
                if (ereg('Netscape([0-9]{1})', $HTTP_USER_AGENT, $log_version)) {
                    $browser_version = $log_version[1];
                    $browser_agent = 'netscape';
                } else {
                    if (ereg('Mozilla/([0-9].[0-9]{1,2})', $HTTP_USER_AGENT, $log_version)) {
                        $browser_version = $log_version[1];
                        $browser_agent = 'mozilla';
                    } else {
                        if (ereg('Konqueror/([0-9].[0-9]{1,2})', $HTTP_USER_AGENT, $log_version)) {
                            $browser_version = $log_version[1];
                            $browser_agent = 'konqueror';
                        } else {
                            $browser_version = 0;
                            $browser_agent = 'other';
                        }
                    }
                }
            }
        }
    }
    // Correct the mime type - we force application/octetstream for all files, except images
    // Please do not change this, it is a security precaution
    if (!strstr($attachment['mimetype'], 'image')) {
        $attachment['mimetype'] = $browser_agent == 'ie' || $browser_agent == 'opera' ? 'application/octetstream' : 'application/octet-stream';
    }
    // Now the tricky part... let's dance
    //	@ob_end_clean();
    //	@ini_set('zlib.output_compression', 'Off');
    header('Pragma: public');
    //	header('Content-Transfer-Encoding: none');
    $real_filename = html_entity_decode(basename($attachment['real_filename']));
    // Send out the Headers
    header('Content-Type: ' . $attachment['mimetype'] . '; name="' . $real_filename . '"');
    header('Content-Disposition: attachment; filename="' . $real_filename . '"');
    unset($real_filename);
    //
    // Now send the File Contents to the Browser
    //
    if ($gotit) {
        $size = @filesize($filename);
        if ($size) {
            header("Content-length: {$size}");
        }
        readfile($filename);
    } else {
        if (!$gotit && intval($attach_config['allow_ftp_upload'])) {
            $conn_id = attach_init_ftp();
            $ini_val = @phpversion() >= '4.0.0' ? 'ini_get' : 'get_cfg_var';
            $tmp_path = !@$ini_val('safe_mode') ? '/tmp' : $upload_dir;
            $tmp_filename = @tempnam($tmp_path, 't0000');
            @unlink($tmp_filename);
            $mode = FTP_BINARY;
            if (preg_match("/text/i", $attachment['mimetype']) || preg_match("/html/i", $attachment['mimetype'])) {
                $mode = FTP_ASCII;
            }
            $result = @ftp_get($conn_id, $tmp_filename, $filename, $mode);
            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.");
            }
            @ftp_quit($conn_id);
            $size = @filesize($tmp_filename);
            if ($size) {
                header("Content-length: {$size}");
            }
            readfile($tmp_filename);
//.........这里部分代码省略.........
开发者ID:Nekrofage,项目名称:FJR,代码行数:101,代码来源:download.php

示例10: send_file_to_browser

function send_file_to_browser($attachment, $upload_dir)
{
    global $_SERVER, $HTTP_USER_AGENT, $HTTP_SERVER_VARS, $lang, $attach_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;
        }
    }
    // Correct the mime type - we force application/octetstream for all files, except images
    // Please do not change this, it is a security precaution
    if (!strstr($attachment['mimetype'], 'image')) {
        $attachment['mimetype'] = $browser_agent == 'ie' || $browser_agent == 'opera' ? 'application/octetstream' : 'application/octet-stream';
    }
    //bt
    require_once FT_ROOT . 'includes/functions_torrent.php';
    send_torrent_with_passkey($filename);
    //bt end
    // Now the tricky part... let's dance
    //	@ob_end_clean();
    //	@ini_set('zlib.output_compression', 'Off');
    header('Pragma: public');
    //	header('Content-Transfer-Encoding: none');
    // Send out the Headers
    header('Content-Type: ' . $attachment['mimetype'] . '; name="' . clean_filename($attachment['real_filename']) . '"');
    header('Content-Disposition: inline; filename="' . clean_filename($attachment['real_filename']) . '"');
    //
    // Now send the File Contents to the Browser
    //
    if ($gotit) {
        $size = @filesize($filename);
        if ($size) {
            header("Content-length: {$size}");
        }
        readfile($filename);
    } else {
        if (!$gotit && intval($attach_config['allow_ftp_upload'])) {
            $conn_id = attach_init_ftp();
            $ini_val = @phpversion() >= '4.0.0' ? 'ini_get' : 'get_cfg_var';
            $tmp_path = !@$ini_val('safe_mode') ? '/tmp' : $upload_dir . '/tmp';
            $tmp_filename = @tempnam($tmp_path, 't0000');
            @unlink($tmp_filename);
            $mode = FTP_BINARY;
            if (preg_match("/text/i", $attachment['mimetype']) || preg_match("/html/i", $attachment['mimetype'])) {
                $mode = FTP_ASCII;
            }
            $result = @ftp_get($conn_id, $tmp_filename, $filename, $mode);
            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.");
            }
            @ftp_quit($conn_id);
            $size = @filesize($tmp_filename);
            if ($size) {
                header("Content-length: {$size}");
            }
            readfile($tmp_filename);
            @unlink($tmp_filename);
        } else {
            message_die(GENERAL_ERROR, $lang['Error_no_attachment'] . "<br /><br /><b>404 File Not Found:</b> The File <i>" . $filename . "</i> does not exist.");
        }
    }
    exit;
}
开发者ID:forummaks,项目名称:forum_maks,代码行数:66,代码来源:download.php

示例11: create_thumbnail

function create_thumbnail($source, $new_file)
{
    global $attach_config;
    $source = amod_realpath($source);
    $min_filesize = intval($attach_config['img_min_thumb_filesize']);
    $img_filesize = file_exists(amod_realpath($source)) ? filesize($source) : false;
    if (!$img_filesize || $img_filesize <= $min_filesize) {
        return FALSE;
    }
    $size = image_getdimension($source);
    if ($size[0] <= 0 && $size[1] <= 0) {
        return FALSE;
    }
    $new_size = get_img_size_format($size[0], $size[1]);
    $tmp_path = '';
    $old_file = '';
    if (intval($attach_config['allow_ftp_upload'])) {
        $old_file = $new_file;
        $tmp_path = explode('/', $source);
        $tmp_path[count($tmp_path) - 1] = '';
        $tmp_path = implode('/', $tmp_path);
        if ($tmp_path == '') {
            $tmp_path = '/tmp';
        }
        $value = trim($tmp_path);
        if ($value[strlen($value) - 1] == '/') {
            $value[strlen($value) - 1] = ' ';
        }
        $new_file = trim($value) . '/t00000';
    }
    global $MAIN_CFG;
    if (!isset($MAIN_CFG['imaging']['type'])) {
        //$attach_config['use_gd2']
        $MAIN_CFG['imaging']['type'] = empty($attach_config['img_imagick']) ? 'gd2' : 'im';
        $MAIN_CFG['imaging']['impath'] = $attach_config['img_imagick'];
        $MAIN_CFG['imaging']['pbmpath'] = $attach_config['img_imagick'];
    }
    require_once 'includes/imaging/imaging.inc';
    Graphic::resize($source, $new_size, $new_file, $size);
    if (!file_exists(amod_realpath($new_file))) {
        return FALSE;
    }
    if (intval($attach_config['allow_ftp_upload'])) {
        $result = ftp_file($new_file, $old_file, $this->type, TRUE);
        // True for disable error-mode
        if (!$result) {
            return FALSE;
        }
    } else {
        chmod($new_file, PHP_AS_NOBODY ? 0666 : 0644);
    }
    return TRUE;
}
开发者ID:cbsistem,项目名称:nexos,代码行数:53,代码来源:functions_thumbs.php

示例12: create_thumbnail

/**
* Create thumbnail
*/
function create_thumbnail($source, $new_file, $mimetype)
{
    global $attach_config, $imagick;
    $source = amod_realpath($source);
    $min_filesize = (int) $attach_config['img_min_thumb_filesize'];
    $img_filesize = @file_exists($source) ? @filesize($source) : false;
    if (!$img_filesize || $img_filesize <= $min_filesize) {
        return false;
    }
    list($width, $height, $type, ) = getimagesize($source);
    if (!$width || !$height) {
        return false;
    }
    list($new_width, $new_height) = get_img_size_format($width, $height);
    $tmp_path = $old_file = '';
    if (intval($attach_config['allow_ftp_upload'])) {
        $old_file = $new_file;
        $tmp_path = explode('/', $source);
        $tmp_path[count($tmp_path) - 1] = '';
        $tmp_path = implode('/', $tmp_path);
        if ($tmp_path == '') {
            $tmp_path = '/tmp';
        }
        $value = trim($tmp_path);
        if ($value[strlen($value) - 1] == '/') {
            $value[strlen($value) - 1] = ' ';
        }
        //
        $new_file = tempnam(trim($value), 't00000');
        // We remove it now because it gets created again later
        @unlink($new_file);
    }
    $used_imagick = false;
    if (is_imagick()) {
        passthru($imagick . ' -quality 85 -antialias -sample ' . $new_width . 'x' . $new_height . ' "' . str_replace('\\', '/', $source) . '" +profile "*" "' . str_replace('\\', '/', $new_file) . '"');
        if (@file_exists($new_file)) {
            $used_imagick = true;
        }
    }
    if (!$used_imagick) {
        $type = get_supported_image_types($type);
        if ($type['gd']) {
            switch ($type['format']) {
                case IMG_GIF:
                    $image = imagecreatefromgif($source);
                    break;
                case IMG_JPG:
                    $image = imagecreatefromjpeg($source);
                    break;
                case IMG_PNG:
                    $image = imagecreatefrompng($source);
                    break;
                case IMG_WBMP:
                    $image = imagecreatefromwbmp($source);
                    break;
            }
            if ($type['version'] == 1 || !$attach_config['use_gd2']) {
                $new_image = imagecreate($new_width, $new_height);
                imagecopyresized($new_image, $image, 0, 0, 0, 0, $new_width, $new_height, $width, $height);
            } else {
                $new_image = imagecreatetruecolor($new_width, $new_height);
                imagecopyresampled($new_image, $image, 0, 0, 0, 0, $new_width, $new_height, $width, $height);
            }
            switch ($type['format']) {
                case IMG_GIF:
                    imagegif($new_image, $new_file);
                    break;
                case IMG_JPG:
                    imagejpeg($new_image, $new_file, 90);
                    break;
                case IMG_PNG:
                    imagepng($new_image, $new_file);
                    break;
                case IMG_WBMP:
                    imagewbmp($new_image, $new_file);
                    break;
            }
            imagedestroy($new_image);
        }
    }
    if (!@file_exists($new_file)) {
        return false;
    }
    if (intval($attach_config['allow_ftp_upload'])) {
        $result = ftp_file($new_file, $old_file, $mimetype, true);
        // True for disable error-mode
        @unlink($new_file);
        if (!$result) {
            return false;
        }
    } else {
        @chmod($new_file, 0664);
    }
    return true;
}
开发者ID:puring0815,项目名称:OpenKore,代码行数:98,代码来源:functions_thumbs.php

示例13: init_display_template

function init_display_template($template_var, $replacement, $filename = 'forums/viewtopic_attach_body.html')
{
    global $template;
    //
    // Handle Attachment Informations
    //
    if (!isset($template->uncompiled_code[$template_var])) {
        // If we don't have a file assigned to this handle, die.
        if (!isset($template->files[$template_var])) {
            die("Template->loadfile(): No file specified for attachment handle {$template_var}");
        }
        $filename_2 = $template->files[$template_var];
        //		  die("Filename: $filename_2");
        $str = implode("", file($filename_2));
        if (empty($str)) {
            die("Template->loadfile(): File {$filename_2} for attachment handle {$template_var} is empty");
        }
        $template->uncompiled_code[$template_var] = $str;
    }
    $complete_filename = $filename;
    if (substr($complete_filename, 0, 1) != '/') {
        $complete_filename = $template->root . '/' . $complete_filename;
    }
    if (!file_exists(amod_realpath($complete_filename))) {
        die("Template->make_filename(): Error - file {$complete_filename} does not exist for displaying");
    }
    $content = implode('', file($complete_filename));
    if (empty($content)) {
        die('Template->loadfile(): File ' . $complete_filename . ' is empty');
    }
    // replace $replacement with uncompiled code in $filename
    $template->uncompiled_code[$template_var] = str_replace($replacement, $content, $template->uncompiled_code[$template_var]);
    //
    // Force Reload on cached version
    //
    display_compile_cache_clear($template->files[$template_var], $template_var);
}
开发者ID:cbsistem,项目名称:nexos,代码行数:37,代码来源:displaying.php

示例14: thumbnail_exists

/**
* Check if Thumbnail exist
*/
function thumbnail_exists($filename)
{
    global $upload_dir, $attach_config;
    $filename = basename($filename);
    if (!@file_exists(@amod_realpath($upload_dir . '/' . THUMB_DIR . '/t_' . $filename))) {
        return false;
    } else {
        return true;
    }
}
开发者ID:ErR163,项目名称:torrentpier,代码行数:13,代码来源:functions_attach.php

示例15: message_die

    message_die(GENERAL_MESSAGE, $lang['No_user_id_specified']);
}
$user_id = $user_id == '-1' ? ANONYMOUS : intval($user_id);
$profiledata = get_userdata($user_id);
if ($user_id == ANONYMOUS) {
    $profiledata['user_id'] = ANONYMOUS;
    $profiledata['username'] = $lang['Guest'];
} else {
    $profiledata['user_id'] = intval($profiledata['user_id']);
}
if ($profiledata['user_id'] != $userdata['user_id'] && $userdata['user_level'] != ADMIN) {
    message_die(GENERAL_MESSAGE, $lang['Not_Authorised']);
}
$page_title = $lang['User_acp_title'];
$language = $board_config['default_lang'];
if (!@file_exists(@amod_realpath($phpbb_root_path . 'language/lang_' . $language . '/lang_admin_attach.' . $phpEx))) {
    $language = $attach_config['board_lang'];
}
include $phpbb_root_path . 'language/lang_' . $language . '/lang_admin_attach.' . $phpEx;
$start = isset($HTTP_GET_VARS['start']) ? $HTTP_GET_VARS['start'] : 0;
if (isset($HTTP_POST_VARS['order'])) {
    $sort_order = $HTTP_POST_VARS['order'] == 'ASC' ? 'ASC' : 'DESC';
} else {
    if (isset($HTTP_GET_VARS['order'])) {
        $sort_order = $HTTP_GET_VARS['order'] == 'ASC' ? 'ASC' : 'DESC';
    } else {
        $sort_order = '';
    }
}
if (isset($HTTP_GET_VARS['mode']) || isset($HTTP_POST_VARS['mode'])) {
    $mode = isset($HTTP_POST_VARS['mode']) ? $HTTP_POST_VARS['mode'] : $HTTP_GET_VARS['mode'];
开发者ID:BackupTheBerlios,项目名称:phpbbsfp,代码行数:31,代码来源:profilcp_uacp.php


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