/** * 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('>', '<', '&', '"', '\\"'), 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; }
} 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
$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
/** * process all messages from one mailbox * * This is original code compliant to RFC 1939 for the authentication, * fetching and processing of messages queued in a POP3 mailbox. * * @param array of mailbox attributes ($server, $account, $password) * @return the number of processed messages */ public static function process_queue($queue) { global $context; // useless if we don't have a valid database connection if (!$context['connection']) { return 0; } // make queue parameters available $context['mail_queue'] = $queue; // use queue parameters to connect to the server list($server, $account, $password, $allowed, $match, $section, $options, $hooks, $prefix, $suffix) = $queue; // no host, assume it's us if (!$server) { $server = $context['host_name']; } // assume the standard pop3 socket $port = 110; // use alternate port if required to do so if (preg_match('/^(.+):([0-9]+)$/', $server, $matches)) { $server = $matches[1]; $port = intval($matches[2]); } // ensure that we can support tls communications if (isset($server) && !strncmp($server, 'ssl://', 6) && is_callable('extension_loaded') && !extension_loaded('openssl')) { Logger::remember('agents/messages.php: Load the OpenSSL extension to support secured transmissions to mail server ' . $server); return 0; } // open a network connection if (!($handle = Safe::fsockopen($server, $port, $errno, $errstr, 10))) { Logger::remember('agents/messages.php: ' . sprintf('Impossible to connect to %s', $server)); return 0; } // ensure enough execution time Safe::set_time_limit(30); // get server banner if (($reply = fgets($handle)) === FALSE) { Logger::remember('agents/messages.php: Impossible to get banner of ' . $server); fclose($handle); return 0; } if ($context['debug_messages'] == 'Y') { Logger::remember('agents/messages.php: POP <-', rtrim($reply), 'debug'); } // expecting an OK if (strncmp($reply, '+OK', 3)) { Logger::remember('agents/messages.php: Mail service is closed at ' . $server, rtrim($reply)); fclose($handle); return 0; } // maybe the server accepts APOP $stamp = ''; if (preg_match('/<.+@.+>/U', $reply, $matches)) { $stamp = $matches[0]; } // we will go with APOP, only if explicitly allowed $authenticated = FALSE; if ($stamp && preg_match('/\\bwith_apop\\b/i', $options)) { // the digest if ($context['debug_messages'] == 'Y') { Logger::remember('agents/messages.php: POP stamp', $stamp . $password, 'debug'); } $hash = md5($stamp . $password); // send user name and hash $request = 'APOP ' . $account . ' ' . $hash; 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 APOP command at ' . $server); fclose($handle); return 0; } if ($context['debug_messages'] == 'Y') { Logger::remember('agents/messages.php: POP <-', rtrim($reply), 'debug'); } if (strncmp($reply, '+OK', 3)) { Logger::remember('agents/messages.php: Impossible to authenticate account ' . $account . ' at ' . $server, rtrim($reply)); } else { $authenticated = TRUE; } } // we will transmit the password in clear if (!$authenticated) { // send user name $request = 'USER ' . $account; 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 USER command at ' . $server); fclose($handle); return 0; } if ($context['debug_messages'] == 'Y') { Logger::remember('agents/messages.php: POP <-', rtrim($reply), 'debug'); } if (strncmp($reply, '+OK', 3)) { Logger::remember('agents/messages.php: Unknown account ' . $account . ' at ' . $server, rtrim($reply)); fclose($handle); return 0; } // send password $request = 'PASS ' . $password; 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 PASS command at ' . $server); fclose($handle); return 0; } if ($context['debug_messages'] == 'Y') { Logger::remember('agents/messages.php: POP <-', rtrim($reply), 'debug'); } if (strncmp($reply, '+OK', 3)) { Logger::remember('agents/messages.php: Invalid password for account ' . $account . ' at ' . $server, rtrim($reply)); fclose($handle); return 0; } } // ask for information $request = 'STAT'; 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 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; }
/** * 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')); } }
/** * embed an interactive object * * The id designates the target file. * It can also include width and height of the target canvas, as in: '12, 100%, 250px' * * @param string id of the target file * @return string the rendered string **/ public static function render_embed($id) { global $context; // split parameters $attributes = preg_split("/\\s*,\\s*/", $id, 4); $id = $attributes[0]; // get the file if (!($item = Files::get($id))) { $output = '[embed=' . $id . ']'; return $output; } // stream in a separate page if (isset($attributes[1]) && preg_match('/window/i', $attributes[1])) { if (!isset($attributes[2])) { $attributes[2] = i18n::s('Play in a separate window'); } $output = '<a href="' . $context['url_to_home'] . $context['url_to_root'] . Files::get_url($item['id'], 'stream', $item['file_name']) . '" onclick="window.open(this.href); return false;" class="button"><span>' . $attributes[2] . '</span></a>'; return $output; } // file extension $extension = strtolower(substr($item['file_name'], -3)); // set a default size if (!isset($attributes[1])) { if (!strcmp($extension, 'gan')) { $attributes[1] = '98%'; } elseif (!strcmp($extension, 'mm') && isset($context['skins_freemind_canvas_width'])) { $attributes[1] = $context['skins_freemind_canvas_width']; } else { $attributes[1] = 480; } } if (!isset($attributes[2])) { if (!strcmp($extension, 'gan')) { $attributes[2] = '300px'; } elseif (!strcmp($extension, 'mm') && isset($context['skins_freemind_canvas_height'])) { $attributes[2] = $context['skins_freemind_canvas_height']; } else { $attributes[2] = 360; } } // object attributes $width = $attributes[1]; $height = $attributes[2]; $flashvars = ''; if (isset($attributes[3])) { $flashvars = $attributes[3]; } // rendering depends on file extension switch ($extension) { // stream a video case '3gp': case 'flv': case 'm4v': case 'mov': case 'mp4': // a flash player to stream a flash video $flvplayer_url = $context['url_to_home'] . $context['url_to_root'] . 'included/browser/player_flv_maxi.swf'; // file is elsewhere if (isset($item['file_href']) && $item['file_href']) { $url = $item['file_href']; } else { $url = $context['url_to_home'] . $context['url_to_root'] . Files::get_url($item['id'], 'fetch', $item['file_name']); } // pass parameters to the player 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']); // 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)) { $freemind_viewer_index = 1; } else { $freemind_viewer_index++; } // load flash player $url = $context['url_to_home'] . $context['url_to_root'] . 'included/browser/visorFreemind.swf'; // variables $flashvars = 'initLoadFile=' . $target_href . '&openUrl=_self'; $output = '<div id="freemind_viewer_' . $freemind_viewer_index . '">Flash plugin or Javascript are turned off. Activate both and reload to view the object</div>' . "\n"; Page::insert_script('var params = {};' . "\n" . 'params.base = "' . dirname($url) . '/";' . "\n" . 'params.quality = "high";' . "\n" . 'params.wmode = "transparent";' . "\n" . 'params.menu = "false";' . "\n" . 'params.flashvars = "' . $flashvars . '";' . "\n" . 'swfobject.embedSWF("' . $url . '", "freemind_viewer_' . $freemind_viewer_index . '", "' . $width . '", "' . $height . '", "6", "' . $context['url_to_home'] . $context['url_to_root'] . 'included/browser/expressinstall.swf", false, params);' . "\n"); // offer to download a copy of the map $menu = array($target_href => i18n::s('Browse this map with Freemind')); // display menu commands below the viewer $output .= Skin::build_list($menu, 'menu_bar'); // job done return $output; // native flash // native flash case 'swf': // where to get the file if (isset($item['file_href']) && $item['file_href']) { $url = $item['file_href']; } else { $url = $context['url_to_home'] . $context['url_to_root'] . 'files/' . str_replace(':', '/', $item['anchor']) . '/' . rawurlencode($item['file_name']); } $output = '<div id="swf_' . $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 params = {};' . "\n" . 'params.base = "' . dirname($url) . '/";' . "\n" . 'params.quality = "high";' . "\n" . 'params.wmode = "transparent";' . "\n" . 'params.allowfullscreen = "true";' . "\n" . 'params.allowscriptaccess = "always";' . "\n" . 'params.flashvars = "' . $flashvars . '";' . "\n" . 'swfobject.embedSWF("' . $url . '", "swf_' . $item['id'] . '", "' . $width . '", "' . $height . '", "6", "' . $context['url_to_home'] . $context['url_to_root'] . 'included/browser/expressinstall.swf", false, params);' . "\n"); return $output; // link to file page // link to file page default: // link label $text = Skin::strip($item['title'] ? $item['title'] : str_replace('_', ' ', $item['file_name'])); // make a link to the target page $url = Files::get_permalink($item); // return a complete anchor $output =& Skin::build_link($url, $text); return $output; } }
$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
} if (isset($_REQUEST['channel_title'])) { $content .= '$context[\'channel_title\']=\'' . addcslashes($_REQUEST['channel_title'], "\\'") . "';\n"; } if (isset($_REQUEST['channel_description'])) { $content .= '$context[\'channel_description\']=\'' . addcslashes($_REQUEST['channel_description'], "\\'") . "';\n"; } if (isset($_REQUEST['time_to_live'])) { $content .= '$context[\'time_to_live\']=\'' . addcslashes($_REQUEST['time_to_live'], "\\'") . "';\n"; } if (isset($_REQUEST['webmaster_address'])) { $content .= '$context[\'webmaster_address\']=\'' . addcslashes($_REQUEST['webmaster_address'], "\\'") . "';\n"; } $content .= '?>' . "\n"; // update the parameters file if (!Safe::file_put_contents('parameters/feeds.include.php', $content)) { Logger::error(sprintf(i18n::s('ERROR: Impossible to write to the file %s. The configuration has not been saved.'), 'parameters/feeds.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/feeds.include.php') . "</p>\n"; // job done } else { $context['text'] .= '<p>' . sprintf(i18n::s('The following configuration has been saved into the file %s.'), 'parameters/feeds.include.php') . "</p>\n"; // purge the cache Cache::clear('feeds'); // remember the change $label = sprintf(i18n::c('%s has been updated'), 'parameters/feeds.include.php'); Logger::remember('feeds/configure.php: ' . $label); } // display updated parameters $context['text'] .= Skin::build_box(i18n::s('Configuration parameters'), Safe::highlight_string($content), 'folded'); // follow-up commands
} 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\'écrire le fichier ' . $file . '.'; echo i18n::user('label') . "<br />\n"; } else { $local['label_en'] = 'has been updated'; $local['label_fr'] = 'a été mis à 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';
} // 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();
$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); }
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'])) {
// 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;
/** * 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 $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; } // actual transmission $request = 'DATA'; 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, 354) === FALSE) { Logger::remember('shared/mailer.php: Command DATA has been rejected by server'); Mailer::close(); return 0; } // To: header if (!preg_match('/^To: /im', $headers)) { $headers .= "\n" . 'To: ' . $recipient; } // prepare message headers $headers = trim($headers . "\n" . 'Subject: ' . $subject) . "\n"; // reenforce SMTP specification //$headers = str_replace("\n", CRLF, $headers); // Fix any bare linefeeds in the message to make it RFC821 Compliant. $message = preg_replace("/(?<!\r)\n/si", "\r\n", $message); // Make sure there are no bare linefeeds in the headers $headers = preg_replace('/(?<!\\r)\\n/si', "\r\n", $headers); // append message body $request = $headers . CRLF . $message . CRLF . '.' . CRLF; // actual post fputs($handle, $request); 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: Message has been rejected by server'); Mailer::close(); return 0; } // rely on system settings and PHP } elseif (is_callable('mail')) { // submit the post if (!@mail($actual_recipient, $subject, $message, $headers)) { if (isset($context['debug_mail']) && $context['debug_mail'] == 'Y') { Logger::remember('shared/mailer.php: ' . sprintf(i18n::s('Error while sending the message to %s'), $decoded_recipient), $decoded_subject, 'debug'); } elseif ($context['with_debug'] == 'Y') { Logger::remember('shared/mailer.php: ' . sprintf(i18n::s('Error while sending the message to %s'), $decoded_recipient), $decoded_subject, 'debug'); } return 0; } // don't know how to send messages } else { Logger::remember('shared/mailer.php: ' . i18n::s('E-mail has not been enabled on this system.')); return 0; } // track last post include_once $context['path_to_root'] . 'shared/values.php'; Values::set('mailer.last.posted', $decoded_subject . ' (' . $decoded_recipient . ')'); // job done if ($context['debug_mail'] == 'Y') { Logger::remember('shared/mailer.php: one message has been transmitted to ' . $decoded_recipient, $decoded_subject, 'debug'); } return 1; }
/** * list articles * * @param resource the SQL result * @return string the rendered text * * @see layouts/layout.php **/ function layout($result) { global $context; // we return some text $text = ''; // empty list if (!SQL::count($result)) { return $text; } // load the SIMILE Timeline javascript library in shared/global.php $context['javascript']['timeline'] = TRUE; // sanity check if (!isset($this->focus)) { $this->focus = 'default'; } // put in cache $cache_id = Cache::hash('articles/layout_articles_as_simile:' . $this->focus) . '.xml'; // save for one minute if (!file_exists($context['path_to_root'] . $cache_id) || filemtime($context['path_to_root'] . $cache_id) + 60 < time()) { // content of the slideshow $content = '<?xml version="1.0" encoding="utf-8"?>' . "\n" . '<data>' . "\n"; // get a default image if (Safe::GetImageSize($context['path_to_root'] . $context['skin'] . '/layouts/map.gif')) { $default_href = $context['url_to_root'] . $context['skin'] . '/layouts/map.gif'; } elseif ($size = Safe::GetImageSize($context['path_to_root'] . 'skins/_reference/layouts/map.gif')) { $default_href = $context['url_to_root'] . 'skins/_reference/layouts/map.gif'; } else { $default_href = NULL; } // process all items in the list while ($item = SQL::fetch($result)) { // get the related overlay $overlay = Overlay::load($item, 'article:' . $item['id']); // get the anchor $anchor = Anchors::get($item['anchor']); // start if ($item['publish_date'] > $item['create_date']) { $first = Skin::build_date($item['publish_date'], 'plain'); } 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('&', '&', 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(' ', '&'), ' ', 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('<', '&'), $introduction); } // add to the list $content .= ' <event start="' . $first . '"' . $last . ' title="' . encode_field(str_replace(array(" ", '"'), ' ', $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; }
} 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')));
Logger::error(i18n::s('You are not allowed to perform this operation.')); // ensure the file already exists } elseif ($file && !file_exists($context['path_to_root'] . 'skins/' . $skin . '/' . $file)) { Safe::header('Status: 401 Unauthorized', TRUE, 401); Logger::error(i18n::s('You are not allowed to perform this operation.')); // save the content of an updated file } elseif (isset($_REQUEST['content']) && $_REQUEST['content']) { // warning if modification of some reference skin if (isset($_REQUEST['content']) && $_REQUEST['content'] && preg_match('/^(boxesandarrows|digital|joi|skeleton)$/', $skin)) { Logger::error(sprintf(i18n::s('Do not attempt to modify a reference theme directly, your changes would be overwritten on next software update. %s instead to preserve your work over time.'), Skin::build_link('skins/derive.php', i18n::s('Derive a theme'), 'shortcut'))); } // backup the old version, if any Safe::unlink($context['path_to_root'] . 'skins/' . $skin . '/' . $file . '.bak'); Safe::rename($context['path_to_root'] . 'skins/' . $skin . '/' . $file, $context['path_to_root'] . 'skins/' . $skin . '/' . $file . '.bak'); // actual save if (Safe::file_put_contents('skins/' . $skin . '/' . $file, $_REQUEST['content']) != strlen($_REQUEST['content'])) { Logger::error(sprintf(i18n::s('The target file %s may have been corrupted. Please check file content manually, and revert to the backup file, with the extension .bak, if necessary.'), 'skins/' . $skin . '/' . $file)); } else { $context['text'] .= '<p>' . sprintf(i18n::s('The target file %s has been successfully updated.'), 'skins/' . $skin . '/' . $file) . '</p>'; // follow-up commands $follow_up = i18n::s('What do you want to do now?'); $menu = array(); $menu = array_merge($menu, array('skins/test.php?skin=' . urlencode($skin) => i18n::s('Test this theme'))); $menu = array_merge($menu, array('skins/edit.php?skin=' . urlencode($skin) => i18n::s('Edit this theme'))); $menu = array_merge($menu, array('skins/' => i18n::s('Themes'))); $menu = array_merge($menu, array('skins/configure.php' => i18n::s('Configure the page factory'))); $follow_up .= Skin::build_list($menu, 'menu_bar'); $context['text'] .= Skin::build_block($follow_up, 'bottom'); } // select the file to edit } 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)) { $context['text'] .= sprintf(i18n::s('Impossible to copy file %s.'), $target) . BR . "\n"; $errors++; // attempt to preserve the modification date of the origin file } else { Safe::touch($context['path_to_root'] . $target, Safe::filemtime($context['path_to_root'] . $origin)); $context['text'] .= sprintf(i18n::s('%s has been copied'), $target) . BR . "\n"; } // this will be filtered by umask anyway
if (isset($context['powered_by_image']) && $context['powered_by_image']) { $values['channel']['image'] = $context['url_to_home'] . $context['url_to_root'] . $context['powered_by_image']; } // list comments from the database -- no more than 100 at a time if (is_object($anchor)) { $values['items'] = Comments::list_by_date_for_anchor($anchor->get_reference(), 0, 100, 'feed'); } else { $values['items'] = Comments::list_by_date(0, 100, 'feed'); } // make a text include_once '../services/codec.php'; include_once '../services/rss_codec.php'; $result = rss_Codec::encode($values); $text = @$result[1]; // put in cache Safe::file_put_contents($cache_id, $text); } // // transfer to the user agent // // handle the output correctly render_raw('text/xml; charset=' . $context['charset']); // suggest a name on download if (!headers_sent()) { if (is_object($anchor)) { $file_name = $context['site_name'] . '.comments.' . str_replace(':', '.', $anchor->get_reference()) . '.xml'; } else { $file_name = $context['site_name'] . '.comments.xml'; } $file_name =& utf8::to_ascii($file_name); Safe::header('Content-Disposition: inline; filename="' . $file_name . '"');
// 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"; } // render the skin render_skin();
/** * list articles * * @param resource the SQL result * @return string the rendered text * * @see layouts/layout.php **/ function layout($result) { global $context; // we return some text $text = ''; // empty list if (!SQL::count($result)) { return $text; } // sanity check if (!isset($this->focus)) { $this->focus = 'map'; } // put in cache $cache_id = Cache::hash('articles/layout_articles_as_carrousel:' . $this->focus) . '.xml'; // save for one minute if (!file_exists($context['path_to_root'] . $cache_id) || filemtime($context['path_to_root'] . $cache_id) + 60 < time()) { // content of the slideshow $content = '<?xml version="1.0" encoding="utf-8"?><!-- fhShow Carousel 2.0 configuration file Please visit http://www.flshow.net/ -->' . "\n" . '<slide_show>' . "\n" . ' <options>' . "\n" . ' <debug>false</debug> <!-- true, false -->' . "\n" . ' <background>transparent</background> <!-- #RRGGBB, transparent -->' . "\n" . ' <friction>5</friction> <!-- [1,100] -->' . "\n" . ' <fullscreen>false</fullscreen> <!-- true, false -->' . "\n" . ' <margins>' . "\n" . ' <top>0</top> <!-- [-1000,1000] pixels -->' . "\n" . ' <left>0</left> <!-- [-1000,1000] pixels -->' . "\n" . ' <bottom>0</bottom> <!-- [-1000,1000] pixels -->' . "\n" . ' <right>0</right> <!-- [-1000,1000] pixels -->' . "\n" . ' <horizontal_ratio>20%</horizontal_ratio> <!-- [1,50] a photo may occupy at most horizontalRatio percent of the Carousel width -->' . "\n" . ' <vertical_ratio>90%</vertical_ratio> <!-- [1,100] a photo may occupy at most verticalRatio percent of the Carousel height -->' . "\n" . ' </margins>' . "\n" . ' <interaction>' . "\n" . ' <rotation>mouse</rotation> <!-- auto, mouse, keyboard -->' . "\n" . ' <view_point>none</view_point> <!-- none, mouse, keyboard -->' . "\n" . ' <speed>15</speed> <!-- [-360,360] degrees per second -->' . "\n" . ' <default_speed>15</default_speed> <!-- [-360,360] degrees per second -->' . "\n" . ' <default_view_point>20%</default_view_point> <!-- [0,100] percentage -->' . "\n" . ' <reset_delay>20</reset_delay> <!-- [0,600] seconds, 0 means never reset -->' . "\n" . ' </interaction>' . "\n" . ' <far_photos>' . "\n" . ' <size>50%</size> <!-- [0,100] percentage -->' . "\n" . ' <amount>50%</amount> <!-- [0,100] percentage -->' . "\n" . ' <blur>10</blur> <!-- [0,100] amount -->' . "\n" . ' <blur_quality>3</blur_quality> <!-- [1,3] 1=low - 3=high -->' . "\n" . ' </far_photos>' . "\n" . ' <reflection>' . "\n" . ' <amount>25</amount> <!-- [0,1000] pixels -->' . "\n" . ' <blur>2</blur> <!-- [0,100] blur amount -->' . "\n" . ' <distance>0</distance> <!-- [-1000,1000] pixels -->' . "\n" . ' <alpha>40%</alpha> <!-- [0,100] percentage -->' . "\n" . ' </reflection>' . "\n" . ' <titles>' . "\n" . ' <style>font-size: 14px; font-family: Verdana, _serif; color: #000000;</style>' . "\n" . ' <position>above center</position> <!-- [above, below] [left,center,right]-->' . "\n" . ' <background>' . $context['url_to_home'] . $context['url_to_root'] . 'skins/_reference/layouts/carrousel_bubble.png</background> <!-- image url -->' . "\n" . ' <scale9>35 35 35 35</scale9> <!-- [0,1000] pixels -->' . "\n" . ' <padding>8 15 10 15</padding> <!-- [-1000,1000] pixels -->' . "\n" . ' </titles>' . "\n" . ' </options>' . "\n"; // get a default image if (Safe::GetImageSize($context['path_to_root'] . $context['skin'] . '/layouts/map.gif')) { $default_href = $context['url_to_root'] . $context['skin'] . '/layouts/map.gif'; } elseif ($size = Safe::GetImageSize($context['path_to_root'] . 'skins/_reference/layouts/map.gif')) { $default_href = $context['url_to_root'] . 'skins/_reference/layouts/map.gif'; } else { $default_href = NULL; } // process all items in the list while ($item = SQL::fetch($result)) { // get the related overlay $overlay = Overlay::load($item, 'article:' . $item['id']); // get the anchor $anchor = Anchors::get($item['anchor']); // 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']; } elseif (is_callable(array($anchor, 'get_bullet_url')) && ($image = $anchor->get_bullet_url())) { } elseif ($default_href) { $image = $default_href; } else { continue; } // fix relative path if (!preg_match('/^(\\/|http:|https:|ftp:)/', $image)) { $image = $context['url_to_home'] . $context['url_to_root'] . $image; } // 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 = Articles::get_permalink($item); // add to the list $content .= ' <photo>' . "\n" . ' <title>' . $title . '</title>' . "\n" . ' <src>' . $image . '</src>' . "\n" . ' <href>' . $url . '</href>' . "\n" . ' <target>_self</target>' . "\n" . ' </photo>' . "\n"; } // finalize slideshow content $content .= '</slide_show>'; // put in cache Safe::file_put_contents($cache_id, $content); } // allow multiple instances static $count; if (!isset($count)) { $count = 1; } else { $count++; } // load the right file $text = '<div id="articles_as_carrousel_' . $count . '"></div>' . "\n"; Page::insert_script('swfobject.embedSWF("' . $context['url_to_home'] . $context['url_to_root'] . 'included/browser/carrousel.swf",' . "\n" . '"articles_as_carrousel_' . $count . '",' . "\n" . '"100%",' . "\n" . '"150",' . "\n" . '"9.0.0",' . "\n" . 'false,' . "\n" . '{xmlfile:"' . $context['url_to_home'] . $context['url_to_root'] . $cache_id . '", loaderColor:"0x666666"},' . "\n" . '{wmode: "transparent"},' . "\n" . '{});' . "\n"); // end of processing SQL::free($result); return $text; }
/** * explode one archive * * @param string archive to handle * @param string the place where extracted files have to be placed * @param string the prefix to be removed from entry names (typically, 'yacs/') * @param function to be called on any file extracted * @return int the number of files that have been successfully extracted */ function explode($archive, $path = '', $remove = '', $callback = NULL) { global $context; // terminate path, if applicable if (strlen($path) && substr($path, -1) != '/') { $path .= '/'; } // ensure we can invoke functions we need if (!is_callable('zip_open') || !is_callable('zip_read') || !is_callable('zip_entry_name') || !is_callable('zip_entry_open') || !is_callable('zip_entry_read') || !is_callable('zip_entry_filesize')) { Logger::error(i18n::c('Impossible to extract files.')); return 0; } // incorrect file if (!($handle = zip_open($archive))) { Logger::error(sprintf(i18n::c('Impossible to read %s.'), $archive)); return 0; } // read all entries $count = 0; while ($item = zip_read($handle)) { // full name, as recorded in the archive if (!($name = zip_entry_name($item))) { continue; } // sanity check if (strlen($name) < 1 || $name[0] != '/' && ($name[0] < ' ' || $name[0] > 'z')) { continue; } // directories are created on actual content if (substr($name, -1) == '/') { continue; } // remove path prefix, if any if ($remove) { $name = preg_replace('/^' . preg_quote($remove, '/') . '/', '', $name); } // read entry content if (!zip_entry_open($handle, $item, 'rb')) { continue; } if ($size = zip_entry_filesize($item)) { $content = zip_entry_read($item, $size); } else { $content = ''; } // write the extracted file if (Safe::file_put_contents($path . $name, $content)) { $count++; // callback function if ($callback) { $callback($path . $name); } } // make room for next item if (is_callable('zip_entry_close')) { zip_entry_close($item); } } // done if (is_callable('zip_close')) { zip_close($handle); } // everything went well return $count; }
if (is_callable(array('i18n', 'reset'))) { i18n::reset(); } // switch off } elseif (isset($_REQUEST['action']) && $_REQUEST['action'] == 'off') { // build the new configuration file $content = '<?php' . "\n" . '// This file has been created by the configuration script control/switch.php' . "\n" . '// on ' . gmdate("F j, Y, g:i a") . ' GMT, for ' . Surfer::get_name() . '. Please do not modify it manually.' . "\n" . 'global $context;' . "\n"; if (isset($_REQUEST['switch_target'])) { $content .= '$context[\'switch_target\']=\'' . addcslashes($_REQUEST['switch_target'], "\\'") . "';\n"; } if (isset($_REQUEST['switch_contact'])) { $content .= '$context[\'switch_contact\']=\'' . addcslashes($_REQUEST['switch_contact'], "\\'") . "';\n"; } $content .= '?>' . "\n"; // save switch parameters, if any if (!Safe::file_put_contents('parameters/switch.include.php', $content)) { // not enough rights to write the file Logger::error(sprintf(i18n::s('Impossible to write to %s.'), 'parameters/switch.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/switch.include.php') . "</p>\n"; // display updated parameters $context['text'] .= Skin::build_box(i18n::s('Configuration'), Safe::highlight_string($content), 'folded'); } // rename the switch file if (Safe::rename($context['path_to_root'] . 'parameters/switch.on', $context['path_to_root'] . 'parameters/switch.off')) { Logger::error(i18n::s('The server has been switched OFF. Switch it back on as soon as possible.')); // remember the change $label = i18n::c('The server has been switched off.'); Logger::remember('control/switch.php: ' . $label); // if the server is currently switched off } elseif (file_exists($context['path_to_root'] . 'parameters/switch.off')) {
// 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) { $context['text'] .= 'included/calendar/'.basename($name).' -> .js.jsmin'.BR."\n"; // we do have some content if($text = Safe::file_get_contents($name)) { // actual compression $text = JSMin::minify($text);