type == 1 when mysqlnd and unbuffered queries i.e. with use result // $result->type == 0 when not mysqlnd and buffered queries i.e. without use result if(extension_loaded('mysqlnd') && !empty($result->type)){ $return = (int) (!empty($result)); }elseif(extension_loaded('mysqli')){ $return = @mysqli_num_rows($result); }else{ $return = @mysql_num_rows($result); } return $return; } function softdie($txt){ $array = array(); $array['settings'] = $GLOBALS['settings']; $array['result'] = $txt; $array['tables'] = $GLOBALS['tables']; // Was there an error ? if(!empty($GLOBALS['error'])){ $array['error'] = $GLOBALS['error']; } echo ''.base64_encode(serialize($array)).'';die(); } // The settings $settings = unserialize(base64_decode('[[[settings]]]')); /*echo '
';
print_r($settings);
echo '
';*/ $host = $settings['softdbhost']; $user = $settings['softdbuser']; $pass = $settings['softdbpass']; $db = $settings['softdb']; //Make the Connection $__conn = @soft_mysql_connect($host, $user, $pass, true); //CHECK Errors and SELECT DATABASE if(!empty($__conn)){ if(!(@soft_mysql_select_db($db, $__conn))){ $error[] = 'No such database : '.$db.''; softdie('seldb'); } }else{ $error[] = 'MySQL connection could not be established'; softdie('conn'); } if(!empty($settings['get_tables'])){ $result = soft_mysql_query("SHOW TABLES", $__conn); if(!$result){ $error[] = 'Error while fetching tables from '.$db; softdie('err_tables'); } if(soft_mysql_num_rows($result) > 0){ while($row = soft_mysql_fetch_assoc($result)){ $tables[] = $row['Tables_in_'.$db]; } }else{ $error[] = 'Empty Database : '.$db; softdie('no_tables'); } } // Delete the file in the end. @unlink(__FILE__); softdie('DONE');