예제 #1
0
파일: switch.php 프로젝트: rair/yacs
 $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')) {
     Logger::error(i18n::s('The server is currently switched off. All users are redirected to the closed page.'));
 } else {
     Logger::error(i18n::s('Impossible to rename the file parameters/switch.on to parameters/switch.off. Do it yourself manually if you like.'));
 }
 // follow-up commands
 $menu = array();
예제 #2
0
파일: scan.php 프로젝트: rair/yacs
        $context['text'] .= Skin::build_block('<form method="post" action="setup.php"><p class="assistant_bar">' . "\n" . Skin::build_submit_button(i18n::s('Database maintenance')) . "\n" . '<input type="hidden" name="action" value="build" />' . "\n" . '</p></form>', 'bottom');
        // this may take several minutes
        $context['text'] .= '<p>' . i18n::s('When you will click on the button the server will be immediately requested to proceed. However, because of the so many things to do on the back-end, you may have to wait for minutes before getting a response displayed. Thank you for your patience.') . '</p>';
        // create the database on first installation
    } elseif (!file_exists('../parameters/switch.on')) {
        $context['text'] .= Skin::build_block('<form method="post" action="setup.php"><p class="assistant_bar">' . "\n" . Skin::build_submit_button(i18n::s('Create tables in the database')) . "\n" . '<input type="hidden" name="action" value="build" />' . "\n" . '</p></form>', 'bottom');
        // this may take several minutes
        $context['text'] .= '<p>' . i18n::s('When you will click on the button the server will be immediately requested to proceed. However, because of the so many things to do on the back-end, you may have to wait for minutes before getting a response displayed. Thank you for your patience.') . '</p>';
        // or back to the control panel
    } else {
        $menu = array('control/' => i18n::s('Control Panel'), 'control/setup.php' => i18n::s('Database maintenance'));
        $context['text'] .= Skin::build_list($menu, 'menu_bar');
    }
    // display current hooks
} else {
    // the splash message
    $context['text'] .= i18n::s('This script will scan your php scripts to install software hooks.');
    // the submit button
    $context['text'] .= '<form method="post" action="' . $context['script_url'] . '" id="main_form"><p>' . Skin::build_submit_button(i18n::s('Scan scripts for software extensions'), NULL, NULL, 'confirmed') . '<input type="hidden" name="action" value="check" />' . '</p></form>';
    // the script used for form handling at the browser
    Page::insert_script('$("#confirmed").focus();');
    // this may take several minutes
    $context['text'] .= '<p>' . i18n::s('When you will click on the button the server will be immediately requested to proceed. However, because of the so many things to do on the back-end, you may have to wait for minutes before getting a response displayed. Thank you for your patience.') . '</p>';
    // display the existing hooks configuration file, if any
    $content = Safe::file_get_contents('../parameters/hooks.include.php');
    if (strlen($content)) {
        $context['text'] .= Skin::build_box(sprintf(i18n::s('Current content of %s'), 'parameters/hooks.include.php'), Safe::highlight_string($content), 'folded');
    }
}
// render the skin
render_skin();
예제 #3
0
파일: build.php 프로젝트: rair/yacs
    $context['text'] .= '<form method="post" action="' . $context['script_url'] . '" id="main_form"><p>';
    // version string
    $context['text'] .= i18n::s('Version string (optional)') . ' <input type="text" name="version" size="8" maxlength="128" />';
    // the submit button
    $context['text'] .= BR . Skin::build_submit_button(i18n::s('Yes, I want to (re)build the reference store'), NULL, NULL, 'confirmed');
    // footprints files
    $context['text'] .= BR . '<input type="checkbox" name="enable_footprints" value="Y" checked="checked" /> ' . i18n::s('Enable remote servers to update from this reference store.');
    // end of the form
    $context['text'] .= '</p></form>';
    // set the focus on the button
    Page::insert_script('$("#confirmed").focus();');
    // this may take several minutes
    $context['text'] .= '<p>' . i18n::s('When you will click on the button the server will be immediately requested to proceed. However, because of the so many things to do on the back-end, you may have to wait for minutes before getting a response displayed. Thank you for your patience.') . '</p>';
    // display the existing reference script, if any
    if ($content = Safe::file_get_contents($context['path_to_reference'] . 'footprints.php')) {
        $context['text'] .= Skin::build_box(sprintf(i18n::s('Current content of %s'), $context['path_to_reference'] . 'footprints.php'), Safe::highlight_string($content), 'folded');
    }
    // no build in demo mode
} 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 in demonstration mode.'));
    // just do it
} else {
    // the splash message
    $context['text'] .= '<p>' . i18n::s('Please go to the end of this page to check results of the building process.') . "</p>\n";
    // suppress the footprints file to disable remote updates
    $context['text'] .= '<p>' . i18n::s('Suppressing the footprints file to disable remote updates...') . "</p>\n";
    Safe::unlink($context['path_to_reference'] . 'footprints.php');
    // list running scripts
    $context['text'] .= '<p>' . i18n::s('Listing files...') . BR . "\n";
    // locate script files starting at root
예제 #4
0
파일: configure.php 프로젝트: rair/yacs
     if (!file_exists('../parameters/switch.on') && !file_exists('../parameters/switch.off')) {
         $context['text'] .= '<p>' . i18n::s('Review provided information and go to the bottom of the page to move forward.') . "</a></p>\n";
     }
     // purge the cache
     Cache::clear();
     // also purge session cache for this surfer
     unset($_SESSION['l10n_modules']);
     // remember the change
     $label = sprintf(i18n::c('%s has been updated'), 'parameters/control.include.php');
     Logger::remember('control/configure.php: ' . $label);
 }
 // display updated parameters
 if (is_callable(array('skin', 'build_box'))) {
     $context['text'] .= Skin::build_box(i18n::s('Configuration'), Safe::highlight_string($content), 'folded');
 } else {
     $context['text'] .= Safe::highlight_string($content);
 }
 // first installation
 if (!file_exists('../parameters/switch.on') && !file_exists('../parameters/switch.off')) {
     // some css files may have to be slightly updated
     if ($context['url_to_root_parameter'] != '/yacs/' && ($skins = Safe::opendir('../skins'))) {
         // valid skins have a template.php file
         while (($skin = Safe::readdir($skins)) !== FALSE) {
             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)) {
예제 #5
0
파일: codes.php 프로젝트: rair/yacs
 /**
  * render a block of code
  *
  * @param string the text
  * @return string the rendered text
  **/
 public static function render_pre($text, $variant = 'snippet')
 {
     $text = Codes::fix_tags($text);
     // change new lines
     $text = trim(str_replace("\r", '', str_replace(array("<br>\n", "<br/>\n", "<br />\n", '<br>', '<br/>', '<br />'), "\n", $text)));
     // caught from tinymce
     if (preg_match('/<p>(.*)<\\/p>$/s', $text, $matches)) {
         $text = $matches[1];
         $text = str_replace(array('&amp;', '<p>', '</p>'), array('&', '', "\n"), $text);
     }
     // match some php code
     $explicit = FALSE;
     if (preg_match('/<\\?php\\s/', $text)) {
         $variant = 'php';
     } elseif ($variant == 'php' && !preg_match('/<\\?' . 'php.+' . '\\?' . '>/', $text)) {
         $text = '<?' . 'php' . "\n" . $text . "\n" . '?' . '>';
         $explicit = TRUE;
     }
     // highlight php code, if any
     if ($variant == 'php') {
         // fix some chars set by wysiwig editors
         $text = str_replace(array('&lt;', '&gt;', '&nbsp;', '&quot;'), array('<', '>', ' ', '"'), $text);
         // wrap long lines if necessary
         // 			$lines = explode("\n", $text);
         // 			$text = '';
         // 			foreach($lines as $line)
         // 				$text .= wordwrap($line, 100, " \n", 0)."\n";
         // handle newlines and indentations properly
         $text = str_replace(array("\n<span", "\n</code", "\n</pre", "\n</span"), array('<span', '</code', '</pre', '</span'), Safe::highlight_string($text));
         // remove explicit php prefix and suffix -- dependant of highlight_string() evolution
         if ($explicit) {
             $text = preg_replace(array('/&lt;\\?php<br\\s*\\/>/', '/\\?&gt;/'), '', $text);
         }
         // or prevent html rendering
     } else {
         $text = str_replace(array('<', "\n"), array('&lt;', '<br/>'), $text);
     }
     // prevent additional transformations
     $search = array('[', ']', ':', '//', '##', '**', '++', '--', '__');
     $replace = array('&#91;', '&#93;', '&#58;', '&#47;&#47;', '&#35;&#35;', '&#42;&#42;', '&#43;&#43;', '&#45;&#45;', '&#95;&#95;');
     $output = '<pre>' . str_replace($search, $replace, $text) . '</pre>';
     return $output;
 }