Esempio n. 1
0
 /**
  * create a new authenticator instance
  *
  * This function creates an instance of the Authenticator class based on the given type.
  * For the type '[code]foo[/code]', the script file '[code]users/authenticators/foo.php[/code]' is loaded.
  *
  * Example:
  * [php]
  * // create a new authenticator
  * $authenticator = Authenticator::bind('ldap');
  * [/php]
  *
  * The provided string may include parameters after the type.
  * These parameters, if any, are saved along authenticator attributes.
  *
  * @param string authenticator type, followed by parameters if any
  * @return a brand new instance
  *
  */
 public static function bind($type = '')
 {
     global $context;
     // stop hackers, if any
     $type = preg_replace(FORBIDDEN_IN_PATHS, '', strip_tags($type));
     // remove side spaces
     $type = trim($type);
     // sanity check
     if (!$type) {
         Logger::error(i18n::s('Invalid authenticator type.'));
         return NULL;
     }
     // localize authenticators strings
     i18n::bind('users');
     // extract parameters, if any
     $parameters = '';
     if (strlen($type) > 1 && ($separator = strpos($type, ' ', 1)) !== FALSE) {
         $parameters = substr($type, $separator + 1);
         $type = substr($type, 0, $separator);
     }
     // load the authenticator class file
     $file = $context['path_to_root'] . 'users/authenticators/' . $type . '.php';
     if (is_readable($file)) {
         include_once $file;
     }
     // create the instance
     $class_auth = $type . AUTH_CLASS_SUFFIX;
     if (class_exists(class_auth)) {
         $authenticator = new $class_auth();
         $authenticator->attributes = array();
         $authenticator->attributes['authenticator_type'] = $class_auth;
         $authenticator->attributes['authenticator_parameters'] = $parameters;
         return $authenticator;
     }
     // houston, we've got a problem
     Logger::error(sprintf(i18n::s('Unknown authenticator type %s'), $type));
     return NULL;
 }
Esempio n. 2
0
File: user.php Progetto: rair/yacs
 /**
  * get the path bar for this anchor
  *
  * For users, the path bar is made of one stem for all users, then one stem for the user himself.
  *
  * @return an array of $url => $label
  *
  * @see shared/anchor.php
  */
 function get_path_bar()
 {
     // load localized strings
     i18n::bind('users');
     // the index of users
     $output = array('users/' => i18n::s('People'));
     // then this user
     if (isset($this->item['id'])) {
         $url = $this->get_url();
         if (isset($this->item['full_name']) && $this->item['full_name']) {
             $label = $this->item['full_name'];
         } else {
             $label = $this->item['nick_name'];
         }
         $output = array_merge($output, array($url => $label));
     }
     // return an array of ($url => $label)
     return $output;
 }
Esempio n. 3
0
File: links.php Progetto: rair/yacs
                    // image link
                // image link
                case 'image':
                    include_once $context['path_to_root'] . 'images/images.php';
                    if ($item = Images::get($matches[2])) {
                        return array(Images::get_url($matches[2]), $item['title'] ? $item['title'] : str_replace('_', ' ', ucfirst($item['image_name'])));
                    }
                    return array('', $text, '');
                    // category link
                // category link
                case 'category':
                    if ($item = Categories::get($matches[2])) {
                        return array(Categories::get_permalink($item), $item['title'], $item['introduction']);
                    }
                    return array('', $text, '');
                    // user link
                // user link
                case 'user':
                    if ($item = Users::get($matches[2])) {
                        return array(Users::get_permalink($item), $item['full_name'] ? $item['full_name'] : $item['nick_name']);
                    }
                    return array('', $text, '');
            }
        }
        return array('', $text, '');
    }
}
// load localized strings
if (is_callable(array('i18n', 'bind'))) {
    i18n::bind('links');
}
Esempio n. 4
0
File: search.php Progetto: rair/yacs
// look for words
$search = '';
if (isset($_REQUEST['search'])) {
    $search = $_REQUEST['search'];
} elseif (isset($context['arguments'][0])) {
    $search = $context['arguments'][0];
}
$search = strip_tags($search);
// search type
$type = '';
if (isset($_REQUEST['type'])) {
    $type = $_REQUEST['type'];
}
$type = strip_tags($type);
// load localized strings
i18n::bind('services');
// load a skin engine
load_skin('services');
// loads feeding parameters
Safe::load('parameters/feeds.include.php');
// set default values
if (!$context['channel_title']) {
    $context['channel_title'] = $context['site_name'];
}
if (!$context['channel_description']) {
    $context['channel_description'] = $context['site_description'];
}
// channel attributes
$values = array();
$values['channel'] = array();
// set channel information
Esempio n. 5
0
 * [title]What happens on first installation?[/title]
 *
 * The YACS archive that contains reference scripts is used jointly on first installation and on upgrades.
 * However, scripts to be ran once are useful only for upgrades.
 * Therefore, on first installation (i.e., when the switch file is absent), the extension '.done' is appended to
 * every script in the directory scripts/run_once without actual execution of them.
 *
 * @author Bernard Paques
 * @author GnapZ
 * @reference
 * @license http://www.gnu.org/copyleft/lesser.txt GNU Lesser General Public License
 */
// include global declarations
include_once '../shared/global.php';
// load localized strings
i18n::bind('scripts');
// load the skin
load_skin('scripts');
// the path to this page
$context['path_bar'] = array('control/' => i18n::s('Control Panel'));
// the title of the page
$context['page_title'] = i18n::s('Run one-time scripts');
// the list of script to take into account
global $scripts;
$scripts = array();
// if the user table exists, check that the user is an admin
$query = "SELECT count(*) FROM " . SQL::table_name('users');
if (SQL::query($query) !== FALSE && !Surfer::is_associate()) {
    Safe::header('Status: 401 Unauthorized', TRUE, 401);
    Logger::error(i18n::s('You are not allowed to perform this operation.'));
    // open the directory
Esempio n. 6
0
     */
    function transcode($transcoded)
    {
        global $context;
        // no item bound
        if (!isset($this->item['id'])) {
            return;
        }
        // prepare preg_replace()
        $from = array();
        $to = array();
        foreach ($transcoded as $pair) {
            $from[] = $pair[0];
            $to[] = $pair[1];
        }
        // transcode various fields
        $this->item['introduction'] = preg_replace($from, $to, $this->item['introduction']);
        $this->item['description'] = preg_replace($from, $to, $this->item['description']);
        // update the database
        $query = "UPDATE " . SQL::table_name('categories') . " SET " . " introduction = '" . SQL::escape($this->item['introduction']) . "'," . " description = '" . SQL::escape($this->item['description']) . "'" . " WHERE id = " . SQL::escape($this->item['id']);
        SQL::query($query);
        // always clear the cache, even on no update
        Categories::clear($this->item);
    }
}
// stop hackers
defined('YACS') or exit('Script must be included');
// load localized strings
if (is_callable(array('i18n', 'bind'))) {
    i18n::bind('categories');
}
Esempio n. 7
0
File: query.php Progetto: rair/yacs
 * On subsequent access to the query page, using page handle, these data is restored to surfer environment.
 * With this setup, anonymous surfers may interact with a given web page without registering first.
 *
 * YACS attempts to stop robots by generating a random string and by asking user to type it.
 *
 * @author Bernard Paques
 * @tester fw_crocodile
 * @reference
 * @license http://www.gnu.org/copyleft/lesser.txt GNU Lesser General Public License
 */
// common definitions and initial processing
include_once 'shared/global.php';
// do not always show the edition form
$with_form = FALSE;
// load localized strings
i18n::bind('root');
// load the skin
load_skin('query');
// the title of the page
$context['page_title'] = i18n::s('Help');
// get a section for queries
if (!($anchor = Anchors::get('section:queries'))) {
    $fields = array();
    $fields['nick_name'] = 'queries';
    $fields['title'] =& i18n::c('Queries');
    $fields['introduction'] =& i18n::c('Submitted to the webmaster by any surfers');
    $fields['description'] =& i18n::c('<p>This section has been created automatically on query submission. It\'s aiming to capture feedback directly from surfers. It is highly recommended to delete pages below after their processing. Of course you can edit submitted queries to assign them to other sections if necessary.</p>');
    $fields['locked'] = 'Y';
    // no direct contributions
    $fields['active_set'] = 'N';
    // for associates only
Esempio n. 8
0
 * the active configuration before the last change, if necessary.
 *
 * If the file [code]parameters/demo.flag[/code] exists, the script assumes that this instance
 * of YACS runs in demonstration mode.
 * In this mode the edit form is displayed, but parameters are not saved in the configuration file.
 *
 * @author Bernard Paques
 * @author GnapZ
 * @reference
 * @tester Guillaume Perez
 * @license http://www.gnu.org/copyleft/lesser.txt GNU Lesser General Public License
 */
// common definitions and initial processing
include_once '../shared/global.php';
// load localized strings
i18n::bind('agents');
// 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
Esempio n. 9
0
 * The file [code]parameters/feeds.flash.include.php.bak[/code] can be used to restore
 * the active configuration before the last change, if necessary.
 *
 * If the file [code]parameters/demo.flag[/code] exists, the script assumes that this instance
 * of YACS runs in demonstration mode.
 * In this mode the edit form is displayed, but parameters are not saved in the configuration file.
 *
 * @author Bernard Paques
 * @author GnapZ
 * @reference
 * @license http://www.gnu.org/copyleft/lesser.txt GNU Lesser General Public License
 */
// common definitions and initial processing
include_once '../../shared/global.php';
// load localized strings
i18n::bind('feeds');
// load the skin
load_skin('feeds');
// 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('Flash'));
// 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('feeds/flash/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
Esempio n. 10
0
     *
     * @return the resulting ($count, $min_date, $max_date) array
     *
     * @see comments/index.php
     */
    public static function stat_threads()
    {
        global $context;
        // a dynamic where clause
        $where = '';
        // if not associate, restrict to comments at public published not expired pages
        if (!Surfer::is_associate()) {
            $where = "(articles.active='Y')" . " AND NOT ((articles.publish_date is NULL) OR (articles.publish_date <= '0000-00-00'))" . " AND ((articles.expiry_date is NULL)" . "\tOR (articles.expiry_date <= '" . NULL_DATE . "') OR (articles.expiry_date > '" . gmstrftime('%Y-%m-%d %H:%M:%S') . "'))";
        }
        // avoid blank records on join
        if ($where) {
            $where .= ' AND ';
        }
        $where .= '(articles.id > 0)';
        // the list of comments
        $query = "SELECT DISTINCT articles.id as id FROM " . SQL::table_name('comments') . " AS comments" . ", " . SQL::table_name('articles') . " AS articles" . " WHERE (comments.anchor_type LIKE 'article') AND (comments.anchor_id = articles.id)" . "\tAND " . $where;
        // select among available items
        $result = SQL::query($query);
        $output = SQL::count($result);
        return $output;
    }
}
// load localized strings
if (is_callable(array('i18n', 'bind'))) {
    i18n::bind('comments');
}
Esempio n. 11
0
File: files.php Progetto: rair/yacs
                        }
                        // create the record in the database
                        if (!($fields['id'] = Files::post($fields))) {
                            return FALSE;
                        }
                        // record surfer activity
                        Activities::post('file:' . $fields['id'], 'upload');
                    }
                }
                // so far so good
                if (count($context['uploaded_files']) == 1) {
                    return $context['uploaded_files'][0];
                } else {
                    return $context['uploaded_files'];
                }
            }
        }
        // some error has occured
        return FALSE;
    }
}
// load localized strings
if (is_callable(array('i18n', 'bind'))) {
    i18n::bind('files');
}
// the maximum size for uploads
global $context;
$context['file_maximum_size'] = str_replace('M', ' M', Safe::get_cfg_var('upload_max_filesize'));
if (!$context['file_maximum_size']) {
    $context['file_maximum_size'] = '2 M';
}
Esempio n. 12
0
 /**
  * create a new overlay from scratch
  *
  * This function creates an instance of the Overlay class based on the given type.
  * For the type '[code]foo[/code]', the script file '[code]overlays/foo.php[/code]' is loaded.
  *
  * Example:
  * [php]
  * // create a new overlay
  * $overlay = Overlay::bind('recipe');
  * [/php]
  *
  * The provided string may include parameters after the type.
  * These parameters, if any, are saved along overlay attributes.
  *
  * Example:
  * [php]
  * // this overlay will preserve past events
  * $overlay = Overlay::bind('day without_past_dates');
  * [/php]
  *
  * This function calls the member function initialize() to allow for additional
  * generic initialization steps, if required. Example: loading of an external configuration
  * file.
  *
  * @see articles/edit.php
  * @see overlays/day.php
  * @see sections/edit.php
  *
  * @param string overlay type
  * @return a brand new instance
  */
 public static final function bind($type)
 {
     global $context;
     // sanity check
     if (!$type || !trim($type)) {
         return NULL;
     }
     // stop hackers, if any
     $type = preg_replace(FORBIDDEN_IN_PATHS, '', strip_tags($type));
     // remove side spaces
     $type = trim($type);
     // localize overlays strings --not related to Overlay::bind() at all...
     i18n::bind('overlays');
     // extract parameters, if any
     $parameters = '';
     if (strlen($type) > 1 && ($separator = strpos($type, ' ', 1)) !== FALSE) {
         $parameters = substr($type, $separator + 1);
         $type = substr($type, 0, $separator);
     }
     // reject hooks
     if (preg_match('/hook$/i', $type)) {
         return NULL;
     }
     // load the overlay class file
     $file = $context['path_to_root'] . 'overlays/' . $type . '.php';
     if (is_readable($file)) {
         include_once $file;
     }
     // create the instance
     if (class_exists($type)) {
         $overlay = new $type();
         $overlay->attributes = array();
         $overlay->attributes['overlay_type'] = $type;
         $overlay->attributes['overlay_parameters'] = $parameters;
         // allow for internal initialization of the overlay
         $overlay->initialize();
         return $overlay;
     }
     // houston, we've got a problem -- Logger::error() is buggy here
     if ($context['with_debug'] == 'Y') {
         Logger::remember('overlays/overlay.php: overlay::bind() unknown overlay type', $type, 'debug');
     }
     return NULL;
 }
Esempio n. 13
0
            } elseif (preg_match('/^\\s*left=(.*)$/is', $cell, $matches)) {
                $text .= $cell_opened . ' style="text-align: left;">' . $matches[1] . $cell_suffix;
            } else {
                $text .= $cell_prefix . $cell . $cell_suffix;
            }
        }
        // return a complete row
        $text = $row_prefix . $text . $row_suffix;
        return $text;
    }
    /**
     * close a table
     *
     * @return the HTML to display
     */
    public static function &table_suffix()
    {
        // close tbody
        global $current_table_has_body;
        if ($current_table_has_body) {
            $text = '</tbody></table>' . "\n";
        } else {
            $text = '</table>' . "\n";
        }
        return $text;
    }
}
// load localized strings
if (is_callable(array('i18n', 'bind'))) {
    i18n::bind('skins');
}
Esempio n. 14
0
File: dates.php Progetto: rair/yacs
     *
     * @param the selected anchor (e.g., 'article:12')
     * @return the resulting ($count, $min_date, $max_date) array
     */
    public static function stat_past_for_anchor($anchor)
    {
        global $context;
        // restrict the query to addressable content
        $where = Articles::get_sql_where();
        // put only published pages in boxes
        if (isset($variant) && $variant == 'boxes') {
            $where .= " AND NOT ((articles.publish_date is NULL) OR (articles.publish_date <= '0000-00-00'))" . " AND (articles.publish_date < '" . $context['now'] . "')";
            // provide published pages to anonymous surfers
        } elseif (!Surfer::is_logged()) {
            $where .= " AND NOT ((articles.publish_date is NULL) OR (articles.publish_date <= '0000-00-00'))" . " AND (articles.publish_date < '" . $context['now'] . "')";
            // logged surfers that are non-associates are restricted to their own articles, plus published articles
        } elseif (!Surfer::is_empowered()) {
            $where .= " AND ((articles.create_id=" . Surfer::get_id() . ") OR (NOT ((articles.publish_date is NULL) OR (articles.publish_date <= '0000-00-00'))" . " AND (articles.publish_date < '" . $context['now'] . "')))";
        }
        // now
        $match = gmstrftime('%Y-%m-%d %H:%M:%S');
        // select among available items
        $query = "SELECT COUNT(*) as count, MIN(articles.edit_date) as oldest_date, MAX(articles.edit_date) as newest_date " . " FROM " . SQL::table_name('dates') . " as dates " . ", " . SQL::table_name('articles') . " AS articles" . " WHERE ((dates.anchor_type LIKE 'article') AND (dates.anchor_id = articles.id))" . "\tAND (dates.date_stamp < '" . SQL::escape($match) . "') AND\t(articles.anchor = '" . SQL::escape($anchor) . "') AND " . $where;
        $output = SQL::query_first($query);
        return $output;
    }
}
// load localized strings
if (is_callable(array('i18n', 'bind'))) {
    i18n::bind('dates');
}
Esempio n. 15
0
File: index.php Progetto: rair/yacs
 * To add a new smiley on this system, you will have:
 * - to prepare a new icon file
 * - to name it
 * - to update smileys.php to bind the name to the file
 * - to update the page below to show it working
 *
 * @author Bernard Paques
 * @author GnapZ
 * @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 'smileys.php';
// load localized strings
i18n::bind('smileys');
// load the skin
load_skin('smileys');
// the path to this page
$context['path_bar'] = array('help/' => i18n::s('Help index'));
// the title of the page
$context['page_title'] = i18n::s('Smileys');
// the date of last modification
if (Surfer::is_associate()) {
    $context['page_details'] .= '<p class="details">' . sprintf(i18n::s('Edited %s'), Skin::build_date(getlastmod())) . '</p>';
}
// the splash message
$context['text'] .= '<p>' . i18n::s('Smileys are small graphical images that can be used to convey an emotion or feeling. If you have used email or Internet chat, you are likely familiar with the smilie concept.') . '</p>' . '<p>' . i18n::s('Let face it, sometimes words alone do not suffice. Adding a winking smilie, for instance, may help you clarify that you are joking.') . '</p>' . '<p>' . i18n::s('Use your smilies sparingly, though -- if overused, smilies can be downright annoying.') . '</p>' . '<p>' . i18n::s('Here is the list of codes that are automatically converted into images by this server.') . '</p>';
// use a table for the layout
$context['text'] .= Skin::table_prefix('grid');
$cells = array();
Esempio n. 16
0
     */
    function transcode($transcoded)
    {
        global $context;
        // no item bound
        if (!isset($this->item['id'])) {
            return;
        }
        // prepare preg_replace()
        $from = array();
        $to = array();
        foreach ($transcoded as $pair) {
            $from[] = $pair[0];
            $to[] = $pair[1];
        }
        // transcode various fields
        $this->item['introduction'] = preg_replace($from, $to, $this->item['introduction']);
        $this->item['description'] = preg_replace($from, $to, $this->item['description']);
        // update the database
        $query = "UPDATE " . SQL::table_name('articles') . " SET " . " introduction = '" . SQL::escape($this->item['introduction']) . "'," . " description = '" . SQL::escape($this->item['description']) . "'" . " WHERE id = " . SQL::escape($this->item['id']);
        SQL::query($query);
        // always clear the cache
        Articles::clear($this->item);
    }
}
// stop hackers
defined('YACS') or exit('Script must be included');
// load localized strings
if (is_callable(array('i18n', 'bind'))) {
    i18n::bind('articles');
}
Esempio n. 17
0
$action = '';
if (isset($_REQUEST['action'])) {
    $action = $_REQUEST['action'];
}
if (!$action && isset($context['arguments'][0])) {
    $action = $context['arguments'][0];
}
$action = strip_tags($action);
// associates can do what they want
if (Surfer::is_associate()) {
    $permitted = TRUE;
} else {
    $permitted = FALSE;
}
// load localized strings
i18n::bind('help');
// load the skin
load_skin('help');
// the path to this page
$context['path_bar'] = array('control/' => i18n::s('Control Panel'));
// default page title
$context['page_title'] = i18n::s('Content Assistant');
// permission denied
if (!$permitted) {
    // 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('help/populate.php?action=' . $action));
    }
    // permission denied to authenticated user
    Safe::header('Status: 401 Unauthorized', TRUE, 401);
    Logger::error(i18n::s('You are not allowed to perform this operation.'));
Esempio n. 18
0
File: edit.php Progetto: rair/yacs
/**
 * edit mutable overlays
 *
 * This script helps to change selected pages through named overlays.
 *
 * It gets an overlay id, plus some pieces of text, and updates all related pages.
 *
 * @author Bernard Paques
 * @reference
 * @license http://www.gnu.org/copyleft/lesser.txt GNU Lesser General Public License
 */
// common definitions and initial processing
include_once '../../shared/global.php';
// load localized strings
i18n::bind('overlays');
// load the skin
load_skin('overlays');
// the title of the page
$context['page_title'] = i18n::s('Change named overlays');
// this is reserved to associates
if (!Surfer::is_associate()) {
    Safe::header('Status: 401 Unauthorized', TRUE, 401);
    Logger::error(i18n::s('You are not allowed to perform this operation.'));
    // update targeted overlays
} elseif (isset($_REQUEST['id']) && $_REQUEST['id']) {
    // change all named overlays
    $count = 0;
    if ($ids = Articles::get_ids_for_overlay($_REQUEST['id'])) {
        $context['text'] .= sprintf(i18n::s('Changing all overlays with name %s'), $_REQUEST['id']) . BR;
        // one page at a time
Esempio n. 19
0
File: basic.php Progetto: rair/yacs
 * - &#91;style=cursive]...[/style] - mimic hand writing
 * - &#91;style=comic]...[/style] - make it funny
 * - &#91;style=fantasy]...[/style] - guess what will appear
 * - &#91;style=my_style]...[/style] - translated to &lt;span class="my_style"&gt;...&lt;/span&gt;
 *
 * @see codes/index.php
 *
 * @author Bernard Paques
 * @author GnapZ
 * @reference
 * @license http://www.gnu.org/copyleft/lesser.txt GNU Lesser General Public License
 */
// common definitions and initial processing
include_once '../shared/global.php';
// load localized strings
i18n::bind('codes');
// load the skin
load_skin('codes');
// the path to this page
$context['path_bar'] = array('help/' => i18n::s('Help index'), 'codes/' => i18n::s('Formatting Codes'));
// the title of the page
$context['page_title'] = i18n::s('In-line formatting codes');
// the date of last modification
if (Surfer::is_associate()) {
    $context['page_details'] .= '<p class="details">' . sprintf(i18n::s('Edited %s'), Skin::build_date(getlastmod())) . '</p>';
}
// page header
$context['text'] .= '<p>' . i18n::s('On this page we are introducing some formatting codes and live examples of utilization.') . '</p>';
// add a toc
$context['text'] .= "\n" . '[toc]' . "\n";
// **...**
Esempio n. 20
0
        $fields['edit_name'] = "VARCHAR(128) DEFAULT '' NOT NULL";
        $indexes = array();
        $indexes['PRIMARY KEY'] = "(id)";
        $indexes['INDEX anchor'] = "(anchor)";
        $indexes['INDEX edit_date'] = "(edit_date)";
        return SQL::setup_table('versions', $fields, $indexes);
    }
    /**
     * get some statistics for one anchor
     *
     * @param the selected anchor (e.g., 'section:12')
     * @return the resulting ($count, $min_date, $max_date) array
     */
    public static function stat_for_anchor($anchor)
    {
        global $context;
        // sanity check
        if (!$anchor) {
            return NULL;
        }
        $anchor = SQL::escape($anchor);
        // select among available items
        $query = "SELECT COUNT(*) as count, MIN(edit_date) as oldest_date, MAX(edit_date) as newest_date" . " FROM " . SQL::table_name('versions') . " AS versions" . " WHERE (versions.anchor LIKE '" . SQL::escape($anchor) . "')";
        $output = SQL::query_first($query);
        return $output;
    }
}
// load localized strings
if (is_callable(array('i18n', 'bind'))) {
    i18n::bind('versions');
}
Esempio n. 21
0
File: tables.php Progetto: rair/yacs
     * get some statistics
     *
     * @return the resulting ($count, $min_date, $max_date) array
     */
    public static function stat()
    {
        global $context;
        // select among available items
        $query = "SELECT COUNT(*) as count, MIN(edit_date) as oldest_date, MAX(edit_date) as newest_date" . " FROM " . SQL::table_name('tables');
        $output = SQL::query_first($query);
        return $output;
    }
    /**
     * get some statistics for one anchor
     *
     * @param the selected anchor (e.g., 'article:12')
     * @return the resulting ($count, $min_date, $max_date) array
     */
    public static function stat_for_anchor($anchor)
    {
        global $context;
        // select among available items
        $query = "SELECT COUNT(*) as count, MIN(edit_date) as oldest_date, MAX(edit_date) as newest_date " . " FROM " . SQL::table_name('tables') . " WHERE anchor LIKE '" . SQL::escape($anchor) . "'";
        $output = SQL::query_first($query);
        return $output;
    }
}
// load localized strings
if (is_callable(array('i18n', 'bind'))) {
    i18n::bind('tables');
}
Esempio n. 22
0
File: image.php Progetto: rair/yacs
                }
                // always limit the size of icon images
            } elseif (isset($_REQUEST['action']) && $_REQUEST['action'] == 'set_as_icon') {
                if (Image::adjust($file_path . $file_name, TRUE, 'avatar')) {
                    $_REQUEST['image_size'] = Safe::filesize($file_path . $file_name);
                }
                // resize the image where applicable
            } elseif (isset($_REQUEST['automatic_process'])) {
                if (Image::adjust($file_path . $file_name, TRUE, 'standard')) {
                    $_REQUEST['image_size'] = Safe::filesize($file_path . $file_name);
                }
            }
            return TRUE;
        }
    }
    /**
     * Check if imagick class is available
     * @global type $context
     * @return boolean
     */
    private static function use_magic()
    {
        global $context;
        $use = class_exists('imagick') && isset($context['image_use_imagemagick']) && $context['image_use_imagemagick'] == 'Y';
        return $use;
    }
}
// load localized strings
if (is_callable(array('i18n', 'bind'))) {
    i18n::bind('images');
}
Esempio n. 23
0
<?php

/**
 * demonstrate YACS capability to build dynamic pages from XSLT
 *
 * A minimum script based on the YACS framework.
 *
 * @author Bernard Paques
 * @reference
 * @license http://www.gnu.org/copyleft/lesser.txt GNU Lesser General Public License
 */
// common definitions and initial processing
include_once '../shared/global.php';
// load localized strings -- see i18n/i18n.php for more information on internationalization and localization in YACS
i18n::bind('tools');
// load the skin
load_skin('tools');
if (!defined('DUMMY_TEXT')) {
    define('DUMMY_TEXT', 'Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.' . ' Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.' . ' Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur.' . ' Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.');
}
// the path to this page
$context['path_bar'] = array('tools/' => i18n::s('Tools'));
// populate page attributes -- attributes used by YACS are described in skins/test.php
$context['page_title'] = i18n::s('Hello world');
// $context['navigation'] - navigation boxes
$context['navigation'] .= Skin::build_box(i18n::s('navigation') . ' 1', DUMMY_TEXT, 'navigation');
$context['navigation'] .= Skin::build_box(i18n::s('navigation') . ' 2', DUMMY_TEXT, 'navigation');
// $context['extra'] - extra boxes
$context['extra'] .= Skin::build_box(i18n::s('extra') . ' 1', DUMMY_TEXT, 'extra');
$context['extra'] .= Skin::build_box(i18n::s('extra') . ' 2', DUMMY_TEXT, 'extra');
// $context['page_author'] - the author
Esempio n. 24
0
     * @return the resulting ($count, $min_date, $max_date) array
     *
     * @see locations/index.php
     */
    public static function stat()
    {
        global $context;
        // select among available items
        $query = "SELECT COUNT(*) as count, MIN(edit_date) as oldest_date, MAX(edit_date) as newest_date" . " FROM " . SQL::table_name('locations') . " AS locations";
        $output = SQL::query_first($query);
        return $output;
    }
    /**
     * get some statistics for one anchor
     *
     * @param the selected anchor (e.g., 'article:12')
     * @return the resulting ($count, $min_date, $max_date) array
     */
    public static function stat_for_anchor($anchor)
    {
        global $context;
        // select among available items
        $query = "SELECT COUNT(*) as count, MIN(edit_date) as oldest_date, MAX(edit_date) as newest_date " . " FROM " . SQL::table_name('locations') . " AS locations " . " WHERE locations.anchor LIKE '" . SQL::escape($anchor) . "'";
        $output = SQL::query_first($query);
        return $output;
    }
}
// load localized strings
if (is_callable(array('i18n', 'bind'))) {
    i18n::bind('locations');
}
Esempio n. 25
0
File: new.php Progetto: rair/yacs
 */
// common definitions and initial processing
include_once '../shared/global.php';
include_once '../shared/values.php';
// letters.digest.stamp
// 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 localized strings
i18n::bind('letters');
// 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
Esempio n. 26
0
        }
        // handle of item owner
        if (isset($item['owner_id']) && ($user = Users::get($item['owner_id']))) {
            $text .= "\t" . '<owner_nick_name>' . $user['nick_name'] . '</owner_nick_name>' . "\n";
        }
        // handle of item creator
        if (isset($item['create_id']) && ($user = Users::get($item['create_id']))) {
            $text .= "\t" . '<create_nick_name>' . $user['nick_name'] . '</create_nick_name>' . "\n";
        }
        // handle of last editor
        if (isset($item['edit_id']) && ($user = Users::get($item['edit_id']))) {
            $text .= "\t" . '<edit_nick_name>' . $user['nick_name'] . '</edit_nick_name>' . "\n";
        }
        // the overlay, if any
        if (is_object($overlay)) {
            $text .= $overlay->export();
        }
        // section footer
        $text .= '</section>' . "\n";
        // list articles in this section
        $text .= Articles::list_for_anchor('section:' . $item['id'], 0, 500, 'xml');
        // list sub-sections
        $text .= Sections::list_for_anchor('section:' . $item['id'], 'xml');
        // job done
        return $text;
    }
}
// load localized strings
if (is_callable(array('i18n', 'bind'))) {
    i18n::bind('sections');
}
Esempio n. 27
0
File: switch.php Progetto: rair/yacs
 * and used to adapt messages provided to surfers in [script]control/closed.php[/script].
 *
 * @see control/closed.php
 *
 * When switching on, the script reset localized strings, in case they would have changed
 * while the server was off.
 *
 * @author Bernard Paques
 * @author GnapZ
 * @reference
 * @license http://www.gnu.org/copyleft/lesser.txt GNU Lesser General Public License
 */
// include the global declarations
include_once '../shared/global.php';
// load localized strings
i18n::bind('control');
// load the skin
load_skin('control');
// the path to this page
$context['path_bar'] = array('control/' => i18n::s('Control Panel'));
// the title of the page
$context['page_title'] = i18n::s('Main Switch');
// only associates can used the switch
if (!Surfer::is_associate()) {
    // prevent access to this script
    Safe::header('Status: 401 Unauthorized', TRUE, 401);
    Logger::error(i18n::s('You are not allowed to perform this operation.'));
    // back to the control panel
    $menu = array('control/' => i18n::s('Control Panel'));
    $context['text'] .= Skin::build_list($menu, 'menu_bar');
    // switch on
Esempio n. 28
0
        // update the record of authenticated user
        $query = "UPDATE " . SQL::table_name('servers') . " SET stamp_date='" . gmstrftime('%Y-%m-%d %H:%M:%S') . "'" . " WHERE id = " . SQL::escape($id);
        // do not report on error
        SQL::query($query, TRUE);
    }
    /**
     * get some statistics
     *
     * @return the resulting ($count, $min_date, $max_date) array
     */
    public static function stat()
    {
        global $context;
        // select among active and restricted items
        $where = "servers.active='Y'";
        if (Surfer::is_member()) {
            $where .= " OR servers.active='R'";
        }
        if (Surfer::is_associate()) {
            $where .= " OR servers.active='N'";
        }
        // select among available items
        $query = "SELECT COUNT(*) as count, MIN(edit_date) as oldest_date, MAX(edit_date) as newest_date" . ' FROM ' . SQL::table_name('servers') . ' AS servers' . ' WHERE (' . $where . ')';
        $output = SQL::query_first($query);
        return $output;
    }
}
// load localized strings
if (is_callable(array('i18n', 'bind'))) {
    i18n::bind('servers');
}
Esempio n. 29
0
File: index.php Progetto: rair/yacs
<?php

/**
 * add intelligence to yacs
 *
 * @author Bernard Paques
 * @author GnapZ
 * @reference
 * @license http://www.gnu.org/copyleft/lesser.txt GNU Lesser General Public License
 *
 */
include_once '../shared/global.php';
// load localized strings
i18n::bind('behaviors');
// load the skin
load_skin('behaviors');
// set page title
$context['page_title'] = i18n::s('Behaviors');
// splash message
if (Surfer::is_associate()) {
    $context['text'] .= '<p>' . i18n::s('Behaviors listed below can be used to customise articles attached to some sections.') . '</p>';
}
// list behaviors available on this system
$context['text'] .= '<ul>';
if ($dir = Safe::opendir($context['path_to_root'] . 'behaviors')) {
    // every php script is a behavior, except index.php, behavior.php and behaviors.php
    while (($file = Safe::readdir($dir)) !== FALSE) {
        if ($file[0] == '.' || is_dir($context['path_to_root'] . 'behaviors/' . $file)) {
            continue;
        }
        if ($file == 'index.php') {
Esempio n. 30
0
File: index.php Progetto: rair/yacs
/**
 * extends articles functionality with canvas
 *
 * canvas are a mean to change display of articles
 *
 *
 * @author Christophe Battarel
 * @reference
 * @license http://www.gnu.org/copyleft/lesser.txt GNU Lesser General Public License
 *
 * @see canvas/standard.php
 */
include_once '../shared/global.php';
// load localized strings
i18n::bind('canvas');
// load the skin
load_skin('canvas');
// the title of the page
$context['page_title'] = i18n::s('Canvas');
// splash message
if (Surfer::is_associate()) {
    $context['text'] .= '<p>' . i18n::s('Canvas listed below can be used to customise articles display attached to some sections.') . '</p>';
}
// list canvas available on this system
$context['text'] .= '<ul>';
if ($dir = Safe::opendir($context['path_to_root'] . 'canvas')) {
    // every php script is an canvas, except index.php, canvas.php, and hooks
    while (($file = Safe::readdir($dir)) !== FALSE) {
        if ($file[0] == '.' || is_dir($context['path_to_root'] . 'canvas/' . $file)) {
            continue;