Exemplo n.º 1
0
/**
 * MyBB 1.8
 * Copyright 2014 MyBB Group, All Rights Reserved
 *
 * Website: http://www.mybb.com
 * License: http://www.mybb.com/about/license
 *
 */
function task_versioncheck($task)
{
    global $cache, $lang, $mybb;
    $current_version = rawurlencode($mybb->version_code);
    $updated_cache = array('last_check' => TIME_NOW);
    // Check for the latest version
    require_once MYBB_ROOT . 'inc/class_xml.php';
    $contents = fetch_remote_file("http://www.mybb.com/version_check.php");
    if (!$contents) {
        add_task_log($task, $lang->task_versioncheck_ran_errors);
        return false;
    }
    $pos = strpos($contents, "<");
    if ($pos > 1) {
        $contents = substr($contents, $pos);
    }
    $pos = strpos(strrev($contents), ">");
    if ($pos > 1) {
        $contents = substr($contents, 0, -1 * ($pos - 1));
    }
    $parser = new XMLParser($contents);
    $tree = $parser->get_tree();
    $latest_code = (int) $tree['mybb']['version_code']['value'];
    $latest_version = "<strong>" . htmlspecialchars_uni($tree['mybb']['latest_version']['value']) . "</strong> (" . $latest_code . ")";
    if ($latest_code > $mybb->version_code) {
        $latest_version = "<span style=\"color: #C00;\">" . $latest_version . "</span>";
        $version_warn = 1;
        $updated_cache['latest_version'] = $latest_version;
        $updated_cache['latest_version_code'] = $latest_code;
    } else {
        $latest_version = "<span style=\"color: green;\">" . $latest_version . "</span>";
    }
    // Check for the latest news
    require_once MYBB_ROOT . "inc/class_feedparser.php";
    $feed_parser = new FeedParser();
    $feed_parser->parse_feed("http://feeds.feedburner.com/MyBBDevelopmentBlog");
    $updated_cache['news'] = array();
    require_once MYBB_ROOT . '/inc/class_parser.php';
    $post_parser = new postParser();
    if ($feed_parser->error == '') {
        foreach ($feed_parser->items as $item) {
            if (isset($updated_cache['news'][2])) {
                break;
            }
            $description = $item['description'];
            $description = $post_parser->parse_message($description, array('allow_html' => true));
            $description = preg_replace('#<img(.*)/>#', '', $description);
            $updated_cache['news'][] = array('title' => htmlspecialchars_uni($item['title']), 'description' => $description, 'link' => htmlspecialchars_uni($item['link']), 'author' => htmlspecialchars_uni($item['author']), 'dateline' => $item['date_timestamp']);
        }
    }
    $cache->update("update_check", $updated_cache);
    add_task_log($task, $lang->task_versioncheck_ran);
}
Exemplo n.º 2
0
 /**
  * Parses a feed with the specified filename (or URL)
  *
  * @param string $feed The path or URL of the feed
  * @return boolean True if parsing was a success, false if failure
  */
 function parse_feed($feed)
 {
     // Include the XML parser
     require_once MYBB_ROOT . "inc/class_xml.php";
     // Load the feed we want to parse
     $contents = fetch_remote_file($feed);
     // This is to work around some dodgy bug we've detected with certain installations of PHP
     // where certain characters would magically appear between the fetch_remote_file call
     // and here which break the feed being imported.
     if (strpos($contents, "<") !== 0) {
         $contents = substr($contents, strpos($contents, "<"));
     }
     if (strrpos($contents, ">") + 1 !== strlen($contents)) {
         $contents = substr($contents, 0, strrpos($contents, ">") + 1);
     }
     // Could not load the feed, return an error
     if (!$contents) {
         $this->error = "invalid_file";
         return false;
     }
     // Parse the feed and get the tree
     $parser = new XMLParser($contents);
     $tree = $parser->get_tree();
     // If the feed is invalid, throw back an error
     if ($tree == false) {
         $this->error = "invalid_feed_xml";
         return false;
     }
     // Change array key names to lower case
     $tree = $this->keys_to_lowercase($tree);
     // This is an RSS feed, parse it
     if (array_key_exists("rss", $tree)) {
         $this->parse_rss($tree['rss']);
     } else {
         $this->error = "unknown_feed_type";
         return false;
     }
     return true;
 }
Exemplo n.º 3
0
/**
 * Installation is finished
 */
function install_done()
{
    global $output, $db, $mybb, $errors, $cache, $lang;
    if (empty($mybb->input['adminuser'])) {
        $errors[] = $lang->admin_step_error_nouser;
    }
    if (empty($mybb->input['adminpass'])) {
        $errors[] = $lang->admin_step_error_nopassword;
    }
    if ($mybb->get_input('adminpass') != $mybb->get_input('adminpass2')) {
        $errors[] = $lang->admin_step_error_nomatch;
    }
    if (empty($mybb->input['adminemail'])) {
        $errors[] = $lang->admin_step_error_noemail;
    }
    if (is_array($errors)) {
        create_admin_user();
    }
    require MYBB_ROOT . 'inc/config.php';
    $db = db_connection($config);
    require MYBB_ROOT . 'inc/settings.php';
    $mybb->settings =& $settings;
    ob_start();
    $output->print_header($lang->finish_setup, 'finish');
    echo $lang->done_step_usergroupsinserted;
    // Insert all of our user groups from the XML file
    $usergroup_settings = file_get_contents(INSTALL_ROOT . 'resources/usergroups.xml');
    $parser = new XMLParser($usergroup_settings);
    $parser->collapse_dups = 0;
    $tree = $parser->get_tree();
    $admin_gid = '';
    $group_count = 0;
    foreach ($tree['usergroups'][0]['usergroup'] as $usergroup) {
        // usergroup[cancp][0][value]
        $new_group = array();
        foreach ($usergroup as $key => $value) {
            if (!is_array($value)) {
                continue;
            }
            $new_group[$key] = $db->escape_string($value[0]['value']);
        }
        $db->insert_query("usergroups", $new_group, false);
        // If this group can access the admin CP and we haven't established the admin group - set it (just in case we ever change IDs)
        if ($new_group['cancp'] == 1 && !$admin_gid) {
            $admin_gid = $usergroup['gid'][0]['value'];
        }
        $group_count++;
    }
    // Restart usergroup sequence with correct # of groups
    if ($config['database']['type'] == "pgsql") {
        $db->query("SELECT setval('{$config['database']['table_prefix']}usergroups_gid_seq', (SELECT max(gid) FROM {$config['database']['table_prefix']}usergroups));");
    }
    echo $lang->done . '</p>';
    echo $lang->done_step_admincreated;
    $now = TIME_NOW;
    $salt = random_str();
    $loginkey = generate_loginkey();
    $saltedpw = md5(md5($salt) . md5($mybb->get_input('adminpass')));
    $newuser = array('username' => $db->escape_string($mybb->get_input('adminuser')), 'password' => $saltedpw, 'salt' => $salt, 'loginkey' => $loginkey, 'email' => $db->escape_string($mybb->get_input('adminemail')), 'usergroup' => $admin_gid, 'regdate' => $now, 'lastactive' => $now, 'lastvisit' => $now, 'website' => '', 'icq' => '', 'aim' => '', 'yahoo' => '', 'skype' => '', 'google' => '', 'birthday' => '', 'signature' => '', 'allownotices' => 1, 'hideemail' => 0, 'subscriptionmethod' => '0', 'receivepms' => 1, 'pmnotice' => 1, 'pmnotify' => 1, 'buddyrequestspm' => 1, 'buddyrequestsauto' => 0, 'showimages' => 1, 'showvideos' => 1, 'showsigs' => 1, 'showavatars' => 1, 'showquickreply' => 1, 'invisible' => 0, 'style' => '0', 'timezone' => 0, 'dst' => 0, 'threadmode' => '', 'daysprune' => 0, 'regip' => $db->escape_binary(my_inet_pton(get_ip())), 'language' => '', 'showcodebuttons' => 1, 'tpp' => 0, 'ppp' => 0, 'referrer' => 0, 'buddylist' => '', 'ignorelist' => '', 'pmfolders' => '', 'notepad' => '', 'showredirect' => 1, 'usernotes' => '');
    $db->insert_query('users', $newuser);
    echo $lang->done . '</p>';
    echo $lang->done_step_adminoptions;
    $adminoptions = file_get_contents(INSTALL_ROOT . 'resources/adminoptions.xml');
    $parser = new XMLParser($adminoptions);
    $parser->collapse_dups = 0;
    $tree = $parser->get_tree();
    $insertmodule = array();
    $db->delete_query("adminoptions");
    // Insert all the admin permissions
    foreach ($tree['adminoptions'][0]['user'] as $users) {
        $uid = $users['attributes']['uid'];
        foreach ($users['permissions'][0]['module'] as $module) {
            foreach ($module['permission'] as $permission) {
                $insertmodule[$module['attributes']['name']][$permission['attributes']['name']] = $permission['value'];
            }
        }
        $defaultviews = array();
        foreach ($users['defaultviews'][0]['view'] as $view) {
            $defaultviews[$view['attributes']['type']] = $view['value'];
        }
        $adminoptiondata = array('uid' => (int) $uid, 'cpstyle' => '', 'notes' => '', 'permissions' => $db->escape_string(my_serialize($insertmodule)), 'defaultviews' => $db->escape_string(my_serialize($defaultviews)));
        $insertmodule = array();
        $db->insert_query('adminoptions', $adminoptiondata);
    }
    echo $lang->done . '</p>';
    // Automatic Login
    my_unsetcookie("sid");
    my_unsetcookie("mybbuser");
    my_setcookie('mybbuser', $uid . '_' . $loginkey, null, true);
    ob_end_flush();
    // Make fulltext columns if supported
    if ($db->supports_fulltext('threads')) {
        $db->create_fulltext_index('threads', 'subject');
    }
    if ($db->supports_fulltext_boolean('posts')) {
        $db->create_fulltext_index('posts', 'message');
    }
    echo $lang->done_step_cachebuilding;
    require_once MYBB_ROOT . 'inc/class_datacache.php';
    $cache = new datacache();
    $cache->update_version();
    $cache->update_attachtypes();
    $cache->update_smilies();
    $cache->update_badwords();
    $cache->update_usergroups();
    $cache->update_forumpermissions();
    $cache->update_stats();
    $cache->update_statistics();
    $cache->update_forums();
    $cache->update_moderators();
    $cache->update_usertitles();
    $cache->update_reportedcontent();
    $cache->update_awaitingactivation();
    $cache->update_mycode();
    $cache->update_profilefields();
    $cache->update_posticons();
    $cache->update_spiders();
    $cache->update_bannedips();
    $cache->update_banned();
    $cache->update_bannedemails();
    $cache->update_birthdays();
    $cache->update_groupleaders();
    $cache->update_threadprefixes();
    $cache->update_forumsdisplay();
    $cache->update("plugins", array());
    $cache->update("internal_settings", array('encryption_key' => random_str(32)));
    $cache->update_default_theme();
    $version_history = array();
    $dh = opendir(INSTALL_ROOT . "resources");
    while (($file = readdir($dh)) !== false) {
        if (preg_match("#upgrade([0-9]+).php\$#i", $file, $match)) {
            $version_history[$match[1]] = $match[1];
        }
    }
    sort($version_history, SORT_NUMERIC);
    $cache->update("version_history", $version_history);
    // Schedule an update check so it occurs an hour ago.  Gotta stay up to date!
    $update['nextrun'] = TIME_NOW - 3600;
    $db->update_query("tasks", $update, "tid='12'");
    $cache->update_update_check();
    $cache->update_tasks();
    echo $lang->done . '</p>';
    echo $lang->done_step_success;
    $written = 0;
    if (is_writable('./')) {
        $lock = @fopen('./lock', 'w');
        $written = @fwrite($lock, '1');
        @fclose($lock);
        if ($written) {
            echo $lang->done_step_locked;
        }
    }
    if (!$written) {
        echo $lang->done_step_dirdelete;
    }
    echo $lang->done_whats_next;
    $output->print_footer('');
}
Exemplo n.º 4
0
 $plugins->run_hooks("admin_home_credits_start");
 $page->output_nav_tabs($sub_tabs, 'credits');
 $mybb_credits = $cache->read('mybb_credits');
 if ($mybb->get_input('fetch_new', MyBB::INPUT_INT) == 1 || $mybb->get_input('fetch_new', MyBB::INPUT_INT) == -2 || $mybb->get_input('fetch_new', MyBB::INPUT_INT) != -1 && (!is_array($mybb_credits) || $mybb_credits['last_check'] <= TIME_NOW - 60 * 60 * 24 * 14)) {
     $new_mybb_credits = array('last_check' => TIME_NOW);
     require_once MYBB_ROOT . "inc/class_xml.php";
     $contents = fetch_remote_file("http://www.mybb.com/mybb_team.xml");
     if (!$contents) {
         flash_message($lang->error_communication, 'error');
         if ($mybb->get_input('fetch_new', MyBB::INPUT_INT) == -2) {
             admin_redirect('index.php?module=tools-cache');
         }
         admin_redirect('index.php?module=home-credits&amp;fetch_new=-1');
     }
     $parser = new XMLParser($contents);
     $tree = $parser->get_tree();
     $mybbgroup = array();
     foreach ($tree['mybbgroup']['team'] as $team) {
         $members = array();
         foreach ($team['member'] as $member) {
             $members[] = array('name' => htmlspecialchars_uni($member['name']['value']), 'username' => htmlspecialchars_uni($member['username']['value']), 'profile' => htmlspecialchars_uni($member['profile']['value']), 'lead' => (bool) $member['attributes']['lead'] or false);
         }
         $mybbgroup[] = array('title' => htmlspecialchars_uni($team['attributes']['title']), 'members' => $members);
     }
     $new_mybb_credits['credits'] = $mybbgroup;
     $cache->update('mybb_credits', $new_mybb_credits);
     if ($mybb->get_input('fetch_new', MyBB::INPUT_INT) == -2) {
         $lang->load('tools_cache');
         flash_message($lang->success_cache_reloaded, 'success');
         admin_redirect('index.php?module=tools-cache');
     } else {
Exemplo n.º 5
0
function upgrade12_dbchanges5()
{
    global $db, $output, $mybb;
    $output->print_header("Performing Queries");
    echo "<p>Performing necessary upgrade queries..</p>";
    flush();
    $db->drop_table("templategroups");
    $db->write_query("CREATE TABLE " . TABLE_PREFIX . "templategroups (\n\t\tgid int unsigned NOT NULL auto_increment,\n\t\tprefix varchar(50) NOT NULL default '',\n\t\ttitle varchar(100) NOT NULL default '',\n\t\tPRIMARY KEY (gid)\n\t\t) ENGINE=MyISAM{$collation};");
    $db->write_query("INSERT INTO " . TABLE_PREFIX . "templategroups (gid,prefix,title) VALUES ('1','calendar','<lang:group_calendar>');");
    $db->write_query("INSERT INTO " . TABLE_PREFIX . "templategroups (gid,prefix,title) VALUES ('2','editpost','<lang:group_editpost>');");
    $db->write_query("INSERT INTO " . TABLE_PREFIX . "templategroups (gid,prefix,title) VALUES ('3','forumbit','<lang:group_forumbit>');");
    $db->write_query("INSERT INTO " . TABLE_PREFIX . "templategroups (gid,prefix,title) VALUES ('4','forumjump','<lang:group_forumjump>');");
    $db->write_query("INSERT INTO " . TABLE_PREFIX . "templategroups (gid,prefix,title) VALUES ('5','forumdisplay','<lang:group_forumdisplay>');");
    $db->write_query("INSERT INTO " . TABLE_PREFIX . "templategroups (gid,prefix,title) VALUES ('6','index','<lang:group_index>');");
    $db->write_query("INSERT INTO " . TABLE_PREFIX . "templategroups (gid,prefix,title) VALUES ('7','error','<lang:group_error>');");
    $db->write_query("INSERT INTO " . TABLE_PREFIX . "templategroups (gid,prefix,title) VALUES ('8','memberlist','<lang:group_memberlist>');");
    $db->write_query("INSERT INTO " . TABLE_PREFIX . "templategroups (gid,prefix,title) VALUES ('9','multipage','<lang:group_multipage>');");
    $db->write_query("INSERT INTO " . TABLE_PREFIX . "templategroups (gid,prefix,title) VALUES ('10','private','<lang:group_private>');");
    $db->write_query("INSERT INTO " . TABLE_PREFIX . "templategroups (gid,prefix,title) VALUES ('11','portal','<lang:group_portal>');");
    $db->write_query("INSERT INTO " . TABLE_PREFIX . "templategroups (gid,prefix,title) VALUES ('12','postbit','<lang:group_postbit>');");
    $db->write_query("INSERT INTO " . TABLE_PREFIX . "templategroups (gid,prefix,title) VALUES ('13','redirect','<lang:group_redirect>');");
    $db->write_query("INSERT INTO " . TABLE_PREFIX . "templategroups (gid,prefix,title) VALUES ('14','showthread','<lang:group_showthread>');");
    $db->write_query("INSERT INTO " . TABLE_PREFIX . "templategroups (gid,prefix,title) VALUES ('15','usercp','<lang:group_usercp>');");
    $db->write_query("INSERT INTO " . TABLE_PREFIX . "templategroups (gid,prefix,title) VALUES ('16','online','<lang:group_online>');");
    $db->write_query("INSERT INTO " . TABLE_PREFIX . "templategroups (gid,prefix,title) VALUES ('17','moderation','<lang:group_moderation>');");
    $db->write_query("INSERT INTO " . TABLE_PREFIX . "templategroups (gid,prefix,title) VALUES ('18','nav','<lang:group_nav>');");
    $db->write_query("INSERT INTO " . TABLE_PREFIX . "templategroups (gid,prefix,title) VALUES ('19','search','<lang:group_search>');");
    $db->write_query("INSERT INTO " . TABLE_PREFIX . "templategroups (gid,prefix,title) VALUES ('20','showteam','<lang:group_showteam>');");
    $db->write_query("INSERT INTO " . TABLE_PREFIX . "templategroups (gid,prefix,title) VALUES ('21','reputation','<lang:group_reputation>');");
    $db->write_query("INSERT INTO " . TABLE_PREFIX . "templategroups (gid,prefix,title) VALUES ('22','newthread','<lang:group_newthread>');");
    $db->write_query("INSERT INTO " . TABLE_PREFIX . "templategroups (gid,prefix,title) VALUES ('23','newreply','<lang:group_newreply>');");
    $db->write_query("INSERT INTO " . TABLE_PREFIX . "templategroups (gid,prefix,title) VALUES ('24','member','<lang:group_member>');");
    $db->write_query("INSERT INTO " . TABLE_PREFIX . "templategroups (gid,prefix,title) VALUES ('25','warnings','<lang:group_warning>');");
    $db->write_query("INSERT INTO " . TABLE_PREFIX . "templategroups (gid,prefix,title) VALUES ('26','global','<lang:group_global>');");
    $db->write_query("INSERT INTO " . TABLE_PREFIX . "templategroups (gid,prefix,title) VALUES ('27','header','<lang:group_header>');");
    $db->write_query("INSERT INTO " . TABLE_PREFIX . "templategroups (gid,prefix,title) VALUES ('28','managegroup','<lang:group_managegroup>');");
    $db->write_query("INSERT INTO " . TABLE_PREFIX . "templategroups (gid,prefix,title) VALUES ('29','misc','<lang:group_misc>');");
    $db->write_query("INSERT INTO " . TABLE_PREFIX . "templategroups (gid,prefix,title) VALUES ('30','modcp','<lang:group_modcp>');");
    $db->write_query("INSERT INTO " . TABLE_PREFIX . "templategroups (gid,prefix,title) VALUES ('31','php','<lang:group_php>');");
    $db->write_query("INSERT INTO " . TABLE_PREFIX . "templategroups (gid,prefix,title) VALUES ('32','polls','<lang:group_polls>');");
    $db->write_query("INSERT INTO " . TABLE_PREFIX . "templategroups (gid,prefix,title) VALUES ('33','post','<lang:group_post>');");
    $db->write_query("INSERT INTO " . TABLE_PREFIX . "templategroups (gid,prefix,title) VALUES ('34','printthread','<lang:group_printthread>');");
    $db->write_query("INSERT INTO " . TABLE_PREFIX . "templategroups (gid,prefix,title) VALUES ('35','report','<lang:group_report>');");
    $db->write_query("INSERT INTO " . TABLE_PREFIX . "templategroups (gid,prefix,title) VALUES ('36','smilieinsert','<lang:group_smilieinsert>');");
    $db->write_query("INSERT INTO " . TABLE_PREFIX . "templategroups (gid,prefix,title) VALUES ('37','stats','<lang:group_stats>');");
    $db->write_query("INSERT INTO " . TABLE_PREFIX . "templategroups (gid,prefix,title) VALUES ('38','xmlhttp','<lang:group_xmlhttp>');");
    $db->write_query("INSERT INTO " . TABLE_PREFIX . "templategroups (gid,prefix,title) VALUES ('39','footer','<lang:group_footer>');");
    $query = $db->query("SHOW INDEX FROM " . TABLE_PREFIX . "users");
    while ($ukey = $db->fetch_array($query)) {
        if ($ukey['Key_name'] == "username") {
            $index = $ukey;
            break;
        }
    }
    if ($index) {
        $db->write_query("ALTER TABLE " . TABLE_PREFIX . "users DROP KEY username");
    }
    $db->write_query("ALTER TABLE " . TABLE_PREFIX . "users ADD UNIQUE KEY username (username)");
    if ($db->field_exists('statustime', "privatemessages")) {
        $db->write_query("ALTER TABLE " . TABLE_PREFIX . "privatemessages DROP statustime;");
    }
    $db->write_query("ALTER TABLE " . TABLE_PREFIX . "privatemessages ADD statustime bigint(30) NOT NULL default '0' AFTER status");
    $collation = $db->build_create_table_collation();
    $db->drop_table("calendars");
    $db->drop_table("calendarpermissions");
    $db->drop_table("forumsread");
    $db->drop_table("adminviews");
    $db->drop_table("threadviews");
    $db->write_query("CREATE TABLE " . TABLE_PREFIX . "threadviews (\n\t\ttid int unsigned NOT NULL default '0'\n\t) ENGINE=MyISAM{$collation};");
    $db->write_query("CREATE TABLE " . TABLE_PREFIX . "calendars (\n\t  cid int unsigned NOT NULL auto_increment,\n\t  name varchar(100) NOT NULL default '',\n\t  disporder int unsigned NOT NULL default '0',\n\t  startofweek int(1) NOT NULL default '0',\n\t  showbirthdays int(1) NOT NULL default '0',\n\t  eventlimit int(3) NOT NULL default '0',\n\t  moderation int(1) NOT NULL default '0',\n\t  allowhtml int(1) NOT NULL default '0',\n\t  allowmycode int(1) NOT NULL default '0',\n\t  allowimgcode int(1) NOT NULL default '0',\n\t  allowsmilies int(1) NOT NULL default '0',\n\t  PRIMARY KEY(cid)\n\t) ENGINE=MyISAM{$collation};");
    $calendar_array = array('name' => 'Default Calendar', 'disporder' => 1, 'startofweek' => 0, 'showbirthdays' => 1, 'eventlimit' => 4, 'moderation' => 0, 'allowhtml' => 0, 'allowmycode' => 1, 'allowimgcode' => 1, 'allowsmilies' => 1);
    $db->insert_query("calendars", $calendar_array);
    $db->write_query("CREATE TABLE " . TABLE_PREFIX . "calendarpermissions (\n\t  cid int unsigned NOT NULL default '0',\n\t  gid int unsigned NOT NULL default '0',\n\t  canviewcalendar int(1) NOT NULL default '0',\n\t  canaddevents int(1) NOT NULL default '0',\n\t  canbypasseventmod int(1) NOT NULL default '0',\n\t  canmoderateevents int(1) NOT NULL default '0'\n\t) ENGINE=MyISAM{$collation};");
    $db->write_query("CREATE TABLE " . TABLE_PREFIX . "forumsread (\n\t  fid int unsigned NOT NULL default '0',\n\t  uid int unsigned NOT NULL default '0',\n\t  dateline int(10) NOT NULL default '0',\n\t  KEY dateline (dateline),\n\t  UNIQUE KEY fid (fid,uid)\n\t) ENGINE=MyISAM{$collation};");
    if ($db->field_exists('dateuploaded', "attachments")) {
        $db->write_query("ALTER TABLE " . TABLE_PREFIX . "attachments DROP dateuploaded;");
    }
    $db->write_query("ALTER TABLE " . TABLE_PREFIX . "attachments ADD dateuploaded bigint(30) NOT NULL default '0' AFTER downloads");
    $db->write_query("CREATE TABLE " . TABLE_PREFIX . "adminviews (\n\t\tvid int unsigned NOT NULL auto_increment,\n\t\tuid int unsigned NOT NULL default '0',\n\t\ttitle varchar(100) NOT NULL default '',\n\t\ttype varchar(6) NOT NULL default '',\n\t\tvisibility int(1) NOT NULL default '0',\n\t\t`fields` text NOT NULL,\n\t\tconditions text NOT NULL,\n\t\tsortby varchar(20) NOT NULL default '',\n\t\tsortorder varchar(4) NOT NULL default '',\n\t\tperpage int(4) NOT NULL default '0',\n\t\tview_type varchar(6) NOT NULL default '',\n\t\tPRIMARY KEY(vid)\n\t) ENGINE=MyISAM{$collation};");
    $views = file_get_contents(INSTALL_ROOT . 'resources/adminviews.xml');
    $parser = new XMLParser($views);
    $parser->collapse_dups = 0;
    $tree = $parser->get_tree();
    // Insert admin views
    foreach ($tree['adminviews'][0]['view'] as $view) {
        $fields = array();
        foreach ($view['fields'][0]['field'] as $field) {
            $fields[] = $field['attributes']['name'];
        }
        $conditions = array();
        if ($view['conditions'][0]['condition']) {
            foreach ($view['conditions'][0]['condition'] as $condition) {
                if (!$condition['value']) {
                    continue;
                }
                if ($condition['attributes']['is_serialized'] == 1) {
                    $condition['value'] = unserialize($condition['value']);
                }
                $conditions[$condition['attributes']['name']] = $condition['value'];
            }
        }
        $new_view = array("uid" => 0, "type" => $db->escape_string($view['attributes']['type']), "visibility" => intval($view['attributes']['visibility']), "title" => $db->escape_string($view['title'][0]['value']), "fields" => $db->escape_string(serialize($fields)), "conditions" => $db->escape_string(serialize($conditions)), "sortby" => $db->escape_string($view['sortby'][0]['value']), "sortorder" => $db->escape_string($view['sortorder'][0]['value']), "perpage" => intval($view['perpage'][0]['value']), "view_type" => $db->escape_string($view['view_type'][0]['value']));
        $db->insert_query("adminviews", $new_view);
        $view_count++;
    }
    $avatardimensions = str_replace('x', '|', my_strtolower($mybb->settings['postmaxavatarsize']));
    $db->simple_select("users", "uid", "avatar != '' AND avatardimensions = ''");
    while ($user = $db->fetch_array($query)) {
        $db->update_query("users", array('avatardimensions' => $avatardimensions), "uid='{$user['uid']}'", 1);
    }
    $contents = "Done</p>";
    $contents .= "<p>Click next to continue with the upgrade process.</p>";
    $output->print_contents($contents);
    global $footer_extra;
    $footer_extra = "<script type=\"text/javascript\">window.onload = function() { var button = \$\$('.submit_button'); if(button[0]) { button[0].value = 'Automatically Redirecting...'; button[0].disabled = true; button[0].style.color = '#aaa'; button[0].style.borderColor = '#aaa'; document.forms[0].submit(); }}</script>";
    $output->print_footer("12_redoconfig");
}
Exemplo n.º 6
0
function sync_tasks($redo = 0)
{
    global $db;
    $taskcount = 0;
    $tasks = array();
    if ($redo == 2) {
        $db->drop_table("tasks");
        switch ($db->type) {
            case "pgsql":
                $db->write_query("CREATE TABLE " . TABLE_PREFIX . "tasks (\n\t\t\t\t\ttid serial,\n\t\t\t\t\ttitle varchar(120) NOT NULL default '',\n\t\t\t\t\tdescription text NOT NULL default '',\n\t\t\t\t\tfile varchar(30) NOT NULL default '',\n\t\t\t\t\tminute varchar(200) NOT NULL default '',\n\t\t\t\t\thour varchar(200) NOT NULL default '',\n\t\t\t\t\tday varchar(100) NOT NULL default '',\n\t\t\t\t\tmonth varchar(30) NOT NULL default '',\n\t\t\t\t\tweekday varchar(15) NOT NULL default '',\n\t\t\t\t\tnextrun bigint NOT NULL default '0',\n\t\t\t\t\tlastrun bigint NOT NULL default '0',\n\t\t\t\t\tenabled int NOT NULL default '1',\n\t\t\t\t\tlogging int NOT NULL default '0',\n\t\t\t\t\tlocked bigint NOT NULL default '0',\n\t\t\t\t\tPRIMARY KEY(tid)\n\t\t\t\t);");
                break;
            case "sqlite":
                $db->write_query("CREATE TABLE " . TABLE_PREFIX . "tasks (\n\t\t\t\t\ttid INTEGER PRIMARY KEY,\n\t\t\t\t\ttitle varchar(120) NOT NULL default '',\n\t\t\t\t\tdescription TEXT NOT NULL,\n\t\t\t\t\tfile varchar(30) NOT NULL default '',\n\t\t\t\t\tminute varchar(200) NOT NULL default '',\n\t\t\t\t\thour varchar(200) NOT NULL default '',\n\t\t\t\t\tday varchar(100) NOT NULL default '',\n\t\t\t\t\tmonth varchar(30) NOT NULL default '',\n\t\t\t\t\tweekday varchar(15) NOT NULL default '',\n\t\t\t\t\tnextrun bigint(30) NOT NULL default '0',\n\t\t\t\t\tlastrun bigint(30) NOT NULL default '0',\n\t\t\t\t\tenabled int(1) NOT NULL default '1',\n\t\t\t\t\tlogging int(1) NOT NULL default '0',\n\t\t\t\t\tlocked bigint(30) NOT NULL default '0'\n\t\t\t\t);");
                break;
            case "mysql":
            default:
                $db->write_query("CREATE TABLE " . TABLE_PREFIX . "tasks (\n\t\t\t\t\ttid int unsigned NOT NULL auto_increment,\n\t\t\t\t\ttitle varchar(120) NOT NULL default '',\n\t\t\t\t\tdescription text NOT NULL,\n\t\t\t\t\tfile varchar(30) NOT NULL default '',\n\t\t\t\t\tminute varchar(200) NOT NULL default '',\n\t\t\t\t\thour varchar(200) NOT NULL default '',\n\t\t\t\t\tday varchar(100) NOT NULL default '',\n\t\t\t\t\tmonth varchar(30) NOT NULL default '',\n\t\t\t\t\tweekday varchar(15) NOT NULL default '',\n\t\t\t\t\tnextrun bigint(30) NOT NULL default '0',\n\t\t\t\t\tlastrun bigint(30) NOT NULL default '0',\n\t\t\t\t\tenabled int(1) NOT NULL default '1',\n\t\t\t\t\tlogging int(1) NOT NULL default '0',\n\t\t\t\t\tlocked bigint(30) NOT NULL default '0',\n\t\t\t\t\tPRIMARY KEY (tid)\n\t\t\t\t) ENGINE=MyISAM;");
        }
    } else {
        $query = $db->simple_select("tasks", "file,tid");
        while ($task = $db->fetch_array($query)) {
            $tasks[$task['file']] = $task['tid'];
        }
    }
    require_once MYBB_ROOT . "inc/functions_task.php";
    $task_file = file_get_contents(INSTALL_ROOT . 'resources/tasks.xml');
    $parser = new XMLParser($task_file);
    $parser->collapse_dups = 0;
    $tree = $parser->get_tree();
    // Resync tasks
    foreach ($tree['tasks'][0]['task'] as $task) {
        if (!$tasks[$task['file'][0]['value']] || $redo == 2) {
            $new_task = array('title' => $db->escape_string($task['title'][0]['value']), 'description' => $db->escape_string($task['description'][0]['value']), 'file' => $db->escape_string($task['file'][0]['value']), 'minute' => $db->escape_string($task['minute'][0]['value']), 'hour' => $db->escape_string($task['hour'][0]['value']), 'day' => $db->escape_string($task['day'][0]['value']), 'weekday' => $db->escape_string($task['weekday'][0]['value']), 'month' => $db->escape_string($task['month'][0]['value']), 'enabled' => $db->escape_string($task['enabled'][0]['value']), 'logging' => $db->escape_string($task['logging'][0]['value']));
            $new_task['nextrun'] = fetch_next_run($new_task);
            $db->insert_query("tasks", $new_task);
            $taskcount++;
        } else {
            $update_task = array('title' => $db->escape_string($task['title'][0]['value']), 'description' => $db->escape_string($task['description'][0]['value']), 'file' => $db->escape_string($task['file'][0]['value']));
            $db->update_query("tasks", $update_task, "file='" . $db->escape_string($task['file'][0]['value']) . "'");
        }
    }
    return $taskcount;
}
Exemplo n.º 7
0
function upgrade30_updatetheme()
{
    global $db, $mybb, $output, $config;
    if (file_exists(MYBB_ROOT . $mybb->config['admin_dir'] . "/inc/functions_themes.php")) {
        require_once MYBB_ROOT . $mybb->config['admin_dir'] . "/inc/functions_themes.php";
    } else {
        if (file_exists(MYBB_ROOT . "admin/inc/functions_themes.php")) {
            require_once MYBB_ROOT . "admin/inc/functions_themes.php";
        } else {
            $output->print_error("Please make sure your admin directory is uploaded correctly.");
        }
    }
    $output->print_header("Updating Themes");
    // New default user star
    $contents = "<p>Updating the Default user star image... ";
    $db->update_query("usergroups", array('starimage' => 'images/star.png'), "starimage='images/star.gif'");
    $contents .= "done.</p>";
    $contents .= "<p>Adding new stylesheets... ";
    $query = $db->simple_select("themes", "*", "tid='1'");
    $theme = $db->fetch_array($query);
    $properties = my_unserialize($theme['properties']);
    $stylesheets = my_unserialize($theme['stylesheets']);
    $old = array("global.css", "usercp.css", "modcp.css", "star_ratings.css");
    require_once MYBB_ROOT . "inc/class_xml.php";
    $colors = @file_get_contents(INSTALL_ROOT . 'resources/mybb_theme.xml');
    $parser = new XMLParser($colors);
    $tree = $parser->get_tree();
    if (is_array($tree) && is_array($tree['theme'])) {
        if (is_array($tree['theme']['stylesheets'])) {
            foreach ($tree['theme']['stylesheets']['stylesheet'] as $stylesheet) {
                $new_stylesheet = array("name" => $db->escape_string($stylesheet['attributes']['name']), "tid" => 1, "attachedto" => $db->escape_string($stylesheet['attributes']['attachedto']), "stylesheet" => $db->escape_string($stylesheet['value']), "lastmodified" => TIME_NOW, "cachefile" => $db->escape_string($stylesheet['attributes']['name']));
                if (in_array($new_stylesheet['name'], $old)) {
                    // We can update the disporder here
                    $properties['disporder'][$stylesheet['attributes']['name']] = $stylesheet['attributes']['disporder'];
                } else {
                    // Insert new stylesheet
                    $sid = $db->insert_query("themestylesheets", $new_stylesheet);
                    $css_url = "css.php?stylesheet={$sid}";
                    $cached = cache_stylesheet($tid, $stylesheet['attributes']['name'], $stylesheet['value']);
                    if ($cached) {
                        $css_url = $cached;
                    }
                    // Add to display and stylesheet list
                    $properties['disporder'][$stylesheet['attributes']['name']] = $stylesheet['attributes']['disporder'];
                    $attachedto = $stylesheet['attributes']['attachedto'];
                    if (!$attachedto) {
                        $attachedto = "global";
                    }
                    // private.php?compose,folders|usercp.php,global|global
                    $attachedto = explode("|", $attachedto);
                    foreach ($attachedto as $attached_file) {
                        $attached_actions = explode(",", $attached_file);
                        $attached_file = array_shift($attached_actions);
                        if (count($attached_actions) == 0) {
                            $attached_actions = array("global");
                        }
                        foreach ($attached_actions as $action) {
                            $stylesheets[$attached_file][$action][] = $css_url;
                        }
                    }
                }
            }
        }
    }
    $update_array = array("properties" => $db->escape_string(my_serialize($properties)), "stylesheets" => $db->escape_string(my_serialize($stylesheets)));
    $db->update_query("themes", $update_array, "tid = '1'");
    $contents .= "done.</p>";
    $contents .= "<p>Adding a disporder to all stylesheets... ";
    $query = $db->simple_select("themes", "tid,properties,stylesheets");
    while ($theme = $db->fetch_array($query)) {
        $properties = my_unserialize($theme['properties']);
        $stylesheets = my_unserialize($theme['stylesheets']);
        // Disporder already set?
        if (isset($properties['disporder']) && !empty($properties['disporder'])) {
            continue;
        }
        $disporder = 1;
        // First go through all own stylesheets
        $query2 = $db->simple_select("themestylesheets", "name", "tid='{$theme['tid']}'");
        while ($name = $db->fetch_field($query2, "name")) {
            $properties['disporder'][$name] = $disporder;
            $disporder++;
        }
        // Next go through the inherited stylesheets
        if (!empty($stylesheets)) {
            foreach ($stylesheets as $a) {
                foreach ($a as $file => $stylesheet) {
                    // Don't ask me... Throws an error otherwise
                    if (empty($stylesheet)) {
                        continue;
                    }
                    foreach ($stylesheet as $s) {
                        $name = pathinfo($s, PATHINFO_BASENAME);
                        if (empty($properties['disporder']) || !in_array($name, array_keys($properties['disporder']))) {
                            $properties['disporder'][$name] = $disporder;
                            $disporder++;
                        }
                    }
                }
            }
        }
        $db->update_query("themes", array("properties" => $db->escape_string(my_serialize($properties))), "tid='{$theme['tid']}'");
    }
    $contents .= "done.</p>";
    $contents .= "<p>Adding the Default colors... ";
    $query = $db->simple_select("themes", "*", "tid = '2'");
    // Someone deleted the default theme... :o
    if ($db->num_rows($query) != 0) {
        $theme = $db->fetch_array($query);
        $properties = my_unserialize($theme['properties']);
        $stylesheets = my_unserialize($theme['stylesheets']);
        $properties['editortheme'] = "mybb.css";
        // New editor, so reset the theme for it
        $properties['tablespace'] = 5;
        $properties['borderwidth'] = 0;
        // Reset the logo if it's still the default one
        if ($properties['logo'] == "images/logo.gif") {
            $properties['logo'] = "images/logo.png";
        }
        require_once MYBB_ROOT . "inc/class_xml.php";
        $colors = @file_get_contents(INSTALL_ROOT . 'resources/mybb_theme_colors.xml');
        $parser = new XMLParser($colors);
        $tree = $parser->get_tree();
        if (is_array($tree) && is_array($tree['colors'])) {
            if (is_array($tree['colors']['scheme'])) {
                foreach ($tree['colors']['scheme'] as $tag => $value) {
                    $exp = explode("=", $value['value']);
                    $properties['colors'][$exp[0]] = $exp[1];
                }
            }
            if (is_array($tree['colors']['stylesheets'])) {
                $count = count($properties['disporder']) + 1;
                foreach ($tree['colors']['stylesheets']['stylesheet'] as $stylesheet) {
                    $new_stylesheet = array("name" => $db->escape_string($stylesheet['attributes']['name']), "tid" => 2, "attachedto" => $db->escape_string($stylesheet['attributes']['attachedto']), "stylesheet" => $db->escape_string($stylesheet['value']), "lastmodified" => TIME_NOW, "cachefile" => $db->escape_string($stylesheet['attributes']['name']));
                    $sid = $db->insert_query("themestylesheets", $new_stylesheet);
                    $css_url = "css.php?stylesheet={$sid}";
                    $cached = cache_stylesheet($tid, $stylesheet['attributes']['name'], $stylesheet['value']);
                    if ($cached) {
                        $css_url = $cached;
                    }
                    // Add to display and stylesheet list
                    $properties['disporder'][$stylesheet['attributes']['name']] = $count;
                    $stylesheets[$stylesheet['attributes']['attachedto']]['global'][] = $css_url;
                    ++$count;
                }
            }
            $update_array = array("properties" => $db->escape_string(my_serialize($properties)), "stylesheets" => $db->escape_string(my_serialize($stylesheets)));
            $db->update_query("themes", $update_array, "tid = '2'");
        }
    }
    $contents .= "done.</p>";
    $contents .= '<p>Re-caching and minifying existing stylesheets...</p>';
    $num_re_cached = recache_existing_styles();
    $contents .= "Done. {$num_re_cached} stylesheets re-cached.";
    echo $contents;
    $output->print_contents("<p>Click next to continue with the upgrade process.</p>");
    if (!isset($config['secret_pin']) && is_writable(MYBB_ROOT . "inc/config.php")) {
        $output->print_footer("30_acppin");
    } else {
        $output->print_footer("30_done");
    }
}
Exemplo n.º 8
0
function asb_admin_custom_boxes()
{
    global $lang, $mybb, $db, $page, $html, $min;
    if ($mybb->input['mode'] == 'export') {
        if ((int) $mybb->input['id'] == 0) {
            flash_message($lang->asb_custom_export_error, 'error');
            admin_redirect($html->url(array("action" => 'custom_boxes')));
        }
        $this_custom = new Custom_type($mybb->input['id']);
        if (!$this_custom->is_valid()) {
            flash_message($lang->asb_custom_export_error, 'error');
            admin_redirect($html->url(array("action" => 'custom_boxes')));
        }
        $this_custom->export();
        exit;
    }
    if ($mybb->input['mode'] == 'delete') {
        // info good?
        if ((int) $mybb->input['id'] == 0) {
            flash_message($lang->asb_add_custom_box_delete_failure, 'error');
            admin_redirect($html->url(array("action" => 'custom_boxes')));
        }
        // nuke it
        $this_custom = new Custom_type($mybb->input['id']);
        // success?
        if (!$this_custom->remove()) {
            flash_message($lang->asb_add_custom_box_delete_failure, 'error');
            admin_redirect($html->url(array("action" => 'custom_boxes')));
        }
        // :)
        flash_message($lang->asb_add_custom_box_delete_success, 'success');
        asb_cache_has_changed();
        admin_redirect($html->url(array("action" => 'custom_boxes')));
    }
    // POSTing?
    if ($mybb->request_method == 'post') {
        if ($mybb->input['mode'] == 'import') {
            if (!$_FILES['file'] || $_FILES['file']['error'] == 4) {
                flash_message($lang->asb_custom_import_no_file, 'error');
                admin_redirect($html->url(array("action" => 'custom_boxes')));
            }
            if ($_FILES['file']['error']) {
                flash_message($lang->sprintf($lang->asb_custom_import_file_error, $_FILES['file']['error']), 'error');
                admin_redirect($html->url(array("action" => 'custom_boxes')));
            }
            if (!is_uploaded_file($_FILES['file']['tmp_name'])) {
                flash_message($lang->asb_custom_import_file_upload_error, 'error');
                admin_redirect($html->url(array("action" => 'custom_boxes')));
            }
            $contents = @file_get_contents($_FILES['file']['tmp_name']);
            @unlink($_FILES['file']['tmp_name']);
            if (!trim($contents)) {
                flash_message($lang->asb_custom_import_file_empty, 'error');
                admin_redirect($html->url(array("action" => 'custom_boxes')));
            }
            require_once MYBB_ROOT . 'inc/class_xml.php';
            $parser = new XMLParser($contents);
            $tree = $parser->get_tree();
            if (!is_array($tree) || empty($tree)) {
                flash_message($lang->asb_custom_import_file_empty, 'error');
                admin_redirect($html->url(array("action" => 'custom_boxes')));
            }
            if (!is_array($tree['asb_custom_sideboxes']) || empty($tree['asb_custom_sideboxes'])) {
                if (!is_array($tree['adv_sidebox']) || !is_array($tree['adv_sidebox']['custom_sidebox'])) {
                    flash_message($lang->asb_custom_import_file_empty, 'error');
                    admin_redirect($html->url(array("action" => 'custom_boxes')));
                }
                $results = asb_legacy_custom_import($tree);
                if (!is_array($results)) {
                    flash_message($results, 'error');
                    admin_redirect($html->url(array("action" => 'custom_boxes')));
                }
                $custom = new Custom_type($results);
            } else {
                $custom = new Custom_type();
                if (!$custom->import($contents)) {
                    flash_message($lang->asb_custom_import_fail_generic, 'error');
                    admin_redirect($html->url(array("action" => 'custom_boxes')));
                }
            }
            if (!$custom->save()) {
                flash_message($lang->asb_custom_box_save_failure, 'error');
                admin_redirect($html->url(array("action" => 'custom_boxes')));
            }
            flash_message($lang->asb_custom_import_save_success, 'success');
            admin_redirect($html->url(array("action" => 'custom_boxes', "id" => $custom->get('id'))));
        } else {
            // saving?
            if ($mybb->input['save_box_submit'] == 'Save') {
                if (!$mybb->input['box_name'] || !$mybb->input['box_content']) {
                    flash_message($lang->asb_custom_box_save_failure_no_content, 'error');
                    admin_redirect($html->url(array("action" => 'custom_boxes')));
                }
                $this_custom = new Custom_type((int) $mybb->input['id']);
                // get the info
                $this_custom->set('title', $mybb->input['box_name']);
                $this_custom->set('description', $mybb->input['box_description']);
                $this_custom->set('content', $mybb->input['box_content']);
                $this_custom->set('wrap_content', $mybb->input['wrap_content'] == 'yes');
                // success?
                if (!$this_custom->save()) {
                    flash_message($lang->asb_custom_box_save_failure, 'error');
                    admin_redirect($html->url(array("action" => 'custom_boxes', "id" => $this_custom->get('id'))));
                }
                flash_message($lang->asb_custom_box_save_success, 'success');
                asb_cache_has_changed();
                admin_redirect($html->url(array("action" => 'custom_boxes', "id" => $this_custom->get('id'))));
            }
        }
    }
    $page->add_breadcrumb_item($lang->asb, $html->url());
    if ($mybb->input['mode'] == 'edit') {
        $queryadmin = $db->simple_select('adminoptions', '*', "uid='{$mybb->user['uid']}'");
        $admin_options = $db->fetch_array($queryadmin);
        if ($admin_options['codepress'] != 0) {
            $page->extra_header .= <<<EOF
\t<link type="text/css" href="./jscripts/codepress/languages/codepress-mybb.css" rel="stylesheet" id="cp-lang-style"/>
\t<script type="text/javascript" src="./jscripts/codepress/codepress.js"></script>
\t<script type="text/javascript">
\t<!--
\t\tCodePress.language = 'mybb';
\t// -->
\t</script>
EOF;
        }
        $this_box = new Custom_type((int) $mybb->input['id']);
        $action = $lang->asb_add_custom;
        if ($this_box->get('id')) {
            $specify_box = '&amp;id=' . $this_box->get('id');
            $currently_editing = $lang->asb_editing . ': <strong>' . $this_box->get('title') . '</strong>';
            $action = $lang->asb_edit . ' ' . $this_box->get('title');
        } else {
            // new box
            $specify_box = '';
            $sample_content = <<<EOF
<tr>
\t\t<td class="trow1">{$lang->asb_sample_content_line1} (HTML)</td>
\t</tr>
\t<tr>
\t\t<td class="trow2">{$lang->asb_sample_content_line2}</td>
\t</tr>
\t<tr>
\t\t<td class="trow1"><strong>{$lang->asb_sample_content_line3}</td>
\t</tr>
EOF;
            $this_box->set('content', $sample_content);
            $this_box->set('wrap_content', true);
        }
        $page->extra_header .= <<<EOF
\t<link rel="stylesheet" type="text/css" href="styles/asb_acp.css" media="screen" />
\t<script src="jscripts/asb/asb{$min}.js" type="text/javascript"></script>
EOF;
        $page->add_breadcrumb_item($lang->asb_custom_boxes, $html->url(array("action" => 'custom_boxes')));
        $page->add_breadcrumb_item($lang->asb_add_custom);
        $page->output_header("{$lang->asb} - {$action}");
        asb_output_tabs('asb_add_custom');
        $form = new Form($html->url(array("action" => 'custom_boxes')) . $specify_box, 'post', 'edit_box');
        $form_container = new FormContainer($currently_editing);
        $form_container->output_cell($lang->asb_name);
        $form_container->output_cell($lang->asb_description);
        $form_container->output_cell($lang->asb_custom_box_wrap_content);
        $form_container->output_row('');
        // name
        $form_container->output_cell($form->generate_text_box('box_name', $this_box->get('title'), array("id" => 'box_name')));
        // description
        $form_container->output_cell($form->generate_text_box('box_description', $this_box->get('description')));
        // wrap content?
        $form_container->output_cell($form->generate_check_box('wrap_content', 'yes', $lang->asb_custom_box_wrap_content_desc, array("checked" => $this_box->get('wrap_content'))));
        $form_container->output_row('');
        $form_container->output_cell('Content:', array("colspan" => 3));
        $form_container->output_row('');
        // content
        $form_container->output_cell($form->generate_text_area('box_content', $this_box->get('content'), array("id" => 'box_content', 'class' => 'codepress mybb', 'style' => 'width: 100%; height: 240px;')), array("colspan" => 3));
        $form_container->output_row('');
        // finish form
        $form_container->end();
        $buttons[] = $form->generate_submit_button('Save', array('name' => 'save_box_submit'));
        $form->output_submit_wrapper($buttons);
        $form->end();
        if ($admin_options['codepress'] != 0) {
            echo <<<EOF
\t\t<script type="text/javascript">
\t\t<!--
\t\t\tEvent.observe('edit_box', 'submit', function() {
\t\t\t\tif (\$('box_content_cp')) {
\t\t\t\t\tvar area = \$('box_content_cp');
\t\t\t\t\tarea.id = 'box_content';
\t\t\t\t\tarea.value = box_content.getCode();
\t\t\t\t\tarea.disabled = false;
\t\t\t\t}
\t\t\t});
\t\t// -->
\t\t</script>
EOF;
            // build link bar and ACP footer
            asb_output_footer('edit_custom');
        }
    }
    $page->extra_header .= <<<EOF
\t<link rel="stylesheet" type="text/css" href="styles/asb_acp.css" media="screen" />
\t<script src="jscripts/asb/asb{$min}.js" type="text/javascript"></script>
EOF;
    $page->add_breadcrumb_item($lang->asb_custom_boxes);
    $page->output_header("{$lang->asb} - {$lang->asb_custom_boxes}");
    asb_output_tabs('asb_custom');
    $new_box_url = $html->url(array("action" => 'custom_boxes', "mode" => 'edit'));
    $new_box_link = $html->link($new_box_url, $lang->asb_add_custom_box_types, array("style" => 'font-weight: bold;', "title" => $lang->asb_add_custom_box_types, "icon" => "{$mybb->settings['bburl']}/inc/plugins/asb/images/add.png"), array("alt" => '+', "style" => 'margin-bottom: -3px;', "title" => $lang->asb_add_custom_box_types));
    echo $new_box_link . '<br /><br />';
    $table = new Table();
    $table->construct_header($lang->asb_name);
    $table->construct_header($lang->asb_custom_box_desc);
    $table->construct_header($lang->asb_controls, array("colspan" => 2));
    $custom = asb_get_all_custom();
    // if there are saved types . . .
    if (is_array($custom) && !empty($custom)) {
        // display them
        foreach ($custom as $this_custom) {
            $data = $this_custom->get('data');
            // name (edit link)
            $edit_url = $html->url(array("action" => 'custom_boxes', "mode" => 'edit', "id" => $data['id']));
            $edit_link = $html->link($edit_url, $data['title'], array("title" => $lang->asb_edit, "style" => 'font-weight: bold;'));
            $table->construct_cell($edit_link, array("width" => '30%'));
            // description
            if ($data['description']) {
                $description = $data['description'];
            } else {
                $description = "<em>{$lang->asb_no_description}</em>";
            }
            $table->construct_cell($description, array("width" => '60%'));
            // options popup
            $popup = new PopupMenu('box_' . $data['id'], $lang->asb_options);
            // edit
            $popup->add_item($lang->asb_edit, $edit_url);
            // delete
            $popup->add_item($lang->asb_delete, $html->url(array("action" => 'custom_boxes', "mode" => 'delete', "id" => $data['id'])), "return confirm('{$lang->asb_custom_del_warning}');");
            // export
            $popup->add_item($lang->asb_custom_export, $html->url(array("action" => 'custom_boxes', "mode" => 'export', "id" => $data['id'])));
            // popup cell
            $table->construct_cell($popup->fetch(), array("width" => '10%'));
            // finish the table
            $table->construct_row();
        }
    } else {
        // no saved types
        $table->construct_cell($lang->asb_no_custom_boxes, array("colspan" => 4));
        $table->construct_row();
    }
    $table->output($lang->asb_custom_box_types);
    echo '<br /><br />';
    $import_form = new Form($html->url(array("action" => 'custom_boxes', "mode" => 'import')), 'post', '', 1);
    $import_form_container = new FormContainer($lang->asb_custom_import);
    $import_form_container->output_row($lang->asb_custom_import_select_file, '', $import_form->generate_file_upload_box('file'));
    $import_form_container->end();
    $import_buttons[] = $import_form->generate_submit_button($lang->asb_custom_import, array('name' => 'import'));
    $import_form->output_submit_wrapper($import_buttons);
    $import_form->end();
    // build link bar and ACP footer
    asb_output_footer('custom');
}
Exemplo n.º 9
0
/**
 * Import an entire theme (stylesheets, properties & templates) from an XML file.
 *
 * @param string The contents of the XML file
 * @param array Optional array of options or overrides
 * @return boolean True on success, false on failure
 */
function import_theme_xml($xml, $options = array())
{
    global $mybb, $db;
    require_once MYBB_ROOT . "inc/class_xml.php";
    $parser = new XMLParser($xml);
    $tree = $parser->get_tree();
    if (!is_array($tree) || !is_array($tree['theme'])) {
        return -1;
    }
    $theme = $tree['theme'];
    // Do we have MyBB 1.2 template's we're importing?
    $css_120 = "";
    if (is_array($theme['cssbits'])) {
        $cssbits = kill_tags($theme['cssbits']);
        foreach ($cssbits as $name => $values) {
            $css_120 .= "{$name} {\n";
            foreach ($values as $property => $value) {
                if (is_array($value)) {
                    $property = str_replace('_', ':', $property);
                    $css_120 .= "}\n{$name} {$property} {\n";
                    foreach ($value as $property2 => $value2) {
                        $css_120 .= "\t{$property2}: {$value2}\n";
                    }
                } else {
                    $css_120 .= "\t{$property}: {$value}\n";
                }
            }
            $css_120 .= "}\n";
        }
    }
    if (is_array($theme['themebits'])) {
        $themebits = kill_tags($theme['themebits']);
        $theme['properties']['tag'] = 'properties';
        foreach ($themebits as $name => $value) {
            if ($name == "extracss") {
                $css_120 .= $value;
                continue;
            }
            $theme['properties'][$name] = $value;
        }
    }
    if ($css_120) {
        $css_120 = upgrade_css_120_to_140($css_120);
        $theme['stylesheets']['tag'] = 'stylesheets';
        $theme['stylesheets']['stylesheet'][0]['tag'] = 'stylesheet';
        $theme['stylesheets']['stylesheet'][0]['attributes'] = array('name' => 'global.css', 'version' => $mybb->version_code);
        $theme['stylesheets']['stylesheet'][0]['value'] = $css_120;
        unset($theme['cssbits']);
        unset($theme['themebits']);
    }
    if (is_array($theme['properties'])) {
        foreach ($theme['properties'] as $property => $value) {
            if ($property == "tag" || $property == "value") {
                continue;
            }
            $properties[$property] = $value['value'];
        }
    }
    if (empty($mybb->input['name'])) {
        $name = $theme['attributes']['name'];
    } else {
        $name = $mybb->input['name'];
    }
    $version = $theme['attributes']['version'];
    $query = $db->simple_select("themes", "tid", "name='" . $db->escape_string($name) . "'", array("limit" => 1));
    $existingtheme = $db->fetch_array($query);
    if ($options['force_name_check'] && $existingtheme['tid']) {
        return -3;
    } else {
        if ($existingtheme['tid']) {
            $options['tid'] = $existingtheme['tid'];
        }
    }
    if ($mybb->version_code != $version && $options['version_compat'] != 1) {
        return -2;
    }
    // Do we have any templates to insert?
    if (!empty($theme['templates']['template']) && !$options['no_templates']) {
        if ($options['templateset']) {
            $sid = $options['templateset'];
        } else {
            $sid = $db->insert_query("templatesets", array('title' => $db->escape_string($name) . " Templates"));
        }
        $templates = $theme['templates']['template'];
        if (is_array($templates)) {
            // Theme only has one custom template
            if (array_key_exists("attributes", $templates)) {
                $templates = array($templates);
            }
        }
        $security_check = false;
        $templatecache = array();
        foreach ($templates as $template) {
            if (check_template($template['value'])) {
                $security_check = true;
                break;
            }
            $templatecache[] = array("title" => $db->escape_string($template['attributes']['name']), "template" => $db->escape_string($template['value']), "sid" => $db->escape_string($sid), "version" => $db->escape_string($template['attributes']['version']), "dateline" => TIME_NOW);
        }
        if ($security_check == true) {
            return -4;
        }
        foreach ($templatecache as $template) {
            // PostgreSQL causes apache to stop sending content sometimes and
            // causes the page to stop loading during many queries all at one time
            if ($db->engine == "pgsql") {
                echo " ";
                flush();
            }
            $db->insert_query("templates", $template);
        }
        $properties['templateset'] = $sid;
    }
    // Not overriding an existing theme
    if (!$options['tid']) {
        // Insert the theme
        $theme_id = build_new_theme($name, $properties, $options['parent']);
    } else {
        $db->delete_query("themestylesheets", "tid='{$options['tid']}'");
        $db->update_query("themes", array("properties" => $db->escape_string(serialize($properties))), "tid='{$options['tid']}'");
        $theme_id = $options['tid'];
    }
    // If we have any stylesheets, process them
    if (!empty($theme['stylesheets']['stylesheet']) && !$options['no_stylesheets']) {
        // Are we dealing with a single stylesheet?
        if (isset($theme['stylesheets']['stylesheet']['tag'])) {
            // Trick the system into thinking we have a good array =P
            $theme['stylesheets']['stylesheet'] = array($theme['stylesheets']['stylesheet']);
        }
        foreach ($theme['stylesheets']['stylesheet'] as $stylesheet) {
            if (substr($stylesheet['attributes']['name'], -4) != ".css") {
                continue;
            }
            if (!$stylesheet['attributes']['lastmodified']) {
                $stylesheet['attributes']['lastmodified'] = TIME_NOW;
            }
            $new_stylesheet = array("name" => $db->escape_string($stylesheet['attributes']['name']), "tid" => $theme_id, "attachedto" => $db->escape_string($stylesheet['attributes']['attachedto']), "stylesheet" => $db->escape_string($stylesheet['value']), "lastmodified" => intval($stylesheet['attributes']['lastmodified']), "cachefile" => $db->escape_string($stylesheet['attributes']['name']));
            $sid = $db->insert_query("themestylesheets", $new_stylesheet);
            $css_url = "css.php?stylesheet={$sid}";
            $cached = cache_stylesheet($theme_id, $stylesheet['attributes']['name'], $stylesheet['value']);
            if ($cached) {
                $css_url = $cached;
            }
            $attachedto = $stylesheet['attributes']['attachedto'];
            if (!$attachedto) {
                $attachedto = "global";
            }
            // private.php?compose,folders|usercp.php,global|global
            $attachedto = explode("|", $attachedto);
            foreach ($attachedto as $attached_file) {
                $attached_actions = explode(",", $attached_file);
                $attached_file = array_shift($attached_actions);
                if (count($attached_actions) == 0) {
                    $attached_actions = array("global");
                }
                foreach ($attached_actions as $action) {
                    $theme_stylesheets[$attached_file][$action][] = $css_url;
                }
            }
        }
        // Now we have our list of built stylesheets, save them
        $updated_theme = array("stylesheets" => $db->escape_string(serialize($theme_stylesheets)));
        $db->update_query("themes", $updated_theme, "tid='{$theme_id}'");
    }
    update_theme_stylesheet_list($theme_id);
    // And done?
    return $theme_id;
}
Exemplo n.º 10
0
function sync_settings($redo = 0)
{
    global $db;
    $settingcount = $groupcount = 0;
    if ($redo == 2) {
        $db->drop_table("settinggroups");
        $db->write_query("CREATE TABLE " . TABLE_PREFIX . "settinggroups (\n\t\t  gid smallint unsigned NOT NULL auto_increment,\n\t\t  name varchar(100) NOT NULL default '',\n\t\t  title varchar(220) NOT NULL default '',\n\t\t  description text NOT NULL,\n\t\t  disporder smallint unsigned NOT NULL default '0',\n\t\t  isdefault int(1) NOT NULL default '0',\n\t\t  PRIMARY KEY  (gid)\n\t\t) TYPE=MyISAM;");
        $db->drop_table("settings");
        $db->write_query("CREATE TABLE " . TABLE_PREFIX . "settings (\n\t\t  sid smallint unsigned NOT NULL auto_increment,\n\t\t  name varchar(120) NOT NULL default '',\n\t\t  title varchar(120) NOT NULL default '',\n\t\t  description text NOT NULL,\n\t\t  optionscode text NOT NULL,\n\t\t  value text NOT NULL,\n\t\t  disporder smallint unsigned NOT NULL default '0',\n\t\t  gid smallint unsigned NOT NULL default '0',\n\t\t  isdefault int(1) NOT NULL default '0',\n\t\t  PRIMARY KEY (sid)\n\t\t) TYPE=MyISAM;");
    } else {
        if ($db->type == "mysql" || $db->type == "mysqli") {
            $wheresettings = "isdefault='1' OR isdefault='yes'";
        } else {
            $wheresettings = "isdefault='1'";
        }
        $query = $db->simple_select("settings", "name,sid", $wheresettings);
        while ($setting = $db->fetch_array($query)) {
            $settings[$setting['name']] = $setting['sid'];
        }
        $query = $db->simple_select("settinggroups", "name,title,gid", $wheresettings);
        while ($group = $db->fetch_array($query)) {
            $settinggroups[$group['name']] = $group['gid'];
        }
    }
    $settings_xml = file_get_contents(INSTALL_ROOT . "resources/settings.xml");
    $parser = new XMLParser($settings_xml);
    $parser->collapse_dups = 0;
    $tree = $parser->get_tree();
    $settinggroupnames = array();
    $settingnames = array();
    foreach ($tree['settings'][0]['settinggroup'] as $settinggroup) {
        $settinggroupnames[] = $settinggroup['attributes']['name'];
        $groupdata = array("name" => $db->escape_string($settinggroup['attributes']['name']), "title" => $db->escape_string($settinggroup['attributes']['title']), "description" => $db->escape_string($settinggroup['attributes']['description']), "disporder" => intval($settinggroup['attributes']['disporder']), "isdefault" => $settinggroup['attributes']['isdefault']);
        if (!$settinggroups[$settinggroup['attributes']['name']] || $redo == 2) {
            $gid = $db->insert_query("settinggroups", $groupdata);
            ++$groupcount;
        } else {
            $gid = $settinggroups[$settinggroup['attributes']['name']];
            $db->update_query("settinggroups", $groupdata, "gid='{$gid}'");
        }
        if (!$gid) {
            continue;
        }
        foreach ($settinggroup['setting'] as $setting) {
            $settingnames[] = $setting['attributes']['name'];
            $settingdata = array("name" => $db->escape_string($setting['attributes']['name']), "title" => $db->escape_string($setting['title'][0]['value']), "description" => $db->escape_string($setting['description'][0]['value']), "optionscode" => $db->escape_string($setting['optionscode'][0]['value']), "disporder" => intval($setting['disporder'][0]['value']), "gid" => $gid, "isdefault" => 1);
            if (!$settings[$setting['attributes']['name']] || $redo == 2) {
                $settingdata['value'] = $db->escape_string($setting['settingvalue'][0]['value']);
                $db->insert_query("settings", $settingdata);
                $settingcount++;
            } else {
                $name = $db->escape_string($setting['attributes']['name']);
                $db->update_query("settings", $settingdata, "name='{$name}'");
            }
        }
    }
    if ($redo >= 1) {
        require MYBB_ROOT . "inc/settings.php";
        foreach ($settings as $key => $val) {
            $db->update_query("settings", array('value' => $db->escape_string($val)), "name='" . $db->escape_string($key) . "'");
        }
    }
    unset($settings);
    $query = $db->simple_select("settings", "*", "", array('order_by' => 'title'));
    while ($setting = $db->fetch_array($query)) {
        $setting['value'] = str_replace("\"", "\\\"", $setting['value']);
        $settings .= "\$settings['{$setting['name']}'] = \"" . $setting['value'] . "\";\n";
    }
    $settings = "<?php\n/*********************************\\ \n  DO NOT EDIT THIS FILE, PLEASE USE\n  THE SETTINGS EDITOR\n\\*********************************/\n\n{$settings}\n?>";
    $file = fopen(MYBB_ROOT . "inc/settings.php", "w");
    fwrite($file, $settings);
    fclose($file);
    return array($groupcount, $settingcount);
}
Exemplo n.º 11
0
 public function import($xml)
 {
     if ($xml) {
         require_once MYBB_ROOT . 'inc/class_xml.php';
         $parser = new XMLParser($xml);
         $tree = $parser->get_tree();
         // only doing a single backup, fail if multi detected
         if (is_array($tree) && is_array($tree[$this->table_name])) {
             foreach ($tree[$this->table_name] as $property => $this_entry) {
                 // skip the info
                 if (in_array($property, array('tag', 'value', 'attributes'))) {
                     continue;
                 }
                 // if there is data
                 if (is_array($this_entry) && !empty($this_entry)) {
                     foreach ($this_entry as $key => $value) {
                         // skip the info
                         if (in_array($key, array('tag', 'value'))) {
                             continue;
                         }
                         // get the field name from the array key
                         $key_array = explode('-', $key);
                         $newkey = $key_array[0];
                         // is it a valid property name for this object?
                         if (property_exists($this, $newkey)) {
                             // then store it
                             $this->{$newkey} = $value['value'];
                         }
                     }
                 }
             }
             return true;
         }
     }
     return false;
 }
Exemplo n.º 12
0
function install_done()
{
    global $output, $db, $mybb, $errors, $cache, $lang;
    if (empty($mybb->input['adminuser'])) {
        $errors[] = $lang->admin_step_error_nouser;
    }
    if (empty($mybb->input['adminpass'])) {
        $errors[] = $lang->admin_step_error_nopassword;
    }
    if ($mybb->input['adminpass'] != $mybb->input['adminpass2']) {
        $errors[] = $lang->admin_step_error_nomatch;
    }
    if (empty($mybb->input['adminemail'])) {
        $errors[] = $lang->admin_step_error_noemail;
    }
    if (is_array($errors)) {
        create_admin_user();
    }
    require MYBB_ROOT . 'inc/config.php';
    $db = db_connection($config);
    require MYBB_ROOT . 'inc/settings.php';
    $mybb->settings =& $settings;
    ob_start();
    $output->print_header($lang->finish_setup, 'finish');
    echo $lang->done_step_usergroupsinserted;
    // Insert all of our user groups from the XML file
    $settings = file_get_contents(INSTALL_ROOT . 'resources/usergroups.xml');
    $parser = new XMLParser($settings);
    $parser->collapse_dups = 0;
    $tree = $parser->get_tree();
    $admin_gid = '';
    $group_count = 0;
    foreach ($tree['usergroups'][0]['usergroup'] as $usergroup) {
        // usergroup[cancp][0][value]
        $new_group = array();
        foreach ($usergroup as $key => $value) {
            if ($key == "gid" || !is_array($value)) {
                continue;
            }
            $new_group[$key] = $db->escape_string($value[0]['value']);
        }
        $return_gid = $db->insert_query("usergroups", $new_group);
        // If this group can access the admin CP and we haven't established the admin group - set it (just in case we ever change IDs)
        if ($new_group['cancp'] == 1 && !$admin_gid) {
            $admin_gid = $return_gid;
        }
        $group_count++;
    }
    echo $lang->done . '</p>';
    echo $lang->done_step_admincreated;
    $now = TIME_NOW;
    $salt = random_str();
    $loginkey = generate_loginkey();
    $saltedpw = md5(md5($salt) . md5($mybb->input['adminpass']));
    $newuser = array('username' => $db->escape_string($mybb->input['adminuser']), 'password' => $saltedpw, 'salt' => $salt, 'loginkey' => $loginkey, 'email' => $db->escape_string($mybb->input['adminemail']), 'usergroup' => $admin_gid, 'regdate' => $now, 'lastactive' => $now, 'lastvisit' => $now, 'website' => '', 'icq' => '', 'aim' => '', 'yahoo' => '', 'msn' => '', 'birthday' => '', 'signature' => '', 'allownotices' => 1, 'hideemail' => 0, 'subscriptionmethod' => '0', 'receivepms' => 1, 'pmnotice' => 1, 'pmnotify' => 1, 'remember' => 1, 'showsigs' => 1, 'showavatars' => 1, 'showquickreply' => 1, 'invisible' => 0, 'style' => '0', 'timezone' => 0, 'dst' => 0, 'threadmode' => '', 'daysprune' => 0, 'regip' => $db->escape_string(get_ip()), 'longregip' => intval(ip2long(get_ip())), 'language' => '', 'showcodebuttons' => 1, 'tpp' => 0, 'ppp' => 0, 'referrer' => 0, 'buddylist' => '', 'ignorelist' => '', 'pmfolders' => '', 'notepad' => '', 'showredirect' => 1);
    $db->insert_query('users', $newuser);
    echo $lang->done . '</p>';
    echo $lang->done_step_adminoptions;
    $adminoptions = file_get_contents(INSTALL_ROOT . 'resources/adminoptions.xml');
    $parser = new XMLParser($adminoptions);
    $parser->collapse_dups = 0;
    $tree = $parser->get_tree();
    $insertmodule = array();
    $db->delete_query("adminoptions");
    // Insert all the admin permissions
    foreach ($tree['adminoptions'][0]['user'] as $users) {
        $uid = $users['attributes']['uid'];
        foreach ($users['permissions'][0]['module'] as $module) {
            foreach ($module['permission'] as $permission) {
                $insertmodule[$module['attributes']['name']][$permission['attributes']['name']] = $permission['value'];
            }
        }
        $defaultviews = array();
        foreach ($users['defaultviews'][0]['view'] as $view) {
            $defaultviews[$view['attributes']['type']] = $view['value'];
        }
        $adminoptiondata = array('uid' => intval($uid), 'cpstyle' => '', 'notes' => '', 'permissions' => $db->escape_string(serialize($insertmodule)), 'defaultviews' => $db->escape_string(serialize($defaultviews)));
        $insertmodule = array();
        $db->insert_query('adminoptions', $adminoptiondata);
    }
    echo $lang->done . '</p>';
    // Automatic Login
    my_unsetcookie("sid");
    my_unsetcookie("mybbuser");
    my_setcookie('mybbuser', $uid . '_' . $loginkey, null, true);
    ob_end_flush();
    // Make fulltext columns if supported
    if ($db->supports_fulltext('threads')) {
        $db->create_fulltext_index('threads', 'subject');
    }
    if ($db->supports_fulltext_boolean('posts')) {
        $db->create_fulltext_index('posts', 'message');
    }
    // Register a shutdown function which actually tests if this functionality is working
    add_shutdown('test_shutdown_function');
    echo $lang->done_step_cachebuilding;
    require_once MYBB_ROOT . 'inc/class_datacache.php';
    $cache = new datacache();
    $cache->update_version();
    $cache->update_attachtypes();
    $cache->update_smilies();
    $cache->update_badwords();
    $cache->update_usergroups();
    $cache->update_forumpermissions();
    $cache->update_stats();
    $cache->update_forums();
    $cache->update_moderators();
    $cache->update_usertitles();
    $cache->update_reportedposts();
    $cache->update_mycode();
    $cache->update_posticons();
    $cache->update_update_check();
    $cache->update_tasks();
    $cache->update_spiders();
    $cache->update_bannedips();
    $cache->update_banned();
    $cache->update_birthdays();
    $cache->update("plugins", array());
    $cache->update("internal_settings", array('encryption_key' => random_str(32)));
    echo $lang->done . '</p>';
    echo $lang->done_step_success;
    $written = 0;
    if (is_writable('./')) {
        $lock = @fopen('./lock', 'w');
        $written = @fwrite($lock, '1');
        @fclose($lock);
        if ($written) {
            echo $lang->done_step_locked;
        }
    }
    if (!$written) {
        echo $lang->done_step_dirdelete;
    }
    echo $lang->done_subscribe_mailing;
    $output->print_footer('');
}
Exemplo n.º 13
0
 if (empty($errors)) {
     $xml_import = array();
     $valid_version = true;
     if ($xml_import = $PL->xml_import($contents)) {
         if (!$mybb->get_input('ignore_version', 1)) {
             $info = ougc_pages_info();
             $valid_version = (double) $xml_import['versioncode'] == $info['versioncode'];
         }
         if (!$valid_version) {
             unset($xml_import);
         }
     } else {
         // try to get this as a "Page Manager" page
         require_once MYBB_ROOT . 'inc/class_xml.php';
         $xml_parser = new XMLParser($contents);
         $tree = $xml_parser->get_tree();
         if (!$mybb->get_input('ignore_version', 1)) {
             $valid_version = (double) $tree['pagemanager']['attributes']['version'] == '1.5.2';
         }
         if (!$valid_version) {
             unset($tree);
         }
         if (isset($tree['pagemanager']) && $valid_version && is_array($tree['pagemanager']) && is_array($tree['pagemanager']['page'])) {
             #if(!($template = base64_decode($tree['pagemanager']['page']['template']['value'], isset($tree['pagemanager']['page']['checksum']['value']) ? false : true)))
             if (!($template = base64_decode($tree['pagemanager']['page']['template']['value']))) {
                 $template = $tree['pagemanager']['page']['template']['value'];
             }
             $xml_import = array('name' => (string) $tree['pagemanager']['page']['name']['value'], 'description' => '', 'url' => (string) $tree['pagemanager']['page']['url']['value'], 'groups' => -1, 'php' => !isset($tree['pagemanager']['page']['framework']['value']) || !(int) $tree['pagemanager']['page']['framework']['value'] ? 1 : 0, 'wol' => !isset($tree['pagemanager']['page']['online']['value']) || (int) $tree['pagemanager']['page']['online']['value'] ? 1 : 0, 'visible' => (int) $tree['pagemanager']['page']['enabled']['value'], 'wrapper' => 0, 'init' => 0, 'template' => (string) trim($template));
         }
     }
     if (!$xml_import) {