function save_config() { global $xoopsDB; if (!mysql_table_exists('ck2mod_config')) { mk_config_table(); } $sql = "delete from `ck2mod_config`"; $xoopsDB->query($sql); foreach ($_POST['setup'] as $name => $value) { $sql = "insert into `ck2mod_config` (config_name,config_value,config_type) values('{$name}','{$value}','module');"; $xoopsDB->query($sql); } }
// labeled $inc_name = $inc_num_ary[1] . $inc_num_ary[2] . (string) $inc_num_ary[3] . " "; // label, separator, number break; case 3: // year $inc_name = $inc_num_ary[5] . $inc_num_ary[2] . (string) $inc_num_ary[3] . " "; // year, separator, number break; default: alert("ERROR @ " + "<?php print __LINE__;?>"); } $do_inc_nature = (bool) ($inc_num_ary[4] == 1) ? "true" : "false"; // print "\n<SCRIPT>\n\t var do_inc_nature={$do_inc_nature};\n</SCRIPT>\n"; if (!mysql_table_exists("{$GLOBALS['mysql_prefix']}places")) { $city_name_array_str = ""; } else { $query = "SELECT * FROM `{$GLOBALS['mysql_prefix']}places` ORDER BY `id`"; // get all names $place_result = mysql_query($query) or do_error($query, 'mysql query failed', mysql_error(), basename(__FILE__), __LINE__); $num_places = mysql_num_rows($result); // 3/17/11 $city_name_array_str = $sep = ""; while ($place_row = stripslashes_deep(mysql_fetch_assoc($place_result))) { $city_name_array_str .= "{$sep}'{$place_row['name']}'"; $sep = ","; } } // apply cid data if available $street = isset($cid_street) ? $cid_street : $res_row['street'];
update_setting('_inc_num', $outstr); } } $the_table = "{$GLOBALS['mysql_prefix']}codes"; // 12/15/10 if (!mysql_table_exists($the_table)) { $query = "CREATE TABLE `{$the_table}` (\n\t\t\t `id` int(7) NOT NULL AUTO_INCREMENT,\n\t\t\t `code` varchar(20) NOT NULL,\n\t\t\t `text` varchar(64) NOT NULL,\n\t\t\t `sort` int(3) NOT NULL DEFAULT '999',\n\t\t\t `_by` int(7) NOT NULL DEFAULT 0,\n\t\t\t `_from` varchar(16) NOT NULL DEFAULT '',\n\t\t\t `_on` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,\n\t\t\t PRIMARY KEY (`id`)\n\t\t\t\t) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE utf8_unicode_ci;"; $result = mysql_query($query) or do_error("", 'mysql query failed', mysql_error(), basename(__FILE__), __LINE__); // 3/12/10 $query = "INSERT INTO `{$the_table}` (`code`, `text`, `sort`) VALUES\n\t\t\t\t('ex-1', 'Instructed to return to station ASAP', 999),\n\t\t\t\t('ex-2', 'Requested to contact Dispatch Central by voice', 999);"; $result = mysql_query($query) or do_error("", 'mysql query failed', mysql_error(), basename(__FILE__), __LINE__); // 3/12/10 } $the_table = "{$GLOBALS['mysql_prefix']}hints"; // 11/30/10 if (!mysql_table_exists($the_table)) { $query = "CREATE TABLE IF NOT EXISTS `{$the_table}` (\n\t\t\t\t`id` int(7) NOT NULL AUTO_INCREMENT,\n\t\t\t\t`tag` varchar(8) COLLATE utf8_unicode_ci NOT NULL,\n\t\t\t\t`hint` varchar(200) COLLATE utf8_unicode_ci NOT NULL,\n\t\t\t\t`_by` int(7) NOT NULL DEFAULT '0',\n\t\t\t\t`_from` varchar(16) CHARACTER SET latin1 DEFAULT NULL,\n\t\t\t\t`_on` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,\n\t\t\t\tPRIMARY KEY (`id`)\n\t\t\t) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci AUTO_INCREMENT=1;"; $result = mysql_query($query) or do_error($query, 'mysql_query() failed', mysql_error(), __FILE__, __LINE__); $query = "INSERT INTO `{$GLOBALS['mysql_prefix']}hints` (`tag`, `hint`) VALUES\n\t\t\t\t('_loca', 'Location - type in location in fields, click location on map or use *Located at Facility* menu below '),\n\t\t\t\t('_city', 'City - defaults to default city set in configuration. Enter City if required'),\n\t\t\t\t('_state', 'State - US State or non-US Country code - e.g. UK for United Kingdom'),\n\t\t\t\t('_phone', 'Phone number - for US only, you can use the lookup button to get the callers name and location using the White Pages'),\n\t\t\t\t('_nature', 'Incident nature or Type - Available types are set in in_types table in the configuration'),\n\t\t\t\t('_prio', 'Incident priority - Normal, Medium or High. Affects order and coloring of incidents on Situation display'),\n\t\t\t\t('_proto', 'Incident Protocol - this will show automatically if a protocol is set for the Incident Enter the configuration'),\n\t\t\t\t('_synop', 'Synopsis - Details about the incident, ensure as much detail as possible is completed'),\n\t\t\t\t('_911', '911 contact information'),\n\t\t\t\t('_caller', 'Caller reporting the incident'),\n\t\t\t\t('_name', 'Incident Name - Partially completed and prepend or append incident ID depending on setting. Enter an easily identifiable name.'),\n\t\t\t\t('_booked', 'Scheduled Date. Must be set if incident Status is *Scheduled*. Sets date and time for a future booked Incident, mainly used for non immediate patient transport. Click on Radio button to show date field'),\n\t\t\t\t('_facy', 'Use the first dropdown menu to select the Facility where the incident is located at, use the second dropdown menu to select the facility where persons from the Incident will be received'),\n\t\t\t\t('_start', 'Run-start, Incident start time. Defaults to current date and time or edit by clicking padlock icon to enable date & time fields'),\n\t\t\t\t('_status', 'Incident Status - Open or Closed or set to Scheduled for future booked calls'),\n\t\t\t\t('_end', 'Run-end - incident end time. When incident is closed, click on radio button which will enable date & time fields'),\n\t\t\t\t('_disp', 'Disposition - additional comments about incident, particularly closing it'),\n\t\t\t\t('_coords', 'Incident Lat/Lng - set by clicking on the map for the location or by selecting location with the address fields.'),\n\t\t\t\t('_asof', 'Date/time of most recent incident data update');"; $result = mysql_query($query) or do_error($query, 'mysql_query() failed', mysql_error(), __FILE__, __LINE__); } // end if (!(mysql_table_exists())) // 11/30/10 $query = "ALTER TABLE `{$GLOBALS['mysql_prefix']}captions` \n\t\t\tCHANGE `_by` `_by` INT( 7 ) NOT NULL DEFAULT '0',\n\t\t\tCHANGE `_from` `_from` VARCHAR( 16 ) CHARACTER SET latin1 COLLATE latin1_swedish_ci NULL; "; $result = mysql_query($query) or do_error("", 'mysql query failed', mysql_error(), basename(__FILE__), __LINE__); // 3/12/10 $nature = get_text("Nature"); // 3/30/11 $disposition = get_text("Disposition"); $patient = get_text("Patient"); $incident = get_text("Incident");
if ($roundbitrate >= $StandardBitrate - ($LastBitrate - $StandardBitrate) / 2) { break; } $LastBitrate = $StandardBitrate; } } } return $BitrateTable[$roundbitrate]; } if (!empty($_REQUEST['scan'])) { if (mysql_table_exists('files')) { $SQLquery = 'DROP TABLE files'; safe_mysql_query($SQLquery); } } if (!mysql_table_exists('files')) { $SQLquery = 'CREATE TABLE files ('; $SQLquery .= ' ID mediumint(8) unsigned NOT NULL auto_increment,'; $SQLquery .= ' filename text NOT NULL,'; $SQLquery .= ' md5_file varchar(32) NOT NULL default "",'; $SQLquery .= ' md5_data varchar(32) NOT NULL default "",'; $SQLquery .= ' md5_data_source varchar(32) NOT NULL default "",'; $SQLquery .= ' filesize int(10) unsigned NOT NULL default "0",'; $SQLquery .= ' fileformat varchar(255) NOT NULL default "",'; $SQLquery .= ' audio_dataformat varchar(255) NOT NULL default "",'; $SQLquery .= ' video_dataformat varchar(255) NOT NULL default "",'; $SQLquery .= ' audio_bitrate float NOT NULL default "0",'; $SQLquery .= ' video_bitrate float NOT NULL default "0",'; $SQLquery .= ' playtime_seconds varchar(255) NOT NULL default "",'; $SQLquery .= ' tags varchar(255) NOT NULL default "",'; $SQLquery .= ' artist varchar(255) NOT NULL default "",';
function test_bdd() { global $bdd_hote; global $bdd_user; global $bdd_pass; global $bdd_base; global $ref_parrain; global $install_config_name; global $iui; global $bdd_creer; $text_retour = ""; // La case de création de base de données est cochée if (isset($bdd_creer) && $bdd_creer) { // Tente une connexion au serveur MySQL (en cas d'erreur je passe outre) $link = @mysql_connect($bdd_hote, $bdd_user, $bdd_pass); if (!$link) { $text_retour .= "<div class=\"red_info\">Impossible de se connecter au serveur MySQL : " . mysql_error() . ".<br /><br /></div>" . BDD_form(); return $text_retour; } // Tente la création de la base de données $sql = "CREATE DATABASE " . $bdd_base; if (!mysql_query($sql, $link)) { $text_retour .= "<div class=\"red_info\">Impossible de créer la base de données : " . mysql_error() . ".<br /><br /></div>"; } } // Tente d'établir une connexion avec la base de données try { $bdd = new PDO("mysql:host=" . $bdd_hote . "; dbname=" . $bdd_base . "", $bdd_user, $bdd_pass, NULL); } catch (Exception $e) { // echo 'Exception reçue : ', $e->getMessage(), "\n"; $text_retour .= "<div class=\"red_info\">Les paramètres de connexion à la base de données sont incorrectes<br />Veuillez contacter votre administrateur système ou votre prestataire en hébergement Internet pour obtenir les paramètres corrects.<br /><br /></div>" . BDD_form(); return $text_retour; } // Si pas d'erreur lors de la création, le texte de retour est écrasé $text_retour = ""; // Test de création d'une table $query = "CREATE TABLE IF NOT EXISTS `table_test` (`test` FLOAT NULL) ENGINE = innodb;"; $bdd->query($query); $table_test_ok = mysql_table_exists($bdd, "table_test"); if (!$table_test_ok) { $text_retour .= "<div class=\"red_info\">Vos droits sur la base de données " . $bdd_base . " sont insuffisants. (Impossible de créer une table)<br />Veuillez contacter votre administrateur système ou votre prestataire en hébergement Internet pour résoudre ce problème.<br /><br /></div>" . BDD_form(); return $text_retour; } // Test de supression d'une table $query = "DROP TABLE IF EXISTS `table_test`;"; $bdd->query($query); $table_test_deleted = mysql_table_exists($bdd, "table_test"); if ($table_test_deleted) { $text_retour .= "<div class=\"red_info\">Vos droits sur la base de données " . $bdd_base . " sont insuffisants. (Impossible de supprimer une table)<br />Veuillez contacter votre administrateur système ou votre prestataire en hébergement Internet pour résoudre ce problème.<br /><br /></div>" . BDD_form(); return $text_retour; } // Test d'existence d'une précédente installation (non bloquant) $table_annu_exist = mysql_table_exists($bdd, "annuaire"); if ($table_annu_exist) { $text_retour .= "<div class=\"red_info\">Le système d'installation a détecté une version précédente de l'application Lundi Matin Business<br />Si vous complétez le processus d'installation, les anciennes données seront archivées et sauvegardées.<br /><br /></div>"; } $text_retour .= " La configuration du système est correcte.<br />\r\n\t\t\t\t\t\tLa connexion à votre base de données s'est déroulée avec succès.<br />\r\n\t\r\n\t\t\t\t\t\t\t\t\t\t<form action=\"install_lmb.php\" method=\"POST\" id=\"licence_form\">\r\n\t\t\t\t\t\t\t\t\t\t<p>\r\n\t\t\t\t\t\t\t\t\t\t<input type=\"hidden\" name=\"etape\" value=\"4\" />\r\n\t\t<input type=\"hidden\" name=\"iui\" value=\"" . $iui . "\" />\r\n\t\t\t\t\t\t\t\t\t\t<input type=\"submit\" class=\"bt_suite\" name=\"go_etape_4\" class=\"bt_suite\" value=\"Suivant\" />\r\n\t\t\t\t\t\t\t\t\t\t</p>\r\n\t\t\t\t\t\t\t\t\t\t</form>"; // Configuration de la base de données OK // On inscrit les informations dans le fichiers de config. if (!($file_config_bdd = @fopen($DIR . $install_config_name, "w"))) { $erreur = "Vous n'avez pas les droits en lecture sur le fichier " . $install_config_name . " "; erreur($erreur); } $file_content = "<?php\r\n// *************************************************************************************************************\r\n// PARAMETRES DU SERVEUR\r\n// *************************************************************************************************************\r\n// BASE DE DONNEE\r\n\$bdd_hote = \"" . addslashes($bdd_hote) . "\"; \r\n\$bdd_user = \"" . addslashes($bdd_user) . "\"; \r\n\$bdd_pass = \"" . addslashes($bdd_pass) . "\"; \r\n\$bdd_base = \"" . addslashes($bdd_base) . "\";\r\n\r\n\$ref_parrain = \"" . $ref_parrain . "\";\r\n\r\n?>"; if (!fwrite($file_config_bdd, $file_content)) { $erreur = "Vous n'avez pas les droits en écriture sur le fichier " . $install_config_name . " "; erreur($erreur); } fclose($file_config_bdd); return $text_retour; }
function get_xoopsModulesConfig($config_type = 'module') { global $xoopsDB; if (!mysql_table_exists('ck2mod_config')) { mk_config_table(); } $sql = "select config_sn,config_name,config_value from `ck2mod_config` where config_type='{$config_type}'"; $result = $xoopsDB->query($sql); while (list($config_sn, $config_name, $config_value) = $xoopsDB->fetchRow($result)) { $xoopsModulesConfig[$config_name] = $config_value; } return $xoopsModulesConfig; }
function snap($source, $stuff = "") { // 10/18/08 , 3/5/09 - debug tool global $snap_table; // defined in istest.inc.php if (mysql_table_exists($snap_table)) { $query = "DELETE FROM `{$snap_table}` WHERE `when`< (NOW() - INTERVAL 1 DAY)"; // first remove old $result = mysql_query($query) or do_error($query, 'mysql query failed', mysql_error(), basename(__FILE__), __LINE__); if (is_array($source)) { $source = "array (" . count($source) . ")"; } $query = sprintf("INSERT INTO `{$snap_table}` (`source`,`stuff`) \n\t\t\tVALUES(%s,%s)", quote_smart_deep(trim($source)), quote_smart_deep(trim($stuff))); $result = mysql_query($query) or do_error($query, 'mysql_query() failed', mysql_error(), basename(__FILE__), __LINE__); unset($result); } else { // dump(__LINE__); } }
return true; } } mysql_free_result($res); return false; } $tables = $dtc_database["tables"]; $nbr_tables = sizeof($tables); echo "Checking and updating {$nbr_tables} table structures:"; $tblnames = array_keys($tables); for ($i = 0; $i < $nbr_tables; $i++) { echo " " . $tblnames[$i]; $allvars = $tables[$tblnames[$i]]["vars"]; $varnames = array_keys($allvars); $numvars = sizeof($allvars); if (!mysql_table_exists($tblnames[$i])) { if (strstr($allvars[$varnames[0]], "auto_increment") != NULL) { $q = "CREATE TABLE IF NOT EXISTS " . $tblnames[$i] . "(\n" . $varnames[0] . " " . $allvars[$varnames[0]] . ",PRIMARY KEY (" . $varnames[0] . "));"; } else { $q = "CREATE TABLE IF NOT EXISTS " . $tblnames[$i] . "(\n" . $varnames[0] . " " . $allvars[$varnames[0]] . ");"; } // echo $q; $r = mysql_query($q) or die("Cannot execute query: \"{$q}\" line " . __LINE__ . " in file " . __FILE__ . ", mysql said: " . mysql_error()); } for ($j = 0; $j < $numvars; $j++) { if (!findFieldInTable($tblnames[$i], $varnames[$j])) { if (strstr($allvars[$varnames[$j]], "auto_increment") != FALSE) { // In case there was a primary key, drop it! $q = "ALTER IGNORE TABLE " . $tblnames[$i] . " DROP PRIMARY KEY;"; // Don't die, in some case it can fail! $r = mysql_query($q);
// Auteur: Joyrock //////////////////////////////////////////////: // 21/10/2008: Nettoyage du code, première version // 24/10/2008 - Joyrock : Ajout des logs //On utilise le charset UTF-8 Header('Content-Type: text/html; charset=utf-8'); //Variables locales en français setlocale(LC_ALL, 'fr_FR', 'fr', 'fr_FR@euro'); //Les includes if (!file_exists('config.inc.php')) { die("<p>Le fichier de configuration config.inc.php ne peut être trouvé.</p>"); } require 'config.inc.php'; include 'function.inc.php'; include 'language.php'; if (!mysql_table_exists("servers_config")) { die("<p>Les tables SQL n'existent pas dans la base " . $db_name . "</p><p><a href='create_table.php'>Cliquez ici pour créer les tables.</a></p>"); } //Compatibilité PHP4 et PHP5pour les librairies PHP de gestion XML // http://alexandre.alapetite.net/doc-alex/domxml-php4-php5/index.en.html if (version_compare(PHP_VERSION, '5', '>=')) { require_once 'domxml-php4-to-php5.php'; } //Initialisation de la session $rank = null; $user_name = null; $userguild = null; $id = null; $conf = null; //Si la session n'est pas initiée alors... if (!headers_sent() && !$_SESSION) {
case "time": $max = 5; print "<TD><INPUT MAXLENGTH={$max} SIZE={$max} TYPE= \"text\" NAME=\"frm_" . mysql_field_name($result, $i) . "\" VALUE=\"{$row[$i]}\" onChange = \"this.value=JSfnTrim(this.value)\"/> "; // print ($do_hints)? "<SPAN class='$mand_opt' >" . $hints[mysql_field_type($result, $i)] . "</SPAN>": ""; $hint_str = empty($comments_ar[mysql_field_name($result, $i)]) ? "" : " « <SPAN CLASS='hint'>{$comments_ar[mysql_field_name($result, $i)]}"; print "{$hint_str}</TD></TR>\n\t"; break; case "int": case "bigint": $gotit = FALSE; if (mysql_field_name($result, $i) != $indexname && strtolower(substr(mysql_field_name($result, $i), -$id_lg)) == $FK_id) { // maybe dropdown $lgth = strlen(mysql_field_name($result, $i)); $thetable = substr(mysql_field_name($result, $i), 0, $lgth - $id_lg); // extract corresponding table name if (mysql_table_exists($thetable)) { // does table exist? $query = "SELECT * FROM `{$mysql_prefix}{$thetable}` LIMIT 1"; // order will be by 2nd column $temp_result = mysql_query($query) or myerror(get_file(__FILE__), __LINE__, 'mysql_error', $query); $thecolumn = mysql_field_name($temp_result, 1); // field name 2nd column $query = "SELECT * FROM `{$mysql_prefix}{$thetable}` ORDER BY `{$thecolumn}` ASC"; // get option values $temp_result = mysql_query($query) or myerror(get_file(__FILE__), __LINE__, 'mysql_error', $query); print "\t\t<TD><SELECT NAME='frm_" . mysql_field_name($result, $i) . "'>\n"; if ($row[mysql_field_name($result, $i)] == '0') { print "\t\t<OPTION VALUE='0' selected>Select</OPTION>\n"; } // no selection made while ($sel_row = mysql_fetch_array($temp_result)) {
?> <BR /> <LI><A HREF="#" onClick = "do_Post('evacuees');">Evacuees</A> <?php } // end if evacuees if (mysql_table_exists("{$GLOBALS['mysql_prefix']}constituents")) { // 6/4/09 ?> <BR /> <LI><A HREF="#" onClick = "do_Post('constituents');">Constituents</A> <?php if ($asterisk && mysql_table_exists("{$GLOBALS['mysql_prefix']}pin_ctrl")) { // 7/16 ?> <LI><A HREF="#" onClick = "do_Post('pin_ctrl');">PIN Control</A> <!-- 4/9/10 --> <?php } // end 'pin_ctrl' if ($istest) { ?> <LI><A HREF="#" onClick = "do_Post('log');">Log</A> <LI><A HREF="#" onClick = "do_Post('settings');">Settings</A> <LI><A HREF="#" onClick = "do_Post('ticket');">Tickets</A> <LI><A HREF="#" onClick = "do_Post('responder');">Units</A> <LI><A HREF="#" onClick = "do_Post('action');">Actions</A> <LI><A HREF="#" onClick = "do_Post('patient');">Patients</A>
die('<FONT COLOR="red">' . mysql_error() . '</FONT><hr><TT>' . $SQLquery . '</TT>'); } return $result; } function mysql_table_exists($tablename) { return (bool) mysql_query('DESCRIBE ' . $tablename); } /* ======================= DATABASE TABLE MANAGEMENT ======================== */ // check and see if the tab exists, if so purge the f****r if (mysql_table_exists(PODCAST_TABLE)) { $SQLquery = 'DROP TABLE `' . PODCAST_TABLE . '`'; safe_mysql_query($SQLquery); } // verify tha the table is gone, then build a new table if (!mysql_table_exists(PODCAST_TABLE)) { $SQLquery = 'CREATE TABLE `' . PODCAST_TABLE . '` ('; $SQLquery .= ' `ID` mediumint(8) unsigned NOT NULL auto_increment,'; $SQLquery .= ' `artist` varchar(255) NOT NULL default "",'; $SQLquery .= ' `title` varchar(255) NOT NULL default "",'; $SQLquery .= ' `description` varchar(255) NOT NULL default "",'; $SQLquery .= ' `album` varchar(255) NOT NULL default "",'; $SQLquery .= ' `length` integer NOT NULL default "0",'; $SQLquery .= ' `date` integer NOT NULL,'; $SQLquery .= ' `filepath` text NOT NULL,'; $SQLquery .= ' PRIMARY KEY (`ID`)'; $SQLquery .= ') TYPE=MyISAM;'; safe_mysql_query($SQLquery); } /* ===================== PROCESS PODCAST DIRECTORY ========================== */ // lets opne up the directory to process (podcast enclosure location)
function etabouvert($date_a_verifier, $de_heure, $a_heure, $classe_select) { global $prefix_base; global $dbDb; // a l'état initial l'établissement est considérer comme fermer $ouvert = 'non'; // on explose la date soit sql soit fr $date_selection = explode('/', $date_a_verifier); if(!empty($date_selection[1])) { $jour = $date_selection[0]; $mois = $date_selection[1]; $annee = $date_selection[2]; } else { $date_selection = explode('-', $date_a_verifier); $jour = $date_selection[2]; $mois = $date_selection[1]; $annee = $date_selection[0]; } // date au format SQL $date_sql = $annee.'-'.$mois.'-'.$jour; // pour connaitre le jour lundi, mardi, ... $joursem = aff_jour($jour, $mois, $annee); // on compte le nombre de jour trouvé qui soit ouvert $sql="SELECT count(*) FROM ".$prefix_base."horaires_etablissement WHERE jour_horaire_etablissement = '".$joursem."' AND ouvert_horaire_etablissement = '1' AND ( '".$de_heure."' BETWEEN ouverture_horaire_etablissement AND fermeture_horaire_etablissement OR '".$a_heure."' BETWEEN ouverture_horaire_etablissement AND fermeture_horaire_etablissement OR ouverture_horaire_etablissement BETWEEN '".$de_heure."' AND '".$a_heure."' OR fermeture_horaire_etablissement BETWEEN '".$de_heure."' AND '".$a_heure."' )"; //echo "0 : $sql<br />"; $requete_nb = old_mysql_result(mysqli_query($GLOBALS["mysqli"], $sql),0); // ensuit on vérifie qu'une table edt_calendrier existe $table_edt_calendrier = 'non'; $table= ''; $table = $prefix_base.'edt_calendrier'; $exist_table = mysql_table_exists($table, $dbDb); if ( $exist_table === 1 ) { $table_edt_calendrier = 'oui'; } // si la table existe est qu'elle n'est pas vide alors on vérifie que le jour ne soit pas férier ou dans une période de vacances $requete_nb_calendrier_1 = '0'; $requete_nb_calendrier_2 = '0'; // définition des dates en timestamps $debut_calendrier_ts_gmt = timestamps_encode($date_sql, $de_heure); $fin_calendrier_ts_gmt = timestamps_encode($date_sql, $a_heure); if ( $table_edt_calendrier === 'oui' ) { $sql="SELECT count(*) FROM ".$prefix_base."edt_calendrier WHERE etabferme_calendrier = '0' AND classe_concerne_calendrier = '' AND ( '".$debut_calendrier_ts_gmt."' BETWEEN debut_calendrier_ts AND fin_calendrier_ts OR '".$fin_calendrier_ts_gmt."' BETWEEN debut_calendrier_ts AND fin_calendrier_ts OR debut_calendrier_ts BETWEEN '".$debut_calendrier_ts_gmt."' AND '".$debut_calendrier_ts_gmt."' OR fin_calendrier_ts BETWEEN '".$debut_calendrier_ts_gmt."' AND '".$fin_calendrier_ts_gmt."' )"; //echo "1 : $sql<br />"; $requete_nb_calendrier_1 = old_mysql_result(mysqli_query($GLOBALS["mysqli"], $sql),0); } // on fait de même si c'est pour une classe est précisé if ( $table_edt_calendrier === 'oui' and $classe_select != '' ) { $sql="SELECT count(*) FROM ".$prefix_base."edt_calendrier WHERE etabferme_calendrier = '0' AND ( classe_concerne_calendrier LIKE '".$classe_select.";%;' OR classe_concerne_calendrier LIKE '%;".$classe_select.";%' OR classe_concerne_calendrier LIKE '%;".$classe_select."' OR classe_concerne_calendrier = '".$classe_select."' ) AND ( '".$debut_calendrier_ts_gmt."' BETWEEN debut_calendrier_ts AND fin_calendrier_ts OR '".$fin_calendrier_ts_gmt."' BETWEEN debut_calendrier_ts AND fin_calendrier_ts OR debut_calendrier_ts BETWEEN '".$debut_calendrier_ts_gmt."' AND '".$fin_calendrier_ts_gmt."' OR fin_calendrier_ts BETWEEN '".$debut_calendrier_ts_gmt."' AND '".$fin_calendrier_ts_gmt."' )"; //echo "2 : $sql<br />"; $requete_nb_calendrier_2 = old_mysql_result(mysqli_query($GLOBALS["mysqli"], $sql),0); } /* // DEBUG echo "<pre> \$requete_nb=$requete_nb \$requete_nb_calendrier_1=$requete_nb_calendrier_1 \$requete_nb_calendrier_2=$requete_nb_calendrier_2 </pre>"; */ if ( $requete_nb != '0' and $requete_nb_calendrier_1 === '0' and $requete_nb_calendrier_2 === '0' ) { $ouvert = 'oui'; } else { $ouvert = 'non'; } return($ouvert); }
<body> <div style="text-align:center;"><h1>Kusaba X Installation</h1></div> <?php echo '<h2>Checking configuration file...</h2>'; if (file_exists('config.php')) { require 'config.php'; require KU_ROOTDIR . 'inc/functions.php'; if (KU_RANDOMSEED != "ENTER RANDOM LETTERS/NUMBERS HERE" && KU_RANDOMSEED != "") { echo 'Configuration appears correct.'; echo '<h2>Checking database...</h2>'; $reqiredtables = array("ads", "announcements", "banlist", "bannedhashes", "blotter", "boards", "board_filetypes", "embeds", "events", "filetypes", "front", "loginattempts", "modlog", "module_settings", "posts", "reports", "sections", "staff", "watchedthreads", "wordfilter"); foreach ($reqiredtables as $tablename) { if (KU_DBTYPE == 'mysql' || KU_DBTYPE == 'mysqli') { if (!mysql_table_exists(KU_DBDATABASE, KU_DBPREFIX . $tablename)) { die("Couldn't find the table <strong>" . KU_DBPREFIX . $tablename . "</strong> in the database. Please <a href=\"install-mysql.php\"><strong><u>insert the mySQL dump</u></strong></a>."); } } if (KU_DBTYPE == 'postgres7' || KU_DBTYPE == 'postgres8' || KU_DBTYPE == 'postgres') { if (!pgsql_table_exists(KU_DBDATABASE, KU_DBPREFIX . $tablename)) { die("Couldn't find the table <strong>" . KU_DBPREFIX . $tablename . "</strong> in the database. Please <a href=\"install-pgsql.php\"><strong><u>insert the PostgreSQL dump</u></strong></a>."); } } if (KU_DBTYPE == 'sqlite') { if (!sqlite_table_exists(KU_DBDATABASE, KU_DBPREFIX . $tablename)) { die("Couldn't find the table <strong>" . KU_DBPREFIX . $tablename . "</strong> in the database. Please <a href=\"install-sqlite.php\"><strong><u>insert the SQLite dump</u></strong></a>."); } } } echo 'Database appears correct.';
function make_stats() { global $conf_mysql_db; global $conf_webalizer_country_graph; global $pro_mysql_domain_table; global $conf_dtcshared_path; global $conf_generated_file_path; global $conf_use_webalizer; global $conf_use_awstats; global $conf_use_visitors; $today_midnight = mktime(0, 0, 0); $q = "SELECT admin.adm_login,admin.path,subdomain.subdomain_name,domain.name\n\tFROM admin,domain,subdomain\n\tWHERE domain.owner=admin.adm_login\n\tAND subdomain.domain_name=domain.name\n\tAND subdomain.ip='default'\n\tAND subdomain.generate_vhost='yes'\n\tORDER BY admin.adm_login,domain.name,subdomain.subdomain_name"; $r = mysql_query($q) or die("Cannot query {$q} line " . __LINE__ . " file " . __FILE__ . " sql said " . mysql_error()); $n = mysql_num_rows($r); for ($i = 0; $i < $n; $i++) { $a = mysql_fetch_array($r); $fullpath = $a["path"] . "/" . $a["name"] . "/subdomains/" . $a["subdomain_name"] . "/logs"; if (!file_exists("{$fullpath}/index.php")) { copy("{$conf_generated_file_path}/dtc_stats_index.php", "{$fullpath}/index.php"); } $html_fullpath = $a["path"] . "/" . $a["name"] . "/subdomains/" . $a["subdomain_name"] . "/html"; $table_name = str_replace("-", "A", str_replace(".", "_", $a["name"] . '$' . $a["subdomain_name"] . '$' . "xfer")); echo "Checking {$table_name} ... "; if (mysql_table_exists("apachelogs", $table_name)) { mysql_select_db("apachelogs"); $qus = "SHOW TABLE STATUS LIKE '" . $table_name . "'"; $res = mysql_query($qus) or die("Cannot execute query \"{$qus}\" line " . __LINE__ . " file " . __FILE__ . ": " . mysql_error()); $ars = mysql_fetch_array($res); if ($ars["Rows"] > 0) { $query = "SELECT MIN(time_stamp) AS start FROM apachelogs.`" . $table_name . "`"; $result = mysql_query($query) or die("Cannot execute query \"{$query}\" line " . __LINE__ . " file " . __FILE__ . ": " . mysql_error()); $start = mysql_result($result, 0, "start"); if ($start < $today_midnight) { echo "stats to be done!"; } while ($start < $today_midnight) { $year = date("Y", $start); $month = date("m", $start); $day = date("d", $start); $dump_folder = $fullpath . "/" . $year . "/" . $month; $dump_filename = $dump_folder . "/access_" . $day . ".log"; # $start_24h = $start + (60*60*24); # $year_24h = date("Y",$start_24h); # $month_24h = date("m",$start_24h); # $day_24h = date("d",$start_24h); # # $end = mktime(0,0,0,$month_24h,$day_24h,$year_24h); $secs = $start % (60 * 60 * 24); $end = $start - $secs + 60 * 60 * 24; echo "Querying SELECT * FROM apachelogs." . $table_name . "..."; $query_dump = "SELECT * FROM apachelogs.`" . $table_name . "` WHERE time_stamp>='" . $start . "' AND time_stamp<='" . $end . "' ORDER BY time_stamp"; $result_dump = mysql_query($query_dump) or die("Cannot execute query \"{$query_dump}\" file " . __FILE__ . " line " . __LINE__ . ": " . mysql_error()); $dump_num_rows = mysql_num_rows($result_dump); if ($dump_num_rows > 0) { echo "{$dump_num_rows} records for {$dump_filename}...\n"; if (!is_dir($dump_folder)) { exec("mkdir -p {$dump_folder}"); } $handle = fopen($dump_filename, "w+"); for ($z = 0; $z < $dump_num_rows; $z++) { $rezar = mysql_fetch_array($result_dump); // in case we don't have a request_method logged if (!isset($rezar["request_method"])) { $rezar["request_method"] = "GET"; } // in case we don't have a HTTP proto logged if (!isset($rezar["request_protocol"])) { $rezar["request_protocol"] = "HTTP/1.1"; } if (strstr($rezar["referer"], $a["name"])) { $rezar["referer"] = "self"; } $content = $rezar["remote_host"] . " - - " . date("[d/M/Y:H:i:s O] ", $rezar["time_stamp"]) . '"' . $rezar["request_method"] . " " . $rezar["request_uri"] . " " . $rezar["request_protocol"] . '" ' . $rezar["status"] . " " . $rezar["bytes_sent"] . ' "' . $rezar["referer"] . '" "' . $rezar["agent"] . '"' . "\n"; if (!fwrite($handle, $content)) { echo "WARNING: Cannot write logfile, maybe disk full...\n"; } } fclose($handle); echo "Calculating webalizer stats for " . $day . " " . $month . " " . $year . "\n"; if ($conf_webalizer_country_graph != "yes") { $webalizer_cmd = "nice -n+20 webalizer -p -R 50 -Y -n " . $a["subdomain_name"] . "." . $a["name"] . " -o {$fullpath} {$dump_filename}"; } else { $webalizer_cmd = "nice -n+20 webalizer -p -R 50 -D " . $a["subdomain_name"] . "." . $a["name"] . ".dnscache -N 20 -n " . $a["subdomain_name"] . "." . $a["name"] . " -o {$fullpath} {$dump_filename}"; } echo "{$webalizer_cmd}\n"; exec($webalizer_cmd); if ($conf_use_visitors == "yes") { echo "Calculating visitor stats...\n"; $visitor_cmd = "nice -n+20 visitors -A -m 30 {$dump_folder}/access_*.log -o html > {$fullpath}/{$year}.{$month}.report.html"; echo "{$visitor_cmd}\n"; exec($visitor_cmd); // copy the template file if (!file_exists("{$fullpath}/visitors.php")) { copy("{$conf_dtcshared_path}/visitors_template/visitors.php", "{$fullpath}/visitors.php"); } } if ($conf_use_awstats == "yes" && file_exists("/usr/lib/cgi-bin/awstats.pl")) { if (!file_exists("{$fullpath}/awstats")) { mkdir("{$fullpath}/awstats"); } $fqdn = $a["subdomain_name"] . "." . $a["name"]; if (file_exists("/usr/share/doc/awstats/examples/awstats_buildstaticpages.pl")) { $aw_cmd = "export AWSTATS_FULL_DOMAIN=\"" . $a["subdomain_name"] . "." . $a["name"] . "\" ; export AWSTATS_DIR_DATA=\"{$fullpath}/awstats\" ; export AWSTATS_LOG_FILE=\"{$dump_filename}\" ; nice -n+20 /usr/share/doc/awstats/examples/awstats_buildstaticpages.pl -config=dtc -update -awstatsprog=/usr/lib/cgi-bin/awstats.pl -dir={$fullpath}/awstats"; exec($aw_cmd); } } // disable AWSTATS for now, it's too slow /* $stat_script = "#!/bin/sh AWSTATS_LOG_FILE=$dump_filename if [ -f \$AWSTATS_LOG_FILE ]; then AWSTATS_FULL_DOMAIN=".$a["subdomain_name"].".".$a["name"]." if [ ! -e $fullpath/awstats ]; then mkdir -p $fullpath/awstats fi AWSTATS_DIR_DATA=$fullpath/awstats export AWSTATS_LOG_FILE AWSTATS_FULL_DOMAIN AWSTATS_DIR_DATA echo \"\$AWSTATS_LOG_FILE \$AWSTATS_FULL_DOMAIN \$AWSTATS_DIR_DATA\" >> /tmp/awstats.log if [ -f /usr/share/doc/awstats/examples/awstats_buildstaticpages.pl ]; then nice -n+20 /usr/share/doc/awstats/examples/awstats_buildstaticpages.pl -config=dtc -update -awstatsprog=/usr/lib/cgi-bin/awstats.pl -dir=$fullpath/awstats nobodygroup=`cat /etc/group | cut -f 1 -d: | grep ^nobody` # if we can't find the nobody group, try nogroup if [ -z \"\"\$nobodygroup ]; then nobodygroup=`cat /etc/group | cut -f 1 -d: | grep ^nogroup` fi # if we can't find nogroup, then set to 65534 if [ -z \"\"\$nobodygroup ]; then nobodygroup=65534 fi chown nobody:\$nobodygroup $fullpath/awstats if [ ! -e $html_fullpath/awstats ]; then ln -s $fullpath/awstats $html_fullpath/awstats fi fi fi "; $filep = fopen("$fullpath/awstats.sh", "w+"); if( $filep == NULL){ die("Cannot open file for writing"); } fwrite($filep,$stat_script); fclose($filep); echo "$fullpath/awstats.sh\n"; chmod("$fullpath/awstats.sh",0750); exec ("$fullpath/awstats.sh"); */ } else { echo "table empty\n"; } $query_dump = "DELETE FROM apachelogs.`" . $table_name . "` WHERE time_stamp<='" . $end . "'"; $result_dump = mysql_query($query_dump) or die("Cannot execute query \"{$query_dump}\" file " . __FILE__ . " line " . __LINE__ . ": " . mysql_error()); $opt_table = "OPTIMIZE TABLE apachelogs.`" . $table_name . "` ;"; mysql_query($opt_table) or die("Cannot execute query \"{$opt_table}\" line " . __LINE__ . " file " . __FILE__ . ": " . mysql_error()); $qus = "SHOW TABLE STATUS LIKE '" . $table_name . "'"; $res = mysql_query($qus) or die("Cannot execute query \"{$qus}\" line " . __LINE__ . " file " . __FILE__ . ": " . mysql_error()); $ars = mysql_fetch_array($res); if ($ars["Rows"] == 0) { $start = $today_midnight; } else { $query = "SELECT MIN(time_stamp) AS start FROM apachelogs.`" . $table_name . "`"; $result = mysql_query($query) or die("Cannot execute query \"{$query}\" line " . __LINE__ . " file " . __FILE__ . ": " . mysql_error()); $start = mysql_result($result, 0, "start"); } } echo "[OK]\n"; } else { echo "No records!\n"; } } else { echo "no table!\n"; } mysql_select_db($conf_mysql_db); } }
$AcceptableExtensionsVideo['png']['png'] = array('png'); $AcceptableExtensionsVideo['bmp']['bmp'] = array('bmp'); } if (!empty($video_dataformat)) { return isset($AcceptableExtensionsVideo[$fileformat][$video_dataformat]) ? $AcceptableExtensionsVideo[$fileformat][$video_dataformat] : array(); } else { return isset($AcceptableExtensionsAudio[$fileformat][$audio_dataformat]) ? $AcceptableExtensionsAudio[$fileformat][$audio_dataformat] : array(); } } if (!empty($_REQUEST['scan'])) { if (mysql_table_exists(GETID3_DB_TABLE)) { $SQLquery = 'DROP TABLE `' . mysql_real_escape_string(GETID3_DB_TABLE) . '`'; mysql_query_safe($SQLquery); } } if (!mysql_table_exists(GETID3_DB_TABLE)) { $SQLquery = "CREATE TABLE `" . mysql_real_escape_string(GETID3_DB_TABLE) . "` ("; $SQLquery .= " `ID` int(11) unsigned NOT NULL auto_increment,"; $SQLquery .= " `filename` text NOT NULL,"; $SQLquery .= " `last_modified` int(11) NOT NULL default '0',"; $SQLquery .= " `md5_file` varchar(32) NOT NULL default '',"; $SQLquery .= " `md5_data` varchar(32) NOT NULL default '',"; $SQLquery .= " `md5_data_source` varchar(32) NOT NULL default '',"; $SQLquery .= " `filesize` int(10) unsigned NOT NULL default '0',"; $SQLquery .= " `fileformat` varchar(255) NOT NULL default '',"; $SQLquery .= " `audio_dataformat` varchar(255) NOT NULL default '',"; $SQLquery .= " `video_dataformat` varchar(255) NOT NULL default '',"; $SQLquery .= " `audio_bitrate` float NOT NULL default '0',"; $SQLquery .= " `video_bitrate` float NOT NULL default '0',"; $SQLquery .= " `playtime_seconds` varchar(255) NOT NULL default '',"; $SQLquery .= " `tags` varchar(255) NOT NULL default '',";
$title = addslashes($title); } mysql_query("INSERT INTO " . $prefix . "_temp_links_categories VALUES ('',0,'{$title}','{$cdescription}')"); $newcid = mysql_insert_id(); $result2 = mysql_query("SELECT title, url, description, date, name, email, hits, submitter, linkratingsummary, totalvotes, totalcomments FROM " . $prefix . "_links_links WHERE cid={$cid} AND sid=0"); while (list($ltitle, $url, $description, $date, $name, $email, $hits, $submitter, $linkratingsummary, $totalvotes, $totalcomments) = mysql_fetch_row($result2)) { if (!get_magic_quotes_runtime()) { $ltitle = addslashes($ltitle); $description = addslashes($description); $name = addslashes($name); $email = addslashes($email); } mysql_query("INSERT INTO " . $prefix . "_temp_links_links VALUES ('','{$newcid}','{$ltitle}','{$url}','{$description}','{$date}','{$name}','{$email}','{$hits}','{$submitter}','{$linkratingsummary}','{$totalvotes}','{$totalcomments}')"); } // if links_subcategories exists dump the data (proca). if (mysql_table_exists($prefix . "_links_subcategories", $dbname) == 1) { $result3 = mysql_query("SELECT sid,title FROM " . $prefix . "_links_subcategories WHERE cid={$cid}"); while (list($sid, $stitle) = mysql_fetch_row($result3)) { if (!get_magic_quotes_runtime()) { $stitle = addslashes($stitle); } mysql_query("INSERT INTO " . $prefix . "_temp_links_categories VALUES ('','{$newcid}','{$stitle}','')"); $newscid = mysql_insert_id(); $result4 = mysql_query("SELECT lid, title, url, description, date, name, email, hits, submitter, linkratingsummary, totalvotes, totalcomments FROM " . $prefix . "_links_links where cid={$cid} and sid={$sid}"); while (list($slid, $sltitle, $surl, $sdescription, $sdate, $sname, $semail, $shits, $ssubmitter, $slinkratingsummary, $stotalvotes, $stotalcomments) = mysql_fetch_row($result4)) { if (!get_magic_quotes_runtime()) { $sltitle = addslashes($sltitle); $sdescription = addslashes($sdescription); $sname = addslashes($sname); $semail = addslashes($semail); }