Esempio n. 1
0
File: thread.php Progetto: rair/yacs
 public function get_comment_notification($item)
 {
     global $context;
     // build a tease notification for simple members
     // sanity check
     if (!isset($item['anchor']) || !($anchor = Anchors::get($item['anchor']))) {
         throw new Exception('no anchor for this comment');
     }
     // headline
     $headline = sprintf(i18n::c('%s has replied'), Surfer::get_link());
     $content = BR;
     // shape these
     $tease = Skin::build_mail_content($headline, $content);
     // a set of links
     $menu = array();
     // call for action
     $link = $context['url_to_home'] . $context['url_to_root'] . Comments::get_url($item['id'], 'view');
     $menu[] = Skin::build_mail_button($link, i18n::c('View the reply'), TRUE);
     // link to the container
     $menu[] = Skin::build_mail_button($anchor->get_url(), $anchor->get_title(), FALSE);
     // finalize links
     $tease .= Skin::build_mail_menu($menu);
     // assemble all parts of the mail
     $mail = array();
     $mail['subject'] = sprintf(i18n::c('%s: %s'), i18n::c('Reply in the discussion'), strip_tags($anchor->get_title()));
     $mail['notification'] = Comments::build_notification($item);
     // full notification
     $mail['tease'] = Mailer::build_notification($tease, 1);
     return $mail;
 }
Esempio n. 2
0
File: mail.php Progetto: rair/yacs
 $subject = '';
 if (isset($_REQUEST['subject'])) {
     $subject = strip_tags($_REQUEST['subject']);
 }
 // headline
 $headline = sprintf(i18n::c('%s is notifying you from %s'), Surfer::get_link(), '<a href="' . Categories::get_permalink($item) . '">' . $item['title'] . '</a>');
 // enable yacs codes in messages
 $message = Codes::beautify($_REQUEST['message']);
 // assemble main content of this message
 $message = Skin::build_mail_content($headline, $message);
 // a set of links
 $menu = array();
 // call for action
 $link = Categories::get_permalink($item);
 if (!is_object($overlay) || !($label = $overlay->get_label('permalink_command', 'categories', FALSE))) {
     $label = i18n::c('View the category');
 }
 $menu[] = Skin::build_mail_button($link, $label, TRUE);
 // link to the container
 if (is_object($anchor)) {
     $link = $context['url_to_home'] . $context['url_to_root'] . $anchor->get_url();
     $menu[] = Skin::build_mail_button($link, $anchor->get_title(), FALSE);
 }
 // finalize links
 $message .= Skin::build_mail_menu($menu);
 // threads messages
 $headers = Mailer::set_thread('category:' . $item['id']);
 // send the message
 if (Mailer::notify(Surfer::from(), $to, $subject, $message, $headers)) {
     // feed-back to the sender
     $context['text'] .= '<p>' . i18n::s('A message has been sent to:') . "</p>\n" . '<ul>' . "\n";
Esempio n. 3
0
 /**
  * create a page out of a textual entity
  *
  * If a target is provided, it is extended with the text of this entity.
  * Else if the anchor is an article, a comment is created. Otherwise an article is created.
  *
  * @param array of entity attributes
  * @param string the textual entity to process
  * @param array poster attributes
  * @param string an optional anchor (e.g., 'article:123')
  * @param string reference of the object to be extended, if any
  * @return string reference to the created or updated object, or NULL
  */
 public static function submit_page($entity_headers, $text, $user, $anchor = NULL, $target = NULL)
 {
     global $context;
     // retrieve queue parameters
     list($server, $account, $password, $allowed, $match, $section, $options, $hooks, $prefix, $suffix) = $context['mail_queue'];
     // preserve breaks
     $text = preg_replace('/\\s*<(br|div|h|p)/is', "\n\n<\$1", $text);
     // suppress dangerous html tags
     $text = strip_tags($text, $context['users_allowed_tags']);
     // trim white spaces
     while (TRUE) {
         $text = trim($text, " \t\r\n");
         if (!strncmp($text, '<br>', 4)) {
             $text = substr($text, 4);
         } elseif (!strncmp($text, '<br/>', 5)) {
             $text = substr($text, 5);
         } elseif (!strncmp($text, '<br />', 6)) {
             $text = substr($text, 6);
         } else {
             break;
         }
     }
     // parse article content
     include_once $context['path_to_root'] . 'articles/article.php';
     $article = new Article();
     $entry_fields = array();
     $entry_fields = $article->parse($text, $entry_fields);
     // trim the header
     if ($prefix) {
         $tokens = explode($prefix, $entry_fields['description']);
         if (isset($tokens[1])) {
             $entry_fields['description'] = $tokens[1];
         } else {
             $entry_fields['description'] = $tokens[0];
         }
     }
     // trim the signature
     if ($suffix) {
         list($entry_fields['description'], $dropped) = explode($suffix, $entry_fields['description']);
     }
     // strip extra text
     $entry_fields['description'] = trim(preg_replace('/\\(See attached file: [^\\)]+?\\)/', '', $entry_fields['description']));
     // anchor this item to something
     $entry_fields['anchor'] = $anchor;
     // make a title
     if (!isset($entry_fields['title'])) {
         $entry_fields['title'] = $context['mail_subject'];
     }
     // message creation stamp
     $entry_fields['create_date'] = gmstrftime('%Y-%m-%d %H:%M:%S', strtotime($context['mail_date']));
     if (!isset($entry_fields['create_name'])) {
         $entry_fields['create_name'] = $user['nick_name'];
     }
     if (!isset($entry_fields['create_id'])) {
         $entry_fields['create_id'] = $user['id'];
     }
     if (!isset($entry_fields['create_address'])) {
         $entry_fields['create_address'] = $user['email'];
     }
     // message edition stamp
     $entry_fields['edit_date'] = gmstrftime('%Y-%m-%d %H:%M:%S', time());
     if (!isset($entry_fields['edit_name'])) {
         $entry_fields['edit_name'] = $user['nick_name'];
     }
     if (!isset($entry_fields['edit_id'])) {
         $entry_fields['edit_id'] = $user['id'];
     }
     if (!isset($entry_fields['edit_address'])) {
         $entry_fields['edit_address'] = $user['email'];
     }
     // we have to extend an existing article --this entity is mutable
     if ($target && !strncmp($target, 'article:', 8) && ($article = Articles::get(substr($target, 8), TRUE))) {
         // append the text to article description field
         $fields = array();
         $fields['id'] = $article['id'];
         $fields['description'] = $article['description'] . $entry_fields['description'];
         $fields['silent'] = TRUE;
         Articles::put_attributes($fields);
         return $target;
         // we have to extend an existing comment --this entity is mutable
     } elseif ($target && !strncmp($target, 'comment:', 8) && ($comment = Comments::get(substr($target, 8), TRUE))) {
         // append the text to comment description field
         $comment['description'] .= $entry_fields['description'];
         Comments::post($comment);
         return $target;
         // we have to comment an existing page
     } elseif (!strncmp($anchor, 'article:', 8)) {
         // insert comment in the database
         if (!($entry_fields['id'] = Comments::post($entry_fields))) {
             Logger::remember('agents/messages.php: ' . Logger::error_pop());
             return NULL;
         }
         // debug, if required to do so
         if ($context['debug_messages'] == 'Y') {
             Logger::remember('agents/messages.php: Messages::submit_page() as a comment', $entry_fields, 'debug');
         }
         // increment the post counter of the surfer
         Users::increment_posts($user['id']);
         // clear cache
         $parent = Anchors::get($entry_fields['anchor']);
         // touch the related anchor
         if (is_object($parent) && isset($entry_fields['id'])) {
             $parent->touch('comment:create', $entry_fields['id'], TRUE);
         }
         return 'comment:' . $entry_fields['id'];
         // create a new page
     } else {
         // publish automatically, if required to do so
         $section = Anchors::get($entry_fields['anchor']);
         if (isset($context['users_with_auto_publish']) && $context['users_with_auto_publish'] == 'Y' || preg_match('/\\bauto_publish\\b/i', $options) || is_object($section) && $section->has_option('auto_publish')) {
             $entry_fields['publish_date'] = gmstrftime('%Y-%m-%d %H:%M:%S', time());
             if (!isset($entry_fields['publish_name'])) {
                 $entry_fields['publish_name'] = $user['nick_name'];
             }
             if (!isset($entry_fields['publish_id'])) {
                 $entry_fields['publish_id'] = $user['id'];
             }
             if (!isset($entry_fields['publish_address'])) {
                 $entry_fields['publish_address'] = $user['email'];
             }
         }
         // ensure we are using ids instead of nicknames
         if (is_object($section)) {
             $entry_fields['anchor'] = $section->get_reference();
         }
         // save in the database
         if (!($entry_fields['id'] = Articles::post($entry_fields))) {
             Logger::remember('agents/messages.php: ' . Logger::error_pop());
             return NULL;
         }
         // debugging log
         if (isset($context['debug_messages']) && $context['debug_messages'] == 'Y') {
             $entry_fields['description'] = substr($entry_fields['description'], 0, 1024);
             Logger::remember('agents/messages.php: Messages::submit_page() as an article', $entry_fields, 'debug');
         }
         // increment the post counter of the surfer
         Users::increment_posts($user['id']);
         // do whatever is necessary on page creation
         if (isset($entry_fields['publish_date']) && $entry_fields['publish_date'] > NULL_DATE) {
             Articles::finalize_publication($section, $entry_fields);
         } else {
             Articles::finalize_submission($section, $entry_fields);
         }
         // get the new item
         $article = Anchors::get($anchor);
         // if replies are allowed
         if (!preg_match('/\\bno_reply\\b/i', $options)) {
             // let the sender know about his post
             if (isset($entry_fields['publish_date']) && $entry_fields['publish_date'] > NULL_DATE) {
                 $splash = i18n::s("The page received by e-mail has been successfully published. Please review it now to ensure that it reflects your mind.");
             } else {
                 $splash = i18n::s("The page received by e-mail has been posted. Don't forget to read it online. Then click on the Publish command to make it publicly available.");
             }
             $message = '<p>' . $splash . '</p>' . '<p><a href="' . $context['url_to_home'] . $context['url_to_root'] . $article->get_url() . '">' . $article->get_title() . '</a></p>' . '<div>' . $article->get_teaser('basic') . '</div>' . '<p>' . i18n::c('Thank you for your contribution') . '</p>';
             // enable threading
             $headers = Mailer::set_thread($section);
             // send a mail message
             Mailer::notify(NULL, $post_sender, 'Re: ' . $post_subject, $message, $headers);
         }
         // reference to the new page
         return 'article:' . $entry_fields['id'];
     }
     // job ends
     return NULL;
 }
Esempio n. 4
0
File: delete.php Progetto: rair/yacs
    Safe::header('Status: 401 Unauthorized', TRUE, 401);
    Logger::error(i18n::s('You are not allowed to perform this operation.'));
    // no deletion in demo mode
} elseif (isset($_REQUEST['confirm']) && $_REQUEST['confirm'] == 'yes' && 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.'));
    // deletion is confirmed
} elseif (isset($_REQUEST['confirm']) && $_REQUEST['confirm'] == 'yes') {
    // close the session on self-deletion
    if (Surfer::get_id() == $item['id']) {
        Surfer::reset();
    }
    // attempt to delete
    if (Users::delete($item['id'])) {
        // log item deletion
        $label = sprintf(i18n::c('Deletion: %s'), strip_tags($item['nick_name']));
        $description = Users::get_permalink($item);
        Logger::remember('users/delete.php: ' . $label, $description);
        // this can appear anywhere
        Cache::clear();
        // back to the index page
        Safe::redirect($context['url_to_home'] . $context['url_to_root'] . 'users/');
    }
    // deletion has to be confirmed
} elseif (isset($_SERVER['REQUEST_METHOD']) && $_SERVER['REQUEST_METHOD'] == 'POST') {
    Logger::error(i18n::s('The action has not been confirmed.'));
} else {
    // the submit button
    if (Surfer::is($item['id'])) {
        $label = i18n::s('Yes, I want to suppress my own profile from this server and log out.');
    } else {
Esempio n. 5
0
File: links.php Progetto: rair/yacs
 /**
  * record a click
  *
  * @param string the external url that is targeted
  *
  */
 public static function click($url)
 {
     global $context;
     // we record only GET requests
     if (isset($_SERVER['REQUEST_METHOD']) && $_SERVER['REQUEST_METHOD'] != 'GET') {
         return;
     }
     // do not count crawling
     if (isset($_SERVER['HTTP_USER_AGENT']) && preg_match('/(blo\\.gs|\\bblog|bot\\b|crawler\\b|frontier\\b|slurp\\b|spider\\b)/i', $_SERVER['HTTP_USER_AGENT'])) {
         return;
     }
     // record the activity
     Activities::post($url, 'click');
     // do not record clicks driving to search engines
     if (preg_match('/\\b(google|yahoo)\\b/i', $url)) {
         return;
     }
     // if this url is known
     $query = "SELECT * FROM " . SQL::table_name('links') . " AS links" . " WHERE links.link_url LIKE '" . SQL::escape($url) . "'";
     if ($item = SQL::query_first($query)) {
         // increment the number of clicks
         $query = "UPDATE " . SQL::table_name('links') . " SET hits=hits+1 WHERE id = " . SQL::escape($item['id']);
         SQL::query($query);
         // else create a new record with a count of one click
     } else {
         // get the section for clicks
         $anchor = Sections::lookup('clicks');
         // no section yet, create one
         if (!$anchor) {
             $fields['nick_name'] = 'clicks';
             $fields['title'] = i18n::c('Clicks');
             $fields['introduction'] = i18n::c('Clicked links are referenced here.');
             $fields['description'] = i18n::c('YACS ties automatically external links to this section on use. Therefore, you will have below a global picture of external sites that are referenced through your site.');
             $fields['active_set'] = 'N';
             // for associates only
             $fields['locked'] = 'Y';
             // no direct contributions
             $fields['index_map'] = 'N';
             // listd only to associates
             $fields['rank'] = 20000;
             // towards the end of the list
             // reference the new section
             if ($fields['id'] = Sections::post($fields)) {
                 $anchor = 'section:' . $fields['id'];
             }
         }
         // create a new link in the database
         $fields = array();
         $fields['anchor'] = $anchor;
         $fields['link_url'] = $url;
         $fields['hits'] = 1;
         Surfer::check_default_editor($fields);
         if ($fields['id'] = Links::post($fields)) {
             Links::clear($fields);
         }
     }
 }
Esempio n. 6
0
File: query.php Progetto: rair/yacs
            // message body
            $message = sprintf(i18n::s("<p>Your query will now be reviewed by one of the associates of this community. It is likely that this will be done within the next 24 hours at the latest.</p><p>You can check the status of your query at the following address:</p><p>%s</p><p>We would like to thank you for your interest in our web site.</p>"), '<a href="' . $link . '">' . $link . '</a>');
            // enable threading
            if (isset($item['id'])) {
                $headers = Mailer::set_thread('article:' . $item['id']);
            } else {
                $headers = '';
            }
            // actual post - don't stop on error
            Mailer::notify(NULL, $to, $subject, $message, $headers);
        }
        // get the article back
        $article = Anchors::get('article:' . $_REQUEST['id']);
        // log the query submission
        if (is_object($article)) {
            $label = sprintf(i18n::c('New query: %s'), strip_tags($article->get_title()));
            $link = $context['url_to_home'] . $context['url_to_root'] . $article->get_url();
            $description = '<a href="' . $link . '">' . $link . '</a>' . "\n\n" . $article->get_teaser('basic');
            Logger::notify('query.php: ' . $label, $description);
        }
    }
    // display the form on GET
} else {
    $with_form = TRUE;
}
// display the form
if ($with_form) {
    // splash message
    $context['text'] .= '<p>' . i18n::s('Please fill out the form and it will be sent automatically to the site managers. Be as precise as possible, and mention your e-mail address to let us a chance to contact you back.') . "</p>\n";
    // the form to send a query
    $context['text'] .= '<form method="post" action="' . $context['script_url'] . '" onsubmit="return validateDocumentPost(this)" id="main_form"><div>';
Esempio n. 7
0
    $fields['submit_monitor'] = 'N';
    $fields['monitor_url'] = '';
    if ($error = Servers::post($fields)) {
        $text .= $error;
    } else {
        $text .= sprintf(i18n::s('A record has been created for server %s'), $fields['host_name']) . BR . "\n";
    }
}
// 'www.yacs.fr' server
$fields = array();
$fields['host_name'] = i18n::s('www.yacs.fr');
if (Servers::get($fields['host_name'])) {
    $text .= sprintf(i18n::s('An entry already exists for server %s'), $fields['host_name']) . BR . "\n";
} else {
    $fields['title'] = 'yacs';
    $fields['description'] = i18n::c('The origin server for the YACS system');
    $fields['main_url'] = 'http://www.yacs.fr/';
    $fields['submit_feed'] = 'Y';
    $fields['feed_url'] = 'http://www.yacs.fr/feeds/rss.php';
    $fields['submit_ping'] = 'Y';
    $fields['ping_url'] = 'http://www.yacs.fr/services/ping.php';
    $fields['submit_search'] = 'N';
    $fields['search_url'] = 'http://www.yacs.fr/services/search.php';
    $fields['submit_monitor'] = 'N';
    $fields['monitor_url'] = 'http://www.yacs.fr/services/ping.php';
    if ($error = Servers::post($fields)) {
        $text .= $error;
    } else {
        $text .= sprintf(i18n::s('A record has been created for server %s'), $fields['host_name']) . BR . "\n";
    }
}
Esempio n. 8
0
File: switch.php Progetto: rair/yacs
 }
 $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();
 // do it again
 if (file_exists($context['path_to_root'] . 'parameters/switch.off')) {
     $menu = array_merge($menu, array('control/switch.php?action=on' => i18n::s('Switch on')));
 }
 // control panel
 $menu = array_merge($menu, array('control/' => i18n::s('Control Panel')));
Esempio n. 9
0
File: edit.php Progetto: rair/yacs
             $mail = array();
             $mail['subject'] = sprintf(i18n::c('%s: %s'), i18n::c('Contribution'), strip_tags($anchor->get_title()));
             $mail['notification'] = Files::build_notification('multiple', $attributes);
             // one file has been added
         } elseif ($item =& Files::get_by_anchor_and_name($anchor->get_reference(), $uploaded)) {
             $context['text'] .= '<p>' . i18n::s('Following file has been added:') . '</p>' . Codes::render_object('file', $item['id']);
             // use this file record
             $_REQUEST['id'] = $item['id'];
             // log single upload
             $label = sprintf(i18n::c('New file in %s'), strip_tags($anchor->get_title()));
             $link = Files::get_permalink($item);
             $description = sprintf(i18n::c('%s at %s'), $item['file_name'], '<a href="' . $link . '">' . $link . '</a>');
             Logger::notify('files/edit.php: ' . $label, $description);
             // notification to send by e-mail
             $mail = array();
             $mail['subject'] = sprintf(i18n::c('%s: %s'), i18n::c('Contribution'), strip_tags($anchor->get_title()));
             $mail['notification'] = Files::build_notification('upload', $item);
         }
         // send to anchor watchers
         if (isset($_REQUEST['notify_watchers']) && $_REQUEST['notify_watchers'] == 'Y') {
             $anchor->alert_watchers($mail, $action, isset($_REQUEST['active']) && $_REQUEST['active'] == 'N');
         }
         // send to followers of this user
         if (isset($_REQUEST['notify_followers']) && $_REQUEST['notify_followers'] == 'Y' && Surfer::get_id() && $_REQUEST['active'] != 'N') {
             $mail['message'] = Mailer::build_notification($mail['notification'], 2);
             Users::alert_watchers('user:'******'id'])) {
     // change has been documented
Esempio n. 10
0
File: index.php Progetto: rair/yacs
    $context['page_tools'][] = Skin::build_link('sections/edit.php', i18n::s('Add a section'));
    $context['page_tools'][] = Skin::build_link('help/populate.php', i18n::s('Content Assistant'));
    $context['page_tools'][] = Skin::build_link('sections/check.php', i18n::s('Maintenance'));
}
// display extra information
$cache_id = 'sections/index.php#extra';
if (!($text = Cache::get($cache_id))) {
    // see also
    $lines = array();
    $lines[] = Skin::build_link('categories/', i18n::s('Categories'));
    $lines[] = Skin::build_link('search.php', i18n::s('Search'));
    $lines[] = Skin::build_link('help/', i18n::s('Help index'));
    $lines[] = Skin::build_link('query.php', i18n::s('Contact'));
    $text .= Skin::build_box(i18n::s('See also'), Skin::finalize_list($lines, 'compact'), 'boxes');
    // list monthly publications in an extra box
    $anchor = Categories::get(i18n::c('monthly'));
    if (isset($anchor['id']) && ($items = Categories::list_by_date_for_anchor('category:' . $anchor['id'], 0, COMPACT_LIST_SIZE, 'compact'))) {
        $text .= Skin::build_box($anchor['title'], Skin::build_list($items, 'compact'), 'boxes') . "\n";
    }
    // side boxes for related categories, if any
    if ($categories = Categories::list_by_date_for_display('section:index', 0, 7, 'raw')) {
        foreach ($categories as $id => $attributes) {
            // link to the category page from the box title
            $label =& Skin::build_box_title(Skin::strip($attributes['title']), Categories::get_permalink($attributes), i18n::s('View the category'));
            // box content
            if ($items =& Members::list_articles_by_date_for_anchor('category:' . $id, 0, COMPACT_LIST_SIZE, 'compact')) {
                $text .= Skin::build_box($label, Skin::build_list($items, 'compact'), 'boxes') . "\n";
            }
        }
    }
    // save, whatever change, for 5 minutes
Esempio n. 11
0
File: new.php Progetto: rair/yacs
     // reference the new section
     if ($fields['id'] = Sections::post($fields, FALSE)) {
         $anchor = 'section:' . $fields['id'];
     }
 }
 // archive the letter
 $context['text'] .= i18n::s('Archiving the new letter') . BR . "\n";
 // save the letter as a published article, but don't use special categories
 $fields = array();
 $fields['anchor'] = $anchor;
 $fields['title'] = $_REQUEST['letter_title'];
 $label = $_REQUEST['letter_recipients'];
 if ($_REQUEST['letter_recipients'] == 'custom' && isset($_REQUEST['mail_to'])) {
     $label = $_REQUEST['mail_to'];
 }
 $fields['introduction'] = sprintf(i18n::c('Sent %s to&nbsp;"%s"'), Skin::build_date(time(), 'full', $context['preferred_language']), $label);
 $fields['description'] = $_REQUEST['letter_body'];
 $fields['publish_name'] = Surfer::get_name();
 $fields['publish_id'] = Surfer::get_id();
 $fields['publish_address'] = Surfer::get_email_address();
 $fields['publish_date'] = gmstrftime('%Y-%m-%d %H:%M:%S');
 $fields['id'] = Articles::post($fields);
 // from: from configuration files
 if (isset($context['letter_reply_to']) && $context['letter_reply_to']) {
     $from = $context['letter_reply_to'];
 } elseif (isset($context['mail_from']) && $context['mail_from']) {
     $from = $context['mail_from'];
 } else {
     $from = $context['site_name'];
 }
 // to: build the list of recipients
Esempio n. 12
0
File: chmod.php Progetto: rair/yacs
        $count++;
        // avoid timeouts
        if (!($count % 50)) {
            Safe::set_time_limit(30);
            SQL::ping();
        }
    }
    if ($count) {
        $context['text'] .= sprintf(i18n::s('%d files have been updated.'), $count) . "\n";
    }
    $context['text'] .= "</p>\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>';
    // forward to the index page
    $menu = array('control/' => i18n::s('Control Panel'));
    $context['text'] .= Skin::build_list($menu, 'menu_bar');
    // remember the operation
    $label = sprintf(i18n::c('chmod %s has been applied to scripts'), $context['file_mask']);
    Logger::remember('control/chmod.php: ' . $label);
    // confirmation is required
} else {
    // the confirmation question
    $context['text'] .= '<b>' . sprintf(i18n::s('You are about to chmod(%d) all running scripts of this server. Are you sure?'), $context['file_mask']) . "</b>\n";
    // the menu for this page
    $context['text'] .= '<form method="post" action="' . $context['script_url'] . '"><p>' . Skin::build_submit_button(i18n::s('Yes, I do want to change permissions of running scripts')) . '<input type="hidden" name="action" value="confirm" />' . '</p></form>' . "\n";
    // 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";
}
// render the skin
render_skin();
Esempio n. 13
0
/**
 * dynamically generate the page
 *
 * @see skins/index.php
 */
function send_body()
{
    global $context, $local;
    // $local is required to localize included scripts
    // include every script that has to be run once
    global $scripts, $scripts_count;
    if (@count($scripts)) {
        // the alphabetical order may be used to control script execution order
        sort($scripts);
        reset($scripts);
        // process each script one by one
        foreach ($scripts as $item) {
            // do not execute on first installation
            if (file_exists('../parameters/switch.on') || file_exists('../parameters/switch.off')) {
                // ensure we have a valid database resource
                if (!$context['connection']) {
                    break;
                }
                // remember this as an event
                Logger::remember('scripts/run_once.php: ' . sprintf(i18n::c('script %s has been executed'), $item));
                // where scripts actually are
                $actual_item = str_replace('//', '/', $context['path_to_root'] . 'scripts/run_once/' . $item);
                // include the script to execute it
                $scripts_count++;
                echo Skin::build_block($item, 'subtitle');
                include $actual_item;
                echo "\n";
            }
            // ensure enough overall execution time
            Safe::set_time_limit(30);
            // stamp the file to remember execution time
            Safe::touch($actual_item);
            // rename the script to avoid further execution
            Safe::unlink($actual_item . '.done');
            Safe::rename($actual_item, $actual_item . '.done');
        }
        // refresh javascript libraries
        Cache::purge('js');
    }
    // report on actual execution
    if ($scripts_count) {
        echo '<p>&nbsp;</p><p>' . sprintf(i18n::ns('%d script has been executed', '%d scripts have been executed', $scripts_count), $scripts_count) . "</p>\n";
    } else {
        echo '<p>' . i18n::s('No script has been executed') . "</p>\n";
    }
    // display the total execution time
    $time = round(get_micro_time() - $context['start_time'], 2);
    if ($time > 30) {
        echo '<p>' . sprintf(i18n::s('Script terminated in %.2f seconds.'), $time) . '</p>';
    }
    // if the server has been switched off, go back to the control panel
    if (file_exists('../parameters/switch.off')) {
        echo '<form method="get" action="' . $context['url_to_root'] . 'control/">' . "\n" . '<p class="assistant_bar">' . Skin::build_submit_button(i18n::s('Control Panel')) . '</p>' . "\n" . '</form>' . "\n";
        // else back to the control panel as well, but without a button
    } else {
        $menu = array('control/' => i18n::s('Control Panel'));
        echo Skin::build_list($menu, 'menu_bar');
    }
    // purge the cache, since it is likely that we have modified some data
    Cache::clear();
}
Esempio n. 14
0
File: delete.php Progetto: rair/yacs
    $context['text'] .= Skin::build_block(sprintf(i18n::s('This file has been reserved by %s %s, and it is likely that an updated version will be made available soon.'), Users::get_link($item['assign_name'], $item['assign_address'], $item['assign_id']), Skin::build_date($item['assign_date'])), 'caution');
    // follow-up commands
    $menu = array();
    $menu[] = Skin::build_link($anchor->get_url('files'), i18n::s('Done'), 'button');
    $menu[] = Skin::build_link(Files::get_url($item['id'], 'release'), i18n::s('Release reservation'), 'span');
    $context['text'] .= Skin::build_block(Skin::finalize_list($menu, 'menu_bar'), 'bottom');
    // deletion is confirmed
} elseif (isset($_REQUEST['confirm']) && $_REQUEST['confirm'] == 'yes') {
    // touch the related anchor before actual deletion, since the file has to be accessible at that time
    if (is_object($anchor)) {
        $anchor->touch('file:delete', $item['id']);
    }
    // if no error, back to the anchor or to the index page
    if (Files::delete($item['id'])) {
        // log item deletion
        $label = sprintf(i18n::c('Deletion: %s'), strip_tags($item['title']));
        $description = Files::get_permalink($item);
        Logger::remember('files/delete.php: ' . $label, $description);
        Files::clear($item);
        if ($render_overlaid) {
            echo 'delete done';
            die;
        }
        if (is_object($anchor)) {
            Safe::redirect($anchor->get_url() . '#_attachments');
        } else {
            Safe::redirect($context['url_to_home'] . $context['url_to_root'] . 'files/');
        }
    }
    // deletion has to be confirmed
} elseif (isset($_SERVER['REQUEST_METHOD']) && $_SERVER['REQUEST_METHOD'] == 'POST') {
Esempio n. 15
0
File: select.php Progetto: rair/yacs
 } elseif (isset($_REQUEST['action']) && $_REQUEST['action'] == 'assign' && isset($_REQUEST['anchor']) && isset($_REQUEST['member'])) {
     // add a category member
     if (!strncmp($_REQUEST['member'], 'category:', 9)) {
         Members::assign($_REQUEST['anchor'], $_REQUEST['member']);
         Members::assign($_REQUEST['member'], $_REQUEST['anchor']);
         // add a follower to this person
     } elseif (!strncmp($_REQUEST['member'], 'user:'******'anchor'], $_REQUEST['member']);
         // notify a person that is followed
         if (($follower = Anchors::get($_REQUEST['member'])) && isset($user['email']) && $user['email'] && $user['without_alerts'] != 'Y') {
             // notify target user by e-mail
             $subject = sprintf(i18n::c('%s is following you'), strip_tags($follower->get_title()));
             // headline
             $headline = sprintf(i18n::c('%s is following you'), '<a href="' . $context['url_to_home'] . $context['url_to_root'] . $follower->get_url() . '">' . $follower->get_title() . '</a>');
             // information
             $message = '<p>' . sprintf(i18n::c('%s will receive notifications when you will update your followers at %s'), $follower->get_title(), $context['site_name']) . '</p>';
             // assemble main content of this message
             $message = Skin::build_mail_content($headline, $message);
             // a set of links
             $menu = array();
             // call for action
             $link = $context['url_to_home'] . $context['url_to_root'] . $follower->get_url();
             $menu[] = Skin::build_mail_button($link, $follower->get_title(), TRUE);
             // finalize links
             $message .= Skin::build_mail_menu($menu);
             // enable threading
             $headers = Mailer::set_thread($follower->get_reference());
             // allow for cross-referencing
             Mailer::notify(Surfer::from(), $user['email'], $subject, $message, $headers);
         }
         // regular container
Esempio n. 16
0
 /**
  * build a notification related to a section
  *
  * This function builds a mail message that displays:
  * - an image of the contributor (if possible)
  * - a headline mentioning the contribution
  * - the full content of the section
  * - a button linked to the section
  * - a link to the containing section, if any
  *
  * Note: this function returns legacy HTML, not modern XHTML, because this is what most
  * e-mail client software can afford.
  *
  * @param string either 'apply', 'create' or 'update'
  * @param array attributes of the item
  * @param object overlay of the item, if any
  * @return string text to be send by e-mail
  */
 public static function build_notification($action, $item, $overlay = NULL)
 {
     global $context;
     // get the main anchor
     $anchor = Anchors::get($item['anchor']);
     // compute page title
     if (is_object($overlay)) {
         $title = Codes::beautify_title($overlay->get_text('title', $item));
     } else {
         $title = Codes::beautify_title($item['title']);
     }
     // headline template
     switch ($action) {
         case 'apply':
             $template = i18n::c('%s is requesting access to %s');
             break;
         case 'create':
             $template = i18n::c('%s has created section %s');
             break;
         case 'update':
             $template = i18n::c('%s has updated section %s');
             break;
     }
     // headline
     $headline = sprintf($template, Surfer::get_link(), '<a href="' . Sections::get_permalink($item) . '">' . $title . '</a>');
     // panel content
     $content = '';
     // signal restricted and private articles
     if ($item['active'] == 'N') {
         $title = PRIVATE_FLAG . $title;
     } elseif ($item['active'] == 'R') {
         $title = RESTRICTED_FLAG . $title;
     }
     // insert page title
     $content .= '<h3><span>' . $title . '</span></h3>';
     // insert anchor prefix
     if (is_object($anchor)) {
         $content .= $anchor->get_prefix();
     }
     // the introduction text, if any
     if (is_object($overlay)) {
         $content .= Skin::build_block($overlay->get_text('introduction', $item), 'introduction');
     } elseif (isset($item['introduction']) && trim($item['introduction'])) {
         $content .= Skin::build_block($item['introduction'], 'introduction');
     }
     // get text related to the overlay, if any
     if (is_object($overlay)) {
         $content .= $overlay->get_text('view', $item);
     }
     // filter description, if necessary
     if (is_object($overlay)) {
         $description = $overlay->get_text('description', $item);
     } else {
         $description = $item['description'];
     }
     // the beautified description, which is the actual page body
     if ($description) {
         // use adequate label
         if (is_object($overlay) && ($label = $overlay->get_label('description'))) {
             $content .= Skin::build_block($label, 'title');
         }
         // beautify the target page
         $content .= Skin::build_block($description, 'description', '', $item['options']);
     }
     // attachment details
     $details = array();
     // info on related sections
     if ($count = Sections::count_for_anchor('section:' . $item['id'])) {
         $details[] = sprintf(i18n::nc('%d section', '%d sections', $count), $count);
     }
     // info on related articles
     if ($count = Articles::count_for_anchor('section:' . $item['id'])) {
         $details[] = sprintf(i18n::nc('%d page', '%d pages', $count), $count);
     }
     // info on related files
     if ($count = Files::count_for_anchor('section:' . $item['id'], TRUE)) {
         // the actual list of files attached to this section
         if (preg_match('/\\bfiles_by_title\\b/i', $item['options'])) {
             $items = Files::list_by_title_for_anchor('section:' . $item['id'], 0, 300, 'compact');
         } else {
             $items = Files::list_by_date_for_anchor('section:' . $item['id'], 0, 300, 'compact');
         }
         // wrap it with some header
         if (is_array($items)) {
             $items = Skin::build_list($items);
         }
         if ($items) {
             $content .= '<h3><span>' . i18n::s('Files') . '</span></h3>' . $items;
         }
         // details to be displayed at page bottom
         $details[] = sprintf(i18n::nc('%d file', '%d files', $count), $count);
     }
     // info on related links
     include_once $context['path_to_root'] . 'links/links.php';
     if ($count = Links::count_for_anchor('section:' . $item['id'], TRUE)) {
         $details[] = sprintf(i18n::nc('%d link', '%d links', $count), $count);
     }
     // comments
     include_once $context['path_to_root'] . 'comments/comments.php';
     if ($count = Comments::count_for_anchor('section:' . $item['id'], TRUE)) {
         $details[] = sprintf(i18n::nc('%d comment', '%d comments', $count), $count);
     }
     // describe attachments
     if (count($details)) {
         $content .= '<hr align="left" size=1" width="150">' . '<p style="margin: 3px 0;">' . sprintf(i18n::c('This section has %s'), join(', ', $details)) . '</p>';
     }
     // assemble main content of this message
     $text = Skin::build_mail_content($headline, $content);
     // a set of links
     $menu = array();
     // request access to the item
     if ($action == 'apply') {
         // call for action
         $link = $context['url_to_home'] . $context['url_to_root'] . Sections::get_url($item['id'], 'invite', Surfer::get_id());
         $label = sprintf(i18n::c('Invite %s to participate'), Surfer::get_name());
         $menu[] = Skin::build_mail_button($link, $label, TRUE);
         // link to user profile
         $link = Surfer::get_permalink();
         $label = sprintf(i18n::c('View the profile of %s'), Surfer::get_name());
         $menu[] = Skin::build_mail_button($link, $label, FALSE);
         // invite to visit the item
     } else {
         // call for action
         $link = Sections::get_permalink($item);
         if (!is_object($overlay) || !($label = $overlay->get_label('permalink_command', 'sections', FALSE))) {
             $label = i18n::c('View the section');
         }
         $menu[] = Skin::build_mail_button($link, $label, TRUE);
         // link to the container
         if (is_object($anchor)) {
             $link = $context['url_to_home'] . $context['url_to_root'] . $anchor->get_url();
             $menu[] = Skin::build_mail_button($link, $anchor->get_title(), FALSE);
         }
     }
     // finalize links
     $text .= Skin::build_mail_menu($menu);
     // the full message
     return $text;
 }
Esempio n. 17
0
File: view.php Progetto: rair/yacs
// page canonical link
$context['page_link'] = Articles::get_permalink($item);
// not found -- help web crawlers
if (!isset($item['id'])) {
    include '../error.php';
    // permission denied
} elseif (!$permitted) {
    // make it clear to crawlers
    if (Surfer::is_crawler()) {
        Safe::header('Status: 401 Unauthorized', TRUE, 401);
    } elseif (!Surfer::is_logged()) {
        Safe::redirect($context['url_to_home'] . $context['url_to_root'] . 'users/login.php?url=' . urlencode(Articles::get_permalink($item)));
    } elseif (isset($_REQUEST['requested']) && ($requested = Users::get($_REQUEST['requested'])) && $requested['email']) {
        // prepare the mail message
        $to = Mailer::encode_recipient($requested['email'], $requested['full_name']);
        $subject = sprintf(i18n::c('%s: %s'), i18n::c('Request'), strip_tags($item['title']));
        $message = Articles::build_notification('apply', $item, $overlay);
        $headers = Mailer::set_thread('article:' . $item['id']);
        // allow for skinnable template
        $message = Skin::build_mail_message($message);
        // build multiple parts, for HTML rendering
        $message = Mailer::build_multipart($message);
        // send the message to requested user
        if (Mailer::post(Surfer::from(), $to, $subject, $message, NULL, $headers)) {
            $text = sprintf(i18n::s('Your request has been transmitted to %s. Check your mailbox for feed-back.'), Skin::build_link(Users::get_permalink($requested), Codes::beautify_title($requested['full_name']), 'user'));
            $context['text'] .= Skin::build_block($text, 'note');
        }
        // follow-up navigation
        $context['text'] .= '<div>' . i18n::s('Where do you want to go now?') . '</div>';
        $menu = array();
        $menu[] = Skin::build_link($context['url_to_root'], i18n::s('Front page'), 'button');
Esempio n. 18
0
        $menu = array_merge($menu, array($article->get_url() => i18n::s('View the page')));
        $menu = array_merge($menu, array($article->get_url('edit') => i18n::s('Edit the page')));
        if (Surfer::may_upload()) {
            $menu = array_merge($menu, array('images/edit.php?anchor=' . urlencode($article->get_reference()) => i18n::s('Add an image')));
            $menu = array_merge($menu, array('files/edit.php?anchor=' . urlencode($article->get_reference()) => i18n::s('Add a file')));
        }
        $menu = array_merge($menu, array('links/edit.php?anchor=' . urlencode($article->get_reference()) => i18n::s('Add a link')));
        $follow_up .= Skin::build_list($menu, 'menu_bar');
        $context['text'] .= Skin::build_block($follow_up, 'bottom');
        // log the creation of a new article
        $label = sprintf(i18n::c('Article copy: %s'), strip_tags($article->get_title()));
        // poster and target section
        if (is_object($anchor)) {
            $description = sprintf(i18n::c('Sent by %s in %s'), Surfer::get_name(), $anchor->get_title());
        } else {
            $description = sprintf(i18n::c('Sent by %s'), Surfer::get_name());
        }
        // title and link
        if ($title = $article->get_title()) {
            $description .= $title . "\n";
        }
        $description = '<a href="' . $context['url_to_home'] . $context['url_to_root'] . $article->get_url() . '">' . $article->get_title() . '</a>';
        // notify sysops
        Logger::notify('articles/duplicate.php: ' . $label, $description);
    }
    // action has to be confirmed
} elseif (isset($_SERVER['REQUEST_METHOD']) && $_SERVER['REQUEST_METHOD'] == 'POST') {
    Logger::error(i18n::s('The action has not been confirmed.'));
    // please confirm
} else {
    // the article or the anchor icon, if any
Esempio n. 19
0
    if (isset($_REQUEST['files_url'])) {
        $content .= '$context[\'files_url\']=\'' . addcslashes($_REQUEST['files_url'], "\\'") . "';\n";
    }
    $content .= '?>' . "\n";
    // update the parameters file
    if (!Safe::file_put_contents('parameters/files.include.php', $content)) {
        Logger::error(sprintf(i18n::s('ERROR: Impossible to write to the file %s. The configuration has not been saved.'), 'parameters/files.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/files.include.php') . "</p>\n";
        // job done
    } else {
        $context['text'] .= '<p>' . sprintf(i18n::s('The following configuration has been saved into the file %s.'), 'parameters/files.include.php') . "</p>\n";
        // purge the cache
        Cache::clear();
        // remember the change
        $label = sprintf(i18n::c('%s has been updated'), 'parameters/files.include.php');
        Logger::remember('files/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('files/' => i18n::s('Files')));
    $menu = array_merge($menu, array('control/' => i18n::s('Control Panel')));
    $menu = array_merge($menu, array('files/configure.php' => i18n::s('Configure again')));
    $follow_up .= Skin::build_list($menu, 'menu_bar');
    $context['text'] .= Skin::build_block($follow_up, 'bottom');
}
// render the skin
render_skin();
Esempio n. 20
0
File: invite.php Progetto: rair/yacs
 $label = i18n::s('Message title');
 if (is_object($overlay)) {
     $title = $overlay->get_live_title($item);
 } else {
     $title = $item['title'];
 }
 $title = sprintf(i18n::c('Invitation: %s'), $title);
 $input = '<input type="text" name="subject" size="50" maxlength="255" value="' . encode_field($title) . '" />';
 $fields[] = array($label, $input);
 // default message content
 $content = '';
 if (is_callable(array($overlay, 'get_invite_default_message'))) {
     $content = $overlay->get_invite_default_message();
 }
 if (!$content) {
     $content = '<p>' . i18n::c('I would like to invite you to the following page.') . '</p>' . '<p><a href="' . Sections::get_permalink($item) . '">' . $item['title'] . '</a></p>' . '<p>' . i18n::c('Please let me thank you for your involvement.') . '</p>' . '<p>' . Surfer::get_name() . '</p>';
 }
 // the message
 $label = i18n::s('Message content');
 $input = Surfer::get_editor('message', $content);
 $fields[] = array($label, $input);
 // build the form
 $context['text'] .= Skin::build_form($fields);
 //
 // bottom commands
 //
 $menu = array();
 // the submit button
 $menu[] = Skin::build_submit_button(i18n::s('Submit'), i18n::s('Press [s] to submit data'), 's');
 // cancel button
 if (isset($item['id'])) {
Esempio n. 21
0
 /**
  * list articles as digg do
  *
  * @param resource the SQL result
  * @return string the rendered text
  *
  * @see layouts/layout.php
  **/
 function layout($result)
 {
     global $context;
     // empty list
     if (!SQL::count($result)) {
         $label = i18n::s('No page to display.');
         if (Surfer::is_associate()) {
             $label .= ' ' . sprintf(i18n::s('Use the %s to populate this server.'), Skin::build_link('help/populate.php', i18n::s('Content Assistant'), 'shortcut'));
         }
         $output = '<p>' . $label . '</p>';
         return $output;
     }
     // build a list of articles
     $text = '';
     $item_count = 0;
     include_once $context['path_to_root'] . 'comments/comments.php';
     include_once $context['path_to_root'] . 'links/links.php';
     while ($item = SQL::fetch($result)) {
         // permalink
         $url = Articles::get_permalink($item);
         // get the anchor
         $anchor = Anchors::get($item['anchor']);
         // get the related overlay, if any
         $overlay = Overlay::load($item, 'article:' . $item['id']);
         // next item
         $item_count += 1;
         // section opening
         if ($item_count == 1) {
             $text .= '<div class="newest">' . "\n";
         }
         // reset everything
         $content = $prefix = $label = $suffix = $icon = '';
         // the icon to put aside
         if ($item['thumbnail_url']) {
             $icon = $item['thumbnail_url'];
         } elseif (is_callable(array($anchor, 'get_bullet_url'))) {
             $icon = $anchor->get_bullet_url();
         }
         if ($icon) {
             $icon = '<a href="' . $context['url_to_root'] . $url . '"><img src="' . $icon . '" class="right_image" alt="' . encode_field(i18n::s('View the page')) . '" title="' . encode_field(i18n::s('View the page')) . '" /></a>';
         }
         // signal restricted and private articles
         if ($item['active'] == 'N') {
             $prefix .= PRIVATE_FLAG;
         } elseif ($item['active'] == 'R') {
             $prefix .= RESTRICTED_FLAG;
         }
         // flag articles updated recently
         if ($item['create_date'] >= $context['fresh']) {
             $suffix .= ' ' . NEW_FLAG;
         } elseif ($item['edit_date'] >= $context['fresh']) {
             $suffix .= ' ' . UPDATED_FLAG;
         }
         // add details
         $details = array();
         // the author
         if (isset($context['with_author_information']) && $context['with_author_information'] == 'Y') {
             if ($item['edit_name'] == $item['create_name']) {
                 $details[] = sprintf(i18n::s('by %s'), ucfirst($item['create_name']));
             } else {
                 $details[] = sprintf(i18n::s('by %s, %s'), ucfirst($item['create_name']), ucfirst($item['edit_name']));
             }
         }
         // the publish date
         $details[] = Skin::build_date($item['publish_date']);
         // rating
         $rating_label = '';
         if ($item['rating_count']) {
             $rating_label = Skin::build_rating_img((int) round($item['rating_sum'] / $item['rating_count'])) . ' ' . sprintf(i18n::ns('%d rating', '%d ratings', $item['rating_count']), $item['rating_count']) . ' ';
         }
         // add a link to let surfer rate this item
         if (is_object($anchor) && !$anchor->has_option('without_rating')) {
             if (!$item['rating_count']) {
                 $rating_label .= i18n::s('Rate this page');
             }
             $rating_label = Skin::build_link(Articles::get_url($item['id'], 'like'), $rating_label, 'basic', i18n::s('Rate this page'));
         }
         // display current rating, and allow for rating
         $details[] = $rating_label;
         // details
         if (count($details)) {
             $content .= '<p class="details">' . ucfirst(implode(', ', $details)) . '</p>';
         }
         // the full introductory text
         if ($item['introduction']) {
             $content .= Codes::beautify($item['introduction'], $item['options']);
         } elseif (!is_object($overlay)) {
             include_once $context['path_to_root'] . 'articles/article.php';
             $article = new Article();
             $article->load_by_content($item);
             $content .= $article->get_teaser('teaser');
         }
         // insert overlay data, if any
         if (is_object($overlay)) {
             $content .= $overlay->get_text('list', $item);
         }
         // an array of links
         $menu = array();
         // rate the article
         $menu = array_merge($menu, array(Articles::get_url($item['id'], 'like') => i18n::s('Rate this page')));
         // read the article
         $menu = array_merge($menu, array($url => i18n::s('Read more')));
         // info on related files
         if ($count = Files::count_for_anchor('article:' . $item['id'], TRUE)) {
             $details[] = Skin::build_link($url . '#_attachments', sprintf(i18n::ns('%d file', '%d files', $count), $count), 'basic');
         }
         // info on related comments
         if ($count = Comments::count_for_anchor('article:' . $item['id'], TRUE)) {
             $link = Comments::get_url('article:' . $item['id'], 'list');
             $menu = array_merge($menu, array($link => sprintf(i18n::ns('%d comment', '%d comments', $count), $count)));
         }
         // discuss
         if (Comments::allow_creation($item, $anchor)) {
             $menu = array_merge($menu, array(Comments::get_url('article:' . $item['id'], 'comment') => i18n::s('Discuss')));
         }
         // info on related links
         if ($count = Links::count_for_anchor('article:' . $item['id'], TRUE)) {
             $menu = array_merge($menu, array($url . '#_attachments' => sprintf(i18n::ns('%d link', '%d links', $count), $count)));
         }
         // trackback
         if (Links::allow_trackback()) {
             $menu = array_merge($menu, array('links/trackback.php?anchor=' . urlencode('article:' . $item['id']) => i18n::s('Reference this page')));
         }
         // link to the anchor page
         if (is_object($anchor)) {
             $menu = array_merge($menu, array($anchor->get_url() => $anchor->get_title()));
         }
         // list up to three categories by title, if any
         if ($items = Members::list_categories_by_title_for_member('article:' . $item['id'], 0, 3, 'raw')) {
             foreach ($items as $id => $attributes) {
                 $menu = array_merge($menu, array(Categories::get_permalink($attributes) => $attributes['title']));
             }
         }
         // append a menu
         $content .= Skin::build_list($menu, 'menu_bar');
         // insert a complete box
         $text .= Skin::build_box($icon . $prefix . Codes::beautify_title($item['title']) . $suffix, $content, 'header1', 'article_' . $item['id']);
         // section closing
         if ($item_count == 1) {
             $text .= '</div>' . "\n";
         }
     }
     // end of processing
     SQL::free($result);
     // add links to archives
     $anchor = Categories::get(i18n::c('monthly'));
     if (isset($anchor['id']) && ($items = Categories::list_by_date_for_anchor('category:' . $anchor['id'], 0, COMPACT_LIST_SIZE, 'compact'))) {
         $text .= Skin::build_box(i18n::s('Previous pages'), Skin::build_list($items, 'menu_bar'));
     }
     return $text;
 }
Esempio n. 22
0
 $input = '<select name="anchor"><option value="">' . i18n::s('-- Root level') . "</option>\n" . Sections::get_options('none', NULL) . '</select>';
 $hint = i18n::s('Please carefully select a parent section, if any');
 $fields[] = array($label, $input, $hint);
 // the title
 $label = i18n::s('Wiki Title');
 $input = '<textarea id="title" name="title" rows="1" cols="50" accesskey="t">' . encode_field(i18n::c('Our wiki')) . '</textarea>';
 $hint = i18n::s('Please provide a meaningful title.');
 $fields[] = array($label, $input, $hint);
 // the introduction
 $label = i18n::s('Introduction');
 $input = '<textarea name="introduction" rows="5" cols="50" accesskey="i">' . encode_field(i18n::c('Our collaborative place')) . '</textarea>';
 $hint = i18n::s('Appears at site map, near section title');
 $fields[] = array($label, $input, $hint);
 // the description
 $label = i18n::s('Description');
 $input = '<textarea name="description" rows="4" cols="50">' . encode_field(i18n::c('A description of what information is developed at this wiki.')) . '</textarea>';
 $hint = i18n::s('Give a hint to interested people');
 $fields[] = array($label, $input, $hint);
 // the contribution flag: Yes/public, Restricted/logged, No/associates
 $label = i18n::s('Contribution');
 $input = '<input type="radio" name="contribution" value="Y" accesskey="c" checked="checked" /> ' . i18n::s('Anyone, including anonymous surfer, may contribute to this wiki.') . BR;
 $input .= '<input type="radio" name="contribution" value="R" /> ' . i18n::s('Any authenticated member can contribute.') . BR;
 $input .= '<input type="radio" name="contribution" value="N" /> ' . i18n::s('Only associates and owners can contribute.');
 $fields[] = array($label, $input);
 // the active flag: Yes/public, Restricted/logged, No/associates
 $label = i18n::s('Access');
 $input = '<input type="radio" name="active" value="Y" accesskey="v" checked="checked" /> ' . i18n::s('Public - Everybody, including anonymous surfers') . BR;
 $input .= '<input type="radio" name="active" value="R" /> ' . i18n::s('Community - Access is granted to any identified surfer') . BR;
 $input .= '<input type="radio" name="active" value="N" /> ' . i18n::s('Private - Access is restricted to selected persons');
 $fields[] = array($label, $input);
 // home panel
Esempio n. 23
0
 /**
  * list articles
  *
  * @param resource the SQL result
  * @return array
  *
  * @see layouts/layout.php
  **/
 function layout($result)
 {
     global $context;
     // we return an array of ($url => $attributes)
     $items = array();
     // empty list
     if (!SQL::count($result)) {
         return $items;
     }
     // process all items in the list
     include_once $context['path_to_root'] . 'articles/article.php';
     include_once $context['path_to_root'] . 'comments/comments.php';
     include_once $context['path_to_root'] . 'locations/locations.php';
     while ($item = SQL::fetch($result)) {
         // get the related overlay, if any
         $overlay = Overlay::load($item, 'article:' . $item['id']);
         // get the anchor
         $anchor = Anchors::get($item['anchor']);
         // provide an absolute link
         $url = Articles::get_permalink($item);
         // build a title
         if (is_object($overlay)) {
             $title = Codes::beautify_title($overlay->get_text('title', $item));
         } else {
             $title = Codes::beautify_title($item['title']);
         }
         // time of last update
         $time = SQL::strtotime($item['edit_date']);
         // the section
         $section = '';
         if ($item['anchor'] && ($anchor = Anchors::get($item['anchor']))) {
             $section = ucfirst(trim(strip_tags(Codes::beautify_title($anchor->get_title()))));
         }
         // the icon to use
         $icon = '';
         if ($item['thumbnail_url']) {
             $icon = $item['thumbnail_url'];
         } elseif ($item['anchor'] && ($anchor = Anchors::get($item['anchor'])) && is_callable($anchor, 'get_bullet_url')) {
             $icon = $anchor->get_bullet_url();
         }
         if ($icon) {
             $icon = $context['url_to_home'] . $context['url_to_root'] . $icon;
         }
         // the author(s) is an e-mail address, according to rss 2.0 spec
         $author = '';
         if (isset($item['create_address'])) {
             $author .= $item['create_address'];
         }
         if (isset($item['create_name']) && trim($item['create_name'])) {
             $author .= ' (' . $item['create_name'] . ')';
         }
         if (isset($item['edit_address']) && trim($item['edit_address']) && $item['create_address'] != $item['edit_address']) {
             if ($author) {
                 $author .= ', ';
             }
             $author .= $item['edit_address'];
             if (isset($item['edit_name']) && trim($item['edit_name'])) {
                 $author .= ' (' . $item['edit_name'] . ')';
             }
         }
         // some introductory text for this article
         $article = new Article();
         $article->load_by_content($item);
         $introduction = $article->get_teaser('teaser');
         // warns on restricted access
         if (isset($item['active']) && $item['active'] != 'Y') {
             $introduction = '[' . i18n::c('Restricted to members') . '] ' . $introduction;
         }
         // fix references
         $introduction = preg_replace('/"\\//', '"' . $context['url_to_home'] . '/', $introduction);
         // the article content
         $description = '';
         // other rss fields
         $extensions = array();
         // the geolocation for this page, if any
         if ($location = Locations::locate_anchor('article:' . $item['id'])) {
             $extensions[] = '<georss:point>' . str_replace(',', ' ', $location) . '</georss:point>';
         }
         // url for comments
         if (is_object($anchor)) {
             $extensions[] = '<comments>' . encode_link($context['url_to_home'] . $context['url_to_root'] . $anchor->get_url('comments')) . '</comments>';
         }
         // count comments
         $comment_count = Comments::count_for_anchor('article:' . $item['id']);
         $extensions[] = '<slash:comments>' . $comment_count . "</slash:comments>";
         // the comment post url
         $extensions[] = '<wfw:comment>' . encode_link($context['url_to_home'] . $context['url_to_root'] . Comments::get_url('article:' . $item['id'], 'service.comment')) . "</wfw:comment>";
         // the comment Rss url
         $extensions[] = '<wfw:commentRss>' . encode_link($context['url_to_home'] . $context['url_to_root'] . Comments::get_url('article:' . $item['id'], 'feed')) . "</wfw:commentRss>";
         // the trackback url
         $extensions[] = '<trackback:ping>' . encode_link($context['url_to_home'] . $context['url_to_root'] . 'links/trackback.php?anchor=' . urlencode('article:' . $item['id'])) . "</trackback:ping>";
         // no trackback:about;
         // list all components for this item
         $items[$url] = array($time, $title, $author, $section, $icon, $introduction, $description, $extensions);
     }
     // end of processing
     SQL::free($result);
     return $items;
 }
Esempio n. 24
0
 /**
  * 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;
 }
Esempio n. 25
0
File: day.php Progetto: rair/yacs
 /**
  * get invitation default message
  *
  * This is put in the invitation form.
  *
  * @see articles/invite.php
  *
  * @param string 'PUBLISH' or 'CANCEL'
  * @return string to be put in the web form
  */
 function get_invite_default_message($method = 'PUBLISH')
 {
     global $context;
     // to be displayed into the web form for this invitation
     $text = '';
     if ($value = $this->anchor->get_title()) {
         $text .= sprintf(i18n::c('%s: %s'), i18n::c('Topic'), Skin::build_link($context['url_to_home'] . $context['url_to_root'] . $this->anchor->get_url(), Codes::beautify_title($value))) . BR;
     }
     // dates
     if (isset($this->attributes['date_stamp']) && $this->attributes['date_stamp']) {
         $text .= sprintf(i18n::c('%s: %s'), i18n::c('Date'), Skin::build_date($this->attributes['date_stamp'], 'day')) . BR;
     }
     // build a link to the chairman page, if any
     if (isset($this->attributes['chairman']) && ($user = Users::get($this->attributes['chairman']))) {
         $text .= sprintf(i18n::c('%s: %s'), i18n::c('Chairman'), Users::get_link($user['full_name'], NULL, $user['id'])) . BR;
     }
     // event has been cancelled
     if ($method == 'CANCEL') {
         $text .= '<div><p>' . i18n::c('Event has been cancelled.') . '</p></div>';
     } else {
         // copy content of the introduction field, if any
         if ($value = $this->anchor->get_value('introduction')) {
             $text .= '<div>' . Codes::beautify('<p>' . $value . '</p>') . '</div>';
         }
         // copy the induction message, if any
         if (isset($this->attributes['induction_message'])) {
             $text .= '<div>' . Codes::render($this->attributes['induction_message']) . '</div>';
         }
     }
     // done
     return $text;
 }
Esempio n. 26
0
File: new.php Progetto: rair/yacs
     Sections::post($fields);
     // a private sub-section, for internal work
     if ($_REQUEST['active'] != 'N') {
         $fields = array();
         $fields['active_set'] = 'N';
         $fields['anchor'] = 'section:' . $_REQUEST['id'];
         $fields['articles_layout'] = 'yabb';
         $fields['content_options'] = 'auto_publish with_neighbours members_edit';
         $fields['introduction'] = i18n::c('Reserved to project members');
         $fields['index_map'] = 'N';
         // not mentioned at the home page
         $fields['options'] = 'forward_notifications view_as_tabs';
         // to list editors and watchers explicitly
         $fields['rank'] = 4000;
         $fields['thumbnail_url'] = $context['url_to_home'] . $context['url_to_root'] . 'skins/_reference/thumbnails/meeting.gif';
         $fields['title'] = i18n::c('Private activities');
         Sections::post($fields);
     }
 }
 // increment the post counter of the surfer
 Users::increment_posts(Surfer::get_id());
 // reward the poster
 $context['page_title'] = i18n::s('Congratulation, you have successfully added a new web space');
 // follow-up commands
 $follow_up = i18n::s('What do you want to do now?');
 $menu = array();
 if ($_REQUEST['space_type'] == 'blog') {
     $menu = array_merge($menu, array(Sections::get_permalink($_REQUEST) => i18n::s('View the new blog')));
 } elseif ($_REQUEST['space_type'] == 'project') {
     $menu = array_merge($menu, array(Sections::get_permalink($_REQUEST) => i18n::s('View the new project')));
 } else {
Esempio n. 27
0
File: ldap.php Progetto: rair/yacs
 /**
  * login
  *
  * The script checks provided name and password against remote server.
  *
  * This is done by transmitting the user name and the password
  * to the directory.
  *
  * @param string the nickname of the user
  * @param string the submitted password
  * @return TRUE on successful authentication, FALSE othewise
  */
 function login($name, $password)
 {
     global $context;
     // we need some parameters
     if (!isset($this->attributes['authenticator_parameters']) || !$this->attributes['authenticator_parameters']) {
         Logger::error(i18n::s('Please provide parameters to the authenticator.'));
         return FALSE;
     }
     // tokenize enclosed parameters
     $tokens = preg_split('/(")/', $this->attributes['authenticator_parameters'], -1, PREG_SPLIT_DELIM_CAPTURE);
     $outside = TRUE;
     $parameters = array();
     foreach ($tokens as $token) {
         // sanity check --PREG_SPLIT_NO_EMPTY does not work
         if (!trim($token)) {
             // catch "" arguments (used for example as an empty password)
             if (!$outside) {
                 $parameters[] = "";
             }
             continue;
         }
         // begin or end of a token
         if ($token == '"') {
             $outside = !$outside;
             continue;
         }
         // outside, each word is a token
         if ($outside) {
             $parameters = array_merge($parameters, explode(' ', trim($token)));
         } else {
             $parameters[] = trim($token);
         }
     }
     // ensure a minimum number of parameters
     if (count($parameters) < 1) {
         Logger::error(i18n::s('Provide at least server name to the LDAP authenticator.'));
         return FALSE;
     }
     // prepare network parameters
     $server = $parameters[0];
     if (strstr($server, ':')) {
         list($server, $port) = explode(':', $server, 2);
     } else {
         $port = 389;
     }
     // distinguished name used for bind
     $bind_dn = '';
     if (isset($parameters[1])) {
         $bind_dn = str_replace('%u', $name, $parameters[1]);
     }
     // password used for bind
     $bind_password = '';
     if (isset($parameters[2])) {
         $bind_password = str_replace('%p', $password, $parameters[2]);
     }
     // distinguished name used for search
     $search_dn = '';
     if (isset($parameters[3])) {
         $search_dn = $parameters[3];
     }
     // encode provided parameters to avoid LDAP injections
     $name = preg_replace('/([^a-zA-Z0-9\' ])/e', "chr(92).bin2hex('\$1')", $name);
     $password = preg_replace('/([^a-zA-Z0-9\' ])/e', "chr(92).bin2hex('\$1')", $password);
     // search expression
     $search_filter = '';
     if (isset($parameters[4])) {
         $search_filter = str_replace(array('%u', '%p'), array($name, $password), $parameters[4]);
     }
     // parse options
     $opt_deref = LDAP_DEREF_NEVER;
     $opt_protocol_version = 3;
     $opt_sizelimit = 0;
     $opt_timelimit = 0;
     $opt_ldap_search_func = "ldap_search";
     if (isset($parameters[5])) {
         $tokens = preg_split('/,/', $parameters[5], -1, PREG_SPLIT_NO_EMPTY);
         foreach ($tokens as $token) {
             $argerror = $valerror = 0;
             $argerror_s = $argerror_c = '';
             list($key, $val) = explode('=', $token, 2);
             if (!strcasecmp($key, "DEREF")) {
                 if (!strcasecmp($val, "never")) {
                     $opt_deref = LDAP_DEREF_NEVER;
                 } elseif (!strcasecmp($val, "always")) {
                     $opt_deref = LDAP_DEREF_ALWAYS;
                 } else {
                     $valerror = 1;
                 }
             } elseif (!strcasecmp($key, "PROTOCOL_VERSION")) {
                 if ($val == 2 || $val == 3) {
                     $opt_protocol_version = $val;
                 } else {
                     $valerror = 1;
                 }
             } elseif (!strcasecmp($key, "SCOPE")) {
                 if (!strcasecmp($val, "one")) {
                     $opt_ldap_search_func = "ldap_list";
                 } elseif (!strcasecmp($val, "sub")) {
                     $opt_ldap_search_func = "ldap_search";
                 } else {
                     $valerror = 1;
                 }
             } elseif (!strcasecmp($key, "SIZELIMIT")) {
                 if (ctype_digit($val)) {
                     $opt_sizelimit = $val;
                 } else {
                     $valerror = 1;
                 }
             } elseif (!strcasecmp($key, "TIMELIMIT")) {
                 if (ctype_digit($val)) {
                     $opt_timelimit = $val;
                 } else {
                     $valerror = 1;
                 }
             } else {
                 $argerror_s = sprintf(i18n::s("Unknown LDAP option %s."), $key);
                 $argerror_c = sprintf(i18n::c("Unknown LDAP option %s."), $key);
                 $argerror = 1;
             }
             // a wrong value must trigger an error message
             if ($valerror) {
                 $argerror_s = sprintf(i18n::s("LDAP %s: bad value '%s'."), $key, $val);
                 $argerror_c = sprintf(i18n::c("LDAP %s: bad value '%s'."), $key, $val);
                 $argerror = 1;
             }
             // print any error message raised while parsing the option
             if ($argerror) {
                 Logger::error($argerror_s);
                 if ($context['with_debug'] == 'Y') {
                     Logger::remember('users/authenticators/ldap.php: ' . $argerror_c, '', 'debug');
                 }
                 return FALSE;
             }
         }
     }
     // ensure we can move forward
     if (!is_callable('ldap_connect')) {
         Logger::error(i18n::s('Please activate the LDAP library.'));
         if ($context['with_debug'] == 'Y') {
             Logger::remember('users/authenticators/ldap.php: ' . i18n::c('Please activate the LDAP library.'), '', 'debug');
         }
         return FALSE;
     }
     // open network socket
     if (!($handle = @ldap_connect($server, $port))) {
         Logger::error(sprintf(i18n::s('Impossible to connect to %.'), $server));
         if ($context['with_debug'] == 'Y') {
             Logger::remember('users/authenticators/ldap.php: ' . sprintf(i18n::c('Impossible to connect to %.'), $server . ':' . $port), '', 'debug');
         }
         return FALSE;
     }
     // set desired options
     @ldap_set_option($handle, LDAP_OPT_PROTOCOL_VERSION, $opt_protocol_version);
     @ldap_set_option($handle, LDAP_OPT_DEREF, $opt_deref);
     @ldap_set_option($handle, LDAP_OPT_SIZELIMIT, $opt_sizelimit);
     @ldap_set_option($handle, LDAP_OPT_TIMELIMIT, $opt_timelimit);
     // bind to directory, namely or anonymously
     if ($bind_dn && @ldap_bind($handle, $bind_dn, $bind_password)) {
     } elseif (!$bind_dn && @ldap_bind($handle)) {
     } else {
         Logger::error(sprintf(i18n::s('Impossible to bind to LDAP server %s.'), $server) . BR . ldap_errno($handle) . ': ' . ldap_error($handle));
         if ($context['with_debug'] == 'Y') {
             Logger::remember('users/authenticators/ldap.php: ' . sprintf(i18n::c('Impossible to bind to LDAP server %s.'), $server . ' ' . $bind_dn . ' ' . $bind_password), ldap_errno($handle) . ': ' . ldap_error($handle), 'debug');
         }
         ldap_close($handle);
         return FALSE;
     }
     // stop on successful bind
     if (!trim($search_filter)) {
         ldap_close($handle);
         return TRUE;
     }
     // search the directory
     if (!($result = @call_user_func($opt_ldap_search_func, $handle, $search_dn, $search_filter, array('cn')))) {
         Logger::error(sprintf(i18n::s('Impossible to search in LDAP server %s.'), $server) . BR . ldap_errno($handle) . ': ' . ldap_error($handle));
         if ($context['with_debug'] == 'Y') {
             Logger::remember('users/authenticators/ldap.php: ' . sprintf(i18n::c('Impossible to search in LDAP server %s.'), $server), ldap_errno($handle) . ': ' . ldap_error($handle), 'debug');
         }
         ldap_close($handle);
         return FALSE;
     }
     // successful match
     if (@ldap_first_entry($handle, $result) !== FALSE) {
         ldap_free_result($result);
         ldap_close($handle);
         return TRUE;
     }
     // authentication has failed
     if ($context['with_debug'] == 'Y') {
         Logger::remember('users/authenticators/ldap.php: ' . sprintf(i18n::c('No match for %s.'), $search_filter), '', 'debug');
     }
     ldap_free_result($result);
     ldap_close($handle);
     return FALSE;
 }
Esempio n. 28
0
File: index.php Progetto: rair/yacs
    }
    if (($section = Sections::get('navigation_boxes')) && isset($section['id'])) {
        $context['page_tools'][] = Skin::build_link(Sections::get_permalink($section), i18n::s('Navigation boxes'), 'basic');
    }
}
// save some database requests
$cache_id = 'index.php#extra_news';
if (!($text = Cache::get($cache_id))) {
    // show featured articles -- set in configure.php
    if (isset($context['root_featured_layout']) && $context['root_featured_layout'] != 'none') {
        // set in configure.php
        if (!isset($context['root_featured_count']) || $context['root_featured_count'] < 1) {
            $context['root_featured_count'] = 7;
        }
        // the category used to assign featured pages
        $anchor = Categories::get(i18n::c('featured'));
        if ($anchor['id'] && ($items =& Members::list_articles_by_date_for_anchor('category:' . $anchor['id'], 0, $context['root_featured_count'] + 1, 'news'))) {
            // link to the category page from the box title
            $title =& Skin::build_box_title($anchor['title'], Categories::get_permalink($anchor), i18n::s('Featured pages'));
            // limit to seven links only
            if (@count($items) > $context['root_featured_count']) {
                @array_splice($items, $context['root_featured_count']);
                // link to the category page
                $url = Categories::get_permalink($anchor);
                $items[$url] = i18n::s('Featured pages') . MORE_IMG;
            }
            // render html
            if (is_array($items)) {
                $items =& Skin::build_list($items, 'news');
            }
            // we do have something to display
Esempio n. 29
0
 /**
  * get an overlaid label
  *
  * Accepted action codes:
  * - 'edit' the modification of an existing object
  * - 'delete' the deleting form
  * - 'new' the creation of a new object
  * - 'view' a displayed object
  *
  * @see overlays/overlay.php
  *
  * @param string the target label
  * @param string the on-going action
  * @param boolean TRUE to localize as per surfer settings, FALSE to localize as per community settings
  * @return the label to use
  */
 function get_label($name, $action = 'view', $surfer = TRUE)
 {
     global $context;
     switch ($name . ':' . $action) {
         case 'edit_command:articles':
         case 'edit_command:sections':
             if ($surfer) {
                 return i18n::s('Edit this meeting');
             }
             return i18n::c('Edit this meeting');
         case 'new_command:articles':
         case 'new_command:sections':
             if ($surfer) {
                 return i18n::s('Add a meeting');
             }
             return i18n::c('Add a meeting');
         case 'permalink_command:articles':
         case 'permalink_command:sections':
             if ($surfer) {
                 return i18n::s('View meeting details');
             }
             return i18n::c('View meeting details');
         case 'page_title:edit':
             if ($surfer) {
                 return i18n::s('Edit a meeting');
             }
             return i18n::c('Edit a meeting');
         case 'page_title:delete':
             if ($surfer) {
                 return i18n::s('Delete a meeting');
             }
             return i18n::c('Delete a meeting');
         case 'page_title:new':
             if ($surfer) {
                 return i18n::s('Add a meeting');
             }
             return i18n::c('Add a meeting');
     }
     // no match
     return NULL;
 }
Esempio n. 30
-1
    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')));
        $menu = array_merge($menu, array('overlays/bbb_meetings/configure.php' => i18n::s('Configure again')));
        $follow_up .= Skin::build_list($menu, 'menu_bar');
        $context['text'] .= Skin::build_block($follow_up, 'bottom');
    }
}
// render the skin
render_skin();