Changeset 510

Show
Ignore:
Timestamp:
03/24/05 11:57:05 (4 years ago)
Author:
benoitg
Message:

2005-03-24 Benoit Gr�goire <bock@step.polymtl.ca>

  • Statistics.php: Fix getMostGreedyUsers returning bad values when incoming and outgoing for all connections from a user have null values.
  • wifidog/local_content/default/portal.html: Fix layout so it resizes properly. This in an interim measure.
  • Update schema. This will allow automatic schema updates in the future. To update a live server:

BEGIN;
CREATE TABLE schema_info (

tag text PRIMARY KEY,
value text

);
INSERT INTO schema_info (tag, value) VALUES ('schema_version', '1');
COMMIT;

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/wifidog-auth/ChangeLog

    r504 r510  
    11# $Header$ 
    2  
     22005-03-24 Benoit Gr�ire  <bock@step.polymtl.ca> 
     3        * Statistics.php: Fix getMostGreedyUsers returning bad values when incoming and outgoing for all connections from a user have null values.  
     4        * wifidog/local_content/default/portal.html: Fix layout so it resizes properly.  This in an interim measure. 
     5        * Update schema.  This will allow automatic schema updates in the future.  TO update a live server: 
     6                BEGIN; 
     7                CREATE TABLE schema_info ( 
     8                    tag text PRIMARY KEY, 
     9                    value text 
     10                ); 
     11                INSERT INTO schema_info (tag, value) VALUES ('schema_version', '1'); 
     12                COMMIT; 
     13         
    3142005-03-16 Matthew Asham <matthewa@bcwireless.net> 
    415 * config.php: will use "local.config.php" instead, if present.  avoid cvs over-writing. 
     
    819  
    9202005-02-22 Benoit Gr�ire  <bock@step.polymtl.ca> 
    10 M ChangeLog 
    1121        * sql/dump_initial_data_postgres.sh, wifidog-postgres-initial-data.sql, wifidog-postgres-schema.sql:-Widen the connections size to fix int4 wraparound problems.  To update a running server, execute the following sql sniplet:  
    1222BEGIN; 
  • trunk/wifidog-auth/sql/dump_initial_data_postgres.sh

    r474 r510  
    1313pg_dump -a -D -t node_deployment_status 
    1414pg_dump -a -D -t venue_types 
     15pg_dump -a -D -t schema_info 
  • trunk/wifidog-auth/sql/wifidog-postgres-initial-data.sql

    r474 r510  
    101101 
    102102 
     103-- 
     104-- PostgreSQL database dump 
     105-- 
     106 
     107SET client_encoding = 'LATIN1'; 
     108SET check_function_bodies = false; 
     109 
     110SET SESSION AUTHORIZATION 'wifidog'; 
     111 
     112SET search_path = public, pg_catalog; 
     113 
     114-- 
     115-- Data for TOC entry 2 (OID 680734) 
     116-- Name: schema_info; Type: TABLE DATA; Schema: public; Owner: wifidog 
     117-- 
     118 
     119INSERT INTO schema_info (tag, value) VALUES ('schema_version', '1'); 
     120 
     121 
  • trunk/wifidog-auth/sql/wifidog-postgres-schema.sql

    r474 r510  
    148148 
    149149-- 
    150 -- TOC entry 16 (OID 300919) 
     150-- TOC entry 13 (OID 680734) 
     151-- Name: schema_info; Type: TABLE; Schema: public; Owner: wifidog 
     152-- 
     153 
     154CREATE TABLE schema_info ( 
     155    tag text NOT NULL, 
     156    value text 
     157); 
     158 
     159 
     160-- 
     161-- TOC entry 17 (OID 300919) 
    151162-- Name: idx_token; Type: INDEX; Schema: public; Owner: wifidog 
    152163-- 
     
    156167 
    157168-- 
    158 -- TOC entry 17 (OID 300920) 
     169-- TOC entry 18 (OID 300920) 
    159170-- Name: idx_token_status_and_user_id; Type: INDEX; Schema: public; Owner: wifidog 
    160171-- 
     
    164175 
    165176-- 
    166 -- TOC entry 13 (OID 299870) 
     177-- TOC entry 14 (OID 299870) 
    167178-- Name: administrators_pkey; Type: CONSTRAINT; Schema: public; Owner: wifidog 
    168179-- 
     
    173184 
    174185-- 
    175 -- TOC entry 14 (OID 299874) 
     186-- TOC entry 15 (OID 299874) 
    176187-- Name: token_status_pkey; Type: CONSTRAINT; Schema: public; Owner: wifidog 
    177188-- 
     
    182193 
    183194-- 
    184 -- TOC entry 15 (OID 299889) 
     195-- TOC entry 16 (OID 299889) 
    185196-- Name: connections_pkey; Type: CONSTRAINT; Schema: public; Owner: wifidog 
    186197-- 
     
    191202 
    192203-- 
    193 -- TOC entry 18 (OID 299901) 
     204-- TOC entry 19 (OID 299901) 
    194205-- Name: nodes_pkey; Type: CONSTRAINT; Schema: public; Owner: wifidog 
    195206-- 
     
    200211 
    201212-- 
    202 -- TOC entry 19 (OID 299912) 
     213-- TOC entry 20 (OID 299912) 
    203214-- Name: users_pkey; Type: CONSTRAINT; Schema: public; Owner: wifidog 
    204215-- 
     
    209220 
    210221-- 
    211 -- TOC entry 20 (OID 310107) 
     222-- TOC entry 21 (OID 310107) 
    212223-- Name: node_owners_pkey; Type: CONSTRAINT; Schema: public; Owner: wifidog 
    213224-- 
     
    218229 
    219230-- 
    220 -- TOC entry 21 (OID 318920) 
     231-- TOC entry 22 (OID 318920) 
    221232-- Name: node_deployment_status_pkey; Type: CONSTRAINT; Schema: public; Owner: wifidog 
    222233-- 
     
    227238 
    228239-- 
    229 -- TOC entry 22 (OID 566585) 
     240-- TOC entry 23 (OID 566585) 
    230241-- Name: venue_types_pkey; Type: CONSTRAINT; Schema: public; Owner: wifidog 
    231242-- 
     
    236247 
    237248-- 
    238 -- TOC entry 24 (OID 299891) 
     249-- TOC entry 24 (OID 680739) 
     250-- Name: schema_info_pkey; Type: CONSTRAINT; Schema: public; Owner: wifidog 
     251-- 
     252 
     253ALTER TABLE ONLY schema_info 
     254    ADD CONSTRAINT schema_info_pkey PRIMARY KEY (tag); 
     255 
     256 
     257-- 
     258-- TOC entry 26 (OID 299891) 
    239259-- Name: $1; Type: FK CONSTRAINT; Schema: public; Owner: wifidog 
    240260-- 
     
    245265 
    246266-- 
    247 -- TOC entry 23 (OID 299914) 
     267-- TOC entry 25 (OID 299914) 
    248268-- Name: administrators_ibfk_1; Type: FK CONSTRAINT; Schema: public; Owner: wifidog 
    249269-- 
     
    254274 
    255275-- 
    256 -- TOC entry 25 (OID 300909) 
     276-- TOC entry 27 (OID 300909) 
    257277-- Name: fk_users; Type: FK CONSTRAINT; Schema: public; Owner: wifidog 
    258278-- 
     
    263283 
    264284-- 
    265 -- TOC entry 26 (OID 300913) 
     285-- TOC entry 28 (OID 300913) 
    266286-- Name: fk_nodes; Type: FK CONSTRAINT; Schema: public; Owner: wifidog 
    267287-- 
     
    272292 
    273293-- 
    274 -- TOC entry 29 (OID 310097) 
     294-- TOC entry 31 (OID 310097) 
    275295-- Name: fk_users; Type: FK CONSTRAINT; Schema: public; Owner: wifidog 
    276296-- 
     
    281301 
    282302-- 
    283 -- TOC entry 30 (OID 310101) 
     303-- TOC entry 32 (OID 310101) 
    284304-- Name: fk_nodes; Type: FK CONSTRAINT; Schema: public; Owner: wifidog 
    285305-- 
     
    290310 
    291311-- 
    292 -- TOC entry 27 (OID 318922) 
     312-- TOC entry 29 (OID 318922) 
    293313-- Name: fk_node_deployment_status; Type: FK CONSTRAINT; Schema: public; Owner: wifidog 
    294314-- 
     
    299319 
    300320-- 
    301 -- TOC entry 28 (OID 566588) 
     321-- TOC entry 30 (OID 566588) 
    302322-- Name: fk_venue_types; Type: FK CONSTRAINT; Schema: public; Owner: wifidog 
    303323-- 
  • trunk/wifidog-auth/wifidog/classes/Statistics.php

    r410 r510  
    111111  public static function getMostGreedyUsers($limit) { 
    112112    global $db; 
    113     $db->ExecSql("SELECT DISTINCT user_id, SUM((incoming+outgoing)/1048576) AS total, SUM((incoming/1048576)) AS total_incoming, SUM((outgoing/1048576)) AS total_outgoing FROM connections GROUP BY user_id ORDER BY total DESC limit $limit", $results, false); 
     113    $db->ExecSql("SELECT DISTINCT user_id, SUM((incoming+outgoing)/1048576) AS total, SUM((incoming/1048576)) AS total_incoming, SUM((outgoing/1048576)) AS total_outgoing FROM connections WHERE incoming IS NOT NULL AND outgoing IS NOT NULL GROUP BY user_id ORDER BY total DESC limit $limit", $results, false); 
    114114    return $results; 
    115115  } 
  • trunk/wifidog-auth/wifidog/hotspot_status.php

    r502 r510  
    288288  @ob_clean(); 
    289289  echo $xmldoc->saveXML(); 
    290  } else { 
     290 } 
     291 else if ($format == 'WIFI411_CSV') { 
     292 /* Header("Cache-control: private, no-cache, must-revalidate"); 
     293  Header("Expires: Mon, 26 Jul 1997 05:00:00 GMT"); # Past date 
     294  Header("Pragma: no-cache"); 
     295  Header("Content-Type: text/xml; charset=UTF-8");*/ 
     296 
     297  $xmldoc = new DOMDocument(); 
     298  $xmldoc->formatOutput = true; 
     299  //$xmldoc->encoding="iso-8859-15"; 
     300  $rss = $xmldoc->createElement("rss"); 
     301  $xmldoc->appendChild($rss); 
     302  $rss->setAttribute('version', '2.0'); 
     303 
     304  /* channel */ 
     305  $channel = $xmldoc->createElement("channel"); 
     306  $rss->appendChild($channel); 
     307 
     308  /**************** Required channel elements ********************/ 
     309  /* title */ 
     310  $title = $xmldoc->createElement("title"); 
     311  $title = $channel->appendChild($title); 
     312 
     313  $textnode = $xmldoc->createTextNode(utf8_encode(HOTSPOT_NETWORK_NAME._(": Newest HotSpots"))); 
     314  $title->appendChild($textnode); 
     315 
     316  /* link */ 
     317  $link = $xmldoc->createElement("link"); 
     318  $channel->appendChild($link); 
     319  $textnode = $xmldoc->createTextNode(utf8_encode(HOTSPOT_NETWORK_URL)); 
     320  $link->appendChild($textnode); 
     321 
     322  /* description */ 
     323  $description = $xmldoc->createElement("description"); 
     324  $channel->appendChild($description); 
     325  $textnode = $xmldoc->createTextNode(utf8_encode(_("WiFiDog list of the most recent HotSpots opened by the network: ").HOTSPOT_NETWORK_NAME)); 
     326  $description->appendChild($textnode); 
     327 
     328  /****************** Optional channel elements *******************/ 
     329  /* language */ 
     330  /**@todo Make language selectable */ 
     331  $language = $xmldoc->createElement("language"); 
     332  $channel->appendChild($language); 
     333  $textnode = $xmldoc->createTextNode("en-CA"); 
     334  $language->appendChild($textnode); 
     335 
     336  /* copyright */ 
     337  $copyright = $xmldoc->createElement("copyright"); 
     338  $channel->appendChild($copyright); 
     339  $textnode = $xmldoc->createTextNode(utf8_encode(_("Copyright ").HOTSPOT_NETWORK_NAME)); 
     340  $copyright->appendChild($textnode); 
     341 
     342  /* managingEditor */ 
     343                 
     344  /* webMaster */ 
     345                 
     346  $webMaster = $xmldoc->createElement("webMaster"); 
     347  $channel->appendChild($webMaster); 
     348  $textnode = $xmldoc->createTextNode(utf8_encode(TECH_SUPPORT_EMAIL)); 
     349  $webMaster->appendChild($textnode); 
     350 
     351  /* pubDate */ 
     352  $pubDate = $xmldoc->createElement("pubDate"); 
     353  $channel->appendChild($pubDate); 
     354  $textnode = $xmldoc->createTextNode(utf8_encode(gmdate("D, d M Y H:i:s \G\M\T", time()))); 
     355  $pubDate->appendChild($textnode); 
     356 
     357  /* lastBuildDate */ 
     358  //<lastBuildDate> -- The date-time the last time the content of the channel changed. 
     359  /* Make a request through the database for the latest modification date of an object.   
     360   * Maybe it should be an object property? */ 
     361  $db->ExecSqlUniqueRes("SELECT EXTRACT(epoch FROM MAX(creation_date)) as date_last_hotspot_opened FROM nodes WHERE node_deployment_status = 'DEPLOYED' OR node_deployment_status = 'NON_WIFIDOG_NODE' ", $last_hotspot_row, false); 
     362 
     363  $lastBuildDate = $xmldoc->createElement("lastBuildDate"); 
     364  $channel->appendChild($lastBuildDate); 
     365  $textnode = $xmldoc->createTextNode(gmdate("D, d M Y H:i:s \G\M\T", $last_hotspot_row['date_last_hotspot_opened'])); 
     366  $lastBuildDate->appendChild($textnode); 
     367                 
     368  /* category */ 
     369  /* Specify one or more categories that the channel belongs to. 
     370   *  Follows the same rules as the <item>-level category element.*/ 
     371                  
     372  /* generator */ 
     373  $generator = $xmldoc->createElement("generator"); 
     374  $channel->appendChild($generator); 
     375  $textnode = $xmldoc->createTextNode(utf8_encode(WIFIDOG_NAME . " " . WIFIDOG_VERSION)); 
     376  $generator->appendChild($textnode); 
     377                 
     378  /* docs */ 
     379  $docs = $xmldoc->createElement("docs"); 
     380  $channel->appendChild($docs); 
     381  $textnode = $xmldoc->createTextNode(utf8_encode("http://blogs.law.harvard.edu/tech/rss")); 
     382  $docs->appendChild($textnode); 
     383                 
     384  /* cloud */ 
     385  /* Allows processes to register with a cloud to be notified of updates to the channel, implementing a lightweight publish-subscribe protocol for RSS feeds.*/ 
     386 
     387  /* ttl */ 
     388  /* ttl stands for time to live. It's a number of minutes that indicates how long a channel can be cached before refreshing from the source.*/ 
     389 
     390  /* image */ 
     391  $image = $xmldoc->createElement("image"); 
     392  $channel->appendChild($image); 
     393                 
     394  /* title */ 
     395  $title = $xmldoc->createElement("title"); 
     396  $image->appendChild($title); 
     397  $textnode = $xmldoc->createTextNode(utf8_encode(HOTSPOT_NETWORK_NAME)); 
     398  $title->appendChild($textnode); 
     399  /* url */ 
     400  $url = $xmldoc->createElement("url"); 
     401  $image->appendChild($url); 
     402  $textnode = $xmldoc->createTextNode(utf8_encode(COMMON_CONTENT_URL.NETWORK_LOGO_NAME)); 
     403  $url->appendChild($textnode); 
     404  /* link */ 
     405  $link = $xmldoc->createElement("link"); 
     406  $image->appendChild($link); 
     407  $textnode = $xmldoc->createTextNode(utf8_encode(HOTSPOT_NETWORK_URL)); 
     408  $link->appendChild($textnode); 
     409  /* width */ 
     410  /* 
     411   $width = $xmldoc->createElement("width"); 
     412   $image->appendChild($width); 
     413   $textnode = $xmldoc->createTextNode('135'); 
     414   $width->appendChild($textnode); 
     415  */ 
     416  /* height */ 
     417  /* 
     418   $height = $xmldoc->createElement("height"); 
     419   $image->appendChild($height); 
     420   $textnode = $xmldoc->createTextNode('109'); 
     421   $height->appendChild($textnode); 
     422  */ 
     423  /* description */ 
     424  /* 
     425   $description = $xmldoc->createElement("description"); 
     426   $image->appendChild($description); 
     427   $textnode = $xmldoc->createTextNode("Le portail des TIC"); 
     428   $description->appendChild($textnode); 
     429  */ 
     430 
     431  /* rating */ 
     432  /* textInput */ 
     433  /* skipHours */ 
     434  /* skipDays */ 
     435                 
     436  $i=0; 
     437 
     438  foreach($node_results as $node_row) { 
     439 
     440    $item = $xmldoc->createElement("item"); 
     441    $item = $channel->appendChild($item); 
     442 
     443    /* title */ 
     444    /* lom_1_2_title_langstrings_id */ 
     445    $title = $xmldoc->createElement("title"); 
     446    $item->appendChild($title); 
     447    $title_str = $node_row['name']; 
     448    $textnode = $xmldoc->createTextNode(utf8_encode($title_str)); 
     449    $title->appendChild($textnode); 
     450 
     451    /* link */ 
     452    if(!empty($node_row['home_page_url'])) 
     453      { 
     454        $link = $xmldoc->createElement("link"); 
     455        $item->appendChild($link); 
     456        $textnode = $xmldoc->createTextNode(utf8_encode($node_row['home_page_url'])); 
     457        $link->appendChild($textnode); 
     458      } 
     459 
     460    /* description */ 
     461    $description = $xmldoc->createElement("description"); 
     462    $item->appendChild($description); 
     463    $description_text='<p>'; 
     464    if($node_row['node_deployment_status'] != 'NON_WIFIDOG_NODE') 
     465      { 
     466        if($node_row['is_up']=='t') 
     467          { 
     468            $description_text .= "<img src='".BASE_URL_PATH."images/hotspot_status_up.png'> "; 
     469          } 
     470        else 
     471          { 
     472            $description_text .= "<img src='".BASE_URL_PATH."images/hotspot_status_down.png'> "; 
     473          } 
     474      } 
     475 
     476    if(!empty($node_row['description'])) 
     477      { 
     478        $description_text.= $node_row['description']; 
     479      } 
     480    $description_text.= "</p>\n"; 
     481    $description_text.="<p>\n"; 
     482    if(!empty($node_row['street_address'])) 
     483      { 
     484        $description_text.= ""._("Address:")." ".$node_row['street_address']." "; 
     485      } 
     486    if(!empty($node_row['map_url'])) 
     487      { 
     488        $description_text.=" <a href='".$node_row['map_url']."'>"._("See Map")."</a> "; 
     489      } 
     490    $description_text.= "<br/>\n"; 
     491    if(!empty($node_row['mass_transit_info'])) 
     492      { 
     493        $description_text.=""._("Mass transit:")." ".$node_row['mass_transit_info']."<br/>\n"; 
     494      } 
     495    $description_text.= "</p>\n"; 
     496    if(!empty($node_row['public_email']) || !empty($node_row['public_phone_number'])) 
     497      { 
     498        $description_text.="<p>"._("Contact:"); 
     499 
     500        if(!empty($node_row['public_phone_number'])) 
     501          { 
     502            $description_text.=" $node_row[public_phone_number] "; 
     503          } 
     504        if(!empty($node_row['public_email'])) 
     505          { 
     506            $description_text.=" <a href='".$node_row['public_email']."'>$node_row[public_email]</a> "; 
     507          } 
     508        $description_text.="</p>\n"; 
     509      } 
     510    $textnode = $xmldoc->createTextNode(utf8_encode($description_text)); 
     511    $description->appendChild($textnode); 
     512       
     513    /* author */ 
     514    /* 
     515     $author = $xmldoc->createElement("author"); 
     516     $item->appendChild($author); 
     517     $textnode = $xmldoc->createTextNode($author_vcard->GetEmail().' ('.$author_vcard->GetName().')'); 
     518     $author->appendChild($textnode); 
     519    */ 
     520    /* category */ 
     521 
     522    /* comments */ 
     523    /** Link to page once page is available **/ 
     524    /* enclosure */ 
     525    /* guid */ 
     526 
     527    $guid = $xmldoc->createElement("guid"); 
     528    $guid->setAttribute('isPermaLink', 'false'); 
     529    $item->appendChild($guid); 
     530    $textnode = $xmldoc->createTextNode(utf8_encode(HOTSPOT_NETWORK_URL.$node_row['node_id'])); 
     531    $guid->appendChild($textnode); 
     532 
     533    /* pubDate */ 
     534    $pubDate = $xmldoc->createElement("pubDate"); 
     535    $item->appendChild($pubDate); 
     536    $textnode = $xmldoc->createTextNode(utf8_encode(gmdate("D, d M Y H:i:s \G\M\T", $node_row['creation_date_epoch']))); 
     537    $pubDate->appendChild($textnode); 
     538 
     539    /* source */ 
     540  } 
     541  ob_clean(); 
     542  echo $xmldoc->saveXML(); 
     543 } 
     544  else { 
    291545  foreach($node_results as $node_row) { 
    292546    $node_row['num_online_users'] = $stats->getNumOnlineUsers($node_row['node_id']); 
  • trunk/wifidog-auth/wifidog/local_content/default/portal.html

    r433 r510  
    1 <img style="float: right; margin: 0 0 10px 10px; border: 1px solid #666; padding: 2px;" src="{$hotspot_logo_url}" alt=""> 
    2 <a href='{$hotspot_network_url}'><img src='{$network_logo_banner_url}' alt='{$hotspot_network_name} logo' border='0'></a> 
    3 <br> 
     1<div><img style="float: right; border: 1px solid #666; padding: 2px;width: 250px;" src="{$hotspot_logo_url}" alt=""> 
     2<!--</div> 
     3<div style="">--> 
     4<div> 
     5 
     6<a href='{$hotspot_network_url}'><img style="width: 250px; " src='{$network_logo_banner_url}' alt='{$hotspot_network_name} logo' border='0'></a> 
     7</div> 
     8 
     9<br/> 
    410Content from "<a href='{$hotspot_network_url}'>{$hotspot_network_name}</a>" 
    511{$network_rss_html} 
     12</div> 
  • trunk/wifidog-auth/wifidog/portal/index.php

    r406 r510  
    142142/* If we have local content, display it. Otherwise, display default */ 
    143143if (is_file(NODE_CONTENT_PHP_RELATIVE_PATH.PORTAL_PAGE_NAME)) { 
     144    $smarty->assign("local_content_path", NODE_CONTENT_SMARTY_PATH); 
    144145    $smarty->display(NODE_CONTENT_SMARTY_PATH.PORTAL_PAGE_NAME); 
    145146} else { 
     147    $smarty->assign("local_content_path", DEFAULT_CONTENT_SMARTY_PATH); 
    146148    $smarty->display(DEFAULT_CONTENT_SMARTY_PATH.PORTAL_PAGE_NAME); 
    147149}