Skip to content

Commit

Permalink
time module, mistakenly left out
Browse files Browse the repository at this point in the history
  • Loading branch information
Trystan committed Apr 15, 2013
1 parent 246df75 commit 8f2b547
Show file tree
Hide file tree
Showing 2 changed files with 41 additions and 1 deletion.
1 change: 0 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ Modules/raspberrypi
Modules/site
Modules/command
Modules/sap
Modules/time
Modules/rss
Modules/adminusers
Modules/feedconvert
Expand Down
41 changes: 41 additions & 0 deletions Modules/time/time_controller.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
<?php
/*
All Emoncms code is released under the GNU Affero General Public License.
See COPYRIGHT.txt and LICENSE.txt.
---------------------------------------------------------------------
Emoncms - open source energy visualisation
Part of the OpenEnergyMonitor project:
http://openenergymonitor.org
*/

// no direct access
defined('EMONCMS_EXEC') or die('Restricted access');

function time_controller()
{
global $mysqli,$session, $route;

$result = false;

if (!isset($session['read'])) return array('content'=>false);

if ($route->action == 'local' && $session['read'])
{
$userid = $session['userid'];
$result = $mysqli->query("SELECT timezone FROM users WHERE id = '$userid';");
$row = $result->fetch_object();

$time = (time() + ($row->timezone*3600));
$result = 't'.date('H,i,s',$time);
}

if ($route->action == 'server' && $session['read'])
{
$result = 't'.date('H,i,s');
}

return array('content'=>$result);
}

?>

0 comments on commit 8f2b547

Please sign in to comment.