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


PHP Safe::file_get_contents方法代码示例

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


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

示例1: check_file

 function check_file($node)
 {
     global $context;
     global $footprints;
     $key = substr($node, strlen($context['path_to_root']));
     // no extension to check
     if (strpos($key, '.') === FALSE) {
     } elseif (!strncmp($node, 'scripts/staging', 16)) {
     } elseif (!strcmp($key, 'footprints.php')) {
     } elseif (!strncmp(substr($key, -9), 'index.php', 9) && ($content = Safe::file_get_contents($node)) && !strcmp($content, Safe::mkdir_index_content())) {
     } elseif (!strncmp($key, 'temporary/cache_i18n_locale_', 28)) {
     } elseif (!strncmp(substr($key, -4), '.php', 4)) {
         // one of the parameter files created by yacs
         if (preg_match('/parameters\\/(agents|control|feeds|files|hooks|letters|root|scripts|services|skins|users|virtual_.+)\\.include\\.php$/i', $key)) {
         } elseif (isset($footprints[$key])) {
             $expected = $footprints[$key];
             $actual = Scripts::hash($node);
             if ($expected[0] != $actual[0] || $expected[1] != $actual[1]) {
                 $context['text'] .= sprintf(i18n::s('ERROR: File %s is missing or corrupted.'), $key) . BR . "\n";
             }
         } else {
             $context['text'] .= sprintf(i18n::s('File %s is not part of Yacs.'), $key) . BR . "\n";
         }
         // not a safe file
     } elseif (!preg_match('/\\.(bak|bat|css|done|dtd|fdb|flv|gif|ico|jpeg|jpg|js|jsmin|htc|htm|html|mo|off|on|pdf|png|po|pot|reg|sh|sql|swf|tgz|txt|xml|zip)$/i', $key)) {
         $context['text'] .= sprintf(i18n::s('File %s is not part of Yacs.'), $key) . BR . "\n";
     }
 }
开发者ID:rair,项目名称:yacs,代码行数:28,代码来源:check.php

示例2: render

 /**
  * render graphviz object
  *
  * @return string the rendered text
  **/
 public function render($matches)
 {
     global $context;
     list($text, $variant) = $matches;
     // sanity check
     if (!$text) {
         $text = 'Hello->World!';
     }
     // remove tags put by WYSIWYG editors
     $text = strip_tags(str_replace(array('&gt;', '&lt;', '&amp;', '&quot;', '\\"'), array('>', '<', '&', '"', '"'), str_replace(array('<br />', '</p>'), "\n", $text)));
     // build the .dot content
     switch ($variant) {
         case 'digraph':
         default:
             $text = 'digraph G { ' . $text . ' }' . "\n";
             break;
     }
     // id for this object
     $hash = md5($text);
     // path to cached files
     $path = $context['path_to_root'] . 'temporary/graphviz.';
     // we cache content
     if ($content = Safe::file_get_contents($path . $hash . '.html')) {
         return $content;
     }
     // build a .dot file
     if (!Safe::file_put_contents($path . $hash . '.dot', $text)) {
         $content = '[error writing .dot file]';
         return $content;
     }
     // process the .dot file
     if (isset($context['dot.command'])) {
         $command = $context['dot.command'];
     } else {
         $command = 'dot';
     }
     //		$font = '"/System/Library/Fonts/Times.dfont"';
     //		$command = '/sw/bin/dot -v -Nfontname='.$font
     $command .= ' -Tcmapx -o "' . $path . $hash . '.map"' . ' -Tpng -o "' . $path . $hash . '.png"' . ' "' . $path . $hash . '.dot"';
     if (Safe::shell_exec($command) == NULL) {
         $content = '[error while using graphviz]';
         return $content;
     }
     // produce the HTML
     $content = '<img src="' . $context['url_to_root'] . 'temporary/graphviz.' . $hash . '.png" usemap="#mainmap" />';
     $content .= Safe::file_get_contents($path . $hash . '.map');
     // put in cache
     Safe::file_put_contents($path . $hash . '.html', $content);
     // done
     return $content;
 }
开发者ID:rair,项目名称:yacs,代码行数:56,代码来源:code_graphviz.php

示例3: allow

 /**
  * check access rights
  *
  * @param string script name
  * @paral string target anchor, if any
  * @return boolean FALSE if access is denied, TRUE otherwise
  */
 function allow($script, $anchor = NULL)
 {
     global $context;
     // limit the scope of our check
     if ($script != 'files/view.php' && $script != 'files/fetch.php' && $script != 'files/fetch_all.php' && $script != 'files/stream.php') {
         return TRUE;
     }
     // sanity check
     if (!$anchor) {
         die(i18n::s('No anchor has been found.'));
     }
     // stop here if the agreement has been gathered previously
     if (isset($_SESSION['agreements']) && is_array($agreements = $_SESSION['agreements'])) {
         foreach ($agreements as $agreement) {
             if ($agreement == $anchor) {
                 return TRUE;
             }
         }
     }
     // which agreement?
     if (!$this->parameters) {
         die(sprintf(i18n::s('No parameter has been provided to %s'), 'behaviors/agree_on_file_access'));
     }
     // do we have a related file to display?
     if (!is_readable($context['path_to_root'] . 'behaviors/agreements/' . $this->parameters)) {
         die(sprintf(i18n::s('Bad parameter to behavior <code>%s %s</code>'), 'agree_on_file_access', $this->parameters));
     }
     // splash message
     $context['text'] .= '<p class="agreement">' . i18n::s('Before moving forward, please read following text and express yourself at the end of the page.') . '</p><hr/>' . "\n";
     // load and display the file to be displayed
     $context['text'] .= Codes::beautify(Safe::file_get_contents($context['path_to_root'] . 'behaviors/agreements/' . $this->parameters));
     // target link to record agreement
     if ($context['with_friendly_urls'] == 'Y') {
         $agree_link = 'behaviors/agreements/agree.php/' . rawurlencode($anchor);
     } else {
         $agree_link = 'behaviors/agreements/agree.php?id=' . urlencode($anchor);
     }
     // display confirmation buttons at the end of the agreement
     $context['text'] .= '<hr/><p class="agreement">' . i18n::s('Do you agree?');
     $context['text'] .= ' ' . Skin::build_link($agree_link, i18n::s('Yes'), 'button');
     $context['text'] .= ' ' . Skin::build_link('behaviors/agreements/deny.php', i18n::s('No'), 'button') . '</p>' . "\n";
     // render the skin based only on text provided by this behavior
     render_skin();
     exit;
 }
开发者ID:rair,项目名称:yacs,代码行数:52,代码来源:agree_on_file_access.php

示例4: zipfile

 // start the zip file
 include_once '../shared/zipfile.php';
 $zipfile = new zipfile();
 // place all files into a single directory --fixed time to allow cacheability
 $zipfile->store('yacs/', 0);
 // process every reference file
 $all_files = array();
 $index = 0;
 foreach ($references as $reference) {
     // let's go
     list($path, $file) = $reference;
     if (strlen(trim($path)) > 0) {
         $file = $path . '/' . $file;
     }
     // read file content
     if (($content = Safe::file_get_contents($file_path . $file)) !== FALSE) {
         // compress textual content
         if ($content && preg_match('/\\.(css|htc|htm|html|include|js|mo|php|po|pot|sql|txt|xml)$/i', $file)) {
             $zipfile->deflate('yacs/' . $file, Safe::filemtime($file_path . $file), $content);
         } else {
             $zipfile->store('yacs/' . $file, Safe::filemtime($file_path . $file), $content);
         }
         // to be included in tar file as well
         $all_files[] = $file_path . $file;
     } else {
         $context['text'] .= BR . 'cannot read ' . $file_path . $file;
     }
     // avoid timeouts
     if (!($index++ % 50)) {
         Safe::set_time_limit(30);
         SQL::ping();
开发者ID:rair,项目名称:yacs,代码行数:31,代码来源:build.php

示例5: zipfile

    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
        $file_name = utf8::to_ascii($item['title']) . '.zip';
        Safe::header('Content-Disposition: attachment; filename="' . str_replace('"', '', $file_name) . '"');
        // file size
开发者ID:rair,项目名称:yacs,代码行数:31,代码来源:fetch_all.php

示例6: elseif

    // to the control panel
    $context['text'] .= '<p><a href="control/">' . i18n::s('Control Panel') . "</a></p>\n";
    // end of the installation
} elseif (!file_exists('parameters/switch.on') && !file_exists('parameters/switch.off')) {
    // create the switch
    $content = '---------------------------------------------' . "\n" . 'YACS will process requests if this file is named switch.on,' . "\n" . 'and will redirect everything to control/closed.php if its name is changed to switch.off.' . "\n" . "\n" . 'Associates can use the script control/switch.php to stop and restart remotely.' . "\n" . '---------------------------------------------' . "\n";
    if (!Safe::file_put_contents('parameters/switch.on', $content)) {
        // not enough rights to write the file
        Logger::error(i18n::s('ERROR: YACS cannot create the file parameters/switch.on to activate the server.'));
        // allow for a manual update
        $context['text'] .= '<p style="text-decoration: blink;">' . sprintf(i18n::s('To actually switch on the server, please copy and paste following lines by yourself in file %s.'), 'parameters/switch.on') . "</p>\n";
        // content of the switch file
        $context['text'] .= '<pre>' . $content . "</pre>\n";
    }
    // if there is no index at the upper level
    if (!file_exists($context['path_to_root'] . '../index.php') && ($content = Safe::file_get_contents($context['path_to_root'] . 'index.php'))) {
        // silently attempt to duplicate our index
        Safe::file_put_contents('../index.php', $content);
        // remember this for the next incremental update
        $content = '<?php' . "\n" . '// This file has been created by the setup script setup.php' . "\n" . '// on ' . gmdate("F j, Y, g:i a") . ' GMT, for ' . Surfer::get_name() . '. Please do not modify it manually.' . "\n" . '$context[\'home_at_root\']=\'Y\';' . "\n" . '$context[\'reference_server\']=\'' . addcslashes(i18n::s('www.yacs.fr'), "\\'") . "';\n" . '?>' . "\n";
        Safe::file_put_contents('parameters/scripts.include.php', $content);
    }
    // the splash message
    $context['text'] .= sprintf(i18n::s("<p>You have passed through the several installation steps.</p>\nWhat do you want to do now?<ul>\n<li>Select %s for your site.</li>\n<li>Populate your site with the %s.</li>\n<li>Manage everything from the %s.</li>\n<li>Check the %s of this site.</li>\n<li>Review %s.</li>\n<li>%s.</li>\n<li>Look at the %s.</li>\n<li>Visit %s to learn more.</li>\n</ul>\n<p>Thank you for having selected to use YACS for your web site.</p>\n"), Skin::build_link('skins/', i18n::s('another skin')), Skin::build_link('help/populate.php', i18n::s('Content Assistant')), Skin::build_link('control/', i18n::s('Control Panel')), Skin::build_link($context['url_to_root'], i18n::s('front page')), Skin::build_link('users/view.php', i18n::s('your profile')), Skin::build_link('articles/edit.php', i18n::s('Add a page')), Skin::build_link('help/', i18n::s('Help index')), Skin::build_link(i18n::s('http://www.yacs.fr/'), i18n::s('www.yacs.fr'), 'external')) . "\n";
    // no need for installation
} else {
    // the splash message
    $context['text'] .= i18n::s('<p>Since basic configuration files exist on your server, it is likely that the installation has been achieved successfully. Click on the link below to modify the running parameters of your server.</p>') . "\n";
    // to the control panel
    $context['text'] .= '<p><a href="control/">' . i18n::s('Control Panel') . "</a></p>\n";
}
开发者ID:rair,项目名称:yacs,代码行数:31,代码来源:setup.php

示例7: transform_gan_to_simile

 /**
  * adapt GanttProject file to SIMILE Timeline format
  *
  * @param string file location
  * @return string transformation result, or FALSE
  */
 public static function transform_gan_to_simile($file_path)
 {
     global $context;
     // load the file
     $content = Safe::file_get_contents($file_path);
     // used by parsing functions
     $context['gan2simile'] = array();
     $context['gan2simile']['depth'] = 0;
     $context['gan2simile']['tasks'] = array();
     $context['gan2simile']['last_id'] = 0;
     $context['gan2simile']['current_id'] = 0;
     // one tag at a time
     function g2s_startElement($parser, $name, $attrs)
     {
         global $context;
         // remember task basic attributes
         if (!strcmp($name, 'TASK')) {
             if ($context['gan2simile']['depth'] < 5) {
                 // flag duration if not milestone
                 if ($attrs['DURATION'] > 0) {
                     $duration = TRUE;
                 } else {
                     $duration = FALSE;
                 }
                 // remember this task
                 $context['gan2simile']['tasks'][$attrs['ID']] = array('title' => $attrs['NAME'], 'start' => $attrs['START'], 'duration' => $attrs['DURATION'], 'complete' => $attrs['COMPLETE'], 'isDuration' => $duration, 'notes' => '');
                 $context['gan2simile']['current_id'] = $attrs['ID'];
                 // move to children
                 if (!$context['gan2simile']['depth']) {
                     $context['gan2simile']['last_id'] = $attrs['ID'];
                 }
             }
             $context['gan2simile']['depth']++;
         }
     }
     // close a tag
     function g2s_endElement($parser, $name)
     {
         global $context;
         // we check only tasks
         if (!strcmp($name, 'TASK')) {
             $context['gan2simile']['depth']--;
         }
     }
     // parse the GAN file
     $xml_parser = xml_parser_create();
     xml_set_element_handler($xml_parser, "g2s_startElement", "g2s_endElement");
     if (!xml_parse($xml_parser, $content, TRUE)) {
         die(sprintf("XML error: %s at line %d", xml_error_string(xml_get_error_code($xml_parser)), xml_get_current_line_number($xml_parser)));
     }
     xml_parser_free($xml_parser);
     // the resulting text
     $text = '<?xml version="1.0" encoding="' . $context['charset'] . '"?>' . "\n" . '<data>' . "\n";
     // process each task
     foreach ($context['gan2simile']['tasks'] as $task) {
         // transcode start date
         $start = strtotime($task['start']);
         // format start date as per SIMILE expectation
         $task['start'] = date('M j Y G:i:s', $start) . ' GMT';
         // which day in week?
         $info = getdate($start);
         // add two days for the first week-end
         if ($info['wday'] > 0 && $info['wday'] < 6 && $info['wday'] + $task['duration'] > 6) {
             $task['duration'] += 2;
         }
         // take week-ends into consideration
         $task['duration'] += intval($task['duration'] / 7) * 2;
         // compute and format end date date as per SIMILE expectation
         $end = $start + $task['duration'] * 24 * 60 * 60;
         $task['end'] = date('M j Y G:i:s', $end) . ' GMT';
         $earliestEnd = ' earliestEnd="' . $task['start'] . '"';
         if ($task['complete'] > 0) {
             // from percentage to number of days
             $task['complete'] = intval($task['complete'] * $task['duration'] / 100);
             // add two days for the first week-end
             if ($info['wday'] > 0 && $info['wday'] < 6 && $info['wday'] + $task['complete'] > 6) {
                 $task['complete'] += 2;
             }
             // take week-ends into consideration
             $task['complete'] += intval($task['complete'] / 7) * 2;
             // current completion
             $end = $start + $task['complete'] * 24 * 60 * 60;
             $earliestEnd = ' earliestEnd="' . date('M j Y G:i:s', $end) . ' GMT"';
         }
         // has this one several children?
         $duration = '';
         if ($task['isDuration']) {
             $duration = ' isDuration="true"';
         }
         // one event per task
         $text .= '	<event title="' . encode_field(str_replace(array("&nbsp;", '"'), ' ', $task['title'])) . '" start="' . $task['start'] . '"' . $earliestEnd . ' end="' . $task['end'] . '" ' . $duration . '/>' . "\n";
     }
     // no more events
     $text .= '</data>';
//.........这里部分代码省略.........
开发者ID:rair,项目名称:yacs,代码行数:101,代码来源:files.php

示例8: sprintf

 // ensure we have enough time to process this script
 Safe::set_time_limit(30);
 // the origin file
 $origin = 'skins/' . $skin . $file;
 // the target file
 if ($file == '/' . $skin . '.css') {
     $target = 'skins/' . $directory . '/' . $directory . '.css';
 } else {
     $target = 'skins/' . $directory . $file;
 }
 // ensure the path has been created
 Safe::make_path(dirname($target));
 // unlink previous files, if any
 Safe::unlink($context['path_to_root'] . $target);
 // transcode php files
 if (preg_match('/(\\.php|\\.css)$/i', $target) && ($content = Safe::file_get_contents($context['path_to_root'] . $origin))) {
     // change internal reference
     $content = preg_replace('/skins\\/' . preg_quote($skin, '/') . '/i', 'skins/' . $directory, $content);
     $content = preg_replace('/\'' . preg_quote($skin, '/') . '\'/i', "'" . $directory . "'", $content);
     $content = preg_replace('/' . preg_quote($skin, '/') . '\\.css/i', $directory . ".css", $content);
     // not part of the reference set anymore
     $content = preg_replace('/\\s*\\*\\s+@reference\\s*\\n/i', "\n", $content);
     // save it as the new cache file
     if (Safe::file_put_contents($target, $content)) {
         $context['text'] .= sprintf(i18n::s('%s has been transcoded'), $target) . BR . "\n";
     } else {
         $context['text'] .= sprintf(i18n::s('Impossible to write to %s.'), $target) . BR . "\n";
         $errors++;
     }
     // copy the file
 } elseif (!Safe::copy($context['path_to_root'] . $origin, $context['path_to_root'] . $target)) {
开发者ID:rair,项目名称:yacs,代码行数:31,代码来源:derive.php

示例9: unlink

         if ($text = Safe::file_get_contents($name)) {
             // actual compression
             if (!preg_match('/\\.min\\./', basename($name))) {
                 $minified .= JSMin::minify($text);
             } else {
                 $minified .= $text;
             }
             // one file has been compressed
             $count++;
         }
     }
 }
 // include shared/yacs.js library
 if (file_exists($context['path_to_root'] . 'shared/yacs.js')) {
     $context['text'] .= 'shared/yacs.js' . BR . "\n";
     $text = Safe::file_get_contents($context['path_to_root'] . 'shared/yacs.js');
     $minified .= JSMin::minify($text);
     $count++;
 }
 // save the library to call in page footer
 $file_min = $context['path_to_root'] . 'included/browser/library_js_endpage.min.js';
 if ($minified) {
     Safe::file_put_contents($file_min, $minified);
 } else {
     Safe:
     unlink($file_min);
 }
 // do the same in included/calendar
 /* if($names = Safe::glob($context['path_to_root'].'included/jscalendar/*.js')) {
 		foreach($names as $name) {
 
开发者ID:rair,项目名称:yacs,代码行数:30,代码来源:jsmin.php

示例10: foreach

// process every file
$count = 0;
foreach ($copy as $file) {
    // content of the updated file
    $content = '';
    // expected location in staging repository
    $local_reference = $context['path_to_root'] . 'scripts/staging/' . $file;
    // don't execute PHP scripts, just get them
    if (preg_match('/\\.php$/i', $file)) {
        $remote_reference = 'http://' . $context['reference_server'] . '/scripts/fetch.php?script=' . urlencode($file);
    } else {
        $remote_reference = 'http://' . $context['reference_server'] . '/scripts/reference/' . $file;
    }
    // get the file locally
    if (file_exists($local_reference)) {
        $content = Safe::file_get_contents($local_reference);
    } elseif (($content = http::proceed($remote_reference)) === FALSE) {
        $local['error_en'] = 'Unable to get ' . $file;
        $local['error_fr'] = 'Impossible d\'obtenir ' . $file;
        echo i18n::user('error') . "<br />\n";
    }
    // we have something in hand
    if ($content) {
        // create missing directories where applicable
        Safe::make_path(dirname($file));
        // create backups, if possible
        if (file_exists($context['path_to_root'] . $file)) {
            Safe::unlink($context['path_to_root'] . $file . '.bak');
            Safe::rename($context['path_to_root'] . $file, $context['path_to_root'] . $file . '.bak');
        }
        // update the target file
开发者ID:rair,项目名称:yacs,代码行数:31,代码来源:150224_lasares_to_netgrabber.php

示例11: sprintf

        $label = sprintf(i18n::c('%s has been created'), $target);
        Logger::remember('control/virtual.php: ' . $label);
    }
    $context['text'] .= Skin::build_box(i18n::s('Configuration'), Safe::highlight_string($content), 'unfolded');
    // follow-up commands
    $follow_up = i18n::s('What do you want to do now?');
    $menu = array();
    $menu = array_merge($menu, array('control/virtual.php' => i18n::s('Manage virtual hosts')));
    $menu = array_merge($menu, array('control/' => i18n::s('Control Panel')));
    $follow_up .= Skin::build_list($menu, 'menu_bar');
    $context['text'] .= Skin::build_block($follow_up, 'bottom');
    // view one configuration file
} elseif ($id && $action == 'view') {
    // file has to exist
    $file = 'parameters/virtual_' . $id . '.include.php';
    if (!($content = Safe::file_get_contents($context['path_to_root'] . $file))) {
        Logger::error(i18n::s('No configuration file has been found for this virtual host.'));
    } elseif (file_exists('../parameters/switch.on') || file_exists('../parameters/switch.off')) {
        $context['text'] .= Skin::build_box(i18n::s('Configuration'), Safe::highlight_string($content), 'unfolded');
    } else {
        $context['text'] .= Safe::highlight_string($content);
    }
    // follow-up commands
    $follow_up = i18n::s('What do you want to do now?');
    $menu = array();
    $menu = array_merge($menu, array('control/virtual.php?id=' . urlencode($id) . '&action=edit' => i18n::s('Edit configuration')));
    $menu = array_merge($menu, array('control/virtual.php' => i18n::s('Manage virtual hosts')));
    $menu = array_merge($menu, array('control/' => i18n::s('Control Panel')));
    $follow_up .= Skin::build_list($menu, 'menu_bar');
    $context['text'] .= Skin::build_block($follow_up, 'bottom');
    // no action has been triggered so far
开发者ID:rair,项目名称:yacs,代码行数:31,代码来源:virtual.php

示例12: foreach

    $context['page_title'] = $script;
} else {
    $context['page_title'] = i18n::s('Please indicate a script name.');
}
// no argument has been passed
if (!$script) {
    $context['text'] .= '<p>' . i18n::s('Please indicate a script name.') . "</p>\n";
} else {
    // the separator
    $separator = '----------------------- aqwzsxedcrfvtgbyhnujikolpm ---------------------------' . "\n";
    // the output
    $text = '';
    // one script at a time
    foreach ($script as $name) {
        // read the file from the reference store
        if (!($content = Safe::file_get_contents($context['path_to_root'] . 'scripts/reference/' . $name))) {
            Safe::header('Status: 404 Not Found', TRUE, 404);
            exit('File "' . 'scripts/reference/' . $name . '" not found');
        }
        // happen this to the output buffer
        if ($text) {
            $text .= $separator;
        }
        $text .= $content;
    }
    // only one script has been asked
    if (count($script) == 1) {
        // compress the page if possible, but no transcoding -- the bare handler
        $context['charset'] = 'ASCII';
        render_raw('text/x-httpd-php');
        // send the response to the caller
开发者ID:rair,项目名称:yacs,代码行数:31,代码来源:fetch.php

示例13: post


//.........这里部分代码省略.........
             if (!$body) {
                 $body = 'This is a multi-part message in MIME format.';
             }
             // this part only --second EOL is part of the boundary chain
             $body .= M_EOL . M_EOL . '--' . $boundary . '-internal' . M_EOL . 'Content-Type: ' . $type . M_EOL . 'Content-Transfer-Encoding: ' . $content_encoding . M_EOL . M_EOL . $part;
         }
     }
     // finalize the body
     if (count($message) > 1) {
         $body .= M_EOL . M_EOL . '--' . $boundary . '-internal--';
     }
     // a mix of things
     if (count($attachments)) {
         // encoding is irrelevant if there are multiple parts
         if (!strncmp($content_type, 'multipart/', 10)) {
             $content_encoding = '';
         } else {
             $content_encoding = M_EOL . 'Content-Transfer-Encoding: ' . $content_encoding;
         }
         // identify the main part of the overall message
         $content_start = 'mainpart';
         // the current body becomes the first part of a larger message
         $body = 'This is a multi-part message in MIME format.' . M_EOL . M_EOL . '--' . $boundary . '-external' . M_EOL . 'Content-Type: ' . $content_type . $content_encoding . M_EOL . 'Content-ID: <' . $content_start . '>' . M_EOL . M_EOL . $body;
         // message parts should be considered as an aggregate whole --see RFC 2387
         $content_type = 'multipart/related; type="multipart/alternative"; boundary="' . $boundary . '-external"';
         $content_encoding = '';
         // process every file
         foreach ($attachments as $name => $content) {
             // read external file content
             if (preg_match('/^[0-9]+$/', $name)) {
                 // only a file name has been provided
                 $name = $content;
                 // read file content from the file system
                 if (!($content = Safe::file_get_contents($name))) {
                     continue;
                 }
             }
             // file name is the file type
             if (preg_match('/name="(.+)?"/', $name, $matches)) {
                 $type = $name;
                 $name = $matches[1];
             } else {
                 $type = Files::get_mime_type($name);
             }
             // a unique id for for this file
             $cid = sprintf('%u@%s', crc32($name), $context['host_name']);
             // set a name that avoids problems
             $basename = utf8::to_ascii(basename($name));
             // headers for one file
             $body .= M_EOL . M_EOL . '--' . $boundary . '-external' . M_EOL . 'Content-Type: ' . $type . M_EOL . 'Content-Disposition: inline; filename="' . str_replace('"', '', $basename) . '"' . M_EOL . 'Content-ID: <' . $cid . '>';
             // transfer textual entities as they are
             if (!strncmp($type, 'text/', 5)) {
                 $body .= M_EOL . 'Content-Transfer-Encoding: quoted-printable' . M_EOL . M_EOL . quoted_printable_encode($content);
                 // encode everything else
             } else {
                 $body .= M_EOL . 'Content-Transfer-Encoding: base64' . M_EOL . M_EOL . chunk_split(base64_encode($content), 76, M_EOL);
             }
         }
         // the closing boundary
         $body .= M_EOL . M_EOL . '--' . $boundary . '-external--';
     }
     // Content-Type: header
     if ($content_type && !preg_match('/^Content-Type: /im', $headers)) {
         $headers .= M_EOL . 'Content-Type: ' . $content_type;
     }
     // Content-Transfer-Encoding: header
开发者ID:rair,项目名称:yacs,代码行数:67,代码来源:mailer.php

示例14: elseif

        $context['text'] .= Skin::build_block('<form method="post" action="setup.php"><p class="assistant_bar">' . "\n" . Skin::build_submit_button(i18n::s('Database maintenance')) . "\n" . '<input type="hidden" name="action" value="build" />' . "\n" . '</p></form>', 'bottom');
        // this may take several minutes
        $context['text'] .= '<p>' . i18n::s('When you will click on the button the server will be immediately requested to proceed. However, because of the so many things to do on the back-end, you may have to wait for minutes before getting a response displayed. Thank you for your patience.') . '</p>';
        // create the database on first installation
    } elseif (!file_exists('../parameters/switch.on')) {
        $context['text'] .= Skin::build_block('<form method="post" action="setup.php"><p class="assistant_bar">' . "\n" . Skin::build_submit_button(i18n::s('Create tables in the database')) . "\n" . '<input type="hidden" name="action" value="build" />' . "\n" . '</p></form>', 'bottom');
        // this may take several minutes
        $context['text'] .= '<p>' . i18n::s('When you will click on the button the server will be immediately requested to proceed. However, because of the so many things to do on the back-end, you may have to wait for minutes before getting a response displayed. Thank you for your patience.') . '</p>';
        // or back to the control panel
    } else {
        $menu = array('control/' => i18n::s('Control Panel'), 'control/setup.php' => i18n::s('Database maintenance'));
        $context['text'] .= Skin::build_list($menu, 'menu_bar');
    }
    // display current hooks
} else {
    // the splash message
    $context['text'] .= i18n::s('This script will scan your php scripts to install software hooks.');
    // the submit button
    $context['text'] .= '<form method="post" action="' . $context['script_url'] . '" id="main_form"><p>' . Skin::build_submit_button(i18n::s('Scan scripts for software extensions'), NULL, NULL, 'confirmed') . '<input type="hidden" name="action" value="check" />' . '</p></form>';
    // the script used for form handling at the browser
    Page::insert_script('$("#confirmed").focus();');
    // this may take several minutes
    $context['text'] .= '<p>' . i18n::s('When you will click on the button the server will be immediately requested to proceed. However, because of the so many things to do on the back-end, you may have to wait for minutes before getting a response displayed. Thank you for your patience.') . '</p>';
    // display the existing hooks configuration file, if any
    $content = Safe::file_get_contents('../parameters/hooks.include.php');
    if (strlen($content)) {
        $context['text'] .= Skin::build_box(sprintf(i18n::s('Current content of %s'), 'parameters/hooks.include.php'), Safe::highlight_string($content), 'folded');
    }
}
// render the skin
render_skin();
开发者ID:rair,项目名称:yacs,代码行数:31,代码来源:scan.php

示例15: zipfile

 $context['text'] .= '<p>' . i18n::s('On-going archive preparation...') . '</p>' . "\n";
 // build a zip archive
 include_once '../shared/zipfile.php';
 $zipfile = new zipfile();
 // process every skin/current_skin/ file
 $index = 0;
 foreach ($datafiles as $datafile) {
     // let's go
     list($path, $filename) = $datafile;
     if ($path) {
         $file = $path . '/' . $filename;
     } else {
         $file = $filename;
     }
     // read file content
     if (($content = Safe::file_get_contents($file_prefix . $file)) !== FALSE) {
         // store binary data
         $zipfile->store($file, Safe::filemtime($file_prefix . $file), $content);
         // avoid timeouts
         if (!($index++ % 50)) {
             Safe::set_time_limit(30);
             SQL::ping();
         }
     }
 }
 // suggest a download
 Safe::header('Content-Type: application/zip');
 Safe::header('Content-Disposition: attachment; filename="backup_' . $context['skin'] . '.zip"');
 // send the archive content
 echo $zipfile->get();
 // do not allow for regular rendering
开发者ID:rair,项目名称:yacs,代码行数:31,代码来源:backup.php


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