/** * Gets an array of information about an index. * * @param string $table The table * @param string $index The index * @param bool $debug Dump the query * @return array|bool Array of information about the index, or FALSE on error * @since 4.6.0 * @example * if ($index = safe_index('myTable', 'myIndex')) * { * echo "'myIndex' found in 'myTable' with the type of {$index['Index_type']}."; * } */ function safe_index($table, $index, $debug = false) { $index = strtolower($index); if ($r = safe_show('index', $table, $debug)) { foreach ($r as $a) { if (strtolower($a['Key_name']) === $index) { return $a; } } } return false; }
// /tmp is bad for permanent storage of files, // if no files are uploaded yet, switch to the files directory in the top-txp dir. if (!safe_count('txp_file', "1")) { $tempdir = find_temp_dir(); if ($tempdir == safe_field('val', 'txp_prefs', "name='file_base_path'")) { safe_update('txp_prefs', "val='" . doSlash(dirname(txpath) . DS . 'files') . "',prefs_id=1", "name='file_base_path'"); } } // After this point the changes after RC4 // let's get the advanced fields in the right order for ($i = 1; $i <= 10; $i++) { safe_update("txp_prefs", "position={$i}", "name='custom_{$i}_set'"); } // index ip column in txp_log $ipidxset = false; $i = safe_show('index', 'txp_log'); foreach ($i as $a => $b) { if ($b['Column_name'] == 'ip') { $ipidxset = true; } } if (!$ipidxset) { safe_query("alter table `" . PFX . "txp_log` ADD INDEX `ip` (`ip`)"); } // Language selection moves to Manage languages, Hide it from prefs. safe_update("txp_prefs", "type=2", "name='language'"); // Show gmt-selection in prefs safe_update('txp_prefs', "type=0, html='gmtoffset_select', position=50", "name='gmtoffset'"); if (!safe_field('name', 'txp_prefs', "prefs_id=1 and name='plugin_cache_dir'")) { $maxpos = safe_field('max(position)', 'txp_prefs', '1'); safe_insert('txp_prefs', "name='plugin_cache_dir', val='', prefs_id='1', type='1', event='admin', position='" . doSlash($maxpos) . "', html='text_input'");
function setup_3() { //$db_charsetcollation = _l10n_get_db_charsetcollation(); $sql = array(); $desc = 'COLUMNS'; $result = @safe_show($desc, 'textpattern'); $lang_found = false; $article_id_found = false; if (count($result)) { foreach ($result as $r) { if (!$lang_found and $r['Field'] === L10N_COL_LANG) { $lang_found = true; } if (!$article_id_found and $r['Field'] === L10N_COL_GROUP) { $article_id_found = true; } if ($article_id_found and $lang_found) { break; } } } if (!$lang_found) { $sql[] = ' ADD `' . L10N_COL_LANG . '` VARCHAR( 8 ) NOT NULL DEFAULT \'-\' AFTER `LastModID` , ADD INDEX(`' . L10N_COL_LANG . '`)'; } if (!$article_id_found) { $sql[] = ' ADD `' . L10N_COL_GROUP . '` INT( 11 ) NOT NULL DEFAULT \'0\' AFTER `' . L10N_COL_LANG . '` , ADD INDEX(`' . L10N_COL_GROUP . '`)'; } $this->add_report_item(gTxt('l10n-setup_3_title')); if (!empty($sql)) { $ok = @safe_alter('textpattern', join(',', $sql)); if ($lang_found) { $this->add_report_item(gTxt('l10n-skip_field', array('{field}' => L10N_COL_LANG, '{table}' => 'textpattern')), $ok, true); } else { $this->add_report_item(gTxt('l10n-add_field', array('{field}' => L10N_COL_LANG, '{table}' => 'textpattern')), $ok, true); } if ($article_id_found) { $this->add_report_item(gTxt('l10n-skip_field', array('{field}' => L10N_COL_GROUP, '{table}' => 'textpattern')), $ok, true); } else { $this->add_report_item(gTxt('l10n-add_field', array('{field}' => L10N_COL_GROUP, '{table}' => 'textpattern')), $ok, true); } } else { $this->add_report_item(gTxt('l10n-skip_field', array('{field}' => L10N_COL_LANG, '{table}' => 'textpattern')), true, true); $this->add_report_item(gTxt('l10n-skip_field', array('{field}' => L10N_COL_GROUP, '{table}' => 'textpattern')), true, true); } }