Changeset 1159
- Timestamp:
- 01/03/07 17:49:26 (6 years ago)
- Location:
- trunk/wifidog-auth
- Files:
-
- 10 modified
-
CHANGELOG (modified) (1 diff)
-
wifidog/classes/Content/ContentGroup/ContentGroup.php (modified) (1 diff)
-
wifidog/classes/Content/RssAggregator/RssAggregator.php (modified) (1 diff)
-
wifidog/classes/Content/SmartyTemplate/SmartyTemplate.php (modified) (3 diffs)
-
wifidog/classes/Node.php (modified) (1 diff)
-
wifidog/classes/SmartyWifidog.php (modified) (6 diffs)
-
wifidog/classes/Utils.php (modified) (3 diffs)
-
wifidog/templates/sites/hotspot_status.tpl (modified) (1 diff)
-
wifidog/templates/sites/index.tpl (modified) (1 diff)
-
wifidog/templates/sites/portal.tpl (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
trunk/wifidog-auth/CHANGELOG
r1158 r1159 1 2007-01-03 Benoit Grégoire <bock@step.polymtl.ca> 2 * Yet more Smarty cleanup, add some docs, add Smarty variables to access the physical node a user is connected to. 3 * RssAggregator.php: Fix bug in setMaxItemAge() method when setting a null value 4 1 5 2007-01-02 François Proulx <francois.proulx@gmail.com> 2 6 * Updated the SQL schema initial schema -
trunk/wifidog-auth/wifidog/classes/Content/ContentGroup/ContentGroup.php
r1147 r1159 652 652 } 653 653 } else { 654 $html .= '<p class="warningmsg">' . _("Sorry, no elements available at this hotspot or all elements of the content group have already been shown") . "</p>\n";654 $html .= '<p class="warningmsg">' . _("Sorry, this content-group is empty") . "</p>\n"; 655 655 } 656 656 } -
trunk/wifidog-auth/wifidog/classes/Content/RssAggregator/RssAggregator.php
r1131 r1159 405 405 $max_item_age = 'NULL'; 406 406 } 407 else { 408 $max_item_age = '$max_item_age seconds'; 409 } 407 410 408 411 $max_item_age = $db->escapeString($max_item_age); 409 $db->execSqlUpdate("UPDATE content_rss_aggregator SET max_item_age = '$max_item_age seconds'WHERE content_id = '$this->id'", false);412 $db->execSqlUpdate("UPDATE content_rss_aggregator SET max_item_age = $max_item_age WHERE content_id = '$this->id'", false); 410 413 $this->refresh(); 411 414 -
trunk/wifidog-auth/wifidog/classes/Content/SmartyTemplate/SmartyTemplate.php
r1156 r1159 61 61 protected function __construct($content_id) 62 62 { 63 parent::__construct($content_id);63 parent::__construct($content_id); 64 64 } 65 65 /** When a content object is set as Simple, it means that is is used merely to contain it's own data. No title, description or other metadata will be set or displayed, during display or administration 66 66 * @return true or false */ 67 67 public function isSimpleContent() { 68 return false;68 return false; 69 69 } 70 71 /** 70 /** 71 * Retreives the admin interface of this object. Anything that overrides 72 * this method should call the parent method with it's output at the END of 73 * processing. 74 * @param string $subclass_admin_interface HTML content of the interface 75 * element of a children. 76 * @param string $type_interface SIMPLE pour éditer un seul champ, COMPLETE 77 * pour voir toutes les chaînes, LARGE pour 78 * avoir un textarea. 79 * @return string The HTML fragment for this interface. 80 */ 81 public function getAdminUI($subclass_admin_interface = null, $title = null, $type_interface = "LARGE") { 82 // Init values. 83 $html = ''; 84 $html .= $subclass_admin_interface; 85 $html .= "<div class='admin_section_hint'>" . sprintf(_("To list the available Smarty variables, put %s in the input field, save and then click preview"), "{debug output='html'}") . "</div>"; 86 $html .= "<div class='admin_section_hint'>" . sprintf(_("Therre are also a few custom Smarty modifiers available: %s"), "urlencode, remove_accents, fsize_format") . "</div>"; 87 return parent :: getAdminUI($html, $title, $type_interface); 88 } 89 /** 72 90 * Retreives the user interface of this object. 73 91 * … … 80 98 * @return string The HTML fragment for this interface 81 99 */ 82 public function getUserUI($subclass_user_interface = null) { 83 // Init values 84 $html = ''; 85 $smarty = SmartyWifidog::getObject(); 86 87 $html .= $smarty->fetch('string:'.$this->getString()); 100 public function getUserUI($subclass_user_interface = null) { 101 // Init values 102 $html = ''; 103 $smarty = SmartyWifidog::getObject(); 88 104 89 $html .= $subclass_user_interface; 90 /* Handle hyperlink clicktrough logging */ 91 $html = $this->replaceHyperLinks($html); 92 return Content :: getUserUI($html); 93 } 105 $html .= $smarty->fetch('string:'.$this->getString()); 106 107 $html .= $subclass_user_interface; 108 /* Handle hyperlink clicktrough logging */ 109 $html = $this->replaceHyperLinks($html); 110 return Content :: getUserUI($html); 111 } 94 112 95 113 /** … … 105 123 private function refresh() 106 124 { 107 $this->__construct($this->id);125 $this->__construct($this->id); 108 126 } 109 127 -
trunk/wifidog-auth/wifidog/classes/Node.php
r1157 r1159 1573 1573 $smarty->assign('nodeName', $node ? $node->getName() : ''); 1574 1574 $smarty->assign('nodeLastHeartbeatIP', $node ? $node->getLastHeartbeatIP() : ''); 1575 1576 $node = self::getCurrentRealNode(); 1577 // Set node details 1578 $smarty->assign('realNodeId', $node ? $node->getId() : ''); 1579 $smarty->assign('realNodeName', $node ? $node->getName() : ''); 1580 1581 1575 1582 } 1576 1583 } -
trunk/wifidog-auth/wifidog/classes/SmartyWifidog.php
r1157 r1159 46 46 */ 47 47 require_once("classes/Locale.php"); 48 require_once("classes/Utils.php"); 48 49 require_once("include/smarty.resource.string.php"); 49 50 … … 59 60 60 61 /* 61 * Smarty plugin62 * -------------------------------------------------------------63 * Type: modifier64 * Name: fsize_format65 * Version: 0.266 * Date: 2003-05-1567 * Author: Joscha Feth, joscha@feth.com68 * Purpose: formats a filesize (in bytes) to human-readable format69 * Usage: In the template, use70 {$filesize|fsize_format} => 123.45 B|KB|MB|GB|TB71 or72 {$filesize|fsize_format:"MB"} => 123.45 MB73 or74 {$filesize|fsize_format:"TB":4} => 0.0012 TB75 * Params:76 int size the filesize in bytes77 string format the format, the output shall be: B, KB, MB, GB or TB78 int precision the rounding precision79 string dec_point the decimal separator80 string thousands_sep the thousands separator81 * Install: Drop into the plugin directory82 * Version:83 * 2003-05-15 Version 0.2 - added dec_point and thousands_sep thanks to Thomas Brandl, tbrandl@barff.de84 * - made format always uppercase85 * - count sizes "on-the-fly"86 * 2003-02-21 Version 0.1 - initial release87 * -------------------------------------------------------------88 */62 * Smarty plugin 63 * ------------------------------------------------------------- 64 * Type: modifier 65 * Name: fsize_format 66 * Version: 0.2 67 * Date: 2003-05-15 68 * Author: Joscha Feth, joscha@feth.com 69 * Purpose: formats a filesize (in bytes) to human-readable format 70 * Usage: In the template, use 71 {$filesize|fsize_format} => 123.45 B|KB|MB|GB|TB 72 or 73 {$filesize|fsize_format:"MB"} => 123.45 MB 74 or 75 {$filesize|fsize_format:"TB":4} => 0.0012 TB 76 * Params: 77 int size the filesize in bytes 78 string format the format, the output shall be: B, KB, MB, GB or TB 79 int precision the rounding precision 80 string dec_point the decimal separator 81 string thousands_sep the thousands separator 82 * Install: Drop into the plugin directory 83 * Version: 84 * 2003-05-15 Version 0.2 - added dec_point and thousands_sep thanks to Thomas Brandl, tbrandl@barff.de 85 * - made format always uppercase 86 * - count sizes "on-the-fly" 87 * 2003-02-21 Version 0.1 - initial release 88 * ------------------------------------------------------------- 89 */ 89 90 function smarty_modifier_fsize_format($size,$format = '',$precision = 2, $dec_point = ".", $thousands_sep = ",") 90 91 { … … 125 126 class SmartyWifidog extends Smarty { 126 127 public static function getObject() { 127 return new self();128 return new self(); 128 129 } 129 private function __construct()130 {130 private function __construct() 131 { 131 132 132 133 // Class Constructor. These automatically get set with each new instance. 133 134 134 135 $this->Smarty(); 135 //Now that we have user-definable templates, we must turn on security136 $this->security = true;137 //pretty_print_r($this->security_settings);138 $this->security_settings['MODIFIER_FUNCS'][] = 'sprintf';139 $this->template_dir = WIFIDOG_ABS_FILE_PATH;136 //Now that we have user-definable templates, we must turn on security 137 $this->security = true; 138 //pretty_print_r($this->security_settings); 139 $this->security_settings['MODIFIER_FUNCS'][] = 'sprintf'; 140 $this->template_dir = WIFIDOG_ABS_FILE_PATH; 140 141 $this->compile_dir = $this->template_dir . 'tmp/smarty/templates_c/'; 141 142 $this->config_dir = $this->template_dir . 'tmp/smarty/configs/'; … … 146 147 */ 147 148 $this->register_modifier("_","_"); 149 $this->register_modifier("urlencode","urlencode"); 150 $this->register_modifier("remove_accents",array('Utils', "remove_accents")); 148 151 $this->register_modifier("fsize_format", "smarty_modifier_fsize_format"); 149 152 … … 156 159 //$this->compile_check = true; 157 160 158 /* Common content */161 /* Common content */ 159 162 $network = Network::GetCurrentNetwork(); 160 163 161 /* Useful stuff from config.php */164 /* Useful stuff from config.php */ 162 165 163 166 $this->assign('base_url_path', BASE_URL_PATH); … … 167 170 168 171 /* Other useful stuff */ 169 $this->assign('userIsAtHotspot', Node :: getCurrentRealNode() != null ? true : false); 170 Network::assignSmartyValues($this); 171 Node::assignSmartyValues($this); 172 User::assignSmartyValues($this); 172 Network::assignSmartyValues($this); 173 Node::assignSmartyValues($this); 174 User::assignSmartyValues($this); 173 175 } 174 176 -
trunk/wifidog-auth/wifidog/classes/Utils.php
r1155 r1159 54 54 * Converts the bytes integer value in human-readable format 55 55 */ 56 public static function convertBytesToWords($bytes)57 {58 if ($bytes > 1024 * 1024 * 1024)59 return round($bytes / (1024 * 1024 * 1024), 1)."G";60 if ($bytes > 1024 * 1024)61 return round($bytes / (1024 * 1024), 1)."M";62 if ($bytes > 1024)63 return round($bytes / (1024), 1)."K";64 }56 public static function convertBytesToWords($bytes) 57 { 58 if ($bytes > 1024 * 1024 * 1024) 59 return round($bytes / (1024 * 1024 * 1024), 1)."G"; 60 if ($bytes > 1024 * 1024) 61 return round($bytes / (1024 * 1024), 1)."M"; 62 if ($bytes > 1024) 63 return round($bytes / (1024), 1)."K"; 64 } 65 65 66 66 /** 67 67 * Converts seconds integer value in human-readable format 68 68 */ 69 public static function convertSecondsToWords($seconds)70 {71 $r = '';72 if ($seconds > 60 * 60 * 24 * 365.25)73 {74 $amount = floor($seconds / (60 * 60 * 24 * 365.25));75 if ($amount != 0)76 $r .= " {$amount}y";77 $seconds -= ($amount * 60 * 60 * 24 * 365.25);78 }79 if ($seconds > 60 * 60 * 24)80 {81 $amount = floor($seconds / (60 * 60 * 24));82 if ($amount != 0)83 $r .= " {$amount}d";84 $seconds -= ($amount * 60 * 60 * 24);85 }86 if ($seconds > 60 * 60)87 {88 $amount = floor($seconds / (60 * 60));89 if ($amount != 0)90 $r .= " {$amount}h";91 $seconds -= ($amount * 60 * 60);92 }93 if ($seconds > 60)94 {95 $amount = floor($seconds / 60);96 if ($amount != 0)97 $r .= " {$amount}m";98 $seconds -= ($amount * 60);99 }100 if ($seconds != 0)101 {102 $r .= " {$seconds}s";103 }104 trim($r);105 return $r;106 }69 public static function convertSecondsToWords($seconds) 70 { 71 $r = ''; 72 if ($seconds > 60 * 60 * 24 * 365.25) 73 { 74 $amount = floor($seconds / (60 * 60 * 24 * 365.25)); 75 if ($amount != 0) 76 $r .= " {$amount}y"; 77 $seconds -= ($amount * 60 * 60 * 24 * 365.25); 78 } 79 if ($seconds > 60 * 60 * 24) 80 { 81 $amount = floor($seconds / (60 * 60 * 24)); 82 if ($amount != 0) 83 $r .= " {$amount}d"; 84 $seconds -= ($amount * 60 * 60 * 24); 85 } 86 if ($seconds > 60 * 60) 87 { 88 $amount = floor($seconds / (60 * 60)); 89 if ($amount != 0) 90 $r .= " {$amount}h"; 91 $seconds -= ($amount * 60 * 60); 92 } 93 if ($seconds > 60) 94 { 95 $amount = floor($seconds / 60); 96 if ($amount != 0) 97 $r .= " {$amount}m"; 98 $seconds -= ($amount * 60); 99 } 100 if ($seconds != 0) 101 { 102 $r .= " {$seconds}s"; 103 } 104 trim($r); 105 return $r; 106 } 107 107 108 108 /** … … 123 123 natcasesort($arrTemp); 124 124 foreach ($arrTemp as $key => $value) 125 $arrOut[] = $arrIn[$key];125 $arrOut[] = $arrIn[$key]; 126 126 $arrIn = $arrOut; 127 127 } … … 129 129 /** Use PHP internal functions to execute a command 130 130 @return: Return value of the command*/ 131 public static function execCommand($command, & $output, $debug = false) {132 if($debug)133 print "$command";134 $retval = null;135 exec($command.' 2>&1', $output, $retval);136 if($debug){137 if ($retval != 0)131 public static function execCommand($command, & $output, $debug = false) { 132 if($debug) 133 print "$command"; 134 $retval = null; 135 exec($command.' 2>&1', $output, $retval); 136 if($debug){ 137 if ($retval != 0) 138 138 print "<p style='color:red'><em>Error:</em> Command did not complete successfully (returned $retval): <br/>\n"; 139 139 else 140 140 print "<p style='color:green'>Command completed successfully (returned $retval): <br/>\n"; 141 } 142 if ($debug && $output) { 143 foreach ($output as $output_line) 144 print " $output_line <br/>\n"; 145 } 146 if($debug) 147 print "</p>\n"; 148 return $retval; 149 } 141 } 142 if ($debug && $output) { 143 foreach ($output as $output_line) 144 print " $output_line <br/>\n"; 145 } 146 if($debug) 147 print "</p>\n"; 148 return $retval; 149 } 150 151 /** Lifted from WordPress source code. Removes accented characters */ 152 public static function remove_accents($string) { 153 if ( !preg_match('/[\x80-\xff]/', $string) ) 154 return $string; 155 156 $chars = array( 157 // Decompositions for Latin-1 Supplement 158 chr(195).chr(128) => 'A', chr(195).chr(129) => 'A', 159 chr(195).chr(130) => 'A', chr(195).chr(131) => 'A', 160 chr(195).chr(132) => 'A', chr(195).chr(133) => 'A', 161 chr(195).chr(135) => 'C', chr(195).chr(136) => 'E', 162 chr(195).chr(137) => 'E', chr(195).chr(138) => 'E', 163 chr(195).chr(139) => 'E', chr(195).chr(140) => 'I', 164 chr(195).chr(141) => 'I', chr(195).chr(142) => 'I', 165 chr(195).chr(143) => 'I', chr(195).chr(145) => 'N', 166 chr(195).chr(146) => 'O', chr(195).chr(147) => 'O', 167 chr(195).chr(148) => 'O', chr(195).chr(149) => 'O', 168 chr(195).chr(150) => 'O', chr(195).chr(153) => 'U', 169 chr(195).chr(154) => 'U', chr(195).chr(155) => 'U', 170 chr(195).chr(156) => 'U', chr(195).chr(157) => 'Y', 171 chr(195).chr(159) => 's', chr(195).chr(160) => 'a', 172 chr(195).chr(161) => 'a', chr(195).chr(162) => 'a', 173 chr(195).chr(163) => 'a', chr(195).chr(164) => 'a', 174 chr(195).chr(165) => 'a', chr(195).chr(167) => 'c', 175 chr(195).chr(168) => 'e', chr(195).chr(169) => 'e', 176 chr(195).chr(170) => 'e', chr(195).chr(171) => 'e', 177 chr(195).chr(172) => 'i', chr(195).chr(173) => 'i', 178 chr(195).chr(174) => 'i', chr(195).chr(175) => 'i', 179 chr(195).chr(177) => 'n', chr(195).chr(178) => 'o', 180 chr(195).chr(179) => 'o', chr(195).chr(180) => 'o', 181 chr(195).chr(181) => 'o', chr(195).chr(182) => 'o', 182 chr(195).chr(182) => 'o', chr(195).chr(185) => 'u', 183 chr(195).chr(186) => 'u', chr(195).chr(187) => 'u', 184 chr(195).chr(188) => 'u', chr(195).chr(189) => 'y', 185 chr(195).chr(191) => 'y', 186 // Decompositions for Latin Extended-A 187 chr(196).chr(128) => 'A', chr(196).chr(129) => 'a', 188 chr(196).chr(130) => 'A', chr(196).chr(131) => 'a', 189 chr(196).chr(132) => 'A', chr(196).chr(133) => 'a', 190 chr(196).chr(134) => 'C', chr(196).chr(135) => 'c', 191 chr(196).chr(136) => 'C', chr(196).chr(137) => 'c', 192 chr(196).chr(138) => 'C', chr(196).chr(139) => 'c', 193 chr(196).chr(140) => 'C', chr(196).chr(141) => 'c', 194 chr(196).chr(142) => 'D', chr(196).chr(143) => 'd', 195 chr(196).chr(144) => 'D', chr(196).chr(145) => 'd', 196 chr(196).chr(146) => 'E', chr(196).chr(147) => 'e', 197 chr(196).chr(148) => 'E', chr(196).chr(149) => 'e', 198 chr(196).chr(150) => 'E', chr(196).chr(151) => 'e', 199 chr(196).chr(152) => 'E', chr(196).chr(153) => 'e', 200 chr(196).chr(154) => 'E', chr(196).chr(155) => 'e', 201 chr(196).chr(156) => 'G', chr(196).chr(157) => 'g', 202 chr(196).chr(158) => 'G', chr(196).chr(159) => 'g', 203 chr(196).chr(160) => 'G', chr(196).chr(161) => 'g', 204 chr(196).chr(162) => 'G', chr(196).chr(163) => 'g', 205 chr(196).chr(164) => 'H', chr(196).chr(165) => 'h', 206 chr(196).chr(166) => 'H', chr(196).chr(167) => 'h', 207 chr(196).chr(168) => 'I', chr(196).chr(169) => 'i', 208 chr(196).chr(170) => 'I', chr(196).chr(171) => 'i', 209 chr(196).chr(172) => 'I', chr(196).chr(173) => 'i', 210 chr(196).chr(174) => 'I', chr(196).chr(175) => 'i', 211 chr(196).chr(176) => 'I', chr(196).chr(177) => 'i', 212 chr(196).chr(178) => 'IJ',chr(196).chr(179) => 'ij', 213 chr(196).chr(180) => 'J', chr(196).chr(181) => 'j', 214 chr(196).chr(182) => 'K', chr(196).chr(183) => 'k', 215 chr(196).chr(184) => 'k', chr(196).chr(185) => 'L', 216 chr(196).chr(186) => 'l', chr(196).chr(187) => 'L', 217 chr(196).chr(188) => 'l', chr(196).chr(189) => 'L', 218 chr(196).chr(190) => 'l', chr(196).chr(191) => 'L', 219 chr(197).chr(128) => 'l', chr(197).chr(129) => 'L', 220 chr(197).chr(130) => 'l', chr(197).chr(131) => 'N', 221 chr(197).chr(132) => 'n', chr(197).chr(133) => 'N', 222 chr(197).chr(134) => 'n', chr(197).chr(135) => 'N', 223 chr(197).chr(136) => 'n', chr(197).chr(137) => 'N', 224 chr(197).chr(138) => 'n', chr(197).chr(139) => 'N', 225 chr(197).chr(140) => 'O', chr(197).chr(141) => 'o', 226 chr(197).chr(142) => 'O', chr(197).chr(143) => 'o', 227 chr(197).chr(144) => 'O', chr(197).chr(145) => 'o', 228 chr(197).chr(146) => 'OE',chr(197).chr(147) => 'oe', 229 chr(197).chr(148) => 'R',chr(197).chr(149) => 'r', 230 chr(197).chr(150) => 'R',chr(197).chr(151) => 'r', 231 chr(197).chr(152) => 'R',chr(197).chr(153) => 'r', 232 chr(197).chr(154) => 'S',chr(197).chr(155) => 's', 233 chr(197).chr(156) => 'S',chr(197).chr(157) => 's', 234 chr(197).chr(158) => 'S',chr(197).chr(159) => 's', 235 chr(197).chr(160) => 'S', chr(197).chr(161) => 's', 236 chr(197).chr(162) => 'T', chr(197).chr(163) => 't', 237 chr(197).chr(164) => 'T', chr(197).chr(165) => 't', 238 chr(197).chr(166) => 'T', chr(197).chr(167) => 't', 239 chr(197).chr(168) => 'U', chr(197).chr(169) => 'u', 240 chr(197).chr(170) => 'U', chr(197).chr(171) => 'u', 241 chr(197).chr(172) => 'U', chr(197).chr(173) => 'u', 242 chr(197).chr(174) => 'U', chr(197).chr(175) => 'u', 243 chr(197).chr(176) => 'U', chr(197).chr(177) => 'u', 244 chr(197).chr(178) => 'U', chr(197).chr(179) => 'u', 245 chr(197).chr(180) => 'W', chr(197).chr(181) => 'w', 246 chr(197).chr(182) => 'Y', chr(197).chr(183) => 'y', 247 chr(197).chr(184) => 'Y', chr(197).chr(185) => 'Z', 248 chr(197).chr(186) => 'z', chr(197).chr(187) => 'Z', 249 chr(197).chr(188) => 'z', chr(197).chr(189) => 'Z', 250 chr(197).chr(190) => 'z', chr(197).chr(191) => 's', 251 // Euro Sign 252 chr(226).chr(130).chr(172) => 'E', 253 // GBP (Pound) Sign 254 chr(194).chr(163) => ''); 255 256 $string = strtr($string, $chars); 257 258 return $string; 259 } 260 150 261 }//End class 151 262 /* -
trunk/wifidog-auth/wifidog/templates/sites/hotspot_status.tpl
r1157 r1159 53 53 <div id="login_form"> 54 54 <ul> 55 {if $GMapsEnabled && !$ userIsAtHotspot}55 {if $GMapsEnabled && !$realNodeId} 56 56 <li><a href="{$base_non_ssl_path}hotspots_map.php">{"Deployed HotSpots map"|_}</a></li> 57 57 {/if} -
trunk/wifidog-auth/wifidog/templates/sites/index.tpl
r1157 r1159 104 104 105 105 <ul> 106 {if $googleMapsEnabled} {* This needs to be imporved before being deployed {if $googleMapsEnabled && !$ userIsAtHotspot}*}106 {if $googleMapsEnabled} {* This needs to be imporved before being deployed {if $googleMapsEnabled && !$realNodeId}*} 107 107 <li><a href="{$base_non_ssl_path}hotspots_map.php">{"Deployed HotSpots map"|_}</a></li> 108 108 {/if} -
trunk/wifidog-auth/wifidog/templates/sites/portal.tpl
r1156 r1159 68 68 </p> 69 69 70 {if $ userIsAtHotspot}70 {if $realNodeId} 71 71 <p class="indent"> 72 72 <a id="wifidog_use_internet" href="{$url}">{"Use the Internet"|_}</a>
