コード例 #1
0
ファイル: sessions.php プロジェクト: ibou77/elgg
/**
 * Check if the given user has full access.
 *
 * @todo: Will always return full access if the user is an admin.
 *
 * @param int $user_guid The user to check
 *
 * @return bool
 * @since 1.7.1
 */
function elgg_is_admin_user($user_guid)
{
    global $CONFIG;
    $user_guid = (int) $user_guid;
    $current_user = elgg_get_logged_in_user_entity();
    if ($current_user && $current_user->guid == $user_guid) {
        return $current_user->isAdmin();
    }
    // cannot use magic metadata here because of recursion
    // must support the old way of getting admin from metadata
    // in order to run the upgrade to move it into the users table.
    $version = (int) datalist_get('version');
    if ($version < 2010040201) {
        $admin = elgg_get_metastring_id('admin');
        $yes = elgg_get_metastring_id('yes');
        $one = elgg_get_metastring_id('1');
        $query = "SELECT 1 FROM {$CONFIG->dbprefix}users_entity as e,\n\t\t\t{$CONFIG->dbprefix}metadata as md\n\t\t\tWHERE (\n\t\t\t\tmd.name_id = '{$admin}'\n\t\t\t\tAND md.value_id IN ('{$yes}', '{$one}')\n\t\t\t\tAND e.guid = md.entity_guid\n\t\t\t\tAND e.guid = {$user_guid}\n\t\t\t\tAND e.banned = 'no'\n\t\t\t)";
    } else {
        $query = "SELECT 1 FROM {$CONFIG->dbprefix}users_entity as e\n\t\t\tWHERE (\n\t\t\t\te.guid = {$user_guid}\n\t\t\t\tAND e.admin = 'yes'\n\t\t\t)";
    }
    // normalizing the results from get_data()
    // See #1242
    $info = get_data($query);
    if (!(is_array($info) && count($info) < 1 || $info === false)) {
        return true;
    }
    return false;
}
コード例 #2
0
 /**
  * Launcher executes functionality on plugin init  
  * 
  * Launcher is responsible for querying the settings and running anything
  * that is demanded to run initially.
  */
 public static function launcher()
 {
     $displayerrors = get_plugin_setting('displayerrors', 'elgg_developer_tools');
     if ($displayerrors) {
         ini_set('display_errors', 1);
     }
     $errorlog = get_plugin_setting('errorlog', 'elgg_developer_tools');
     if ($errorlog) {
         ini_set('error_log', datalist_get('dataroot') . "debug.log");
     }
     $exceptionhandler = get_plugin_setting('exceptionhandler', 'elgg_developer_tools');
     if ($exceptionhandler) {
         restore_exception_handler();
     }
     $errorhandler = get_plugin_setting('errorhandler', 'elgg_developer_tools');
     if ($errorhandler) {
         restore_error_handler();
     }
     /** include firePHP if need be **/
     $firephp = get_plugin_setting('enablefirephp', 'elgg_developer_tools');
     if ($firephp) {
         require_once dirname(__FILE__) . '/firephp/FirePHP.class.php';
         require_once dirname(__FILE__) . '/firephp/fb.php';
     } else {
         require_once dirname(__FILE__) . '/FirePHPDisabled.php';
     }
     $timing = get_plugin_setting('timing', 'elgg_developer_tools');
     if ($timing) {
         register_elgg_event_handler('shutdown', 'system', 'elgg_dev_tools_shutdown_hook');
     }
     $showviews = get_plugin_setting('showviews', 'elgg_developer_tools');
     if ($showviews) {
         register_plugin_hook('display', 'view', 'elgg_dev_tools_outline_views');
     }
     $showstrings = get_plugin_setting('showstrings', 'elgg_developer_tools');
     if ($showstrings) {
         // first and last in case a plugin registers a translation in an init method
         register_elgg_event_handler('init', 'system', 'elgg_dev_clear_strings', 1000);
         register_elgg_event_handler('init', 'system', 'elgg_dev_clear_strings', 1);
     }
     $logevents = get_plugin_setting('logevents', 'elgg_developer_tools');
     if ($logevents) {
         register_plugin_hook('all', 'all', 'elgg_dev_log_events');
         register_elgg_event_handler('all', 'all', 'elgg_dev_log_events');
     }
 }
コード例 #3
0
 /**
  * {@inheritdoc}
  */
 protected function handle()
 {
     $path = $this->argument('path');
     if ($path) {
         // make sure the path ends with a slash
         $path = rtrim($path, DIRECTORY_SEPARATOR);
         $path .= DIRECTORY_SEPARATOR;
         if (!is_dir($path)) {
             throw new RuntimeException("{$path} is not a valid directory");
         }
         if (datalist_set('path', $path)) {
             system_message("Root path has been changed");
         } else {
             system_message("Root path could not be changed");
         }
     }
     system_message("Current root path: " . datalist_get('path'));
 }
コード例 #4
0
ファイル: events.php プロジェクト: lorea/Hydra-dev
/**
 * Do something on the 'upgrade', 'system' event (when running upgrade.php)
 *
 * @param string $event  which event was triggered
 * @param string $type   what is the type of the event
 * @param mixed  $object On what object was the event triggered
 *
 * @return void
 *
 * @see elgg_trigger_event()
 */
function newsletter_upgrade_event_handler($event, $type, $object)
{
    // amke sure the correct classes are set for our own classes
    if (!update_subtype("object", Newsletter::SUBTYPE, "Newsletter")) {
        // first time the plugin was activated
        add_subtype("object", Newsletter::SUBTYPE, "Newsletter");
    }
    if (!update_subtype("object", NewsletterSubscription::SUBTYPE, "NewsletterSubscription")) {
        // first time the plugin was activated
        add_subtype("object", NewsletterSubscription::SUBTYPE, "NewsletterSubscription");
    }
    // proccess upgrade scripts
    $upgrade_scripts = array();
    $upgrade_dir = dirname(__FILE__) . "/upgrades/";
    $fh = opendir($upgrade_dir);
    // read all available upgrade scripts
    if (!empty($fh)) {
        while (($upgrade_file = readdir($fh)) !== false) {
            if (!is_dir($upgrade_dir . $upgrade_file)) {
                $upgrade_scripts[] = $upgrade_file;
            }
        }
        closedir($fh);
    }
    if (!empty($upgrade_scripts)) {
        // get already run scripts
        $upgrades = datalist_get("processed_upgrades");
        $processed_upgrades = unserialize($upgrades);
        if (!is_array($processed_upgrades)) {
            $processed_upgrades = array();
        }
        // do we have something left
        $unprocessed = array_diff($upgrade_scripts, $processed_upgrades);
        if (!empty($unprocessed)) {
            // proccess all upgrades
            foreach ($unprocessed as $script) {
                include $upgrade_dir . $script;
                $processed_upgrades[] = $script;
            }
            // save new list
            elgg_set_processed_upgrades($processed_upgrades);
        }
    }
}
コード例 #5
0
ファイル: system.php プロジェクト: pleio/subsite_manager
function subsite_manager_boot_system_plugins_event_handler($event, $type, $object)
{
    global $CONFIG;
    global $SUBSITE_MANAGER_PLUGINS_BOOT;
    // needs to be set for links in html head
    $viewtype = get_input('view', 'default');
    $site_guid = elgg_get_site_entity()->getGUID();
    $lastcached = datalist_get("sc_lastcached_" . $viewtype . "_" . $site_guid);
    $CONFIG->lastcache = $lastcached;
    // skip non-subsites
    if (!subsite_manager_on_subsite()) {
        return true;
    }
    $site = elgg_get_site_entity();
    $to_activate = $site->getPrivateSetting('subsite_manager_plugins_activate');
    if ($to_activate) {
        $SUBSITE_MANAGER_PLUGINS_BOOT = true;
        $site->removePrivateSetting('subsite_manager_plugins_activate');
        $to_activate = unserialize($to_activate);
        set_time_limit(0);
        elgg_generate_plugin_entities();
        $old_ia = elgg_set_ignore_access(true);
        $plugins = elgg_get_plugins('any');
        foreach ($plugins as $plugin) {
            if (in_array($plugin->getID(), $to_activate)) {
                try {
                    $plugin->activate();
                } catch (Exception $e) {
                }
            }
        }
        elgg_set_ignore_access($old_ia);
        $SUBSITE_MANAGER_PLUGINS_BOOT = false;
        elgg_register_event_handler("ready", "system", "subsite_manager_ready_system_handler", 100);
    }
}
コード例 #6
0
ファイル: version.php プロジェクト: eokyere/elgg
/**
 * Upgrades Elgg
 *
 */
function version_upgrade()
{
    $dbversion = (int) datalist_get('version');
    // Upgrade database
    db_upgrade($dbversion);
    system_message(elgg_echo('upgrade:db'));
    // Upgrade core
    if (upgrade_code($dbversion)) {
        system_message(elgg_echo('upgrade:core'));
    }
    // Update the version
    datalist_set('version', get_version());
}
コード例 #7
0
ファイル: login.php プロジェクト: jricher/Elgg
// If all is present and correct, try to log in
$result = false;
if (!empty($username) && !empty($password)) {
    if ($user = authenticate($username, $password)) {
        $result = login($user, $persistent);
    }
}
// Set the system_message as appropriate
if ($result) {
    system_message(elgg_echo('loginok'));
    if ($_SESSION['last_forward_from']) {
        $forward_url = $_SESSION['last_forward_from'];
        $_SESSION['last_forward_from'] = "";
        forward($forward_url);
    } else {
        if (isadminloggedin() && !datalist_get('first_admin_login')) {
            system_message(elgg_echo('firstadminlogininstructions'));
            datalist_set('first_admin_login', time());
            forward('pg/admin/plugins');
        } else {
            if (get_input('returntoreferer')) {
                forward($_SERVER['HTTP_REFERER']);
            } else {
                forward("pg/dashboard/");
            }
        }
    }
} else {
    $error_msg = elgg_echo('loginerror');
    // figure out why the login failed
    if (!empty($username) && !empty($password)) {
コード例 #8
0
ファイル: start.php プロジェクト: rimpy/izap_videos
/**
 * main function that register everything
 *
 * @global <type> $CONFIG
 */
function init_izap_videos()
{
    global $CONFIG;
    // render this plugin from izap-elgg-bridge now
    if (is_plugin_enabled('izap-elgg-bridge')) {
        func_init_plugin_byizap(array('plugin' => array('name' => GLOBAL_IZAP_VIDEOS_PLUGIN)));
    } else {
        register_error('This plugin needs izap-elgg-bridge');
        disable_plugin(GLOBAL_IZAP_VIDEOS_PLUGIN);
    }
    // for the first time, admin settings are not set so send admin to the setting page, to set the default settings
    if (isadminloggedin() && (int) datalist_get('izap_videos_installtime') == 0) {
        datalist_set('izap_videos_installtime', time());
        forward($CONFIG->wwwroot . 'pg/videos/adminSettings/' . get_loggedin_user()->username . '?option=settings');
    }
    // extend the views
    if (is_callable('elgg_extend_view')) {
        $extend_view = 'elgg_extend_view';
    } else {
        $extend_view = 'extend_view';
    }
    // include the main lib file
    include dirname(__FILE__) . '/lib/izapLib.php';
    // load all the required files
    izapLoadLib_izap_videos();
    // register pagehandler
    register_page_handler('videos', 'pageHandler_izap_videos');
    register_page_handler('izap_videos_files', 'pageHandler_izap_videos_files');
    // register the notification hook
    if (is_callable('register_notification_object')) {
        register_notification_object('object', 'izap_videos', elgg_echo('izap_videos:newVideoAdded'));
    }
    $period = get_plugin_setting('izap_cron_time', GLOBAL_IZAP_VIDEOS_PLUGIN);
    if (isOnserverEnabled() && is_plugin_enabled('crontrigger') && $period != 'none') {
        register_plugin_hook('cron', $period, 'izap_queue_cron');
    }
    // asking group to include the izap_videos
    if (is_callable('add_group_tool_option')) {
        add_group_tool_option('izap_videos', elgg_echo('izap_videos:group:enablevideo'), true);
    }
    // register the notification hook
    if (is_callable('register_notification_object')) {
        register_notification_object('object', 'izap_videos', elgg_echo('izap_videos:newVideoAdded'));
    }
    // skip tags from filteration
    if (is_old_elgg()) {
        //allow some tags for elgg lesser than 1.6
        $CONFIG->allowedtags['object'] = array('width' => array(), 'height' => array(), 'classid' => array(), 'codebase' => array(), 'data' => array(), 'type' => array());
        $CONFIG->allowedtags['param'] = array('name' => array(), 'value' => array());
        $CONFIG->allowedtags['embed'] = array('src' => array(), 'type' => array(), 'wmode' => array(), 'width' => array(), 'height' => array());
    } else {
        $allowed_tags = get_plugin_setting('izapHTMLawedTags', GLOBAL_IZAP_VIDEOS_PLUGIN);
        $CONFIG->htmlawed_config['elements'] = 'object, embed, param, p, img, b, i, ul, li, ol, u, a, s, blockquote, br, strong, em' . ($allowed_tags ? ', ' . $allowed_tags : '');
    }
    run_function_once('izapSetup_izap_videos');
    $extend_view('css', 'izap_videos/css/default');
    $extend_view('metatags', 'izap_videos/js/javascript');
    //$extend_view('profile/menu/links','izap_videos/menu');
    $extend_view('groups/right_column', 'izap_videos/gruopVideos', 1);
    // only if enabled by admin
    if (izapIncludeIndexWidget_izap_videos()) {
        $extend_view('index/righthandside', 'izap_videos/customindexVideos');
    }
    // only if enabled by admin
    if (izapTopBarWidget_izap_videos()) {
        $extend_view('elgg_topbar/extend', 'izap_videos/navBar');
    }
    // finally lets register the object
    register_entity_type('object', 'izap_videos');
}
コード例 #9
0
ファイル: system_log.php プロジェクト: gzachos/elgg_ellak
/**
 * Log a system event related to a specific object.
 *
 * This is called by the event system and should not be called directly.
 *
 * @param object $object The object you're talking about.
 * @param string $event  The event being logged
 * @return void
 */
function system_log($object, $event)
{
    global $CONFIG;
    static $log_cache;
    static $cache_size = 0;
    if ($object instanceof Loggable) {
        /* @var ElggEntity|ElggExtender $object */
        if (datalist_get('version') < 2012012000) {
            // this is a site that doesn't have the ip_address column yet
            return;
        }
        // reset cache if it has grown too large
        if (!is_array($log_cache) || $cache_size > 500) {
            $log_cache = array();
            $cache_size = 0;
        }
        // Has loggable interface, extract the necessary information and store
        $object_id = (int) $object->getSystemLogID();
        $object_class = get_class($object);
        $object_type = $object->getType();
        $object_subtype = $object->getSubtype();
        $event = sanitise_string($event);
        $time = time();
        $ip_address = sanitize_string(_elgg_services()->request->getClientIp());
        if (!$ip_address) {
            $ip_address = '0.0.0.0';
        }
        $performed_by = elgg_get_logged_in_user_guid();
        if (isset($object->access_id)) {
            $access_id = $object->access_id;
        } else {
            $access_id = ACCESS_PUBLIC;
        }
        if (isset($object->enabled)) {
            $enabled = $object->enabled;
        } else {
            $enabled = 'yes';
        }
        if (isset($object->owner_guid)) {
            $owner_guid = $object->owner_guid;
        } else {
            $owner_guid = 0;
        }
        // Create log if we haven't already created it
        if (!isset($log_cache[$time][$object_id][$event])) {
            $query = "INSERT DELAYED into {$CONFIG->dbprefix}system_log\n\t\t\t\t(object_id, object_class, object_type, object_subtype, event,\n\t\t\t\tperformed_by_guid, owner_guid, access_id, enabled, time_created, ip_address)\n\t\t\tVALUES\n\t\t\t\t('{$object_id}','{$object_class}','{$object_type}', '{$object_subtype}', '{$event}',\n\t\t\t\t{$performed_by}, {$owner_guid}, {$access_id}, '{$enabled}', '{$time}', '{$ip_address}')";
            insert_data($query);
            $log_cache[$time][$object_id][$event] = true;
            $cache_size += 1;
        }
    }
}
コード例 #10
0
ファイル: default.php プロジェクト: amcfarlane1251/ongarde
            }
        } else {
            $output = $val;
        }
    }
    return $output;
}
$output = hj_framework_decode_xhr_view_outputs($output);
$js = elgg_get_loaded_js();
$js_foot = elgg_get_loaded_js('footer');
$js = array_merge($js, $js_foot);
$css = elgg_get_loaded_css();
$resources = array('js' => array(), 'css' => array());
/** @hack	Prevent js/css from loading again if cached in default viewtype * */
$lastcached_xhr = datalist_get("simplecache_lastcached_xhr");
$lastcached_default = datalist_get("simplecache_lastcached_default");
foreach ($js as $script) {
    if (elgg_is_simplecache_enabled()) {
        $script = str_replace('cache/js/xhr', 'cache/js/default', $script);
    } else {
        $script = str_replace('view=xhr', 'view=default', $script);
    }
    $script = str_replace($lastcached_xhr, $lastcached_default, $script);
    $resources['js'][] = html_entity_decode($script);
}
foreach ($css as $link) {
    if (elgg_is_simplecache_enabled()) {
        $link = str_replace('cache/css/xhr', 'cache/css/default', $link);
    } else {
        $link = str_replace('view=xhr', 'view=default', $link);
    }
/**
 * Upgrades Elgg
 *
 */
function version_upgrade()
{
    $dbversion = (int) datalist_get('version');
    // No version number? Oh snap...this is an upgrade from a clean installation < 1.7.
    // Run all upgrades without error reporting and hope for the best.
    // See http://trac.elgg.org/elgg/ticket/1432 for more.
    $quiet = !$dbversion;
    // Upgrade database
    if (db_upgrade($dbversion, '', $quiet)) {
        system_message(elgg_echo('upgrade:db'));
    }
    // Upgrade core
    if (upgrade_code($dbversion, $quiet)) {
        system_message(elgg_echo('upgrade:core'));
    }
    // Now we trigger an event to give the option for plugins to do something
    $upgrade_details = new stdClass();
    $upgrade_details->from = $dbversion;
    $upgrade_details->to = get_version();
    trigger_elgg_event('upgrade', 'upgrade', $upgrade_details);
    // Update the version
    datalist_set('version', get_version());
}
コード例 #12
0
ファイル: start.php プロジェクト: pleio/subsite_manager
    elgg_log("Loading {$file}...");
    if (!(include_once $file)) {
        $msg = "Could not load {$file}";
        throw new InstallationException($msg);
    }
}
// include subsite manager
require_once dirname(dirname(__FILE__)) . "/mod/subsite_manager/system.php";
// Connect to database, load language files, load configuration, init session
// Plugins can't use this event because they haven't been loaded yet.
elgg_trigger_event('boot', 'system');
// needs to be set for links in html head
$viewtype = get_input('view', 'default');
$site_guid = elgg_get_site_entity()->getGUID();
// Subsite Manager - simple cache prefix
$lastcached = datalist_get("sc_lastcached_" . $viewtype . "_" . $site_guid);
$CONFIG->lastcache = $lastcached;
// Load the plugins that are active
elgg_load_plugins();
// @todo move loading plugins into a single boot function that replaces 'boot', 'system' event
// and then move this code in there.
// This validates the view type - first opportunity to do it is after plugins load.
$view_type = elgg_get_viewtype();
if (!elgg_is_valid_view_type($view_type)) {
    elgg_set_viewtype('default');
}
// @todo deprecate as plugins can use 'init', 'system' event
elgg_trigger_event('plugins_boot', 'system');
// Complete the boot process for both engine and plugins
elgg_trigger_event('init', 'system');
$CONFIG->boot_complete = true;
コード例 #13
0
ファイル: functions.php プロジェクト: amcfarlane1251/ongarde
function translation_editor_load_translations($current_language = "")
{
    global $CONFIG;
    if (empty($current_language)) {
        $current_language = get_current_language();
    }
    // check if update is needed
    $main_ts = datalist_get("te_last_update_" . $current_language);
    $site_ts = get_private_setting($CONFIG->site_guid, "te_last_update_" . $current_language);
    if (!empty($main_ts)) {
        if (empty($site_ts) || $main_ts > $site_ts) {
            if (translation_editor_merge_translations($current_language)) {
                set_private_setting($CONFIG->site_guid, "te_last_update_" . $current_language, time());
            }
        }
    } else {
        translation_editor_merge_translations($current_language, true);
    }
    // load translations
    if ($translations = translation_editor_read_translation($current_language, "translation_editor_merged_" . $CONFIG->site_guid)) {
        add_translation($current_language, $translations);
    }
}
コード例 #14
0
ファイル: 2011010101.php プロジェクト: pleio/subsite_manager
remove_metadata($site->guid, 'pluginorder');
remove_metadata($site->guid, 'enabled_plugins');
// do subsite plugin upgrade
$site_options = array("type" => "site", "subtype" => "subsite", "limit" => false, "site_guids" => false);
if ($subsites = elgg_get_entities($site_options)) {
    set_time_limit(0);
    $old_site_guid = elgg_get_config("site_guid");
    $dir = elgg_get_plugins_path();
    $physical_plugins = elgg_get_plugin_ids_in_dir($dir);
    $hidden = access_get_show_hidden_status();
    access_show_hidden_entities(true);
    $plugin_options = array('type' => 'object', 'subtype' => 'plugin', 'limit' => false);
    $enabled_plugin_options = array("metadata_name" => "enabled_plugins", "site_guids" => false, "limit" => false);
    $subsites_done = 0;
    foreach ($subsites as $subsite) {
        if (!datalist_get("plugins_done_" . $subsite->getGUID())) {
            elgg_set_config("site", $subsite);
            elgg_set_config("site_guid", $subsite->getGUID());
            // get known plugins
            $plugin_options["site_guids"] = array($subsite->getGUID());
            $known_plugins = elgg_get_entities($plugin_options);
            if (!$known_plugins) {
                $known_plugins = array();
            }
            // map paths to indexes
            $id_map = array();
            foreach ($known_plugins as $i => $plugin) {
                // if the ID is wrong, delete the plugin because we can never load it.
                $id = $plugin->getID();
                if (!$id) {
                    $plugin->delete();
コード例 #15
0
ファイル: install.php プロジェクト: eokyere/elgg
/**
 * Returns whether or not other settings have been set
 *
 * @return true|false Whether or not the rest of the installation has been followed through with
 */
function is_installed()
{
    global $CONFIG;
    return datalist_get('installed');
}
コード例 #16
0
 * Elgg install site action
 * 
 * Creates a nwe site and sets it as the default
 * 
 * @package Elgg
 * @subpackage Core
 * @author Curverider Ltd
 * @link http://elgg.org/
 */
elgg_set_viewtype('failsafe');
// Set failsafe again incase we get an exception thrown
if (is_installed()) {
    forward();
}
if (get_input('settings') == 'go') {
    if (!datalist_get('default_site')) {
        // Sanitise
        $path = sanitise_filepath(get_input('path'));
        $dataroot = sanitise_filepath(get_input('dataroot'));
        // Blank?
        if ($dataroot == "/") {
            throw new InstallationException(elgg_echo('InstallationException:DatarootBlank'));
        }
        // That it's valid
        if (stripos($dataroot, $path) !== false) {
            throw new InstallationException(sprintf(elgg_echo('InstallationException:DatarootUnderPath'), $dataroot));
        }
        // Check data root is writable
        if (!is_writable($dataroot)) {
            throw new InstallationException(sprintf(elgg_echo('InstallationException:DatarootNotWritable'), $dataroot));
        }
コード例 #17
0
 /**
  * Boot straps into 1.8 upgrade system from 1.7
  *
  * This runs all the 1.7 upgrades, then sets the processed_upgrades to all existing 1.7 upgrades.
  * Control is then passed back to the main upgrade function which detects and runs the
  * 1.8 upgrades, regardless of filename convention.
  *
  * @return bool
  */
 protected function bootstrap17to18()
 {
     $db_version = (int) datalist_get('version');
     // the 1.8 upgrades before the upgrade system change that are interspersed with 1.7 upgrades.
     $upgrades_18 = array('2010111501.php', '2010121601.php', '2010121602.php', '2010121701.php', '2010123101.php', '2011010101.php');
     $upgrade_files = $this->getUpgradeFiles();
     $processed_upgrades = array();
     foreach ($upgrade_files as $upgrade_file) {
         // ignore if not in 1.7 format or if it's a 1.8 upgrade
         if (in_array($upgrade_file, $upgrades_18) || !preg_match("/[0-9]{10}\\.php/", $upgrade_file)) {
             continue;
         }
         $upgrade_version = $this->getUpgradeFileVersion($upgrade_file);
         // this has already been run in a previous 1.7.X -> 1.7.X upgrade
         if ($upgrade_version < $db_version) {
             $processed_upgrades[] = $upgrade_file;
         }
     }
     return $this->setProcessedUpgrades($processed_upgrades);
 }
コード例 #18
0
ファイル: install.php プロジェクト: eokyere/elgg
 * @subpackage Core
 * @license http://www.gnu.org/licenses/old-licenses/gpl-2.0.html GNU Public License version 2
 * @author Curverider Ltd
 * @copyright Curverider Ltd 2008-2009
 * @link http://elgg.org/
 */
/**
 * Start the Elgg engine
 */
require_once dirname(__FILE__) . "/engine/start.php";
global $CONFIG;
elgg_set_viewtype('failsafe');
/**
 * If we're installed, go back to the homepage
 */
if (is_installed() && is_db_installed() && datalist_get('installed')) {
    forward("index.php");
}
/**
 * Install the database
 */
if (!is_db_installed()) {
    validate_platform();
    run_sql_script(dirname(__FILE__) . "/engine/schema/mysql.sql");
    init_site_secret();
    system_message(elgg_echo("installation:success"));
}
/**
 * Load the front page
 */
page_draw(elgg_echo("installation:settings"), elgg_view_layout("one_column", elgg_view("settings/install")));
コード例 #19
0
ファイル: start.php プロジェクト: risho/Elgg
}
// confirm that the installation completed successfully
verify_installation();
// Autodetect some default configuration settings
set_default_config();
// needs to be set for links in html head
$viewtype = get_input('view', 'default');
$lastcached = datalist_get("simplecache_lastcached_{$viewtype}");
$CONFIG->lastcache = $lastcached;
// Trigger boot events for core. Plugins can't hook
// into this because they haven't been loaded yet.
elgg_trigger_event('boot', 'system');
// Load the plugins that are active
elgg_load_plugins();
elgg_trigger_event('plugins_boot', 'system');
// Trigger system init event for plugins
elgg_trigger_event('init', 'system');
// Regenerate the simple cache if expired.
// Don't do it on upgrade because upgrade does it itself.
// @todo - move into function and perhaps run off init system event
if (!defined('UPGRADING')) {
    $lastupdate = datalist_get("simplecache_lastupdate_{$viewtype}");
    $lastcached = datalist_get("simplecache_lastcached_{$viewtype}");
    if ($lastupdate == 0 || $lastcached < $lastupdate) {
        elgg_regenerate_simplecache($viewtype);
        $lastcached = datalist_get("simplecache_lastcached_{$viewtype}");
    }
    $CONFIG->lastcache = $lastcached;
}
// System loaded and ready
elgg_trigger_event('ready', 'system');
コード例 #20
0
ファイル: configuration.php プロジェクト: duanhv/mdg-social
/**
 * Loads configuration related to Elgg as an application
 *
 * This loads from the datalists database table
 * @access private
 */
function _elgg_load_application_config()
{
    global $CONFIG;
    $install_root = str_replace("\\", "/", dirname(dirname(dirname(__FILE__))));
    $defaults = array('path' => "{$install_root}/", 'view_path' => "{$install_root}/views/", 'plugins_path' => "{$install_root}/mod/", 'language' => 'en', 'viewpath' => "{$install_root}/views/", 'pluginspath' => "{$install_root}/mod/");
    foreach ($defaults as $name => $value) {
        if (empty($CONFIG->{$name})) {
            $CONFIG->{$name} = $value;
        }
    }
    $path = datalist_get('path');
    if (!empty($path)) {
        $CONFIG->path = $path;
    }
    $dataroot = datalist_get('dataroot');
    if (!empty($dataroot)) {
        $CONFIG->dataroot = $dataroot;
    }
    $simplecache_enabled = datalist_get('simplecache_enabled');
    if ($simplecache_enabled !== false) {
        $CONFIG->simplecache_enabled = $simplecache_enabled;
    } else {
        $CONFIG->simplecache_enabled = 1;
    }
    $system_cache_enabled = datalist_get('system_cache_enabled');
    if ($system_cache_enabled !== false) {
        $CONFIG->system_cache_enabled = $system_cache_enabled;
    } else {
        $CONFIG->system_cache_enabled = 1;
    }
    // initialize context here so it is set before the get_input call
    $CONFIG->context = array();
    // needs to be set before system, init for links in html head
    $viewtype = get_input('view', 'default');
    $lastcached = datalist_get("simplecache_lastcached_{$viewtype}");
    $CONFIG->lastcache = $lastcached;
    $CONFIG->i18n_loaded_from_cache = false;
    // this must be synced with the enum for the entities table
    $CONFIG->entity_types = array('group', 'object', 'site', 'user');
}
コード例 #21
0
/**
 * Generates a unique invite code for a user
 *
 * @param string $username The username of the user sending the invitation
 * @return string Invite code
 */
function generate_invite_code($username)
{
    $secret = datalist_get('__site_secret__');
    return md5($username . $secret);
}
コード例 #22
0
ファイル: start.php プロジェクト: eokyere/elgg
    header("Location: install.php");
    exit;
}
// Trigger events
if (!substr_count($_SERVER["PHP_SELF"], "install.php") && !substr_count($_SERVER["PHP_SELF"], "setup.php") && !$lightmode && !(defined('upgrading') && upgrading == 'upgrading')) {
    // If default settings haven't been installed, forward to the default settings page
    trigger_elgg_event('init', 'system');
    //if (!datalist_get('default_settings')) {
    //forward("setup.php");
    //}
}
// System booted, return to normal view
set_input('view', $oldview);
if (empty($oldview)) {
    if (empty($CONFIG->view)) {
        $oldview = 'default';
    } else {
        $oldview = $CONFIG->view;
    }
}
if ($installed && $db_installed) {
    $lastupdate = datalist_get('simplecache_lastupdate');
    $lastcached = datalist_get('simplecache_' . $oldview);
    if ($lastupdate == 0 || $lastcached < $lastupdate) {
        elgg_view_regenerate_simplecache();
        $lastcached = time();
        datalist_set('simplecache_lastupdate', $lastcached);
        datalist_set('simplecache_' . $oldview, $lastcached);
    }
    $CONFIG->lastcache = $lastcached;
}
コード例 #23
0
/**
 * Loads configuration related to Elgg as an application
 *
 * This runs on the engine boot and loads from the datalists database table.
 * 
 * @see _elgg_engine_boot()
 * 
 * @access private
 */
function _elgg_load_application_config()
{
    global $CONFIG;
    $install_root = str_replace("\\", "/", dirname(dirname(dirname(__FILE__))));
    $defaults = array('path' => "{$install_root}/", 'plugins_path' => "{$install_root}/mod/", 'language' => 'en', 'pluginspath' => "{$install_root}/mod/");
    foreach ($defaults as $name => $value) {
        if (empty($CONFIG->{$name})) {
            $CONFIG->{$name} = $value;
        }
    }
    $GLOBALS['_ELGG']->view_path = "{$install_root}/views/";
    // set cookie values for session and remember me
    _elgg_configure_cookies($CONFIG);
    if (!is_memcache_available()) {
        _elgg_services()->datalist->loadAll();
    }
    // allow sites to set dataroot and simplecache_enabled in settings.php
    if (isset($CONFIG->dataroot)) {
        $CONFIG->dataroot = sanitise_filepath($CONFIG->dataroot);
        $GLOBALS['_ELGG']->dataroot_in_settings = true;
    } else {
        $dataroot = datalist_get('dataroot');
        if (!empty($dataroot)) {
            $CONFIG->dataroot = $dataroot;
        }
        $GLOBALS['_ELGG']->dataroot_in_settings = false;
    }
    if (isset($CONFIG->simplecache_enabled)) {
        $GLOBALS['_ELGG']->simplecache_enabled_in_settings = true;
    } else {
        $simplecache_enabled = datalist_get('simplecache_enabled');
        if ($simplecache_enabled !== false) {
            $CONFIG->simplecache_enabled = $simplecache_enabled;
        } else {
            $CONFIG->simplecache_enabled = 1;
        }
        $GLOBALS['_ELGG']->simplecache_enabled_in_settings = false;
    }
    $system_cache_enabled = datalist_get('system_cache_enabled');
    if ($system_cache_enabled !== false) {
        $CONFIG->system_cache_enabled = $system_cache_enabled;
    } else {
        $CONFIG->system_cache_enabled = 1;
    }
    // needs to be set before system, init for links in html head
    $CONFIG->lastcache = (int) datalist_get("simplecache_lastupdate");
    $GLOBALS['_ELGG']->i18n_loaded_from_cache = false;
    // this must be synced with the enum for the entities table
    $CONFIG->entity_types = array('group', 'object', 'site', 'user');
}
コード例 #24
0
<?php

/**
 * Elgg 1.8.3 upgrade 2012012100
 * system_cache
 *
 * Convert viewpath cache to system cache
 */
$value = datalist_get('viewpath_cache_enabled');
datalist_set('system_cache_enabled', $value);
$query = "DELETE FROM {$CONFIG->dbprefix}datalists WHERE name='viewpath_cache_enabled'";
delete_data($query);
コード例 #25
0
/**
 * Retrieve the site secret.
 *
 */
function get_site_secret()
{
    $secret = datalist_get('__site_secret__');
    if (!$secret) {
        $secret = init_site_secret();
    }
    return $secret;
}
 * Elgg update site action
 *
 * This is an update version of the sitesettings/install action
 * which is used by the admin panel to modify basic settings.
 *
 * @package Elgg
 * @subpackage Core
 * @author Curverider Ltd
 * @link http://elgg.org/
 */
global $CONFIG;
// block non-admin users
admin_gatekeeper();
if (get_input('settings') == 'go') {
    if (datalist_get('default_site')) {
        $site = get_entity(datalist_get('default_site'));
        if (!$site instanceof ElggSite) {
            throw new InstallationException(elgg_echo('InvalidParameterException:NonElggSite'));
        }
        $site->description = get_input('sitedescription');
        $site->name = get_input('sitename');
        $site->email = get_input('siteemail');
        $site->url = get_input('wwwroot');
        datalist_set('path', sanitise_filepath(get_input('path')));
        datalist_set('dataroot', sanitise_filepath(get_input('dataroot')));
        if (get_input('simplecache_enabled')) {
            elgg_view_enable_simplecache();
        } else {
            elgg_view_disable_simplecache();
        }
        if (get_input('viewpath_cache_enabled')) {
コード例 #27
0
ファイル: ElggInstaller.php プロジェクト: nogsus/Elgg
 /**
  * Load remaining engine libraries and complete bootstraping (see start.php)
  *
  * @param string $step Which step to boot strap for. Required because
  *                     boot strapping is different until the DB is populated.
  *
  * @return void
  */
 protected function finishBootstraping($step)
 {
     $dbIndex = array_search('database', $this->getSteps());
     $settingsIndex = array_search('settings', $this->getSteps());
     $adminIndex = array_search('admin', $this->getSteps());
     $completeIndex = array_search('complete', $this->getSteps());
     $stepIndex = array_search($step, $this->getSteps());
     // To log in the user, we need to use the Elgg core session handling.
     // Otherwise, use default php session handling
     $useElggSession = $stepIndex == $adminIndex && $this->isAction || $stepIndex == $completeIndex;
     if (!$useElggSession) {
         session_name('Elgg_install');
         session_start();
         elgg_unregister_event_handler('boot', 'system', 'session_init');
     }
     if ($stepIndex > $dbIndex) {
         // once the database has been created, load rest of engine
         global $CONFIG;
         $lib_dir = $CONFIG->path . 'engine/lib/';
         $this->loadSettingsFile();
         $lib_files = array('database.php', 'actions.php', 'admin.php', 'annotations.php', 'cron.php', 'entities.php', 'extender.php', 'filestore.php', 'group.php', 'location.php', 'mb_wrapper.php', 'memcache.php', 'metadata.php', 'metastrings.php', 'navigation.php', 'notification.php', 'objects.php', 'opendd.php', 'pagehandler.php', 'pam.php', 'plugins.php', 'private_settings.php', 'relationships.php', 'river.php', 'sites.php', 'statistics.php', 'tags.php', 'user_settings.php', 'users.php', 'upgrade.php', 'web_services.php', 'widgets.php', 'xml.php', 'deprecated-1.7.php', 'deprecated-1.8.php', 'deprecated-1.9.php');
         foreach ($lib_files as $file) {
             $path = $lib_dir . $file;
             if (!(include_once $path)) {
                 $msg = elgg_echo('InstallationException:MissingLibrary', array($file));
                 throw new InstallationException($msg);
             }
         }
         setup_db_connections();
         register_translations(dirname(dirname(__FILE__)) . "/languages/");
         if ($stepIndex > $settingsIndex) {
             $CONFIG->site_guid = (int) datalist_get('default_site');
             $CONFIG->site_id = $CONFIG->site_guid;
             $CONFIG->site = get_entity($CONFIG->site_guid);
             $CONFIG->dataroot = datalist_get('dataroot');
             _elgg_session_boot(NULL, NULL, NULL);
         }
         elgg_trigger_event('init', 'system');
     }
 }
コード例 #28
0
ファイル: 2010061501.php プロジェクト: rasul/Elgg
<?php

/**
 * utf8 conversion and file merging for usernames with multibyte chars
 *
 */
// check that we need to do the utf8 conversion
// C&P logic from 2010033101
set_time_limit(0);
$dbversion = (int) datalist_get('version');
if ($dbversion < 2009100701) {
    // start a new link to the DB to see what its defaults are.
    $link = mysql_connect($CONFIG->dbhost, $CONFIG->dbuser, $CONFIG->dbpass, TRUE);
    mysql_select_db($CONFIG->dbname, $link);
    $q = "SHOW VARIABLES LIKE 'character_set_client'";
    $r = mysql_query($q);
    $client = mysql_fetch_assoc($r);
    $q = "SHOW VARIABLES LIKE 'character_set_connection'";
    $r = mysql_query($q);
    $connection = mysql_fetch_assoc($r);
    // only run upgrade if not already talking utf8
    if ($client['Value'] != 'utf8' && $connection['Value'] != 'utf8') {
        $qs = array();
        $qs[] = "SET NAMES utf8";
        $qs[] = "ALTER TABLE {$CONFIG->dbprefix}users_entity DISABLE KEYS";
        $qs[] = "REPLACE INTO {$CONFIG->dbprefix}users_entity\n\t\t\t(guid, name, username, password, salt, email, language, code,\n\t\t\tbanned, admin, last_action, prev_last_action, last_login, prev_last_login)\n\n\t\t\tSELECT guid, name, unhex(hex(convert(username using latin1))),\n\t\t\t\tpassword, salt, email, language, code,\n\t\t\t\tbanned, admin, last_action, prev_last_action, last_login, prev_last_login\n\t\t\tFROM {$CONFIG->dbprefix}users_entity";
        $qs[] = "ALTER TABLE {$CONFIG->dbprefix}users_entity ENABLE KEYS";
        foreach ($qs as $q) {
            if (!update_data($q)) {
                throw new Exception('Couldn\'t execute upgrade query: ' . $q);
            }
コード例 #29
0
ファイル: ElggVersion.php プロジェクト: socialweb/PiGo
 /**
  * @return null|int timestamp representing last check for external version date 
  * or null if never checked
  */
 static function getLatestReleaseLastChecked()
 {
     return datalist_get('version_last_checked');
 }
コード例 #30
0
 public function testElggSaveConfigForDatalist()
 {
     global $CONFIG;
     $name = 'foo' . rand(0, 1000);
     $value = 'test';
     $this->assertTrue(elgg_save_config($name, $value, null));
     $this->assertIdentical($value, datalist_get($name));
     $this->assertIdentical($value, $CONFIG->{$name});
     delete_data("DELETE FROM {$CONFIG->dbprefix}datalists WHERE name = '{$name}'");
     unset($CONFIG->{$name});
 }