当前位置: 首页>>代码示例>>PHP>>正文


PHP XMLParser::get_tree方法代码示例

本文整理汇总了PHP中XMLParser::get_tree方法的典型用法代码示例。如果您正苦于以下问题:PHP XMLParser::get_tree方法的具体用法?PHP XMLParser::get_tree怎么用?PHP XMLParser::get_tree使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在XMLParser的用法示例。


在下文中一共展示了XMLParser::get_tree方法的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: task_versioncheck

/**
 * 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);
}
开发者ID:mainhan1804,项目名称:xomvanphong,代码行数:61,代码来源:versioncheck.php

示例2: substr

 /**
  * 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;
 }
开发者ID:mainhan1804,项目名称:xomvanphong,代码行数:45,代码来源:class_feedparser.php

示例3: install_done

/**
 * 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');
    }
//.........这里部分代码省略.........
开发者ID:mainhan1804,项目名称:xomvanphong,代码行数:101,代码来源:index.php

示例4: array

 $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 {
开发者ID:mainhan1804,项目名称:xomvanphong,代码行数:31,代码来源:credits.php

示例5: upgrade12_dbchanges5

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'];
            }
//.........这里部分代码省略.........
开发者ID:slothly,项目名称:mybb,代码行数:101,代码来源:upgrade12.php

示例6: sync_tasks

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;
}
开发者ID:Nidrax,项目名称:ppm-1.6,代码行数:43,代码来源:upgrade.php

示例7: upgrade30_updatetheme

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++;
                        }
                    }
                }
            }
//.........这里部分代码省略.........
开发者ID:olada,项目名称:mybbintegrator,代码行数:101,代码来源:upgrade30.php

示例8: asb_admin_custom_boxes

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?
//.........这里部分代码省略.........
开发者ID:badboy4life91,项目名称:Advanced-Sidebox,代码行数:101,代码来源:acp.php

示例9: import_theme_xml

/**
 * 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) {
//.........这里部分代码省略.........
开发者ID:KasaiDot,项目名称:mybb,代码行数:101,代码来源:functions_themes.php

示例10: sync_settings

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);
}
开发者ID:benn0034,项目名称:SHIELDsite2.old,代码行数:74,代码来源:upgrade.php

示例11: import

 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;
 }
开发者ID:badboy4life91,项目名称:Advanced-Sidebox,代码行数:36,代码来源:portable.php

示例12: install_done

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();
//.........这里部分代码省略.........
开发者ID:benn0034,项目名称:SHIELDsite2.old,代码行数:101,代码来源:index.php

示例13: array

 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) {
开发者ID:ambsalinas,项目名称:anima,代码行数:31,代码来源:ougc_pages.php


注:本文中的XMLParser::get_tree方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。