- Timestamp:
- Dec 23, 2013, 9:17:28 PM (10 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
extensions/Subscribe_to_comments/include/functions.inc.php
r21608 r26139 1 1 <?php 2 if (!defined('SUBSCRIBE_TO_PATH')) die('Hacking attempt!'); 3 4 include_once(PHPWG_ROOT_PATH.'include/functions_mail.inc.php'); 2 defined('SUBSCRIBE_TO_PATH') or die('Hacking attempt!'); 5 3 6 4 /** … … 10 8 function send_comment_to_subscribers($comm) 11 9 { 12 if ( empty($comm) or !is_array($comm))13 { 14 trigger_error('send_comment_to_subscribers: undefined edcomm', E_USER_WARNING);15 return false; 16 } 17 10 if (empty($comm) or !is_array($comm)) 11 { 12 trigger_error('send_comment_to_subscribers: undefined comm', E_USER_WARNING); 13 return false; 14 } 15 18 16 global $conf, $page, $user, $template; 19 17 20 18 // create search clauses 21 19 $where_clauses = array(); … … 24 22 $element_id = $comm['image_id']; 25 23 $element_type = 'image'; 26 27 array_push($where_clauses, 'type = "image" AND element_id = '.$element_id.''); 28 if (!empty($page['category']['id'])) array_push($where_clauses, 'type = "album-images" AND element_id = '.$page['category']['id'].''); 29 array_push($where_clauses, 'type = "all-images"'); 24 25 $where_clauses[] = '(type = "image" AND element_id = '.$element_id.')'; 26 $where_clauses[] = 'type = "all-images"'; 27 if (!empty($page['category']['id'])) 28 { 29 $where_clauses[] = '(type = "album-images" AND element_id = '.$page['category']['id'].')'; 30 } 30 31 } 31 32 else if (isset($comm['category_id'])) … … 33 34 $element_id = $comm['category_id']; 34 35 $element_type = 'category'; 35 36 array_push($where_clauses, 'type = "album" AND element_id = '.$element_id.'');37 array_push($where_clauses, 'type = "all-albums"');36 37 $where_clauses[] = '(type = "album" AND element_id = '.$element_id.')'; 38 $where_clauses[] = 'type = "all-albums"'; 38 39 } 39 40 else … … 41 42 return; 42 43 } 43 44 44 45 // exclude current user 45 46 $exclude = null; … … 52 53 $exclude = $user['email']; 53 54 } 54 55 55 56 // get subscribers datas 56 57 $query = ' … … 61 62 FROM '.SUBSCRIBE_TO_TABLE.' 62 63 WHERE ( 63 ('.implode(")\n OR (", $where_clauses).')64 '.implode("\n OR ", $where_clauses).' 64 65 ) 65 66 AND validated = true 66 67 AND email != "'.$exclude.'" 68 GROUP BY email 67 69 '; 68 $subscriptions = hash_from_query($query, 'id'); 69 70 if (count($subscriptions)==0) return; 71 70 $subscriptions = query2array($query); 71 72 if (count($subscriptions)==0) 73 { 74 return; 75 } 76 72 77 set_make_full_url(); 73 78 74 79 // get element infos 75 80 if ($element_type == 'image') … … 81 86 $element = get_category_infos($comm['category_id']); 82 87 } 83 88 84 89 // format comment 85 if ($comm['author'] == 'guest') $comm['author'] = l10n('guest'); 90 if ($comm['author'] == 'guest') 91 { 92 $comm['author'] = l10n('guest'); 93 } 94 86 95 $comm['author'] = trigger_event('render_comment_author', $comm['author']); 87 96 $comm['content'] = trigger_event('render_comment_content', $comm['content']); 88 89 // mail content 90 $subject = '['.strip_tags($conf['gallery_title']).'] Re:'.$element['name']; 91 92 $template->set_filename('stc_mail', realpath(SUBSCRIBE_TO_PATH . 'template/mail/notification.tpl')); 97 98 include_once(PHPWG_ROOT_PATH.'include/functions_mail.inc.php'); 93 99 94 100 foreach ($subscriptions as $row) … … 103 109 $row['user_id'] = $conf['guest_id']; 104 110 } 105 111 106 112 // check permissions 107 113 if (!user_can_view_element($row['user_id'], $element_id, $element_type)) … … 109 115 continue; 110 116 } 111 112 // send mail 113 switch_lang_to($row['language']); 114 load_language('plugin.lang', SUBSCRIBE_TO_PATH); 115 116 $comm['caption'] = sprintf('<b>%s</b> wrote on <i>%s</i>', $comm['author'], format_date(date('Y-m-d H:i:s'))); 117 118 $template->assign('STC', array( 119 'element' => $element, 120 'comment' => $comm, 121 'UNSUB_URL' => make_stc_url('unsubscribe', $row['email'], $row['id']), 122 'MANAGE_URL' => make_stc_url('manage', $row['email']), 123 'GALLERY_TITLE' => $conf['gallery_title'], 124 )); 125 126 $content = $template->parse('stc_mail', true); 127 128 stc_send_mail($row['email'], $content, $subject); 117 118 switch_lang_to($language); 119 120 $comm['date'] = format_date(date('Y-m-d H:i:s')); 121 122 pwg_mail( 123 $row['email'], 124 array( 125 'subject' => '['.strip_tags($conf['gallery_title']).'] Re:'.$element['name'], 126 ), 127 array( 128 'filename' => 'notification', 129 'dirname' => SUBSCRIBE_TO_PATH . 'template', 130 'assign' => array( 131 'ELEMENT' => $element, 132 'COMMENT' => $comm, 133 'UNSUB_URL' => make_stc_url('unsubscribe', $row['email'], $row['id']), 134 'MANAGE_URL' => make_stc_url('manage', $row['email']), 135 ), 136 ) 137 ); 138 129 139 switch_lang_back(); 130 140 } 131 141 132 142 load_language('plugin.lang', SUBSCRIBE_TO_PATH); 133 143 unset_make_full_url(); … … 149 159 return false; 150 160 } 151 152 if ( !in_array($type, array('all-images','all-albums')) and $element_id == 'NULL')161 162 if (!in_array($type, array('all-images','all-albums')) and $element_id == 'NULL') 153 163 { 154 164 trigger_error('subscribe_to_comment: missing element_id', E_USER_WARNING); 155 165 return false; 156 166 } 157 167 158 168 global $page, $conf, $user, $template, $picture; 159 169 160 170 // check email 161 if ( !empty($email) and !email_check_format($email))162 { 163 array_push($page['errors'], l10n('mail address must be like xxx@yyy.eee (example : jack@altern.org)'));164 return false; 165 } 166 if ( ( is_a_guest() or empty($user['email'])) and empty($email) )167 { 168 array_push($page['errors'], l10n('Invalid email adress, your are not subscribed to comments.'));169 return false; 170 } 171 else if ( !is_a_guest() and empty($email))171 if (!empty($email) and !email_check_format($email)) 172 { 173 $page['errors'][] = l10n('mail address must be like xxx@yyy.eee (example : jack@altern.org)'); 174 return false; 175 } 176 if ( (is_a_guest() or empty($user['email'])) and empty($email) ) 177 { 178 $page['errors'][] = l10n('Invalid email address, your are not subscribed to comments.'); 179 return false; 180 } 181 else if (!is_a_guest() and empty($email)) 172 182 { 173 183 $email = $user['email']; 174 184 } 175 176 // search if already registered (can't use ODKU because we want to get the id of inserted OR updated row)185 186 // search if already registered 177 187 $query = ' 178 188 SELECT id … … 184 194 ;'; 185 195 $result = pwg_query($query); 186 196 187 197 if (pwg_db_num_rows($result)) 188 198 { 189 list($inserted_id) = pwg_db_fetch_row($result); 190 } 191 else 192 { 193 $query = ' 199 return false; 200 } 201 202 $query = ' 194 203 INSERT INTO '.SUBSCRIBE_TO_TABLE.'( 195 204 type, … … 209 218 ) 210 219 ;'; 211 pwg_query($query); 212 213 $inserted_id = pwg_db_insert_id(); 214 } 215 216 // notify admins 217 if ( pwg_db_changes() != 0 and $conf['Subscribe_to_Comments']['notify_admin_on_subscribe'] ) 218 { 219 stc_mail_notification_admins($email, $type, $element_id, $inserted_id); 220 } 221 222 // send validation mail 223 if ( is_a_guest() and pwg_db_changes() != 0 ) 224 { 225 set_make_full_url(); 226 227 $template->set_filename('stc_mail', realpath(SUBSCRIBE_TO_PATH . 'template/mail/confirm.tpl')); 228 229 $subject = '['.strip_tags($conf['gallery_title']).'] '.l10n('Confirm your subscribtion to comments'); 230 220 pwg_query($query); 221 222 $stc_id = pwg_db_insert_id(); 223 224 include_once(PHPWG_ROOT_PATH.'include/functions_mail.inc.php'); 225 226 set_make_full_url(); 227 228 if (!is_a_guest() or $conf['Subscribe_to_Comments']['notify_admin_on_subscribe']) 229 { 231 230 switch ($type) 232 231 { 233 232 case 'image': 234 233 $element = get_picture_infos($element_id); 235 $element['on'] = sprintf(l10n('the picture <a href="%s">%s</a>'), $element['url'], $element['name']);234 $element['on'] = l10n('the picture <a href="%s">%s</a>', $element['url'], $element['name']); 236 235 break; 237 236 case 'album-images': 238 237 $element = get_category_infos($element_id); 239 $element['on'] = sprintf(l10n('all pictures of the album <a href="%s">%s</a>'), $element['url'], $element['name']);238 $element['on'] = l10n('all pictures of the album <a href="%s">%s</a>', $element['url'], $element['name']); 240 239 break; 241 240 case 'all-images': … … 245 244 case 'album': 246 245 $element = get_category_infos($element_id); 247 $element['on'] = sprintf(l10n('the album <a href="%s">%s</a>'), $element['url'], $element['name']);246 $element['on'] = l10n('the album <a href="%s">%s</a>', $element['url'], $element['name']); 248 247 break; 249 248 case 'all-albums': … … 252 251 break; 253 252 } 254 255 $template->assign('STC', array( 256 'element' => $element, 257 'VALIDATE_URL' => make_stc_url('validate', $email, $inserted_id), 258 'MANAGE_URL' => make_stc_url('manage', $email), 259 'GALLERY_TITLE' => $conf['gallery_title'], 260 )); 261 262 $content = $template->parse('stc_mail', true); 263 264 stc_send_mail($email, $content, $subject); 265 unset_make_full_url(); 266 267 array_push($page['infos'], l10n('Please check your email inbox to confirm your subscription.')); 268 return true; 253 } 254 255 // send validation mail 256 if (is_a_guest()) 257 { 258 pwg_mail( 259 $email, 260 array( 261 'subject' => '['.strip_tags($conf['gallery_title']).'] '.l10n('Confirm your subscription to comments'), 262 ), 263 array( 264 'filename' => 'confirm', 265 'dirname' => SUBSCRIBE_TO_PATH . 'template', 266 'assign' => array( 267 'ELEMENT' => $element, 268 'VALIDATE_URL' => make_stc_url('validate', $email, $stc_id), 269 'MANAGE_URL' => make_stc_url('manage', $email), 270 ), 271 ) 272 ); 273 274 $page['infos'][] = l10n('Please check your email in-box to confirm your subscription.'); 269 275 } 270 276 // just display confirmation message 271 else if (pwg_db_changes() != 0) 272 { 273 array_push($page['infos'], l10n('You have been added to the list of subscribers.')); 274 return true; 275 } 276 277 return false; 277 else 278 { 279 $page['infos'][] = l10n('You have been added to the list of subscribers.'); 280 } 281 282 // notify admins 283 if ($conf['Subscribe_to_Comments']['notify_admin_on_subscribe']) 284 { 285 $keyargs_content = array( 286 get_l10n_args('Hi administrators,'), 287 get_l10n_args(''), 288 get_l10n_args('%s has subscribed to comments on %s.', array($email, $element['on'])), 289 get_l10n_args('', ''), 290 get_l10n_args('Connected user: %s', stripslashes($user['username'])), 291 get_l10n_args('IP: %s', $_SERVER['REMOTE_ADDR']), 292 get_l10n_args('Browser: %s', $_SERVER['HTTP_USER_AGENT']), 293 ); 294 295 pwg_mail_notification_admins( 296 get_l10n_args('%s has subscribed to comments on %s.', array($email, '')), 297 $keyargs_content 298 ); 299 } 300 301 unset_make_full_url(); 302 303 return true; 278 304 } 279 305 … … 285 311 * @return: bool 286 312 */ 287 function un_subscribe_to_comments($email, $id )288 { 289 if ( !empty($email) and !email_check_format($email))313 function un_subscribe_to_comments($email, $ids) 314 { 315 if (!empty($email) and !email_check_format($email)) 290 316 { 291 317 trigger_error('un_subscribe_to_comment: bad email', E_USER_WARNING); 292 318 return false; 293 319 } 294 295 if (!preg_match('#^[0-9]+$#', $id)) 320 if (empty($ids)) 296 321 { 297 322 trigger_error('un_subscribe_to_comment: bad id', E_USER_WARNING); 298 323 return false; 299 324 } 300 301 global $ template, $user;302 325 326 global $user; 327 303 328 // check email 304 if ( ( is_a_guest() or empty($user['email'])) and empty($email) )305 { 306 return false; 307 } 308 else if ( !is_a_guest() and empty($email))329 if ( (is_a_guest() or empty($user['email'])) and empty($email) ) 330 { 331 return false; 332 } 333 else if (!is_a_guest() and empty($email)) 309 334 { 310 335 $email = $user['email']; 311 336 } 312 337 338 if (!is_array($ids)) 339 { 340 $ids = array($ids); 341 } 342 $ids = array_map('intval', $ids); 343 313 344 // delete subscription 314 345 $query = ' 315 346 DELETE FROM '.SUBSCRIBE_TO_TABLE.' 316 WHERE 347 WHERE 317 348 email = "'.pwg_db_real_escape_string($email).'" 318 AND id = '.$id.'349 AND id IN('. implode(',', $ids) .') 319 350 ;'; 320 351 pwg_query($query); 321 352 322 353 return (pwg_db_changes() != 0); 323 354 } … … 330 361 * @return: bool 331 362 */ 332 function validate_subscriptions($email, $id )363 function validate_subscriptions($email, $ids) 333 364 { 334 365 if (!email_check_format($email)) … … 337 368 return false; 338 369 } 339 340 if (!preg_match('#^[0-9]+$#', $id)) 370 if (empty($ids)) 341 371 { 342 372 trigger_error('validate_subscriptions: bad id', E_USER_WARNING); 343 373 return false; 344 374 } 345 375 376 if (!is_array($ids)) 377 { 378 $ids = array($ids); 379 } 380 $ids = array_map('intval', $ids); 381 346 382 $query = ' 347 383 UPDATE '.SUBSCRIBE_TO_TABLE.' 348 384 SET validated = "true" 349 WHERE 385 WHERE 350 386 email = "'.pwg_db_real_escape_string($email).'" 351 AND id = '.$id.'387 AND id IN('. implode(',', $ids) .') 352 388 ;'; 353 389 pwg_query($query); 354 390 355 391 return (pwg_db_changes() != 0); 356 }357 358 359 /**360 * send notification to admins361 * @param: string email362 * @param: string type (image|album-images|all-images|album|all-albums)363 * @param: int element_id364 * @param: int subscription id365 */366 function stc_mail_notification_admins($email, $type, $element_id, $inserted_id)367 {368 global $user, $conf, $template;369 370 $admins = get_admins_email();371 if (empty($admins)) return;372 373 set_make_full_url();374 switch_lang_to(get_default_language());375 load_language('plugin.lang', SUBSCRIBE_TO_PATH);376 377 $template->set_filename('stc_mail', realpath(SUBSCRIBE_TO_PATH . 'template/mail/admin.tpl'));378 379 $subject = '['.strip_tags($conf['gallery_title']).'] '.sprintf(l10n('%s has subscribed to comments on %s.'), is_a_guest()?$email:$user['username'], null);380 381 switch ($type)382 {383 case 'image':384 $element = get_picture_infos($element_id, false);385 $element['on'] = sprintf(l10n('the picture <a href="%s">%s</a>'), $element['url'], $element['name']);386 break;387 case 'album-images':388 $element = get_category_infos($element_id, false);389 $element['on'] = sprintf(l10n('all pictures of the album <a href="%s">%s</a>'), $element['url'], $element['name']);390 break;391 case 'all-images':392 $element['on'] = l10n('all pictures of the gallery');393 break;394 case 'album':395 $element = get_category_infos($element_id, false);396 $element['on'] = sprintf(l10n('the album <a href="%s">%s</a>'), $element['url'], $element['name']);397 break;398 case 'all-albums':399 $element['on'] = l10n('all albums of the gallery');400 break;401 }402 403 $technical_infos[] = sprintf(l10n('Connected user: %s'), stripslashes($user['username']));404 $technical_infos[] = sprintf(l10n('IP: %s'), $_SERVER['REMOTE_ADDR']);405 $technical_infos[] = sprintf(l10n('Browser: %s'), $_SERVER['HTTP_USER_AGENT']);406 407 $template->assign('STC', array(408 'ELEMENT' => $element['on'],409 'USER' => is_a_guest() ? '<b>'.$email.'</b>' : '<b>'.$user['username'].'</b> ('.$email.')',410 'GALLERY_TITLE' => $conf['gallery_title'],411 'TECHNICAL' => implode('<br>', $technical_infos),412 ));413 414 $content = $template->parse('stc_mail', true);415 416 stc_send_mail($admins, $content, $subject);417 418 unset_make_full_url();419 switch_lang_back();420 load_language('plugin.lang', SUBSCRIBE_TO_PATH);421 392 } 422 393 … … 431 402 function make_stc_url($action, $email, $id=null) 432 403 { 433 if ( empty($action) or empty($email))404 if (empty($action) or empty($email)) 434 405 { 435 406 trigger_error('make_stc_url: missing action and/or mail', E_USER_WARNING); 436 407 return null; 437 408 } 438 409 439 410 global $conf; 440 411 set_make_full_url(); 441 442 $url_params = array( 443 'action' => $action, 444 'email' => $email, 445 ); 446 412 413 $url_params = compact('action', 'email'); 447 414 if (!empty($id)) 448 415 { 449 416 $url_params['id'] = $id; 450 417 } 451 418 452 419 $url_params['key'] = crypt_value( 453 $action.$email. (isset($url_params['id'])?$url_params['id']:null),420 $action.$email.$id, 454 421 $conf['secret_key'] 455 422 ); 456 423 457 424 $url = add_url_params( 458 make_index_url( array('section' => 'subscriptions')),425 make_index_url(array('section' => 'subscriptions')), 459 426 $url_params 460 427 ); 461 428 462 429 unset_make_full_url(); 463 430 return $url; 464 }465 466 467 /**468 * send mail with STC style469 * @param: string to470 * @param: string content471 * @param: string subject472 * @return: bool473 */474 function stc_send_mail($to, $content, $subject)475 {476 global $conf, $conf_mail, $page, $template;477 478 // inputs479 if (empty($to))480 {481 return false;482 }483 484 if (empty($content))485 {486 return false;487 }488 489 if (empty($subject))490 {491 $subject = 'Piwigo';492 }493 else494 {495 $subject = trim(preg_replace('#[\n\r]+#s', '', $subject));496 $subject = encode_mime_header($subject);497 }498 499 if (!isset($conf_mail))500 {501 $conf_mail = get_mail_configuration();502 }503 504 $args['from'] = $conf_mail['formated_email_webmaster'];505 506 set_make_full_url();507 508 // hearders509 $headers = 'From: '.$args['from']."\n";510 $headers.= 'MIME-Version: 1.0'."\n";511 $headers.= 'X-Mailer: Piwigo Mailer'."\n";512 $headers.= 'Content-Transfer-Encoding: 8bit'."\n";513 $headers.= 'Content-Type: text/html; charset="'.get_pwg_charset().'";'."\n";514 515 // template516 $template->set_filenames(array(517 'stc_mail_header' => realpath(SUBSCRIBE_TO_PATH . 'template/mail/header.tpl'),518 'stc_mail_footer' => realpath(SUBSCRIBE_TO_PATH . 'template/mail/footer.tpl'),519 ));520 $stc_mail_css = file_get_contents(realpath(SUBSCRIBE_TO_PATH . 'template/mail/style.css'));521 522 $template->assign(array(523 'GALLERY_URL' => get_gallery_home_url(),524 'PHPWG_URL' => PHPWG_URL,525 'STC_MAIL_CSS' => str_replace("\n", null, $stc_mail_css),526 ));527 528 $content = $template->parse('stc_mail_header', true) . $content . $template->parse('stc_mail_footer', true);529 530 $content = wordwrap($content, 70, "\n", false);531 532 unset_make_full_url();533 534 // send mail535 return536 trigger_event('send_mail',537 false, /* Result */538 trigger_event('send_mail_to', get_strict_email_list($to)),539 trigger_event('send_mail_subject', $subject),540 trigger_event('send_mail_content', $content),541 trigger_event('send_mail_headers', $headers),542 $args543 );544 431 } 545 432 … … 553 440 function get_picture_infos($image_id, $with_thumb=true) 554 441 { 555 if (empty($image_id)) return array(); 556 442 if (empty($image_id)) 443 { 444 return array(); 445 } 446 557 447 $query = ' 558 448 SELECT … … 565 455 ;'; 566 456 $element = pwg_db_fetch_assoc(pwg_query($query)); 567 457 568 458 if (empty($element['name'])) 569 459 { … … 571 461 } 572 462 $element['name'] = trigger_event('render_element_name', $element['name']); 573 463 574 464 $element['url'] = make_picture_url(array( 575 465 'image_id'=>$element['id'] 576 466 )); 577 467 578 468 if ($with_thumb) 579 469 { 580 470 $element['thumbnail'] = DerivativeImage::thumb_url($element); 581 471 } 582 472 583 473 return $element; 584 474 } … … 593 483 { 594 484 global $conf; 595 596 if ($user_id===null) $user_id = $conf['guest_id']; 597 485 486 if ($user_id===null) 487 { 488 $user_id = $conf['guest_id']; 489 } 490 598 491 $query = ' 599 492 SELECT … … 606 499 img.path 607 500 FROM '.CATEGORIES_TABLE.' AS cat 608 LEFT JOIN '.USER_CACHE_CATEGORIES_TABLE.' AS ucc 501 LEFT JOIN '.USER_CACHE_CATEGORIES_TABLE.' AS ucc 609 502 ON ucc.cat_id = cat.id AND ucc.user_id = '.$user_id.' 610 503 LEFT JOIN '.IMAGES_TABLE.' AS img … … 613 506 ;'; 614 507 $element = pwg_db_fetch_assoc(pwg_query($query)); 615 508 616 509 $element['url'] = make_index_url(array( 617 510 'section'=>'categories', 618 511 'category'=>$element, 619 512 )); 620 513 621 514 $element['name'] = trigger_event('render_category_name', $element['name']); 622 515 623 516 if ($with_thumb) 624 517 { … … 636 529 } 637 530 } 638 531 639 532 return $element; 640 533 } … … 647 540 { 648 541 global $conf, $user; 649 542 650 543 $admins = array(); 651 544 652 545 $query = ' 653 546 SELECT … … 655 548 u.'.$conf['user_fields']['email'].' AS email 656 549 FROM '.USERS_TABLE.' AS u 657 JOIN '.USER_INFOS_TABLE.' AS i 550 JOIN '.USER_INFOS_TABLE.' AS i 658 551 ON i.user_id = u.'.$conf['user_fields']['id'].' 659 552 WHERE i.status IN ("webmaster", "admin") … … 686 579 { 687 580 global $conf; 688 581 689 582 $old_conf = $conf['external_authentification']; 690 583 $conf['external_authentification'] = false; 691 584 $user = getuserdata($user_id, true); 692 585 $conf['external_authentification'] = $old_conf; 693 586 694 587 if ($type == 'image') 695 588 { … … 715 608 */ 716 609 function crypt_value($value, $key) 717 { 610 { 718 611 if (extension_loaded('mcrypt')) 719 612 { … … 733 626 } 734 627 } 735 628 736 629 $result = base64url_encode($result); 737 return trim($result); 630 return trim($result); 738 631 } 739 632 … … 746 639 function decrypt_value($value, $key) 747 640 { 748 $value = base64url_decode($value); 749 641 $value = base64url_decode($value); 642 750 643 if (extension_loaded('mcrypt')) 751 644 { … … 765 658 } 766 659 } 767 660 768 661 return trim($result); 769 662 } … … 773 666 * http://php.net/manual/en/function.base64-encode.php#103849 774 667 */ 775 function base64url_encode($data) 776 { 777 return rtrim(strtr(base64_encode($data), '+/', '-_'), '='); 778 } 779 function base64url_decode($data) 780 { 781 return base64_decode(str_pad(strtr($data, '-_', '+/'), strlen($data) % 4, '=', STR_PAD_RIGHT)); 782 } 783 784 ?> 668 if (!function_exists('base64url_encode')) 669 { 670 function base64url_encode($data) 671 { 672 return rtrim(strtr(base64_encode($data), '+/', '-_'), '='); 673 } 674 function base64url_decode($data) 675 { 676 return base64_decode(str_pad(strtr($data, '-_', '+/'), strlen($data) % 4, '=', STR_PAD_RIGHT)); 677 } 678 }
Note: See TracChangeset
for help on using the changeset viewer.