- Timestamp:
- Mar 7, 2013, 10:06:42 PM (11 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
extensions/Subscribe_to_comments/include/functions.inc.php
r17921 r21340 157 157 158 158 // check email 159 if ( !empty($email) and ! is_valid_email($email) )159 if ( !empty($email) and !email_check_format($email) ) 160 160 { 161 161 array_push($page['errors'], l10n('mail address must be like xxx@yyy.eee (example : jack@altern.org)')); … … 172 172 } 173 173 174 // search if already registered (can use ODKU because we want to get the id of inserted OR updated row)174 // search if already registered (can't use ODKU because we want to get the id of inserted OR updated row) 175 175 $query = ' 176 176 SELECT id … … 213 213 214 214 // notify admins 215 if ( pwg_db_changes( null) != 0 and $conf['Subscribe_to_Comments']['notify_admin_on_subscribe'] )215 if ( pwg_db_changes() != 0 and $conf['Subscribe_to_Comments']['notify_admin_on_subscribe'] ) 216 216 { 217 217 stc_mail_notification_admins($email, $type, $element_id, $inserted_id); … … 219 219 220 220 // send validation mail 221 if ( is_a_guest() and pwg_db_changes( null) != 0 )221 if ( is_a_guest() and pwg_db_changes() != 0 ) 222 222 { 223 223 set_make_full_url(); … … 267 267 } 268 268 // just display confirmation message 269 else if (pwg_db_changes( null) != 0)269 else if (pwg_db_changes() != 0) 270 270 { 271 271 array_push($page['infos'], l10n('You have been added to the list of subscribers.')); … … 285 285 function un_subscribe_to_comments($email, $id) 286 286 { 287 if (empty($id)) 288 { 289 trigger_error('un_subscribe_to_comment: missing id', E_USER_WARNING); 287 if ( !empty($email) and !email_check_format($email) ) 288 { 289 trigger_error('un_subscribe_to_comment: bad email', E_USER_WARNING); 290 return false; 291 } 292 293 if (!preg_match('#^[0-9]+$#', $id)) 294 { 295 trigger_error('un_subscribe_to_comment: bad id', E_USER_WARNING); 290 296 return false; 291 297 } … … 308 314 WHERE 309 315 email = "'.pwg_db_real_escape_string($email).'" 310 AND id = "'.pwg_db_real_escape_string($id).'"316 AND id = '.$id.' 311 317 ;'; 312 318 pwg_query($query); 313 314 if (pwg_db_changes(null) != 0) return true; 315 return false; 319 320 return (pwg_db_changes() != 0); 316 321 } 317 322 … … 325 330 function validate_subscriptions($email, $id) 326 331 { 327 if ( empty($email))328 { 329 trigger_error('validate_subscriptions: missingemail', E_USER_WARNING);330 return false; 331 } 332 333 if ( empty($id))334 { 335 trigger_error('validate_subscriptions: missingid', E_USER_WARNING);332 if (!email_check_format($email)) 333 { 334 trigger_error('validate_subscriptions: bad email', E_USER_WARNING); 335 return false; 336 } 337 338 if (!preg_match('#^[0-9]+$#', $id)) 339 { 340 trigger_error('validate_subscriptions: bad id', E_USER_WARNING); 336 341 return false; 337 342 } … … 342 347 WHERE 343 348 email = "'.pwg_db_real_escape_string($email).'" 344 AND id = '. pwg_db_real_escape_string($id).'349 AND id = '.$id.' 345 350 ;'; 346 351 pwg_query($query); 347 348 if (pwg_db_changes(null) != 0) return true; 349 return false; 352 353 return (pwg_db_changes() != 0); 350 354 } 351 355 … … 371 375 $template->set_filename('stc_mail', dirname(__FILE__).'/../template/mail/admin.tpl'); 372 376 373 $subject = '['.strip_tags($conf['gallery_title']).'] '.sprintf(l10n('%s has subscribed to comments on '), is_a_guest()?$email:$user['username']);377 $subject = '['.strip_tags($conf['gallery_title']).'] '.sprintf(l10n('%s has subscribed to comments on %s.'), is_a_guest()?$email:$user['username'], null); 374 378 375 379 switch ($type) … … 401 405 $template->assign('STC', array( 402 406 'ELEMENT' => $element['on'], 403 'USER' => sprintf(l10n('%s has subscribed to comments on'), is_a_guest() ? '<b>'.$email.'</b>' : '<b>'.$user['username'].'</b> ('.$email.')'),407 'USER' => is_a_guest() ? '<b>'.$email.'</b>' : '<b>'.$user['username'].'</b> ('.$email.')', 404 408 'GALLERY_TITLE' => $conf['gallery_title'], 405 409 'TECHNICAL' => implode('<br>', $technical_infos), … … 504 508 $headers.= 'MIME-Version: 1.0'."\n"; 505 509 $headers.= 'X-Mailer: Piwigo Mailer'."\n"; 506 // $headers.= 'Content-Transfer-Encoding: Quoted-Printable'."\n";507 510 $headers.= 'Content-Transfer-Encoding: 8bit'."\n"; 508 511 $headers.= 'Content-Type: text/html; charset="'.get_pwg_charset().'";'."\n"; … … 523 526 $content = $template->parse('stc_mail_header', true) . $content . $template->parse('stc_mail_footer', true); 524 527 525 // $content = quoted_printable_encode($content); 526 $content = wordwrap($content, 70, "\n", true); 528 $content = wordwrap($content, 70, "\n", false); 527 529 528 530 unset_make_full_url(); … … 687 689 688 690 /** 689 * check if mail adress is valid690 * @param: string email691 * @return: bool692 */693 if (!function_exists('is_valid_email'))694 {695 function is_valid_email($mail_address)696 {697 if (version_compare(PHP_VERSION, '5.2.0') >= 0)698 {699 return filter_var($mail_address, FILTER_VALIDATE_EMAIL)!==false;700 }701 else702 {703 $atom = '[-a-z0-9!#$%&\'*+\\/=?^_`{|}~]'; // before arobase704 $domain = '([a-z0-9]([-a-z0-9]*[a-z0-9]+)?)'; // domain name705 $regex = '/^' . $atom . '+' . '(\.' . $atom . '+)*' . '@' . '(' . $domain . '{1,63}\.)+' . $domain . '{2,63}$/i';706 707 if (!preg_match($regex, $mail_address)) return false;708 return true;709 }710 }711 }712 713 714 /**715 691 * crypt a string using mcrypt extension or 716 692 * http://stackoverflow.com/questions/800922/how-to-encrypt-string-without-mcrypt-library-in-php/802957#802957
Note: See TracChangeset
for help on using the changeset viewer.