Пример #1
0
 /**
  * list banned servers
  *
  * This function is used to limit external links saved into the database.
  * It makes a pattern suitable for [code]preg_match()[/code] out of this list.
  *
  * Banned hosts and domains are manually put in the configuration file for servers,
  * as a list of words separated by spaces or commas.
  *
  * Following domains are always banned:
  * - mail.yahoo.com
  * - gmail.google.com
  * - www.laposte.net
  *
  * Here is an example of usage:
  * [php]
  * // the url to check
  * $url = ...
  *
  * // list banned servers
  * include_once '../servers/servers.php';
  * $banned_pattern = Servers::get_banned_pattern();
  *
  * // skip banned hosts
  * if(preg_match($banned_pattern, $url))
  *	   continue;
  * [/php]
  *
  * This function will always return a valid pattern string, even if no configuration file has been saved.
  *
  * @return a string to be used in [code]preg_match()[/code]
  *
  * @see agents/referrals.php
  * @see feeds/feeds.php
  * @see servers/test.php
  */
 public static function get_banned_pattern()
 {
     global $context;
     // use the configuration file
     Safe::load('parameters/servers.include.php');
     // get parameter
     if (isset($context['banned_hosts']) && $context['banned_hosts']) {
         $banned = $context['banned_hosts'];
     } else {
         $banned = '.kanoodle.com, \\bporn, \\bsex';
     }
     // quote tokens to build a pattern
     $banned_pattern = array();
     $banned_tokens = preg_split('/[\\s,]+/', $banned, -1, PREG_SPLIT_NO_EMPTY);
     foreach ($banned_tokens as $banned_token) {
         $banned_pattern[] = str_replace(array('.', '/'), array('\\.', '\\/'), $banned_token);
     }
     return '/(' . implode('|', $banned_pattern) . ')/';
 }
Пример #2
0
// load the skin
load_skin('agents');
// the path to this page
$context['path_bar'] = array('control/' => i18n::s('Control Panel'));
// the title of the page
$context['page_title'] = sprintf(i18n::s('%s: %s'), i18n::s('Configure'), i18n::s('Background processing'));
// anonymous users are invited to log in or to register
if (!Surfer::is_logged()) {
    Safe::redirect($context['url_to_home'] . $context['url_to_root'] . 'users/login.php?url=' . urlencode('agents/configure.php'));
} elseif (!Surfer::is_associate()) {
    Safe::header('Status: 401 Unauthorized', TRUE, 401);
    Logger::error(i18n::s('You are not allowed to perform this operation.'));
    // display the input form
} elseif (isset($_SERVER['REQUEST_METHOD']) && $_SERVER['REQUEST_METHOD'] != 'POST') {
    // load current parameters, if any
    Safe::load('parameters/agents.include.php');
    // the form
    $context['text'] .= '<form method="post" action="' . $context['script_url'] . '" id="main_form"><div>';
    //
    // messages
    //
    $messages = '';
    // introduction to the queue list
    $messages .= '<p>' . i18n::s('Mail accounts from which messages can be fetched and posted in the database.') . "</p>\n";
    // list existing queues
    if (isset($context['mail_queues']) && is_array($context['mail_queues'])) {
        $count = 0;
        foreach ($context['mail_queues'] as $name => $attributes) {
            // queues list
            $count++;
            $messages .= '<p><b>' . sprintf(i18n::s('Queue #%d'), $count) . "</b></p>\n";
Пример #3
0
 /**
  * process new messages, if any
  *
  * This function checks inbound mailboxes, and process new messages on their arrival.
  *
  * This function is aiming to run silently, therefore errors are logged in a file.
  *
  * @return a string to be displayed in resulting page, if any
  */
 public static function tick_hook()
 {
     global $context;
     // useless if we don't have a valid database connection
     if (!$context['connection']) {
         return;
     }
     // we need some queue definitions
     Safe::load('parameters/agents.include.php');
     if (!isset($context['mail_queues']) || !is_array($context['mail_queues']) || !count($context['mail_queues'])) {
         return 'agents/messages.php: no queue has been defined' . BR;
     }
     // remember start time
     $stamp = get_micro_time();
     // process each inbound queue
     include_once $context['path_to_root'] . 'shared/values.php';
     // messages.tick
     $count = 0;
     foreach ($context['mail_queues'] as $name => $queue) {
         // count messages retrieved
         $messages = Messages::process_queue($queue);
         $count += $messages;
         // remember tick date
         Values::set('messages.tick.' . $name, $messages);
     }
     // rebuild index pages
     if ($count) {
         Cache::clear();
     }
     // compute execution time
     $time = round(get_micro_time() - $stamp, 2);
     // report on work achieved
     if ($count > 1) {
         return 'agents/messages.php: ' . $count . ' messages have been processed (' . $time . ' seconds)' . BR;
     } elseif ($count == 1) {
         return 'agents/messages.php: 1 message has been processed (' . $time . ' seconds)' . BR;
     } else {
         return 'agents/messages.php: nothing to do (' . $time . ' seconds)' . BR;
     }
 }
Пример #4
0
// load the skin
load_skin('overlays');
// the path to this page
$local['control_en'] = 'Control Panel';
$local['control_fr'] = 'Panneau de contr&ocirc;le';
$context['path_bar'] = array('control/index.php' => i18n::user('control'));
// page title
$context['page_title'] = i18n::s('Configure: BigBlueButton meetings');
// only associates can proceed
if (!Surfer::is_associate()) {
    Safe::header('Status: 401 Unauthorized', TRUE, 401);
    $context['error'] .= '<p>' . i18n::s('You are not allowed to perform this operation.') . '</p>';
    // display the input form
} elseif (isset($_SERVER['REQUEST_METHOD']) && $_SERVER['REQUEST_METHOD'] != 'POST') {
    // load current parameters, if any
    Safe::load('parameters/overlays.bbb_meetings.include.php');
    // the form
    $context['text'] .= '<form method="post" action="' . $context['self_script'] . '" id="main_form">';
    $fields = array();
    // server name
    $label = i18n::s('BBB server');
    $input = '<input type="text" name="bbb_server" id="bbb_server" size="32" value="' . encode_field(isset($context['bbb_server']) ? $context['bbb_server'] : '') . '" maxlength="255" />';
    $fields[] = array($label, $input);
    // server salt
    $label = i18n::s('Security salt');
    $input = '<input type="text" name="bbb_salt" id="bbb_salt" size="32" value="' . encode_field(isset($context['bbb_salt']) ? $context['bbb_salt'] : '') . '" maxlength="255" />';
    $fields[] = array($label, $input);
    // build the form
    $context['text'] .= Skin::build_form($fields);
    $fields = array();
    // bottom commands
Пример #5
0
Файл: new.php Проект: rair/yacs
// load the skin
load_skin('letters');
// maximum number of recipients
if (!defined('MAXIMUM_RECIPIENTS')) {
    define('MAXIMUM_RECIPIENTS', 5000);
}
// wrapping threshold
if (!defined('WRAPPING_LENGTH')) {
    define('WRAPPING_LENGTH', 70);
}
// the path to this page
$context['path_bar'] = array('letters/' => i18n::s('Newsletters'));
// the title of the page
$context['page_title'] = i18n::s('Post a letter');
// load parameters for letters
Safe::load('parameters/letters.include.php');
// default values if no configuration file is available
if (!isset($context['letter_body'])) {
    $context['letter_body'] = '';
}
if (!isset($context['letter_prefix'])) {
    $context['letter_prefix'] = '';
}
if (!isset($context['letter_suffix'])) {
    $context['letter_suffix'] = '';
}
if (!isset($context['letter_title'])) {
    $context['letter_title'] = '';
}
if (!isset($context['title_prefix'])) {
    $context['title_prefix'] = '*** ';
Пример #6
0
 /**
  * get news from remote servers
  *
  * This function queries remote sources and populate the table of links based on fetched news.
  *
  * On tick, the including hook calls [code]Feeds::tick_hook()[/code].
  * See [script]control/scan.php[/script] for a more complete description of hooks.
  *
  * The function browses the database to locate servers acting as feeders, and read the URLs to use.
  *
  * A round-robin algorithm is implemented, meaning that servers are polled in sequence throughout successive ticks.
  * At most 1 feed is parsed on each tick, to limit impact when the "poor-man" cron mechanism is used,
  * which is the default setting.
  *
  * XML feeds are fetched and parsed according to their type.
  * At the moment YACS is able to process RSS and slashdot feeds.
  * Link records are created or updated in the database saving as much of possible of provided data.
  * Item data is reflected in Link, Title, and Description fields.
  * Channel	data is used to populate the Source field.
  * Stamping information is based on feeding date, and channel title.
  * Also, the edit action 'link:feed' marks links that are collected from feeders.
  * The anchor field is set to the category assigned in the server profile.
  *
  * At the end of the feeding process, the database is purged from oldest links according to the limit
  * defined in parameters/feeds.include.php, set through feeds/configure.php.
  * See Links::purge_old_news().
  *
  * @param boolean if set to true, fetch news on each call; else use normal period of time
  * @return a string to be displayed in resulting page, if any
  *
  * @see control/scan.php
  * @see feeds/configure.php
  */
 public static function tick_hook($forced = FALSE)
 {
     global $context;
     // load librairies only once
     include_once $context['path_to_root'] . 'links/links.php';
     include_once $context['path_to_root'] . 'servers/servers.php';
     include_once $context['path_to_root'] . 'shared/values.php';
     // feeds.tick
     // get feeding parameters
     Safe::load('parameters/feeds.include.php');
     // delay between feeds - minimum is 5 minutes
     if (!isset($context['minutes_between_feeds']) || $context['minutes_between_feeds'] < 5) {
         $context['minutes_between_feeds'] = 5;
     }
     // do not wait for the end of a feeding cycle
     if ($forced) {
         $threshold = gmstrftime('%Y-%m-%d %H:%M:%S');
     } else {
         $threshold = gmstrftime('%Y-%m-%d %H:%M:%S', time() - $context['minutes_between_feeds'] * 60);
     }
     // get a batch of feeders
     if (!($feeders = Servers::list_for_feed(0, 1, 'feed'))) {
         return 'feeds/feeds.php: no feed has been defined' . BR;
     }
     // remember start time
     $start_time = get_micro_time();
     // list banned tokens
     $banned_pattern = Servers::get_banned_pattern();
     // browse each feed
     $count = 0;
     foreach ($feeders as $server_id => $attributes) {
         // get specific feed parameters
         list($feed_url, $feed_title, $anchor, $stamp) = $attributes;
         // skip servers processed recently
         if ($stamp > $threshold) {
             continue;
         }
         // flag this record to enable round-robin even on error
         Servers::stamp($server_id);
         // fetch news from the provided link
         if (!($news = Feeds::get_remote_news_from($feed_url)) || !is_array($news)) {
             continue;
         }
         // no anchor has been defined for this feed
         if (!$anchor) {
             // create a default section if necessary
             if (!($anchor = Sections::lookup('external_news'))) {
                 $fields = array();
                 $fields['nick_name'] = 'external_news';
                 $fields['create_date'] = gmstrftime('%Y-%m-%d %H:%M:%S', time());
                 $fields['edit_date'] = gmstrftime('%Y-%m-%d %H:%M:%S', time());
                 $fields['index_map'] = 'N';
                 $fields['locked'] = 'Y';
                 // no direct contributions
                 $fields['rank'] = 40000;
                 // at the end of the list
                 $fields['title'] = i18n::c('External News');
                 $fields['description'] = i18n::c('Received from feeding servers');
                 if (!($fields['id'] = Sections::post($fields))) {
                     Logger::remember('feeds/feeds.php: Impossible to add a section.');
                     return;
                 }
                 $anchor = 'section:' . $fields['id'];
             }
         }
         // process retrieved links
         $links = 0;
         foreach ($news as $item) {
             // link has to be valid
             if (!isset($item['link']) || !($item['title'] . $item['description'])) {
                 if (isset($context['debug_feeds']) && $context['debug_feeds'] == 'Y') {
                     Logger::remember('feeds/feeds.php: feed item is invalid', $item, 'debug');
                 }
                 continue;
             }
             // skip banned servers
             if ($banned_pattern && preg_match($banned_pattern, $item['link'])) {
                 if (isset($context['debug_feeds']) && $context['debug_feeds'] == 'Y') {
                     Logger::remember('feeds/feeds.php: feed host has been banned', $item['link'], 'debug');
                 }
                 continue;
             }
             // one link processed
             $links++;
             // link description
             $fields = array();
             $fields['anchor'] = $anchor;
             $fields['link_url'] = $item['link'];
             $fields['title'] = $item['title'];
             $fields['description'] = $item['description'];
             if ($item['category']) {
                 $fields['description'] .= ' (' . $item['category'] . ')';
             }
             $fields['edit_name'] = $feed_title;
             $fields['edit_address'] = $feed_url;
             $fields['edit_action'] = 'link:feed';
             if ($item['pubDate']) {
                 $fields['edit_date'] = gmstrftime('%Y-%m-%d %H:%M:%S', strtotime($item['pubDate']));
             }
             // update links that already exist in the database
             if (Links::have($item['link'], $anchor, $fields)) {
                 continue;
             }
             // save link in the database
             if (!Links::post($fields)) {
                 Logger::remember('feeds/feeds.php: Impossible to save feed link: ' . Logger::error_pop());
             }
         }
         // one feed has been processed
         $count += 1;
         // remember tick date
         Values::set('feeds.tick.' . $feed_url, $links);
     }
     // cap the number of links used for news
     if (!isset($context['maximum_news']) || !$context['maximum_news']) {
         $context['maximum_news'] = 1000;
     }
     if ($context['maximum_news'] > 10) {
         include_once $context['path_to_root'] . 'links/links.php';
         Links::purge_old_news($context['maximum_news']);
     }
     // compute execution time
     $time = round(get_micro_time() - $start_time, 2);
     // report on work achieved
     if ($count > 1) {
         return 'feeds/feeds.php: ' . $count . ' feeds have been processed (' . $time . ' seconds)' . BR;
     } elseif ($count == 1) {
         return 'feeds/feeds.php: 1 feed has been processed (' . $time . ' seconds)' . BR;
     } else {
         return 'feeds/feeds.php: nothing to do (' . $time . ' seconds)' . BR;
     }
 }
Пример #7
0
// load the skin
load_skin('servers');
// the path to this page
$context['path_bar'] = array('control/' => i18n::s('Control Panel'));
// the title of the page
$context['page_title'] = sprintf(i18n::s('%s: %s'), i18n::s('Configure'), i18n::s('Servers'));
// anonymous users are invited to log in or to register
if (!Surfer::is_logged()) {
    Safe::redirect($context['url_to_home'] . $context['url_to_root'] . 'users/login.php?url=' . urlencode('servers/configure.php'));
} elseif (!Surfer::is_associate()) {
    Safe::header('Status: 401 Unauthorized', TRUE, 401);
    Logger::error(i18n::s('You are not allowed to perform this operation.'));
    // display the input form
} elseif (isset($_SERVER['REQUEST_METHOD']) && $_SERVER['REQUEST_METHOD'] != 'POST') {
    // load current parameters, if any
    Safe::load('parameters/servers.include.php');
    // the form
    $context['text'] .= '<form method="post" action="' . $context['script_url'] . '" id="main_form"><div>';
    // banned feeders
    if (!isset($context['banned_hosts'])) {
        $context['banned_hosts'] = '.kanoodle.com \\bporn \\bsex';
    }
    $label = i18n::s('Servers to be banned');
    $input = '<textarea name="banned_hosts" id="banned_hosts" cols="40" rows="2">' . encode_field($context['banned_hosts']) . '</textarea>';
    $hint = i18n::s('Links and referrals from these servers will be dropped');
    $fields[] = array($label, $input, $hint);
    // build the form
    $context['text'] .= Skin::build_form($fields);
    //
    // bottom commands
    //
Пример #8
0
 /**
  * initialize this instance
  *
  * @see overlays/bbb_meetings/configure.php
  * @see overlays/overlay.php
  *
  */
 function initialize()
 {
     global $context;
     // load current parameters, if any
     Safe::load('parameters/overlays.bbb_meetings.include.php');
     // default host
     if (!isset($context['bbb_server']) || !$context['bbb_server']) {
         $context['bbb_server'] = $context['host_name'];
     }
 }
Пример #9
0
 function index_keywords($file_name)
 {
     // parse keywords in some files
     if (preg_match('/(\\.txt|\\.doc|\\.xls)$/i', $file_name) && ($handle = Safe::fopen($file_name, 'rb')) !== FALSE) {
         // load noise words
         Safe::load('files/noise_words.php');
         // use chunks of 50 kbytes
         $filtered_words = array();
         while (count($noise_words) && ($buffer = fread($handle, 51200))) {
             // strip binary stuff
             $buffer = preg_replace("/[вда]/m", 'a', $buffer);
             $buffer = preg_replace("/[йкли]/m", 'e', $buffer);
             $buffer = preg_replace("/[оп]/m", 'i', $buffer);
             $buffer = preg_replace("/[фц]/m", 'o', $buffer);
             $buffer = preg_replace("/[ыь]/m", 'u', $buffer);
             $buffer = str_replace('з', 'c', $buffer);
             $buffer = preg_replace('/[^a-zA-Z_0-9]+/m', ' ', $buffer);
             // ensure enough execution time
             Safe::set_time_limit(30);
             // strip html-like things
             $buffer = strip_tags($buffer);
             $buffer = preg_replace('/&\\w;/m', '', $buffer);
             // ensure enough execution time
             Safe::set_time_limit(30);
             // extract all readable words
             //					$context['debug'][] = 'buffer=<pre>'.$buffer.'</pre>';
             $words = preg_split("/[\\s]+/", $buffer);
             //					$context['debug'][] = count($words).' words extracted';
             // ensure enough execution time
             Safe::set_time_limit(30);
             // filter words
             foreach ($words as $word) {
                 // mysql does not index words of less than 3 chars
                 $length = strlen($word);
                 if ($length <= 3 || $length > 25) {
                     continue;
                 }
                 if (preg_match('/[0-9]/', $word)) {
                     continue;
                 }
                 if (preg_match('/^[_0-9]/', $word)) {
                     continue;
                 }
                 // filter words against the list of noise words
                 $word = strtolower($word);
                 if (!in_array($word, $noise_words)) {
                     $filtered_words[$word] += 1;
                 }
             }
             // ensure enough execution time
             Safe::set_time_limit(30);
         }
         // the complete file has been read
         fclose($handle);
         // ensure enough execution time
         Safe::set_time_limit(30);
         // memorize up to 1000 keywords
         if (is_array($filtered_words)) {
             ksort($filtered_words);
             reset($filtered_words);
             $keywords = '';
             if (is_array($filtered_words)) {
                 foreach ($filtered_words as $word => $count) {
                     $keywords .= $word . ' ';
                     if ($keywords_count++ > 1000) {
                         break;
                     }
                 }
             }
         }
         // ensure enough execution time
         Safe::set_time_limit(30);
     }
     return $keywords;
 }
Пример #10
0
 /**
  * process one file uploaded by handx weblog
  *
  * @param string the file to process
  */
 public static function process_handx_weblog($file)
 {
     global $context;
     // load parameters for uploads
     Safe::load('parameters/agents.include.php');
     if (!$context['uploads_nick_name']) {
         Logger::remember('agents/upload.php: no parameters, skipping ' . $file);
         return;
     }
     // read the input queue
     if (!($content = trim(Safe::file_get_contents($context['path_to_root'] . $file)))) {
         return;
     }
     // save in the output queue
     if ($handle = Safe::fopen($context['path_to_root'] . $file . '.bak', 'ab')) {
         fwrite($handle, $content);
         fclose($handle);
         // delete the input queue
         Safe::unlink($context['path_to_root'] . $file);
     }
     // date is derived from file name
     $name = basename($file);
     $year = substr($name, 0, 4);
     $month = substr($name, 4, 2);
     $day = substr($name, 6, 2);
     // split entries using the default separator value
     $separator = "/<table width=100%><tr><td class='time'>(.+?)<\\/td><\\/tr><\\/table>/";
     $entries = preg_split($separator, $content, -1, PREG_SPLIT_DELIM_CAPTURE | PREG_SPLIT_NO_EMPTY);
     // no time information
     if (@count($entries) == 1) {
         // make a stamp
         $stamp = gmstrftime('%Y-%m-%d %H:%M:%S', mktime(0, 0, 0, $month, $day, $year));
         // process this entry
         Uploads::process_handx_entry(trim($entries[0]), $stamp);
         // pairs of time and content strings
     } elseif (@count($entries) > 1) {
         // process all pairs
         for ($index = 0; $index < count($entries); $index++) {
             // the time as extracted by preg_split()
             $stamp = '';
             if (preg_match('/(\\d{1,2}):(\\d{1,2}) (am|pm)/', $entries[$index], $matches)) {
                 $index++;
                 // make a stamp
                 $hour = $matches[1];
                 $minutes = $matches[2];
                 if ($matches[3] == 'pm') {
                     $hour += 12;
                 }
                 $stamp = gmstrftime('%Y-%m-%d %H:%M:%S', mktime($hour, $minutes, 0, $month, $day, $year));
             }
             // the entry itself
             $entry = $entries[$index];
             // process this entry
             Uploads::process_handx_entry(trim($entry), $stamp);
         }
     }
 }
Пример #11
0
 /**
  * initialize this instance
  *
  * @see overlays/etherpad_meetings/configure.php
  * @see overlays/overlay.php
  *
  */
 function initialize()
 {
     global $context;
     // load current parameters, if any
     Safe::load('parameters/overlays.etherpad_meetings.include.php');
     // use some unique id
     if (!isset($this->attributes['meeting_id'])) {
         $this->attributes['meeting_id'] = md5(mt_rand());
     }
 }
Пример #12
0
// load the skin
load_skin('overlays');
// the path to this page
$local['control_en'] = 'Control Panel';
$local['control_fr'] = 'Panneau de contr&ocirc;le';
$context['path_bar'] = array('control/index.php' => i18n::user('control'));
// page title
$context['page_title'] = i18n::s('Configure: Etherpad meetings');
// only associates can proceed
if (!Surfer::is_associate()) {
    Safe::header('Status: 401 Unauthorized', TRUE, 401);
    $context['error'] .= '<p>' . i18n::s('You are not allowed to perform this operation.') . '</p>';
    // display the input form
} elseif (isset($_SERVER['REQUEST_METHOD']) && $_SERVER['REQUEST_METHOD'] != 'POST') {
    // load current parameters, if any
    Safe::load('parameters/overlays.etherpad_meetings.include.php');
    // the form
    $context['text'] .= '<form method="post" action="' . $context['self_script'] . '" id="main_form">';
    $fields = array();
    // server name
    $label = i18n::s('Etherpad server');
    $input = '<input type="text" name="etherpad_server" id="etherpad_server" size="32" value="' . encode_field(isset($context['etherpad_server']) ? $context['etherpad_server'] : '') . '" maxlength="255" />';
    $hint = 'sync.in, piratepad.net, primarypad.com, openetherpad.org, typewith.me';
    $fields[] = array($label, $input, $hint);
    // build the form
    $context['text'] .= Skin::build_form($fields);
    $fields = array();
    // bottom commands
    $menu = array();
    // the submit button
    $local['submit_en'] = 'Submit';
Пример #13
0
    }
    // report on failures, if any
    if ($failures) {
        $context['text'] .= '<p>' . FAILURE_PREFIX . i18n::s('Warning! Some files have not been updated.') . FAILURE_SUFFIX . "</p>\n";
    }
    // report on missing files, if any
    if ($missing_files) {
        $context['text'] .= '<p>' . FAILURE_PREFIX . i18n::s('Some updated files are missing.') . FAILURE_SUFFIX . "</p>\n";
        // forward to the staging script
        $menu = array('scripts/stage.php' => i18n::s('Stage updated scripts'));
        $context['text'] .= Skin::build_list($menu, 'menu_bar');
    }
    // list staging files
} else {
    // load the special update prefix, if any
    Safe::load('scripts/staging/scripts/update_header.php');
    // splash message
    $context['text'] .= '<p>' . sprintf(i18n::s('Reference set of %d files built on %s on server %s'), count($footprints), $generation['date'], $generation['server']) . "</p>\n";
    // sort footprints by alphabetical order
    ksort($footprints);
    reset($footprints);
    // use footprints of reference files to locate updates
    $staging_files = 0;
    $missing_files = 0;
    $box = '';
    foreach ($footprints as $file => $attributes) {
        // only consider php scripts at the moment
        if (!preg_match('/\\.php$/', $file)) {
            continue;
        }
        // maybe the script has already been executed -- never expect an exact copy
Пример #14
0
 * @license http://www.gnu.org/copyleft/lesser.txt GNU Lesser General Public License
 */
// common definitions and initial processing
include_once '../shared/global.php';
include_once 'scripts.php';
// what to do
$action = '';
if (isset($_REQUEST['action'])) {
    $action = $_REQUEST['action'];
}
if (!$action && isset($context['arguments'][0])) {
    $action = $context['arguments'][0];
}
$action = strip_tags($action);
// load footprints, if any
Safe::load('footprints.php');
// load localized strings
i18n::bind('scripts');
// load the skin
load_skin('scripts');
// the path to this page
$context['path_bar'] = array('scripts/' => i18n::s('Server software'));
// the title of the page
$context['page_title'] = i18n::s('Check software integrity');
// anonymous users are invited to log in or to register
if (!Surfer::is_logged()) {
    Safe::redirect($context['url_to_home'] . $context['url_to_root'] . 'users/login.php?url=' . urlencode('scripts/update.php'));
} elseif (!Surfer::is_associate()) {
    Safe::header('Status: 401 Unauthorized', TRUE, 401);
    Logger::error(i18n::s('You are not allowed to perform this operation.'));
    // invalid staging index
Пример #15
0
     Logger::error(sprintf(i18n::s('ERROR: Impossible to write to the file %s. The configuration has not been saved.'), $parameters_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.'), $parameters_file) . "</p>\n";
     // job done
 } else {
     $context['text'] .= '<p>' . sprintf(i18n::s('The following configuration has been saved into the file %s.'), $parameters_file) . "</p>\n";
     // purge the cache
     Cache::clear();
     // remember the change
     $label = sprintf(i18n::c('%s has been updated'), $parameters_file);
     Logger::remember('skins/flexible/configure.php: ' . $label);
 }
 // display updated parameters
 $context['text'] .= Skin::build_box(i18n::s('Configuration parameters'), Safe::highlight_string($content), 'folded');
 // reload current parameters, to be sure
 Safe::load($parameters_file, TRUE);
 // read the template file
 if (!($content = Safe::file_get_contents($template_file))) {
     Logger::error(sprintf(i18n::s('ERROR: Impossible to read the file %s.'), $template_file));
 } else {
     // prepare the transformation
     $needles = array();
     $values = array();
     // page-level parameters
     $needles[] = '!!body_background!!';
     $values[] = $context['flexible_body_bg'];
     $needles[] = '!!page_background!!';
     $values[] = $context['flexible_page_bg'];
     // page width
     $needles[] = '!!width!!';
     if ($context['flexible_width'] == '960px') {
Пример #16
0
// load the skin
load_skin('files');
// the path to this page
$context['path_bar'] = array('control/' => i18n::s('Control Panel'));
// the title of the page
$context['page_title'] = sprintf(i18n::s('%s: %s'), i18n::s('Configure'), i18n::s('Files'));
// anonymous users are invited to log in or to register
if (!Surfer::is_logged()) {
    Safe::redirect($context['url_to_home'] . $context['url_to_root'] . 'users/login.php?url=' . urlencode('files/configure.php'));
} elseif (!Surfer::is_associate()) {
    Safe::header('Status: 401 Unauthorized', TRUE, 401);
    Logger::error(i18n::s('You are not allowed to perform this operation.'));
    // display the input form
} elseif (isset($_SERVER['REQUEST_METHOD']) && $_SERVER['REQUEST_METHOD'] != 'POST') {
    // load current parameters, if any
    Safe::load('parameters/files.include.php');
    // the form
    $context['text'] .= '<form method="post" action="' . $context['script_url'] . '" id="main_form"><div>';
    //
    // supported extensions
    //
    $extensions = '';
    // supported extensions
    $label = i18n::s('Supported extensions');
    include_once 'files.php';
    $input = implode(', ', array_keys(Files::get_mime_types()));
    $hint = i18n::s('Recommended tools are listed for each extension on download.');
    $fields[] = array($label, $input, $hint);
    // additional extensions
    $label = i18n::s('Additional extensions');
    if (!isset($context['files_extensions'])) {
Пример #17
0
// the title of the page
$context['page_title'] = sprintf(i18n::s('%s: %s'), i18n::s('Configure'), i18n::s('Page factory'));
// anonymous users are invited to log in or to register
if (!Surfer::is_logged()) {
    Safe::redirect($context['url_to_home'] . $context['url_to_root'] . 'users/login.php?url=' . urlencode('skins/configure.php'));
} elseif (!Surfer::is_associate()) {
    Safe::header('Status: 401 Unauthorized', TRUE, 401);
    Logger::error(i18n::s('You are not allowed to perform this operation.'));
    // display the input form
} elseif (isset($_SERVER['REQUEST_METHOD']) && $_SERVER['REQUEST_METHOD'] != 'POST') {
    // first installation
    if (!file_exists('../parameters/switch.on') && !file_exists('../parameters/switch.off')) {
        $context['text'] .= '<p>' . i18n::s('You can use default values and change these later on. Hit the button at the bottom of the page to move forward.') . "</p>\n";
    }
    // load current parameters, if any
    Safe::load('parameters/skins.include.php');
    // the form
    $context['text'] .= '<form method="post" action="' . $context['script_url'] . '" id="main_form"><div>';
    //
    // meta-information
    //
    $meta = '';
    // site name
    $label = i18n::s('Site name');
    $input = '<input type="text" name="site_name" size="50" value="' . encode_field($context['site_name']) . '" maxlength="255" />';
    $hint = i18n::s('Short and meaningful title, such as "My little big server", used almost everywhere, and appended to the title of every page of this site');
    $fields[] = array($label, $input, $hint);
    // site slogan
    if (!isset($context['site_slogan'])) {
        $context['site_slogan'] = '-- just do it. and do it right. and make it free. and let it be. and... (your turn)';
    }
Пример #18
0
 * At the end of the staging process a link is displayed to launch [script]scripts/update.php[/script], that will
 * actually move the staging files to running directories. But this is another story.
 *
 * @see scripts/update.php
 *
 * @author Bernard Paques
 * @author GnapZ
 * @tester Paddy
 * @reference
 * @license http://www.gnu.org/copyleft/lesser.txt GNU Lesser General Public License
 */
// common definitions and initial processing
include_once '../shared/global.php';
include_once 'scripts.php';
// parameters for scripts
Safe::load('parameters/scripts.include.php');
// ensure we have a default reference server
if (!isset($context['reference_server']) || !$context['reference_server']) {
    $context['reference_server'] = i18n::s('www.yacs.fr');
}
// no local file at the moment
$id = NULL;
$external_id = NULL;
// load localized strings
i18n::bind('scripts');
// load the skin
load_skin('scripts');
// the path to this page
$context['path_bar'] = array('scripts/' => i18n::s('Server software'));
// the title of the page
$context['page_title'] = i18n::s('Stage updated scripts');
Пример #19
0
 /**
  * check if a file type is authorized
  *
  * This function is based on the growing list of extensions officially supported by YACS.
  * It also considers additional extensions set in the configuration panel for files.
  *
  * @see files/configure.php
  *
  * @param string file name, including extension
  * @return TRUE or FALSE
  *
  * @see agents/messages.php
  * @see files/edit.php
  * @see files/view.php
  */
 public static function is_authorized($name)
 {
     global $context;
     // create the pattern only once
     static $extensions_pattern;
     if (!is_string($extensions_pattern)) {
         $extensions_pattern = implode(', ', array_keys(Files::get_mime_types()));
     }
     // we do need some extension
     if (($position = strrpos($name, '.')) === FALSE) {
         return FALSE;
     }
     // extract the extension
     if (!($extension = substr($name, $position + 1))) {
         return FALSE;
     }
     // match official extensions
     if (preg_match('/\\b' . preg_quote($extension, '/') . '\\b/i', $extensions_pattern)) {
         return TRUE;
     }
     // load parameters related to files
     Safe::load('parameters/files.include.php');
     // match additional extensions
     if (isset($context['files_extensions']) && $context['files_extensions'] && preg_match('/\\b' . preg_quote($extension, '/') . '\\b/i', $context['files_extensions'])) {
         return TRUE;
     }
     // no match
     return FALSE;
 }
Пример #20
0
Файл: feed.php Проект: rair/yacs
// page title
$context['page_title'] = i18n::s('RSS feed');
// not found
if (!isset($item['id'])) {
    include '../error.php';
    // permission denied
} elseif (!$permitted) {
    Safe::header('Status: 401 Unauthorized', TRUE, 401);
    Logger::error(i18n::s('You are not allowed to perform this operation.'));
    // send the list of recent contributions by this user
} else {
    // get the list from the cache, if possible
    $cache_id = 'users/feed.php?id=' . $item['id'] . '#channel';
    if (!($text = Cache::get($cache_id))) {
        // loads feeding parameters
        Safe::load('parameters/feeds.include.php');
        // structured data
        $values = array();
        $values['channel'] = array();
        // set channel information
        $values['channel']['title'] = $item['full_name'] ? $item['full_name'] : $item['nick_name'];
        $values['channel']['link'] = Users::get_permalink($item);
        $values['channel']['description'] = $item['introduction'];
        // the image for this channel
        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'];
        }
        // the list of newest pages
        $values['items'] = (array) Articles::list_for_author_by('publication', $item['id'], 0, 50, 'feed');
        // make a text
        include_once '../services/codec.php';
Пример #21
0
Файл: i18n.php Проект: rair/yacs
 /**
  * lookup a localised string in an array
  *
  * This can be used to parse manifest files for example.
  *
  * This function also transcode HTML entities to Unicode entities, if any.
  *
  * @param array the array containing localized strings
  * @param string the label identifying string
  * @param string desired language, if any
  * @return string the localized string, if any
  */
 public static function &l(&$strings, $name, $forced = '')
 {
     global $context;
     // sanity check
     if (!$name) {
         return $name;
     }
     // select a string
     if ($forced && ($key = $name . '_' . $forced) && array_key_exists($key, $strings)) {
         $text = $strings[$key];
     } elseif (($key = $name . '_' . $context['language']) && array_key_exists($key, $strings)) {
         $text = $strings[$key];
     } elseif (($key = $name . '_en') && array_key_exists($key, $strings)) {
         $text = $strings[$key];
     } elseif (array_key_exists($name, $strings)) {
         $text = $strings[$name];
     } else {
         $text = $name;
         if ($context['with_debug'] == 'Y') {
             logger::remember('i18n/i18n.php: ' . $name . ' is not localized', '', 'debug');
         }
     }
     // the file may be absent during updates
     Safe::load('shared/utf8.php');
     // transcode to utf8
     if (isset($context['charset']) && $context['charset'] == 'utf-8' && is_callable(array('utf8', 'transcode'))) {
         $text =& utf8::transcode($text);
     }
     return $text;
 }