Changeset 554
- Timestamp:
- 04/19/05 17:04:33 (8 years ago)
- Location:
- trunk/wifidog-auth
- Files:
-
- 1 added
- 7 modified
-
ChangeLog (modified) (1 diff)
-
wifidog/admin/generic_object_admin.php (modified) (3 diffs)
-
wifidog/classes/Content/HotspotRss.php (added)
-
wifidog/classes/Network.php (modified) (1 diff)
-
wifidog/classes/Node.php (modified) (7 diffs)
-
wifidog/config.php (modified) (2 diffs)
-
wifidog/local_content/default/stylesheet.css (modified) (1 diff)
-
wifidog/portal/index.php (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/wifidog-auth/ChangeLog
r553 r554 1 2005-04-19 Benoit Grégoire <bock@step.polymtl.ca> 2 * Working (beta...) content manager and portal. 3 * Add content preview mode 4 1 5 2005-04-18 Benoit Grégoire <bock@step.polymtl.ca> 2 6 * Hotspot and network content association, continue access control work. -
trunk/wifidog-auth/wifidog/admin/generic_object_admin.php
r553 r554 23 23 /**@file generic_object_admin.php 24 24 * A simple interface to edit any object that implements the GenericObject interface. The php file takes the following params: 25 * $_REQUEST['action']: new, edit, delete (also save, but not meant for calling from outside this file)25 * $_REQUEST['action']: new, edit, delete, preview (also save, but not meant for calling from outside this file) 26 26 * $_REQUEST['object_id']: The id of the object ot be edited 27 27 * $_REQUEST['object_class']: The class name of the object ot be edited 28 * $_REQUEST['node_id']: In preview mode, the current node to simulate display 28 29 * $_REQUEST['debug']: If present and non empty, the $_REQUEST variables will be displayed 29 30 * @author Copyright (C) 2005 Benoit Grégoire <bock@step.polymtl.ca>, … … 106 107 $html .= '</form>'; 107 108 109 $html .= "<form action='".GENERIC_OBJECT_ADMIN_ABS_HREF."' method='post'>"; 110 $html .= $common_input; 111 $html .= "<input type='hidden' name='action' value='preview'>\n"; 112 $html .= "<input type=submit name='preview_submit' value='"._("Preview")." ".get_class($object)."'>\n"; 113 $html .= '</form>'; 114 108 115 $html .= "<form action='".GENERIC_OBJECT_ADMIN_ABS_HREF."' method='post'>"; 109 116 $html .= $common_input; … … 113 120 } 114 121 122 123 if ($_REQUEST['action'] == 'preview') 124 { 125 if(empty($_REQUEST['node_id'])) 126 { 127 $node_id = null; 128 $node = null; 129 } 130 else 131 { 132 $node_id = $_REQUEST['node_id']; 133 $node= Node::getObject($node_id); 134 Node::setCurrentNode($node); 135 } 136 $common_input = ''; 137 if(!empty($_REQUEST['debug'])) 138 { 139 $common_input .= "<input type=submit name='debug' value='true'>\n"; 140 } 141 $common_input .= "<input type='hidden' name='object_id' value='".$object->GetId()."'>\n"; 142 $common_input .= "<input type='hidden' name='object_class' value='".get_class($object)."'>\n"; 143 $common_input .= "<input type='hidden' name='node_id' value='".$node_id."'>\n"; 144 145 $html .= "<form action='".GENERIC_OBJECT_ADMIN_ABS_HREF."' method='post'>"; 146 $html .= $common_input; 147 148 $name = "node_id"; 149 $html .= Node :: getSelectNodeUI($name); 150 151 $html .= $object->getUserUI(); 152 $html .= "<input type='hidden' name='action' value='preview'>\n"; 153 $html .= "<input type=submit name='preview_submit' value='"._("Preview")." ".get_class($object)."'>\n"; 154 $html .= '</form>'; 155 156 $html .= "<form action='".GENERIC_OBJECT_ADMIN_ABS_HREF."' method='post'>"; 157 $html .= $common_input; 158 $html .= "<input type='hidden' name='action' value='edit'>\n"; 159 $html .= "<input type=submit name='edit_submit' value='"._("Edit")." ".get_class($object)."'>\n"; 160 $html .= '</form>'; 161 } 162 115 163 echo $html; 116 164 $smarty->display("templates/footer.html"); -
trunk/wifidog-auth/wifidog/classes/Network.php
r553 r554 41 41 { 42 42 return new self($id); 43 } 44 45 /** Get the current network for which the portal is displayed or to which a user is physically connected. 46 * @param $real_network_only true or false. If true, the real physical network where the user is connected is returned, and the node set by setCurrentNode is ignored. 47 * @return a Node object, or null if it can't be found. 48 */ 49 static function getCurrentNetwork($real_network_only = false) 50 { 51 global $AUTH_SOURCE_ARRAY; 52 $keys = array_keys ( $AUTH_SOURCE_ARRAY); 53 54 return new self($keys[0]); 43 55 } 44 56 -
trunk/wifidog-auth/wifidog/classes/Node.php
r553 r554 1 1 <?php 2 2 3 3 4 /********************************************************************\ … … 30 31 private $mRow; 31 32 private $id; 33 private static $current_node_id = null; 32 34 33 35 /** Instantiate a node object … … 42 44 } 43 45 46 /** Get the current node for which the portal is displayed or to which a user is physically connected. 47 * @param $real_node_only true or false. If true, the real physical node where the user is connected is returned, and the node set by setCurrentNode is ignored. 48 * @return a Node object, or null if it can't be found. 49 */ 50 static function getCurrentNode($real_node_only = false) 51 { 52 $object = null; 53 if (self :: $current_node_id != null && $real_node_only == false) 54 { 55 $object = new self(self :: $current_node_id); 56 } 57 else 58 { 59 $object = getCurrentRealNode(); 60 } 61 return $object; 62 } 63 64 /** Set the current node where the user is to be considered connected to. (For portal and content display purpuses, among other. 65 * @param $node Node. The new current node. 66 * @return true */ 67 static function setCurrentNode(Node $node) 68 { 69 self :: $current_node_id = $node->GetId(); 70 return true; 71 } 72 73 /** Get the current node to which a user is physically connected, if any. This is done by an IP adress lookup against the last reported IP adress of the node 74 * @param * @return a Node object, or null if it can't be found. 75 */ 76 public function getCurrentRealNode() 77 { 78 global $db; 79 $retval = null; 80 $sql = "SELECT node_id, last_heartbeat_ip from nodes WHERE last_heartbeat_ip='$_SERVER[REMOTE_ADDR]'"; 81 $db->ExecSql($sql, $node_rows, false); 82 $num_match = count($node_rows); 83 if ($num_match == 0) 84 { 85 // User is not physically connected to a node 86 $retval = null; 87 } 88 else 89 if ($num_match = 1) 90 { 91 // Only a single node matches, the user is presumed to be there 92 $retval = new self($node_rows[0]['node_id']); 93 } 94 else 95 { 96 /* We have more than one node matching the IP (the nodes are behind the same NAT). 97 * We will try to discriminate by finding which node the user last authenticated against. 98 * If the IP matches, we can be pretty certain the user is there. 99 */ 100 $retval = null; 101 $current_user = User :: getCurrentUser(); 102 if ($current_user != null) 103 { 104 $current_user_id = $current_user->getId(); 105 $_SERVER['REMOTE_ADDR']; 106 $sql = "SELECT node_id, last_heartbeat_ip from connections NATURAL JOIN nodes WHERE user_id='$current_user_id' ORDER BY last_updated DESC "; 107 $db->ExecSql($sql, $node_rows, false); 108 $node_row = $node_rows[0]; 109 if($node_row!=null && $node_row['last_heartbeat_ip']==$_SERVER['REMOTE_ADDR']) 110 { 111 $retval = new self($node_row['node_id']); 112 } 113 } 114 } 115 return $retval; 116 } 117 44 118 public function delete(& $errmsg) 45 119 { 46 $retval =false;47 $user = User ::getCurrentUser();48 if ($this->isOwner($user)||$user->isSuperAdmin())49 { 50 $errmsg =_('Access denied!');120 $retval = false; 121 $user = User :: getCurrentUser(); 122 if ($this->isOwner($user) || $user->isSuperAdmin()) 123 { 124 $errmsg = _('Access denied!'); 51 125 } 52 126 global $db; … … 54 128 if (!$db->ExecSqlUpdate("DELETE FROM nodes WHERE node_id='{$this->$id}'", false)) 55 129 { 56 $errmsg=_('Could not delete node!');} 57 else 58 { 59 $retval=true; 60 } 61 return $retval; 130 $errmsg = _('Could not delete node!'); 131 } 132 else 133 { 134 $retval = true; 135 } 136 return $retval; 62 137 } 63 138 … … 123 198 * @return html markup 124 199 */ 125 public static function getSelectNodeUI($user_prefix, $sql_additional_where =null)200 public static function getSelectNodeUI($user_prefix, $sql_additional_where = null) 126 201 { 127 202 global $db; … … 290 365 return $html; 291 366 } 292 367 293 368 /** Process admin interface of this object. 294 369 */ 295 370 public function processAdminUI() 296 371 { 297 if($this->isOwner($user)||$user->isSuperAdmin()) 372 $user = User::getCurrentUser(); 373 if (!$this->isOwner($user) || !$user->isSuperAdmin()) 298 374 { 299 375 throw new Exception(_('Access denied!')); … … 317 393 } 318 394 } 319 320 /** Add content to this node */395 396 /** Add content to this node */ 321 397 public function addContent(Content $content) 322 398 { 323 399 global $db; 324 $content_id =$db->EscapeString($content->getId());400 $content_id = $db->EscapeString($content->getId()); 325 401 $sql = "INSERT INTO node_has_content (node_id, content_id) VALUES ('$this->id','$content_id')"; 326 402 $db->ExecSqlUpdate($sql, false); 327 403 } 328 329 /** Remove content from this node */404 405 /** Remove content from this node */ 330 406 public function removeContent(Content $content) 331 407 { 332 408 global $db; 333 $content_id =$db->EscapeString($content->getId());409 $content_id = $db->EscapeString($content->getId()); 334 410 $sql = "DELETE FROM node_has_content WHERE node_id='$this->id' AND content_id='$content_id'"; 335 411 $db->ExecSqlUpdate($sql, false); 336 412 } 337 413 338 414 /**Get an array of all Content linked to this node 339 415 * @return an array of Content or an empty arrray */ -
trunk/wifidog-auth/wifidog/config.php
r545 r554 7 7 * 8 8 * $Log$ 9 * Revision 1.32 2005/04/19 21:02:40 benoitg 10 * 2005-04-19 Benoit Gr�goire <bock@step.polymtl.ca> 11 * * Working (beta...) content manager and portal. 12 * * Add content preview mode 13 * 9 14 * Revision 1.31 2005/04/14 15:12:35 benoitg 10 15 * 2005-04-14 Benoit Gr�goire <bock@step.polymtl.ca> … … 214 219 define('STYLESHEET_NAME', 'stylesheet.css'); 215 220 define('LOGIN_PAGE_NAME', 'login.html'); 216 define('PORTAL_PAGE_NAME', 'portal.html'); 221 define('PORTAL_PAGE_NAME', 'portal.html');/**< @deprecated version - 19-Apr-2005*/ 217 222 define('PAGE_HEADER_NAME', 'header.html'); 218 223 define('PAGE_FOOTER_NAME', 'footer.html'); -
trunk/wifidog-auth/wifidog/local_content/default/stylesheet.css
r553 r554 209 209 210 210 .list_ui_container{ display: inline; } 211 212 /* Portal */ 213 214 #portal_container { 215 margin: 3px;} 216 217 .portal_network_section {/*background-color: #FBFBFF;/*lighter blue*/ 218 margin: 3px;} 219 .portal_node_section {/*background-color: #FBFBFF;/*lighter blue*/ 220 margin: 3px;} 221 .portal_user_section {/*background-color: #FBFBFF;/*lighter blue*/ 222 margin: 3px;} 223 224 .portal_section_logo{ 225 float: right; 226 clear: right; 227 padding: 2px; 228 max-height: 100px; 229 max-width: 100px; 230 } 231 211 232 {/literal} -
trunk/wifidog-auth/wifidog/portal/index.php
r553 r554 32 32 garbage_collect(); 33 33 } 34 $node = Node::getObject($_REQUEST['gw_id']); 34 35 35 if ( !isset($_REQUEST['gw_id'])) {36 if ($node==null) { 36 37 $smarty->display("templates/message_unknown_hotspot.html"); 37 38 exit; 38 39 } 40 $node_id=$node->getId(); 41 $portal_template = $node_id . ".html"; 39 42 40 $portal_template = $_REQUEST['gw_id'] . ".html";41 $node_id = $db->EscapeString($_REQUEST['gw_id']);42 43 $node = Node::getObject($node_id);44 43 if ($node == null) { 45 44 $smarty->assign("gw_id", $_REQUEST['gw_id']); … … 48 47 } 49 48 49 Node::setCurrentNode($node); 50 50 51 $smarty->assign('hotspot_name', $node->getName()); 51 $ hotspot_rss_url = $node->getRSSURL();52 $node_name= $node->getName(); 52 53 53 54 /* Find out who is online */ 54 55 $smarty->assign("online_users", $node->getOnlineUsers()); 55 56 56 if (RSS_SUPPORT) {57 // $old_error_level = error_reporting(E_ERROR);58 define('MAGPIE_DIR', BASEPATH.MAGPIE_REL_PATH);59 // require_once(MAGPIE_DIR.'rss_fetch.inc');60 // define('MAGPIE_DEBUG', 0);61 require_once BASEPATH.'classes/RssPressReview.inc';62 $press_review=new RssPressReview;63 $tokens = "/[\s,]+/";64 $network_rss_sources = NETWORK_RSS_URL;65 $network_rss_html = null;66 if(!empty($network_rss_sources))67 {68 69 $extract_array=null;70 $extract_array = preg_split($tokens, $network_rss_sources);71 //print_r($extract_array);72 foreach($extract_array as $source)73 {74 $network_rss_sources_array[] = array('url' => $source, 'default_publication_interval' => 7*24*3600);75 }76 $network_rss_html=$press_review->get_rss_html($network_rss_sources_array, 5);77 }78 79 $hotspot_rss_html=null;80 if(!empty($hotspot_rss_url))81 {82 $extract_array=null;83 $extract_array = preg_split($tokens, $hotspot_rss_url);84 //print_r($extract_array);85 foreach($extract_array as $source)86 {87 $hotspot_rss_sources_array[] = array('url' => $source, 'default_publication_interval' => 7*24*3600);88 }89 $hotspot_rss_html=$press_review->get_rss_html($hotspot_rss_sources_array, 5);90 }91 /**92 @return the generated html or the error message or an empty string if called without a URL.93 */94 function generate_rss_html ( $url ) {95 $rss_html='';96 if(!empty($url))97 {98 $rss = fetch_rss( $url );99 $rss_html='';100 if ( !$rss )101 {102 $rss_html .= _("Error: ") . magpie_error() ;103 }104 else105 {106 //$rss->show_channel();107 //$rss->show_list();108 $rss_html .= "<p>"._('Channel: ') . $rss->channel['title'] . "</p>\n";109 $rss_html .= "<ul>\n";110 foreach ($rss->items as $item)111 {112 //echo '<pre>'; print_r($item); echo '</pre>';113 $href = $item['link'];114 $title = $item['title'];115 $summary = $item['summary'];116 $rss_html .= "<li><emp><a href=$href>$title</a></emp> $summary</li>\n";117 }118 $rss_html .= "</ul>\n";119 }120 }121 return $rss_html;122 }123 124 125 //$network_rss_html=generate_rss_html(NETWORK_RSS_URL);126 //echo $networkrss_html;127 $smarty->assign("network_rss_html", $network_rss_html);128 129 130 //$hotspot_rss_html=generate_rss_html($hotspot_rss_url);131 //echo $hotspot_rss_html;132 $smarty->assign("hotspot_rss_html", $hotspot_rss_html);133 // error_reporting($old_error_level);134 }135 57 136 58 if (isset($session)) { 137 59 $smarty->assign("original_url_requested", $session->get(SESS_ORIGINAL_URL_VAR)); 138 60 } 61 $hotspot_network_name=HOTSPOT_NETWORK_NAME; 62 $hotspot_network_url=HOTSPOT_NETWORK_URL; 63 $network_logo_url=COMMON_CONTENT_URL.NETWORK_LOGO_NAME; 64 $network_logo_banner_url=COMMON_CONTENT_URL.NETWORK_LOGO_BANNER_NAME; 65 66 $hotspot_logo_url= find_local_content_url(HOTSPOT_LOGO_NAME); 67 $hotspot_logo_banner_url=find_local_content_url(HOTSPOT_LOGO_BANNER_NAME); 68 139 69 140 70 $smarty->display(DEFAULT_CONTENT_SMARTY_PATH."header.html"); 71 $html=''; 72 $html .= "<div id='portal_container'>\n"; 141 73 74 /* Network section */ 75 $html .= "<div class='portal_network_section'>\n"; 76 $html .= "<a href='{$hotspot_network_url}'><img class='portal_section_logo' src='{$network_logo_banner_url}' alt='{$hotspot_network_name} logo' border='0'></a>\n"; 77 $html .= "Content from \"<a href='{$hotspot_network_url}'>{$hotspot_network_name}</a>\"\n"; 78 $contents = Network::getCurrentNetwork()->getAllContent(); 79 foreach ($contents as $content) 80 { 81 $html .= $content->getUserUI(); 82 } 83 $html .= "</div>\n"; 84 85 /* Node section */ 86 $html .= "<div class='portal_node_section'>\n"; 87 $html .= "<img class='portal_section_logo' src='{$hotspot_logo_url}' alt=''>\n"; 88 $html .= "Content from \"<a href='{$hotspot_logo_url}'>{$node_name}</a>\"\n"; 89 $contents = $node->getAllContent(); 90 foreach ($contents as $content) 91 { 92 $html .= $content->getUserUI(); 93 } 94 $html .= "</div>\n"; 95 96 /* User section */ 97 $html .= "<div class='portal_user_section'>\n"; 98 $html .= _("My content")."\n"; 99 $html .= "</div>\n"; 100 $html .= "</div>\n"; /* end portal_container */ 101 echo $html; 142 102 /* If we have local content, display it. Otherwise, display default */ 143 if (is_file(NODE_CONTENT_PHP_RELATIVE_PATH.PORTAL_PAGE_NAME)) {103 /*if (is_file(NODE_CONTENT_PHP_RELATIVE_PATH.PORTAL_PAGE_NAME)) { 144 104 $smarty->assign("local_content_path", NODE_CONTENT_SMARTY_PATH); 145 105 $smarty->display(NODE_CONTENT_SMARTY_PATH.PORTAL_PAGE_NAME); … … 148 108 $smarty->display(DEFAULT_CONTENT_SMARTY_PATH.PORTAL_PAGE_NAME); 149 109 } 110 */ 150 111 151 112 $smarty->display(DEFAULT_CONTENT_SMARTY_PATH."footer.html");
