function collectData($type) { initTable($type); $tables = array('socdem' => array('table' => 'ank1', 'field' => 'user_id'), 'potreb' => array('table' => 'ank2', 'field' => 'person_id', 'user_fnc' => 'personByUser')); $total = 0; $st = query('select * from panelie_user where status_id in (10,11) and is_tester=0'); while ($obj = mysql_fetch_assoc($st)) { if (isset($tables[$type]['user_fnc'])) { $obj['user_id'] = $tables[$type]['user_fnc']($obj['user_id']); } if ($obj1 = mysql_fetch_assoc(query('select * from panelie_' . $tables[$type]['table'] . ' where ' . $tables[$type]['field'] . '=' . $obj['user_id']))) { $binds = array(); $binds[] = 'id=' . $obj['user_id']; $st2 = query("select * from panelie_single_choice where anketa_type='{$type}' and anketa_id='" . $obj1['id'] . "'"); while ($ans = mysql_fetch_assoc($st2)) { $binds[] = $ans['question_name'] . "=" . $ans['value']; if ($ans['descr']) { $binds[] = $ans['question_name'] . "_descr='" . $ans['descr'] . "'"; } } $oldName = ''; $values = array(); $freqs = array(); $descr = NULL; $st2 = query("select * from panelie_multiple_choice where anketa_type='{$type}' and anketa_id='" . $obj1['id'] . "' order by question_name"); while ($ans = mysql_fetch_assoc($st2)) { if ($oldName != $ans['question_name'] && $oldName) { $binds = array_merge($binds, applyData($oldName, $values, $freqs, $descr)); $values = array(); $freqs = array(); $descr = NULL; } $values[] = $ans['value']; if ($ans['freq']) { $freqs[$ans['value']] = $ans['freq']; } if ($ans['descr']) { $descr = $ans['descr']; } $oldName = $ans['question_name']; } $binds = array_merge($binds, applyData($oldName, $values, $freqs, $descr)); if ($type == 'socdem') { $binds[] = getDistrict($obj['city_id']); } $q = "insert into " . $type . "_data set " . join(', ', $binds); } // print $q."\n"; query($q); $total++; } print "{$total} rows inserted into table " . $type . "_data\n"; }
/** * Returns an array of Science_Chemistry_Element objects belonging to an element family * * @param string $family * @return array Science_Chemistry_Element objects * @access public */ function getElementFamily($family) { if (empty($this->periodic_table)) { initTable(); } $elemlist = array(); foreach ($this->periodic_table as $sym => $elem) { if ($elem->family == $family) { $elemlist[$sym] = $elem; } } return $elemlist; }
/** * eval_ccpc_setSettings - Enregistre les réglages de l'évaluation sélectionnée * * @category : eval_ccpc_functions * @param array $settings array Array contenant les données d'évaluation à enregistrer, correspond à la même structure que l'array retourné par eval_ccpc_setSettings * @return boolean TRUE si l'opération s'est déroulé avec succès * * @Author Ali Bellamine * */ function eval_ccpc_setSettings($settings) { initTable(); // S'assure de l'existence de la table dans la BDD global $db; if (isset($settings['id']) && count(checkEvaluation($settings['id'], array())) == 0) { // On vérifie les données à enregistrer if (isset($settings['dateDebut']) && isset($settings['dateFin']) && is_numeric($settings['dateFin']) && is_numeric($settings['dateDebut']) && $settings['dateDebut'] <= $settings['dateFin']) { // On prépare l'array $settings['dateDebut'] = TimestampToDatetime($settings['dateDebut']); $settings['dateFin'] = TimestampToDatetime($settings['dateFin']); // On vérifie si l'évaluation existe déjà dans la base settings $sql = 'SELECT count(*) FROM eval_ccpc_settings WHERE id_evaluation = ? LIMIT 1'; $res = $db->prepare($sql); $res->execute(array($settings['id'])); $res_f = $res->fetch(); if ($res_f[0] == 0) { $sql = 'INSERT INTO eval_ccpc_settings (id_evaluation, dateDebut, dateFin) VALUES (:id, :dateDebut, :dateFin)'; } else { $sql = 'UPDATE eval_ccpc_settings SET dateDebut = :dateDebut, dateFin = :dateFin WHERE id_evaluation = :id'; } $res2 = $db->prepare($sql); if ($res2->execute($settings)) { return TRUE; } else { return FALSE; } } else { return FALSE; } } else { return FALSE; } }
if ($db->query("CREATE TABLE " . $sql)) { echo "<b>{$tablename} table created.<br></b>"; return true; } else { echo "<b style='color:red;'>{$tablename} could not be created/updated.<br></b>"; echo "<b>Error log:</b><br>"; die(var_dump($db->errorInfo())); return false; } } $sqltenders = "`{$dbname}`.`tenders` (\n `id` int(11) NOT NULL AUTO_INCREMENT,\n `title` text,\n `brief` text,\n `emd` text NOT NULL,\n `category` text,\n `startdate` text,\n `starttime` text,\n `closedate` text,\n `closetime` text,\n `ownerid` int(11) NOT NULL,\n `open` BOOLEAN NOT NULL,\n `timestamp` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,\n PRIMARY KEY (`id`)\n);"; initTable($db, $dbname, $sqltenders, "tenders"); $sqlusers = "`{$dbname}`.`users` (\n `id` int(11) NOT NULL AUTO_INCREMENT,\n `name` text,\n `pass` text,\n `email` text NOT NULL,\n `phone` text NOT NULL,\n `type` text NOT NULL,\n `timestamp` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,\n PRIMARY KEY (`id`)\n);"; initTable($db, $dbname, $sqlusers, "users"); $sqltenderuser = "******"; initTable($db, $dbname, $sqltenderuser, "tender_user"); $db = null; } if (!file_exists('data')) { mkdir('data'); } if (!file_exists('data/tenders')) { mkdir('data/tenders'); } if (!file_exists('data/tender_applications')) { mkdir('data/tender_applications'); } ?> <br><a href="/">Click here to go to home page</a> </body> </html>
} else { require PLUGIN_PATH . 'lang/' . DEFAULT_LANG . '.php'; } // Insertion du fichier de fonctions require PLUGIN_PATH . 'core/fnDisplayEvaluationResult.php'; // Fonctions propres à l'affichage des résultats d'épreuves require PLUGIN_PATH . 'core/fnGraphGen.php'; // Affichage des graphiques include PLUGIN_PATH . 'core/fnAdmin.php'; // Administration du module // On nettoie le cache --> supprime tous les fichiers de + de 30 jours : afin d'éviter la surconsommation d'espace disque eval_ccpc_clearCache(); $erreur = array(); $urlPage = http_build_query($_GET); // URL avec les $_GET initTable(); // Met à jour la structure de la BDD si besoin /** Routage -- On détermine la variable $action **/ $action = 'listEvaluation'; // Page par défault if (isset($_GET['service'])) { if (count(checkService($_GET['service'], array())) == 0) { $action = 'evaluationDetails'; } } else { if (isset($_GET['ajax']) && is_file(PLUGIN_PATH . 'ajax/' . $_GET['ajax'] . '.php')) { $action = 'loadAjax'; } else { if (isset($_GET['page']) && is_file(PLUGIN_PATH . 'displayEvaluationResult/' . $_GET['page'] . '.php')) {