Simplify check_init()
This commit is contained in:
21
chat.php
21
chat.php
@ -3107,19 +3107,8 @@ function style_this($text, $styleinfo){
|
|||||||
}
|
}
|
||||||
|
|
||||||
function check_init(){
|
function check_init(){
|
||||||
global $db, $memcached;
|
global $db;
|
||||||
if(!MEMCACHED || !$found=$memcached->get(DBNAME . '-' . PREFIX . 'num-tables')){
|
return @$db->query('SELECT * FROM ' . PREFIX . 'settings LIMIT 1;');
|
||||||
if(DBDRIVER===0){
|
|
||||||
$result=$db->query("SHOW TABLES LIKE '" . PREFIX . "settings';");
|
|
||||||
$found=($result->fetch(PDO::FETCH_ASSOC)!==false);
|
|
||||||
}else{
|
|
||||||
$found=$db->query('SELECT * FROM ' . PREFIX . 'settings LIMIT 1;');
|
|
||||||
}
|
|
||||||
if(MEMCACHED){
|
|
||||||
$memcached->set(DBNAME . '-' . PREFIX . 'num-tables', $found);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return $found;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function destroy_chat(){
|
function destroy_chat(){
|
||||||
@ -3136,7 +3125,6 @@ function destroy_chat(){
|
|||||||
$db->exec('DROP TABLE ' . PREFIX . 'sessions;');
|
$db->exec('DROP TABLE ' . PREFIX . 'sessions;');
|
||||||
$db->exec('DROP TABLE ' . PREFIX . 'settings;');
|
$db->exec('DROP TABLE ' . PREFIX . 'settings;');
|
||||||
if(MEMCACHED){
|
if(MEMCACHED){
|
||||||
$memcached->delete(DBNAME . '-' . PREFIX . 'num-tables');
|
|
||||||
$memcached->delete(DBNAME . '-' . PREFIX . 'filter');
|
$memcached->delete(DBNAME . '-' . PREFIX . 'filter');
|
||||||
$memcached->delete(DBANEM . '-' . PREFIX . 'linkfilter');
|
$memcached->delete(DBANEM . '-' . PREFIX . 'linkfilter');
|
||||||
foreach($C['settings'] as $setting){
|
foreach($C['settings'] as $setting){
|
||||||
@ -3151,7 +3139,7 @@ function destroy_chat(){
|
|||||||
}
|
}
|
||||||
|
|
||||||
function init_chat(){
|
function init_chat(){
|
||||||
global $H, $I, $db, $memcached;
|
global $H, $I, $db;
|
||||||
$suwrite='';
|
$suwrite='';
|
||||||
if(check_init()){
|
if(check_init()){
|
||||||
$suwrite=$I['initdbexist'];
|
$suwrite=$I['initdbexist'];
|
||||||
@ -3205,9 +3193,6 @@ function init_chat(){
|
|||||||
foreach($settings as $pair){
|
foreach($settings as $pair){
|
||||||
$stmt->execute($pair);
|
$stmt->execute($pair);
|
||||||
}
|
}
|
||||||
if(MEMCACHED){
|
|
||||||
$memcached->delete(DBNAME . '-' . PREFIX . 'num-tables');
|
|
||||||
}
|
|
||||||
$reg=array(
|
$reg=array(
|
||||||
'nickname' =>$_REQUEST['sunick'],
|
'nickname' =>$_REQUEST['sunick'],
|
||||||
'passhash' =>md5(sha1(md5($_REQUEST['sunick'].$_REQUEST['supass']))),
|
'passhash' =>md5(sha1(md5($_REQUEST['sunick'].$_REQUEST['supass']))),
|
||||||
|
Reference in New Issue
Block a user