Changeset 9 for trunk/include
- Timestamp:
- May 13, 2003, 12:02:06 PM (21 years ago)
- Location:
- trunk/include
- Files:
-
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/include/functions.inc.php
r6 r9 21 21 //----------------------------------------------------------- generic functions 22 22 23 // get_enums returns an array containing the possible values of a enum field 24 // in a table of the database. 25 function get_enums( $table, $field ) 26 { 27 // retrieving the properties of the table. Each line represents a field : 28 // columns are 'Field', 'Type' 29 $result=mysql_query("desc $table"); 30 while ( $row = mysql_fetch_array( $result ) ) 31 { 32 // we are only interested in the the field given in parameter for the 33 // function 34 if ( $row['Field']==$field ) 35 { 36 // retrieving possible values of the enum field 37 // enum('blue','green','black') 38 $option = explode( ',', substr($row['Type'], 5, -1 ) ); 39 for ( $i = 0; $i < sizeof( $option ); $i++ ) 40 { 41 // deletion of quotation marks 42 $option[$i] = str_replace( "'", '',$option[$i] ); 43 } 44 } 45 } 46 mysql_free_result( $result ); 47 return $option; 48 } 49 23 50 // get_boolean transforms a string to a boolean value. If the string is 24 51 // "false" (case insensitive), then the boolean value false is returned. In … … 55 82 function get_moment() 56 83 { 57 $t1 = explode( " ", microtime() );58 $t2 = explode( ".", $t1[0] );59 $t2 = $t1[1]. ".".$t2[1];84 $t1 = explode( ' ', microtime() ); 85 $t2 = explode( '.', $t1[0] ); 86 $t2 = $t1[1].'.'.$t2[1]; 60 87 return $t2; 61 88 } … … 274 301 } 275 302 276 function templatize_array( $array, $global_array_name )277 { 278 global $vtp, $ handle, $lang, $page, $user, $conf;303 function templatize_array( $array, $global_array_name, $handle ) 304 { 305 global $vtp, $lang, $page, $user, $conf; 279 306 280 307 for( $i = 0; $i < sizeof( $array ); $i++ ) -
trunk/include/functions_category.inc.php
r2 r9 1 1 <?php 2 2 /*************************************************************************** 3 * functions_category.inc.php 3 * functions_category.inc.php * 4 4 * -------------------- * 5 5 * application : PhpWebGallery 1.3 * … … 132 132 $url.= "&search=".$_GET['search']; 133 133 } 134 $lien_cat = add_session_id _to_url( $url );134 $lien_cat = add_session_id( $url ); 135 135 if ( $row['name'] == "" ) 136 136 { -
trunk/include/functions_session.inc.php
r2 r9 49 49 } 50 50 51 function session_create( $ pseudo)51 function session_create( $username ) 52 52 { 53 53 global $conf,$prefixeTable,$REMOTE_ADDR; 54 // 1. trouver une clé de session inexistante54 // 1. searching an unused sesison key 55 55 $id_found = false; 56 56 while ( !$id_found ) … … 66 66 } 67 67 } 68 // 2. récupération de l'id de l'utilisateur dont le pseudo 69 // est passé en paramètre 68 // 2. retrieving id of the username given in parameter 70 69 $query = 'select id'; 71 70 $query.= ' from '.$prefixeTable.'users'; 72 $query.= " where pseudo = '".$pseudo."';";71 $query.= " where username = '".$username."';"; 73 72 $row = mysql_fetch_array( mysql_query( $query ) ); 74 73 $user_id = $row['id']; 75 // 3. inserti on de la session dans la base de donnée74 // 3. inserting session in database 76 75 $expiration = $conf['session_time']*60+time(); 77 76 $query = 'insert into '.$prefixeTable.'sessions'; … … 83 82 return $generated_id; 84 83 } 85 86 function add_session_id_to_url( $url, $redirect = false ) 84 85 // add_session_id adds the id of the session to the string given in 86 // parameter as $url. If the session id is the first parameter to the url, 87 // it is preceded by a '?', else it is preceded by a '&'. If the 88 // parameter $redirect is set to true, '&' is used instead of '&'. 89 function add_session_id( $url, $redirect = false ) 87 90 { 88 91 global $page, $user; 89 $amp = "&";92 $amp = '&'; 90 93 if ( $redirect ) 91 94 { 92 $amp = "&";95 $amp = '&'; 93 96 } 94 97 if ( !$user['is_the_guest'] ) 95 98 { 96 if ( ereg( "\.php\?",$url ) )99 if ( preg_match( '/\.php\?/',$url ) ) 97 100 { 98 return $url.$amp. "id=".$page['session_id'];101 return $url.$amp.'id='.$page['session_id']; 99 102 } 100 103 else 101 104 { 102 return $url."?id=".$page['session_id']; 103 } 104 } 105 else 106 { 107 return $url; 108 } 109 } 110 111 function add_session_id( $url, $redirect = false ) 112 { 113 global $page, $user; 114 $amp = "&"; 115 if ( $redirect ) 116 { 117 $amp = "&"; 118 } 119 if ( !$user['is_the_guest'] ) 120 { 121 if ( ereg( "\.php\?",$url ) ) 122 { 123 return $url.$amp."id=".$page['session_id']; 124 } 125 else 126 { 127 return $url."?id=".$page['session_id']; 105 return $url.'?id='.$page['session_id']; 128 106 } 129 107 } -
trunk/include/functions_user.inc.php
r2 r9 15 15 * * 16 16 ***************************************************************************/ 17 18 // validate_mail_address verifies whether the given mail address has the 19 // right format. ie someone@domain.com "someone" can contain ".", "-" or 20 // even "_". Exactly as "domain". The extension doesn't have to be 21 // "com". The mail address can also be empty. 22 // If the mail address doesn't correspond, an error message is returned. 17 23 function validate_mail_address( $mail_address ) 18 24 { 19 25 global $lang; 20 26 21 $output = ''; 22 // le mail doit être conforme à qqch du type : nom@serveur.com 23 if ( $mail_address != '' 24 and !ereg( "([_a-z0-9-]+(\.[_a-z0-9-]+)*@[a-z0-9-]+(\.[a-z0-9-]+)+)", 25 $mail_address ) ) 26 { 27 $output = $lang['reg_err_mail_address']; 28 } 29 30 return $output; 31 } 32 33 function register_user( $login, $password, $password_conf, 34 $mail_address, $status = 'visiteur' ) 35 { 36 global $prefixeTable; 27 if ( $mail_address == '' ) 28 { 29 return ''; 30 } 31 $regex = '/^[\w-]+(\.[\w-]+)*@[\w-]+(\.[\w-]+)*\.[a-z]+$/'; 32 if ( !preg_match( $regex, $mail_address ) ) 33 { 34 return $lang['reg_err_mail_address']; 35 } 36 } 37 38 function register_user( 39 $login, $password, $password_conf, $mail_address, $status = 'guest' ) 40 { 41 global $prefixeTable, $lang; 37 42 38 43 $error = array(); 39 44 $i = 0; 40 // l e login ne doit pas41 // 1. être vide42 // 2. commencer ou se terminer par un espace43 // 3. comporter les caractères ' ou "44 // 4. être déjà utilisé45 // login must not 46 // 1. be empty 47 // 2. start ou end with space character 48 // 3. include ' or " characters 49 // 4. be already used 45 50 if ( $login == '' ) 46 51 { … … 63 68 $query = 'select id'; 64 69 $query.= ' from '.$prefixeTable.'users'; 65 $query.= " where pseudo= '".$login."';";70 $query.= " where username = '".$login."';"; 66 71 $result = mysql_query( $query ); 67 72 if ( mysql_num_rows( $result ) > 0 ) … … 70 75 } 71 76 } 72 // on vérifie que le password rentré correspond bien 73 // à la confirmation faite par l'utilisateur 77 // given password must be the same as the confirmation 74 78 if ( $password != $password_conf ) 75 79 { … … 82 86 $error[$i++] = $error_mail_address; 83 87 } 84 85 // on enregistre le nouvel utilisateur si aucune 86 //erreur détectée dans les paramètres 88 89 // if no error until here, registration of the user 87 90 if ( sizeof( $error ) == 0 ) 88 91 { 89 // 1. récupération des valeurs par défaut de l'application92 // 1. retrieving default values, the ones of the user "guest" 90 93 $infos = array( 'nb_image_line', 'nb_line_page', 'theme', 'language', 91 94 'maxwidth', 'maxheight', 'expand', 'show_nb_comments', … … 105 108 } 106 109 $query.= ' from '.$prefixeTable.'users'; 107 $query.= " where pseudo = 'visiteur';";110 $query.= " where username = 'guest';"; 108 111 $row = mysql_fetch_array( mysql_query( $query ) ); 109 // 2. ajout du nouvel utilisateur112 // 2. adding new user 110 113 $query = 'insert into '.$prefixeTable.'users'; 111 114 $query.= ' ('; 112 $query.= ' pseudo,password,mail_address,status';115 $query.= ' username,password,mail_address,status'; 113 116 for ( $i = 0; $i < sizeof( $infos ); $i++ ) 114 117 { 115 118 $query.= ','.$infos[$i]; 116 119 } 117 $query.= ' values (';120 $query.= ') values ('; 118 121 $query.= " '".$login."'"; 119 122 $query.= ",'".md5( $password )."'"; … … 129 132 for ( $i = 0; $i < sizeof( $infos ); $i++ ) 130 133 { 131 $query.= ','.$row[$infos[$i]]; 134 $query.= ','; 135 if ( $row[$infos[$i]] == '' ) 136 { 137 $query.= 'NULL'; 138 } 139 else 140 { 141 $query.= "'".$row[$infos[$i]]."'"; 142 } 132 143 } 133 144 $query.= ');'; 134 145 mysql_query( $query ); 135 // 3. r écupérer l'identifiant de l'utilisateur nouvellement créé146 // 3. retrieving the id of the newly created user 136 147 $query = 'select id'; 137 148 $query.= ' from '.$prefixeTable.'users'; 138 $query.= " where pseudo= '".$login."';";149 $query.= " where username = '".$login."';"; 139 150 $row = mysql_fetch_array( mysql_query( $query ) ); 140 151 $user_id = $row['id']; 141 // 4.ajouter les restrictions au nouvel utilisateur, 142 // les mêmes que celles de l'utilisateur par défaut 152 // 4. adding restrictions to the new user, the same as the user "guest" 143 153 $query = 'select cat_id'; 144 154 $query.= ' from '.$prefixeTable.'restrictions as r'; 145 155 $query.= ','.$prefixeTable.'users as u '; 146 156 $query.= ' where u.id = r.user_id'; 147 $query.= " and u. pseudo = 'visiteur';";157 $query.= " and u.username = 'guest';"; 148 158 $result = mysql_query( $query ); 149 159 while( $row = mysql_fetch_array( $result ) ) … … 191 201 $query.= ' where id = '.$user_id; 192 202 $query.= ';'; 203 echo $query; 193 204 mysql_query( $query ); 194 205 } -
trunk/include/init.inc.php
r2 r9 30 30 $isadmin = false; 31 31 include_once( './language/'.$user['language'].'.php' ); 32 // displaying the username in the language of the connected user, instead of 33 // "guest" as you can find in the database 32 34 if ( $user['is_the_guest'] ) 33 35 { 34 $user[' pseudo'] = $lang['guest'];36 $user['username'] = $lang['guest']; 35 37 } 36 38 include_once( './template/'.$user['template'].'/style.inc.php' ); -
trunk/include/user.inc.php
r2 r9 1 1 <?php 2 2 /*************************************************************************** 3 * user.inc.php is a part of PhpWebGallery*4 * ------------------ -*5 * last update : Saturday, October 26, 2002*6 * email : pierrick@z0rglub.com*3 * user.inc.php * 4 * ------------------ * 5 * application : PhpWebGallery 1.3 * 6 * author : Pierrick LE GALL <pierrick@z0rglub.com> * 7 7 * * 8 8 *************************************************************************** … … 20 20 // Example : 21 21 // status --> $user['status'] 22 $infos = array( 'id', ' pseudo', 'mail_address', 'nb_image_line',22 $infos = array( 'id', 'username', 'mail_address', 'nb_image_line', 23 23 'nb_line_page', 'status', 'theme', 'language', 'maxwidth', 24 24 'maxheight', 'expand', 'show_nb_comments', 'short_period', … … 72 72 if ( !$query_done ) 73 73 { 74 $query_user .= " where pseudo = 'visiteur'";74 $query_user .= ' where id = 2'; 75 75 $user['is_the_guest'] = true; 76 76 }
Note: See TracChangeset
for help on using the changeset viewer.