[ Index ] |
PHP Cross Reference of MyBB 1.8.39 |
[Summary view] [Print] [Text view]
1 <?php 2 /** 3 * MyBB 1.8 4 * Copyright 2014 MyBB Group, All Rights Reserved 5 * 6 * Website: http://www.mybb.com 7 * License: http://www.mybb.com/about/license 8 * 9 */ 10 11 /** 12 * Logs an administrator action taking any arguments as log data. 13 */ 14 function log_admin_action() 15 { 16 global $db, $mybb; 17 18 $data = func_get_args(); 19 20 if(count($data) == 1 && is_array($data[0])) 21 { 22 $data = $data[0]; 23 } 24 25 if(!is_array($data)) 26 { 27 $data = array($data); 28 } 29 30 $log_entry = array( 31 "uid" => (int)$mybb->user['uid'], 32 "ipaddress" => $db->escape_binary(my_inet_pton(get_ip())), 33 "dateline" => TIME_NOW, 34 "module" => $db->escape_string($mybb->get_input('module')), 35 "action" => $db->escape_string($mybb->get_input('action')), 36 "data" => $db->escape_string(@my_serialize($data)) 37 ); 38 39 $db->insert_query("adminlog", $log_entry); 40 } 41 42 /** 43 * Redirects the current user to a specified URL. 44 * 45 * @param string $url The URL to redirect to 46 */ 47 function admin_redirect($url) 48 { 49 if(!headers_sent()) 50 { 51 $url = str_replace("&", "&", $url); 52 header("Location: $url"); 53 } 54 else 55 { 56 echo "<meta http-equiv=\"refresh\" content=\"0; url={$url}\">"; 57 } 58 exit; 59 } 60 61 /** 62 * Updates an administration session data array. 63 * 64 * @param string $name The name of the item in the data session to update 65 * @param mixed $value The value 66 */ 67 function update_admin_session($name, $value) 68 { 69 global $db, $admin_session; 70 71 $admin_session['data'][$name] = $value; 72 $updated_session = array( 73 "data" => $db->escape_string(@my_serialize($admin_session['data'])) 74 ); 75 $db->update_query("adminsessions", $updated_session, "sid='{$admin_session['sid']}'"); 76 } 77 78 /** 79 * Saves a "flash message" for the current user to be shown on their next page visit. 80 * 81 * @param string $message The message to show 82 * @param string $type The type of message to be shown (success|error) 83 */ 84 function flash_message($message, $type='') 85 { 86 $flash = array('message' => $message, 'type' => $type); 87 update_admin_session('flash_message', $flash); 88 } 89 90 /** 91 * Draw pagination for pages in the Admin CP. 92 * 93 * @param int $page The current page we're on 94 * @param int $per_page The number of items per page 95 * @param int $total_items The total number of items in this collection 96 * @param string $url The URL for pagination of this collection 97 * @return string The built pagination 98 */ 99 function draw_admin_pagination($page, $per_page, $total_items, $url) 100 { 101 global $mybb, $lang; 102 103 if($total_items <= $per_page) 104 { 105 return ''; 106 } 107 108 $pages = ceil($total_items / $per_page); 109 110 $pagination = "<div class=\"pagination\"><span class=\"pages\">{$lang->pages}: </span>\n"; 111 112 if($page > 1) 113 { 114 $prev = $page-1; 115 $prev_page = fetch_page_url($url, $prev); 116 $pagination .= "<a href=\"{$prev_page}\" class=\"pagination_previous\">« {$lang->previous}</a> \n"; 117 } 118 119 // Maximum number of "page bits" to show 120 if(!$mybb->settings['maxmultipagelinks']) 121 { 122 $mybb->settings['maxmultipagelinks'] = 5; 123 } 124 125 $max_links = $mybb->settings['maxmultipagelinks']; 126 127 $from = $page-floor($mybb->settings['maxmultipagelinks']/2); 128 $to = $page+floor($mybb->settings['maxmultipagelinks']/2); 129 130 if($from <= 0) 131 { 132 $from = 1; 133 $to = $from+$max_links-1; 134 } 135 136 if($to > $pages) 137 { 138 $to = $pages; 139 $from = $pages-$max_links+1; 140 if($from <= 0) 141 { 142 $from = 1; 143 } 144 } 145 146 if($to == 0) 147 { 148 $to = $pages; 149 } 150 151 if($from > 2) 152 { 153 $first = fetch_page_url($url, 1); 154 $pagination .= "<a href=\"{$first}\" title=\"{$lang->page} 1\" class=\"pagination_first\">1</a> ... "; 155 } 156 157 for($i = $from; $i <= $to; ++$i) 158 { 159 $page_url = fetch_page_url($url, $i); 160 if($page == $i) 161 { 162 $pagination .= "<span class=\"pagination_current\">{$i}</span> \n"; 163 } 164 else 165 { 166 $pagination .= "<a href=\"{$page_url}\" title=\"{$lang->page} {$i}\">{$i}</a> \n"; 167 } 168 } 169 170 if($to < $pages) 171 { 172 $last = fetch_page_url($url, $pages); 173 $pagination .= "... <a href=\"{$last}\" title=\"{$lang->page} {$pages}\" class=\"pagination_last\">{$pages}</a>"; 174 } 175 176 if($page < $pages) 177 { 178 $next = $page+1; 179 $next_page = fetch_page_url($url, $next); 180 $pagination .= " <a href=\"{$next_page}\" class=\"pagination_next\">{$lang->next} »</a>\n"; 181 } 182 $pagination .= "</div>\n"; 183 return $pagination; 184 } 185 186 /** 187 * Builds a CSV parent list for a particular forum. 188 * 189 * @param int $fid The forum ID 190 * @param string $navsep Optional separator - defaults to comma for CSV list 191 * @return string The built parent list 192 */ 193 function make_parent_list($fid, $navsep=",") 194 { 195 global $pforumcache, $db; 196 197 if(!$pforumcache) 198 { 199 $query = $db->simple_select("forums", "name, fid, pid", "", array("order_by" => "disporder, pid")); 200 while($forum = $db->fetch_array($query)) 201 { 202 $pforumcache[$forum['fid']][$forum['pid']] = $forum; 203 } 204 } 205 206 reset($pforumcache); 207 reset($pforumcache[$fid]); 208 209 $navigation = ''; 210 211 foreach($pforumcache[$fid] as $key => $forum) 212 { 213 if($fid == $forum['fid']) 214 { 215 if(!empty($pforumcache[$forum['pid']])) 216 { 217 $navigation = make_parent_list($forum['pid'], $navsep).$navigation; 218 } 219 220 if($navigation) 221 { 222 $navigation .= $navsep; 223 } 224 $navigation .= $forum['fid']; 225 } 226 } 227 return $navigation; 228 } 229 230 /** 231 * @param int $fid 232 */ 233 function save_quick_perms($fid) 234 { 235 global $db, $inherit, $canview, $canpostthreads, $canpostreplies, $canpostpolls, $canpostattachments, $cache; 236 237 $permission_fields = array(); 238 239 $field_list = $db->show_fields_from("forumpermissions"); 240 foreach($field_list as $field) 241 { 242 if(strpos($field['Field'], 'can') !== false || strpos($field['Field'], 'mod') !== false) 243 { 244 $permission_fields[$field['Field']] = 1; 245 } 246 } 247 248 // "Can Only View Own Threads" and "Can Only Reply Own Threads" permissions are forum permission only options 249 $usergroup_permission_fields = $permission_fields; 250 unset($usergroup_permission_fields['canonlyviewownthreads']); 251 unset($usergroup_permission_fields['canonlyreplyownthreads']); 252 253 $query = $db->simple_select("usergroups", "gid"); 254 while($usergroup = $db->fetch_array($query)) 255 { 256 $query2 = $db->simple_select("forumpermissions", $db->escape_string(implode(',', array_keys($permission_fields))), "fid='{$fid}' AND gid='{$usergroup['gid']}'", array('limit' => 1)); 257 $existing_permissions = $db->fetch_array($query2); 258 259 if(!$existing_permissions) 260 { 261 $query2 = $db->simple_select("usergroups", $db->escape_string(implode(',', array_keys($usergroup_permission_fields))), "gid='{$usergroup['gid']}'", array('limit' => 1)); 262 $existing_permissions = $db->fetch_array($query2); 263 } 264 265 // Delete existing permissions 266 $db->delete_query("forumpermissions", "fid='{$fid}' AND gid='{$usergroup['gid']}'"); 267 268 // Only insert the new ones if we're using custom permissions 269 if(empty($inherit[$usergroup['gid']])) 270 { 271 if(!empty($canview[$usergroup['gid']])) 272 { 273 $pview = 1; 274 } 275 else 276 { 277 $pview = 0; 278 } 279 280 if(!empty($canpostthreads[$usergroup['gid']])) 281 { 282 $pthreads = 1; 283 } 284 else 285 { 286 $pthreads = 0; 287 } 288 289 if(!empty($canpostreplies[$usergroup['gid']])) 290 { 291 $preplies = 1; 292 } 293 else 294 { 295 $preplies = 0; 296 } 297 298 if(!empty($canpostpolls[$usergroup['gid']])) 299 { 300 $ppolls = 1; 301 } 302 else 303 { 304 $ppolls = 0; 305 } 306 307 if(!$preplies && !$pthreads) 308 { 309 $ppost = 0; 310 } 311 else 312 { 313 $ppost = 1; 314 } 315 316 $insertquery = array( 317 "fid" => (int)$fid, 318 "gid" => (int)$usergroup['gid'], 319 "canview" => (int)$pview, 320 "canpostthreads" => (int)$pthreads, 321 "canpostreplys" => (int)$preplies, 322 "canpostpolls" => (int)$ppolls, 323 ); 324 325 foreach($permission_fields as $field => $value) 326 { 327 if(array_key_exists($field, $insertquery)) 328 { 329 continue; 330 } 331 332 $insertquery[$db->escape_string($field)] = isset($existing_permissions[$field]) ? (int)$existing_permissions[$field] : 0; 333 } 334 335 $db->insert_query("forumpermissions", $insertquery); 336 } 337 } 338 $cache->update_forumpermissions(); 339 } 340 341 /** 342 * Checks if a particular user has the necessary permissions to access a particular page. 343 * 344 * @param array $action Array containing module and action to check for 345 * @param bool $error 346 * @return bool 347 */ 348 function check_admin_permissions($action, $error = true) 349 { 350 global $mybb, $page, $lang, $modules_dir; 351 352 if(is_super_admin($mybb->user['uid'])) 353 { 354 return true; 355 } 356 357 require_once $modules_dir."/".$action['module']."/module_meta.php"; 358 if(function_exists($action['module']."_admin_permissions")) 359 { 360 $func = $action['module']."_admin_permissions"; 361 $permissions = $func(); 362 if( 363 !empty($permissions['permissions'][$action['action']]) && 364 empty($mybb->admin['permissions'][$action['module']][$action['action']]) 365 ) 366 { 367 if($error) 368 { 369 $page->output_header($lang->access_denied); 370 $page->add_breadcrumb_item($lang->access_denied, "index.php?module=home-index"); 371 $page->output_error("<b>{$lang->access_denied}</b><ul><li style=\"list-style-type: none;\">{$lang->access_denied_desc}</li></ul>"); 372 $page->output_footer(); 373 exit; 374 } 375 else 376 { 377 return false; 378 } 379 } 380 } 381 382 return true; 383 } 384 385 /** 386 * Fetches the list of administrator permissions for a particular user or group 387 * 388 * @param int $get_uid The user ID to fetch permissions for 389 * @param int $get_gid The (optional) group ID to fetch permissions for 390 * @return array Array of permissions for specified user or group 391 */ 392 function get_admin_permissions($get_uid=0, $get_gid=0) 393 { 394 global $db, $mybb; 395 396 // Set UID and GID if none 397 $uid = $get_uid; 398 $gid = $get_gid; 399 400 $gid_array = array(); 401 402 if($uid === 0) 403 { 404 $uid = $mybb->user['uid']; 405 } 406 407 if(!$gid) 408 { 409 // Prepare user's groups since the group isn't specified 410 $gid_array[] = (-1) * (int)$mybb->user['usergroup']; 411 412 if($mybb->user['additionalgroups']) 413 { 414 $additional_groups = explode(',', $mybb->user['additionalgroups']); 415 416 if(!empty($additional_groups)) 417 { 418 // Make sure gids are negative 419 foreach($additional_groups as $g) 420 { 421 $gid_array[] = (-1) * abs($g); 422 } 423 } 424 } 425 } 426 else 427 { 428 // Group is specified 429 // Make sure gid is negative 430 $gid_array[] = (-1) * abs($gid); 431 } 432 433 // What are we trying to find? 434 if($get_gid && !$get_uid) 435 { 436 // A group only 437 438 $options = array( 439 "order_by" => "uid", 440 "order_dir" => "ASC", 441 "limit" => "1" 442 ); 443 $query = $db->simple_select("adminoptions", "permissions", "(uid='-{$get_gid}' OR uid='0') AND permissions != ''", $options); 444 return my_unserialize($db->fetch_field($query, "permissions")); 445 } 446 else 447 { 448 // A user and/or group 449 450 $options = array( 451 "order_by" => "uid", 452 "order_dir" => "DESC" 453 ); 454 455 // Prepare user's groups into SQL format 456 $group_sql = ''; 457 foreach($gid_array as $gid) 458 { 459 $group_sql .= " OR uid='{$gid}'"; 460 } 461 462 $perms_group = array(); 463 $query = $db->simple_select("adminoptions", "permissions, uid", "(uid='{$uid}'{$group_sql}) AND permissions != ''", $options); 464 while($perm = $db->fetch_array($query)) 465 { 466 $perm['permissions'] = my_unserialize($perm['permissions']); 467 468 // Sorting out which permission is which 469 if($perm['uid'] > 0) 470 { 471 $perms_user = $perm; 472 return $perms_user['permissions']; 473 } 474 elseif($perm['uid'] < 0) 475 { 476 $perms_group[] = $perm['permissions']; 477 } 478 else 479 { 480 $perms_def = $perm['permissions']; 481 } 482 } 483 484 // Figure out group permissions...ugh. 485 foreach($perms_group as $gperms) 486 { 487 if(!isset($final_group_perms)) 488 { 489 // Use this group as the base for admin group permissions 490 $final_group_perms = $gperms; 491 continue; 492 } 493 494 // Loop through each specific permission to find the highest permission 495 foreach($gperms as $perm_name => $perm_value) 496 { 497 if($final_group_perms[$perm_name] != '1' && $perm_value == '1') 498 { 499 $final_group_perms[$perm_name] = '1'; 500 } 501 } 502 } 503 504 // Send specific user, or group permissions before default. 505 // If user's permission are explicitly set, they've already been returned above. 506 if(isset($final_group_perms)) 507 { 508 return $final_group_perms; 509 } 510 elseif(isset($perms_def)) 511 { 512 return $perms_def; 513 } 514 515 return array(); 516 } 517 } 518 519 /** 520 * Fetch the iconv/mb encoding for a particular MySQL encoding 521 * 522 * @param string $mysql_encoding The MySQL encoding 523 * @return string The iconv/mb encoding 524 */ 525 function fetch_iconv_encoding($mysql_encoding) 526 { 527 $mysql_encoding = explode("_", $mysql_encoding); 528 switch($mysql_encoding[0]) 529 { 530 case "utf8": 531 case "utf8mb3": 532 return "utf-8"; 533 break; 534 case "latin1": 535 return "iso-8859-1"; 536 break; 537 default: 538 return $mysql_encoding[0]; 539 } 540 } 541 542 /** 543 * Adds/Updates a Page/Tab to the permissions array in the adminoptions table 544 * 545 * @param string $tab The name of the tab that is being affected 546 * @param string $page The name of the page being affected (optional - if not specified, will affect everything under the specified tab) 547 * @param integer $default Default permissions for the page (1 for allowed - 0 for disallowed - -1 to remove) 548 */ 549 function change_admin_permission($tab, $page="", $default=1) 550 { 551 global $db; 552 553 $query = $db->simple_select("adminoptions", "uid, permissions", "permissions != ''"); 554 while($adminoption = $db->fetch_array($query)) 555 { 556 $adminoption['permissions'] = my_unserialize($adminoption['permissions']); 557 558 if($default == -1) 559 { 560 if(!empty($page)) 561 { 562 unset($adminoption['permissions'][$tab][$page]); 563 } 564 else 565 { 566 unset($adminoption['permissions'][$tab]); 567 } 568 } 569 else 570 { 571 if(!empty($page)) 572 { 573 if($adminoption['uid'] == 0) 574 { 575 $adminoption['permissions'][$tab][$page] = 0; 576 } 577 else 578 { 579 $adminoption['permissions'][$tab][$page] = $default; 580 } 581 } 582 else 583 { 584 if($adminoption['uid'] == 0) 585 { 586 $adminoption['permissions'][$tab]['tab'] = 0; 587 } 588 else 589 { 590 $adminoption['permissions'][$tab]['tab'] = $default; 591 } 592 } 593 } 594 595 $db->update_query("adminoptions", array('permissions' => $db->escape_string(my_serialize($adminoption['permissions']))), "uid='{$adminoption['uid']}'"); 596 } 597 } 598 599 /** 600 * Checks if we have had too many attempts at logging into the ACP 601 * 602 * @param integer $uid The uid of the admin to check 603 * @param boolean $return_num Return an array of the number of attempts and expiry time? (default false) 604 * @return mixed Return an array if the second parameter is true, boolean otherwise. 605 */ 606 function login_attempt_check_acp($uid=0, $return_num=false) 607 { 608 global $db, $mybb; 609 610 $attempts['loginattempts'] = 0; 611 612 if($uid > 0) 613 { 614 $query = $db->simple_select("adminoptions", "loginattempts, loginlockoutexpiry", "uid='".(int)$uid."'", 1); 615 $attempts = $db->fetch_array($query); 616 617 if(!$attempts) 618 { 619 return false; 620 } 621 } 622 623 if($attempts['loginattempts'] <= 0) 624 { 625 return false; 626 } 627 628 if($mybb->settings['maxloginattempts'] > 0 && $attempts['loginattempts'] >= $mybb->settings['maxloginattempts']) 629 { 630 // Has the expiry dateline been set yet? 631 if($attempts['loginlockoutexpiry'] == 0 && $return_num == false) 632 { 633 $db->update_query("adminoptions", array("loginlockoutexpiry" => TIME_NOW+((int)$mybb->settings['loginattemptstimeout']*60)), "uid='".(int)$uid."'"); 634 } 635 636 // Are we returning the # of login attempts? 637 if($return_num == true) 638 { 639 return $attempts; 640 } 641 // Otherwise are we still locked out? 642 else if($attempts['loginlockoutexpiry'] > TIME_NOW) 643 { 644 return true; 645 } 646 } 647 648 return false; 649 } 650 651 /** 652 * Checks whether the administrator is on a mobile device 653 * 654 * @param string $useragent The useragent to be checked 655 * @return boolean A true/false depending on if the administrator is on a mobile 656 */ 657 function is_mobile($useragent) 658 { 659 return preg_match("/(android|avantgo|blackberry|bolt|boost|cricket|docomo|fone|hiptop|mini|mobi|palm|phone|pie|tablet|up\.browser|up\.link|webos|wos)/i", $useragent); 660 } 661 662 /** 663 * Checks whether there are any 'security' issues in templates via complex syntax 664 * 665 * @param string $template The template to be scanned 666 * @return boolean A true/false depending on if an issue was detected 667 */ 668 function check_template($template) 669 { 670 // Check to see if our database password is in the template 671 if(preg_match('#\$config\[(([\'|"]database[\'|"])|([^\'"].*?))\]\[(([\'|"](database|hostname|password|table_prefix|username)[\'|"])|([^\'"].*?))\]#i', $template) !== 0) 672 { 673 return true; 674 } 675 676 // System calls via backtick 677 if(preg_match('#\$\s*\{#', $template) !== 0) 678 { 679 return true; 680 } 681 682 // Any other malicious acts? 683 // Courtesy of ZiNgA BuRgA 684 $allowed = preg_replace('~\\{\\$+[a-zA-Z_][a-zA-Z_0-9]*((?:-\\>|\\:\\:)\\$*[a-zA-Z_][a-zA-Z_0-9]*|\\[\s*\\$*([\'"]?)[a-zA-Z_ 0-9 ]+\\2\\]\s*)*\\}~', '', $template); 685 if($allowed === null || preg_match("~\\{\\$.+?\\}~s", $allowed) !== 0) 686 { 687 return true; 688 } 689 690 return false; 691 } 692 693 /** 694 * Provides a function to entirely delete a user's posts, and find the threads attached to them 695 * 696 * @param integer $uid The uid of the user 697 * @param int $date A UNIX timestamp to delete posts that are older 698 * @return array An array of threads to delete, threads/forums to recount 699 */ 700 function delete_user_posts($uid, $date) 701 { 702 global $db; 703 $uid = (int)$uid; 704 705 // Build an array of posts to delete 706 $postcache = array(); 707 $query = $db->simple_select("posts", "pid", "uid = '".$uid."' AND dateline < '".$date."'"); 708 while($post = $db->fetch_array($query)) 709 { 710 $postcache[] = $post['pid']; 711 } 712 713 if(!$db->num_rows($query)) 714 { 715 return false; 716 } 717 elseif(!empty($postcache)) 718 { 719 // Let's start deleting posts 720 $user_posts = implode(",", $postcache); 721 $query = $db->query(" 722 SELECT p.pid, p.visible, f.usepostcounts, t.tid AS thread, t.firstpost, t.fid AS forum 723 FROM ".TABLE_PREFIX."posts p 724 LEFT JOIN ".TABLE_PREFIX."forums f ON (f.fid=p.fid) 725 LEFT JOIN ".TABLE_PREFIX."threads t ON (t.tid=p.tid) 726 WHERE p.pid IN ({$user_posts}) 727 "); 728 729 $post_count = 0; // Collect the post number to deduct from the user's postcount 730 $thread_list = array(); 731 $forum_list = array(); 732 $delete_thread_list = array(); 733 if(!$db->num_rows($query)) 734 { 735 return false; 736 } 737 else 738 { 739 while($post = $db->fetch_array($query)) 740 { 741 if($post['usepostcounts'] != 0 && $post['visible'] == 1) 742 { 743 ++$post_count; 744 } 745 746 if($post['pid'] == $post['firstpost']) 747 { 748 $delete_thread_list[] = $post['thread']; 749 } 750 751 if(!in_array($post['thread'], $thread_list) && !in_array($post['thread'], $delete_thread_list)) 752 { 753 $thread_list[] = $post['thread']; // Threads that have been affected by this action, that aren't marked to be deleted 754 } 755 if(!in_array($post['forum'], $forum_list)) 756 { 757 $forum_list[] = $post['forum']; // Forums that have been affected, too 758 } 759 760 // Remove the attachments to this post, then delete the post 761 remove_attachments($post['pid']); 762 $db->delete_query("posts", "pid = '".$post['pid']."'"); 763 $db->delete_query("pollvotes", "pid = '".$post['pid']."'"); // Delete pollvotes attached to this post 764 } 765 766 $db->update_query("users", array("postnum" => "postnum-".$post_count.""), "uid='".$uid."'", 1, true); 767 768 $to_return = array( 769 'to_delete' => $delete_thread_list, 770 'thread_update' => $thread_list, 771 'forum_update' => $forum_list 772 ); 773 774 return $to_return; 775 } 776 } 777 } 778 779 /** 780 * Prints a selection JavaScript code for selectable groups/forums fields. 781 */ 782 function print_selection_javascript() 783 { 784 static $already_printed = false; 785 786 if($already_printed) 787 { 788 return; 789 } 790 791 $already_printed = true; 792 793 echo "<script type=\"text/javascript\"> 794 function checkAction(id) 795 { 796 var checked = ''; 797 798 $('.'+id+'_forums_groups_check').each(function(e, val) 799 { 800 if($(this).prop('checked') == true) 801 { 802 checked = $(this).val(); 803 } 804 }); 805 806 $('.'+id+'_forums_groups').each(function(e) 807 { 808 $(this).hide(); 809 }); 810 811 if($('#'+id+'_forums_groups_'+checked)) 812 { 813 $('#'+id+'_forums_groups_'+checked).show(); 814 } 815 } 816 </script>"; 817 } 818 819 if(!function_exists('array_column')) 820 { 821 function array_column($input, $column_key) 822 { 823 $values = array(); 824 825 if(!is_array($input)) 826 { 827 $input = array($input); 828 } 829 830 foreach($input as $val) 831 { 832 if(is_array($val) && isset($val[$column_key])) 833 { 834 $values[] = $val[$column_key]; 835 } 836 elseif(is_object($val) && isset($val->$column_key)) 837 { 838 $values[] = $val->$column_key; 839 } 840 } 841 842 return $values; 843 } 844 } 845 846 /** 847 * Output the auto redirect block. 848 * 849 * @param \Form $form An existing form instance to wrap the redirect within. 850 * @param string $prompt The prompt to show. 851 */ 852 function output_auto_redirect($form, $prompt) 853 { 854 global $lang; 855 856 echo <<<HTML 857 <div class="confirm_action"> 858 <p>{$prompt}</p> 859 <br /> 860 <script type="text/javascript"> 861 $(function() { 862 var button = $("#proceed_button"); 863 if (button.length > 0) { 864 // create a temporary div element to render the text within, un-escaping HTML entities 865 var textElement = $('<div/>').html('{$lang->automatically_redirecting}'); 866 867 button.val(textElement.text()); 868 button.attr("disabled", true); 869 button.css("color", "#aaa"); 870 button.css("borderColor", "#aaa"); 871 872 var parent_form = button.closest('form'); 873 874 if (parent_form.length > 0) { 875 parent_form.submit(); 876 } 877 } 878 }); 879 </script> 880 <p class="buttons"> 881 {$form->generate_submit_button($lang->proceed, array('class' => 'button_yes', 'id' => 'proceed_button'))} 882 </p> 883 </div> 884 HTML; 885 }
title
Description
Body
title
Description
Body
title
Description
Body
title
Body
2005 - 2021 © MyBB.de | Alle Rechte vorbehalten! | Sponsor: netcup | Cross-referenced by PHPXref |