[ Index ] |
PHP Cross Reference of MyBB 1.8.38 |
[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 * @param resource|PDOStatement|mysqli_result $query The query to be run. Needs to select the "action" column of the "warninglevels" table 13 * @param array $max_expiration_times Return variable. The maximum expiration time 14 * @param array $check_levels Return variable. Whether those "levels" were checked 15 */ 16 function find_warnlevels_to_check($query, &$max_expiration_times, &$check_levels) 17 { 18 global $db; 19 20 // we have some warning levels we need to revoke 21 $max_expiration_times = array( 22 1 => -1, // Ban 23 2 => -1, // Revoke posting 24 3 => -1 // Moderate posting 25 ); 26 $check_levels = array( 27 1 => false, // Ban 28 2 => false, // Revoke posting 29 3 => false // Moderate posting 30 ); 31 while($warn_level = $db->fetch_array($query)) 32 { 33 // revoke actions taken at this warning level 34 $action = my_unserialize($warn_level['action']); 35 if($action['type'] < 1 || $action['type'] > 3) // prevent any freak-ish cases 36 { 37 continue; 38 } 39 40 $check_levels[$action['type']] = true; 41 42 $max_exp_time = &$max_expiration_times[$action['type']]; 43 if($action['length'] && $max_exp_time != 0) 44 { 45 $expiration = $action['length']; 46 if($expiration > $max_exp_time) 47 { 48 $max_exp_time = $expiration; 49 } 50 } 51 else 52 { 53 $max_exp_time = 0; 54 } 55 } 56 } 57 58 /** 59 * Returns a friendly expiration time of a suspension/warning 60 * 61 * @param int $time The time period of the suspension/warning 62 * @return array An array of the time/period remaining 63 */ 64 function fetch_friendly_expiration($time) 65 { 66 if($time == 0 || $time == -1) 67 { 68 return array("period" => "never"); 69 } 70 else if($time % 2592000 == 0) 71 { 72 return array("time" => $time/2592000, "period" => "months"); 73 } 74 else if($time % 604800 == 0) 75 { 76 return array("time" => $time/604800, "period" => "weeks"); 77 } 78 else if($time % 86400 == 0) 79 { 80 return array("time" => $time/86400, "period" => "days"); 81 } 82 else 83 { 84 return array("time" => ceil($time/3600), "period" => "hours"); 85 } 86 } 87 88 /** 89 * Figures out the length of a suspension/warning 90 * 91 * @param int $time The amount of time to calculate the length of suspension/warning 92 * @param string $period The period of time to calculate the length of suspension/warning 93 * @return int Length of the suspension/warning (in seconds) 94 */ 95 function fetch_time_length($time, $period) 96 { 97 $time = (int)$time; 98 99 if($period == "hours") 100 { 101 $time = $time*3600; 102 } 103 else if($period == "days") 104 { 105 $time = $time*86400; 106 } 107 else if($period == "weeks") 108 { 109 $time = $time*604800; 110 } 111 else if($period == "months") 112 { 113 $time = $time*2592000; 114 } 115 else if($period == "never" && $time == 0) 116 { 117 // User is permanentely banned 118 $time = "-1"; 119 } 120 else 121 { 122 $time = 0; 123 } 124 return $time; 125 }
title
Description
Body
title
Description
Body
title
Description
Body
title
Body
2005 - 2021 © MyBB.de | Alle Rechte vorbehalten! | Sponsor: netcup | Cross-referenced by PHPXref |