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


PHP Safe::file_put_contents方法代码示例

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


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

示例1: 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

示例2: addcslashes

 }
 if (isset($_REQUEST['opentok_api_secret'])) {
     $content .= '$context[\'opentok_api_secret\']=\'' . addcslashes($_REQUEST['opentok_api_secret'], "\\'") . "';\n";
 }
 if (isset($_REQUEST['opentok_api_url'])) {
     $content .= '$context[\'opentok_api_url\']=\'' . addcslashes($_REQUEST['opentok_api_url'], "\\'") . "';\n";
 }
 if (isset($_REQUEST['twilio_account_sid'])) {
     $content .= '$context[\'twilio_account_sid\']=\'' . addcslashes($_REQUEST['twilio_account_sid'], "\\'") . "';\n";
 }
 if (isset($_REQUEST['twilio_authentication_token'])) {
     $content .= '$context[\'twilio_authentication_token\']=\'' . addcslashes($_REQUEST['twilio_authentication_token'], "\\'") . "';\n";
 }
 $content .= '?>' . "\n";
 // update the parameters file
 if (!Safe::file_put_contents('parameters/services.include.php', $content)) {
     Logger::error(sprintf(i18n::s('ERROR: Impossible to write to the file %s. The configuration has not been saved.'), 'parameters/services.include.php'));
     // allow for a manual update
     $context['text'] .= '<p style="text-decoration: blink;">' . sprintf(i18n::s('To actually change the configuration, please copy and paste following lines by yourself in file %s.'), 'parameters/services.include.php') . "</p>\n";
     // job done
 } else {
     $context['text'] .= '<p>' . sprintf(i18n::s('The following configuration has been saved into the file %s.'), 'parameters/services.include.php') . "</p>\n";
     // purge the cache
     Cache::clear();
     // remember the change
     $label = sprintf(i18n::c('%s has been updated'), 'parameters/services.include.php');
     Logger::remember('services/configure.php: ' . $label);
 }
 // display updated parameters
 $context['text'] .= Skin::build_box(i18n::s('Configuration parameters'), Safe::highlight_string($content), 'folded');
 // follow-up commands
开发者ID:rair,项目名称:yacs,代码行数:31,代码来源:configure.php

示例3: sprintf

     $content .= "\t" . '}' . "\n\n";
     // the tail section
     $content .= '}' . "\n" . '?>' . "\n";
     // compile all hooks into a single file
     if (!Safe::file_put_contents('parameters/hooks.include.php', $content)) {
         $context['text'] .= sprintf(i18n::s('Impossible to write to %s.'), 'parameters/hooks.include.php') . BR . "\n";
     } else {
         $context['text'] .= i18n::s('Hooks have been compiled in parameters/hooks.include.php') . BR . "\n";
         // remember the change
         $label = sprintf(i18n::c('%s has been updated'), 'parameters/hooks.include.php');
         Logger::remember('control/scan.php: ' . $label);
     }
     // list hooks using xml
     if (isset($xml)) {
         $xml = '<?xml version="1.0" ?>' . "\n" . '<hooks>' . "\n" . $xml . '</hooks>' . "\n";
         if (!Safe::file_put_contents('parameters/hooks.xml', $xml)) {
             $context['text'] .= sprintf(i18n::s('Impossible to write to %s.'), 'parameters/hooks.xml') . BR . "\n";
         } else {
             $context['text'] .= i18n::s('Hooks have been listed in parameters/hooks.xml') . 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>';
 // if the server has been switched off, update the database schema
 if (file_exists('../parameters/switch.off')) {
     $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
开发者ID:rair,项目名称:yacs,代码行数:31,代码来源:scan.php

示例4: process_queue


//.........这里部分代码省略.........
     if ($context['debug_messages'] == 'Y') {
         Logger::remember('agents/messages.php: POP ->', $request, 'debug');
     }
     // expecting an OK
     if (($reply = fgets($handle)) === FALSE) {
         Logger::remember('agents/messages.php: No reply to STAT command at ' . $server);
         fclose($handle);
         return 0;
     }
     if (strncmp($reply, '+OK', 3)) {
         Logger::remember('agents/messages.php: Rejected command STAT at ' . $server, 'reply="' . rtrim($reply) . '"');
         fclose($handle);
         return 0;
     }
     // evaluate queue size
     $tokens = explode(' ', $reply);
     if ($context['debug_messages'] == 'Y') {
         Logger::remember('agents/messages.php: POP <-', rtrim($reply), 'debug');
     }
     $queue_size = @$tokens[1];
     // nothing to do
     if (!$queue_size) {
         fclose($handle);
         return 0;
     }
     // limit the number of messages processed on each tick
     if ($queue_size > 10) {
         $queue_size = 10;
     }
     // process messages one by one
     for ($index = 1; $index <= $queue_size; $index++) {
         // ask for the message
         $request = 'RETR ' . $index;
         fputs($handle, $request . CRLF);
         if ($context['debug_messages'] == 'Y') {
             Logger::remember('agents/messages.php: POP ->', $request, 'debug');
         }
         // expecting an OK
         if (($reply = fgets($handle)) === FALSE) {
             Logger::remember('agents/messages.php: No reply to RETR command at ' . $server);
             fclose($handle);
             return $index - 1;
         }
         if (strncmp($reply, '+OK', 3)) {
             Logger::remember('agents/messages.php: Rejected command RETR at ' . $server, rtrim($reply));
             fclose($handle);
             return $index - 1;
         }
         // fetch one message at a time
         $message = '';
         while (!feof($handle)) {
             // ensure enough execution time
             Safe::set_time_limit(30);
             // get a chunk (up to ten 1500-byte Ethernet packets)
             $chunk = fread($handle, 16384);
             // look for message end
             if (preg_match("/(.*)\\.\r\n\$/s", $chunk, $matches)) {
                 $message .= $matches[1];
                 break;
             }
             // not yet at the end
             $message .= $chunk;
         }
         // suppress the message from the mailbox before entering into the database
         $request = 'DELE ' . $index;
         fputs($handle, $request . CRLF);
         if ($context['debug_messages'] == 'Y') {
             Logger::remember('agents/messages.php: POP ->', $request, 'debug');
         }
         // expecting an OK
         if (($reply = fgets($handle)) === FALSE) {
             Logger::remember('agents/messages.php: No reply to DELE command at ' . $server);
         } elseif (strncmp($reply, '+OK', 3)) {
             Logger::remember('agents/messages.php: Rejected command DELE at ' . $server, rtrim($reply));
         }
         // file the message if in debug mode
         if ($context['debug_messages'] == 'Y' && Safe::make_path('temporary/agents')) {
             Safe::file_put_contents('temporary/agents/' . uniqid('message_'), $message);
         }
         // process the message
         Messages::process_message($message);
     }
     // close the session to actually purge the queue
     $request = 'QUIT';
     fputs($handle, $request . CRLF);
     if ($context['debug_messages'] == 'Y') {
         Logger::remember('agents/messages.php: POP ->', $request, 'debug');
     }
     // expecting an OK
     if (($reply = fgets($handle)) === FALSE) {
         Logger::remember('agents/messages.php: No reply to QUIT command at ' . $server);
     } elseif (strncmp($reply, '+OK', 3)) {
         Logger::remember('agents/messages.php: Rejected command QUIT at ' . $server, rtrim($reply));
     }
     if ($queue_size > 0) {
         Logger::remember('agents/messages.php: ' . $queue_size . ' message(s) have been processed from ' . $server);
     }
     fclose($handle);
     return $queue_size;
 }
开发者ID:rair,项目名称:yacs,代码行数:101,代码来源:messages.php

示例5: save_patterns

 /**
  * internal method to store patterns of this serveur in a file
  * this to spare time for parsing each extension in /codes at page loading
  * @see method render
  * 
  * @global array $context
  * @param array $patterns_map
  */
 private static function save_patterns($patterns_map)
 {
     global $context;
     // backup the old version
     Safe::unlink($context['path_to_root'] . 'codes/patterns.auto.php.bak');
     Safe::rename($context['path_to_root'] . 'codes/patterns.auto.php', $context['path_to_root'] . 'codes/auto.patterns.auto.php.bak');
     $content = '<?php' . "\n" . '// This file has been created by the script codes/codes.php' . "\n" . '// on ' . gmdate("F j, Y, g:i a") . ' GMT, Please do not modify it manually.' . "\n";
     foreach ($patterns_map as $pattern => $action) {
         $content .= '$patterns_map[\'' . $pattern . '\']="' . addcslashes(str_replace("\n", '\\n', $action), '"') . "\";\n";
     }
     if (!Safe::file_put_contents('codes/patterns.auto.php', $content)) {
         Logger::error(sprintf(i18n::s('ERROR: Impossible to write to the file %s. The configuration has not been saved.'), 'codes/patterns.auto.php'));
     }
 }
开发者ID:rair,项目名称:yacs,代码行数:22,代码来源:codes.php

示例6: render_embed


//.........这里部分代码省略.........
             // 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']);
                 // map the file on the regular web space
                 $url_prefix = $context['url_to_home'] . $context['url_to_root'];
                 // redirect to the actual file
                 $target_href = $url_prefix . $path;
             }
             // allow several viewers to co-exist in the same page
             static $freemind_viewer_index;
             if (!isset($freemind_viewer_index)) {
开发者ID:rair,项目名称:yacs,代码行数:67,代码来源:code_embed.php

示例7: sprintf

         $staging_files++;
         continue;
     }
     // download the updated script from the reference server
     $context['text'] .= sprintf(i18n::s('Staging %s'), $file) . BR . "\n";
     // get the file -- reference server have to be installed at the root
     $url = 'http://' . $context['reference_server'] . '/scripts/fetch.php?script=' . $file;
     if (!($content = http::proceed($url))) {
         $context['text'] .= sprintf(i18n::s('Impossible to read %s.'), $url) . BR . "\n";
         $errors++;
         continue;
     }
     // ensure enough execution time
     Safe::set_time_limit(30);
     // save it in the staging store
     if (!Safe::file_put_contents('scripts/staging/' . $file, $content)) {
         $context['text'] .= '<p>' . sprintf(i18n::s('Impossible to write to %s.'), 'scripts/staging/' . $file) . "</p>\n";
         $errors++;
         continue;
     }
     // ensure we have an exact copy by comparing hashes
     $staging_hash = Scripts::hash('scripts/staging/' . $file);
     if ($attributes[1] != $staging_hash[1]) {
         $context['text'] .= i18n::s('File has been corrupted!') . BR . "\n";
         $errors++;
         continue;
     }
     // update statistics
     $staging_files++;
 }
 // errors have been encountered
开发者ID:rair,项目名称:yacs,代码行数:31,代码来源:stage.php

示例8: elseif

    } 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
        if (!Safe::file_put_contents($file, $content)) {
            $local['label_en'] = 'Impossible to write to the file ' . $file . '.';
            $local['label_fr'] = 'Impossible d\'&eacute;crire le fichier ' . $file . '.';
            echo i18n::user('label') . "<br />\n";
        } else {
            $local['label_en'] = 'has been updated';
            $local['label_fr'] = 'a &eacute;t&eacute; mis &agrave; jour';
            echo $file . ' ' . i18n::user('label') . "<br />\n";
        }
    }
    // next one
    $count += 1;
    Safe::set_time_limit(30);
}
// basic reporting
$local['label_en'] = 'files have been copied';
开发者ID:rair,项目名称:yacs,代码行数:31,代码来源:150224_lasares_to_netgrabber.php

示例9: sprintf

 }
 // with Indexes
 if (isset($_SESSION['htaccess']['indexes'])) {
     if (!($chunk = Safe::file_get_contents('control/htaccess/indexes/.htaccess'))) {
         Logger::error(sprintf(i18n::s('Impossible to read %s.'), 'control/htaccess/indexes/.htaccess'));
     } else {
         $content .= $chunk;
     }
 }
 // ensure smooth operations
 if ($content && !count($context['error'])) {
     // backup the old version
     Safe::unlink($context['path_to_root'] . '.htaccess.bak');
     Safe::rename($context['path_to_root'] . '.htaccess', $context['path_to_root'] . '.htaccess.bak');
     // update the parameters file
     if (!Safe::file_put_contents($context['path_to_root'] . '.htaccess', $content)) {
         Logger::error(sprintf(i18n::s('ERROR: Impossible to write to the file %s. The configuration has not been saved.'), $context['path_to_root'] . '.htaccess'));
         // allow for a manual update
         $context['text'] .= '<p style="text-decoration: blink;">' . sprintf(i18n::s('To actually change the configuration, please copy and paste following lines by yourself in file %s.'), $context['path_to_root'] . '.htaccess') . "</p>\n";
         // job done
     } else {
         $context['text'] .= '<p>' . sprintf(i18n::s('The following configuration has been saved into the file %s.'), '.htaccess') . "</p>\n";
         // remember the change
         $label = sprintf(i18n::c('%s has been updated'), '.htaccess');
         Logger::remember('control/htaccess/index.php: ' . $label);
     }
     // display updated parameters
     $context['text'] .= Skin::build_box(i18n::s('Configuration parameters'), str_replace("\n", BR, htmlspecialchars($content)), 'folded');
     // follow-up commands
     $follow_up = i18n::s('Where do you want to go now?');
     $menu = array();
开发者ID:rair,项目名称:yacs,代码行数:31,代码来源:index.php

示例10: str_replace

 $needles[] = '!!extra_panel!!';
 $values[] = '#extra_panel {' . "\n" . '	background: ' . $context['flexible_extra_bg'] . ';' . "\n" . '	border-bottom: ' . $context['flexible_extra_bottom'] . ';' . "\n" . '	border-left: ' . $context['flexible_extra_left'] . ';' . "\n" . '	border-right: ' . $context['flexible_extra_right'] . ';' . "\n" . '	border-top: ' . $context['flexible_extra_top'] . ';' . "\n" . '	color: ' . $context['flexible_extra_color'] . ';' . "\n" . '	font-family: ' . $context['flexible_extra_family'] . ';' . "\n" . '	font-size: ' . $context['flexible_extra_size'] . ';' . "\n" . '	font-weight: ' . $context['flexible_extra_weight'] . ';' . "\n" . '	padding: ' . $context['flexible_extra_padding'] . ';' . "\n" . '	width: ' . $context['flexible_extra_width'] . ';' . "\n" . '}' . "\n" . "\n" . '#extra_panel a {' . "\n" . '	background: ' . ($context['flexible_extra_a_bg'] ? $context['flexible_extra_a_bg'] : 'transparent') . ';' . "\n" . '	color: ' . $context['flexible_extra_a_color'] . ';' . "\n" . '	font-family: ' . $context['flexible_extra_a_family'] . ';' . "\n" . '	font-size: ' . $context['flexible_extra_a_size'] . ';' . "\n" . '	font-weight: ' . $context['flexible_extra_a_weight'] . ';' . "\n" . '	text-decoration: ' . $context['flexible_extra_a_decoration'] . ';' . "\n" . '}' . "\n" . "\n" . '#extra_panel a:hover {' . "\n" . '	background: ' . ($context['flexible_extra_h_bg'] ? $context['flexible_extra_h_bg'] : 'transparent') . ';' . "\n" . '	color: ' . $context['flexible_extra_h_color'] . ';' . "\n" . '	text-decoration: ' . $context['flexible_extra_h_decoration'] . ';' . "\n" . '}' . "\n" . "\n";
 // extra boxes in extra panel
 //
 $needles[] = '!!extra_box!!';
 $values[] = 'dl.extra_box { /* one box */' . "\n" . '	background: ' . $context['flexible_extra_dl_bg'] . ';' . "\n" . '}' . "\n\n" . 'dl.extra_box dt { /* box title */' . "\n" . '	background: ' . $context['flexible_extra_dt_bg'] . ';' . "\n" . '	border-bottom: ' . $context['flexible_extra_dt_bottom'] . ';' . "\n" . '	border-left: ' . $context['flexible_extra_dt_left'] . ';' . "\n" . '	border-right: ' . $context['flexible_extra_dt_right'] . ';' . "\n" . '	border-top: ' . $context['flexible_extra_dt_top'] . ';' . "\n" . '	color: ' . $context['flexible_extra_dt_color'] . ';' . "\n" . '	font-family: ' . $context['flexible_extra_dt_family'] . ';' . "\n" . '	font-size: ' . $context['flexible_extra_dt_size'] . ';' . "\n" . '	font-weight: ' . $context['flexible_extra_dt_weight'] . ';' . "\n" . '	margin: ' . $context['flexible_extra_dt_margin'] . ';' . "\n" . '	padding: ' . $context['flexible_extra_dt_padding'] . ';' . "\n" . '}' . "\n\n" . 'dl.extra_box dd { /* box content */' . "\n" . '	border-bottom: ' . $context['flexible_extra_dd_bottom'] . ';' . "\n" . '	border-left: ' . $context['flexible_extra_dd_left'] . ';' . "\n" . '	border-right: ' . $context['flexible_extra_dd_right'] . ';' . "\n" . '	border-top: ' . $context['flexible_extra_dd_top'] . ';' . "\n" . '	margin: ' . $context['flexible_extra_dd_margin'] . ';' . "\n" . '	padding: ' . $context['flexible_extra_dd_padding'] . ';' . "\n" . '}' . "\n";
 // footer panel
 $needles[] = '!!footer_panel!!';
 $values[] = 'tr#footer_panel td {' . "\n" . '	text-align: ' . $context['flexible_footer_align'] . ';' . "\n" . '	background: ' . $context['flexible_footer_bg'] . ';' . "\n" . '	border-bottom: ' . $context['flexible_footer_bottom'] . ';' . "\n" . '	border-left: ' . $context['flexible_footer_left'] . ';' . "\n" . '	border-right: ' . $context['flexible_footer_right'] . ';' . "\n" . '	border-top: ' . $context['flexible_footer_top'] . ';' . "\n" . '	color: ' . $context['flexible_footer_color'] . ';' . "\n" . '	font-family: ' . $context['flexible_footer_family'] . ';' . "\n" . '	font-size: ' . $context['flexible_footer_size'] . ';' . "\n" . '	font-weight: ' . $context['flexible_footer_weight'] . ';' . "\n" . '	height: ' . $context['flexible_footer_height'] . ';' . "\n" . '	margin: 0;' . "\n" . '	padding: ' . $context['flexible_footer_padding'] . ';' . "\n" . '}' . "\n" . "\n" . '#footer_panel a {' . "\n" . '	background: ' . $context['flexible_footer_a_bg'] . ';' . "\n" . '	color: ' . $context['flexible_footer_a_color'] . ';' . "\n" . '	font-family: ' . $context['flexible_footer_a_family'] . ';' . "\n" . '	font-size: ' . $context['flexible_footer_a_size'] . ';' . "\n" . '	font-weight: ' . $context['flexible_footer_a_weight'] . ';' . "\n" . '	text-decoration: ' . $context['flexible_footer_a_decoration'] . ';' . "\n" . '}' . "\n" . "\n" . '#footer_panel a:hover {' . "\n" . '	background: ' . $context['flexible_footer_h_bg'] . ';' . "\n" . '	color: ' . $context['flexible_footer_h_color'] . ';' . "\n" . '	text-decoration: ' . $context['flexible_footer_h_decoration'] . ';' . "\n" . '}' . "\n";
 // do the transformation
 $content = str_replace($needles, $values, $content);
 // backup old styles
 Safe::unlink($context['path_to_root'] . $styles_file . '.bak');
 Safe::rename($context['path_to_root'] . $styles_file, $context['path_to_root'] . $styles_file . '.bak');
 // save updated styles
 if (!Safe::file_put_contents($styles_file, $content)) {
     Logger::error(sprintf(i18n::s('ERROR: Impossible to write to the file %s. Styles sheet has not been saved.'), $styles_file));
     // allow for a manual update
     $context['text'] .= '<p style="text-decoration: blink;">' . sprintf(i18n::s('To actually change the configuration, please copy and paste following lines by yourself in file %s.'), $styles_file) . "</p>\n";
     // display updated styles
     $context['text'] .= Skin::build_box(i18n::s('Styles'), Skin::build_block($content, 'code'), 'folded');
 } else {
     $context['text'] .= '<p>' . sprintf(i18n::s('Styles sheet has been saved into the file %s.'), $styles_file) . "</p>\n";
     // display updated styles
     $context['text'] .= Skin::build_box(i18n::s('Styles'), Skin::build_block($content, 'code'), 'folded');
     // purge the cache
     Cache::clear();
     // remember the change
     $label = sprintf(i18n::c('%s has been updated'), $styles_file);
     Logger::remember('skins/flexible/configure.php: ' . $label);
 }
开发者ID:rair,项目名称:yacs,代码行数:31,代码来源:configure.php

示例11: while

             if ($skin[0] == '.' || !is_dir('../skins/' . $skin)) {
                 continue;
             }
             if (!file_exists('../skins/' . $skin . '/template.php')) {
                 continue;
             }
             // look for css files
             if ($files = Safe::opendir('../skins/' . $skin)) {
                 while (($file = Safe::readdir($files)) !== FALSE) {
                     if (!preg_match('/\\.css$/i', $file)) {
                         continue;
                     }
                     // change this css file
                     if ($content = Safe::file_get_contents('../skins/' . $skin . '/' . $file)) {
                         $content = str_replace('/yacs/', $context['url_to_root_parameter'], $content);
                         Safe::file_put_contents('skins/' . $skin . '/' . $file, $content);
                     }
                 }
                 Safe::closedir($files);
             }
         }
         Safe::closedir($skins);
     }
     // look for software extensions
     $context['text'] .= Skin::build_block('<form method="get" action="scan.php" id="main_form">' . "\n" . '<p class="assistant_bar">' . Skin::build_submit_button(i18n::s('Look for software extensions'), NULL, 's', 'confirmed') . '</p>' . "\n" . '</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>\n";
     // the followup link, if any
 } elseif (isset($context['followup_link'])) {
     // ensure we have a label
     if (!isset($context['followup_label'])) {
开发者ID:rair,项目名称:yacs,代码行数:31,代码来源:configure.php

示例12: sprintf

 // end the footprints file
 $content .= '?>' . "\n";
 // stop here
 if (!isset($_REQUEST['enable_footprints']) || $_REQUEST['enable_footprints'] != 'Y') {
     $context['text'] .= '<p>' . sprintf(i18n::s('The file %s has not been generated and the reference store can only be used for test purpose.'), $context['path_to_reference'] . 'footprints.php') . "</p>\n";
     // file cannot be saved
 } elseif (!Safe::file_put_contents($context['path_to_reference'] . 'footprints.php', $content)) {
     $context['text'] .= '<p>' . sprintf(i18n::s('Impossible to write to %s.'), $context['path_to_reference'] . 'footprints.php') . "</p>\n";
     // follow-up
 } else {
     $context['text'] .= '<p>' . sprintf(i18n::s('Meta data have been saved in %s'), $context['path_to_reference'] . 'footprints.php') . "</p>\n";
     // also put the file in the archive
     $references[] = array('', 'footprints.php');
 }
 // also update our own version
 Safe::file_put_contents($context['path_to_root'] . 'footprints.php', $content);
 // splash message
 $context['text'] .= '<p>' . i18n::s('On-going archive preparation...') . "\n";
 $file_path = $context['path_to_reference'];
 $file_name = 'temporary/' . gmdate("Ymd") . '_yacs_' . trim($_REQUEST['version']);
 // 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;
开发者ID:rair,项目名称:yacs,代码行数:31,代码来源:build.php

示例13: process

 /**
  * actual transmission of a mail message
  *
  * This function transmit messages to a mail server, as per SMTP protocol.
  *
  * @param string destination address
  * @param string message subject line
  * @param string message content
  * @param mixed message headers
  * @return int the number of transmitted messages, O on error
  */
 private static function process($recipient, $subject, $message, $headers = '')
 {
     global $context;
     // email services have to be activated
     if (!isset($context['with_email']) || $context['with_email'] != 'Y') {
         Logger::error(i18n::s('E-mail has not been enabled on this system.'));
         return 0;
         // check recipient address
     } elseif (!$recipient) {
         Logger::error(i18n::s('Empty recipient address'));
         return 0;
         // check mail subject
     } elseif (!$subject) {
         Logger::error(i18n::s('No subject'));
         return 0;
         // check mail content
     } elseif (!$message) {
         Logger::error(i18n::s('No message'));
         return 0;
     }
     // decode recipient for log
     $decoded_recipient = $recipient;
     if (preg_match('/^=\\?[^\\?]+\\?B\\?(.*)=$/i', $recipient, $matches)) {
         $decoded_recipient = base64_decode($matches[1]);
     }
     // extract the actual e-mail address -- Foo Bar <foo@bar.com> => foo@bar.com
     $tokens = explode(' ', $decoded_recipient);
     $actual_recipient = trim(str_replace(array('<', '>'), '', $tokens[count($tokens) - 1]));
     // decode subject for log
     $decoded_subject = $subject;
     if (preg_match('/^=\\?[^\\?]+\\?B\\?(.*)=$/i', $subject, $matches)) {
         $decoded_subject = base64_decode($matches[1]);
     }
     // mail() is expecting a string
     if (is_array($headers)) {
         $headers = implode("\n", $headers);
     }
     // determine the From: address
     if (isset($context['mail_from']) && $context['mail_from']) {
         $from = $context['mail_from'];
     } else {
         $from = $context['host_name'];
     }
     // From: header is mandatory
     if (!preg_match('/^From: /im', $headers)) {
         $headers .= "\n" . 'From: ' . $from;
     }
     if ($context['debug_mail'] == 'Y') {
         $all_headers = 'Subject: ' . $subject . "\n" . 'To: ' . $decoded_recipient . "\n" . $headers;
         Logger::remember('shared/mailer.php: sending a message to ' . $decoded_recipient, $all_headers . "\n\n" . $message, 'debug');
         Safe::file_put_contents('temporary/mailer.process.txt', $all_headers . "\n\n" . $message);
     }
     // connect to the mail server
     if (!isset($context['mail_handle']) && !Mailer::connect()) {
         return 0;
     }
     // we manage directly the SMTP transaction
     if (isset($context['mail_variant']) && ($context['mail_variant'] == 'pop3' || $context['mail_variant'] == 'smtp')) {
         $handle = $context['mail_handle'];
         // the adress to use on error
         if (preg_match('/<([^>]+)>/', $from, $matches)) {
             $address = $matches[1];
         } else {
             $address = trim($from);
         }
         // say who we are
         $request = 'MAIL FROM:<' . $address . '>';
         fputs($handle, $request . CRLF);
         if ($context['debug_mail'] == 'Y') {
             Logger::remember('shared/mailer.php: SMTP ->', $request, 'debug');
         }
         // expecting an OK
         if (Mailer::parse_response($handle, 250) === FALSE) {
             Logger::remember('shared/mailer.php: Command MAIL FROM has been rejected by server');
             Mailer::close();
             return 0;
         }
         // provide destination address
         $request = 'RCPT TO:<' . $actual_recipient . '>';
         fputs($handle, $request . CRLF);
         if ($context['debug_mail'] == 'Y') {
             Logger::remember('shared/mailer.php: SMTP ->', $request, 'debug');
         }
         // expecting an OK
         if (Mailer::parse_response($handle, 250) === FALSE) {
             Logger::remember('shared/mailer.php: Command RCPT TO has been rejected by server');
             Mailer::close();
             return 0;
         }
//.........这里部分代码省略.........
开发者ID:rair,项目名称:yacs,代码行数:101,代码来源:mailer.php

示例14: layout


//.........这里部分代码省略.........
             } else {
                 $first = Skin::build_date($item['create_date'], 'plain');
             }
             // end
             $last = Skin::build_date($item['edit_date'], 'plain');
             if ($last != $first) {
                 $last = ' end="' . $last . '"';
             } else {
                 $last = '';
             }
             // build a title
             if (is_object($overlay)) {
                 $title = Codes::beautify_title($overlay->get_text('title', $item));
             } else {
                 $title = Codes::beautify_title($item['title']);
             }
             // the url to view this item
             $url = str_replace('&', '&amp;', Articles::get_permalink($item));
             // this is visual
             if (isset($item['icon_url']) && $item['icon_url']) {
                 $image = $item['icon_url'];
             } elseif (isset($item['thumbnail_url']) && $item['thumbnail_url']) {
                 $image = $item['thumbnail_url'];
             } else {
                 $image = '';
             }
             // fix relative path
             if ($image && !preg_match('/^(\\/|http:|https:|ftp:)/', $image)) {
                 $image = $context['url_to_root'] . $image;
             }
             if ($image) {
                 $image = ' image="' . $image . '"';
             }
             // introduction
             $introduction = '';
             if (is_object($overlay)) {
                 $introduction = $overlay->get_text('introduction', $item);
             } else {
                 $introduction = $item['introduction'];
             }
             // insert overlay data, if any
             if (is_object($overlay) && ($data = $overlay->get_text('list', $item))) {
                 if ($introduction) {
                     $introduction .= BR;
                 }
                 $introduction .= $data;
             }
             // ampersands kill SIMILE Timeline
             if ($introduction) {
                 $introduction = encode_field(str_replace(array('&nbsp;', '&'), ' ', Codes::beautify($introduction)));
             }
             // details
             $details = array();
             // info on related comments
             if ($count = Comments::count_for_anchor('article:' . $item['id'], TRUE)) {
                 $details[] = sprintf(i18n::ns('%d comment', '%d comments', $count), $count);
             }
             // info on related files
             if ($count = Files::count_for_anchor('article:' . $item['id'], TRUE)) {
                 $details[] = sprintf(i18n::ns('%d file', '%d files', $count), $count);
             }
             // info on related links
             if ($count = Links::count_for_anchor('article:' . $item['id'], TRUE)) {
                 $details[] = sprintf(i18n::ns('%d link', '%d links', $count), $count);
             }
             // combine in-line details
             if (count($details)) {
                 if ($introduction) {
                     $introduction .= BR;
                 }
                 $introduction .= '<span class="details">' . trim(implode(', ', $details)) . '</span>';
             }
             // escape the introduction, if any
             if ($introduction) {
                 $introduction = str_replace(array('<', '&'), array('&lt;', '&amp;'), $introduction);
             }
             // add to the list
             $content .= '	<event start="' . $first . '"' . $last . ' title="' . encode_field(str_replace(array("&nbsp;", '"'), ' ', $title)) . '" link="' . $url . '"' . $image . '>' . "\n" . '		' . $introduction . "\n" . '	</event>' . "\n";
         }
         // finalize slideshow content
         $content .= '</data>';
         // put in cache
         Safe::file_put_contents($cache_id, $content);
     }
     // allow multiple instances
     static $count;
     if (!isset($count)) {
         $count = 1;
     } else {
         $count++;
     }
     // 1 week ago
     $now = gmdate('M d Y H:i:s', time() - 7 * 24 * 60 * 60);
     // load the right file
     $text = '<div id="articles_as_simile_' . $count . '" style="height: 300px; border: 1px solid #aaa; font-size: 10px"></div>' . "\n";
     Page::insert_script('var simile_handle_' . $count . ';' . "\n" . 'function onLoad' . $count . '() {' . "\n" . '  var eventSource = new Timeline.DefaultEventSource();' . "\n" . '  var bandInfos = [' . "\n" . '    Timeline.createBandInfo({' . "\n" . '        eventSource:    eventSource,' . "\n" . '        date:           "' . $now . '",' . "\n" . '        width:          "80%",' . "\n" . '        intervalUnit:   Timeline.DateTime.WEEK,' . "\n" . '        intervalPixels: 200' . "\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_' . $count . ' = Timeline.create(document.getElementById("articles_as_simile_' . $count . '"), bandInfos);' . "\n" . '  Timeline.loadXML("' . $context['url_to_home'] . $context['url_to_root'] . $cache_id . '", function(xml, url) { eventSource.loadXML(xml, url); });' . "\n" . '}' . "\n" . "\n" . 'var resizeTimerID' . $count . ' = null;' . "\n" . 'function onResize' . $count . '() {' . "\n" . '    if (resizeTimerID' . $count . ' == null) {' . "\n" . '        resizeTimerID' . $count . ' = window.setTimeout(function() {' . "\n" . '            resizeTimerID' . $count . ' = null;' . "\n" . '            simile_handle_' . $count . '.layout();' . "\n" . '        }, 500);' . "\n" . '    }' . "\n" . '}' . "\n" . "\n" . '// observe page major events' . "\n" . '$(document).ready( onLoad' . $count . ');' . "\n" . '$(window).resize(onResize' . $count . ');' . "\n");
     // end of processing
     SQL::free($result);
     return $text;
 }
开发者ID:rair,项目名称:yacs,代码行数:101,代码来源:layout_articles_as_simile.php

示例15: elseif

} elseif (file_exists($context['path_to_root'] . 'parameters/demo.flag')) {
    Safe::header('Status: 401 Unauthorized', TRUE, 401);
    Logger::error(i18n::s('You are not allowed to perform this operation.'));
    // save updated parameters
} else {
    // build the new configuration file
    $content = '<?php' . "\n" . '// This file has been created by the configuration script overlays/bbb_meetings/configure.php' . "\n" . '// on ' . gmdate("F j, Y, g:i a") . ' GMT, for ' . Surfer::get_name() . '. Please do not modify it manually.' . "\n";
    if (isset($_REQUEST['bbb_server'])) {
        $content .= '$context[\'bbb_server\']=\'' . addcslashes($_REQUEST['bbb_server'], "\\'") . "';\n";
    }
    if (isset($_REQUEST['bbb_salt'])) {
        $content .= '$context[\'bbb_salt\']=\'' . addcslashes($_REQUEST['bbb_salt'], "\\'") . "';\n";
    }
    $content .= '?>' . "\n";
    // update the parameters file
    if (!Safe::file_put_contents('parameters/overlays.bbb_meetings.include.php', $content)) {
        Logger::error(sprintf(i18n::s('ERROR: Impossible to write to the file %s. The configuration has not been saved.'), 'parameters/overlays.bbb_meetings.include.php'));
        // report to end-user
    } else {
        $context['text'] .= '<p>' . sprintf(i18n::s('The following configuration has been saved into the file %s.'), 'parameters/overlays.bbb_meetings.include.php') . "</p>\n";
        // purge the cache
        Cache::clear();
        // remember the change
        $label = sprintf(i18n::c('%s has been updated'), 'parameters/overlays.bbb_meetings.include.php');
        Logger::remember('overlays/bbb_meetings/configure.php: ' . $label);
        // display updated parameters
        $context['text'] .= Skin::build_box(i18n::s('Configuration parameters'), Safe::highlight_string($content), 'folded');
        // follow-up commands
        $follow_up = i18n::s('Where do you want to go now?');
        $menu = array();
        $menu = array_merge($menu, array('control/' => i18n::s('Control Panel')));
开发者ID:rair,项目名称:yacs,代码行数:31,代码来源:configure.php


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