PageRenderTime 48ms CodeModel.GetById 15ms RepoModel.GetById 1ms app.codeStats 0ms

/tags/Beta_3_8_7/Internet/webtools.php

#
PHP | 295 lines | 228 code | 29 blank | 38 comment | 54 complexity | 1d2f8baac4236b6f185c05f1d24967f8 MD5 | raw file
Possible License(s): GPL-2.0, BSD-3-Clause
  1. <?
  2. /* $Id: webtools.php 4208 2001-10-16 08:07:20Z ma $ */
  3. // inserts ftp file size
  4. function GetFileSize($fn) {
  5. $fh = ftp_connect('ftp.openxp.de');
  6. if ($fh) {
  7. if (ftp_login($fh,"anonymous","webmaster@openxp.de")) {
  8. $result = sprintf ("(%01.2f MB)", (ftp_size($fh, $fn)/1024/1024));
  9. };
  10. ftp_quit($fh);
  11. };
  12. return $result;
  13. };
  14. // inserts header (including navigation menu)
  15. function ShowHeader($title) {
  16. global $language, $Menu;
  17. header ("Content-Type: text/html; charset=iso-8859-1");
  18. header ("Content-Language: ".$language);
  19. // now we use XHTML 1.0
  20. echo("<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Transitional//EN\" \"DTD/xhtml1-transitional.dtd\">\n");
  21. echo("<html xmlns=\"http://www.w3.org/1999/xhtml\" xml:lang=\"".$language."\" lang=\"".$language."\">\n");
  22. echo("<head>\n");
  23. // depends on the language
  24. if ($language == "de") {
  25. echo("<meta name=\"copyright\" content=\"Copyright by OpenXP-Team, &copy; 1999-" . htmlspecialchars(date("Y")) . ", all rights reserved\" />\n");
  26. echo("<meta name=\"description\" content=\"Information zu einem Point-Programm\" />\n");
  27. } else {
  28. echo("<meta name=\"copyright\" content=\"Copyright by OpenXP Team, &copy; 1999-" . htmlspecialchars(date("Y")) . ", all rights reserved\" />\n");
  29. echo("<meta name=\"description\" content=\"Information on a point program\" />\n");
  30. };
  31. echo("<meta name=\"keywords\" content=\"crosspoint,xp,mail,news,email,point,fido,zconnect,maus,rfc,mua,newsreader\" />\n");
  32. // we like robots because of the web-directories
  33. echo("<meta name=\"robots\" content=\"index\" />\n");
  34. echo("<title>".htmlspecialchars($title)."</title>\n</head>\n\n");
  35. // now the body follows
  36. echo("<body bgcolor=\"white\" text=\"black\">\n");
  37. echo("\n<table width=\"100%\"><tr>\n<td width=\"75\">&nbsp;</td>");
  38. // link to the other language
  39. if ($language == "de") {
  40. echo("\n<td align=\"center\"><h1><a name=\"top\">OpenXP-Projekt</a></h1></td>");
  41. echo("\n<td width=\"75\" align=\"right\">");
  42. echo("<small><a href=\"http://www.openxp.com/\">English</a></small>");
  43. } else {
  44. echo("\n<td align=\"center\"><h1><a name=\"top\">OpenXP Project</a></h1></td>");
  45. echo("\n<td width=\"75\" align=\"right\">");
  46. echo("<small><a href=\"http://www.openxp.de/\">Deutsch</a></small>");
  47. };
  48. echo("</td></tr></table>");
  49. echo("<hr noshade=\"noshade\" size=\"1\" />");
  50. // open main table
  51. echo("\n<table border=\"0\" cellspacing=\"0\" cellpadding=\"10\"><tr>");
  52. // build site map
  53. echo("\n<td align=\"left\" valign=\"top\" width=\"140\">");
  54. // now underlaying a blue table and then set the header
  55. echo("\n<table width=\"100%\" border=\"0\" cellpadding=\"0\" cellspacing=\"0\" bgcolor=\"blue\"><tr>");
  56. echo("\n<td>\n<table width=\"100%\" border=\"0\" cellpadding=\"4\"><tr bgcolor=\"yellow\">");
  57. echo("\n<th align=\"center\">Site Map</th>\n</tr>\n<tr bgcolor=\"white\">\n<td align=\"left\">");
  58. echo("\n<dl>"); // start definition list
  59. $InSub = false;
  60. reset($Menu);
  61. do {
  62. $Item = current($Menu);
  63. if ($Item["sub"]) {
  64. echo("\n<dd><small>"); $closeitem = "</small></dd>";
  65. } else {
  66. echo("\n<dt>"); $closeitem = "</dt>";
  67. };
  68. // show the item
  69. if (isset($Item["url"])) {
  70. echo("<a href=\"" . htmlspecialchars($Item["url"]) . "\">" . htmlspecialchars($Item[$language]) . "</a>");
  71. } else {
  72. echo(htmlspecialchars($Item[$language]));
  73. };
  74. echo($closeitem);
  75. // fetch next element
  76. } while (next($Menu) != false);
  77. // that's it. now close left cell and go to main part
  78. echo("</dl>\n</td></tr>\n</table>");
  79. echo("</td></tr></table>\n</td>\n<td align=\"left\" valign=\"top\">\n");
  80. // Document is prepared now
  81. }; // ShowHeader
  82. // concludes the HTML page
  83. function ShowFooter() {
  84. global $language;
  85. echo("\n</td></tr></table>\n<hr noshade=\"noshade\" size=\"1\" />");
  86. echo("\n<table width=\"100%\"><tr>\n<td align=\"left\" width=\"25%\">");
  87. if ($language == "de") {
  88. echo("<a href=\"#top\">Seitenanfang</a>\n");
  89. } else {
  90. echo("<a href=\"#top\">Top</a>\n");
  91. };
  92. echo("\n</td><td align=\"center\" width=\"50%\"><a href=\"http://sourceforge.net\"><img src=\"http://sourceforge.net/sflogo.php?group_id=3766&amp;type=1\" width=\"88\" height=\"31\" border=\"0\" alt=\"SourceForge\" /></a>");
  93. echo("</td><td align=\"right\" width=\"25%\">");
  94. echo("<small>Published by <a href=\"mailto:dev@openxp.de\">OpenXP Team</a></small>\n");
  95. // close the doc
  96. echo("</td></tr></table></body>\n</html>\n");
  97. };
  98. // generates a contact table from a file
  99. function ShowContactTable($tablefile) {
  100. global $language;
  101. // generate table header
  102. echo("<table width=\"100%\" border=\"0\" cellspacing=\"1\" cellpadding=\"2\"><tr>");
  103. echo("\n<th nowrap=\"nowrap\" width=\"20%\" bgcolor=\"#EEEE00\">Name/Homepage</th>");
  104. echo("\n<th width=\"5%\" bgcolor=\"#EEEE00\" align=\"center\">K&uuml;rzel</th>");
  105. echo("\n<th nowrap=\"nowrap\" width=\"75%\" bgcolor=\"#EEEE00\">Aufgabenfeld</th></tr>");
  106. $ptfile = fopen($tablefile,"r");
  107. if ($ptfile==false) return 0;
  108. // interpret input file entries
  109. while (!feof($ptfile)) {
  110. echo("\n<tr bgcolor=\"#e0e0e0\">");
  111. // Name/homepage
  112. echo("\n<td nowrap=\"nowrap\">".fgets($ptfile,120)."</td>");
  113. // Short/mail
  114. echo("\n<td nowrap=\"nowrap\" align=\"center\">".fgets($ptfile,150)."</td>");
  115. // Job
  116. $job=fgets($ptfile,150);
  117. if ($language=="en") { $job=fgets($ptfile,150); } else { fgets($ptfile,150); }
  118. echo("\n<td nowrap=\"nowrap\">".$job."</td></tr>");
  119. // skip empty line
  120. fgets($ptfile,10);
  121. }
  122. fclose($ptfile);
  123. // generate table end
  124. echo("\n</table>\n");
  125. }
  126. // generates feature list from file
  127. function ShowFeatureList($tablefile) {
  128. global $language;
  129. // generate table header
  130. echo("<table border=\"0\" cellspacing=\"1\" cellpadding=\"2\"><tr>\n");
  131. echo("<th nowrap=\"nowrap\" bgcolor=\"#EEEE00\">Feature</th>");
  132. echo("\n<th nowrap=\"nowrap\" bgcolor=\"#EEEE00\">3.20</th>");
  133. echo("\n<th nowrap=\"nowrap\" bgcolor=\"#EEEE00\">3.40</th>");
  134. echo("\n<th nowrap=\"nowrap\" bgcolor=\"#EEEE00\">OXP/32</th></tr>");
  135. $ptfile = fopen($tablefile,"r");
  136. if ($ptfile==false) return 0;
  137. // interpret input file entries
  138. while (!feof($ptfile)) {
  139. echo("\n<tr bgcolor=\"#e0e0e0\">");
  140. // Feature
  141. $feature=fgets($ptfile,200);
  142. if ($language=="en") { $feature=fgets($ptfile,200); } else { fgets($ptfile,200); }
  143. echo("\n<td nowrap=\"nowrap\">".$feature."</td>");
  144. // Supported in versions...
  145. echo("\n<td nowrap=\"nowrap\" align=\"center\">".fgets($ptfile,20)."</td>");
  146. echo("\n<td nowrap=\"nowrap\" align=\"center\">".fgets($ptfile,20)."</td>");
  147. echo("\n<td nowrap=\"nowrap\" align=\"center\">".fgets($ptfile,20)."</td></tr>");
  148. fgets($ptfile,10);
  149. }
  150. fclose($ptfile);
  151. // generate table end
  152. echo("</table>");
  153. }
  154. // generates a news page from a file
  155. function ShowNews($newsfile,$genindex) {
  156. // show overall headline
  157. $pnfile = fopen($newsfile,"r");
  158. if ($pnfile==false) return 0;
  159. echo("\n<h2>".fgets($pnfile,200)."</h2>");
  160. fgets($pnfile,10);
  161. // generate index if necessary
  162. if ($genindex==1) {
  163. $iarticle = 0;
  164. echo("\n<ul>");
  165. while (!feof($pnfile)) {
  166. $iarticle++;
  167. $headline=fgets($pnfile,200);
  168. echo("\n<li><a href=\"#art".$iarticle."\">".$headline."</a></li>");
  169. do {
  170. $headline=trim(fgets($pnfile,1000));
  171. } while(($headline!="")and(!feof($pnfile))and($headline!="+"));
  172. }
  173. echo("\n</ul>\n<hr noshade=\"noshade\" size=\"1\" />");
  174. rewind($pnfile);
  175. fgets($pnfile,200); fgets($pnfile,10);
  176. }
  177. // show articles
  178. $iarticle = 0;
  179. while (!feof($pnfile)) {
  180. $iarticle++;
  181. $headline=fgets($pnfile,200);
  182. echo("\n<h3><a name=\"art".$iarticle."\">".$headline."</a></h3>\n");
  183. do {
  184. $headline=fgets($pnfile,1000);
  185. $headline=trim($headline);
  186. if(($headline!="")and($headline!="+")) echo($headline."\n");
  187. } while(($headline!="")and(!feof($pnfile))and($headline!="+"));
  188. }
  189. fclose($pnfile);
  190. }
  191. // inserts only first entry from newsfile
  192. function InsertLatestNews($newsfile) {
  193. $pnfile = fopen($newsfile,"r");
  194. if ($pnfile==false) return 0;
  195. fgets($pnfile,200); fgets($pnfile,10); // skip headline + space
  196. echo("\n<p><big>".trim(fgets($pnfile,200))."</big>\n<br /><small>");
  197. do {
  198. $news=trim(fgets($pnfile,1000));
  199. if ($news=="+") {
  200. echo("</small></p>\n<p><big>".trim(fgets($pnfile,200))."</big>\n<br /><small>");
  201. } else {
  202. echo($news)."\n";
  203. }
  204. } while(($news!="")and(!feof($pnfile)));
  205. echo("</small></p>\n");
  206. echo("<hr noshade=\"noshade\" size=\"1\" />");
  207. fclose($pnfile);
  208. }
  209. // show download table
  210. function ShowDownloadTable($downfile) {
  211. global $language;
  212. $pdfile = fopen($downfile,"r");
  213. if ($pdfile==false) return 0;
  214. // open ftp connection for getting file sizes
  215. $fhandle = ftp_connect('ftp.openxp.de');
  216. if ($fhandle) {
  217. if (!ftp_login($fhandle,"anonymous","webmaster@openxp.de"))
  218. ftp_quit($fhandle);
  219. }
  220. $popen=false;
  221. echo("\n");
  222. while(!feof($pdfile)) {
  223. $line=fgets($pdfile,300);
  224. if(strpos(" ".$line,"*")==1) { // headline
  225. if($popen) { echo("</p>\n"); $popen=false; };
  226. if($language=="de") {
  227. echo("<h3>".substr($line,1)."</h3>");
  228. fgets($pdfile,300);
  229. } else {
  230. $line=fgets($pdfile,300);
  231. echo("<h3>".$line."</h3>");
  232. }
  233. } else {
  234. if ($fhandle) {
  235. $fsize = ftp_size($fhandle, $line);
  236. $ftime = date("Y-m-d", ftp_mdtm($fhandle, $line));
  237. } else {
  238. $fsize = ""; // no ftp connection made
  239. $ftime = "";
  240. }
  241. if($popen) {
  242. echo("<br />\n");
  243. } else {
  244. echo("\n<p>"); $popen=true;
  245. }
  246. if($language=="de") {
  247. $fdesc=fgets($pdfile,200);
  248. fgets($pdfile,200);
  249. } else {
  250. fgets($pdfile,200);
  251. $fdesc=fgets($pdfile,200);
  252. }
  253. echo("\n".htmlspecialchars($fdesc));
  254. if($fsize != -1) {
  255. echo(" (<a href=\"".htmlspecialchars("ftp://ftp.openxp.de".$line)."\">FTP</a>/");
  256. echo("<a href=\"".htmlspecialchars("http://www.happyarts.de/ftp".$line)."\">HTTP</a>, ");
  257. echo(sprintf("%01.2f MB", $fsize/1024/1024).", ".$ftime.")");
  258. } else if($language=="de") echo (" (<i>z.Zt. nicht verfügbar</i>)"); else echo(" (<i>temporarily not available</i>)");
  259. fgets($pdfile,20); // skip empty line
  260. }
  261. }
  262. if($popen) { echo("</p>\n"); $popen=false; };
  263. if ($fhandle) ftp_quit($fhandle);
  264. fclose($pdfile);
  265. }
  266. ?>