Source for file admin.php

Documentation is available at admin.php

  1. <?
  2. /**
  3. * admin.php
  4. *
  5. * This program is free software; you can redistribute it and/or modify
  6. * it under the terms of the GNU General Public License as published by
  7. * the Free Software Foundation; either version 2 of the License, or
  8. * (at your option) any later version.
  9. * This program is distributed in the hope that it will be useful,
  10. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  12. * GNU General Public License for more details.
  13. * @author Stephan Raabe
  14. */
  15.  
  16. /**
  17. * Writes a cancel button
  18. */
  19.  
  20. function writeCancel($link)
  21. {
  22. echo '<input style="background-image:url(system/admin/img/oes_cancelback.png);background-repeat:no-repeat;" type="button" value="Cancel" class="adminsubmitbtn" onclick="'.$link.'">';
  23. }
  24.  
  25. /**
  26. * Writes an OK button
  27. */
  28. function writeOk($link)
  29. {
  30. echo '<input style="background-image:url(system/admin/img/oes_okback.png);background-repeat:no-repeat;" type="button" value="Ok" class="adminsubmitbtn" onclick="'.$link.'">';
  31. }
  32.  
  33. /**
  34. * Writes a back button
  35. */
  36. function writeBack($link)
  37. {
  38. echo '<input style="background-image:url(system/admin/img/oes_backback.png);background-repeat:no-repeat;" type="button" value="Back" class="adminsubmitbtn" onclick="'.$link.'">';
  39. }
  40.  
  41. /**
  42. * Writes a menu item
  43. */
  44. function writeOeLink($title,$link,$icon)
  45. {
  46. ?>
  47. <div class="oe_menu_item">
  48. <div class="icon"><a href="<?= $link; ?>"><img src="system/admin/img/oes_<?= $icon; ?>.png"></a></div>
  49. <div class="link"><a href="<?= $link; ?>"><?= $title; ?></a></div>
  50. </div>
  51. <?
  52. }
  53.  
  54. /**
  55. * writes the admin menu header
  56. */
  57. function getAdminHead($name,$img,$control = "")
  58. {
  59. global $admin_lang,$page,$site_help;
  60. ?>
  61. <? if ($control == "yes") { ?>
  62. <link rel="stylesheet" type="text/css" href="system/admin/style/oe_pullmenu.css" />
  63. <script type="text/javascript" src="system/admin/script/DropDownMenuX.js"></script>
  64. <div id="oe_menuback"></div>
  65. <div id="oe_pulldown">
  66. <table cellspacing="0" cellpadding="0" id="menu1" class="ddmx">
  67. <tr>
  68. <td>
  69. <a class="item1" href="javascript:void(0)">System</a>
  70. <div class="section">
  71. <a class="item2" href="website.php?id=<?= $page["page_path"]; ?>&admin=settings"><?= $admin_lang["settings"][1]; ?></a>
  72. <a class="item2" href="website.php?id=<?= $page["page_path"]; ?>&admin=phpinfo">PHP Info</a>
  73. <a class="item2" href="website.php?id=<?= $page["page_path"]; ?>&admin=deletecache"><?= $admin_lang["filecache"][1]; ?></a>
  74. <a class="item2 arrow" href="website.php?id=<?= $page["page_path"]; ?>&admin=stringpool"><?= $admin_lang["stringpool"][1]; ?><img src="system/admin/img/arrow1.gif" width="10" height="12" alt="" /></a>
  75. <div class="section">
  76. <a class="item2" href="website.php?id=<?= $page["page_path"]; ?>&admin=stringpool&action=showstringpoolItem"><?= $admin_lang["stringpool"][5]; ?></a>
  77. </div>
  78. <a class="item2 arrow" href="website.php?id=<?= $page["page_path"]; ?>&admin=languages"><?= $admin_lang["lang"][1]; ?><img src="system/admin/img/arrow1.gif" width="10" height="12" alt="" /></a>
  79. <div class="section">
  80. <a class="item2" href="website.php?id=<?= $page["page_path"]; ?>&admin=languages&action=showlanguageItem"><?= $admin_lang["table"][23]; ?></a>
  81. </div>
  82. </div>
  83. </td>
  84. <td>
  85. <a class="item1" href="javascript:void(0)">Layout</a>
  86. <div class="section">
  87. <a class="item2 arrow" href="website.php?id=<?= $page["page_path"]; ?>&admin=templates"><?= $admin_lang["templates"][1]; ?><img src="system/admin/img/arrow1.gif" width="10" height="12" alt="" /></a>
  88. <div class="section">
  89. <a class="item2" href="website.php?id=<?= $page["page_path"]; ?>&admin=templates&action=showtemplateItem"><?= $admin_lang["table"][18]; ?></a>
  90. </div>
  91. <a class="item2 arrow" href="website.php?id=<?= $page["page_path"]; ?>&admin=attributes"><?= $admin_lang["attributes"][1]; ?><img src="system/admin/img/arrow1.gif" width="10" height="12" alt="" /></a>
  92. <div class="section">
  93. <a class="item2" href="website.php?id=<?= $page["page_path"]; ?>&admin=attributes&action=showattributeItem"><?= $admin_lang["table"][19]; ?></a>
  94. </div>
  95. <a class="item2" href="website.php?id=<?= $page["page_path"]; ?>&admin=edit/css">Editor CSS</a>
  96. </div>
  97. </td>
  98. <td>
  99. <a class="item1" href="javascript:void(0)"><?= $admin_lang["admin"][5]; ?></a>
  100. <div class="section">
  101. <a class="item2 arrow" href="website.php?id=<?= $page["page_path"]; ?>&admin=accounts"><?= $admin_lang["accounts"][1]; ?><img src="system/admin/img/arrow1.gif" width="10" height="12" alt="" /></a>
  102. <div class="section">
  103. <a class="item2" href="website.php?id=<?= $page["page_path"]; ?>&admin=accounts&action=showaccountItem"><?= $admin_lang["table"][20]; ?></a>
  104. </div>
  105. <a class="item2" href="website.php?id=<?= $page["page_path"]; ?>&admin=statistic"><?= $admin_lang["statistics"][1]; ?></a>
  106. <a class="item2 arrow" href="website.php?id=<?= $page["page_path"]; ?>&admin=newsletter"><?= $admin_lang["newsletter"][1]; ?><img src="system/admin/img/arrow1.gif" width="10" height="12" alt="" /></a>
  107. <div class="section">
  108. <a class="item2" href="website.php?id=<?= $page["page_path"]; ?>&admin=newsletter&action=shownewsletterItem"><?= $admin_lang["table"][21]; ?></a>
  109. </div>
  110. <a class="item2" href="website.php?id=<?= $page["page_path"]; ?>&admin=group"><?= $admin_lang["group"][1]; ?></a>
  111. </div>
  112. </td>
  113. <td>
  114. <a class="item1" href="javascript:void(0)"><?= $admin_lang["admin"][6]; ?></a>
  115. <div class="section">
  116. <a class="item2" href="website.php?id=<?= $page["page_path"]; ?>&admin=exporting"><?= $admin_lang["exporting"][1]; ?></a>
  117. <a class="item2 arrow" href="website.php?id=<?= $page["page_path"]; ?>&admin=replacing"><?= $admin_lang["replacing"][1]; ?><img src="system/admin/img/arrow1.gif" width="10" height="12" alt="" /></a>
  118. <div class="section">
  119. <a class="item2" href="website.php?id=<?= $page["page_path"]; ?>&admin=replacing&action=showreplacingItem"><?= $admin_lang["table"][22]; ?></a>
  120. </div>
  121. </div>
  122. </td>
  123. <td>
  124. <a class="item1" href="javascript:void(0)"><?= $admin_lang["admin"][7]; ?></a>
  125. <div class="section">
  126. <a class="item2" href="<?= $site_help; ?>" target="_blank"><?= $admin_lang["admin"][2]; ?></a>
  127. <a class="item2" href="http://www.openengine.de" target="_blank">openengine.de</a>
  128. <a class="item2" href="http://www.openengine.de/forum" target="_blank">Forum</a>
  129. <a class="item2" href="#" onclick="window.open('website.php?id=<?= $page["page_path"]; ?>&admin=greeting','login','width=420,height=300')">Info</a>
  130. </div>
  131. </td>
  132. </tr>
  133. </table>
  134. </div>
  135. <script type="text/javascript">
  136. var ddmx = new DropDownMenuX('menu1');
  137. ddmx.delay.show = 0;
  138. ddmx.delay.hide = 400;
  139. ddmx.position.levelX.left = 2;
  140. ddmx.init();
  141. </script>
  142. <? } ?>
  143. <!-- Admin Head START -->
  144. <div id="oe_head">
  145. <div class="icon"><img src="system/admin/img/oes_<?= $img; ?>.png" alt="" border="0"></div>
  146. <div class="text"><?= $name; ?></div>
  147. </div>
  148. <!-- Admin Head END -->
  149.  
  150. <?
  151. }
  152.  
  153. /**
  154. * returns an html encodes string (ISO or UTF-8)
  155. * @return string
  156. */
  157. function htmlencode($input)
  158. {
  159. global $site_encoding;
  160. if ($site_encoding == "utf-8")
  161. {
  162. $htmlEntities = array_values (get_html_translation_table (HTML_ENTITIES, ENT_QUOTES));
  163. $entitiesDecoded = array_keys (get_html_translation_table (HTML_ENTITIES, ENT_QUOTES));
  164. $num = count ($entitiesDecoded);
  165. for ($u = 0; $u < $num; $u++)
  166. {
  167. $utf8Entities[$u] = '&#'.ord($entitiesDecoded[$u]).';';
  168. }
  169. $output = str_replace ($htmlEntities, $utf8Entities, $input);
  170. }
  171. else
  172. {
  173. $output = $input;
  174. $output = str_replace("<","[oe_lt]",$output);
  175. $output = str_replace(">","[oe_gt]",$output);
  176. $output = htmlentities($output);
  177. $output = str_replace("[oe_lt]","<",$output);
  178. $output = str_replace("[oe_gt]",">",$output);
  179. $output = str_replace("&quot;",'"',$output);
  180. $output = str_replace("&amp;",'&',$output);
  181. }
  182. $output = ereg_replace("'","&#039;", $output);
  183. return $output;
  184. }
  185.  
  186. /**
  187. * returns the filename of a path
  188. * @return string
  189. */
  190. function getFile($page_file)
  191. {
  192. $file_name = ereg_replace("/", "_", $page_file);
  193. if (substr($file_name, 0, 1) == "_")
  194. {
  195. $file_name = substr($file_name, 1);
  196. }
  197. return $file_name;
  198. }
  199.  
  200. /**
  201. * returns the folders of a path
  202. * @return string
  203. */
  204. function getFolder($page_file)
  205. {
  206. $folders = explode("/",$page_file);
  207. $str_folder = "";
  208. for ($i = 0; $i < sizeof($folders) - 1; $i++)
  209. {
  210. $str_folder .= $folders[$i]."/";
  211. }
  212. return $str_folder;
  213. }
  214.  
  215. /**
  216. * checks if a staging textblock of a page is temporaly saved (staging)
  217. * @return bool
  218. */
  219. function isStage($page_key,$block)
  220. {
  221. global $site_staging,$db_praefix;
  222. $link = connectDB();
  223. $query = "SELECT page_key FROM ".$db_praefix."stage WHERE stage_edit = '$block' AND page_key = $page_key";
  224. $result = mysql_query($query);
  225. closeDB($link);
  226. if (mysql_num_rows($result) == 0)
  227. {
  228. return false;
  229. }
  230. else
  231. {
  232. return true;
  233. }
  234. }
  235.  
  236. /**
  237. * checks if a page has a temporaly saved textblock (staging)
  238. * @return bool
  239. */
  240. function isPageStage($page_key)
  241. {
  242. global $site_staging,$db_praefix;
  243. $link = connectDB();
  244. $query = "SELECT page_key FROM ".$db_praefix."stage WHERE page_key = $page_key";
  245. $result = mysql_query($query);
  246. closeDB($link);
  247. if (mysql_num_rows($result) == 0)
  248. {
  249. return false;
  250. }
  251. else
  252. {
  253. return true;
  254. }
  255. }
  256.  
  257. /**
  258. * returns the content of page by textblock definition
  259. * @return string
  260. */
  261. function staging_output($block)
  262. {
  263. global $page,$db_praefix;
  264. $link = connectDB();
  265. $query = "SELECT stage_input FROM ".$db_praefix."stage WHERE stage_edit = '$block' AND page_key = ".$page["page_key"];
  266. $result = mysql_query($query);
  267. closeDB($link);
  268. if (mysql_num_rows($result) == 0)
  269. {
  270. return $page[$block];
  271. }
  272. else
  273. {
  274. $output = mysql_fetch_array($result);
  275. return $output["stage_input"];
  276. }
  277. }
  278.  
  279. /**
  280. * updates the statistic entry of a page
  281. */
  282. function update_statistic($page_key,$page_count)
  283. {
  284. global $db_praefix;
  285. $page_count = $page_count + 1;
  286. $link = connectDB();
  287. $query = "UPDATE ".$db_praefix."page SET page_count = $page_count where page_key = $page_key";
  288. $result = mysql_query($query);
  289. closeDB($link);
  290. }
  291.  
  292. /**
  293. * returns a page by path
  294. * @return array
  295. */
  296. function get_page($page_path)
  297. {
  298. global $db_praefix;
  299.  
  300. $account_status = 0;
  301. $access = "";
  302. if (empty($_GET["export"]))
  303. {
  304. $account_status = $_SESSION["account_group"];
  305. if ($_SESSION["account_group"] == 1)
  306. {
  307. $account_access = $_SESSION["account_access"];
  308. $access = " AND (page_access <= $account_access)";
  309. }
  310. }
  311.  
  312. $link = connectDB();
  313. $query = "SELECT * FROM ".$db_praefix."page WHERE (page_path = '$page_path') AND (page_status <= ".$account_status.") $access";
  314. $result = mysql_query($query);
  315. $menge = mysql_num_fields($result);
  316. $row = mysql_fetch_row ($result);
  317. $page_rows = mysql_num_rows($result);
  318. for($x = 0; $x < $menge; $x++)
  319. {
  320. $page[mysql_field_name($result,$x)] = $row[$x];
  321. }
  322. mysql_free_result($result);
  323. $page["page_rows"] = $page_rows;
  324. if (isset($_GET["template"]))
  325. {
  326. $page["page_template"] = $_GET["template"];
  327. }
  328. closeDB($link);
  329. return $page;
  330. }
  331.  
  332. /**
  333. * returns a page by path
  334. * @return array
  335. */
  336. function get_key_path($page_path)
  337. {
  338. global $db_praefix;
  339.  
  340. $account_status = 0;
  341. $access = "";
  342. if (empty($_GET["export"]))
  343. {
  344. $account_status = $_SESSION["account_group"];
  345. if ($_SESSION["account_group"] == 1)
  346. {
  347. $account_access = $_SESSION["account_access"];
  348. $access = " AND (page_access <= $account_access)";
  349. }
  350. }
  351.  
  352. $link = connectDB();
  353. $query = "SELECT * FROM ".$db_praefix."page WHERE (page_path = '$page_path') AND (page_status <= ".$account_status.") $access";
  354. $result = mysql_query($query);
  355. $menge = mysql_num_fields($result);
  356. $row = mysql_fetch_row ($result);
  357. $page_rows = mysql_num_rows($result);
  358. for($x = 0; $x < $menge; $x++)
  359. {
  360. $page[mysql_field_name($result,$x)] = $row[$x];
  361. }
  362. mysql_free_result($result);
  363. closeDB($link);
  364. return $page;
  365. }
  366.  
  367. /**
  368. * returns a recordset of subpages
  369. * @return resource
  370. */
  371. function get_subpages($page_path)
  372. {
  373. global $db_praefix;
  374.  
  375. $account_status = 0;
  376. $access = "";
  377. if (empty($_GET["export"]))
  378. {
  379. $account_status = $_SESSION["account_group"];
  380. if ($_SESSION["account_group"] == 1)
  381. {
  382. $account_access = $_SESSION["account_access"];
  383. $access = " AND (page_access <= $account_access)";
  384. }
  385. }
  386. $page = get_key_path($page_path);
  387. $page_key = $page["page_key"];
  388. $link = connectDB();
  389. $query = "SELECT * FROM ".$db_praefix."page WHERE (page_parent = $page_key) AND (page_status <= ".$account_status.") $access AND (page_start = 0) ORDER BY page_order DESC";
  390. $result = mysql_query($query);
  391. closeDB($link);
  392. return $result;
  393. }
  394.  
  395. /**
  396. * returns a recordset of subpages order by date
  397. * @return resource
  398. */
  399. function get_subpages_date($page_path,$order)
  400. {
  401. global $db_praefix;
  402.  
  403. $account_status = 0;
  404. $access = "";
  405. if (empty($_GET["export"]))
  406. {
  407. $account_status = $_SESSION["account_group"];
  408. if ($_SESSION["account_group"] == 1)
  409. {
  410. $account_access = $_SESSION["account_access"];
  411. $access = " AND (page_access <= $account_access)";
  412. }
  413. }
  414. $page = get_key_path($page_path);
  415. $page_key = $page["page_key"];
  416. $link = connectDB();
  417. $query = "SELECT * FROM ".$db_praefix."page WHERE (page_parent = $page_key) AND (page_status <= ".$account_status.") $access AND (page_start = 0) ORDER BY page_date_unformated $order";
  418. $result = mysql_query($query);
  419. closeDB($link);
  420. return $result;
  421. }
  422.  
  423. /**
  424. * returns a recordset of subpages
  425. * @return resource
  426. */
  427. function get_subpages_key($page_key)
  428. {
  429. global $db_praefix;
  430.  
  431. $account_status = 0;
  432. $access = "";
  433. if (empty($_GET["export"]))
  434. {
  435. $account_status = $_SESSION["account_group"];
  436. if ($_SESSION["account_group"] == 1)
  437. {
  438. $account_access = $_SESSION["account_access"];
  439. $access = " AND (page_access <= $account_access)";
  440. }
  441. }
  442. $link = connectDB();
  443. $query = "SELECT * FROM ".$db_praefix."page WHERE (page_parent = $page_key) AND (page_status <= ".$account_status.") $access AND (page_start = 0) ORDER BY page_order DESC";
  444. $result = mysql_query($query);
  445. closeDB($link);
  446. return $result;
  447. }
  448.  
  449. /**
  450. * returns a recordset of subpages with a specified template name
  451. * @return resource
  452. */
  453. function get_subpages_bytemplate($page_key,$template)
  454. {
  455. global $db_praefix;
  456.  
  457. $account_status = 0;
  458. $access = "";
  459. if (empty($_GET["export"]))
  460. {
  461. $account_status = $_SESSION["account_group"];
  462. if ($_SESSION["account_group"] == 1)
  463. {
  464. $account_access = $_SESSION["account_access"];
  465. $access = " AND (page_access <= $account_access)";
  466. }
  467. }
  468. $link = connectDB();
  469. $query = "SELECT * FROM ".$db_praefix."page WHERE (page_parent = $page_key) AND (page_status <= ".$account_status.") $access AND (page_start = 0) AND (page_template = '$template') ORDER BY page_order DESC";
  470. $result = mysql_query($query);
  471. closeDB($link);
  472. return $result;
  473. }
  474.  
  475. /**
  476. * returns a recordset of subpages order alphabetic up
  477. * @return resource
  478. */
  479. function get_subpages_key_up($page_key)
  480. {
  481. global $db_praefix;
  482.  
  483. $account_status = 0;
  484. $access = "";
  485. if (empty($_GET["export"]))
  486. {
  487. $account_status = $_SESSION["account_group"];
  488. if ($_SESSION["account_group"] == 1)
  489. {
  490. $account_access = $_SESSION["account_access"];
  491. $access = " AND (page_access <= $account_access)";
  492. }
  493. }
  494. $link = connectDB();
  495. $query = "SELECT * FROM ".$db_praefix."page WHERE (page_parent = $page_key) AND (page_status <= ".$account_status.") $access AND (page_start = 0) ORDER BY page_navigation";
  496. $result = mysql_query($query);
  497. closeDB($link);
  498. return $result;
  499. }
  500.  
  501. /**
  502. * returns a recordset of subpages order alphabetic up
  503. * @return resource
  504. */
  505. function get_subpages_key_down($page_key)
  506. {
  507. global $db_praefix;
  508.  
  509. $account_status = 0;
  510. $access = "";
  511. if (empty($_GET["export"]))
  512. {
  513. $account_status = $_SESSION["account_group"];
  514. if ($_SESSION["account_group"] == 1)
  515. {
  516. $account_access = $_SESSION["account_access"];
  517. $access = " AND (page_access <= $account_access)";
  518. }
  519. }
  520. $link = connectDB();
  521. $query = "SELECT * FROM ".$db_praefix."page WHERE (page_parent = $page_key) AND (page_status <= ".$account_status.") $access AND (page_start = 0) ORDER BY page_navigation DESC";
  522. $result = mysql_query($query);
  523. closeDB($link);
  524. return $result;
  525. }
  526.  
  527. /**
  528. * returns a recordset of subpages limited by a start index and a stepsize
  529. * @return resource
  530. */
  531. function get_subpages_key_limit($page_key,$start,$stepsize)
  532. {
  533. global $db_praefix;
  534.  
  535. $account_status = 0;
  536. $access = "";
  537. if (empty($_GET["export"]))
  538. {
  539. $account_status = $_SESSION["account_group"];
  540. if ($_SESSION["account_group"] == 1)
  541. {
  542. $account_access = $_SESSION["account_access"];
  543. $access = " AND (page_access <= $account_access)";
  544. }
  545. }
  546. $link = connectDB();
  547. $query = "SELECT * FROM ".$db_praefix."page WHERE (page_parent = $page_key) AND (page_status <= ".$account_status.") $access AND (page_start = 0) ORDER BY page_order DESC LIMIT $start, $stepsize";
  548. $result = mysql_query($query);
  549. closeDB($link);
  550. return $result;
  551. }
  552.  
  553. /**
  554. * returns a recordset of subpages orderd by field
  555. * @return resource
  556. */
  557. function get_subpages_alphabetic($page_path,$field)
  558. {
  559. global $db_praefix;
  560.  
  561. $account_status = 0;
  562. $access = "";
  563. if (empty($_GET["export"]))
  564. {
  565. $account_status = $_SESSION["account_group"];
  566. if ($_SESSION["account_group"] == 1)
  567. {
  568. $account_access = $_SESSION["account_access"];
  569. $access = " AND (page_access <= $account_access)";
  570. }
  571. }
  572.  
  573. $page = get_key_path($page_path);
  574. $page_key = $page["page_key"];
  575. $link = connectDB();
  576. $query = "SELECT * FROM ".$db_praefix."page WHERE (page_parent = $page_key) AND (page_status <= ".$account_status.") $access AND (page_start = 0) ORDER BY $field";
  577. $result = mysql_query($query);
  578. closeDB($link);
  579. return $result;
  580. }
  581.  
  582. /**
  583. * returns a searchresult
  584. * @return array
  585. */
  586. function get_searchresult($searchstring,$field_name,$stepsize,$step)
  587. {
  588. global $db_praefix;
  589. $search = array();
  590. $link = connectDB();
  591. $query = "SELECT * FROM ".$db_praefix."page WHERE ($field_name like '%$searchstring%') ORDER BY page_headline";
  592. $result = mysql_query($query);
  593. $maxsearch = mysql_num_rows($result);
  594. $counter = 1;
  595. while ($row = mysql_fetch_array($result))
  596. {
  597. if (($counter >= (($step - 1) * $stepsize)) && ($counter < (($step * $stepsize)) + 1))
  598. {
  599. $search[$counter] = array("search_max" => $maxsearch,"search_counter" => $counter,"page_headline" => $row["page_headline"],"page_title" => $row["page_title"],"page_path" => $row["page_path"],$field_name => $row[$field_name]);
  600. }
  601. $counter++;
  602. }
  603. closeDB($link);
  604. return $search;
  605. }
  606.  
  607. /**
  608. * returns a page by page key
  609. * @return array
  610. */
  611. function get_page_key($page_key)
  612. {
  613. global $db_praefix;
  614.  
  615. $account_status = 0;
  616. $access = "";
  617. if (empty($_GET["export"]))
  618. {
  619. $account_status = $_SESSION["account_group"];
  620. if ($_SESSION["account_group"] == 1)
  621. {
  622. $account_access = $_SESSION["account_access"];
  623. $access = " AND (page_access <= $account_access)";
  624. }
  625. }
  626. $link = connectDB();
  627. $query = "SELECT * FROM ".$db_praefix."page WHERE (page_key = $page_key) AND (page_status <= ".$account_status.") $access";
  628. $result = mysql_query($query);
  629. $menge = mysql_num_fields($result);
  630. $row = mysql_fetch_row ($result);
  631. $page_rows = mysql_num_rows($result);
  632. for($x = 0; $x < $menge; $x++)
  633. {
  634. $page[mysql_field_name($result,$x)] = $row[$x];
  635. }
  636. mysql_free_result($result);
  637. $page["page_rows"] = $page_rows;
  638. if (isset($_GET["template"]))
  639. {
  640. $page["page_template"] = $_GET["template"];
  641. }
  642. closeDB($link);
  643. return $page;
  644. }
  645.  
  646. /**
  647. * returns a homepage
  648. * @return array
  649. */
  650. function get_homepage($page_start)
  651. {
  652. global $db_praefix;
  653. $account_status = 0;
  654. $access = "";
  655. if (empty($_GET["export"]))
  656. {
  657. $account_status = $_SESSION["account_group"];
  658. if ($_SESSION["account_group"] == 1)
  659. {
  660. $account_access = $_SESSION["account_access"];
  661. $access = " AND (page_access <= $account_access)";
  662. }
  663. }
  664.  
  665. $link = connectDB();
  666. $homepage = array();
  667. $query = "SELECT * FROM ".$db_praefix."page WHERE (page_key = $page_start) AND (page_status <= ".$account_status.") $access";
  668. $result = mysql_query($query);
  669. $menge = mysql_num_fields($result);
  670. $row = mysql_fetch_row ($result);
  671. $page_rows = mysql_num_rows($result);
  672. for($x = 0; $x < $menge; $x++)
  673. {
  674. $homepage[mysql_field_name($result,$x)] = $row[$x];
  675. }
  676. mysql_free_result($result);
  677. closeDB($link);
  678. return $homepage;
  679. }
  680.  
  681. /**
  682. * returns all start sites
  683. * @return resource
  684. */
  685. function get_homepages()
  686. {
  687. global $db_praefix;
  688. $account_status = 0;
  689. $access = "";
  690. if (empty($_GET["export"]))
  691. {
  692. $account_status = $_SESSION["account_group"];
  693. if ($_SESSION["account_group"] == 1)
  694. {
  695. $account_access = $_SESSION["account_access"];
  696. $access = " AND (page_access <= $account_access)";
  697. }
  698. }
  699.  
  700. $link = connectDB();
  701. $query = "SELECT * FROM ".$db_praefix."page WHERE ((page_start = 1) OR (page_parent = 0)) AND (page_status <= ".$account_status.") $access";
  702. $result = mysql_query($query);
  703. closeDB($link);
  704. return $result;
  705.  
  706. }
  707.  
  708. /**
  709. * returns the path navigation
  710. * @return array
  711. */
  712. function get_path($url_mode)
  713. {
  714. global $db_praefix,$page;
  715. $path = array();
  716. $external = 0;
  717. $account_status = 0;
  718. $access = "";
  719. $link = connectDB();
  720. if (empty($_GET["export"]))
  721. {
  722. $path_url = "website.php?id=".$page["page_path"];
  723. }
  724. else
  725. {
  726. $path_url = getFile($page["page_path"]);
  727. }
  728. $path[0] = array("current" => "1","external" => "0","page_lang" => $page["page_lang"],"page_key" => $page["page_key"],"page_headline" => $page["page_headline"],"page_navigation" => $page["page_navigation"],"page_title" => $page["page_title"],"page_path" => $path_url,"page_template" => $page["page_template"]);
  729. $counter = 1;
  730. $page_parent = $page["page_parent"];
  731. $page_start = $page["page_start"];
  732. while (($page_parent != 0) && ($page_start != 1))
  733. {
  734. $query = "SELECT * FROM ".$db_praefix."page WHERE (page_key = $page_parent)";
  735. $result = mysql_query($query);
  736. $row = mysql_fetch_array($result);
  737. if (($row["page_extern"] != "") && ($_SESSION["account_group"] < 2))
  738. {
  739. $link_path = $row["page_extern"];
  740. $external = 1;
  741. }
  742. else
  743. {
  744. if (empty($_GET["export"]))
  745. {
  746. $link_path = "website.php?id=".$row["page_path"];
  747. }
  748. else
  749. {
  750. $link_path = getFile($row["page_path"]);
  751. }
  752. }
  753. if ($row["page_status"] <= $_SESSION["account_group"])
  754. {
  755. if (($_SESSION["account_group"] == 1) && ($row["page_access"] > $_SESSION["account_access"]))
  756. {
  757. }
  758. else
  759. {
  760. $path[$counter] = array("current" => "0","external" => $external,"page_lang" => $row["page_lang"],"page_key" => $row["page_key"],"page_headline" => $row["page_headline"],"page_navigation" => $row["page_navigation"],"page_title" => $row["page_title"],"page_path" => $link_path,"page_template" => $row["page_template"]);
  761. }
  762. }
  763. $counter++;
  764. $page_parent = $row["page_parent"];
  765. $page_start = $row["page_start"];
  766. mysql_free_result($result);
  767. }
  768. $path = array_reverse($path);
  769. closeDB($link);
  770. return $path;
  771. }
  772.  
  773. /**
  774. * returns the primary navigation
  775. * @return array
  776. */
  777. function get_primary($path,$prim_key,$url_mode)
  778. {
  779. global $db_praefix;
  780. $link = connectDB();
  781. $external = 0;
  782. $primary = array();
  783.  
  784. $account_status = 0;
  785. $access = "";
  786. if (empty($_GET["export"]))
  787. {
  788. $account_status = $_SESSION["account_group"];
  789. if ($_SESSION["account_group"] == 1)
  790. {
  791. $account_access = $_SESSION["account_access"];
  792. $access = " AND (page_access <= $account_access)";
  793. }
  794. }
  795.  
  796. if (sizeof($path) > 1)
  797. {
  798. $primarytemp = $path[1];
  799. $page_keycurrent = $primarytemp["page_key"];
  800. $query = "SELECT * FROM ".$db_praefix."page WHERE page_parent = $prim_key AND (page_status <= ".$account_status.") $access AND (page_start = 0) ORDER BY page_order DESC";
  801. $result = mysql_query($query);
  802. $counter = 0;
  803. while ($row = mysql_fetch_array ($result))
  804. {
  805. if ($row["page_hide"] == 0)
  806. {
  807. if (($row["page_extern"] != "") && ($_SESSION["account_group"] < 2))
  808. {
  809. $link_path = $row["page_extern"];
  810. $external = 1;
  811. }
  812. else
  813. {
  814. if (empty($_GET["export"]))
  815. {
  816. $link_path = "website.php?id=".$row["page_path"];
  817. }
  818. else
  819. {
  820. $link_path = getFile($row["page_path"]);
  821. }
  822. }
  823. if ($page_keycurrent == $row["page_key"])
  824. {
  825. $primary[$counter] = array("current" => "1","external" => $external,"page_key" => $row["page_key"],"page_headline" => $row["page_headline"],"page_navigation" => $row["page_navigation"],"page_title" => $row["page_title"],"page_path" => $link_path,"page_att1" => $row["page_att1"],"page_att2" => $row["page_att2"],"page_template" => $row["page_template"]);
  826. }
  827. else
  828. {
  829. $primary[$counter] = array("current" => "0","external" => $external,"page_key" => $row["page_key"],"page_headline" => $row["page_headline"],"page_navigation" => $row["page_navigation"],"page_title" => $row["page_title"],"page_path" => $link_path,"page_att1" => $row["page_att1"],"page_att2" => $row["page_att2"],"page_template" => $row["page_template"]);
  830. }
  831. $counter++;
  832. }
  833. }
  834. mysql_free_result($result);
  835. }
  836. else
  837. {
  838. $query = "SELECT * FROM ".$db_praefix."page WHERE page_parent = $prim_key AND (page_status <= ".$account_status.") $access AND (page_start = 0) ORDER BY page_order DESC";
  839. $result = mysql_query($query);
  840. $counter = 0;
  841. while ($row = mysql_fetch_array ($result))
  842. {
  843. if ($row["page_hide"] == 0)
  844. {
  845. if (($row["page_extern"] != "") && ($_SESSION["account_group"] < 2))
  846. {
  847. $link_path = $row["page_extern"];
  848. $external = 1;
  849. }
  850. else
  851. {
  852. if (empty($_GET["export"]))
  853. {
  854. $link_path = "website.php?id=".$row["page_path"];
  855. }
  856. else
  857. {
  858. $link_path = getFile($row["page_path"]);
  859. }
  860. }
  861. $primary[$counter] = array("current" => "0","external" => $external,"page_key" => $row["page_key"],"page_headline" => $row["page_headline"],"page_navigation" => $row["page_navigation"],"page_title" => $row["page_title"],"page_path" => $link_path,"page_att1" => $row["page_att1"],"page_att2" => $row["page_att2"],"page_template" => $row["page_template"]);
  862. $counter++;
  863. }
  864. }
  865. mysql_free_result($result);
  866. }
  867. closeDB($link);
  868. return $primary;
  869. }
  870.  
  871. /**
  872. * returns the siblings navigation
  873. * @return array
  874. */
  875. function get_siblings($page,$url_mode)
  876. {
  877. global $db_praefix;
  878. $external = 0;
  879. $account_status = 0;
  880. $access = "";
  881. if (empty($_GET["export"]))
  882. {
  883. $account_status = $_SESSION["account_group"];
  884. if ($_SESSION["account_group"] == 1)
  885. {
  886. $account_access = $_SESSION["account_access"];
  887. $access = " AND (page_access <= $account_access)";
  888. }
  889. }
  890. $siblings = array();
  891. if (($page["page_start"] == 0) && ($page["page_parent"] != 0))
  892. {
  893. $link = connectDB();
  894. $page_parent = $page["page_parent"];
  895. $query = "SELECT * FROM ".$db_praefix."page WHERE page_parent = $page_parent AND (page_status <= ".$account_status.") $access AND (page_start = 0) ORDER BY page_order DESC";
  896. $result = mysql_query($query);
  897. $counter = 0;
  898. while ($row = mysql_fetch_array ($result))
  899. {
  900. if ($row["page_hide"] == 0)
  901. {
  902. if (($row["page_extern"] != "") && ($_SESSION["account_group"] < 2))
  903. {
  904. $link_path = $row["page_extern"];
  905. $external = 1;
  906. }
  907. else
  908. {
  909. if (empty($_GET["export"]))
  910. {
  911. $link_path = "website.php?id=".$row["page_path"];
  912. }
  913. else
  914. {
  915. $link_path = getFile($row["page_path"]);
  916. }
  917. }
  918. if ($page["page_key"] == $row["page_key"])
  919. {
  920. $siblings[$counter] = array("current" => "1","external" => $external,"page_key" => $row["page_key"],"page_headline" => $row["page_headline"],"page_navigation" => $row["page_navigation"],"page_title" => $row["page_title"],"page_path" => $link_path,"page_att1" => $row["page_att1"],"page_att2" => $row["page_att2"],"page_template" => $row["page_template"]);
  921. }
  922. else
  923. {
  924. $siblings[$counter] = array("current" => "0","external" => $external,"page_key" => $row["page_key"],"page_headline" => $row["page_headline"],"page_navigation" => $row["page_navigation"],"page_title" => $row["page_title"],"page_path" => $link_path,"page_att1" => $row["page_att1"],"page_att2" => $row["page_att2"],"page_template" => $row["page_template"]);
  925. }
  926. $counter++;
  927. }
  928. }
  929. mysql_free_result($result);
  930. closeDB($link);
  931. }
  932. return $siblings;
  933. }
  934.  
  935. /**
  936. * returns the children navigation
  937. * @return array
  938. */
  939. function get_childs($page_key,$url_mode)
  940. {
  941. global $db_praefix;
  942. $external = 0;
  943. $account_status = 0;
  944. $access = "";
  945. if (empty($_GET["export"]))
  946. {
  947. $account_status = $_SESSION["account_group"];
  948. if ($_SESSION["account_group"] == 1)
  949. {
  950. $account_access = $_SESSION["account_access"];
  951. $access = " AND (page_access <= $account_access)";
  952. }
  953. }
  954.  
  955. $childs = array();
  956. $link = connectDB();
  957. $query = "SELECT * FROM ".$db_praefix."page WHERE page_parent = $page_key AND (page_status <= ".$account_status.") AND (page_start = 0) $access ORDER BY page_order DESC";
  958. $result = mysql_query($query);
  959. $counter = 0;
  960. while ($row = mysql_fetch_array ($result))
  961. {
  962. if ($row["page_hide"] == 0)
  963. {
  964. if (($row["page_extern"] != "") && ($_SESSION["account_group"] < 2))
  965. {
  966. $link_path = $row["page_extern"];
  967. $external = 1;
  968. }
  969. else
  970. {
  971. if (empty($_GET["export"]))
  972. {
  973. $link_path = "website.php?id=".$row["page_path"];
  974. }
  975. else
  976. {
  977. $link_path = getFile($row["page_path"]);
  978. }
  979. }
  980. $childs[$counter] = array("current" => "0","external" => $external,"page_key" => $row["page_key"],"page_headline" => $row["page_headline"],"page_navigation" => $row["page_navigation"],"page_title" => $row["page_title"],"page_path" => $link_path,"page_att1" => $row["page_att1"],"page_att2" => $row["page_att2"],"page_template" => $row["page_template"]);
  981. $counter++;
  982. }
  983. }
  984. mysql_free_result($result);
  985. closeDB($link);
  986. return $childs;
  987. }
  988.  
  989. /**
  990. * writes a required javascript
  991. */
  992. function writeRequire($formName,$fields)
  993. {
  994. global $db_praefix,$admin_lang;
  995. echo "function checkInput() {";
  996. $strg = "if (";
  997. $counter = 0;
  998. foreach ($fields as $field)
  999. {
  1000. $counter = $counter + 1;
  1001. $strg = $strg. "(document.".$formName.".".$field.".value != '')";
  1002. if ($counter < sizeof($fields))
  1003. {
  1004. $strg = $strg." && ";
  1005. }
  1006. }
  1007. $strg = $strg.")";
  1008. echo $strg;
  1009. echo "{ document.".$formName.".submit(); } else { alert ('".$admin_lang["profile"][3]."') }}";
  1010. }
  1011.  
  1012. /**
  1013. * returns the status name by status key
  1014. * @return string
  1015. */
  1016. function getStatus($page_status)
  1017. {
  1018. switch ($page_status)
  1019. {
  1020. case "0":
  1021. return "Released";
  1022. break;
  1023. case "1":
  1024. return "Registered User";
  1025. break;
  1026. case "2":
  1027. return "Locked";
  1028. break;
  1029. }
  1030. }
  1031.  
  1032. /**
  1033. * returns all language packs
  1034. * @return resource
  1035. */
  1036. function get_langs()
  1037. {
  1038. global $db_praefix;
  1039. $link = connectDB();
  1040. $query = "SELECT * FROM ".$db_praefix."language ORDER BY lang_short";
  1041. $result = mysql_query($query);
  1042. closeDB($link);
  1043. return $result;
  1044. }
  1045.  
  1046. /**
  1047. * returns all templates
  1048. * @return resource
  1049. */
  1050. function get_templates()
  1051. {
  1052. global $db_praefix;
  1053. $link = connectDB();
  1054. $query = "SELECT * FROM ".$db_praefix."template ORDER BY template_short";
  1055. $result = mysql_query($query);
  1056. closeDB($link);
  1057. return $result;
  1058. }
  1059.  
  1060. /**
  1061. * returns a template by template key
  1062. * @return resource
  1063. */
  1064. function get_template($template_key)
  1065. {
  1066. global $db_praefix;
  1067. $link = connectDB();
  1068. $query = "SELECT * FROM ".$db_praefix."template WHERE template_key = $template_key";
  1069. $result = mysql_query($query);
  1070. closeDB($link);
  1071. return $result;
  1072. }
  1073.  
  1074. /**
  1075. * returns a template by template key
  1076. * @return resource
  1077. */
  1078. function get_template_page($template_key)
  1079. {
  1080. global $db_praefix;
  1081. $link = connectDB();
  1082. $query = "SELECT * FROM ".$db_praefix."template WHERE template_key = $template_key";
  1083. $result = mysql_query($query);
  1084. $template = mysql_fetch_array($result);
  1085. $template_name = $template["template_name"];
  1086. $query = "SELECT * FROM ".$db_praefix."page WHERE page_template = '$template_name'";
  1087. $result = mysql_query($query);
  1088. closeDB($link);
  1089. return $result;
  1090. }
  1091.  
  1092. /**
  1093. * returns the content of template select
  1094. * @return string
  1095. */
  1096. function get_templateselect($template_name)
  1097. {
  1098. global $db_praefix;
  1099. $link = connectDB();
  1100. $query = "SELECT * FROM ".$db_praefix."template WHERE template_name = '$template_name'";
  1101. $result = mysql_query($query);
  1102. closeDB($link);
  1103. $templateselect = mysql_fetch_array($result);
  1104. return $templateselect["template_select"];
  1105. }
  1106.  
  1107. /**
  1108. * returns all attributes
  1109. * @return resource
  1110. */
  1111. function get_attributes()
  1112. {
  1113. global $db_praefix;
  1114. $link = connectDB();
  1115. $query = "SELECT * FROM ".$db_praefix."attribute ORDER BY att_name";
  1116. $result = mysql_query($query);
  1117. closeDB($link);
  1118. return $result;
  1119. }
  1120.  
  1121. /**
  1122. * returns an attribute by attribute key
  1123. * @return resource
  1124. */
  1125. function get_attribute($att_key)
  1126. {
  1127. global $db_praefix;
  1128. $link = connectDB();
  1129. $query = "SELECT * FROM ".$db_praefix."attribute WHERE att_key = $att_key";
  1130. $result = mysql_query($query);
  1131. closeDB($link);
  1132. return $result;
  1133. }
  1134.  
  1135. /**
  1136. * returns all user groups
  1137. * @return resource
  1138. */
  1139. function get_groups()
  1140. {
  1141. global $db_praefix;
  1142. $link = connectDB();
  1143. $query = "SELECT * FROM ".$db_praefix."group ORDER BY group_order DESC";
  1144. $result = mysql_query($query);
  1145. closeDB($link);
  1146. return $result;
  1147. }
  1148.  
  1149. /**
  1150. * returns a user group by group key
  1151. * @return resource
  1152. */
  1153. function get_group($group_key)
  1154. {
  1155. global $db_praefix;
  1156. $link = connectDB();
  1157. $query = "SELECT * FROM ".$db_praefix."group WHERE group_key = $group_key";
  1158. $result = mysql_query($query);
  1159. closeDB($link);
  1160. return $result;
  1161. }
  1162.  
  1163. /**
  1164. * returns all replacings for export
  1165. * @return resource
  1166. */
  1167. function get_replacings()
  1168. {
  1169. global $db_praefix;
  1170. $link = connectDB();
  1171. $query = "SELECT * FROM ".$db_praefix."replacing ORDER BY re_name";
  1172. $result = mysql_query($query);
  1173. closeDB($link);
  1174. return $result;
  1175. }
  1176.  
  1177. /**
  1178. * returns a replacing by replacing key
  1179. * @return resource
  1180. */
  1181. function get_replacing($re_key)
  1182. {
  1183. global $db_praefix;
  1184. $link = connectDB();
  1185. $query = "SELECT * FROM ".$db_praefix."replacing WHERE re_key = $re_key";
  1186. $result = mysql_query($query);
  1187. closeDB($link);
  1188. return $result;
  1189. }
  1190.  
  1191. /**
  1192. * returns all export folders
  1193. * @return resource
  1194. */
  1195. function get_exportfolders()
  1196. {
  1197. global $db_praefix;
  1198. $link = connectDB();
  1199. $query = "SELECT page_key,page_path,page_title,page_exportfolder FROM ".$db_praefix."page WHERE page_start = 1 ORDER BY page_title";
  1200. $result = mysql_query($query);
  1201. closeDB($link);
  1202. return $result;
  1203. }
  1204.  
  1205. /**
  1206. * returns a export folder by folder key
  1207. * @return resource
  1208. */
  1209. function get_exportfolder($page_key)
  1210. {
  1211. global $db_praefix;
  1212. $link = connectDB();
  1213. $query = "SELECT page_key,page_title,page_exportfolder FROM ".$db_praefix."page WHERE page_key = $page_key";
  1214. $result = mysql_query($query);
  1215. closeDB($link);
  1216. return $result;
  1217. }
  1218.  
  1219. /**
  1220. * returns all accounts
  1221. * @return resource
  1222. */
  1223. function get_accounts()
  1224. {
  1225. global $db_praefix;
  1226. $link = connectDB();
  1227. $query = "SELECT * FROM ".$db_praefix."account WHERE (account_group != 0) ORDER BY account_lastname";
  1228. $result = mysql_query($query);
  1229. closeDB($link);
  1230. return $result;
  1231. }
  1232.  
  1233. /**
  1234. * returns all active accounts of the group registered users
  1235. * @return resource
  1236. */
  1237. function get_freeaccounts()
  1238. {
  1239. global $db_praefix;
  1240. $link = connectDB();
  1241. $query = "SELECT * FROM ".$db_praefix."account WHERE (account_group = 1) AND (account_lock = 0) ORDER BY account_lastname";
  1242. $result = mysql_query($query);
  1243. closeDB($link);
  1244. return $result;
  1245. }
  1246.  
  1247. /**
  1248. * returns all active authors and administrators
  1249. * @return resource
  1250. */
  1251. function get_adminaccounts()
  1252. {
  1253. global $db_praefix;
  1254. $link = connectDB();
  1255. $query = "SELECT * FROM ".$db_praefix."account WHERE (account_group != 1) AND (account_group != 0) AND (account_lock = 0) ORDER BY account_lastname";
  1256. $result = mysql_query($query);
  1257. closeDB($link);
  1258. return $result;
  1259. }
  1260.  
  1261. /**
  1262. * returns all active accounts with newsletter flag
  1263. * @return resource
  1264. */
  1265. function get_infoaccounts()
  1266. {
  1267. global $db_praefix;
  1268. $link = connectDB();
  1269. $query = "SELECT * FROM ".$db_praefix."account WHERE (account_group != 0) AND (account_lock = 0) AND (account_info = 1) ORDER BY account_lastname";
  1270. $result = mysql_query($query);
  1271. closeDB($link);
  1272. return $result;
  1273. }
  1274.  
  1275. /**
  1276. * returns a account search result
  1277. * @return resource
  1278. */
  1279. function search_accounts($accounts_lastname,$accounts_email,$accounts_group)
  1280. {
  1281. global $db_praefix;
  1282. $link = connectDB();
  1283. $query = "SELECT * FROM ".$db_praefix."account WHERE (account_lastname like '$accounts_lastname%') AND (account_email like '%$accounts_email%') AND (account_group = $accounts_group) ORDER BY account_lastname";
  1284. $result = mysql_query($query);
  1285. closeDB($link);
  1286. return $result;
  1287. }
  1288.  
  1289. /**
  1290. * updates an account record
  1291. */
  1292. function updateAccount($page_key,$accountn_key,$accountn_email,$accountn_password,$accountn_firstname,$accountn_lastname,$accountn_telefon,$accountn_company,$accountn_homepage,$accountn_group,$accountn_lock,$accountn_info,$accountn_lang,$accountn_editor,$accountn_access,$accountn_menu)
  1293. {
  1294. global $db_praefix;
  1295. $link = connectDB();
  1296. if ($accountn_password != "")
  1297. {
  1298. $accountn_password = md5($accountn_password);
  1299. $query = "UPDATE ".$db_praefix."account SET account_password = '$accountn_password' WHERE account_key = $accountn_key";
  1300. $result = mysql_query($query);
  1301. }
  1302. $query = "UPDATE ".$db_praefix."account SET account_email = '$accountn_email', account_firstname = '$accountn_firstname', account_lastname = '$accountn_lastname', account_telefon = '$accountn_telefon', account_company = '$accountn_company', account_lang = '$accountn_lang', account_homepage = '$accountn_homepage', account_group = $accountn_group, account_lock = $accountn_lock, account_info = $accountn_info, account_editor = '$accountn_editor', account_access = $accountn_access, account_menu = $accountn_menu WHERE account_key = $accountn_key";
  1303. $result = mysql_query($query);
  1304. closeDB($link);
  1305. $pagekey = get_page_key($page_key);
  1306. ?>
  1307. <script language="JavaScript">
  1308. location.href = "website.php?id=<?= $pagekey["page_path"]; ?>&admin=accounts";
  1309. </script>
  1310. <?
  1311. }
  1312.  
  1313. /**
  1314. * returns an account by accout key
  1315. * @return resource
  1316. */
  1317. function get_account($account_key)
  1318. {
  1319. global $db_praefix;
  1320. $link = connectDB();
  1321. $query = "SELECT * FROM ".$db_praefix."account WHERE account_key = $account_key";
  1322. $result = mysql_query($query);
  1323. closeDB($link);
  1324. return $result;
  1325. }
  1326.  
  1327. /**
  1328. * inserts an account record
  1329. */
  1330. function addAccount($page_key,$accountn_email,$accountn_password,$accountn_firstname,$accountn_lastname,$accountn_telefon,$accountn_company,$accountn_group,$accountn_lock)
  1331. {
  1332. global $db_praefix;
  1333. $link = connectDB();
  1334. $query = "SELECT * FROM ".$db_praefix."account WHERE account_email = '$accountn_email'";
  1335. $result2 = mysql_query($query);
  1336. closeDB($link);
  1337.  
  1338. if (mysql_num_rows($result2) == 0)
  1339. {
  1340. $accountn_password = md5($accountn_password);
  1341. $link = connectDB();
  1342. $query = "INSERT ".$db_praefix."account (account_email,account_password,account_firstname,account_lastname,account_telefon,account_company,account_group,account_lock) VALUES ('$accountn_email','$accountn_password','$accountn_firstname','$accountn_lastname','$accountn_telefon','$accountn_company','$accountn_group','$accountn_lock')";
  1343. $result = mysql_query($query);
  1344. closeDB($link);
  1345. $pagekey = get_page_key($page_key);
  1346. ?>
  1347. <script language="JavaScript">
  1348. location.href = "website.php?id=<?= $pagekey["page_path"]; ?>&admin=accounts";
  1349. </script>
  1350. <?
  1351. }
  1352. else
  1353. {
  1354. ?>
  1355. <script language="JavaScript">
  1356. alert("Username exists!");
  1357. location.href = "website.php?id=<?= $pagekey["page_path"]; ?>&admin=accounts&action=addaccount";
  1358. </script>
  1359. <?
  1360. }
  1361. }
  1362.  
  1363. /**
  1364. * deletes an account record
  1365. */
  1366. function deleteAccount($account_key)
  1367. {
  1368. global $db_praefix;
  1369. $link = connectDB();
  1370. $query = "DELETE FROM ".$db_praefix."account WHERE account_key = $account_key";
  1371. $result = mysql_query($query);
  1372. closeDB($link);
  1373. }
  1374.  
  1375. /**
  1376. * updates a content of a page
  1377. */
  1378. function updateText($page_key,$page_edit,$page_input)
  1379. {
  1380. global $db_praefix,$site_url,$site_staging,$site_admin;
  1381. $link = connectDB();
  1382. $page_input = ereg_replace($site_url."/","",$page_input);
  1383. $page_input = ereg_replace("<oe:site_url/>",$site_url, $page_input);
  1384. $page_input = ereg_replace("<oe:site_admin/>",$site_admin, $page_input);
  1385. if ($site_staging == 0)
  1386. {
  1387. $query = "UPDATE ".$db_praefix."page SET $page_edit = '$page_input' WHERE page_key = $page_key";
  1388. $result = mysql_query($query);
  1389. }
  1390. else
  1391. {
  1392. $query = "SELECT stage_key FROM ".$db_praefix."stage WHERE stage_edit = '$page_edit' AND page_key = $page_key";
  1393. $result = mysql_query($query);
  1394. if (mysql_num_rows($result) == 0)
  1395. {
  1396. $query = "INSERT ".$db_praefix."stage (page_key,stage_edit,stage_input) VALUES ('$page_key','$page_edit','$page_input')";
  1397. $result = mysql_query($query);
  1398. }
  1399. else
  1400. {
  1401. $query = "UPDATE ".$db_praefix."stage SET stage_input = '$page_input' WHERE stage_edit = '$page_edit' AND page_key = $page_key";
  1402. $result = mysql_query($query);
  1403. }
  1404. }
  1405. closeDB($link);
  1406. $pagekey = get_page_key($page_key);
  1407. ?>
  1408. <script language="JavaScript">
  1409. window.opener.location.href = "website.php?id=<?= $pagekey["page_path"]; ?>";
  1410. window.close();
  1411. </script>
  1412. <?
  1413. }
  1414.  
  1415. /**
  1416. * updates a content of a page
  1417. */
  1418. function updateTextNoCache($page_key,$page_edit,$page_input)
  1419. {
  1420. global $db_praefix,$site_url,$site_staging,$site_admin;
  1421. $link = connectDB();
  1422. $page_input = ereg_replace($site_url."/","",$page_input);
  1423. $page_input = ereg_replace("'","&#039;", $page_input);
  1424. $query = "UPDATE ".$db_praefix."page SET $page_edit = '$page_input' WHERE page_key = $page_key";
  1425. $result = mysql_query($query);
  1426. closeDB($link);
  1427. $pagekey = get_page_key($page_key);
  1428. $pageparent = get_page_key($pagekey["page_parent"]);
  1429. ?>
  1430. <script language="JavaScript">
  1431. window.opener.location.href = "website.php?id=<?= $pageparent["page_path"]; ?>";
  1432. window.close();
  1433. </script>
  1434. <?
  1435. }
  1436.  
  1437. /**
  1438. * returns the next navigation
  1439. * @return array
  1440. */
  1441. function nextpage()
  1442. {
  1443. global $db_praefix,$page;
  1444. $account_status = 0;
  1445. $access = "";
  1446. if (empty($_GET["export"]))
  1447. {
  1448. $account_status = $_SESSION["account_group"];
  1449. if ($_SESSION["account_group"] == 1)
  1450. {
  1451. $account_access = $_SESSION["account_access"];
  1452. $access = " AND (page_access <= $account_access)";
  1453. }
  1454. }
  1455. $link = connectDB();
  1456. $parent_key = $page["page_parent"];
  1457. $page_order = $page["page_order"] - 1;
  1458. $query = "SELECT * FROM ".$db_praefix."page WHERE (page_parent = $parent_key) AND (page_order = $page_order) AND (page_status <= ".$account_status.") $access AND (page_start = 0)";
  1459. $result = mysql_query($query);
  1460. closeDB($link);
  1461. $next_array = mysql_fetch_array($result);
  1462. return $next_array;
  1463. }
  1464.  
  1465. /**
  1466. * returns the back navigation
  1467. * @return array
  1468. */
  1469. function backpage()
  1470. {
  1471. global $db_praefix,$page;
  1472. $account_status = 0;
  1473. $access = "";
  1474. if (empty($_GET["export"]))
  1475. {
  1476. $account_status = $_SESSION["account_group"];
  1477. if ($_SESSION["account_group"] == 1)
  1478. {
  1479. $account_access = $_SESSION["account_access"];
  1480. $access = " AND (page_access <= $account_access)";
  1481. }
  1482. }
  1483. $link = connectDB();
  1484. $parent_key = $page["page_parent"];
  1485. $page_order = $page["page_order"] + 1;
  1486. $query = "SELECT * FROM ".$db_praefix."page WHERE (page_parent = $parent_key) AND (page_order = $page_order) AND (page_status <= ".$account_status.") $access AND (page_start = 0)";
  1487. $result = mysql_query($query);
  1488. closeDB($link);
  1489. $back_array = mysql_fetch_array($result);
  1490. return $back_array;
  1491. }
  1492.  
  1493. /**
  1494. * writes admin log in folder /logfiles
  1495. */
  1496. function writeLog($log_user,$log_action,$log_page)
  1497. {
  1498. global $log_path;
  1499. if ($log_path != "")
  1500. {
  1501. $log_time = date("ymdhis");
  1502. $log_file = $log_path."/admin_log.csv";
  1503. $fp = fopen($log_file,"a");
  1504. $log_text = $log_user.";".$log_action.";".$log_page.";".$log_time."\n";
  1505. fputs($fp,$log_text);
  1506. fclose($fp);
  1507. }
  1508. }
  1509.  
  1510. /**
  1511. * returns string pool value
  1512. * @return string
  1513. */
  1514. function stringpool($name,$select)
  1515. {
  1516. global $db_praefix;
  1517. $link = connectDB();
  1518. $query = "SELECT * FROM ".$db_praefix."stringpool WHERE str_name = '$name' AND str_select = '$select'";
  1519. $result = mysql_query($query);
  1520. if (mysql_num_rows($result) == 0)
  1521. {
  1522. return "";
  1523. }
  1524. else
  1525. {
  1526. $stringpool_arr = mysql_fetch_array($result);
  1527. return $stringpool_arr["str_value"];
  1528. }
  1529. closeDB($link);
  1530. }
  1531.  
  1532. /**
  1533. * check if $page_parent is a parent page of the current page
  1534. * @return bool
  1535. */
  1536. function isParent($parent_key)
  1537. {
  1538. global $path;
  1539. $isParent = false;
  1540. if (isset($path))
  1541. {
  1542. foreach ($path as $value)
  1543. {
  1544. if ($value["page_key"] == $parent_key)
  1545. {
  1546. $isParent = true;
  1547. }
  1548. }
  1549. }
  1550. return $isParent;
  1551. }
  1552. ?>

Documentation generated on Tue, 04 Oct 2005 11:13:37 +0200 by phpDocumentor 1.3.0RC3