function login() { $retour = false; $login = Db::escape($_POST['login']); $getAuth = Db::query("SELECT * FROM `" . TABLE_PREFIX . "admin` WHERE `login_txt` = '" . $login . "'\r\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tAND `mdp_txt` = '" . Db::escape(md5($_POST['mdp'])) . "'"); if (Db::num_rows($getAuth) > 0) { $_SESSION['key'] = true; // Mise en session de la connexion $entry = Db::fetch_assoc($getAuth); $retour = true; } else { $getLogin = Db::query("SELECT * FROM `" . TABLE_PREFIX . "admin` WHERE `login_txt` = '" . $login . "'"); if (Db::num_rows($getLogin) > 0) { $this->login = $login; $getPwd = Db::query("SELECT * FROM `" . TABLE_PREFIX . "admin` WHERE `login_txt` = '" . $login . "'\r\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tAND `mdp_txt` = '" . Db::escape(md5($_POST['mdp'])) . "'"); if (Db::num_rows($getPwd) <= 0) { $this->errors = "pwd"; } } else { $this->errors = "login"; } $retour = false; } return $retour; }
function delete($id, $categ) { $title = ""; $getEntries = Query::selectById($id); if (Db::num_rows($getEntries)) { $entry = Db::fetch_assoc($getEntries); foreach ($entry as $column => $value) { if (CATEGORIE_NOM == "news") { if ($column == "titre_txt") { $title = $value; } } elseif (CATEGORIE_NOM == "membre") { if ($column == "nom_txt" || $column == "nom_txt") { $title .= $value; } } elseif (CATEGORIE_NOM == "newsletters") { if ($column == "email_txt") { $title = $value; } } elseif (CATEGORIE_NOM == "users") { $title = $value; } } $entry = Db::fetch_assoc($getEntries); } Db::add_transaction_execute(DELETE, $categ, $title); return Db::executeQuery("UPDATE `" . TABLE_PREFIX . CATEGORIE_NOM . "` SET `delete_logical` = '1' WHERE `id` = '" . Db::escape($id) . "'"); }
function changepwd() { $retour = true; $oldpwd = Db::escape($_POST['old']); $newpwd = Db::escape($_POST['new']); $verifpwd = Db::escape($_POST['verif']); $login = Db::escape($_POST['login']); $getLogin = Query::connexionLogin($login); if (Db::num_rows($getLogin) > 0) { $this->login = $login; $getPwd = Query::connexion($login, $oldpwd); if (Db::num_rows($getPwd) > 0) { if ($newpwd != $verifpwd) { $this->errors = "changeVerif"; $retour = false; } else { Query::updatePassword($newpwd, $login); } } else { $this->errors = "pwd"; $retour = false; } } else { $this->errors = "login"; $retour = false; } return $retour; }
function changepwd() { $retour = true; $oldpwd = Db::escape($_POST['old']); $newpwd = Db::escape($_POST['new']); $verifpwd = Db::escape($_POST['verif']); $login = Db::escape($_POST['login']); $getLogin = Db::query("SELECT * FROM `" . TABLE_PREFIX . "admin` WHERE `login_txt` = '" . $login . "'"); if (Db::num_rows($getLogin) > 0) { $this->login = $login; $getPwd = Db::query("SELECT * FROM `" . TABLE_PREFIX . "admin` WHERE `login_txt` = '" . $login . "'\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tAND `mdp_txt` = '" . md5($oldpwd) . "'"); if (Db::num_rows($getPwd) > 0) { if ($newpwd != $verifpwd) { $this->errors = "changeVerif"; $retour = false; } else { Db::query("UPDATE " . TABLE_PREFIX . "admin SET mdp_txt = '" . md5($newpwd) . "' WHERE login_txt = '" . $login . "'"); } } else { $this->errors = "pwd"; $retour = false; } } else { $this->errors = "login"; $retour = false; } return $retour; }
function sendNewsletter($titre, $contenu, $view) { $passage_ligne = "\r\n"; //=====Déclaration des messages au format HTML $patterns = array(); $replacements = array(); $patterns[0] = '/<h1/'; $replacements[0] = '<h1 style="width:770px;line-height:25px;font-size:18px;padding-left:5px;background-color:#f49f25;"'; $string = preg_replace($patterns, $replacements, stripslashes($contenu)); $string = str_replace('../albums', 'http://www.pcf-cdh.be/albums', $string); $string = str_replace("<a href=", "<a style=\"color:#f49f25;\" href=", $string); $message_html = "\n\t\t\t<div style=\"width:800px;min-height:600px;font-size:11px;font-family:Verdana;\">\n\t\t\t\t<div>\n\t\t\t\t\t<img src=\"http://www.pcf-cdh.be/images/header.jpg\" height=\"175px;\" />\n\t\t\t\t</div>\n\t\t\t\t<div style=\"margin-left:14px;width:770px;min-height:300px;\">\n\t\t\t\t" . $string . "\n\t\t\t\t</div>\n\t\t\t\t<div>\n\t\t\t\t\t<a style=\"text-decoration:none;\" href=\"http://www.pcf-cdh.be/deputy.php\"><img src=\"http://www.pcf-cdh.be/images/footer.jpg\" style=\"height:66px;border:none;\" /></a>\n\t\t\t\t\t<a style=\"text-decoration:none;\" href=\"http://www.pcf-cdh.be\"><img src=\"http://www.pcf-cdh.be/images/footer2.jpg\" style=\"height:50px;border:none;\" /></a>\n\t\t\t\t</div>\n\t\t\t\t<div style=\"width:800px;text-align:center;\">\n\t\t\t\t\t<a style=\"text-decoration:none;font-size:8px;\" href=\"http://www.pcf-cdh.be/desincription.php\">Se désabonner de la newsletters</a>\n\t\t\t\t</div>\n\t\t\t</div>"; //=====Création de la boundary $boundary = "-----=" . md5(rand()); $boundary_alt = "-----=" . md5(rand()); //=====Définition du sujet $sujet = "Newsletter du groupe cdH : " . $titre; //========= //=====Création du header de l'e-mail $header = "From: " . MAIL . "" . $passage_ligne; $header .= "Reply-to: " . MAIL . "" . $passage_ligne; $header .= "MIME-Version: 1.0" . $passage_ligne; $header .= "Content-Type: multipart/mixed;" . $passage_ligne . " boundary=\"{$boundary}\"" . $passage_ligne; //========== //=====Création du message $message = $passage_ligne . "--" . $boundary . $passage_ligne; $message .= "Content-Type: multipart/alternative;" . $passage_ligne . " boundary=\"{$boundary_alt}\"" . $passage_ligne; $message .= $passage_ligne . "--" . $boundary_alt . $passage_ligne; //=====Ajout du message au format HTML $message .= "Content-Type: text/html; charset=\"ISO-8859-1\"" . $passage_ligne; $message .= "Content-Transfer-Encoding: 8bit" . $passage_ligne; $message .= $passage_ligne . $message_html . $passage_ligne; //=====On ferme la boundary alternative $message .= $passage_ligne . "--" . $boundary_alt . "--" . $passage_ligne; $message .= $passage_ligne . "--" . $boundary . $passage_ligne; //=====Envoi de l'e-mail if ($view == true) { $sqlQuery = "SELECT email_txt FROM cdh_newsletter"; $getEntries = Db::query($sqlQuery); if (Db::num_rows($getEntries) > 0) { $entry = Db::fetch_assoc($getEntries); while ($entry) { foreach ($entry as $column => $value) { $value = stripslashes(htmlentities($value, ENT_QUOTES, "iso-8859-1")); mail($value, $sujet, $message, $header); } $entry = Db::fetch_assoc($getEntries); } } header("Location: http://www.pcf-cdh.be/admin/index.php?module=newsletter&categorie=5&sscategorie=14&send=true"); } else { mail('', $sujet, $message, $header); mail('', $sujet, $message, $header); mail('', $sujet, $message, $header); header("Location: http://www.pcf-cdh.be/admin/index.php?module=newsletter&categorie=5&sscategorie=14&send=true"); } }
function sendNewsletter($titre, $contenu, $view) { $passage_ligne = "\r\n"; //=====Declaration des messages au format HTML $patterns = array(); $patterns[0] = '/<img src="../albums/'; $replacements = array(); $replacements[0] = '<img src="http://www.microniser.com/albums/'; $string = preg_replace($patterns, $replacements, stripslashes($contenu)); $string = str_replace("<a href=", "<a style=\"color:#f49f25;\" href=", $string); $message_html = "\r\n\t\t\t<div style=\"width:800px;min-height:600px;font-size:10px;font-family:Verdana;\">\r\n\t\t\t\t<div>\r\n\t\t\t\t\tIMAGE ENTETE\r\n\t\t\t\t</div>\r\n\t\t\t\t<div style=\"margin-left:14px;width:770px;min-height:300px;\">\r\n\t\t\t\t" . $string . "\r\n\t\t\t\t</div>\r\n\t\t\t\t<div>\r\n\t\t\t\t\tIMAGE PIED DE PAGE\r\n\t\t\t\t</div>\r\n\t\t\t\t<div style=\"width:800px;text-align:center;\">\r\n\t\t\t\t\t<a style=\"text-decoration:none;font-size:8px;\" href=\"http://www.microniser.com/desincription.php\">Se désabonner de la newsletters</a>\r\n\t\t\t\t</div>\r\n\t\t\t</div>"; //=====Creation de la boundary $boundary = "-----=" . md5(rand()); $boundary_alt = "-----=" . md5(rand()); //=====Definition du sujet $sujet = "Newsletter Microniser : " . $titre; //========= //=====Creation du header de l'e-mail $header = "From: " . MAIL . "" . $passage_ligne; $header .= "Reply-to: " . MAIL . "" . $passage_ligne; $header .= "MIME-Version: 1.0" . $passage_ligne; $header .= "Content-Type: multipart/mixed;" . $passage_ligne . " boundary=\"{$boundary}\"" . $passage_ligne; //========== //=====Creation du message $message = $passage_ligne . "--" . $boundary . $passage_ligne; $message .= "Content-Type: multipart/alternative;" . $passage_ligne . " boundary=\"{$boundary_alt}\"" . $passage_ligne; $message .= $passage_ligne . "--" . $boundary_alt . $passage_ligne; //=====Ajout du message au format HTML $message .= "Content-Type: text/html; charset=\"ISO-8859-1\"" . $passage_ligne; $message .= "Content-Transfer-Encoding: 8bit" . $passage_ligne; $message .= $passage_ligne . $message_html . $passage_ligne; //=====On ferme la boundary alternative $message .= $passage_ligne . "--" . $boundary_alt . "--" . $passage_ligne; $message .= $passage_ligne . "--" . $boundary . $passage_ligne; //=====Envoi de l'e-mail if ($view == true) { $sqlQuery = "SELECT email_txt FROM micro_newsletters"; $getEntries = Db::query($sqlQuery); if (Db::num_rows($getEntries) > 0) { $entry = Db::fetch_assoc($getEntries); while ($entry) { foreach ($entry as $column => $value) { $value = stripslashes(htmlentities($value, ENT_QUOTES, "iso-8859-1")); //mail($value, $sujet, $message, $header); } $entry = Db::fetch_assoc($getEntries); } } header("Location: http://www.microniser.com/admin/index.php?module=newsletters&categorie=7&sscategorie=41&send=true"); } else { mail('', $sujet, $message, $header); header("Location: http://www.microniser.com/admin/index.php?module=newsletters&categorie=7&sscategorie=41"); } }
function sendNewsletter($groupe, $sujet, $contenu) { //=====Declaration des messages au format HTML $message_html = "\n\t\t\t<div style=\"width:800px;min-height:600px;font-size:10px;font-family:Verdana;\">\n\t\t\t\t<div>\n\t\t\t\t\tIMAGE ENTETE\n\t\t\t\t</div>\n\t\t\t\t<div style=\"margin-left:14px;width:770px;min-height:300px;\">\n\t\t\t\t" . $contenu . "\n\t\t\t\t</div>\n\t\t\t\t<div>\n\t\t\t\t\tIMAGE PIED DE PAGE\n\t\t\t\t</div>\n\t\t\t\t<div style=\"width:800px;text-align:center;\">\n\t\t\t\t\t<a style=\"text-decoration:none;font-size:8px;\" href=\"http://www.microniser.com/desincription.php\">Se désabonner de la newsletters</a>\n\t\t\t\t</div>\n\t\t\t</div>"; //=====Envoi de l'e-mail $getEntries = Query::selectEmailNewslettersWithGroup($groupe); if (Db::num_rows($getEntries) > 0) { $entry = Db::fetch_assoc($getEntries); while ($entry) { foreach ($entry as $column => $email) { //Mail::ConstructBoundary($email, $sujet, $message_html) echo $email; } $entry = Db::fetch_assoc($getEntries); } } header("Location: " . SITE_URL . "/admin/webpassions.php?module=historiquenewsletters&categorie=130&sscategorie=130&send=send" . $groupe); }
function getEnumValue($column, $val) { $sqlQuery = "SELECT " . $column . " FROM " . TABLE_PREFIX . CATEGORIE_NOM . "_" . $column; $getEntries = Db::query($sqlQuery); $tmp = '<select name="' . $column . '" class="jNiceSelectWrapper"><option></option>'; if (Db::num_rows($getEntries) > 0) { $entry = Db::fetch_assoc($getEntries); while ($entry) { foreach ($entry as $column => $option) { $selected = $val == $option ? 'selected="selected"' : ''; // are we selected? $tmp .= '<option value="' . $option . '" ' . $selected . '>' . $option . '</option>'; } $entry = Db::fetch_assoc($getEntries); } } $tmp .= '</select>'; return $tmp; }
function login() { $retour = false; $login = Db::escape($_POST['login']); $mdp = Db::escape($_POST['mdp']); $getAuth = Query::connexion($login, $mdp); if (Db::num_rows($getAuth) > 0) { // Mise en session de la connexion $_SESSION['key'] = true; $entry = Db::fetch_assoc($getAuth); $retour = true; } else { $getLogin = Query::connexionLogin($login); if (Db::num_rows($getLogin) > 0) { $this->login = $login; $this->errors = "pwd"; } else { $this->errors = "login"; } $retour = false; } return $retour; }
function login() { $retour = false; $login = Utils::anti_injection($_POST['login']); $getAuth = Db::query("SELECT * FROM `" . TABLE_PREFIX . "admin` WHERE `login_txt` = '" . $login . "'"); if (Db::num_rows($getAuth) > 0) { $mdp = Utils::anti_injection($_POST['mdp']); $getMdp = Db::query("SELECT * FROM `" . TABLE_PREFIX . "admin` WHERE `login_txt` = '" . $login . "'\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tAND `mdp_txt` = '" . md5($mdp) . "'"); if (Db::num_rows($getMdp) > 0) { $_SESSION['key'] = true; // Mise en session de la connexion $retour = true; } else { $this->login = $login; $this->errors = "pwd"; $retour = false; } $entry = Db::fetch_assoc($getMdp); } else { $this->errors = "login"; $retour = false; } return $retour; }
} $test = true; $test_name = "CONSULTAR DATOS EN UNA TABLA DE PRUEBA"; $start_benchmark = microtime(true); try { $value1 = $db->query("SELECT * FROM kumbia_test ORDER BY id"); if (!$value1) { throw new DbException("No se puede consultar en la tabla de prueba (1)"); } while ($row = $db->fetch_array()) { if ($row['id'] != 0 && $row['id'] != 1 && $row['id'] != 2 && $row['id'] != 4 && $row['id'] != 5) { throw new DbException("No se puede consultar en la tabla de prueba {$row['id']} (2)"); } } if (!isset($config->database->pdo)) { if ($db->num_rows() != 2) { throw new DbException("No se puede consultar en la tabla de prueba (3)"); } } $value2 = $db->fetch_one("SELECT * FROM kumbia_test {$db->limit(1)}"); if (!is_array($value2)) { throw new DbException("No se puede consultar en la tabla de prueba (4)"); } $value3 = $db->fetch_all("SELECT * FROM kumbia_test"); if (count($value3) != 2) { throw new DbException("No se puede consultar en la tabla de prueba (5)"); } $value4 = $db->in_query_assoc("SELECT * FROM kumbia_test {$db->limit(1)}"); if (count($value4[0]) != 3) { throw new DbException("No se puede consultar en la tabla de prueba (6)"); }
/** * Database Result Function. * This will query the database and output the result as object. * * @param string $vars * * * @author Puguh Wijayanto (www.metalgenix.com) * @since 0.0.1 */ public static function result($vars) { //print_r($vars); if (DB_DRIVER == 'mysql') { mysql_query('SET CHARACTER SET utf8'); $q = mysql_query($vars) or die(mysql_error()); $n = mysql_num_rows($q); if ($n > 0) { for ($i = 0; $i < $n; $i++) { $r[] = mysql_fetch_object($q); } } else { $r['error'] = 'data not found'; } } elseif (DB_DRIVER == 'mysqli') { //echo $vars; $q = self::query($vars); $n = $q->num_rows; if ($n > 0) { for ($i = 0; $i < $n; $i++) { $r[] = $q->fetch_object(); } } else { $r['error'] = 'data not found'; } $q->close(); } self::$num_rows = $n; return $r; }
public static function table_list_grid($request, $table, $field, $condition, $order = '', $bilrow = 10, $dbg = 'N') { $error = ''; $x = 0; $cari = chk($request['cari']); $all = chk($request['fw_all']); $sql = "SELECT {$field} FROM {$table} WHERE {$condition}"; list($data, $sts) = Db::query($sql); if ($sts != '1') { echo $sts; } else { if ($order == '') { $order = Db::field_name($data, 0); } if ($cari != '') { $cari = str_replace("'", "''", $cari); $bil_field = Db::num_fields($data); $carian = ''; $array_field = explode(",", $field); //echo '<pre>'; print_r($array_field); echo '</pre>'; $bil_field = count($array_field); for ($a = 0; $a < $bil_field; $a++) { $nama_field = Db::field_name($data, $a); // $nama_field_all = $array_field[$a]; // // $pos = strpos($nama_field_all, '*'); // // if ($pos === false) { // $nama_field = $nama_field_all; // switch (Db::$db) // { // case 'Pg': // $carian = "$carian CAST($nama_field AS TEXT) ILIKE '%$cari%' OR"; // break; // case 'Mysql': // $carian = "$carian $nama_field LIKE '%$cari%' OR"; // break; // case 'Oci': // $carian = "$carian lower($nama_field) LIKE lower('%$cari%') OR"; // break; // } // } $type_field = Db::field_type($data, $a); $array_type = array("timestamp", "float8", "int4"); foreach ($array_field as $fieldselect) { if (strpos($fieldselect, $nama_field) !== false) { $nama_field = $fieldselect; } $position = strpos($nama_field, ' as '); if ($position != '') { $nama_field = substr($nama_field, '0', $position); } $position = strpos($nama_field, ' AS '); if ($position != '') { $nama_field = substr($nama_field, '0', $position); } $nama_field = str_replace('DISTINCT ', '', $nama_field); } if (!in_array($type_field, $array_type)) { switch (Db::$db) { case 'Pg': $carian = "{$carian} CAST({$nama_field} AS TEXT) ILIKE '%{$cari}%' OR"; break; case 'Mysql': $carian = "{$carian} {$nama_field} LIKE '%{$cari}%' OR"; break; case 'Oci': $carian = "{$carian} lower({$nama_field}) LIKE lower('%{$cari}%') OR"; break; } } } $carian = "(" . substr($carian, 1, -3) . ")"; $condition = "{$condition} AND {$carian}"; } $totalreturned = Db::num_rows($table, $field, $condition); $request = datagrid($request, $totalreturned, $bilrow); $request['fw_all'] = $all; $page_end = $request['page_end']; $bilrow = $request['bilrow']; $limit = $request['limit']; if ($totalreturned == $page_end) { $page_end = $page_end - $bilrow; } if ($page_end < '0') { $page_end = '0'; } if (Db::$db == 'Oci') { $maxrow = $page_end + $bilrow; $sql = "SELECT * FROM (\n SELECT a.*, ROWNUM fw_bil FROM (\n SELECT {$field}\n FROM {$table}\n WHERE {$condition}\n ORDER BY {$order}\n ) a WHERE rownum <= {$maxrow}\n ) where fw_bil > {$page_end}"; // ORDER BY $order"; } else { $condition = "{$condition} ORDER BY {$order} LIMIT {$bilrow} OFFSET {$page_end} "; $sql = "SELECT {$field} FROM {$table} WHERE {$condition}"; } list($data, $sts) = Db::query($sql); if ($sts != '1') { echo $sts; } else { $datarow = Db::fetch_assoc($data); if (is_array($datarow)) { foreach ($datarow as $row => $value) { $datarow[$row]['fw_bil'] = $row + $page_end; } } } } if ($dbg == 'Y') { echo "<br>DEBUG : " . $sql . "<br>"; } elseif ($dbg == 'D') { echo "<br>DEBUG : " . $sql . "<br>"; echo "<pre>"; print_r($datarow); echo "</pre>"; } return array('totalreturned' => $totalreturned, 'page_end' => $page_end, 'request' => $request, 'fw_senarai' => chk($datarow)); }