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


PHP file_ftp_get函数代码示例

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


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

示例1: print_bug_attachment_preview_text

/**
 * Prints the preview of a text file attachment.
 * @param array $p_attachment An attachment arrray from within the array returned by the file_get_visible_attachments() function
 */
function print_bug_attachment_preview_text($p_attachment)
{
    if (!$p_attachment['exists']) {
        return;
    }
    echo "\n<pre class=\"bug-attachment-preview-text\">";
    switch (config_get('file_upload_method')) {
        case DISK:
            if (file_exists($p_attachment['diskfile'])) {
                $t_content = file_get_contents($p_attachment['diskfile']);
            }
            break;
        case FTP:
            if (file_exists($p_attachment['diskfile'])) {
                $t_content = file_get_contents($p_attachment['diskfile']);
            } else {
                $t_ftp = file_ftp_connect();
                file_ftp_get($t_ftp, $p_attachment['diskfile'], $p_attachment['diskfile']);
                file_ftp_disconnect($t_ftp);
                if (file_exists($p_attachment['diskfile'])) {
                    $t_content = file_get_contents($p_attachment['diskfile']);
                }
            }
            break;
        default:
            $t_bug_file_table = db_get_table('bug_file');
            $c_attachment_id = db_prepare_int($p_attachment['id']);
            $t_query = "SELECT * FROM {$t_bug_file_table} WHERE id=" . db_param();
            $t_result = db_query_bound($t_query, array($c_attachment_id));
            $t_row = db_fetch_array($t_result);
            $t_content = $t_row['content'];
    }
    echo htmlspecialchars($t_content);
    echo '</pre>';
}
开发者ID:nextgens,项目名称:mantisbt,代码行数:39,代码来源:print_api.php

示例2: mci_file_get

/**
 * Returns the attachment contents
 *
 * @param int $p_file_id
 * @param string $p_type The file type, bug or doc
 * @param int $p_user_id
 * @return string|soap_fault the string contents, or a soap_fault
 */
function mci_file_get($p_file_id, $p_type, $p_user_id)
{
    # we handle the case where the file is attached to a bug
    # or attached to a project as a project doc.
    $query = '';
    switch ($p_type) {
        case 'bug':
            $t_bug_file_table = db_get_table('bug_file');
            $query = "SELECT *\n\t\t\t\tFROM {$t_bug_file_table}\n\t\t\t\tWHERE id='{$p_file_id}'";
            break;
        case 'doc':
            $t_project_file_table = db_get_table('project_file');
            $query = "SELECT *\n\t\t\t\tFROM {$t_project_file_table}\n\t\t\t\tWHERE id='{$p_file_id}'";
            break;
        default:
            return new soap_fault('Server', '', 'Invalid file type ' . $p_type . ' .');
    }
    $result = db_query($query);
    if ($result->EOF) {
        return new soap_fault('Client', '', 'Unable to find an attachment with type ' . $p_type . ' and id ' . $p_file_id . ' .');
    }
    $row = db_fetch_array($result);
    if ($p_type == 'doc') {
        $t_project_id = $row['project_id'];
    } else {
        if ($p_type == 'bug') {
            $t_bug_id = $row['bug_id'];
            $t_project_id = bug_get_field($t_bug_id, 'project_id');
        }
    }
    $t_diskfile = file_normalize_attachment_path($row['diskfile'], $t_project_id);
    $t_content = $row['content'];
    # Check access rights
    switch ($p_type) {
        case 'bug':
            if (!mci_file_can_download_bug_attachments($t_bug_id, $p_user_id)) {
                return mci_soap_fault_access_denied($p_user_id);
            }
            break;
        case 'doc':
            # Check if project documentation feature is enabled.
            if (OFF == config_get('enable_project_documentation')) {
                return mci_soap_fault_access_denied($p_user_id);
            }
            if (!access_has_project_level(config_get('view_proj_doc_threshold'), $t_project_id, $p_user_id)) {
                return mci_soap_fault_access_denied($p_user_id);
            }
            break;
    }
    # dump file content to the connection.
    switch (config_get('file_upload_method')) {
        case DISK:
            if (file_exists($t_diskfile)) {
                return mci_file_read_local($t_diskfile);
            } else {
                return new soap_fault('Client', '', 'Unable to find an attachment with type ' . $p_type . ' and id ' . $p_file_id . ' .');
            }
        case FTP:
            if (file_exists($t_diskfile)) {
                return mci_file_read_local($t_diskfile);
            } else {
                $ftp = file_ftp_connect();
                file_ftp_get($ftp, $t_diskfile, $t_diskfile);
                file_ftp_disconnect($ftp);
                return mci_file_read_local($t_diskfile);
            }
        default:
            return $t_content;
    }
}
开发者ID:nextgens,项目名称:mantisbt,代码行数:78,代码来源:mc_file_api.php

示例3: print_bug_attachments_list

function print_bug_attachments_list($p_bug_id)
{
    $t_attachments = file_get_visible_attachments($p_bug_id);
    $t_attachments_count = count($t_attachments);
    $i = 0;
    $image_previewed = false;
    foreach ($t_attachments as $t_attachment) {
        $t_file_display_name = string_display_line($t_attachment['display_name']);
        $t_filesize = number_format($t_attachment['size']);
        $t_date_added = date(config_get('normal_date_format'), $t_attachment['date_added']);
        if ($image_previewed) {
            $image_previewed = false;
            echo '<br />';
        }
        if ($t_attachment['can_download']) {
            $t_href_start = '<a href="' . string_attribute($t_attachment['download_url']) . '">';
            $t_href_end = '</a>';
            $t_href_clicket = " [<a href=\"file_download.php?file_id={$t_attachment['id']}&amp;type=bug\" target=\"_blank\">^</a>]";
        } else {
            $t_href_start = '';
            $t_href_end = '';
            $t_href_clicket = '';
        }
        if (!$t_attachment['exists']) {
            print_file_icon($t_file_display_name);
            echo '&#160;<span class="strike">' . $t_file_display_name . '</span>' . lang_get('word_separator') . '(' . lang_get('attachment_missing') . ')';
        } else {
            echo $t_href_start;
            print_file_icon($t_file_display_name);
            echo $t_href_end . '&#160;' . $t_href_start . $t_file_display_name . $t_href_end . $t_href_clicket . ' (' . $t_filesize . ' ' . lang_get('bytes') . ') ' . '<span class="italic">' . $t_date_added . '</span>';
        }
        if ($t_attachment['can_delete']) {
            echo '&#160;[';
            print_link('bug_file_delete.php?file_id=' . $t_attachment['id'] . form_security_param('bug_file_delete'), lang_get('delete_link'), false, 'small');
            echo ']';
        }
        if ($t_attachment['exists']) {
            if (FTP == config_get('file_upload_method') && $t_attachment['exists']) {
                echo ' (' . lang_get('cached') . ')';
            }
            if ($t_attachment['preview'] && $t_attachment['type'] == 'text') {
                $c_id = db_prepare_int($t_attachment['id']);
                $t_bug_file_table = db_get_table('mantis_bug_file_table');
                echo "<script type=\"text/javascript\" language=\"JavaScript\">\n<!--\nfunction swap_content( span ) {\ndisplayType = ( document.getElementById( span ).style.display == 'none' ) ? '' : 'none';\ndocument.getElementById( span ).style.display = displayType;\n}\n\n -->\n </script>";
                echo " <span id=\"hideSection_{$c_id}\">[<a class=\"small\" href='#' id='attmlink_" . $c_id . "' onclick='swap_content(\"hideSection_" . $c_id . "\");swap_content(\"showSection_" . $c_id . "\");return false;'>" . lang_get('show_content') . "</a>]</span>";
                echo " <span style='display:none' id=\"showSection_{$c_id}\">[<a class=\"small\" href='#' id='attmlink_" . $c_id . "' onclick='swap_content(\"hideSection_" . $c_id . "\");swap_content(\"showSection_" . $c_id . "\");return false;'>" . lang_get('hide_content') . "</a>]";
                echo "<pre>";
                /** @todo Refactor into a method that gets contents for download / preview. */
                switch (config_get('file_upload_method')) {
                    case DISK:
                        if ($t_attachment['exists']) {
                            $v_content = file_get_contents($t_attachment['diskfile']);
                        }
                        break;
                    case FTP:
                        if (file_exists($t_attachment['exists'])) {
                            file_get_contents($t_attachment['diskfile']);
                        } else {
                            $ftp = file_ftp_connect();
                            file_ftp_get($ftp, $t_attachment['diskfile'], $t_attachment['diskfile']);
                            file_ftp_disconnect($ftp);
                            $v_content = file_get_contents($t_attachment['diskfile']);
                        }
                        break;
                    default:
                        $query = "SELECT *\n\t                  \t\t\t\t\tFROM {$t_bug_file_table}\n\t\t\t\t            \t\t\tWHERE id=" . db_param();
                        $result = db_query_bound($query, array($c_id));
                        $row = db_fetch_array($result);
                        $v_content = $row['content'];
                }
                echo htmlspecialchars($v_content);
                echo "</pre></span>\n";
            }
            if ($t_attachment['can_download'] && $t_attachment['preview'] && $t_attachment['type'] == 'image') {
                $t_preview_style = 'border: 0;';
                $t_max_width = config_get('preview_max_width');
                if ($t_max_width > 0) {
                    $t_preview_style .= ' max-width:' . $t_max_width . 'px;';
                }
                $t_max_height = config_get('preview_max_height');
                if ($t_max_height > 0) {
                    $t_preview_style .= ' max-height:' . $t_max_height . 'px;';
                }
                $t_preview_style = 'style="' . $t_preview_style . '"';
                $t_title = file_get_field($t_attachment['id'], 'title');
                $t_image_url = $t_attachment['download_url'] . '&amp;show_inline=1' . form_security_param('file_show_inline');
                echo "\n<br />{$t_href_start}<img alt=\"{$t_title}\" {$t_preview_style} src=\"{$t_image_url}\" />{$t_href_end}";
                $image_previewed = true;
            }
        }
        if ($i != $t_attachments_count - 1) {
            echo "<br />\n";
            $i++;
        }
    }
}
开发者ID:Tarendai,项目名称:spring-website,代码行数:96,代码来源:print_api.php

示例4: header

# command when IE is used over HTTPS.
global $g_allow_file_cache;
if (isset($_SERVER["HTTPS"]) && "on" == $_SERVER["HTTPS"] && preg_match("/MSIE/", $_SERVER["HTTP_USER_AGENT"])) {
    # Suppress "Pragma: no-cache" header.
} else {
    if (!isset($g_allow_file_cache)) {
        header('Pragma: no-cache');
    }
}
header('Expires: ' . gmdate('D, d M Y H:i:s \\G\\M\\T', time()));
# dump file content to the connection.
switch (config_get('file_upload_method')) {
    case DISK:
        if (file_exists($v_diskfile)) {
            readfile($v_diskfile);
        }
        break;
    case FTP:
        if (file_exists($v_diskfile)) {
            readfile($v_diskfile);
        } else {
            $ftp = file_ftp_connect();
            file_ftp_get($ftp, $v_diskfile, $v_diskfile);
            file_ftp_disconnect($ftp);
            readfile($v_diskfile);
        }
        break;
    default:
        echo $v_content;
}
exit;
开发者ID:centaurustech,项目名称:BenFund,代码行数:31,代码来源:file_download.php

示例5: header

             $t_content_type = $t_content_type_override;
         }
         header('Content-Type: ' . $t_content_type);
         if (config_get('file_download_xsendfile_enabled')) {
             $t_xsendfile_header_name = config_get('file_download_xsendfile_header_name');
             header($t_xsendfile_header_name . ': ' . $t_local_disk_file);
         } else {
             readfile($t_local_disk_file);
         }
     }
     break;
 case FTP:
     $t_local_disk_file = file_normalize_attachment_path($v_diskfile, $t_project_id);
     if (!file_exists($t_local_disk_file)) {
         $ftp = file_ftp_connect();
         file_ftp_get($ftp, $t_local_disk_file, $v_diskfile);
         file_ftp_disconnect($ftp);
     }
     if ($finfo) {
         $t_file_info_type = $finfo->file($t_local_disk_file);
         if ($t_file_info_type !== false) {
             $t_content_type = $t_file_info_type;
         }
     }
     if ($t_content_type_override) {
         $t_content_type = $t_content_type_override;
     }
     header('Content-Type: ' . $t_content_type);
     readfile($t_local_disk_file);
     break;
 default:
开发者ID:N0ctrnl,项目名称:mantisbt,代码行数:31,代码来源:file_download.php

示例6: file_get_content

/**
 * Get file content
 *
 * @param int $p_file_id file id
 * @param string $p_type file type (either 'bug' or 'doc')
 * @return array|bool array containing file type and content or false on failure to retrieve file
 */
function file_get_content($p_file_id, $p_type = 'bug')
{
    # we handle the case where the file is attached to a bug
    # or attached to a project as a project doc.
    $query = '';
    switch ($p_type) {
        case 'bug':
            $t_bug_file_table = db_get_table('bug_file');
            $query = "SELECT *\n\t\t\t\tFROM {$t_bug_file_table}\n\t\t\t\tWHERE id=" . db_param();
            break;
        case 'doc':
            $t_project_file_table = db_get_table('project_file');
            $query = "SELECT *\n\t\t\t\tFROM {$t_project_file_table}\n\t\t\t\tWHERE id=" . db_param();
            break;
        default:
            return false;
    }
    $result = db_query_bound($query, array($p_file_id));
    $row = db_fetch_array($result);
    if ($f_type == 'bug') {
        $t_project_id = bug_get_field($row['bug_id'], 'project_id');
    } else {
        $t_project_id = $row['bug_id'];
    }
    # If finfo is available (always true for PHP >= 5.3.0) we can use it to determine the MIME type of files
    $finfo_available = false;
    if (class_exists('finfo')) {
        $t_info_file = config_get('fileinfo_magic_db_file');
        if (is_blank($t_info_file)) {
            $finfo = new finfo(FILEINFO_MIME);
        } else {
            $finfo = new finfo(FILEINFO_MIME, $t_info_file);
        }
        if ($finfo) {
            $finfo_available = true;
        }
    }
    $t_content_type = $row['file_type'];
    switch (config_get('file_upload_method')) {
        case DISK:
            $t_local_disk_file = file_normalize_attachment_path($row['diskfile'], $t_project_id);
            if (file_exists($t_local_disk_file)) {
                if ($finfo_available) {
                    $t_file_info_type = $finfo->file($t_local_disk_file);
                    if ($t_file_info_type !== false) {
                        $t_content_type = $t_file_info_type;
                    }
                }
                return array('type' => $t_content_type, 'content' => file_get_contents($t_local_disk_file));
            }
            break;
        case FTP:
            $t_local_disk_file = file_normalize_attachment_path($row['diskfile'], $t_project_id);
            if (!file_exists($t_local_disk_file)) {
                $ftp = file_ftp_connect();
                file_ftp_get($ftp, $t_local_disk_file, $row['diskfile']);
                file_ftp_disconnect($ftp);
            }
            if ($finfo_available) {
                $t_file_info_type = $finfo->file($t_local_disk_file);
                if ($t_file_info_type !== false) {
                    $t_content_type = $t_file_info_type;
                }
            }
            return array('type' => $t_content_type, 'content' => file_get_contents($t_local_disk_file));
            break;
        default:
            if ($finfo_available) {
                $t_file_info_type = $finfo->buffer($row['content']);
                if ($t_file_info_type !== false) {
                    $t_content_type = $t_file_info_type;
                }
            }
            return array('type' => $t_content_type, 'content' => $row['content']);
            break;
    }
}
开发者ID:rasperen,项目名称:mantisbt,代码行数:84,代码来源:file_api.php

示例7: mci_file_get

function mci_file_get($p_file_id, $p_type, $p_user_id)
{
    # we handle the case where the file is attached to a bug
    # or attached to a project as a project doc.
    $query = '';
    switch ($p_type) {
        case 'bug':
            $t_bug_file_table = config_get('mantis_bug_file_table');
            $query = "SELECT *\r\n\t\t\t\t\tFROM {$t_bug_file_table}\r\n\t\t\t\t\tWHERE id='{$p_file_id}'";
            break;
        case 'doc':
            $t_project_file_table = config_get('mantis_project_file_table');
            $query = "SELECT *\r\n\t\t\t\t\tFROM {$t_project_file_table}\r\n\t\t\t\t\tWHERE id='{$p_file_id}'";
            break;
        default:
            return new soap_fault('Client', '', 'Access Denied');
    }
    $result = db_query($query);
    $row = db_fetch_array($result);
    extract($row, EXTR_PREFIX_ALL, 'v');
    # Check access rights
    switch ($p_type) {
        case 'bug':
            if (!mci_file_can_download_bug_attachments($v_bug_id, $p_user_id)) {
                return new soap_fault('Client', '', 'Access Denied');
            }
            break;
        case 'doc':
            # Check if project documentation feature is enabled.
            if (OFF == config_get('enable_project_documentation')) {
                return new soap_fault('Client', '', 'Access Denied');
            }
            if (!access_has_project_level(config_get('view_proj_doc_threshold'), $v_project_id, $p_user_id)) {
                return new soap_fault('Client', '', 'Access Denied');
            }
            break;
    }
    # dump file content to the connection.
    switch (config_get('file_upload_method')) {
        case DISK:
            if (file_exists($v_diskfile)) {
                return base64_encode(mci_file_read_local($v_diskfile));
            } else {
                return null;
            }
        case FTP:
            if (file_exists($v_diskfile)) {
                return base64_encode(mci_file_read_local($v_diskfile));
            } else {
                $ftp = file_ftp_connect();
                file_ftp_get($ftp, $v_diskfile, $v_diskfile);
                file_ftp_disconnect($ftp);
                return base64_encode(mci_file_read_local($v_diskfile));
            }
        default:
            return base64_encode($v_content);
    }
}
开发者ID:amjadtbssm,项目名称:website,代码行数:58,代码来源:mc_file_api.php

示例8: file_list_attachments

function file_list_attachments($p_bug_id)
{
    $t_attachment_rows = bug_get_attachments($p_bug_id);
    $num_files = sizeof($t_attachment_rows);
    if ($num_files === 0) {
        return;
    }
    $t_can_download = file_can_download_bug_attachments($p_bug_id);
    $t_can_delete = file_can_delete_bug_attachments($p_bug_id);
    $t_preview_text_ext = config_get('preview_text_extensions');
    $t_preview_image_ext = config_get('preview_image_extensions');
    $image_previewed = false;
    for ($i = 0; $i < $num_files; $i++) {
        $row = $t_attachment_rows[$i];
        extract($row, EXTR_PREFIX_ALL, 'v');
        $t_file_display_name = string_display_line(file_get_display_name($v_filename));
        $t_filesize = number_format($v_filesize);
        $t_date_added = date(config_get('normal_date_format'), db_unixtimestamp($v_date_added));
        if ($image_previewed) {
            $image_previewed = false;
            print '<br />';
        }
        if ($t_can_download) {
            $t_href_start = "<a href=\"file_download.php?file_id={$v_id}&amp;type=bug\">";
            $t_href_end = '</a>';
            $t_href_clicket = " [<a href=\"file_download.php?file_id={$v_id}&amp;type=bug\" target=\"_blank\">^</a>]";
        } else {
            $t_href_start = '';
            $t_href_end = '';
            $t_href_clicket = '';
        }
        $t_exists = config_get('file_upload_method') != DISK || file_exists($v_diskfile);
        if (!$t_exists) {
            print_file_icon($t_file_display_name);
            print '&nbsp;<span class="strike">' . $t_file_display_name . '</span> (attachment missing)';
        } else {
            print $t_href_start;
            print_file_icon($t_file_display_name);
            print $t_href_end . '&nbsp;' . $t_href_start . $t_file_display_name . $t_href_end . "{$t_href_clicket} ({$t_filesize} bytes) <span class=\"italic\">{$t_date_added}</span>";
            if ($t_can_delete) {
                print " [<a class=\"small\" href=\"bug_file_delete.php?file_id={$v_id}\">" . lang_get('delete_link') . '</a>]';
            }
            if (FTP == config_get('file_upload_method') && file_exists($v_diskfile)) {
                print ' (' . lang_get('cached') . ')';
            }
            if ($t_can_download && $v_filesize <= config_get('preview_attachments_inline_max_size') && $v_filesize != 0 && in_array(strtolower(file_get_extension($t_file_display_name)), $t_preview_text_ext, true)) {
                $c_id = db_prepare_int($v_id);
                $t_bug_file_table = config_get('mantis_bug_file_table');
                echo "<script type=\"text/javascript\" language=\"JavaScript\">\r\n<!--\r\nfunction swap_content( span ) {\r\ndisplayType = ( document.getElementById( span ).style.display == 'none' ) ? '' : 'none';\r\ndocument.getElementById( span ).style.display = displayType;\r\n}\r\n\r\n -->\r\n </script>";
                print " <span id=\"hideSection_{$c_id}\">[<a class=\"small\" href='#' id='attmlink_" . $c_id . "' onclick='swap_content(\"hideSection_" . $c_id . "\");swap_content(\"showSection_" . $c_id . "\");return false;'>" . lang_get('show_content') . "</a>]</span>";
                print " <span style='display:none' id=\"showSection_{$c_id}\">[<a class=\"small\" href='#' id='attmlink_" . $c_id . "' onclick='swap_content(\"hideSection_" . $c_id . "\");swap_content(\"showSection_" . $c_id . "\");return false;'>" . lang_get('hide_content') . "</a>]";
                print "<pre>";
                switch (config_get('file_upload_method')) {
                    case DISK:
                        if (file_exists($v_diskfile)) {
                            $v_content = file_get_contents($v_diskfile);
                        }
                        break;
                    case FTP:
                        if (file_exists($v_diskfile)) {
                            file_get_contents($v_diskfile);
                        } else {
                            $ftp = file_ftp_connect();
                            file_ftp_get($ftp, $v_diskfile, $v_diskfile);
                            file_ftp_disconnect($ftp);
                            $v_content = file_get_contents($v_diskfile);
                        }
                        break;
                    default:
                        $query = "SELECT *\r\n\t                  \t\t\t\t\t\tFROM {$t_bug_file_table}\r\n\t\t\t\t            \t\t\tWHERE id='{$c_id}'";
                        $result = db_query($query);
                        $row = db_fetch_array($result);
                        $v_content = $row['content'];
                }
                echo htmlspecialchars($v_content);
                print "</pre></span>\n";
            }
            if ($t_can_download && $v_filesize <= config_get('preview_attachments_inline_max_size') && $v_filesize != 0 && in_array(strtolower(file_get_extension($t_file_display_name)), $t_preview_image_ext, true)) {
                $t_preview_style = 'border: 0;';
                $t_max_width = config_get('preview_max_width');
                if ($t_max_width > 0) {
                    $t_preview_style .= ' max-width:' . $t_max_width . 'px;';
                }
                $t_max_height = config_get('preview_max_height');
                if ($t_max_height > 0) {
                    $t_preview_style .= ' max-height:' . $t_max_height . 'px;';
                }
                $t_preview_style = 'style="' . $t_preview_style . '"';
                $t_title = file_get_field($v_id, 'title');
                print "\n<br />{$t_href_start}<img alt=\"{$t_title}\" {$t_preview_style} src=\"file_download.php?file_id={$v_id}&amp;type=bug\" />{$t_href_end}";
                $image_previewed = true;
            }
        }
        if ($i != $num_files - 1) {
            print "<br />\n";
        }
    }
}
开发者ID:amjadtbssm,项目名称:website,代码行数:98,代码来源:file_api.php


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