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


PHP Files::get_path方法代码示例

本文整理汇总了PHP中Files::get_path方法的典型用法代码示例。如果您正苦于以下问题:PHP Files::get_path方法的具体用法?PHP Files::get_path怎么用?PHP Files::get_path使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Files的用法示例。


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

示例1: layout

 /**
  * list images
  *
  * @param resource the SQL result
  * @return string the rendered text
  *
  * @see layouts/layout.php
  **/
 function layout($result)
 {
     global $context;
     // empty list
     if (!SQL::count($result)) {
         $output = array();
         return $output;
     }
     // we return an array of ($url => $attributes)
     $items = array();
     // process all items in the list
     while ($item = SQL::fetch($result)) {
         // get the anchor for this image
         if ($item['anchor']) {
             $anchor = Anchors::get($item['anchor']);
         }
         // url to view the image
         $url = $context['url_to_home'] . $context['url_to_root'] . Images::get_url($item['id']);
         // time of last update
         $time = SQL::strtotime($item['edit_date']);
         // the title as the label
         if ($item['title']) {
             $label = ucfirst($item['title']) . ' (' . $item['image_name'] . ')';
         } else {
             $label = $item['image_name'];
         }
         // the section
         $section = '';
         if (is_object($anchor)) {
             $section = ucfirst($anchor->get_title());
         }
         // the author(s) is an e-mail address, according to rss 2.0 spec
         $author = $item['create_address'] . ' (' . $item['create_name'] . ')';
         if ($item['create_address'] != $item['edit_address']) {
             if ($author) {
                 $author .= ', ';
             }
             $author .= $item['edit_address'] . ' (' . $item['edit_name'] . ')';
         }
         // the description
         $description = Codes::beautify($item['description']);
         // cap the number of words
         $description = Skin::cap($description, 300);
         // fix image references
         $description = preg_replace('#"/([^">]+?)"#', '"' . $context['url_to_home'] . '/$1"', $description);
         $introduction = $description;
         // other rss fields
         $extensions = array();
         // url for enclosure
         $type = Files::get_mime_type($item['image_name']);
         $extensions[] = '<enclosure url="' . $context['url_to_home'] . $context['url_to_root'] . Files::get_path($item['anchor'], 'images') . '/' . $item['image_name'] . '"' . ' length="' . $item['image_size'] . '"' . ' type="' . $type . '" />';
         // list all components for this item
         $items[$url] = array($time, $label, $author, $section, NULL, $introduction, $description, $extensions);
     }
     // end of processing
     SQL::free($result);
     return $items;
 }
开发者ID:rair,项目名称:yacs,代码行数:66,代码来源:layout_images_as_feed.php

示例2: render_embed


//.........这里部分代码省略.........
             if ($flashvars) {
                 $flashvars = str_replace('autostart=true', 'autoplay=1', $flashvars) . '&';
             }
             $flashvars .= 'width=' . $width . '&height=' . $height;
             // if there is a static image for this video, use it
             if (isset($item['icon_url']) && $item['icon_url']) {
                 $flashvars .= '&startimage=' . urlencode($item['icon_url']);
             }
             // if there is a subtitle file for this video, use it
             if (isset($item['file_name']) && ($srt = 'files/' . str_replace(':', '/', $item['anchor']) . '/' . str_replace('.' . $extension, '.srt', $item['file_name'])) && file_exists($context['path_to_root'] . $srt)) {
                 $flashvars .= '&srt=1&srturl=' . urlencode($context['url_to_home'] . $context['url_to_root'] . $srt);
             }
             // if there is a logo file in the skin, use it
             Skin::define_img_href('FLV_IMG_HREF', 'codes/flvplayer_logo.png', '');
             if (FLV_IMG_HREF) {
                 $flashvars .= '&top1=' . urlencode(FLV_IMG_HREF . '|10|10');
             }
             // rely on Flash
             if (Surfer::has_flash()) {
                 // the full object is built in Javascript --see parameters at http://flv-player.net/players/maxi/documentation/
                 $output = '<div id="flv_' . $item['id'] . '" class="no_print">Flash plugin or Javascript are turned off. Activate both and reload to view the object</div>' . "\n";
                 Page::insert_script('var flashvars = { flv:"' . $url . '", ' . str_replace(array('&', '='), array('", ', ':"'), $flashvars) . '", autoload:0, margin:1, showiconplay:1, playeralpha:50, iconplaybgalpha:30, showfullscreen:1, showloading:"always", ondoubleclick:"fullscreen" }' . "\n" . 'var params = { allowfullscreen: "true", allowscriptaccess: "always" }' . "\n" . 'var attributes = { id: "file_' . $item['id'] . '", name: "file_' . $item['id'] . '"}' . "\n" . 'swfobject.embedSWF("' . $flvplayer_url . '", "flv_' . $item['id'] . '", "' . $width . '", "' . $height . '", "9", "' . $context['url_to_home'] . $context['url_to_root'] . 'included/browser/expressinstall.swf", flashvars, params);' . "\n");
                 // native support
             } else {
                 // <video> is HTML5, <object> is legacy
                 $output = '<video width="' . $width . '" height="' . $height . '" autoplay="" controls="" src="' . $url . '" >' . "\n" . '	<object width="' . $width . '" height="' . $height . '" data="' . $url . '" type="' . Files::get_mime_type($item['file_name']) . '">' . "\n" . '		<param value="' . $url . '" name="movie" />' . "\n" . '		<param value="true" name="allowFullScreen" />' . "\n" . '		<param value="always" name="allowscriptaccess" />' . "\n" . '		<a href="' . $url . '">No video playback capabilities, please download the file</a>' . "\n" . '	</object>' . "\n" . '</video>' . "\n";
             }
             // job done
             return $output;
             // a ganttproject timeline
         // a ganttproject timeline
         case 'gan':
             // where the file is
             $path = Files::get_path($item['anchor']) . '/' . rawurlencode($item['file_name']);
             // we actually use a transformed version of the file
             $cache_id = Cache::hash($path) . '.xml';
             // apply the transformation
             if (!file_exists($context['path_to_root'] . $cache_id) || filemtime($context['path_to_root'] . $cache_id) < filemtime($context['path_to_root'] . $path) || !($text = Safe::file_get_contents($context['path_to_root'] . $cache_id))) {
                 // transform from GanttProject to SIMILE Timeline
                 $text = Files::transform_gan_to_simile($path);
                 // put in cache
                 Safe::file_put_contents($cache_id, $text);
             }
             // load the SIMILE Timeline javascript library in shared/global.php
             $context['javascript']['timeline'] = TRUE;
             // cache would kill the loading of the library
             cache::poison();
             // 1 week ago
             $now = gmdate('M d Y H:i:s', time() - 7 * 24 * 60 * 60);
             // load the right file
             $output = '<div id="gantt" style="height: ' . $height . '; width: ' . $width . '; border: 1px solid #aaa; font-family: Trebuchet MS, Helvetica, Arial, sans serif; font-size: 8pt"></div>' . "\n";
             Page::insert_script('var simile_handle;' . "\n" . 'function onLoad() {' . "\n" . '  var eventSource = new Timeline.DefaultEventSource();' . "\n" . '	var theme = Timeline.ClassicTheme.create();' . "\n" . '            theme.event.bubble.width = 350;' . "\n" . '            theme.event.bubble.height = 300;' . "\n" . '  var bandInfos = [' . "\n" . '    Timeline.createBandInfo({' . "\n" . '        eventSource:    eventSource,' . "\n" . '        date:           "' . $now . '",' . "\n" . '        width:          "80%",' . "\n" . '        intervalUnit:   Timeline.DateTime.WEEK,' . "\n" . '        intervalPixels: 200,' . "\n" . '		  theme:          theme,' . "\n" . '        layout:         "original"  // original, overview, detailed' . "\n" . '    }),' . "\n" . '    Timeline.createBandInfo({' . "\n" . '        showEventText: false,' . "\n" . '        trackHeight: 0.5,' . "\n" . '        trackGap: 0.2,' . "\n" . '        eventSource:    eventSource,' . "\n" . '        date:           "' . $now . '",' . "\n" . '        width:          "20%",' . "\n" . '        intervalUnit:   Timeline.DateTime.MONTH,' . "\n" . '        intervalPixels: 50' . "\n" . '    })' . "\n" . '  ];' . "\n" . '  bandInfos[1].syncWith = 0;' . "\n" . '  bandInfos[1].highlight = true;' . "\n" . '  bandInfos[1].eventPainter.setLayout(bandInfos[0].eventPainter.getLayout());' . "\n" . '  simile_handle = Timeline.create(document.getElementById("gantt"), bandInfos, Timeline.HORIZONTAL);' . "\n" . '	simile_handle.showLoadingMessage();' . "\n" . '  Timeline.loadXML("' . $context['url_to_home'] . $context['url_to_root'] . $cache_id . '", function(xml, url) { eventSource.loadXML(xml, url); });' . "\n" . '	simile_handle.hideLoadingMessage();' . "\n" . '}' . "\n" . "\n" . 'var resizeTimerID = null;' . "\n" . 'function onResize() {' . "\n" . '    if (resizeTimerID == null) {' . "\n" . '        resizeTimerID = window.setTimeout(function() {' . "\n" . '            resizeTimerID = null;' . "\n" . '            simile_handle.layout();' . "\n" . '        }, 500);' . "\n" . '    }' . "\n" . '}' . "\n" . "\n" . '// observe page major events' . "\n" . '$(document).ready( onLoad);' . "\n" . '$(window).resize(onResize);' . "\n");
             // job done
             return $output;
             // a Freemind map
         // a Freemind map
         case 'mm':
             // if we have an external reference, use it
             if (isset($item['file_href']) && $item['file_href']) {
                 $target_href = $item['file_href'];
                 // else redirect to ourself
             } else {
                 // ensure a valid file name
                 $file_name = utf8::to_ascii($item['file_name']);
                 // where the file is
                 $path = Files::get_path($item['anchor']) . '/' . rawurlencode($item['file_name']);
开发者ID:rair,项目名称:yacs,代码行数:67,代码来源:code_embed.php

示例3: elseif

 $context['page_title'] = i18n::s('Thank you for your contribution');
 // the page has been published
 if (isset($_REQUEST['publish_date']) && $_REQUEST['publish_date'] > NULL_DATE) {
     $context['text'] .= '<p>' . i18n::s('The page has been successfully posted. Please review it now to ensure that it reflects your mind.') . '</p>';
 } elseif (Surfer::is_empowered()) {
     $context['text'] .= i18n::s('<p>Don\'t forget to publish the new page someday. Review the page, enhance it and then click on the Publish command to make it publicly available.</p>');
 } elseif (isset($context['users_with_auto_publish']) && $context['users_with_auto_publish'] == 'Y' || is_object($anchor) && $anchor->has_option('auto_publish')) {
     $context['text'] .= i18n::s('<p>Don\'t forget to publish the new page someday. Review the page, enhance it and then click on the Publish command to make it publicly available.</p>');
 } else {
     $context['text'] .= i18n::s('<p>The new page will now be reviewed before its publication. It is likely that this will be done within the next 24 hours at the latest.</p>');
 }
 if (!isset($_REQUEST['first_comment'])) {
     $_REQUEST['first_comment'] = '';
 }
 // attach some file
 $file_path = Files::get_path('article:' . $_REQUEST['id']);
 if (isset($_FILES['upload']) && ($uploaded = Files::upload($_FILES['upload'], $file_path, 'article:' . $_REQUEST['id']))) {
     // several files have been added
     if (is_array($uploaded)) {
         $_REQUEST['first_comment'] .= '<div>' . Skin::build_list(Files::list_for_anchor_and_name('article:' . $_REQUEST['id'], $uploaded, 'compact'), 'compact') . '</div>';
     } elseif ($file =& Files::get_by_anchor_and_name('article:' . $_REQUEST['id'], $uploaded)) {
         $_REQUEST['first_comment'] .= '<div>' . Codes::render_object('file', $file['id']) . '</div>';
         // silently delete the previous file if the name has changed
         if (isset($file['file_name']) && $file['file_name'] != $uploaded) {
             Safe::unlink($file_path . '/' . $file['file_name']);
         }
     }
 }
 // capture first comment too
 if (isset($_REQUEST['first_comment']) && $_REQUEST['first_comment']) {
     include_once $context['path_to_root'] . 'comments/comments.php';
开发者ID:rair,项目名称:yacs,代码行数:31,代码来源:edit_as_thread.php

示例4: fpassthru

                // validate content in cache
                if (http::validate($last_modified)) {
                    return;
                }
                // actual transmission except on a HEAD request
                if (isset($_SERVER['REQUEST_METHOD']) && $_SERVER['REQUEST_METHOD'] != 'HEAD') {
                    fpassthru($handle);
                }
                fclose($handle);
            }
            // the post-processing hook, then exit even on HEAD
            finalize_page();
            return;
        }
        // redirect to the actual file
        $target_href = $context['url_to_home'] . $context['url_to_root'] . Files::get_path($item['anchor']) . '/' . rawurlencode($item['file_name']);
    }
    // let the web server provide the actual file
    if (!headers_sent()) {
        Safe::header('Status: 302 Found', TRUE, 302);
        Safe::header('Location: ' . $target_href);
        // this one may be blocked by anti-popup software
    } else {
        $context['site_head'] .= '<meta http-equiv="Refresh" content="1;url=' . $target_href . '" />' . "\n";
    }
    // help the surfer
    $context['text'] .= '<p>' . i18n::s('You are requesting the following file:') . '</p>' . "\n";
    $context['text'] .= '<p><a href="' . encode_field($target_href) . '">' . basename($target_href) . '</a></p>' . "\n";
    // automatic or not
    $context['text'] .= '<p>' . i18n::s('The download should start automatically within seconds. Else hit the provided link to trigger it manually.') . '</p>' . "\n";
}
开发者ID:rair,项目名称:yacs,代码行数:31,代码来源:fetch.php

示例5: urlencode

        $fields['thumbnail_url'] = $context['url_to_master'] . $context['url_to_root'] . Files::get_path($target->get_reference()) . '/thumbs/' . urlencode($file->item['file_name']);
    }
    $output['success'] = $file->set_values($fields);
    // move file physicaly
    if ($output['success']) {
        $from = $context['path_to_root'] . Files::get_path($last_parent->get_reference()) . '/' . $file->item['file_name'];
        $dir = $context['path_to_root'] . Files::get_path($target->get_reference());
        $to = $dir . '/' . $file->item['file_name'];
        // check that dir exists
        if (!is_dir($dir)) {
            Safe::make_path($dir);
        }
        Safe::rename($from, $to);
        // move thumb if any
        if ($file->item['thumbnail_url']) {
            $from = Files::get_path($last_parent->get_reference()) . '/thumbs/' . $file->item['file_name'];
            // make directory thumbs
            $to = $dir . '/thumbs/' . $file->item['file_name'];
            // check that dir exist
            if (!is_dir($dir . '/thumbs')) {
                Safe::mkdir($dir . '/thumbs');
            }
            Safe::rename($from, $to);
        }
    }
}
// we return some JSON
$output = json_encode($output);
// allow for data compression
render_raw('application/json; charset=' . $context['charset']);
// actual transmission except on a HEAD request
开发者ID:rair,项目名称:yacs,代码行数:31,代码来源:move.php

示例6: rawurlencode

        Safe::header('Status: 401 Unauthorized', TRUE, 401);
    }
    // permission denied to authenticated user
    Safe::header('Status: 401 Unauthorized', TRUE, 401);
    Logger::error(i18n::s('You are not allowed to perform this operation.'));
    // stream this file
} else {
    // if we have an external reference, use it
    if (isset($item['file_href']) && $item['file_href']) {
        $target_href = $item['file_href'];
        // else redirect to ourself
    } else {
        // ensure a valid file name
        $file_name = utf8::to_ascii($item['file_name']);
        // where the file is
        $path = Files::get_path($item['anchor']) . '/' . rawurlencode($item['file_name']);
        // redirect to the actual file
        $target_href = $context['url_to_home'] . $context['url_to_root'] . $path;
    }
    // determine attribute for this item
    $type = $mime = $text = '';
    // the default is to provide the file directly
    $fetched = FALSE;
    // embed the file depending on the file type
    $extension = strtolower(@array_pop(@explode('.', @basename($item['file_name']))));
    switch ($extension) {
        case 'aif':
        case 'aiff':
        case 'au':
        case 'mka':
        case 'mp3':
开发者ID:rair,项目名称:yacs,代码行数:31,代码来源:stream.php

示例7: sprintf

         // save content of the overlay in this item
         $_REQUEST['overlay'] = $overlay->save();
         $_REQUEST['overlay_id'] = $overlay->get_id();
     }
     // save in the database
     Files::post($_REQUEST);
     // log record creation
     if (!$item['id']) {
         $label = sprintf(i18n::c('New file in %s'), strip_tags($anchor->get_title()));
         $link = $context['url_to_home'] . $context['url_to_root'] . Files::get_url($_REQUEST['id']);
         $description = sprintf(i18n::c('%s at %s'), $_REQUEST['file_name'], '<a href="' . $link . '">' . $link . '</a>');
         Logger::notify('files/edit.php: ' . $label, $description);
     }
     // a file has been uploaded
 } elseif (Files::get_uploaded('upload', 'name')) {
     $file_path = Files::get_path($_REQUEST['anchor']);
     // update an existing file record
     if (isset($item['id'])) {
         Files::set_uploaded('upload', 'id', $item['id']);
     }
     // attach some file
     if ($uploaded = Files::upload(Files::get_uploaded('upload'), $file_path, $anchor->get_reference(), $overlay)) {
         // actually, a new file
         if (!isset($item['id'])) {
             $action = 'file:create';
         } else {
             $action = 'file:upload';
         }
         // several files have been added
         if (is_array($uploaded)) {
             $compact_list = Skin::build_list(Files::list_for_anchor_and_name($anchor->get_reference(), $uploaded, 'compact'), 'compact');
开发者ID:rair,项目名称:yacs,代码行数:31,代码来源:edit.php

示例8: array

     $rows[] = array(i18n::s('Source'), $item['source']);
 }
 // keywords
 if ($item['keywords']) {
     $rows[] = array(i18n::s('Keywords'), $item['keywords']);
 }
 // display these details
 $context['text'] .= Skin::table(NULL, $rows);
 // insert anchor prefix
 if (is_object($anchor)) {
     $context['text'] .= $anchor->get_prefix();
 }
 // if we have a local file
 if (!isset($item['file_href']) || !$item['file_href']) {
     // where the file is
     $path = $context['path_to_root'] . Files::get_path($item['anchor']) . '/' . rawurlencode(utf8::to_ascii($item['file_name']));
     //load some file parser if one is available
     $analyzer = NULL;
     if (is_readable($context['path_to_root'] . 'included/getid3/getid3.php')) {
         include_once $context['path_to_root'] . 'included/getid3/getid3.php';
         $analyzer = new getid3();
     }
     // parse file content, and streamline information
     $data = array();
     if (is_object($analyzer) && Files::is_stream($item['file_name'])) {
         $data = $analyzer->analyze($path);
         getid3_lib::CopyTagsToComments($data);
     }
     // details
     $rows = array();
     // artist
开发者ID:rair,项目名称:yacs,代码行数:31,代码来源:view.php

示例9: submit_image

 /**
  * create a referenced image
  *
  * @param array of entity attributes (e.g., 'Content-Disposition')
  * @param string image actual content
  * @param array poster attributes
  * @param string the target anchor (e.g., 'article:123')
  * @param string reference of the object to be extended, if any
  * @return string reference to the created object, or NULL
  */
 public static function submit_image($entity_headers, $content, $user, $anchor, $target = NULL)
 {
     global $context;
     // retrieve queue parameters
     list($server, $account, $password, $allowed, $match, $section, $options, $hooks, $prefix, $suffix) = $context['mail_queue'];
     // locate content-disposition
     foreach ($entity_headers as $header) {
         if (preg_match('/Content-Disposition/i', $header['name'])) {
             $content_disposition = $header['value'];
             break;
         }
     }
     // find file name in content-disposition
     $file_name = '';
     if ($content_disposition && preg_match('/filename="*([a-zA-Z0-9\'\\(\\)\\+_,-\\.\\/:=\\? ]+)"*\\s*/i', $content_disposition, $matches)) {
         $file_name = $matches[1];
     }
     // as an alternative, look in content-type
     if (!$file_name) {
         // locate content-type
         foreach ($entity_headers as $header) {
             if (preg_match('/Content-Type/i', $header['name'])) {
                 $content_type = $header['value'];
                 break;
             }
         }
         // find file name in content-type
         if ($content_type && preg_match('/name="*([a-zA-Z0-9\'\\(\\)\\+_,-\\.\\/:=\\? ]+)"*\\s*/i', $content_type, $matches)) {
             $file_name = $matches[1];
         }
     }
     // as an alternative, look in content-description
     if (!$file_name) {
         // locate content-description
         foreach ($entity_headers as $header) {
             if (preg_match('/Content-Description/i', $header['name'])) {
                 $content_description = $header['value'];
                 break;
             }
         }
         // find file name in content-description
         $file_name = $content_description;
     }
     // sanity check
     if (!$file_name) {
         Logger::remember('agents/messages.php: No file name to use for submitted image');
         return NULL;
     }
     // file size
     $file_size = strlen($content);
     // sanity check
     if ($file_size < 7) {
         Logger::remember('agents/messages.php: Short image skipped', $file_name);
         return NULL;
     }
     // sanity check
     if (!$anchor) {
         Logger::remember('agents/messages.php: No anchor to use for submitted image', $file_name);
         return NULL;
     }
     // get anchor data -- this is a mutable object
     $host = Anchors::get($anchor, TRUE);
     if (!is_object($host)) {
         Logger::remember('agents/messages.php: Unknown anchor ' . $anchor, $file_name);
         return NULL;
     }
     // create target folders
     $file_path = Files::get_path($anchor, 'images');
     if (!Safe::make_path($file_path)) {
         Logger::remember('agents/messages.php: Impossible to create ' . $file_path);
         return NULL;
     }
     if (!Safe::make_path($file_path . '/thumbs')) {
         Logger::remember('agents/messages.php: Impossible to create ' . $file_path . '/thumbs');
         return NULL;
     }
     $file_path = $context['path_to_root'] . $file_path . '/';
     // save the entity in the file system
     if (!($file = Safe::fopen($file_path . $file_name, 'wb'))) {
         Logger::remember('agents/messages.php: Impossible to open ' . $file_path . $file_name);
         return NULL;
     }
     if (fwrite($file, $content) === FALSE) {
         Logger::remember('agents/messages.php: Impossible to write to ' . $file_path . $file_name);
         return NULL;
     }
     fclose($file);
     // get image information
     if (!($image_information = Safe::GetImageSize($file_path . $file_name))) {
         Safe::unlink($file_path . $file_name);
//.........这里部分代码省略.........
开发者ID:rair,项目名称:yacs,代码行数:101,代码来源:messages.php

示例10: get_url

 /**
  * build a reference to a file
  *
  * Depending on parameter '[code]with_friendly_urls[/code]' and on action,
  * following results can be observed:
  *
  * - view - files/view.php?id=123 or files/view.php/123 or file-123
  *
  * - other - files/edit.php?id=123 or files/edit.php/123 or file-edit/123
  *
  * @param int the id of the file to handle
  * @param string the expected action ('view', 'print', 'edit', 'delete', ...)
  * @param string additional data, such as file name, if any
  * @return string a normalized reference
  *
  * @see control/configure.php
  */
 public static function get_url($id, $action = 'view', $name = NULL)
 {
     global $context;
     // get files in rss -- the id has to be an anchor (e.g., 'article:15')
     if ($action == 'feed') {
         if ($context['with_friendly_urls'] == 'Y') {
             return 'files/feed.php/' . str_replace(':', '/', $id);
         } elseif ($context['with_friendly_urls'] == 'R') {
             return 'files/feed.php/' . str_replace(':', '/', $id);
         } else {
             return 'files/feed.php?anchor=' . urlencode($id);
         }
     }
     // add a file -- the id has to be an anchor (e.g., 'article:15')
     if ($action == 'file') {
         if ($context['with_friendly_urls'] == 'Y') {
             return 'files/edit.php/' . str_replace(':', '/', $id);
         } elseif ($context['with_friendly_urls'] == 'R') {
             return 'files/edit.php/' . str_replace(':', '/', $id);
         } else {
             return 'files/edit.php?anchor=' . urlencode($id);
         }
     }
     // confirm the download
     if ($action == 'confirm') {
         $action = 'fetch';
         $name = 'confirm';
     }
     // clear assignment
     if ($action == 'release') {
         $action = 'fetch';
         $name = 'release';
     }
     // reserve the file
     if ($action == 'reserve') {
         $action = 'fetch';
         $name = 'reserve';
     }
     // direct access to the file
     if ($action == 'direct') {
         // get file data
         $file = Files::get($id);
         // get path to the file
         $url = Files::get_path($file['anchor']) . '/' . rawurlencode($file['file_name']);
         return $url;
     }
     // check the target action
     if (!preg_match('/^(author|delete|edit|fetch|list|stream|thread|view)$/', $action)) {
         return 'files/' . $action . '.php?id=' . urlencode($id) . '&action=' . urlencode($name);
     }
     // normalize the link
     return normalize_url(array('files', 'file'), $action, $id, $name);
 }
开发者ID:rair,项目名称:yacs,代码行数:70,代码来源:files.php

示例11: elseif

    // permission denied
} elseif (!$permitted) {
    Safe::header('Status: 401 Unauthorized', TRUE, 401);
    Logger::error(i18n::s('You are not allowed to perform this operation.'));
    // package the files
} else {
    // build a zip archive
    include_once '../shared/zipfile.php';
    $zipfile = new zipfile();
    // get related files from the database
    $items = array();
    if (isset($type) && isset($id)) {
        $items = Files::list_by_date_for_anchor($type . ':' . $id, 0, 20, 'raw');
    }
    // archive each file
    $file_path = $context['path_to_root'] . Files::get_path($type . ':' . $id);
    foreach ($items as $id => $attributes) {
        // read file content
        if ($content = Safe::file_get_contents($file_path . '/' . $attributes['file_name'], 'rb')) {
            // add the binary data
            $zipfile->deflate($attributes['file_name'], Safe::filemtime($file_path . '/' . $attributes['file_name']), $content);
        }
    }
    //
    // transfer to the user agent
    //
    // send the archive content
    if ($archive = $zipfile->get()) {
        // suggest a download
        Safe::header('Content-Type: application/octet-stream');
        // suggest a name for the saved file
开发者ID:rair,项目名称:yacs,代码行数:31,代码来源:fetch_all.php

示例12:

    // back to the anchor page
    if (is_object($anchor) && $anchor->is_viewable()) {
        $context['text'] .= Skin::build_block(Skin::build_link($anchor->get_url(), i18n::s('Back to main page'), 'button'), 'bottom');
    }
    // page tools
    //
    if ($editable) {
        Skin::define_img('IMAGES_EDIT_IMG', 'images/edit.gif');
        $context['page_tools'][] = Skin::build_link(Images::get_url($item['id'], 'edit'), IMAGES_EDIT_IMG . i18n::s('Update this image'), 'basic', i18n::s('Press [e] to edit'), FALSE, 'e');
    }
    // the delete command is available to associates and editors
    if ($item['id'] && (Surfer::is_associate() || is_object($anchor) && $anchor->is_assigned())) {
        Skin::define_img('IMAGES_DELETE_IMG', 'images/delete.gif');
        $context['page_tools'][] = Skin::build_link(Images::get_url($item['id'], 'delete'), IMAGES_DELETE_IMG . i18n::s('Delete this image'));
    }
    // general help on this page
    //
    $help = '<p>' . i18n::s('To save this image on your hard drive, drag the mouse above the image and use the right button. A contextual pop-up menu should appear. Select the adequate command depending on the browser used.') . '</p>';
    $context['components']['boxes'] = Skin::build_box(i18n::s('Help'), $help, 'boxes', 'help');
    // thumbnail, in an extra box
    //
    if (Surfer::is_associate() && $item['thumbnail_name'] && $item['thumbnail_name'] != $item['image_name']) {
        $url = $context['url_to_root'] . Files::get_path($item['anchor'], 'images') . '/' . $item['thumbnail_name'];
        $context['components']['boxes'] .= Skin::build_box(i18n::s('Thumbnail'), '<img src="' . $url . '" />', 'boxes');
    }
    // referrals, if any
    //
    $context['components']['referrals'] =& Skin::build_referrals(Images::get_url($item['id']));
}
// render the skin
render_skin();
开发者ID:rair,项目名称:yacs,代码行数:31,代码来源:view.php

示例13: upload_to

 /**
  * upload a file as a image attach to a given anchor
  * to be used in custom "edit_as" script
  * 
  * @global string $context
  * @param object $anchor
  * @param array $file (from $_FILES)
  * @param bool $set_as_thumb
  * @param bool $put
  */
 public static function upload_to($anchor, $file, $set_as_thumb = false, $put = false)
 {
     global $context;
     // attach some image
     $path = Files::get_path($anchor->get_reference(), 'images');
     // $_REQUEST['action'] = 'set_as_icon'; // instruction for image::upload
     if (isset($file) && ($uploaded = Files::upload($file, $path, array('Image', 'upload')))) {
         // prepare image informations
         $image = array();
         $image['image_name'] = $uploaded;
         $image['image_size'] = $file['size'];
         $image['thumbnail_name'] = 'thumbs/' . $uploaded;
         $image['anchor'] = $anchor->get_reference();
         //$combined = array_merge($image, $_FILES);
         // post the image which was uploaded
         if ($image['id'] = Images::post($image)) {
             // successfull post
             $context['text'] .= '<p>' . i18n::s('Following image has been added:') . '</p>' . Codes::render_object('image', $image['id']) . '<br style="clear:left;" />' . "\n";
             // set image as icon and thumbnail
             if ($set_as_thumb) {
                 // delete former icon if any
                 /*if(isset($anchor->item['icon_url'])
                                                         && $anchor->item['icon_url']
                                                         && $match = Images::get_by_anchor_and_name($anchor->get_reference(), pathinfo($anchor->item['icon_url'],PATHINFO_BASENAME))) {
                 
                 
                                                     if($match['id'] != $image['id'])
                                                         Images::delete($match['id']);
                                                 }*/
                 $fields = array('thumbnail_url' => Images::get_thumbnail_href($image), 'icon_url' => Images::get_icon_href($image));
                 if ($put) {
                     $fields['id'] = $_REQUEST['id'];
                     $class = $anchor->get_static_group_class();
                     $class::put_attributes($fields);
                 } else {
                     $_REQUEST = array_merge($_REQUEST, $fields);
                 }
             }
         }
     }
 }
开发者ID:rair,项目名称:yacs,代码行数:51,代码来源:images.php

示例14: while

 if (!($result = SQL::query($query))) {
     $context['text'] .= Logger::error_pop() . BR . "\n";
     return;
     // parse the whole list
 } else {
     // fetch one anchor and the linked member
     $errors_count = 0;
     while ($row = SQL::fetch($result)) {
         // animate user screen and take care of time
         $count++;
         if (!($count % 100)) {
             $context['text'] .= sprintf(i18n::s('%d records have been processed'), $count) . BR . "\n";
             // ensure enough execution time
             Safe::set_time_limit(30);
         }
         $file_from = Files::get_path($row['anchor']);
         if (!file_exists($context['path_to_root'] . $file_from . '/' . $row['file_name'])) {
             $errors_count++;
             $anchor = Anchors::get($row['anchor']);
             $context['text'] .= sprintf(i18n::s('Missing: %s'), 'file ' . Skin::build_link(Files::get_url($row['id']), $row['id'] . ' ' . $row['file_name'])) . ' ' . i18n::s('in') . ' ' . (is_object($anchor) ? Skin::build_link($anchor->get_url(), $row['anchor']) : '') . BR . "\n";
         }
     }
 }
 // ending message
 $context['text'] .= sprintf(i18n::s('%d records have been processed'), $count) . BR . "\n";
 $context['text'] .= sprintf(i18n::s('%d missing files'), $errors_count) . BR . "\n";
 // display the execution time
 $time = round(get_micro_time() - $context['start_time'], 2);
 $context['text'] .= '<p>' . sprintf(i18n::s('Script terminated in %.2f seconds.'), $time) . '</p>';
 // forward to the index page
 $menu = array('images/' => i18n::s('Images'));
开发者ID:rair,项目名称:yacs,代码行数:31,代码来源:check.php

示例15: explode_callback

 function explode_callback($name)
 {
     global $context;
     // reject all files put in sub-folders
     $file_path = Files::get_path($_REQUEST['anchor'], 'images');
     if (($path = substr($name, strlen($file_path . '/'))) && strpos($path, '/') !== FALSE) {
         Safe::unlink($name);
     } elseif (!($attributes = Safe::GetImageSize($name))) {
         Safe::unlink($name);
     } elseif ($attributes[0] > 5000 || $attributes[1] > 5000) {
         Safe::unlink($name);
     }
 }
开发者ID:rair,项目名称:yacs,代码行数:13,代码来源:edit.php


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