Changeset 18164 for trunk/include
- Timestamp:
- Sep 23, 2012, 11:34:30 AM (12 years ago)
- Location:
- trunk/include
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/include/functions.inc.php
r17748 r18164 1726 1726 } 1727 1727 } 1728 1729 /** 1730 * check email format 1731 */ 1732 function email_check_format($mail_address) 1733 { 1734 if (version_compare(PHP_VERSION, '5.2.0') >= 0) 1735 { 1736 return filter_var($mail_address, FILTER_VALIDATE_EMAIL)!==false; 1737 } 1738 else 1739 { 1740 $atom = '[-a-z0-9!#$%&\'*+\\/=?^_`{|}~]'; // before arobase 1741 $domain = '([a-z0-9]([-a-z0-9]*[a-z0-9]+)?)'; // domain name 1742 $regex = '/^' . $atom . '+' . '(\.' . $atom . '+)*' . '@' . '(' . $domain . '{1,63}\.)+' . $domain . '{2,63}$/i'; 1743 1744 return (bool)preg_match($regex, $mail_address); 1745 } 1746 } 1728 1747 ?> -
trunk/include/functions_comment.inc.php
r17351 r18164 92 92 if ( empty($comm['author']) ) 93 93 { 94 if ($conf['comments_author_mandatory']) 95 { 96 array_push($infos, l10n('Username is mandatory') ); 97 $comment_action='reject'; 98 } 94 99 $comm['author'] = 'guest'; 95 100 } … … 129 134 130 135 // website 131 if ( !empty($comm['website_url']) and !preg_match('/^https?/i', $comm['website_url']) ) 132 { 133 $comm['website_url'] = 'http://'.$comm['website_url']; 134 } 135 if ( !empty($comm['website_url']) and !url_check_format($comm['website_url']) ) 136 { 137 array_push($infos, l10n('Your website URL is invalid')); 136 if (!empty($comm['website_url'])) 137 { 138 if (!preg_match('/^https?/i', $comm['website_url'])) 139 { 140 $comm['website_url'] = 'http://'.$comm['website_url']; 141 } 142 if (!url_check_format($comm['website_url'])) 143 { 144 array_push($infos, l10n('Your website URL is invalid')); 145 $comment_action='reject'; 146 } 147 } 148 149 // email 150 if (empty($comm['email'])) 151 { 152 if (!empty($user['email'])) 153 { 154 $comm['email'] = $user['email']; 155 } 156 else if ($conf['comments_email_mandatory']) 157 { 158 array_push($infos, l10n('Email address is missing. Please specify an email address.') ); 159 $comment_action='reject'; 160 } 161 } 162 else if (!email_check_format($comm['email'])) 163 { 164 array_push($infos, l10n('mail address must be like xxx@yyy.eee (example : jack@altern.org)')); 138 165 $comment_action='reject'; 139 166 } … … 180 207 $query = ' 181 208 INSERT INTO '.COMMENTS_TABLE.' 182 (author, author_id, anonymous_id, content, date, validated, validation_date, image_id, website_url )209 (author, author_id, anonymous_id, content, date, validated, validation_date, image_id, website_url, email) 183 210 VALUES ( 184 211 \''.$comm['author'].'\', … … 190 217 '.($comment_action=='validate' ? 'NOW()':'NULL').', 191 218 '.$comm['image_id'].', 192 '.(!empty($comm['website_url']) ? '\''.$comm['website_url'].'\'' : 'NULL').' 219 '.(!empty($comm['website_url']) ? '\''.$comm['website_url'].'\'' : 'NULL').', 220 '.(!empty($comm['email']) ? '\''.$comm['email'].'\'' : 'NULL').' 193 221 ) 194 222 '; … … 208 236 ( 209 237 get_l10n_args('Author: %s', stripslashes($comm['author']) ), 238 get_l10n_args('Email: %s', stripslashes($comm['email']) ), 210 239 get_l10n_args('Comment: %s', stripslashes($comm['content']) ), 211 240 get_l10n_args('', ''), -
trunk/include/functions_user.inc.php
r13240 r18164 42 42 } 43 43 44 $atom = '[-a-z0-9!#$%&\'*+\\/=?^_`{|}~]'; // before arobase 45 $domain = '([a-z0-9]([-a-z0-9]*[a-z0-9]+)?)'; // domain name 46 $regex = '/^' . $atom . '+' . '(\.' . $atom . '+)*' . '@' . '(' . $domain . '{1,63}\.)+' . $domain . '{2,63}$/i'; 47 48 if ( !preg_match( $regex, $mail_address ) ) 44 if ( !email_check_format($mail_address) ) 49 45 { 50 46 return l10n('mail address must be like xxx@yyy.eee (example : jack@altern.org)'); … … 54 50 { 55 51 $query = ' 56 selectcount(*)57 from'.USERS_TABLE.'58 whereupper('.$conf['user_fields']['email'].') = upper(\''.$mail_address.'\')59 '.(is_numeric($user_id) ? ' and'.$conf['user_fields']['id'].' != \''.$user_id.'\'' : '').'52 SELECT count(*) 53 FROM '.USERS_TABLE.' 54 WHERE upper('.$conf['user_fields']['email'].') = upper(\''.$mail_address.'\') 55 '.(is_numeric($user_id) ? 'AND '.$conf['user_fields']['id'].' != \''.$user_id.'\'' : '').' 60 56 ;'; 61 57 list($count) = pwg_db_fetch_row(pwg_query($query)); -
trunk/include/picture_comment.inc.php
r17351 r18164 50 50 'content' => trim( $_POST['content'] ), 51 51 'website_url' => trim( $_POST['website_url'] ), 52 'email' => trim( @$_POST['email'] ), 52 53 'image_id' => $page['image_id'], 53 54 ); … … 55 56 include_once(PHPWG_ROOT_PATH.'include/functions_comment.inc.php'); 56 57 57 $comment_action = insert_user_comment($comm, @$_POST['key'], $page[' infos']);58 $comment_action = insert_user_comment($comm, @$_POST['key'], $page['errors']); 58 59 59 60 switch ($comment_action) … … 144 145 author, 145 146 author_id, 146 '.$conf['user_fields']['username'].' AS username,147 u.'.$conf['user_fields']['email'].' AS user_email, 147 148 date, 148 149 image_id, 149 150 website_url, 151 com.email, 150 152 content, 151 153 validated … … 162 164 while ($row = pwg_db_fetch_assoc($result)) 163 165 { 164 if (!empty($row['author'])) 165 { 166 $author = $row['author']; 167 if ($author == 'guest') 168 { 169 $author = l10n('guest'); 170 } 171 } 172 else 173 { 174 $author = stripslashes($row['username']); 166 if ($row['author'] == 'guest') 167 { 168 $row['author'] = l10n('guest'); 169 } 170 171 $email = null; 172 if (!empty($row['user_email'])) 173 { 174 $email = $row['user_email']; 175 } 176 else if (!empty($row['email'])) 177 { 178 $email = $row['email']; 175 179 } 176 180 … … 178 182 array( 179 183 'ID' => $row['id'], 180 'AUTHOR' => trigger_event('render_comment_author', $ author),184 'AUTHOR' => trigger_event('render_comment_author', $row['author']), 181 185 'DATE' => format_date($row['date'], true), 182 186 'CONTENT' => trigger_event('render_comment_content',$row['content']), … … 216 220 if (is_admin()) 217 221 { 222 $tpl_comment['EMAIL'] = $email; 223 218 224 if ($row['validated'] != 'true') 219 225 { … … 245 251 { 246 252 $key = get_ephemeral_key(3, $page['image_id']); 247 $content = $author = $website_url = ''; 248 if ('reject'===@$comment_action) 249 { 250 $content = htmlspecialchars( stripslashes($comm['content']) ); 251 $author = htmlspecialchars( stripslashes($comm['author']) ); 252 $website_url = htmlspecialchars( stripslashes($comm['website_url']) ); 253 } 253 254 254 $template->assign('comment_add', 255 255 array( 256 'F_ACTION' => $url_self, 257 'KEY' => $key, 258 'CONTENT' => $content, 259 'SHOW_AUTHOR' => !is_classic_user(), 260 'AUTHOR' => $author , 261 'WEBSITE_URL' => $website_url, 256 'F_ACTION' => $url_self, 257 'KEY' => $key, 258 'CONTENT' => stripslashes(@$_POST['content']), 259 'SHOW_AUTHOR' => !is_classic_user(), 260 'AUTHOR_MANDATORY' => $conf['comments_author_mandatory'], 261 'AUTHOR' => stripslashes(@$_POST['author']), 262 'WEBSITE_URL' => stripslashes(@$_POST['website_url']), 263 'SHOW_EMAIL' => !is_classic_user() or empty($user['email']), 264 'EMAIL_MANDATORY' => $conf['comments_email_mandatory'], 265 'EMAIL' => stripslashes(@$_POST['email']), 262 266 )); 263 267 }
Note: See TracChangeset
for help on using the changeset viewer.