示例#1
0
function upgrade_izap_videos_to($version)
{
    global $CONFIG;
    $update_entity_subtype = "UPDATE {$CONFIG->dbprefix}entity_subtypes SET class = 'IzapVideos' WHERE subtype = 'izap_videos'";
    $del_entity_query = "DELETE FROM {$CONFIG->dbprefix}entities\n                WHERE subtype IN (SELECT id FROM {$CONFIG->dbprefix}entity_subtypes\n                                  WHERE subtype='izapVideoQueue')";
    $del_queue_object_query = "DELETE FROM {$CONFIG->dbprefix}entity_subtypes where subtype='izapVideoQueue'";
    if (update_data($update_entity_subtype) || (delete_data($del_entity_query) || delete_data($del_queue_object_query))) {
        datalist_set('izap_videos_version', $version);
    }
}
示例#2
0
function subsite_manager_upgrade_system_handler($event, $type, $entity)
{
    if (get_input("all") == "true") {
        // find subsites and do stuff
        $options = array("type" => "site", "subtype" => Subsite::SUBTYPE, "limit" => false);
        // this could take a while
        set_time_limit(0);
        $batch = new ElggBatch("elgg_get_entities", $options);
        $viewtypes = elgg_get_config("view_types");
        $dataroot = elgg_get_config("dataroot");
        foreach ($batch as $subsite) {
            // clear simplecache
            $dir = $dataroot . "views_simplecache/" . $subsite->getGUID() . "/";
            if (file_exists($dir) && ($handle = opendir($dir))) {
                // remove files
                while (false !== ($file = readdir($handle))) {
                    if (!is_dir($dir . $file)) {
                        unlink($dir . $file);
                    }
                }
                closedir($handle);
            }
            if (!empty($viewtypes) && is_array($viewtypes)) {
                foreach ($viewtypes as $viewtype) {
                    datalist_set("sc_lastupdate_" . $viewtype . "_" . $subsite->getGUID(), 0);
                    datalist_set("sc_lastcached_" . $viewtype . "_" . $subsite->getGUID(), 0);
                }
            }
            // clear system cache
            $system_cache = new ElggFileCache($dataroot . "system_cache/" . $subsite->getGUID() . "/");
            $system_cache->clear();
            // cleanup cron cache
            $cron_cache = $dataroot . "subsite_manager/" . $subsite->getGUID() . "/cron_cache.json";
            if (file_exists($cron_cache)) {
                unlink($cron_cache);
            }
            // reset translation editor cache
            // can't use remove_private_setting because of 'name like' not 'name ='
            $sql = "DELETE FROM " . get_config("dbprefix") . "private_settings";
            $sql .= " WHERE name LIKE 'te_last_update_%'";
            $sql .= " AND entity_guid = " . $subsite->getGUID();
            delete_data($sql);
        }
    }
}
 /**
  * {@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
 /**
  * Create a user account for the admin
  *
  * @param array $submissionVars Submitted vars
  * @param bool  $login          Login in the admin user?
  *
  * @return bool
  */
 protected function createAdminAccount($submissionVars, $login = FALSE)
 {
     global $CONFIG;
     $guid = register_user($submissionVars['username'], $submissionVars['password1'], $submissionVars['displayname'], $submissionVars['email']);
     if (!$guid) {
         register_error(elgg_echo('install:admin:cannot_create'));
         return FALSE;
     }
     $user = get_entity($guid);
     if (!$user) {
         register_error(elgg_echo('install:error:loadadmin'));
         return FALSE;
     }
     elgg_set_ignore_access(TRUE);
     if ($user->makeAdmin() == FALSE) {
         register_error(elgg_echo('install:error:adminaccess'));
     } else {
         datalist_set('admin_registered', 1);
     }
     elgg_set_ignore_access(FALSE);
     // add validation data to satisfy user validation plugins
     create_metadata($guid, 'validated', TRUE, '', 0, ACCESS_PUBLIC);
     create_metadata($guid, 'validated_method', 'admin_user', '', 0, ACCESS_PUBLIC);
     if ($login) {
         if (login($user) == FALSE) {
             register_error(elgg_echo('install:error:adminlogin'));
         }
     }
     return TRUE;
 }
/**
 * 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());
}
示例#6
0
/**
 * Disables the simple cache.
 *
 * @warning Simplecache is also purged when disabled.
 *
 * @access private
 * @see elgg_register_simplecache_view()
 * @return void
 * @since 1.8.0
 */
function elgg_disable_simplecache()
{
    global $CONFIG;
    if ($CONFIG->simplecache_enabled) {
        datalist_set('simplecache_enabled', 0);
        $CONFIG->simplecache_enabled = 0;
        // purge simple cache
        if ($handle = opendir($CONFIG->dataroot . 'views_simplecache')) {
            while (false !== ($file = readdir($handle))) {
                if ($file != "." && $file != "..") {
                    unlink($CONFIG->dataroot . 'views_simplecache/' . $file);
                }
            }
            closedir($handle);
        }
    }
}
示例#7
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());
}
示例#8
0
 public function testDatalistSetWithUsedName()
 {
     global $CONFIG;
     $name = 'foo' . rand(0, 1000);
     $value = 'test';
     $this->assertTrue(datalist_set($name, 'not test'));
     $this->assertTrue(datalist_set($name, $value));
     $this->assertEqual($value, datalist_get($name));
     delete_data("DELETE FROM {$CONFIG->dbprefix}datalists WHERE name = '{$name}'");
 }
<?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);
示例#10
0
/**
 * 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');
}
示例#11
0
文件: version.php 项目: rasul/Elgg
/**
 * Run any php upgrade scripts which are required
 *
 * @param int  $version Version upgrading from.
 * @param bool $quiet   Suppress errors.  Don't use this.
 *
 * @return bool
 */
function upgrade_code($version, $quiet = FALSE)
{
    global $CONFIG;
    $version = (int) $version;
    $upgrade_path = elgg_get_config('path') . 'engine/lib/upgrades/';
    $processed_upgrades = unserialize(datalist_get('processed_upgrades'));
    // the day we started the new upgrade names
    $upgrade_epoch = 2011021700;
    if (!$processed_upgrades) {
        $processed_upgrades = array();
    }
    $upgrades = array();
    $upgrade_files = elgg_get_upgrade_files($upgrade_path);
    if ($upgrade_files === false) {
        return false;
    }
    // bootstrap into the new upgrade system.
    // can't do this in an upgrade because we need to check for 2010050701,
    // which would already have been run by then.
    if ($version < $upgrade_epoch) {
        foreach ($upgrade_files as $upgrade_file) {
            $upgrade_version = elgg_get_upgrade_file_version($upgrade_file);
            // the upgrade that made life difficult
            // the only way to test if we're upgrading from 1.7 to 1.8 or within 1.8
            // is to test for the the walled_garden config option, which
            // 2010050701 explicitly sets
            if ($upgrade_version == 2010050701) {
                $db_prefix = elgg_get_config('dbprefix');
                $site_guid = elgg_get_config('site_guid');
                $q = "SELECT value FROM {$db_prefix}config\n\t\t\t\t\tWHERE name = 'walled_garden' AND site_guid = {$site_guid}";
                $result = get_data_row($q);
                if (!$result) {
                    $upgrades[] = $upgrade_file;
                }
                continue;
            } elseif ($version < $upgrade_version) {
                $upgrades[] = $upgrade_file;
            } else {
                // all of the upgrades before the epoch have been run except one...
                $processed_upgrades[] = $upgrade_file;
            }
        }
    } else {
        // add any upgrades that haven't been run to the upgrades list
        $upgrades = elgg_get_unprocessed_upgrades($upgrade_files, $processed_upgrades);
    }
    // Sort and execute
    sort($upgrades);
    foreach ($upgrades as $upgrade) {
        $upgrade_version = elgg_get_upgrade_file_version($upgrade);
        $success = true;
        // hide all errors.
        if ($quiet) {
            // hide include errors as well as any exceptions that might happen
            try {
                if (!@(include "{$upgrade_path}/{$upgrade}")) {
                    $success = false;
                    error_log($e->getmessage());
                }
            } catch (Exception $e) {
                $success = false;
                error_log($e->getmessage());
            }
        } else {
            if (!(include "{$upgrade_path}/{$upgrade}")) {
                $success = false;
            }
        }
        if ($success) {
            // incrementally set upgrade so we know where to start if something fails.
            $processed_upgrades[] = $upgrade;
            // don't set the version to a lower number in instances where an upgrade
            // has been merged from a lower version
            if ($upgrade_version > $version) {
                datalist_set('version', $upgrade_version);
            }
            $processed_upgrades = array_unique($processed_upgrades);
            datalist_set('processed_upgrades', serialize($processed_upgrades));
        } else {
            return false;
        }
    }
    return true;
}
示例#12
0
     register_error(elgg_echo("IOException:UnableToSaveNew", array(get_class($site))));
     $site = null;
 } else {
     $site = get_entity($guid);
     $site->createACL();
     // set default language
     $lan = get_config("language", $CONFIG->site_guid);
     set_config("language", $lan, $site->getGUID());
     // set default access
     set_config("default_access", $site->getACL(), $site->getGUID());
     // default allow registration
     set_config("allow_registration", true, $site->getGUID());
     // enable simple cache
     datalist_set("simplecache_enabled_" . $site->getGUID(), 1);
     // enable file path cache
     datalist_set("viewpath_cache_enabled_" . $site->getGUID(), 1);
 }
 if (!empty($site)) {
     // Default site attributes
     $site->name = $name;
     $site->description = $description;
     $site->email = "noreply@" . get_site_domain($site->getGUID());
     $site->url = $url;
     // site category
     $site->category = $category;
     // Site icon
     if (get_resized_image_from_uploaded_file("icon", 16, 16)) {
         // prepare image sizes
         $topbar = get_resized_image_from_uploaded_file("icon", 16, 16, true);
         $tiny = get_resized_image_from_uploaded_file("icon", 25, 25, true);
         $small = get_resized_image_from_uploaded_file("icon", 40, 40, true);
/**
 * Deletes all cached views in the simplecache and sets the lastcache and
 * lastupdate time to 0 for every valid viewtype.
 *
 * @return bool
 * @since 1.7.4
 */
function elgg_invalidate_simplecache()
{
    global $CONFIG;
    if (!isset($CONFIG->views->simplecache) || !is_array($CONFIG->views->simplecache)) {
        return false;
    }
    _elgg_rmdir("{$CONFIG->dataroot}views_simplecache");
    mkdir("{$CONFIG->dataroot}views_simplecache");
    $time = time();
    datalist_set("simplecache_lastupdate", $time);
    $CONFIG->lastcache = $time;
    return true;
}
<?php

/**
 * Elgg upgrade script.
 *
 * This script triggers any upgrades necessary, ensuring that upgrades are triggered deliberately by a single
 * user.
 *
 * @package Elgg
 * @subpackage Core
 * @author Curverider Ltd
 * @link http://elgg.org/
 */
// Include elgg engine
define('upgrading', 'upgrading');
define('externalpage', true);
require_once dirname(__FILE__) . "/engine/start.php";
if (get_input('upgrade') == 'upgrade') {
    if (version_upgrade_check()) {
        version_upgrade();
    }
    datalist_set('simplecache_lastupdate', 0);
    elgg_filepath_cache_reset();
} else {
    global $CONFIG;
    echo elgg_view('settings/upgrading');
    exit;
}
forward();
示例#15
0
 /**
  * Create a user account for the admin
  *
  * @param array $submissionVars Submitted vars
  * @param bool  $login          Login in the admin user?
  *
  * @return bool
  */
 protected function createAdminAccount($submissionVars, $login = FALSE)
 {
     try {
         $guid = register_user($submissionVars['username'], $submissionVars['password1'], $submissionVars['displayname'], $submissionVars['email']);
     } catch (Exception $e) {
         register_error($e->getMessage());
         return false;
     }
     if (!$guid) {
         register_error(elgg_echo('install:admin:cannot_create'));
         return false;
     }
     $user = get_entity($guid);
     if (!$user instanceof ElggUser) {
         register_error(elgg_echo('install:error:loadadmin'));
         return false;
     }
     elgg_set_ignore_access(TRUE);
     if ($user->makeAdmin() == FALSE) {
         register_error(elgg_echo('install:error:adminaccess'));
     } else {
         datalist_set('admin_registered', 1);
     }
     elgg_set_ignore_access(false);
     // add validation data to satisfy user validation plugins
     create_metadata($guid, 'validated', TRUE, '', 0, ACCESS_PUBLIC);
     create_metadata($guid, 'validated_method', 'admin_user', '', 0, ACCESS_PUBLIC);
     if ($login) {
         $handler = new Elgg_Http_DatabaseSessionHandler(_elgg_services()->db);
         $storage = new Elgg_Http_NativeSessionStorage(array(), $handler);
         $session = new ElggSession($storage);
         $session->setName('Elgg');
         _elgg_services()->setValue('session', $session);
         if (login($user) == FALSE) {
             register_error(elgg_echo('install:error:adminlogin'));
         }
     }
     return TRUE;
 }
示例#16
0
/**
 * Run a function one time per installation.
 *
 * If you pass a timestamp as the second argument, it will run the function
 * only if (i) it has never been run before or (ii) the timestamp is >=
 * the last time it was run.
 *
 * @warning Functions are determined by their name.  If you change the name of a function
 * it will be run again.
 *
 * @tip Use $timelastupdatedcheck in your plugins init function to perform automated
 * upgrades.  Schedule a function to run once and pass the timestamp of the new release.
 * This will cause the run once function to be run on all installations.  To perform
 * additional upgrades, create new functions for each release.
 *
 * @warning The function name cannot be longer than 255 characters long due to
 * the current schema for the datalist table.
 *
 * @internal A datalist entry $functioname is created with the value of time().
 *
 * @param string $functionname         The name of the function you want to run.
 * @param int    $timelastupdatedcheck A UNIX timestamp. If time() is > than this,
 *                                     this function will be run again.
 *
 * @return bool
 */
function run_function_once($functionname, $timelastupdatedcheck = 0)
{
    $lastupdated = datalist_get($functionname);
    if ($lastupdated) {
        $lastupdated = (int) $lastupdated;
    } elseif ($lastupdated !== false) {
        $lastupdated = 0;
    } else {
        // unable to check datalist
        return false;
    }
    if (is_callable($functionname) && $lastupdated <= $timelastupdatedcheck) {
        $functionname();
        datalist_set($functionname, time());
        return true;
    } else {
        return false;
    }
}
示例#17
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;
}
示例#18
0
$dataroot = sanitise_filepath(get_input('dataroot', '', false));
// check for relative paths
if (stripos(PHP_OS, 'win') === 0) {
    if (strpos($dataroot, ':') !== 1) {
        $msg = elgg_echo('admin:configuration:dataroot:relative_path', array($dataroot));
        register_error($msg);
        forward(REFERER);
    }
} else {
    if (strpos($dataroot, '/') !== 0) {
        $msg = elgg_echo('admin:configuration:dataroot:relative_path', array($dataroot));
        register_error($msg);
        forward(REFERER);
    }
}
datalist_set('dataroot', $dataroot);
if ('on' === get_input('simplecache_enabled')) {
    elgg_enable_simplecache();
} else {
    elgg_disable_simplecache();
}
set_config('simplecache_minify_js', 'on' === get_input('simplecache_minify_js'), $site->getGUID());
set_config('simplecache_minify_css', 'on' === get_input('simplecache_minify_css'), $site->getGUID());
if ('on' === get_input('system_cache_enabled')) {
    elgg_enable_system_cache();
} else {
    elgg_disable_system_cache();
}
set_config('default_access', get_input('default_access', ACCESS_PRIVATE), $site->getGUID());
$user_default_access = 'on' === get_input('allow_user_default_access');
set_config('allow_user_default_access', $user_default_access, $site->getGUID());
 */
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')) {
            elgg_enable_filepath_cache();
        } else {
            elgg_disable_filepath_cache();
        }
        set_config('language', get_input('language'), $site->getGUID());
        set_config('default_access', get_input('default_access'), $site->getGUID());
        if (get_input('allow_user_default_access')) {
            set_config('allow_user_default_access', 1, $site->getGUID());
        } else {
示例#20
0
文件: cache.php 项目: nachopavon/Elgg
/**
 * Deletes all cached views in the simplecache and sets the lastcache and
 * lastupdate time to 0 for every valid viewtype.
 *
 * @return bool
 * @since 1.7.4
 */
function elgg_invalidate_simplecache()
{
    global $CONFIG;
    if (!isset($CONFIG->views->simplecache) || !is_array($CONFIG->views->simplecache)) {
        return false;
    }
    $handle = opendir($CONFIG->dataroot . 'views_simplecache');
    if (!$handle) {
        return false;
    }
    // remove files.
    $return = true;
    while (false !== ($file = readdir($handle))) {
        if ($file != "." && $file != "..") {
            $return = $return && unlink($CONFIG->dataroot . 'views_simplecache/' . $file);
        }
    }
    closedir($handle);
    // reset cache times
    $viewtypes = $CONFIG->view_types;
    if (!is_array($viewtypes)) {
        return false;
    }
    foreach ($viewtypes as $viewtype) {
        $return = $return && datalist_set("simplecache_lastupdate_{$viewtype}", 0);
        $return = $return && datalist_set("simplecache_lastcached_{$viewtype}", 0);
    }
    return $return;
}
示例#21
0
文件: login.php 项目: jricher/Elgg
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)) {
        // See if it exists and is disabled
        $access_status = access_get_show_hidden_status();
示例#22
0
 /**
  * Saves the processed upgrades to a dataset.
  *
  * @param array $processed_upgrades An array of processed upgrade filenames
  *                                  (not the path, just the file)
  * @return bool
  */
 protected function setProcessedUpgrades(array $processed_upgrades)
 {
     $processed_upgrades = array_unique($processed_upgrades);
     return datalist_set('processed_upgrades', serialize($processed_upgrades));
 }
示例#23
0
function translation_editor_merge_translations($language = "", $update = false)
{
    global $CONFIG;
    $result = false;
    if (empty($language)) {
        $language = get_current_language();
    }
    if (!empty($language)) {
        $translations = array();
        if ($core = translation_editor_read_translation($language, "core")) {
            $translations = $core;
        }
        if ($custom_keys = translation_editor_read_translation($language, "custom_keys")) {
            $translations += $custom_keys;
        }
        if ($plugins = elgg_get_plugins()) {
            foreach ($plugins as $plugin) {
                if ($plugin_translation = translation_editor_read_translation($language, $plugin->title)) {
                    $translations += $plugin_translation;
                }
            }
        }
        if (!empty($translations)) {
            if (translation_editor_write_translation($language, "translation_editor_merged_" . $CONFIG->site_guid, $translations)) {
                $result = true;
            }
        } else {
            if (translation_editor_delete_translation($language, "translation_editor_merged_" . $CONFIG->site_guid)) {
                $result = true;
            }
        }
    }
    if ($result) {
        elgg_trigger_event("language:merge", "translation_editor", $language);
    }
    // reset language cache on all sites
    if ($update) {
        $ts = time();
        datalist_set("te_last_update_" . $language, $ts);
        set_private_setting($CONFIG->site_guid, "te_last_update_" . $language, $ts);
    }
    return $result;
}
示例#24
0
文件: upgrade.php 项目: n8b/VMN
/**
 * Saves the processed upgrades to a dataset.
 *
 * @param array $processed_upgrades An array of processed upgrade filenames
 *                                  (not the path, just the file)
 * @return bool
 * @access private
 *
 * @todo this is still required because of the hack in the 2011010101 upgrade
 */
function elgg_set_processed_upgrades(array $processed_upgrades)
{
    $processed_upgrades = array_unique($processed_upgrades);
    return datalist_set('processed_upgrades', serialize($processed_upgrades));
}
/**
 * Registers a user, returning false if the username already exists
 *
 * @param string $username The username of the new user
 * @param string $password The password
 * @param string $name The user's display name
 * @param string $email Their email address
 * @param bool $allow_multiple_emails Allow the same email address to be registered multiple times?
 * @param int $friend_guid Optionally, GUID of a user this user will friend once fully registered 
 * @return int|false The new user's GUID; false on failure
 */
function register_user($username, $password, $name, $email, $allow_multiple_emails = false, $friend_guid = 0, $invitecode = '')
{
    // Load the configuration
    global $CONFIG;
    $username = trim($username);
    $password = trim($password);
    $name = trim($name);
    $email = trim($email);
    // A little sanity checking
    if (empty($username) || empty($password) || empty($name) || empty($email)) {
        return false;
    }
    // See if it exists and is disabled
    $access_status = access_get_show_hidden_status();
    access_show_hidden_entities(true);
    // Validate email address
    if (!validate_email_address($email)) {
        throw new RegistrationException(elgg_echo('registration:emailnotvalid'));
    }
    // Validate password
    if (!validate_password($password)) {
        throw new RegistrationException(elgg_echo('registration:passwordnotvalid'));
    }
    // Validate the username
    if (!validate_username($username)) {
        throw new RegistrationException(elgg_echo('registration:usernamenotvalid'));
    }
    // Check to see if $username exists already
    if ($user = get_user_by_username($username)) {
        //return false;
        throw new RegistrationException(elgg_echo('registration:userexists'));
    }
    // If we're not allowed multiple emails then see if this address has been used before
    if (!$allow_multiple_emails && get_user_by_email($email)) {
        throw new RegistrationException(elgg_echo('registration:dupeemail'));
    }
    access_show_hidden_entities($access_status);
    // Check to see if we've registered the first admin yet.
    // If not, this is the first admin user!
    $admin = datalist_get('admin_registered');
    // Otherwise ...
    $user = new ElggUser();
    $user->username = $username;
    $user->email = $email;
    $user->name = $name;
    $user->access_id = ACCESS_PUBLIC;
    $user->salt = generate_random_cleartext_password();
    // Note salt generated before password!
    $user->password = generate_user_password($user, $password);
    $user->owner_guid = 0;
    // Users aren't owned by anyone, even if they are admin created.
    $user->container_guid = 0;
    // Users aren't contained by anyone, even if they are admin created.
    $user->save();
    // If $friend_guid has been set, make mutual friends
    if ($friend_guid) {
        if ($friend_user = get_user($friend_guid)) {
            if ($invitecode == generate_invite_code($friend_user->username)) {
                $user->addFriend($friend_guid);
                $friend_user->addFriend($user->guid);
            }
        }
    }
    global $registering_admin;
    if (!$admin) {
        $user->admin = true;
        datalist_set('admin_registered', 1);
        $registering_admin = true;
    } else {
        $registering_admin = false;
    }
    // Turn on email notifications by default
    set_user_notification_setting($user->getGUID(), 'email', true);
    return $user->getGUID();
}
     throw new InstallationException(sprintf(elgg_echo('InstallationException:DatarootNotWritable'), $dataroot));
 }
 $site = new ElggSite();
 $site->name = get_input('sitename');
 $site->url = get_input('wwwroot');
 $site->description = get_input('sitedescription');
 $site->email = get_input('siteemail');
 $site->access_id = ACCESS_PUBLIC;
 $guid = $site->save();
 if (!$guid) {
     throw new InstallationException(sprintf(elgg_echo('InstallationException:CantCreateSite'), get_input('sitename'), get_input('wwwroot')));
 }
 datalist_set('installed', time());
 datalist_set('path', $path);
 datalist_set('dataroot', $dataroot);
 datalist_set('default_site', $site->getGUID());
 set_config('view', get_input('view'), $site->getGUID());
 set_config('language', get_input('language'), $site->getGUID());
 set_config('default_access', get_input('default_access'), $site->getGUID());
 $debug = get_input('debug');
 if ($debug) {
     set_config('debug', 1, $site->getGUID());
 } else {
     unset_config('debug', $site->getGUID());
 }
 $usage = get_input('usage');
 if (is_array($usage)) {
     $usage = $usage[0];
 }
 if ($usage) {
     unset_config('ping_home', $site->getGUID());
/**
 * Initialise the site secret.
 *
 */
function init_site_secret()
{
    $secret = md5(rand() . microtime());
    if (datalist_set('__site_secret__', $secret)) {
        return $secret;
    }
    return false;
}
示例#28
0
<?php

/**
 * Clears old simplecache variables out of database
 */
$query = "DELETE FROM {$CONFIG->dbprefix}datalists WHERE name LIKE 'simplecache%'";
delete_data($query);
if ($CONFIG->simplecache_enabled) {
    datalist_set('simplecache_enabled', 1);
    elgg_invalidate_simplecache();
} else {
    datalist_set('simplecache_enabled', 0);
}
示例#29
0
 /**
  * Tries several methods and sources of determining latest Elgg release.
  * @return string|boolean returns release string or false on failure
  */
 static function getLatestRelease($overrideCache = false)
 {
     if (self::$latestRelease !== null) {
         return self::$latestRelease;
     }
     //fetch from datalist if caching period not reached
     $lastChecked = datalist_get('version_last_checked');
     $cachedRelease = datalist_get('version_newest');
     $time = time();
     if ($cachedRelease && !$overrideCache && $lastChecked + self::$cachingPeriod > $time) {
         self::$latestRelease = $cachedRelease;
         return $cachedRelease;
     }
     $release = false;
     $mt = microtime(true);
     if (!($release = self::getLatestFromGithub())) {
         // github is wrong, maybe missing https support, try elgg.org
         $release = self::getLatestFromElggOrg();
     }
     datalist_set('version_last_checked', $time);
     datalist_set('version_newest', $release);
     self::$latestRelease = $release;
     return $release;
 }
示例#30
0
            datalist_set("plugins_done_" . $subsite->getGUID(), true);
            if ($subsites_done == 10) {
                forward("upgrade.php");
            }
            $subsites_done++;
        }
    }
    // cleanup datalist
    $query = "DELETE FROM " . elgg_get_config("dbprefix") . "datalists";
    $query .= " WHERE name LIKE 'plugins_done_%'";
    delete_data($query);
    access_show_hidden_entities($hidden);
}
elgg_set_ignore_access($old_id);
/**
 * @hack
 *
 * We stop the upgrade at this point because plugins weren't given the chance to
 * load due to the new plugin code introduced with Elgg 1.8. Instead, we manually
 * set the version and start the upgrade process again.
 *
 * The variables from upgrade_code() are available because this script was included
 */
if ($upgrade_version > $version) {
    datalist_set('version', $upgrade_version);
}
// add ourselves to the processed_upgrades.
$processed_upgrades[] = '2011010101.php';
$processed_upgrades = array_unique($processed_upgrades);
elgg_set_processed_upgrades($processed_upgrades);
forward('upgrade.php');