no42 Posted November 2, 2013 Share Posted November 2, 2013 Simple patch that adds functionality to easily change your time zone, from the configuration tile. Feel free to check the code/patch below, its Saturday night and I've been drinking :) : diff -Npaur /Volumes/Pineapple/pineapple/components/system/configuration/functions.php /tmp/configuration-new/functions.php --- /Volumes/Pineapple/pineapple/components/system/configuration/functions.php 2013-10-10 07:54:58.000000000 +0100 +++ /tmp/configuration-new/functions.php 2013-11-02 22:29:15.000000000 +0000 @@ -6,6 +6,10 @@ if(isset($_GET['change_port'])){ echo change_port($_POST['port']); } +if(isset($_GET['change_time'])){ + echo change_time($_POST['time']); +} + if(isset($_GET['change_password'])){ echo change_password($_POST['password'], $_POST['repeat']); } @@ -93,6 +97,14 @@ function change_port($port){ return '<font color="lime">Port changed to '.$port.'.</font>'; } +function change_time($time){ + if (in_array($time, range(-12, 12))) { + exec("echo GMT".$time." > /etc/TZ"); + }else{ + exec("echo UTC > /etc/TZ"); + } +} + function change_password($password, $repeat){ if($password != $repeat || trim($password) == ''){ return "<font color='red'>There was an error. Please try again</font>"; diff -Npaur /Volumes/Pineapple/pineapple/components/system/configuration/includes/content/time.php /tmp/configuration-new/includes/content/time.php --- /Volumes/Pineapple/pineapple/components/system/configuration/includes/content/time.php 1970-01-01 01:00:00.000000000 +0100 +++ /tmp/configuration-new/includes/content/time.php 2013-11-02 22:29:15.000000000 +0000 @@ -0,0 +1,38 @@ +<?php include('/pineapple/includes/api/tile_functions.php'); ?> + +<center><div id='config_message'></div></center> +<fieldset> + <legend>Time Settings</legend> + <form id='config_change_time' method='POST' action='/components/system/configuration/functions.php?change_time' onSubmit='$(this).AJAXifyForm(update_message); return false;'> + Time Zone: + <select name="time" id="time"> + <option value="12">(GMT -12:00) Eniwetok, Kwajalein</option> + <option value="11">(GMT -11:00) Midway Island, Samoa</option> + <option value="10">(GMT -10:00) Hawaii</option> + <option value="9">(GMT -9:00) Alaska</option> + <option value="8">(GMT -8:00) Pacific Time (US & Canada)</option> + <option value="7">(GMT -7:00) Mountain Time (US & Canada)</option> + <option value="6">(GMT -6:00) Central Time (US & Canada), Mexico City</option> + <option value="5">(GMT -5:00) Eastern Time (US & Canada), Bogota, Lima</option> + <option value="4">(GMT -4:00) Atlantic Time (Canada), Caracas, La Paz</option> + <option value="3">(GMT -3:00) Brazil, Buenos Aires, Georgetown</option> + <option value="2">(GMT -2:00) Mid-Atlantic</option> + <option value="1">(GMT -1:00 hour) Azores, Cape Verde Islands</option> + <option value="0">(GMT) Western Europe Time, London, Lisbon, Casablanca</option> + <option value="-1">(GMT +1:00 hour) Brussels, Copenhagen, Madrid, Paris</option> + <option value="-2">(GMT +2:00) Kaliningrad, South Africa</option> + <option value="-3">(GMT +3:00) Baghdad, Riyadh, Moscow, St. Petersburg</option> + <option value="-4">(GMT +4:00) Abu Dhabi, Muscat, Baku, Tbilisi</option> + <option value="-5">(GMT +5:00) Ekaterinburg, Islamabad, Karachi, Tashkent</option> + <option value="-6">(GMT +6:00) Almaty, Dhaka, Colombo</option> + <option value="-7">(GMT +7:00) Bangkok, Hanoi, Jakarta</option> + <option value="-8">(GMT +8:00) Beijing, Perth, Singapore, Hong Kong</option> + <option value="-9">(GMT +9:00) Tokyo, Seoul, Osaka, Sapporo, Yakutsk</option> + <option value="-10">(GMT +10:00) Eastern Australia, Guam, Vladivostok</option> + <option value="-11">(GMT +11:00) Magadan, Solomon Islands, New Caledonia</option> + <option value="-12">(GMT +12:00) Auckland, Wellington, Fiji, Kamchatka</option> + </select> + <input type='submit' name='change_time' value='Change Time'> + </form> +</fieldset> + diff -Npaur /Volumes/Pineapple/pineapple/components/system/configuration/large_tile.php /tmp/configuration-new/large_tile.php --- /Volumes/Pineapple/pineapple/components/system/configuration/large_tile.php 2013-10-10 07:54:58.000000000 +0100 +++ /tmp/configuration-new/large_tile.php 2013-11-02 22:29:15.000000000 +0000 @@ -9,5 +9,6 @@ <li><a id="dnsspoof">DNS Spoof</a></li> <li><a id="css">CSS Editor</a></li> <li><a id="advanced">Advanced</a></li> + <li><a id="time">Time</a></li> </ul> <div class="tabContainer" /> \ No newline at end of file Quote Link to comment Share on other sites More sharing options...
thesugarat Posted November 4, 2013 Share Posted November 4, 2013 midnitesnake, Love the idea but after making changes to the two existing files and creating the time.php file all I get in the Configuration Tile: Time tab is an echo of the topmost bar of the Management Page with time uptime and logout. Any idea what I've done wrong? Quote Link to comment Share on other sites More sharing options...
no42 Posted November 4, 2013 Author Share Posted November 4, 2013 did you use the "patch" command or manual add the additional code? Could be that copying the code onto the forum has messed up the alignment/formatting, I'll stick a copy on pastebin http://pastebin.com/R1ZBaPwK Quote Link to comment Share on other sites More sharing options...
thesugarat Posted November 4, 2013 Share Posted November 4, 2013 I did it manually. Wasn't sure about those diff commands so I figured it out from what is mentioned and the + symbols that indicated lines added. What you pasted looks exactly what was in the spoiler. I'll check again though. Maybe you could post the 3 files or spoilers of the content.... Quote Link to comment Share on other sites More sharing options...
no42 Posted November 4, 2013 Author Share Posted November 4, 2013 (edited) Individual paste bin's of the modified and new file: functions.php http://pastebin.com/AQfwCDt4 large_tile.php http://pastebin.com/ESTMyC8X includes/content/time.php http://pastebin.com/Tuw2nGcd but should be simple as: opkg update opkg install patch --dest usb [manually copy n paste patch to file, e.g. vi time.patch] patch < time.patch Edited November 4, 2013 by midnitesnake Quote Link to comment Share on other sites More sharing options...
thesugarat Posted November 4, 2013 Share Posted November 4, 2013 Thanks, that's got it working now. I copied from paste bin and created the .php files then scp'd them over replacing the other files I had edited. There was a 1 byte difference in each file for some reason. Rebooted and there it is. Quote Link to comment Share on other sites More sharing options...
no42 Posted November 5, 2013 Author Share Posted November 5, 2013 Glad you got it working :) Quote Link to comment Share on other sites More sharing options...
Sebkinne Posted November 5, 2013 Share Posted November 5, 2013 I'll push this into a tile update, thanks midnightsnake! I always forget people are in different time zones.. Quote Link to comment Share on other sites More sharing options...
thesugarat Posted November 14, 2013 Share Posted November 14, 2013 Applied this again after update to 1.0.1 firmware and it's still working. :) Quote Link to comment Share on other sites More sharing options...
Sebkinne Posted November 15, 2013 Share Posted November 15, 2013 Timezone changing has been added to the UI, based on the above patches, modified to fit in better with our usual style! Thanks! Quote Link to comment Share on other sites More sharing options...
jjd Posted November 15, 2013 Share Posted November 15, 2013 (edited) Timezone changing has been added to the UI, based on the above patches, modified to fit in better with our usual style! Thanks! love it thanks Seb! although it does not seem to save the timezone for me after a powerdown Edited November 15, 2013 by jjd Quote Link to comment Share on other sites More sharing options...
no42 Posted November 15, 2013 Author Share Posted November 15, 2013 It currently modifies a symlink. It is only a small change (with some sed action) for it to edit to the master_file to persist across reboots. Quote Link to comment Share on other sites More sharing options...
Sebkinne Posted November 15, 2013 Share Posted November 15, 2013 It currently modifies a symlink. It is only a small change (with some sed action) for it to edit to the master_file to persist across reboots. Almost. UCI will take care of it too. I forgot about the persistence. Update pushed to the bar! Quote Link to comment Share on other sites More sharing options...
thesugarat Posted November 15, 2013 Share Posted November 15, 2013 That's great... After yesterdays bar update it wiped it again. Was going to do it this evening but thanks to you now it's just built in. I know it's something simple but I always want to see that time up there correct even if I'm not connected via client mode and more importantly I want any logs produced in that configuration to be accurate as well. Quote Link to comment Share on other sites More sharing options...
jjd Posted November 15, 2013 Share Posted November 15, 2013 Almost. UCI will take care of it too. I forgot about the persistence. Update pushed to the bar! You rock! Quote Link to comment Share on other sites More sharing options...
Sebkinne Posted November 15, 2013 Share Posted November 15, 2013 That's great... After yesterdays bar update it wiped it again. Was going to do it this evening but thanks to you now it's just built in. I know it's something simple but I always want to see that time up there correct even if I'm not connected via client mode and more importantly I want any logs produced in that configuration to be accurate as well. Yeah, the issue for me is, I'm never on a firmware for long enough to care about the TZ. That's why I never added it, as it didn't occur to me. Silly but the truth. Quote Link to comment Share on other sites More sharing options...
Z4ub4d3 Posted November 16, 2013 Share Posted November 16, 2013 That's great... After yesterdays bar update it wiped it again. Was going to do it this evening but thanks to you now it's just built in. I know it's something simple but I always want to see that time up there correct even if I'm not connected via client mode and more importantly I want any logs produced in that configuration to be accurate as well. The logs being correct is the main reason i want the time zone to be set properly as well. Now i do not have to set it manually. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.