public function convert_reputations_data() { $types = $import_data = array(); $sql = 'SELECT * FROM ' . $this->table_prefix . 'reputation_types'; $result = $this->db->sql_query($sql); while ($row = $this->db->sql_fetchrow($result)) { $types[(string) $row['reputation_type_name']] = (int) $row['reputation_type_id']; } $this->db->sql_freeresult($result); $actions = array(1 => 'post', 2 => 'user', 3 => 'warning', 4 => 'ban', 5 => 'likes'); $sql = 'SELECT * FROM ' . $this->table_prefix . 'reputations_mod_backup'; $result = $this->db->sql_query($sql); while ($row = $this->db->sql_fetchrow($result)) { $action = $actions[$row['action']]; if (!isset($types[$action])) { continue; } $import_data[$row['rep_id']]['user_id_from'] = isset($row['rep_from']) ? (int) $row['rep_from'] : 0; $import_data[$row['rep_id']]['user_id_to'] = isset($row['rep_to']) ? (int) $row['rep_to'] : 0; $import_data[$row['rep_id']]['reputation_time'] = isset($row['time']) ? $row['time'] : 0; $import_data[$row['rep_id']]['reputation_type_id'] = isset($row['action']) ? (int) $types[$action] : 0; $import_data[$row['rep_id']]['reputation_item_id'] = isset($row['post_id']) && ($action == 'post' || $action == 'likes') ? (int) $row['post_id'] : 0; $import_data[$row['rep_id']]['reputation_points'] = isset($row['point']) ? $row['point'] : 0; $import_data[$row['rep_id']]['reputation_comment'] = isset($row['comment']) ? $row['comment'] : ''; } $this->db->sql_freeresult($result); if (!empty($import_data)) { $insert_buffer = new \phpbb\db\sql_insert_buffer($this->db, $this->table_prefix . 'reputations'); foreach ($import_data as $reputation_data) { $insert_buffer->insert($reputation_data); } $insert_buffer->flush(); } }
/** * {@inheritdoc} */ public function run() { $this->db->sql_return_on_error(true); $languages = $this->language_helper->get_available_languages(); $installed_languages = array(); foreach ($languages as $lang_info) { $lang_pack = array('lang_iso' => $lang_info['iso'], 'lang_dir' => $lang_info['iso'], 'lang_english_name' => htmlspecialchars($lang_info['name']), 'lang_local_name' => htmlspecialchars($lang_info['local_name'], ENT_COMPAT, 'UTF-8'), 'lang_author' => htmlspecialchars($lang_info['author'], ENT_COMPAT, 'UTF-8')); $this->db->sql_query('INSERT INTO ' . LANG_TABLE . ' ' . $this->db->sql_build_array('INSERT', $lang_pack)); $installed_languages[] = (int) $this->db->sql_nextid(); if ($this->db->get_sql_error_triggered()) { $error = $this->db->sql_error($this->db->get_sql_error_sql()); $this->iohandler->add_error_message($error['message']); } } $sql = 'SELECT * FROM ' . PROFILE_FIELDS_TABLE; $result = $this->db->sql_query($sql); $insert_buffer = new \phpbb\db\sql_insert_buffer($this->db, PROFILE_LANG_TABLE); while ($row = $this->db->sql_fetchrow($result)) { foreach ($installed_languages as $lang_id) { $insert_buffer->insert(array('field_id' => $row['field_id'], 'lang_id' => $lang_id, 'lang_name' => strtoupper(substr($row['field_name'], 6)), 'lang_explain' => '', 'lang_default_value' => '')); } } $this->db->sql_freeresult($result); $insert_buffer->flush(); }
protected function set_up_forums() { static $forums; if (empty($forums)) { $this->create_forum('Parent with two flat children'); $this->create_forum('Flat child #1', 1); $this->create_forum('Flat child #2', 1); $this->create_forum('Parent with two nested children'); $this->create_forum('Nested child #1', 4); $this->create_forum('Nested child #2', 5); $this->create_forum('Parent with flat and nested children'); $this->create_forum('Mixed child #1', 7); $this->create_forum('Mixed child #2', 7); $this->create_forum('Nested child #1 of Mixed child #2', 9); $this->create_forum('Mixed child #3', 7); // Updating forum_parents column here so it's not empty // This is required, so we can see whether the methods // correctly clear the values. $sql = "UPDATE phpbb_forums\n\t\t\t\tSET forum_parents = 'a:0:{}'"; $this->db->sql_query($sql); // Copy the forums into a static array, so we can reuse the list later $sql = 'SELECT * FROM phpbb_forums'; $result = $this->db->sql_query($sql); $forums = $this->db->sql_fetchrowset($result); $this->db->sql_freeresult($result); } else { $buffer = new \phpbb\db\sql_insert_buffer($this->db, 'phpbb_forums'); $buffer->insert_all($forums); $buffer->flush(); $this->database_synchronisation(array('phpbb_forums' => array('forum_id'))); } }
public function statuses_data() { $statuses_data = array(array('status_id' => 1, 'status_name' => 'NEW'), array('status_id' => 2, 'status_name' => 'IN_PROGRESS'), array('status_id' => 3, 'status_name' => 'IMPLEMENTED'), array('status_id' => 4, 'status_name' => 'DUPLICATE'), array('status_id' => 5, 'status_name' => 'INVALID')); $insert_buffer = new \phpbb\db\sql_insert_buffer($this->db, $this->table_prefix . 'ideas_statuses'); foreach ($statuses_data as $row) { $insert_buffer->insert($row); } $insert_buffer->flush(); }
public function copy_table($old_table, $new_table) { // Load the insert buffer class to perform a buffered multi insert $insert_buffer = new \phpbb\db\sql_insert_buffer($this->db, $this->table_prefix . $new_table); $result = $this->db->sql_query('SELECT * FROM ' . $this->table_prefix . $old_table); while ($row = $this->db->sql_fetchrow($result)) { $insert_buffer->insert($row); } $this->db->sql_freeresult($result); // Flush the buffer $insert_buffer->flush(); }
/** * Add auto group types to the database * * @return null * @access public */ public function add_autogroups_type_data() { // Load the insert buffer class to perform a buffered multi insert $insert_buffer = new \phpbb\db\sql_insert_buffer($this->db, $this->table_prefix . 'autogroups_types'); // Auto group types array $types = array('birthdays', 'membership', 'posts', 'warnings'); // Insert data foreach ($types as $type) { $insert_buffer->insert(array('autogroups_type_name' => 'phpbb.autogroups.type.' . $type)); } // Flush the buffer $insert_buffer->flush(); }
/** * Add pages link locations to the database * * @return null * @access public */ public function add_page_link_location_data() { // Load the insert buffer class to perform a buffered multi insert $insert_buffer = new \phpbb\db\sql_insert_buffer($this->db, $this->table_prefix . 'pages_links'); // Define our default page link locations/events // NOTE: These names are updated in m5_update_link_names.php $page_link_locations = array('overall_header_navigation_prepend' => 'Nav Bar Before Links', 'overall_header_navigation_append' => 'Nav Bar After Links', 'overall_header_breadcrumbs_before' => 'Nav Bar Before Breadcrumbs', 'overall_header_breadcrumbs_after' => 'Nav Bar After Breadcrumbs', 'overall_footer_timezone_before' => 'Footer Before Time Zone', 'overall_footer_timezone_after' => 'Footer After Time Zone', 'overall_footer_teamlink_before' => 'Footer Before Team Link', 'overall_footer_teamlink_after' => 'Footer After Team Link', 'navbar_header_quick_links_before' => 'Quick links Menu Top', 'navbar_header_quick_links_after' => 'Quick Links Menu Bottom'); // Insert data foreach ($page_link_locations as $event => $location) { $insert_buffer->insert(array('page_link_location' => $location, 'page_link_event_name' => $event)); } // Flush the buffer $insert_buffer->flush(); }
/** * Add countries to the database * * @return null * @access public */ public function update_tables() { // Load the insert buffer class to perform a buffered multi insert $insert_buffer = new \phpbb\db\sql_insert_buffer($this->db, $this->table_prefix . 'postsstat_domains'); $countries = array(1 => array('domain' => 'ac', 'description' => 'Ascension Island'), 2 => array('domain' => 'ad', 'description' => 'Andorra'), 3 => array('domain' => 'ae', 'description' => 'United Arab Emirates'), 4 => array('domain' => 'af', 'description' => 'Afghanistan'), 5 => array('domain' => 'ag', 'description' => 'Antigua and Barbuda'), 6 => array('domain' => 'ai', 'description' => 'Anguilla'), 7 => array('domain' => 'al', 'description' => 'Albania'), 8 => array('domain' => 'am', 'description' => 'Armenia'), 9 => array('domain' => 'an', 'description' => 'Netherlands Antilles'), 10 => array('domain' => 'ao', 'description' => 'Angola'), 11 => array('domain' => 'aq', 'description' => 'Antarctica'), 12 => array('domain' => 'ar', 'description' => 'Argentina'), 13 => array('domain' => 'as', 'description' => 'American Samoa'), 14 => array('domain' => 'at', 'description' => 'Austria'), 15 => array('domain' => 'au', 'description' => 'Australia'), 16 => array('domain' => 'aw', 'description' => 'Aruba'), 17 => array('domain' => 'ax', 'description' => 'land'), 18 => array('domain' => 'az', 'description' => 'Azerbaijan'), 19 => array('domain' => 'ba', 'description' => 'Bosnia and Herzegovina'), 20 => array('domain' => 'bb', 'description' => 'Barbados'), 21 => array('domain' => 'bd', 'description' => 'Bangladesh'), 22 => array('domain' => 'be', 'description' => 'Belgium'), 23 => array('domain' => 'bf', 'description' => 'Burkina Faso'), 24 => array('domain' => 'bg', 'description' => 'Bulgaria'), 25 => array('domain' => 'bh', 'description' => 'Bahrain'), 26 => array('domain' => 'bi', 'description' => 'Burundi'), 27 => array('domain' => 'bj', 'description' => 'Benin'), 28 => array('domain' => 'bm', 'description' => 'Bermuda'), 29 => array('domain' => 'bn', 'description' => 'Brunei'), 30 => array('domain' => 'bo', 'description' => 'Bolivia'), 31 => array('domain' => 'br', 'description' => 'Brazil'), 32 => array('domain' => 'bs', 'description' => 'Bahamas'), 33 => array('domain' => 'bt', 'description' => 'Bhutan'), 34 => array('domain' => 'bv', 'description' => 'Bouvet Island'), 35 => array('domain' => 'bw', 'description' => 'Botswana'), 36 => array('domain' => 'by', 'description' => 'Belarus'), 37 => array('domain' => 'bz', 'description' => 'Belize'), 38 => array('domain' => 'ca', 'description' => 'Canada'), 39 => array('domain' => 'cc', 'description' => 'Cocos (Keeling) Islands'), 40 => array('domain' => 'cd', 'description' => 'Democratic Republic of the Congo'), 41 => array('domain' => 'cf', 'description' => 'Central African Republic'), 42 => array('domain' => 'cg', 'description' => 'Republic of the Congo'), 43 => array('domain' => 'ch', 'description' => 'Switzerland'), 44 => array('domain' => 'ci', 'description' => 'Côte d\'Ivoire'), 45 => array('domain' => 'ck', 'description' => 'Cook Islands'), 46 => array('domain' => 'cl', 'description' => 'Chile'), 47 => array('domain' => 'cm', 'description' => 'Cameroon'), 48 => array('domain' => 'cn', 'description' => 'People\'s Republic of China'), 49 => array('domain' => 'co', 'description' => 'Colombia'), 50 => array('domain' => 'cr', 'description' => 'Costa Rica'), 51 => array('domain' => 'cs', 'description' => 'Czechoslovakia'), 52 => array('domain' => 'cu', 'description' => 'Cuba'), 53 => array('domain' => 'cv', 'description' => 'Cape Verde'), 54 => array('domain' => 'cw', 'description' => 'Cura‡ao'), 55 => array('domain' => 'cx', 'description' => 'Christmas Island'), 56 => array('domain' => 'cy', 'description' => 'Cyprus'), 57 => array('domain' => 'cz', 'description' => 'Czech Republic'), 58 => array('domain' => 'dd', 'description' => 'East Germany'), 59 => array('domain' => 'de', 'description' => 'Germany'), 60 => array('domain' => 'dj', 'description' => 'Djibouti'), 61 => array('domain' => 'dk', 'description' => 'Denmark'), 62 => array('domain' => 'dm', 'description' => 'Dominica'), 63 => array('domain' => 'do', 'description' => 'Dominican Republic'), 64 => array('domain' => 'dz', 'description' => 'Algeria'), 65 => array('domain' => 'ec', 'description' => 'Ecuador'), 66 => array('domain' => 'ee', 'description' => 'Estonia'), 67 => array('domain' => 'eg', 'description' => 'Egypt'), 68 => array('domain' => 'eh', 'description' => 'Western Sahara'), 69 => array('domain' => 'er', 'description' => 'Eritrea'), 70 => array('domain' => 'es', 'description' => 'Spain'), 71 => array('domain' => 'et', 'description' => 'Ethiopia'), 72 => array('domain' => 'eu', 'description' => 'European Union'), 73 => array('domain' => 'fi', 'description' => 'Finland'), 74 => array('domain' => 'fj', 'description' => 'Fiji'), 75 => array('domain' => 'fk', 'description' => 'Falkland Islands'), 76 => array('domain' => 'fm', 'description' => 'Federated States of Micronesia'), 77 => array('domain' => 'fo', 'description' => 'Faroe Islands'), 78 => array('domain' => 'fr', 'description' => 'France'), 79 => array('domain' => 'ga', 'description' => 'Gabon'), 80 => array('domain' => 'gb', 'description' => 'United Kingdom'), 81 => array('domain' => 'gd', 'description' => 'Grenada'), 82 => array('domain' => 'ge', 'description' => 'Georgia'), 83 => array('domain' => 'gf', 'description' => 'French Guiana'), 84 => array('domain' => 'gg', 'description' => 'Guernsey'), 85 => array('domain' => 'gh', 'description' => 'Ghana'), 86 => array('domain' => 'gi', 'description' => 'Gibraltar'), 87 => array('domain' => 'gl', 'description' => 'Greenland'), 88 => array('domain' => 'gm', 'description' => 'The Gambia'), 89 => array('domain' => 'gn', 'description' => 'Guinea'), 90 => array('domain' => 'gp', 'description' => 'Guadeloupe'), 91 => array('domain' => 'gq', 'description' => 'Equatorial Guinea'), 92 => array('domain' => 'gr', 'description' => 'Greece'), 93 => array('domain' => 'gs', 'description' => 'South Georgia and the South Sandwich Islands'), 94 => array('domain' => 'gt', 'description' => 'Guatemala'), 95 => array('domain' => 'gu', 'description' => 'Guam'), 96 => array('domain' => 'gw', 'description' => 'Guinea-Bissau'), 97 => array('domain' => 'gy', 'description' => 'Guyana'), 98 => array('domain' => 'hk', 'description' => 'Hong Kong'), 99 => array('domain' => 'hm', 'description' => 'Heard Island and McDonald Islands'), 100 => array('domain' => 'hn', 'description' => 'Honduras'), 101 => array('domain' => 'hr', 'description' => 'Croatia'), 102 => array('domain' => 'ht', 'description' => 'Haiti'), 103 => array('domain' => 'hu', 'description' => 'Hungary'), 104 => array('domain' => 'id', 'description' => 'Indonesia'), 105 => array('domain' => 'ie', 'description' => 'Ireland'), 106 => array('domain' => 'il', 'description' => 'Israel'), 107 => array('domain' => 'im', 'description' => 'Isle of Man'), 108 => array('domain' => 'in', 'description' => 'India'), 109 => array('domain' => 'io', 'description' => 'British Indian Ocean Territory'), 110 => array('domain' => 'iq', 'description' => 'Iraq'), 111 => array('domain' => 'ir', 'description' => 'Iran'), 112 => array('domain' => 'is', 'description' => 'Iceland'), 113 => array('domain' => 'it', 'description' => 'Italy'), 114 => array('domain' => 'je', 'description' => 'Jersey'), 115 => array('domain' => 'jm', 'description' => 'Jamaica'), 116 => array('domain' => 'jo', 'description' => 'Jordan'), 117 => array('domain' => 'jp', 'description' => 'Japan'), 118 => array('domain' => 'ke', 'description' => 'Kenya'), 119 => array('domain' => 'kg', 'description' => 'Kyrgyzstan'), 120 => array('domain' => 'kh', 'description' => 'Cambodia'), 121 => array('domain' => 'ki', 'description' => 'Kiribati'), 122 => array('domain' => 'km', 'description' => 'Comoros'), 123 => array('domain' => 'kn', 'description' => 'Saint Kitts and Nevis'), 124 => array('domain' => 'kp', 'description' => 'Democratic People\'s Republic of Korea'), 125 => array('domain' => 'kr', 'description' => 'Republic of Korea'), 126 => array('domain' => 'kw', 'description' => 'Kuwait'), 127 => array('domain' => 'ky', 'description' => 'Cayman Islands'), 128 => array('domain' => 'kz', 'description' => 'Kazakhstan'), 129 => array('domain' => 'la', 'description' => 'Laos'), 130 => array('domain' => 'lb', 'description' => 'Lebanon'), 131 => array('domain' => 'lc', 'description' => 'Saint Lucia'), 132 => array('domain' => 'li', 'description' => 'Liechtenstein'), 133 => array('domain' => 'lk', 'description' => 'Sri Lanka'), 134 => array('domain' => 'lr', 'description' => 'Liberia'), 135 => array('domain' => 'ls', 'description' => 'Lesotho'), 136 => array('domain' => 'lt', 'description' => 'Lithuania'), 137 => array('domain' => 'lu', 'description' => 'Luxembourg'), 138 => array('domain' => 'lv', 'description' => 'Latvia'), 139 => array('domain' => 'ly', 'description' => 'Libya'), 140 => array('domain' => 'ma', 'description' => 'Morocco'), 141 => array('domain' => 'mc', 'description' => 'Monaco'), 142 => array('domain' => 'md', 'description' => 'Moldova'), 143 => array('domain' => 'me', 'description' => 'Montenegro'), 144 => array('domain' => 'mg', 'description' => 'Madagascar'), 145 => array('domain' => 'mh', 'description' => 'Marshall Islands'), 146 => array('domain' => 'mk', 'description' => 'Macedonia'), 147 => array('domain' => 'ml', 'description' => 'Mali'), 148 => array('domain' => 'mm', 'description' => 'Myanmar'), 149 => array('domain' => 'mn', 'description' => 'Mongolia'), 150 => array('domain' => 'mo', 'description' => 'Macau'), 151 => array('domain' => 'mp', 'description' => 'Northern Mariana Islands'), 152 => array('domain' => 'mq', 'description' => 'Martinique'), 153 => array('domain' => 'mr', 'description' => 'Mauritania'), 154 => array('domain' => 'ms', 'description' => 'Montserrat'), 155 => array('domain' => 'mt', 'description' => 'Malta'), 156 => array('domain' => 'mu', 'description' => 'Mauritius'), 157 => array('domain' => 'mv', 'description' => 'Maldives'), 158 => array('domain' => 'mw', 'description' => 'Malawi'), 159 => array('domain' => 'mx', 'description' => 'Mexico'), 160 => array('domain' => 'my', 'description' => 'Malaysia'), 161 => array('domain' => 'mz', 'description' => 'Mozambique'), 162 => array('domain' => 'na', 'description' => 'Namibia'), 163 => array('domain' => 'nc', 'description' => 'New Caledonia'), 164 => array('domain' => 'ne', 'description' => 'Niger'), 165 => array('domain' => 'nf', 'description' => 'Norfolk Island'), 166 => array('domain' => 'ng', 'description' => 'Nigeria'), 167 => array('domain' => 'ni', 'description' => 'Nicaragua'), 168 => array('domain' => 'nl', 'description' => 'Netherlands'), 169 => array('domain' => 'no', 'description' => 'Norway'), 170 => array('domain' => 'np', 'description' => 'Nepal'), 171 => array('domain' => 'nr', 'description' => 'Nauru'), 172 => array('domain' => 'nu', 'description' => 'Niue'), 173 => array('domain' => 'nz', 'description' => 'New Zealand'), 174 => array('domain' => 'om', 'description' => 'Oman'), 175 => array('domain' => 'pa', 'description' => 'Panama'), 176 => array('domain' => 'pe', 'description' => 'Peru'), 177 => array('domain' => 'pf', 'description' => 'French Polynesia'), 178 => array('domain' => 'pg', 'description' => 'Papua New Guinea'), 179 => array('domain' => 'ph', 'description' => 'Philippines'), 180 => array('domain' => 'pk', 'description' => 'Pakistan'), 181 => array('domain' => 'pl', 'description' => 'Poland'), 182 => array('domain' => 'pm', 'description' => 'Saint-Pierre and Miquelon'), 183 => array('domain' => 'pn', 'description' => 'Pitcairn Islands'), 184 => array('domain' => 'pr', 'description' => 'Puerto Rico'), 185 => array('domain' => 'ps', 'description' => 'State of Palestine[19]'), 186 => array('domain' => 'pt', 'description' => 'Portugal'), 187 => array('domain' => 'pw', 'description' => 'Palau'), 188 => array('domain' => 'py', 'description' => 'Paraguay'), 189 => array('domain' => 'qa', 'description' => 'Qatar'), 190 => array('domain' => 're', 'description' => 'R‚union'), 191 => array('domain' => 'ro', 'description' => 'Romania'), 192 => array('domain' => 'rs', 'description' => 'Serbia'), 193 => array('domain' => 'ru', 'description' => 'Russia'), 194 => array('domain' => 'rw', 'description' => 'Rwanda'), 195 => array('domain' => 'sa', 'description' => 'Saudi Arabia'), 196 => array('domain' => 'sb', 'description' => 'Solomon Islands'), 197 => array('domain' => 'sc', 'description' => 'Seychelles'), 198 => array('domain' => 'sd', 'description' => 'Sudan'), 199 => array('domain' => 'se', 'description' => 'Sweden'), 200 => array('domain' => 'sg', 'description' => 'Singapore'), 201 => array('domain' => 'sh', 'description' => 'Saint Helena'), 202 => array('domain' => 'si', 'description' => 'Slovenia'), 203 => array('domain' => 'sj', 'description' => 'Svalbard and Jan Mayen Islands'), 204 => array('domain' => 'sk', 'description' => 'Slovakia'), 205 => array('domain' => 'sl', 'description' => 'Sierra Leone'), 206 => array('domain' => 'sm', 'description' => 'San Marino'), 207 => array('domain' => 'sn', 'description' => 'Senegal'), 208 => array('domain' => 'so', 'description' => 'Somalia'), 209 => array('domain' => 'sr', 'description' => 'Suriname'), 210 => array('domain' => 'ss', 'description' => 'South Sudan'), 211 => array('domain' => 'st', 'description' => 'São Tomé and Príncipe'), 212 => array('domain' => 'su', 'description' => 'Soviet Union'), 213 => array('domain' => 'sv', 'description' => 'El Salvador'), 214 => array('domain' => 'sx', 'description' => 'Sint Maarten'), 215 => array('domain' => 'sy', 'description' => 'Syria'), 216 => array('domain' => 'sz', 'description' => 'Swaziland'), 217 => array('domain' => 'tc', 'description' => 'Turks and Caicos Islands'), 218 => array('domain' => 'td', 'description' => 'Chad'), 219 => array('domain' => 'tf', 'description' => 'French Southern and Antarctic Lands'), 220 => array('domain' => 'tg', 'description' => 'Togo'), 221 => array('domain' => 'th', 'description' => 'Thailand'), 222 => array('domain' => 'tj', 'description' => 'Tajikistan'), 223 => array('domain' => 'tk', 'description' => 'Tokelau'), 224 => array('domain' => 'tl', 'description' => 'East Timor'), 225 => array('domain' => 'tm', 'description' => 'Turkmenistan'), 226 => array('domain' => 'tn', 'description' => 'Tunisia'), 227 => array('domain' => 'to', 'description' => 'Tonga'), 228 => array('domain' => 'tp', 'description' => 'East Timor'), 229 => array('domain' => 'tr', 'description' => 'Turkey'), 230 => array('domain' => 'tt', 'description' => 'Trinidad and Tobago'), 231 => array('domain' => 'tv', 'description' => 'Tuvalu'), 232 => array('domain' => 'tw', 'description' => 'Taiwan'), 233 => array('domain' => 'tz', 'description' => 'Tanzania'), 234 => array('domain' => 'ua', 'description' => 'Ukraine'), 235 => array('domain' => 'ug', 'description' => 'Uganda'), 236 => array('domain' => 'uk', 'description' => 'United Kingdom'), 237 => array('domain' => 'us', 'description' => 'United States of America'), 238 => array('domain' => 'uy', 'description' => 'Uruguay'), 239 => array('domain' => 'uz', 'description' => 'Uzbekistan'), 240 => array('domain' => 'va', 'description' => 'Vatican City'), 241 => array('domain' => 'vc', 'description' => 'Saint Vincent and the Grenadines'), 242 => array('domain' => 've', 'description' => 'Venezuela'), 243 => array('domain' => 'vg', 'description' => 'British Virgin Islands'), 244 => array('domain' => 'vi', 'description' => 'United States Virgin Islands'), 245 => array('domain' => 'vn', 'description' => 'Vietnam'), 246 => array('domain' => 'vu', 'description' => 'Vanuatu'), 247 => array('domain' => 'wf', 'description' => 'Wallis and Futuna'), 248 => array('domain' => 'ws', 'description' => 'Samoa'), 249 => array('domain' => 'ye', 'description' => 'Yemen'), 250 => array('domain' => 'yt', 'description' => 'Mayotte'), 251 => array('domain' => 'yu', 'description' => 'SFR Yugoslavia'), 252 => array('domain' => 'za', 'description' => 'South Africa'), 253 => array('domain' => 'zm', 'description' => 'Zambia'), 254 => array('domain' => 'zw', 'description' => 'Zimbabwe'), 255 => array('domain' => 'com', 'description' => 'Commercial'), 256 => array('domain' => 'org', 'description' => 'Organization'), 257 => array('domain' => 'net', 'description' => 'Network'), 258 => array('domain' => 'lo', 'description' => 'Localhost'), 259 => array('domain' => 'un', 'description' => 'Unknown')); // Insert data foreach ($countries as $country) { $insert_buffer->insert($country); } // Flush the buffer $insert_buffer->flush(); $insert_buffer = new \phpbb\db\sql_insert_buffer($this->db, $this->table_prefix . 'postsstat_config'); $config = array(1 => array('start_screen' => 'online')); // Insert data foreach ($config as $c) { $insert_buffer->insert($c); } // Flush the buffer $insert_buffer->flush(); }
public function create_custom_field() { $sql = 'SELECT MAX(field_order) as max_field_order FROM ' . PROFILE_FIELDS_TABLE; $result = $this->db->sql_query($sql); $max_field_order = (int) $this->db->sql_fetchfield('max_field_order'); $this->db->sql_freeresult($result); $sql_ary = array('field_name' => 'phpbb_wlm', 'field_type' => 'profilefields.type.string', 'field_ident' => 'phpbb_wlm', 'field_length' => '40', 'field_minlen' => '5', 'field_maxlen' => '255', 'field_novalue' => '', 'field_default_value' => '', 'field_validation' => '.*', 'field_required' => 0, 'field_show_novalue' => 0, 'field_show_on_reg' => 0, 'field_show_on_pm' => 1, 'field_show_on_vt' => 1, 'field_show_on_ml' => 0, 'field_show_profile' => 1, 'field_hide' => 0, 'field_no_view' => 0, 'field_active' => 1, 'field_is_contact' => 1, 'field_contact_desc' => '', 'field_contact_url' => '', 'field_order' => $max_field_order + 1); $sql = 'INSERT INTO ' . PROFILE_FIELDS_TABLE . ' ' . $this->db->sql_build_array('INSERT', $sql_ary); $this->db->sql_query($sql); $field_id = (int) $this->db->sql_nextid(); $insert_buffer = new \phpbb\db\sql_insert_buffer($this->db, PROFILE_LANG_TABLE); $sql = 'SELECT lang_id FROM ' . LANG_TABLE; $result = $this->db->sql_query($sql); $lang_name = 'WLM'; while ($lang_id = (int) $this->db->sql_fetchfield('lang_id')) { $insert_buffer->insert(array('field_id' => (int) $field_id, 'lang_id' => (int) $lang_id, 'lang_name' => $lang_name, 'lang_explain' => '', 'lang_default_value' => '')); } $this->db->sql_freeresult($result); $insert_buffer->flush(); }
public function migrate_data_from_old_tables() { $old_new_tables = array($this->table_prefix . 'captcha_sortables_questions' => $this->table_prefix . 'sortables_questions', $this->table_prefix . 'captcha_sortables_answers' => $this->table_prefix . 'sortables_answers', $this->table_prefix . 'captcha_sortables_confirm' => $this->table_prefix . 'sortables_confirm'); // Loop through the tables foreach ($old_new_tables as $old_table => $new_table) { // Create an insert buffer for the new table $insert_buffer = new \phpbb\db\sql_insert_buffer($this->db, $new_table); // Select everything from the old table $sql = 'SELECT * FROM ' . $old_table; $result = $this->db->sql_query($sql); while ($row = $this->db->sql_fetchrow($result)) { // And add it to the buffer $insert_buffer->insert($row); } $this->db->sql_freeresult($result); // Insert everything into the new table $insert_buffer->flush(); // Unset the insert buffer for the current table unset($insert_buffer); // Remove table $this->db_tools->sql_table_drop($old_table); } }
/** * Custom function to convert and add Pages MOD data * * @return null * @access public */ public function convert_pages_data() { $import_data = array(); // Load all the Pages MOD data $sql = 'SELECT * FROM ' . $this->table_prefix . 'pages_mod_backup'; $result = $this->db->sql_query($sql); // Map the Pages MOD data to our import array, and perform any data changes as needed while ($row = $this->db->sql_fetchrow($result)) { // Data to import $import_data[$row['page_id']]['page_title'] = isset($row['page_title']) ? substr($row['page_title'], 0, 200) : ''; $import_data[$row['page_id']]['page_description'] = isset($row['page_desc']) ? substr($row['page_desc'], 0, 255) : ''; $import_data[$row['page_id']]['page_route'] = isset($row['page_url']) ? substr($row['page_url'], 0, 100) : ''; $import_data[$row['page_id']]['page_order'] = isset($row['page_order']) ? min($row['page_order'], 16777215) : 0; $import_data[$row['page_id']]['page_content'] = isset($row['page_content']) ? $row['page_content'] : ''; $import_data[$row['page_id']]['page_content_bbcode_uid'] = isset($row['bbcode_uid']) ? $row['bbcode_uid'] : ''; $import_data[$row['page_id']]['page_content_bbcode_bitfield'] = isset($row['bbcode_bitfield']) ? $row['bbcode_bitfield'] : ''; $import_data[$row['page_id']]['page_display'] = isset($row['page_display']) ? $row['page_display'] : 0; $import_data[$row['page_id']]['page_display_to_guests'] = isset($row['page_display_guests']) ? $row['page_display_guests'] : 0; // Data added by Pages extension $import_data[$row['page_id']]['page_content_bbcode_options'] = 7; $import_data[$row['page_id']]['page_content_allow_html'] = 0; $import_data[$row['page_id']]['page_template'] = 'pages_default.html'; // Data not imported // $row['page_time'] // $row['page_author'] } $this->db->sql_freeresult($result); // If we have data to import, let's go!! :) if (!empty($import_data)) { // Load the insert buffer class to perform a buffered multi insert $insert_buffer = new \phpbb\db\sql_insert_buffer($this->db, $this->table_prefix . 'pages'); // Insert imported data to our Pages table foreach ($import_data as $page_data) { $insert_buffer->insert($page_data); } // Flush the buffer $insert_buffer->flush(); } }
public function create_pbwow_fields() { $sql = 'SELECT MAX(field_order) as max_field_order FROM ' . PROFILE_FIELDS_TABLE; $result = $this->db->sql_query($sql); $max_field_order = (int) $this->db->sql_fetchfield('max_field_order'); $this->db->sql_freeresult($result); foreach ($this->profilefields as $profilefield_name => $meta) { if ($this->db_tools->sql_column_exists($this->table_prefix . 'profile_fields_data', 'pf_' . $profilefield_name)) { // Already exists (and seems to be up to date) continue; } else { if (isset($meta['profilefield_oldname']) && $this->db_tools->sql_column_exists($this->table_prefix . 'profile_fields_data', 'pf_' . $meta['profilefield_oldname'])) { // Update existing old version. We can safely assume that the phpBB 3.1 migration has already converted them to the new format succesfully $sql = "UPDATE " . $this->table_prefix . "profile_fields\n\t\t\t\t\tSET field_name = '" . $profilefield_name . "', field_ident = '" . $profilefield_name . "'\n\t\t\t\t\tWHERE field_ident = '" . $meta['profilefield_oldname'] . "'"; $this->db->sql_query($sql); // Add the new version column to the profile fields data table $schema_change = array('add_columns' => array($this->table_prefix . 'profile_fields_data' => array('pf_' . $profilefield_name => $meta['profilefield_database_type']))); $this->db_tools->perform_schema_changes($schema_change); // Copy the user data to the new column // TODO use buffer $sql = 'UPDATE ' . $this->table_prefix . 'profile_fields_data SET pf_' . $profilefield_name . ' = pf_' . $meta['profilefield_oldname']; $this->db->sql_query($sql); // Drop the old column $schema_change2 = array('drop_columns' => array($this->table_prefix . 'profile_fields_data' => array('pf_' . $meta['profilefield_oldname']))); $this->db_tools->perform_schema_changes($schema_change2); } else { // Create a new one $data = $meta['profilefield_data']; $type = $data['field_type']; $entries = isset($meta['profilefield_entries']) ? $meta['profilefield_entries'] : false; $sql_ary = array_merge($data, array('field_name' => $profilefield_name, 'field_ident' => $profilefield_name, 'field_order' => $max_field_order + 1)); $max_field_order++; $sql = 'INSERT INTO ' . PROFILE_FIELDS_TABLE . ' ' . $this->db->sql_build_array('INSERT', $sql_ary); $this->db->sql_query($sql); $field_id = (int) $this->db->sql_nextid(); // Probably not the most efficient, but it gets the job done $insert_buffer = new \phpbb\db\sql_insert_buffer($this->db, PROFILE_LANG_TABLE); $insert_buffer2 = new \phpbb\db\sql_insert_buffer($this->db, PROFILE_FIELDS_LANG_TABLE); $sql = 'SELECT lang_id FROM ' . LANG_TABLE; $result = $this->db->sql_query($sql); while ($lang_id = (int) $this->db->sql_fetchfield('lang_id')) { // Set the profile field language options $insert_buffer->insert(array('field_id' => $field_id, 'lang_id' => $lang_id, 'lang_name' => $meta['profilefield_lang_name'], 'lang_explain' => $meta['profilefield_lang_explain'], 'lang_default_value' => '')); if ($entries) { // This profile field has predefined entry values, so they must be set for each lang foreach ($entries as $entry => $value) { $insert_buffer2->insert(array('field_id' => $field_id, 'lang_id' => $lang_id, 'option_id' => $entry, 'field_type' => $type, 'lang_value' => $value)); } } } $this->db->sql_freeresult($result); $insert_buffer->flush(); $insert_buffer2->flush(); // Add a column to the profile fields data table $schema_change = array('add_columns' => array($this->table_prefix . 'profile_fields_data' => array('pf_' . $profilefield_name => $meta['profilefield_database_type']))); $this->db_tools->perform_schema_changes($schema_change); } } } }
/** * Populate the language tables */ function add_language($mode, $sub) { global $db, $lang, $phpbb_root_path, $phpEx; $dir = @opendir($phpbb_root_path . 'language'); if (!$dir) { $this->error('Unable to access the language directory', __LINE__, __FILE__); } $installed_languages = array(); while (($file = readdir($dir)) !== false) { $path = $phpbb_root_path . 'language/' . $file; if ($file == '.' || $file == '..' || is_link($path) || is_file($path) || $file == 'CVS') { continue; } if (is_dir($path) && file_exists($path . '/iso.txt')) { $lang_file = file("{$path}/iso.txt"); $lang_pack = array('lang_iso' => basename($path), 'lang_dir' => basename($path), 'lang_english_name' => trim(htmlspecialchars($lang_file[0])), 'lang_local_name' => trim(htmlspecialchars($lang_file[1], ENT_COMPAT, 'UTF-8')), 'lang_author' => trim(htmlspecialchars($lang_file[2], ENT_COMPAT, 'UTF-8'))); $db->sql_query('INSERT INTO ' . LANG_TABLE . ' ' . $db->sql_build_array('INSERT', $lang_pack)); $installed_languages[] = (int) $db->sql_nextid(); if ($db->get_sql_error_triggered()) { $error = $db->sql_error($db->get_sql_error_sql()); $this->p_master->db_error($error['message'], $db->get_sql_error_sql(), __LINE__, __FILE__); } } } closedir($dir); $sql = 'SELECT * FROM ' . PROFILE_FIELDS_TABLE; $result = $db->sql_query($sql); $profile_fields = array(); $insert_buffer = new \phpbb\db\sql_insert_buffer($db, PROFILE_LANG_TABLE); while ($row = $db->sql_fetchrow($result)) { foreach ($installed_languages as $lang_id) { $insert_buffer->insert(array('field_id' => $row['field_id'], 'lang_id' => $lang_id, 'lang_name' => strtoupper(substr($row['field_name'], 6)), 'lang_explain' => '', 'lang_default_value' => '')); } } $db->sql_freeresult($result); $insert_buffer->flush(); }
/** * @param int $start Start of staggering step * @return mixed int start of the next step, null if the end was reached */ public function convert_user_field_to_custom_field($start) { $insert_buffer = new \phpbb\db\sql_insert_buffer($this->db, $this->table_prefix . 'profile_fields_data'); $limit = 250; $converted_users = 0; $sql = 'SELECT user_id, ' . $this->user_column_name . ' FROM ' . $this->table_prefix . 'users WHERE ' . $this->user_column_name . " <> ''\n\t\t\tORDER BY user_id"; $result = $this->db->sql_query_limit($sql, $limit, $start); while ($row = $this->db->sql_fetchrow($result)) { $converted_users++; $cp_data = array('pf_' . $this->profilefield_name => $row[$this->user_column_name]); $sql = 'UPDATE ' . $this->table_prefix . 'profile_fields_data SET ' . $this->db->sql_build_array('UPDATE', $cp_data) . ' WHERE user_id = ' . (int) $row['user_id']; $this->db->sql_query($sql); if (!$this->db->sql_affectedrows()) { $cp_data['user_id'] = (int) $row['user_id']; $cp_data = array_merge($this->get_insert_sql_array(), $cp_data); $insert_buffer->insert($cp_data); } } $this->db->sql_freeresult($result); $insert_buffer->flush(); if ($converted_users < $limit) { // No more users left, we are done... return; } return $start + $limit; }
/** * Add a notification for specific users * * @param string|array $notification_type_name Type identifier or array of item types (only acceptable if the $data is identical for the specified types) * @param array $data Data specific for this type that will be inserted * @param array $notify_users User list to notify */ public function add_notifications_for_users($notification_type_name, $data, $notify_users) { if (is_array($notification_type_name)) { foreach ($notification_type_name as $type) { $this->add_notifications_for_users($type, $data, $notify_users); } return; } $notification_type_id = $this->get_notification_type_id($notification_type_name); $item_id = $this->get_item_type_class($notification_type_name)->get_item_id($data); $user_ids = array(); $notification_objects = $notification_methods = array(); // Never send notifications to the anonymous user! unset($notify_users[ANONYMOUS]); // Make sure not to send new notifications to users who've already been notified about this item // This may happen when an item was added, but now new users are able to see the item $sql = 'SELECT n.user_id FROM ' . $this->notifications_table . ' n, ' . $this->notification_types_table . ' nt WHERE n.notification_type_id = ' . (int) $notification_type_id . ' AND n.item_id = ' . (int) $item_id . ' AND nt.notification_type_id = n.notification_type_id AND nt.notification_type_enabled = 1'; $result = $this->db->sql_query($sql); while ($row = $this->db->sql_fetchrow($result)) { unset($notify_users[$row['user_id']]); } $this->db->sql_freeresult($result); if (!sizeof($notify_users)) { return; } // Allow notifications to perform actions before creating the insert array (such as run a query to cache some data needed for all notifications) $notification = $this->get_item_type_class($notification_type_name); $pre_create_data = $notification->pre_create_insert_array($data, $notify_users); unset($notification); $insert_buffer = new \phpbb\db\sql_insert_buffer($this->db, $this->notifications_table); // Go through each user so we can insert a row in the DB and then notify them by their desired means foreach ($notify_users as $user => $methods) { $notification = $this->get_item_type_class($notification_type_name); $notification->user_id = (int) $user; // Insert notification row using buffer. $insert_buffer->insert($notification->create_insert_array($data, $pre_create_data)); // Users are needed to send notifications $user_ids = array_merge($user_ids, $notification->users_to_query()); foreach ($methods as $method) { // setup the notification methods and add the notification to the queue if ($method) // blank means we just insert it as a notification, but do not notify them by any other means { if (!isset($notification_methods[$method])) { $notification_methods[$method] = $this->get_method_class($method); } $notification_methods[$method]->add_to_queue($notification); } } } $insert_buffer->flush(); // We need to load all of the users to send notifications $this->user_loader->load_users($user_ids); // run the queue for each method to send notifications foreach ($notification_methods as $method) { $method->notify(); } }
/** * {@inheritdoc} */ public function notify() { $insert_buffer = new \phpbb\db\sql_insert_buffer($this->db, $this->notifications_table); /** @var \phpbb\notification\type\type_interface $notification */ foreach ($this->queue as $notification) { $data = $notification->get_insert_array(); $insert_buffer->insert($data); } $insert_buffer->flush(); // We're done, empty the queue $this->empty_queue(); }