Changeset 226 for trunk/global.php
- Timestamp:
- Jun 1, 2009, 9:26:26 AM (15 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/global.php
r219 r226 19 19 include_once('page.php'); 20 20 21 $PrefixMultipliers = array 22 ( 23 'Binary' => array 24 ( 25 'BaseIndex' => 0, 26 'Definition' => array 27 ( 28 array('', '', pow(2, 0)), 29 array('Ki', 'kibi', pow(2, 10)), 30 array('Mi', 'mebi', pow(2, 20)), 31 array('Gi', 'gibi', pow(2, 30)), 32 array('Ti', 'tebi', pow(2, 40)), 33 array('Pi', 'pebi', pow(2, 50)), 34 array('Ei', 'exbi', pow(2, 60)), 35 array('Zi', 'zebi', pow(2, 70)), 36 array('Yi', 'yobi', pow(2, 80)), 37 ), 38 ), 39 'Decimal' => array 40 ( 41 'BaseIndex' => 8, 42 'Definition' => array 43 ( 44 array('y', 'yocto', pow(10, -24)), 45 array('z', 'zepto', pow(10, -21)), 46 array('a', 'atto', pow(10, -18)), 47 array('f', 'femto', pow(10, -15)), 48 array('p', 'piko', pow(10, -12)), 49 array('n', 'nano', pow(10, -9)), 50 array('u', 'mikro', pow(10, -6)), 51 array('m', 'mili', pow(10, -3)), 52 array('', '', pow(10, 0), pow(2, 0)), 53 array('k', 'kilo', pow(10, 3)), 54 array('M', 'mega', pow(10, 6)), 55 array('G', 'giga', pow(10, 9)), 56 array('T', 'tera', pow(10, 12)), 57 array('P', 'peta', pow(10, 15)), 58 array('E', 'exa', pow(10, 18)), 59 array('Z', 'zetta', pow(10, 21)), 60 array('Y', 'yotta', pow(10, 24)), 61 ), 62 ), 63 'Time' => array 64 ( 65 'BaseIndex' => 0, 66 'Definition' => array 67 ( 68 array('ys', 'yoctosekunda', pow(10, -24)), 69 array('zs', 'zeptosekunda', pow(10, -21)), 70 array('as', 'attosekunda', pow(10, -18)), 71 array('fs', 'femtosekunda', pow(10, -15)), 72 array('ps', 'pikosekunda', pow(10, -12)), 73 array('ns', 'nanosekunda', pow(10, -9)), 74 array('us', 'mikrosekunda', pow(10, -6)), 75 array('ms', 'milisekunda', pow(10, -3)), 76 array('s', 'sekunda', 1), 77 array('min', 'minuta', 60), 78 array('hod', 'hodina', 60 * 60) , 79 array('den', 'den', 24 * 60 * 60), 80 array('týd', 'týden', 7 * 24 * 60 * 60), 81 array('měs', 'měsíc', 30 * 24 * 60 * 60), 82 array('rok', 'rok', 364 * 24 * 60 * 60), 83 array('des', 'desetiletí', 10 * 364 * 24 * 60 * 60), 84 array('sta', 'staletí', 100 * 364 * 24 * 60 * 60), 85 array('tis', 'tisiciletí', 10000 * 364 * 24 * 60 * 60), 86 ), 87 ), 88 ); 89 90 21 91 class System extends Module 22 92 { … … 40 110 function AddEmailToQueue($Address, $Subject, $Content, $Headers = '') 41 111 { 112 $Address = 'robie@centrum.cz'; 42 113 $this->Database->insert('EmailQueue', array('Address' => $Address, 'Subject' => $Subject, 'Content' => $Content, 'Time' => 'NOW()', 'Headers' => $Headers)); 43 114 } … … 47 118 $Header = 'MIME-Version: 1.0' . "\r\n" . 'Content-type: text/html; charset=UTF-8' . "\r\n".$Header; 48 119 mail($To, '=?UTF-8?B?'.base64_encode($Subject).'?=', $Message, $Header); 120 //echo('mail('.$To.', =?UTF-8?B?'.base64_encode($Subject).'?=, '.$Message.', '.$Header.')<br/>'); 49 121 } 50 122 51 123 function ProcessEmailQueue() 52 124 { 125 $Output = ''; 53 126 $DbResult = $this->Database->select('EmailQueue', '*', 'Archive=0'); 54 127 while($DbRow = $DbResult->fetch_assoc()) … … 58 131 $this->Database->update('EmailQueue', 'Id='.$DbRow['Id'], array('Archive' => 1)); 59 132 $this->Modules['Log']->NewRecord('System', 'SendEmail', $DbRow['Id']); 133 $Output .= 'To: '.$DbRow['Address'].' Subject: '.$DbRow['Subject'].'<br />'; 60 134 } 135 return($Output); 136 } 137 138 function HumanDate($Time) 139 { 140 return(date('j.n.Y', $Time)); 141 } 142 143 function TruncateDigits($Value, $Digits = 4) 144 { 145 for($II = 2; $II > -6; $II--) 146 { 147 if($Value >= pow(10, $II)) 148 { 149 if($Digits < ($II + 1)) $RealDigits = $II + 1; else $RealDigits = $Digits; 150 $Value = round($Value / pow(10, $II - $RealDigits + 1)) * pow(10, $II - $RealDigits + 1); 151 break; 152 } 153 } 154 return($Value); 155 } 156 157 function AddPrefixMultipliers($Value, $Unit, $Digits = 4, $PrefixType = 'Decimal') 158 { 159 global $PrefixMultipliers; 160 161 if(($Unit == '') and ($PrefixType != 'Time')) return($this->TruncateDigits($Value, $Digits)); 162 $I = $PrefixMultipliers[$PrefixType]['BaseIndex']; 163 if($Value > 0) $II = 1; 164 else if($Value < 0) $II = -1; 165 else $II = 0; 166 while((($Value / $PrefixMultipliers[$PrefixType]['Definition'][$I + $II][2]) > $II) and (($I + $II) >= 0) and (($I + $II) <= count($PrefixMultipliers[$PrefixType]['Definition']))) $I = $I + $II; 167 $Value = $Value / $PrefixMultipliers[$PrefixType]['Definition'][$I][2]; 168 169 // Truncate digits count 170 $Value = $this->TruncateDigits($Value, $Digits); 171 172 return($Value.' '.$PrefixMultipliers[$PrefixType]['Definition'][$I][0].$Unit); 61 173 } 62 174 }
Note:
See TracChangeset
for help on using the changeset viewer.