crabs_cms-1.0.4 ©2006-2008 - Christophe Cazajus (crabs-mettre_le_signe_at-crabs-world.com)
1 <?php 2 // 3 // ============================================================================= 4 // crabs_cms-1.0.4 : Crabs Contents Management System 5 // Copyright (C) 2006-2008 : Christophe Cazajus (crabs-mettre_le_signe_at-crabs-world.com) 6 // 7 // Ce source fait partie d'un projet logiciel libre. Vous pouvez le distribuer 8 // et/ou le modifier en respectant les termes de la GNU General Public License 9 // version 2 ou (suite a votre propre choix) une version ulterieure. 10 // 11 // Ce programme est distribue dans l'espoir qu'il puisse etre utile, mais 12 // sans aucune garantie, meme si il est associe a un produit qui vous en 13 // propose une. Conformez-vous a la GNU General Public License pour avoir 14 // plus de precisions. 15 // 16 // L'auteur ne peut etre tenu responsable de l'utilisation faite des 17 // composantes associees a ce projet (en partie ou dans leur totalite). 18 // 19 // Une copie du fichier de la GNU GPL est fournie dans le repertoire DOC 20 // de ce projet sous le nom gnu_gpl.txt 21 // 22 // ============================================================================= 23 // 24 class MYSQL 25 { 26 var $_c ; 27 var $_root ; 28 29 function MYSQL( $do_connect=false ) 30 { 31 $this->_c = false ; 32 if ( $do_connect ) $this->connect() ; 33 } 34 function connect() 35 { 36 global $DB_HOST, $DB_USER, $DB_PASSWD, $DB_BASE ; 37 $c = mysql_connect($DB_HOST,$DB_USER,$DB_PASSWD) 38 or $this->err("mysql_connect"); 39 mysql_select_db( $DB_BASE, $c ) or $this->err("mysql_select_db") ; 40 $this->_c = $c ; 41 } 42 function close() 43 { 44 if ( !$this->_c ) return ; 45 mysql_close($this->_c); 46 $this->_c=false; 47 } 48 function id() { return mysql_insert_id( $this->_c ) ; } 49 function query($sql) 50 { 51 if ( !$this->_c ) $this->connect() ; 52 $r = mysql_query( $sql, $this->_c ) or $this->err($sql) ; 53 return $r ; 54 } 55 function enumValue( $table, $field ) 56 { 57 $arryEnum = array() ; 58 $result=mysql_query("SHOW COLUMNS FROM $table LIKE '$field'"); 59 if( mysql_num_rows( $result ) > 0 ) 60 { 61 $row=mysql_fetch_row($result); 62 preg_match_all("/'(.*?)'/", $row['Type'], $matches); 63 $arryEnum = $matches[1] ; 64 } 65 return $arryEnum ; 66 } 67 function err( $call ) 68 { 69 global $ACCUEIL_URL ; 70 if ( $this->_c ) $err = mysql_error( $this->_c ) ; 71 else $err = mysql_error() ; 72 echo <<<HTML 73 <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" 74 "http://www.w3.org/TR/html4/strict.dtd"> 75 <html> 76 <head> 77 <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"> 78 <meta http-equiv="CONTENT-LANGUAGE" content="fr"> 79 <meta name="LANGUAGE" content="fr"> 80 <title>Erreur Mysql</title> 81 </head> 82 <body> 83 <h1>URI</h1> 84 <pre>$_SERVER[REQUEST_URI]</pre> 85 <h1>CONTEXTE</h1> 86 <pre>$call</pre> 87 <h1>RAISON</h1> 88 <p>$err</p> 89 <p><br><a href="$ACCUEIL_URL">Revenir au site</a></p> 90 </body> 91 </html> 92 93 HTML; 94 exit() ; 95 } 96 } 97 ?>
Date de génération : 24/10/2008 21:34