Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Newer
Older
100644 166 lines (125 sloc) 4.134 kb
87abb3fa »
2010-05-18 first commit
1 <?php
2 include_once(dirname(__FILE__)."/ressources/class.user.inc");
3 include_once(dirname(__FILE__)."/ressources/class.templates.inc");
4
5 if(isset($_GET["current-time"])){get_current_time();exit;}
6 if(isset($_GET["settings"])){set_current_date_js();exit;}
7 if(isset($_GET["date-settings"])){set_current_date_page();exit;}
8 if(isset($_GET["year"])){save_currenttime();exit;}
9 die("Wrong commands");
10
11
12 function set_current_date_js(){
13 $tpl=new templates();
14 $title=$tpl->_ENGINE_parse_body('{server_time}');
15 $page=CurrentPageName();
16 $user=new usersMenus();
17 if(!$user->AsArticaAdministrator){
18 echo $tpl->_ENGINE_parse_body("alert('{ERROR_NO_PRIVS}')");
19 die();
20 }
21 $html="
22
23 var x_SaveServerTime= function (obj) {
24 var results=obj.responseText;
25 if (results.length>0){
26 alert(results);
27 LoadTimeParams();
28 }
29 }
30
31 function LoadTimeParams(){
32 YahooWin6('450','$page?date-settings=yes','$title');
33
34 }
35
36 function SaveServerTime(){
37 var XHR = new XHRConnection();
38 XHR.appendData('year',document.getElementById('year').value);
39 XHR.appendData('month',document.getElementById('month').value);
40 XHR.appendData('day',document.getElementById('day').value);
41 XHR.appendData('hour',document.getElementById('hour').value);
42 XHR.appendData('minute',document.getElementById('minute').value);
43 XHR.appendData('seconds',document.getElementById('seconds').value);
44
45
46 document.getElementById('servertimediv').innerHTML='<center><img src=\"img/wait_verybig.gif\"></center>';
47 XHR.sendAndLoad('$page', 'GET',x_SaveServerTime);
48
49 }
50
51
52 LoadTimeParams();
53
54 ";
55
56 echo $html;
57
58 }
59
60 function save_currenttime(){
61
62 $newdate="MMDDhhmmYY.ss";
63 $newdate="{$_GET["month"]}{$_GET["day"]}{$_GET["hour"]}{$_GET["minute"]}{$_GET["year"]}.{$_GET["seconds"]}";
64 $sock=new sockets();
65 echo $sock->getfile("SetServerTime:$newdate");
66 }
67
68 function get_current_time(){
69
70 $users=new usersMenus();
71 if($users->AsArticaAdministrator){
72 $html="<a onclick=\"Loadjs('index.time.php?settings=yes')\" href='#'>".date('d-m H:i:s')."</a></li>";
73 }else{
74
75 $html="<a onclick=\"#\" href='#'>".date('d-m H:i:s')."</a></li>";
76 }
77
78
79 }
80
81
82 function set_current_date_page(){
83 $user=new usersMenus();
84 if(!$user->AsArticaAdministrator){die();}
85 $sock=new sockets();
86 $time=$sock->getfile('GetCurrentBindate');
87
88 for($i=1;$i<13;$i++){
89 if($i<10){$month_text="0$i";}else{$month_text=$i;}
90 $months[$month_text]=$month_text;
91 }
92
93 for($i=1;$i<32;$i++){
94 if($i<10){$day_text="0$i";}else{$day_text=$i;}
95 $days[$day_text]=$day_text;
96 }
97
98 for($i=1;$i<24;$i++){
99 if($i<10){$hours_text="0$i";}else{$hours_text=$i;}
100 $hours[$hours_text]=$hours_text;
101 }
102
103 for($i=1;$i<60;$i++){
104 if($i<10){$mins_text="0$i";}else{$mins_text=$i;}
105 $mins[$mins_text]=$mins_text;
106 $secs[$mins_text]=$mins_text;
107 }
108
109 for($i=2009;$i<2050;$i++){
110 $years_value=$i-2000;
111 if($years_value<10){$years_value="0$years_value";}else{$years_value=$i;}
112 $years[$years_value]=$i;
113 }
114
115 if(preg_match("#([0-9]+)-([0-9]+) ([0-9]+):([0-9]+):([0-9]+)#",$time,$re)){
116 $defday=$re[1];
117 $defmonth=$re[2];
118 $defhour=$re[3];
119 $defmin=$re[4];
120 $defsec=$re[5];
121 }
122
123 $form="
124 <table style='width:99%'>
125 <tr>
126 <th>{year}</th>
127 <th>{month}</th>
128 <th>{day}</th>
129 <th>{hours}</th>
130 <th>{minutes}</th>
131 <th>{seconds}</th>
132 </tr>
133 <tr>
134 <td align='center'>" . Field_array_Hash($years,'year',date('Y'))."</td>
135 <td align='center'>" . Field_array_Hash($months,'month',$defmonth)."</td>
136 <td align='center'>" . Field_array_Hash($days,'day',$defday)."</td>
137 <td align='center'>" . Field_array_Hash($hours,'hour',$defhour)."</td>
138 <td align='center'>" . Field_array_Hash($mins,'minute',$defmin)."</td>
139 <td align='center'>" . Field_array_Hash($secs,'seconds',$defsec)."</td>
140 </tr>
141 <tr><td colspan=6><hr></td></tr>
142 <tr>
143 <td colspan=6 align='right'><input type='button' OnClick=\"javascript:SaveServerTime();\" value='{edit}&nbsp;&raquo;&nbsp;&raquo;'></td>
144 </tr>
145
146 </table>
147 ";
148 $form=RoundedLightWhite($form);
149
150 $html="<H1>{server_time}: $time</H1>
151 <div id='servertimediv'>
152 $form
153 </div>
154
155
156 ";
157
158
159
160
161
162 $tpl=new templates();
163 echo $tpl->_ENGINE_parse_body($html);
164
165 }
166 ?>
Something went wrong with that request. Please try again.