rtoss - Blame information for rev 352

Subversion Repositories:
Rev:
Rev Author Line No. Line
3 roytam 1 <?php
2 require("./fav_settings.php");
3 require("./fav_strings.php");
4  
179 roytam 5 function printAdmJs($id) {
6         if(isset($_SESSION['isLogined']))
7                 return ' onmouseover="toggleAdmTool(\'adm'.$id.'\')" onmouseout="toggleAdmTool(\'adm'.$id.'\')"';
8         else
9                 return '';
10 }
11  
12 function printAdmTools($id) {
13         global $SidebarSuffix2,$admAppend,$MyFav_Edit,$MyFav_Delete;
352 roytam 14         return '<a href="'.text2xml("fav_action.php?action=edit&id=".$id.$SidebarSuffix2).'" class="admtool" '.$admAppend.' onclick="return true;">'.$MyFav_Edit.'</a>&nbsp;<a href="'.text2xml("fav_action.php?action=delete&id=".$id.$SidebarSuffix2).'" class="admtool" '.$admAppend.' onclick="return true;">'.$MyFav_Delete.'</a>';
179 roytam 15 }
16  
3 roytam 17 if(isset($_POST['pwd'])||isset($_POST['logout'])) logInOut(val($_POST,'pwd'),isset($_POST['logout']));
18  
352 roytam 19 // *** Read SQLite DB *** //
20 $db = new PDO('sqlite:./'.$sqlite_file, '', '', array(PDO::ATTR_PERSISTENT => true));
21  
3 roytam 22 $qry="SELECT * FROM Fav WHERE cat = 1 ORDER BY ord,id";
352 roytam 23 $rs=$db->query($qry);
3 roytam 24  
352 roytam 25 $ary=$rs->fetchAll(PDO::FETCH_ASSOC);
26  
27 foreach($ary as &$acat) {
28         $qry2="SELECT * FROM Fav WHERE cat = 0 AND catid = ".$acat['id']." ORDER BY ord,id";
29         $rs2=$db->query($qry2);
30         $ary2=$rs2->fetchAll(PDO::FETCH_ASSOC);
31         $acat['childs']=$ary2;
32  
33 }
34  
35 $qry2="SELECT * FROM Fav WHERE cat = 0 AND catid = 0 ORDER BY ord,id";
36 $rs3=$db->query($qry2);
37 $ary3=$rs3->fetchAll(PDO::FETCH_ASSOC);
38 // *** Read SQLite DB *** //
39  
40  
3 roytam 41 if (!($oldNetscape || $noXML))
42   header('Content-type: application/xhtml+xml');
43 echo '<?xml version="1.0" encoding="UTF-8"?>
44 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/2002/REC-xhtml1-20020801/DTD/xhtml1-transitional.dtd">
45 <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="zh-tw" lang="zh-tw">
46 <head>
56 roytam 47 <meta http-equiv="Content-Type" content="'.(($oldNetscape || $noXML)?'text/html':'application/xhtml+xml').'; charset=utf-8" />
179 roytam 48 <meta http-equiv="X-UA-Compatible" content="IE=EmulateIE7" /> <!-- IE8 workaround -->
3 roytam 49 <title>'.$MyFav_Title.'</title>
50 <link href="./style.css" rel="stylesheet" type="text/css" />
51 <link rel="alternate" type="application/xml" title="RSS 1.0 Feed" href="rss.php" />
52 <link rel="alternate" type="application/xml" title="RSS 2.0 Feed" href="rss2.php" />
53 <link rel="alternate" type="application/xml" title="Atom Feed" href="atom.php" />
54 <style type="text/css">';
55 if (!($oldNetscape || $noXML)) echo '<![CDATA[';
56 if ($InSidebar) echo 'body {font-size: 9pt;}';
57 echo 'a.toggle { display:block; float:left; text-align:center; width:1em;}
58 a.admtool { font-size: 9pt;}
59 a.navi {
60         font-size: 9pt;
61         text-decoration: underline overline;
62         line-height: 1em;
63 }
64 .dh {display:none;}
65 .dv {display:block;}
66 .divNavi {
33 roytam 67         border: 1px dotted #999;
68         background-color:#fff;
3 roytam 69         top: 20px;
70         right: 0px;
71         position: absolute;
33 roytam 72         text-align: right;
3 roytam 73         line-height: 1em;
33 roytam 74         padding: 2px;
75         width:auto;
76         height:auto;
77         overflow:auto;
78 }
79 .divNavi-hide {
80         border: 1px dotted #999;
81         background-color:#fff;
82         top: 20px;
83         right: 0px;
84         position: absolute;
85         text-align: right;
86         line-height: 1em;
87         padding: 2px;
88         width:1em;
89         height:1em;
90         overflow:hidden;
91 }
179 roytam 92 ul,li,dt,dl,dd { margin:0; padding:0; text-indent:0px; list-style-position:inside;}
93 dl dd div ul li {padding-left:0.35em;}
94 .admtools-hide {display:none;}
95 .admtools {display:inline; padding-left:1em;}
96 ';
3 roytam 97 if (!($oldNetscape || $noXML)) echo ']]>';
98 echo '</style>
99 <script type="text/javascript">';
100 if (!($oldNetscape || $noXML)) echo '<![CDATA[';
101 echo 'var ie=window.clipboardData
102 var ns4=document.layers?1:0
103 var ns6=document.getElementById&&!document.all?1:0
104 var opera=window.opera?1:0
105 var geckoCSS2=(navigator.userAgent.indexOf("Gecko/")!=-1?navigator.userAgent.substr(navigator.userAgent.indexOf("Gecko/")+6,8):0)>=20011011?1:0;
33 roytam 106 var webkit=navigator.userAgent.indexOf("AppleWebKit/")!=-1?1:0;
3 roytam 107 var cookieName = "WebFavShow";
33 roytam 108 var inSidebar = '.(int)$InSidebar.';
109 var TimeoutTimer,TimerFlag;
3 roytam 110  
111 function gID(s) { return document.getElementById(s); }
112  
113 function ToggleDiv(divID,aID) {
114         if (gID(divID).className=="dv") ShrinkDiv(divID,aID);
115         else ExpandDiv(divID,aID);
116 }
117  
118 function getLinkText(aID) {
119         if (ie) return gID(aID).innerText;
120         else    return gID(aID).firstChild.nodeValue;
121 }
122  
123 function setLinkText(aID,newText) {
124         if (ie) gID(aID).innerText=newText;
125         else    gID(aID).firstChild.nodeValue=newText;
126 }
127  
128 function toggleAllDiv(aID,command) {
129         var aText=getLinkText(aID);
130  
131         var DIVcoll = document.getElementsByTagName("div");
132         if (command=="invert") {
133                 for (var LC=0; LC<DIVcoll.length; LC++){
134                         if (DIVcoll[LC].className=="dv")
135                         ToggleDiv(DIVcoll[LC].id,DIVcoll[LC].id.toString().replace(/d/,"a"));
136                         else if (DIVcoll[LC].className=="dh")
137                         ToggleDiv(DIVcoll[LC].id,DIVcoll[LC].id.toString().replace(/d/,"a"));
138                 }
139         } else if (command=="force") {
140                 if (aText=="'.$MyFav_ExpandAll.'") {
141                         for (var LC=0; LC<DIVcoll.length; LC++){
142                                 if (DIVcoll[LC].className=="dh")
143                                 ToggleDiv(DIVcoll[LC].id,DIVcoll[LC].id.toString().replace(/d/,"a"));
144                         }
145                         setLinkText(aID,"'.$MyFav_ShrinkAll.'");
146                 } else {
147                         for (var LC=0; LC<DIVcoll.length; LC++){
148                                 if (DIVcoll[LC].className=="dv")
149                                 ToggleDiv(DIVcoll[LC].id,DIVcoll[LC].id.toString().replace(/d/,"a"));
150                         }
151                         setLinkText(aID,"'.$MyFav_ExpandAll.'");
152                 }
153         }
154 }
155 function ExpandDiv(divID,aID) {
156         gID(divID).className="dv";
157         add_submenu(divID);
158         setLinkText(aID,"'.$MyFav_ShrinkMark.'");
159 }
179 roytam 160 function toggleAdmTool(divID) {
161         if(gID(divID).className=="admtools-hide") gID(divID).className="admtools";
162         else gID(divID).className="admtools-hide";
163 }
3 roytam 164 function ShrinkDiv(divID,aID) {
165         gID(divID).className="dh";
166         remove_submenu(divID);
167         setLinkText(aID,"'.$MyFav_ExpandMark.'");
168 }
169 function add2Sidebar() {
170 var myHref=self.location.href.replace(/#.*/g,"");
171 if (window.sidebar&&window.sidebar.addPanel)
172  window.sidebar.addPanel("My Web Faviourites",myHref+"?sidebar=Y","");
173 else
174  alert("Your browser does not support this particular feature.");
175 }
176 function moveNavi() {
35 roytam 177         var offsetTop = 20; needRepeat = true;
3 roytam 178  
35 roytam 179         if (ie && !window.XMLHttpRequest) { //<IE7
3 roytam 180                 divNavi.style.pixelTop = document.body.scrollTop + offsetTop;
36 roytam 181 //              divNavi.style.pixelLeft = document.body.clientWidth + document.body.scrollLeft - divNavi.offsetWidth - offsetTop;
182                 divNavi.style.pixelRight = offsetTop;
35 roytam 183         } else if (ns6||opera||ie) {
3 roytam 184                 var obj = document.getElementById("divNavi");
35 roytam 185                 if (!(geckoCSS2||opera||webkit||ie))
3 roytam 186                         obj.style.top=window.pageYOffset+offsetTop;
187                 else {
188                         obj.style.right="12px";
189                         obj.style.position="fixed";
35 roytam 190                         needRepeat = false;
3 roytam 191                 }
192         } else if (ns4) {
193                 // it causes error in netscape
194 //              eval(document.divNavi.top=eval(window.pageYOffset+offsetTop));
195         }
35 roytam 196         if(needRepeat) setTimeout("moveNavi()",100); //IEでスレが大きい場合CPUを食うようなので変更。
3 roytam 197 }
33 roytam 198 function minNavi() { document.getElementById("divNavi").className = "divNavi-hide";TimerFlag=0; }
199 function NaviTimout() {
200         if(inSidebar && !TimerFlag) {
201                 TimeoutTimer=setTimeout("minNavi()",1000);
202                 TimerFlag=1;
203         }
204 }
205 function restoreNavi() {
206         if(TimerFlag) {
207                 clearTimeout(TimeoutTimer);
208                 TimerFlag=0;
209         }
210         document.getElementById("divNavi").className = "divNavi";
211 }
212  
3 roytam 213 function add_submenu(id) {
214         var submenus = get_submenu();
215         for (var i = 0; i<submenus.length; i++) if (submenus[i] == id) return;
216         submenus.push(id);
217         set_submenu(submenus);
218 }
219 function remove_submenu(id){
220         var submenus = get_submenu();
221         var new_submenus = new Array();
222         for (var i=0; i<submenus.length; i++) if (submenus[i] != id) new_submenus.push(submenus[i]);
223         set_submenu(new_submenus);
224 }
225 function get_submenu() {
226         var cookie = get_cookie(cookieName);
227         if (cookie) return cookie.split(/,/);
228         else return [];
229 }
230 function set_submenu(submenus) {
231         set_cookie(cookieName, submenus.join(","), 365);
232 }
233 function get_cookie(name) {
234         with(document.cookie) {
235                 var index = indexOf(name + "=");
236                 if (index == -1) return "";
237                 index = indexOf("=", index) + 1;
238                 var endstr = indexOf(";", index);
239                 if (endstr == -1) endstr = length;
240                 return unescape(substring(index, endstr));
241         }
242 }
243 function set_cookie(name, value, days) {
244         if(days) {
245                 var date = new Date();
246                 date.setTime(date.getTime()+(days*24*60*60*1000));
247                 var expires = "; expires="+date.toGMTString();
248         } else expires = "";
249         document.cookie = name+"="+value+expires+"; path=/";
250 }';
251 if (!($oldNetscape || $noXML)) echo ']]>';
352 roytam 252 echo '</script>';
253 if($jscroll) {
254         echo '<script type="text/javascript" src="jquery.min.js"></script>
255 <script type="text/javascript" src="jquery.nicescroll.min.js"></script>
256 <script type="text/javascript">';
257         if (!($oldNetscape || $noXML)) echo '<![CDATA[';
258         echo '$(document).ready(
259         function() {
260                 $("html").niceScroll({cursorcolor:"#888",cursorwidth:7,cursoropacitymin:0.25,mousescrollstep:13,scrollspeed:40});
261                 if(location.hash) document.getElementById("a"+location.hash.substring(1)).scrollIntoView(true);
262         }
263 );';
264         if (!($oldNetscape || $noXML)) echo ']]>';
265         echo '</script>';
266 }
267 echo '</head>
3 roytam 268 <body onload="moveNavi();">
352 roytam 269 <center><h2>'.$MyFav_Title.'</h2></center>
270 <a name="top" id="atop"></a>';
271 if (isset($_SESSION['isLogined'])) echo '<a href="'.text2xml("fav_action.php?action=order&id=-1".$SidebarSuffix2).'" class="admtool" onclick="return true;" '.$admAppend.'>'.$MyFav_CatOrder.'</a> ';
272 if (!$oldNetscape) echo '<a id="aToggle" href="'.text2xml("javascript:toggleAllDiv('aToggle','force');").'" class="admtool" onclick="return true;">'.($shrinkFirst?$MyFav_ExpandAll:$MyFav_ShrinkAll).'</a> <a id="aToggle2" href="'.text2xml("javascript:toggleAllDiv('aToggle2','invert');").'" class="admtool" onclick="return true;">'.$MyFav_InvertAll.'</a>';
36 roytam 273 echo '<div class="'.($NoNavi?'dh':($DispNavi?'divNavi':'divNavi-hide')).'" id="divNavi" onmouseover="restoreNavi()" onmouseout="NaviTimout()">';
274 if (!$NoNavi) {
352 roytam 275         echo '<a href="#bottom" style="font-size:x-small;" onmouseover="restoreNavi()" onclick="return true;">'.$MyFav_GotoBottom."</a><br />\n";
276         foreach($ary as $a) {
277                 echo '<a href="#'.$a['id'].'" class="navi" onmouseover="restoreNavi()" '.((!$oldNetscape)?'onclick="'.text2xml("ExpandDiv('d".$a['id']."','a".$a['id']."');").'"':'').'>'.text2xml($a['name'])."</a><br />\n";
278         }
279         echo '<a href="#top" style="font-size:x-small;" onclick="return true;">'.$MyFav_GotoTop."</a><br />\n";
36 roytam 280 }
352 roytam 281 echo '</div>';
282  
283 function ary2listOflinks($arr) {
284         global $oldNetscape,$divShrink,$shrinkFirst,$MyFav_ExpandMark,$MyFav_ShrinkMark,$SidebarSuffix2,$admAppend,$MyFav_Add,$MyFav_Order,$aAppend;
285         $txt='';
286         foreach($arr as $a) {
287                 if($a['cat']=="1") {
288                         $txt.= '<dt>';
289                         if(isset($_SESSION['isLogined'])) $txt.= '<div onmouseover="toggleAdmTool(\'adm'.$a['id'].'\')" onmouseout="toggleAdmTool(\'adm'.$a['id'].'\')">';
290                         if (!$oldNetscape)
291                                 $txt.= '<a id="a'.$a['id'].'" href="'.text2xml("javascript:ToggleDiv('d".$a['id']."','a".$a['id']."');").'" class="toggle">'.($shrinkFirst?$MyFav_ExpandMark:$MyFav_ShrinkMark).'</a> ';
292                         $txt.= '<a name="'.$a['id'].'"'.($a['addr']?' href="'.text2xml($a['addr']).'" '.$aAppend:'').'>'.text2xml($a['name']).'</a>';
293  
294                         if (isset($_SESSION['isLogined'])) $txt.= '<span class="admtools-hide" id="adm'.$a['id'].'"><a href="'.text2xml("fav_action.php?action=add&catid=".$a['id'].$SidebarSuffix2).'" class="admtool" '.$admAppend.' onclick="return true;">'.$MyFav_Add.'</a>&nbsp;<a href="'.text2xml("fav_action.php?action=order&id=".$a['id'].$SidebarSuffix2).'" class="admtool" onclick="return true;" '.$admAppend.'>'.$MyFav_Order.'</a>&nbsp;'.printAdmTools($a['id']).'</span></div>';
295  
296  
297                         $txt .='</dt><dd><div id="d'.$a['id'].'" class="'.$divShrink.'"><ul>'.ary2listOflinks($a['childs']).'</ul><br /></div></dd><dt><br /></dt>';
298                 } else {
299                         if ($a['protected']) $txt .= '<li type="circle"'.(printAdmJs($a['id'])).'><a href="'.text2xml("fav_action.php?action=go&id=".$a['id']).'" '.$aAppend.'>'.text2xml($a['name']).'</a>';
300                         else $txt .='<li'.(printAdmJs($a['id'])).'><a href="'.text2xml($a['addr']).'" '.$aAppend.'>'.text2xml($a['name']).'</a>';
301                         if (isset($_SESSION['isLogined'])) $txt .= '<span class="admtools-hide" id="adm'.$a['id'].'">'.printAdmTools($a['id']).'</span>';
302                 }
3 roytam 303         }
352 roytam 304         return $txt;
3 roytam 305 }
306  
352 roytam 307 echo '<dl>'.ary2listOflinks($ary);
308 echo '<dd><ul>'.ary2listOflinks($ary3).'</ul></dd></dl>
3 roytam 309 <script type="text/javascript">';
310 if (!($oldNetscape || $noXML)) echo '<![CDATA[';
311 echo 'var showsubmenu = get_submenu();
312 for (submenu in showsubmenu) {
313         ExpandDiv(showsubmenu[submenu],showsubmenu[submenu].replace(/d/,"a"));
314 }';
315 if (!($oldNetscape || $noXML)) echo ']]>';
316 echo '</script>
352 roytam 317 <a name="bottom" id="abottom"></a>';
318 if (isset($_SESSION['isLogined'])) echo '<a href="'.text2xml("fav_action.php?action=add".$SidebarSuffix2).'" class="admtool" onclick="return true;" '.$admAppend.'>'.$MyFav_Add.'</a>&nbsp;<a href="'.text2xml("fav_action.php?action=order&id=0".$SidebarSuffix2).'" class="admtool" onclick="return true;" '.$admAppend.'>'.$MyFav_Order.'</a> <a href="'.text2xml("fav_action.php?action=opt".$SidebarSuffix2).'" class="admtool" onclick="return true;" '.$admAppend.'>'.$MyFav_Optimize.'</a> <a href="'.text2xml("javascript:location.href='".$BaseURL."fav_action.php?action=add&name='+escape(document.title)+'&url='+escape(document.location.href);").'" class="admtool" onclick="return true;" '.$admAppend.'>'.$MyFav_Bookmarklet.'</a>';
3 roytam 319 $uriSuffix=isset($_SERVER['QUERY_STRING']) && $_SERVER['QUERY_STRING']!=""?"?".$_SERVER['QUERY_STRING']:'';
320  
321 echo '<form action="'.text2xml($_SERVER['PHP_SELF'].$uriSuffix).'" method="post">';
322 if (!isset($_SESSION['isLogined'])) {
323         echo $MyFav_LoginPrompt;
324     echo '<input type="password" name="pwd" />
325     <input type="submit" name="Submit" value="'.$MyFav_LogIn.'" />';
326 } else echo '<input type="submit" name="logout" value="'.$MyFav_LogOut.'" />';
327 echo '</form>';
328 if (!$InSidebar) echo '<a href="javascript:add2Sidebar();" class="admtool">[Add to Sidebar]</a> ';
329 echo '<a href="atom.php" class="admtool">[Atom 0.3 Feed]</a> <a href="rss.php" class="admtool">[RSS 1.0 Feed]</a> <a href="rss2.php" class="admtool">[RSS 2.0 Feed]</a><br />';
330 require("./fav_footer.htm");
331 echo '</body>
332 </html>';