Documentation is available at admin.php
- <?
- /**
- * admin.php
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- * @author Stephan Raabe
- */
- /**
- * Writes a cancel button
- */
- function writeCancel($link)
- {
- echo '<input style="background-image:url(system/admin/img/oes_cancelback.png);background-repeat:no-repeat;" type="button" value="Cancel" class="adminsubmitbtn" onclick="'.$link.'">';
- }
- /**
- * Writes an OK button
- */
- function writeOk($link)
- {
- echo '<input style="background-image:url(system/admin/img/oes_okback.png);background-repeat:no-repeat;" type="button" value="Ok" class="adminsubmitbtn" onclick="'.$link.'">';
- }
- /**
- * Writes a back button
- */
- function writeBack($link)
- {
- echo '<input style="background-image:url(system/admin/img/oes_backback.png);background-repeat:no-repeat;" type="button" value="Back" class="adminsubmitbtn" onclick="'.$link.'">';
- }
- /**
- * Writes a menu item
- */
- function writeOeLink($title,$link,$icon)
- {
- ?>
- <div class="oe_menu_item">
- <div class="icon"><a href="<?= $link; ?>"><img src="system/admin/img/oes_<?= $icon; ?>.png"></a></div>
- <div class="link"><a href="<?= $link; ?>"><?= $title; ?></a></div>
- </div>
- <?
- }
- /**
- * writes the admin menu header
- */
- function getAdminHead($name,$img,$control = "")
- {
- global $admin_lang,$page,$site_help;
- ?>
- <? if ($control == "yes") { ?>
- <link rel="stylesheet" type="text/css" href="system/admin/style/oe_pullmenu.css" />
- <script type="text/javascript" src="system/admin/script/DropDownMenuX.js"></script>
- <div id="oe_menuback"></div>
- <div id="oe_pulldown">
- <table cellspacing="0" cellpadding="0" id="menu1" class="ddmx">
- <tr>
- <td>
- <a class="item1" href="javascript:void(0)">System</a>
- <div class="section">
- <a class="item2" href="website.php?id=<?= $page["page_path"]; ?>&admin=settings"><?= $admin_lang["settings"][1]; ?></a>
- <a class="item2" href="website.php?id=<?= $page["page_path"]; ?>&admin=phpinfo">PHP Info</a>
- <a class="item2" href="website.php?id=<?= $page["page_path"]; ?>&admin=deletecache"><?= $admin_lang["filecache"][1]; ?></a>
- <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>
- <div class="section">
- <a class="item2" href="website.php?id=<?= $page["page_path"]; ?>&admin=stringpool&action=showstringpoolItem"><?= $admin_lang["stringpool"][5]; ?></a>
- </div>
- <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>
- <div class="section">
- <a class="item2" href="website.php?id=<?= $page["page_path"]; ?>&admin=languages&action=showlanguageItem"><?= $admin_lang["table"][23]; ?></a>
- </div>
- </div>
- </td>
- <td>
- <a class="item1" href="javascript:void(0)">Layout</a>
- <div class="section">
- <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>
- <div class="section">
- <a class="item2" href="website.php?id=<?= $page["page_path"]; ?>&admin=templates&action=showtemplateItem"><?= $admin_lang["table"][18]; ?></a>
- </div>
- <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>
- <div class="section">
- <a class="item2" href="website.php?id=<?= $page["page_path"]; ?>&admin=attributes&action=showattributeItem"><?= $admin_lang["table"][19]; ?></a>
- </div>
- <a class="item2" href="website.php?id=<?= $page["page_path"]; ?>&admin=edit/css">Editor CSS</a>
- </div>
- </td>
- <td>
- <a class="item1" href="javascript:void(0)"><?= $admin_lang["admin"][5]; ?></a>
- <div class="section">
- <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>
- <div class="section">
- <a class="item2" href="website.php?id=<?= $page["page_path"]; ?>&admin=accounts&action=showaccountItem"><?= $admin_lang["table"][20]; ?></a>
- </div>
- <a class="item2" href="website.php?id=<?= $page["page_path"]; ?>&admin=statistic"><?= $admin_lang["statistics"][1]; ?></a>
- <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>
- <div class="section">
- <a class="item2" href="website.php?id=<?= $page["page_path"]; ?>&admin=newsletter&action=shownewsletterItem"><?= $admin_lang["table"][21]; ?></a>
- </div>
- <a class="item2" href="website.php?id=<?= $page["page_path"]; ?>&admin=group"><?= $admin_lang["group"][1]; ?></a>
- </div>
- </td>
- <td>
- <a class="item1" href="javascript:void(0)"><?= $admin_lang["admin"][6]; ?></a>
- <div class="section">
- <a class="item2" href="website.php?id=<?= $page["page_path"]; ?>&admin=exporting"><?= $admin_lang["exporting"][1]; ?></a>
- <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>
- <div class="section">
- <a class="item2" href="website.php?id=<?= $page["page_path"]; ?>&admin=replacing&action=showreplacingItem"><?= $admin_lang["table"][22]; ?></a>
- </div>
- </div>
- </td>
- <td>
- <a class="item1" href="javascript:void(0)"><?= $admin_lang["admin"][7]; ?></a>
- <div class="section">
- <a class="item2" href="<?= $site_help; ?>" target="_blank"><?= $admin_lang["admin"][2]; ?></a>
- <a class="item2" href="http://www.openengine.de" target="_blank">openengine.de</a>
- <a class="item2" href="http://www.openengine.de/forum" target="_blank">Forum</a>
- </div>
- </td>
- </tr>
- </table>
- </div>
- <script type="text/javascript">
- var ddmx = new DropDownMenuX('menu1');
- ddmx.delay.show = 0;
- ddmx.delay.hide = 400;
- ddmx.position.levelX.left = 2;
- ddmx.init();
- </script>
- <? } ?>
- <!-- Admin Head START -->
- <div id="oe_head">
- <div class="icon"><img src="system/admin/img/oes_<?= $img; ?>.png" alt="" border="0"></div>
- <div class="text"><?= $name; ?></div>
- </div>
- <!-- Admin Head END -->
- <?
- }
- /**
- * returns the filename of a path
- * @return string
- */
- function getFile($page_file)
- {
- $file_name = ereg_replace("/", "_", $page_file);
- if (substr($file_name, 0, 1) == "_")
- {
- $file_name = substr($file_name, 1);
- }
- return $file_name;
- }
- /**
- * returns the folders of a path
- * @return string
- */
- function getFolder($page_file)
- {
- $folders = explode("/",$page_file);
- $str_folder = "";
- for ($i = 0; $i < sizeof($folders) - 1; $i++)
- {
- $str_folder .= $folders[$i]."/";
- }
- return $str_folder;
- }
- /**
- * checks if a staging textblock of a page is temporaly saved (staging)
- * @return bool
- */
- function isStage($page_key,$block)
- {
- global $site_staging,$db_praefix;
- $link = connectDB();
- $query = "SELECT page_key FROM ".$db_praefix."stage WHERE stage_edit = '$block' AND page_key = $page_key";
- $result = mysql_query($query);
- closeDB($link);
- if (mysql_num_rows($result) == 0)
- {
- return false;
- }
- else
- {
- return true;
- }
- }
- /**
- * checks if a page has a temporaly saved textblock (staging)
- * @return bool
- */
- function isPageStage($page_key)
- {
- global $site_staging,$db_praefix;
- $link = connectDB();
- $query = "SELECT page_key FROM ".$db_praefix."stage WHERE page_key = $page_key";
- $result = mysql_query($query);
- closeDB($link);
- if (mysql_num_rows($result) == 0)
- {
- return false;
- }
- else
- {
- return true;
- }
- }
- /**
- * returns the content of page by textblock definition
- * @return string
- */
- function staging_output($block)
- {
- global $page,$db_praefix;
- $link = connectDB();
- $query = "SELECT stage_input FROM ".$db_praefix."stage WHERE stage_edit = '$block' AND page_key = ".$page["page_key"];
- $result = mysql_query($query);
- closeDB($link);
- if (mysql_num_rows($result) == 0)
- {
- return $page[$block];
- }
- else
- {
- $output = mysql_fetch_array($result);
- return $output["stage_input"];
- }
- }
- /**
- * updates the statistic entry of a page
- */
- function update_statistic($page_key,$page_count)
- {
- global $db_praefix;
- $page_count = $page_count + 1;
- $link = connectDB();
- $query = "UPDATE ".$db_praefix."page SET page_count = $page_count where page_key = $page_key";
- $result = mysql_query($query);
- closeDB($link);
- }
- /**
- * returns a page by path
- * @return array
- */
- function get_page($page_path)
- {
- global $db_praefix;
- $account_status = 0;
- $access = "";
- if (empty($_GET["export"]))
- {
- $account_status = $_SESSION["account_group"];
- if ($_SESSION["account_group"] == 1)
- {
- $account_access = $_SESSION["account_access"];
- $access = " AND (page_access <= $account_access)";
- }
- }
- $link = connectDB();
- $query = "SELECT * FROM ".$db_praefix."page WHERE (page_path = '$page_path') AND (page_status <= ".$account_status.") $access";
- $result = mysql_query($query);
- $menge = mysql_num_fields($result);
- $row = mysql_fetch_row ($result);
- $page_rows = mysql_num_rows($result);
- for($x = 0; $x < $menge; $x++)
- {
- $page[mysql_field_name($result,$x)] = $row[$x];
- }
- mysql_free_result($result);
- $page["page_rows"] = $page_rows;
- if (isset($_GET["template"]))
- {
- $page["page_template"] = $_GET["template"];
- }
- closeDB($link);
- return $page;
- }
- /**
- * returns a page by path
- * @return array
- */
- function get_key_path($page_path)
- {
- global $db_praefix;
- $account_status = 0;
- $access = "";
- if (empty($_GET["export"]))
- {
- $account_status = $_SESSION["account_group"];
- if ($_SESSION["account_group"] == 1)
- {
- $account_access = $_SESSION["account_access"];
- $access = " AND (page_access <= $account_access)";
- }
- }
- $link = connectDB();
- $query = "SELECT * FROM ".$db_praefix."page WHERE (page_path = '$page_path') AND (page_status <= ".$account_status.") $access";
- $result = mysql_query($query);
- $menge = mysql_num_fields($result);
- $row = mysql_fetch_row ($result);
- $page_rows = mysql_num_rows($result);
- for($x = 0; $x < $menge; $x++)
- {
- $page[mysql_field_name($result,$x)] = $row[$x];
- }
- mysql_free_result($result);
- closeDB($link);
- return $page;
- }
- /**
- * returns a recordset of subpages
- * @return resource
- */
- function get_subpages($page_path)
- {
- global $db_praefix;
- $account_status = 0;
- $access = "";
- if (empty($_GET["export"]))
- {
- $account_status = $_SESSION["account_group"];
- if ($_SESSION["account_group"] == 1)
- {
- $account_access = $_SESSION["account_access"];
- $access = " AND (page_access <= $account_access)";
- }
- }
- $page = get_key_path($page_path);
- $page_key = $page["page_key"];
- $link = connectDB();
- $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";
- $result = mysql_query($query);
- closeDB($link);
- return $result;
- }
- /**
- * returns a recordset of subpages order by date
- * @return resource
- */
- function get_subpages_date($page_path,$order)
- {
- global $db_praefix;
- $account_status = 0;
- $access = "";
- if (empty($_GET["export"]))
- {
- $account_status = $_SESSION["account_group"];
- if ($_SESSION["account_group"] == 1)
- {
- $account_access = $_SESSION["account_access"];
- $access = " AND (page_access <= $account_access)";
- }
- }
- $page = get_key_path($page_path);
- $page_key = $page["page_key"];
- $link = connectDB();
- $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";
- $result = mysql_query($query);
- closeDB($link);
- return $result;
- }
- /**
- * returns a recordset of subpages
- * @return resource
- */
- function get_subpages_key($page_key)
- {
- global $db_praefix;
- $account_status = 0;
- $access = "";
- if (empty($_GET["export"]))
- {
- $account_status = $_SESSION["account_group"];
- if ($_SESSION["account_group"] == 1)
- {
- $account_access = $_SESSION["account_access"];
- $access = " AND (page_access <= $account_access)";
- }
- }
- $link = connectDB();
- $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";
- $result = mysql_query($query);
- closeDB($link);
- return $result;
- }
- /**
- * returns a recordset of subpages limited by a start index and a stepsize
- * @return resource
- */
- function get_subpages_key_limit($page_key,$start,$stepsize)
- {
- global $db_praefix;
- $account_status = 0;
- $access = "";
- if (empty($_GET["export"]))
- {
- $account_status = $_SESSION["account_group"];
- if ($_SESSION["account_group"] == 1)
- {
- $account_access = $_SESSION["account_access"];
- $access = " AND (page_access <= $account_access)";
- }
- }
- $link = connectDB();
- $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";
- $result = mysql_query($query);
- closeDB($link);
- return $result;
- }
- /**
- * returns a recordset of subpages orderd by field
- * @return resource
- */
- function get_subpages_alphabetic($page_path,$field)
- {
- global $db_praefix;
- $account_status = 0;
- $access = "";
- if (empty($_GET["export"]))
- {
- $account_status = $_SESSION["account_group"];
- if ($_SESSION["account_group"] == 1)
- {
- $account_access = $_SESSION["account_access"];
- $access = " AND (page_access <= $account_access)";
- }
- }
- $page = get_key_path($page_path);
- $page_key = $page["page_key"];
- $link = connectDB();
- $query = "SELECT * FROM ".$db_praefix."page WHERE (page_parent = $page_key) AND (page_status <= ".$account_status.") $access AND (page_start = 0) ORDER BY $field";
- $result = mysql_query($query);
- closeDB($link);
- return $result;
- }
- /**
- * returns a searchresult
- * @return array
- */
- function get_searchresult($searchstring,$field_name,$stepsize,$step)
- {
- global $db_praefix;
- $search = array();
- $link = connectDB();
- $query = "SELECT * FROM ".$db_praefix."page WHERE ($field_name like '%$searchstring%') ORDER BY page_headline";
- $result = mysql_query($query);
- $maxsearch = mysql_num_rows($result);
- $counter = 1;
- while ($row = mysql_fetch_array($result))
- {
- if (($counter >= (($step - 1) * $stepsize)) && ($counter < (($step * $stepsize)) + 1))
- {
- $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]);
- }
- $counter++;
- }
- closeDB($link);
- return $search;
- }
- /**
- * returns a page by page key
- * @return array
- */
- function get_page_key($page_key)
- {
- global $db_praefix;
- $account_status = 0;
- $access = "";
- if (empty($_GET["export"]))
- {
- $account_status = $_SESSION["account_group"];
- if ($_SESSION["account_group"] == 1)
- {
- $account_access = $_SESSION["account_access"];
- $access = " AND (page_access <= $account_access)";
- }
- }
- $link = connectDB();
- $query = "SELECT * FROM ".$db_praefix."page WHERE (page_key = $page_key) AND (page_status <= ".$account_status.") $access";
- $result = mysql_query($query);
- $menge = mysql_num_fields($result);
- $row = mysql_fetch_row ($result);
- $page_rows = mysql_num_rows($result);
- for($x = 0; $x < $menge; $x++)
- {
- $page[mysql_field_name($result,$x)] = $row[$x];
- }
- mysql_free_result($result);
- $page["page_rows"] = $page_rows;
- if (isset($_GET["template"]))
- {
- $page["page_template"] = $_GET["template"];
- }
- closeDB($link);
- return $page;
- }
- /**
- * returns a homepage
- * @return array
- */
- function get_homepage($page_start)
- {
- global $db_praefix;
- $account_status = 0;
- $access = "";
- if (empty($_GET["export"]))
- {
- $account_status = $_SESSION["account_group"];
- if ($_SESSION["account_group"] == 1)
- {
- $account_access = $_SESSION["account_access"];
- $access = " AND (page_access <= $account_access)";
- }
- }
- $link = connectDB();
- $homepage = array();
- $query = "SELECT * FROM ".$db_praefix."page WHERE (page_key = $page_start) AND (page_status <= ".$account_status.") $access";
- $result = mysql_query($query);
- $menge = mysql_num_fields($result);
- $row = mysql_fetch_row ($result);
- $page_rows = mysql_num_rows($result);
- for($x = 0; $x < $menge; $x++)
- {
- $homepage[mysql_field_name($result,$x)] = $row[$x];
- }
- mysql_free_result($result);
- closeDB($link);
- return $homepage;
- }
- /**
- * returns all start sites
- * @return resource
- */
- function get_homepages()
- {
- global $db_praefix;
- $account_status = 0;
- $access = "";
- if (empty($_GET["export"]))
- {
- $account_status = $_SESSION["account_group"];
- if ($_SESSION["account_group"] == 1)
- {
- $account_access = $_SESSION["account_access"];
- $access = " AND (page_access <= $account_access)";
- }
- }
- $link = connectDB();
- $query = "SELECT * FROM ".$db_praefix."page WHERE ((page_start = 1) OR (page_parent = 0)) AND (page_status <= ".$account_status.") $access";
- $result = mysql_query($query);
- closeDB($link);
- return $result;
- }
- /**
- * returns the path navigation
- * @return array
- */
- function get_path($url_mode)
- {
- global $db_praefix,$page;
- $path = array();
- $external = 0;
- $account_status = 0;
- $access = "";
- if (empty($_GET["export"]))
- {
- $account_status = $_SESSION["account_group"];
- if ($_SESSION["account_group"] == 1)
- {
- $account_access = $_SESSION["account_access"];
- $access = " AND (page_access <= $account_access)";
- }
- }
- $link = connectDB();
- if (empty($_GET["export"]))
- {
- $path_url = "website.php?id=".$page["page_path"];
- }
- else
- {
- $path_url = getFile($page["page_path"]);
- }
- $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"]);
- $counter = 1;
- $page_parent = $page["page_parent"];
- $page_start = $page["page_start"];
- while (($page_parent != 0) && ($page_start != 1))
- {
- $query = "SELECT * FROM ".$db_praefix."page WHERE (page_key = $page_parent) AND (page_status <= ".$account_status.") $access";
- $result = mysql_query($query);
- $row = mysql_fetch_array($result);
- if (($row["page_extern"] != "") && ($_SESSION["account_group"] < 2))
- {
- $link_path = $row["page_extern"];
- $external = 1;
- }
- else
- {
- if (empty($_GET["export"]))
- {
- $link_path = "website.php?id=".$row["page_path"];
- }
- else
- {
- $link_path = getFile($row["page_path"]);
- }
- }
- $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"]);
- $counter++;
- $page_parent = $row["page_parent"];
- $page_start = $row["page_start"];
- mysql_free_result($result);
- }
- $path = array_reverse($path);
- closeDB($link);
- return $path;
- }
- /**
- * returns the primary navigation
- * @return array
- */
- function get_primary($path,$prim_key,$url_mode)
- {
- global $db_praefix;
- $link = connectDB();
- $external = 0;
- $primary = array();
- $account_status = 0;
- $access = "";
- if (empty($_GET["export"]))
- {
- $account_status = $_SESSION["account_group"];
- if ($_SESSION["account_group"] == 1)
- {
- $account_access = $_SESSION["account_access"];
- $access = " AND (page_access <= $account_access)";
- }
- }
- if (sizeof($path) > 1)
- {
- $primarytemp = $path[1];
- $page_keycurrent = $primarytemp["page_key"];
- $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";
- $result = mysql_query($query);
- $counter = 0;
- while ($row = mysql_fetch_array ($result))
- {
- if ($row["page_hide"] == 0)
- {
- if (($row["page_extern"] != "") && ($_SESSION["account_group"] < 2))
- {
- $link_path = $row["page_extern"];
- $external = 1;
- }
- else
- {
- if (empty($_GET["export"]))
- {
- $link_path = "website.php?id=".$row["page_path"];
- }
- else
- {
- $link_path = getFile($row["page_path"]);
- }
- }
- if ($page_keycurrent == $row["page_key"])
- {
- $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"]);
- }
- else
- {
- $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"]);
- }
- $counter++;
- }
- }
- mysql_free_result($result);
- }
- else
- {
- $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";
- $result = mysql_query($query);
- $counter = 0;
- while ($row = mysql_fetch_array ($result))
- {
- if ($row["page_hide"] == 0)
- {
- if (($row["page_extern"] != "") && ($_SESSION["account_group"] < 2))
- {
- $link_path = $row["page_extern"];
- $external = 1;
- }
- else
- {
- if (empty($_GET["export"]))
- {
- $link_path = "website.php?id=".$row["page_path"];
- }
- else
- {
- $link_path = getFile($row["page_path"]);
- }
- }
- $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"]);
- $counter++;
- }
- }
- mysql_free_result($result);
- }
- closeDB($link);
- return $primary;
- }
- /**
- * returns the siblings navigation
- * @return array
- */
- function get_siblings($page,$url_mode)
- {
- global $db_praefix;
- $external = 0;
- $account_status = 0;
- $access = "";
- if (empty($_GET["export"]))
- {
- $account_status = $_SESSION["account_group"];
- if ($_SESSION["account_group"] == 1)
- {
- $account_access = $_SESSION["account_access"];
- $access = " AND (page_access <= $account_access)";
- }
- }
- $siblings = array();
- if (($page["page_start"] == 0) && ($page["page_parent"] != 0))
- {
- $link = connectDB();
- $page_parent = $page["page_parent"];
- $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";
- $result = mysql_query($query);
- $counter = 0;
- while ($row = mysql_fetch_array ($result))
- {
- if ($row["page_hide"] == 0)
- {
- if (($row["page_extern"] != "") && ($_SESSION["account_group"] < 2))
- {
- $link_path = $row["page_extern"];
- $external = 1;
- }
- else
- {
- if (empty($_GET["export"]))
- {
- $link_path = "website.php?id=".$row["page_path"];
- }
- else
- {
- $link_path = getFile($row["page_path"]);
- }
- }
- if ($page["page_key"] == $row["page_key"])
- {
- $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"]);
- }
- else
- {
- $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"]);
- }
- $counter++;
- }
- }
- mysql_free_result($result);
- closeDB($link);
- }
- return $siblings;
- }
- /**
- * returns the children navigation
- * @return array
- */
- function get_childs($page_key,$url_mode)
- {
- global $db_praefix;
- $external = 0;
- $account_status = 0;
- $access = "";
- if (empty($_GET["export"]))
- {
- $account_status = $_SESSION["account_group"];
- if ($_SESSION["account_group"] == 1)
- {
- $account_access = $_SESSION["account_access"];
- $access = " AND (page_access <= $account_access)";
- }
- }
- $childs = array();
- $link = connectDB();
- $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";
- $result = mysql_query($query);
- $counter = 0;
- while ($row = mysql_fetch_array ($result))
- {
- if ($row["page_hide"] == 0)
- {
- if (($row["page_extern"] != "") && ($_SESSION["account_group"] < 2))
- {
- $link_path = $row["page_extern"];
- $external = 1;
- }
- else
- {
- if (empty($_GET["export"]))
- {
- $link_path = "website.php?id=".$row["page_path"];
- }
- else
- {
- $link_path = getFile($row["page_path"]);
- }
- }
- $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"]);
- $counter++;
- }
- }
- mysql_free_result($result);
- closeDB($link);
- return $childs;
- }
- /**
- * writes a required javascript
- */
- function writeRequire($formName,$fields)
- {
- global $db_praefix,$admin_lang;
- echo "function checkInput() {";
- $strg = "if (";
- $counter = 0;
- foreach ($fields as $field)
- {
- $counter = $counter + 1;
- $strg = $strg. "(document.".$formName.".".$field.".value != '')";
- if ($counter < sizeof($fields))
- {
- $strg = $strg." && ";
- }
- }
- $strg = $strg.")";
- echo $strg;
- echo "{ document.".$formName.".submit(); } else { alert ('".$admin_lang["profile"][3]."') }}";
- }
- /**
- * returns the status name by status key
- * @return string
- */
- function getStatus($page_status)
- {
- switch ($page_status)
- {
- case "0":
- return "Released";
- break;
- case "1":
- return "Registered User";
- break;
- case "2":
- return "Locked";
- break;
- }
- }
- /**
- * returns all language packs
- * @return resource
- */
- function get_langs()
- {
- global $db_praefix;
- $link = connectDB();
- $query = "SELECT * FROM ".$db_praefix."language ORDER BY lang_short";
- $result = mysql_query($query);
- closeDB($link);
- return $result;
- }
- /**
- * returns all templates
- * @return resource
- */
- function get_templates()
- {
- global $db_praefix;
- $link = connectDB();
- $query = "SELECT * FROM ".$db_praefix."template ORDER BY template_short";
- $result = mysql_query($query);
- closeDB($link);
- return $result;
- }
- /**
- * returns a template by template key
- * @return resource
- */
- function get_template($template_key)
- {
- global $db_praefix;
- $link = connectDB();
- $query = "SELECT * FROM ".$db_praefix."template WHERE template_key = $template_key";
- $result = mysql_query($query);
- closeDB($link);
- return $result;
- }
- /**
- * returns a template by template key
- * @return resource
- */
- function get_template_page($template_key)
- {
- global $db_praefix;
- $link = connectDB();
- $query = "SELECT * FROM ".$db_praefix."template WHERE template_key = $template_key";
- $result = mysql_query($query);
- $template = mysql_fetch_array($result);
- $template_name = $template["template_name"];
- $query = "SELECT * FROM ".$db_praefix."page WHERE page_template = '$template_name'";
- $result = mysql_query($query);
- closeDB($link);
- return $result;
- }
- /**
- * returns the content of template select
- * @return string
- */
- function get_templateselect($template_name)
- {
- global $db_praefix;
- $link = connectDB();
- $query = "SELECT * FROM ".$db_praefix."template WHERE template_name = '$template_name'";
- $result = mysql_query($query);
- closeDB($link);
- $templateselect = mysql_fetch_array($result);
- return $templateselect["template_select"];
- }
- /**
- * returns all attributes
- * @return resource
- */
- function get_attributes()
- {
- global $db_praefix;
- $link = connectDB();
- $query = "SELECT * FROM ".$db_praefix."attribute ORDER BY att_name";
- $result = mysql_query($query);
- closeDB($link);
- return $result;
- }
- /**
- * returns an attribute by attribute key
- * @return resource
- */
- function get_attribute($att_key)
- {
- global $db_praefix;
- $link = connectDB();
- $query = "SELECT * FROM ".$db_praefix."attribute WHERE att_key = $att_key";
- $result = mysql_query($query);
- closeDB($link);
- return $result;
- }
- /**
- * returns all user groups
- * @return resource
- */
- function get_groups()
- {
- global $db_praefix;
- $link = connectDB();
- $query = "SELECT * FROM ".$db_praefix."group ORDER BY group_order DESC";
- $result = mysql_query($query);
- closeDB($link);
- return $result;
- }
- /**
- * returns a user group by group key
- * @return resource
- */
- function get_group($group_key)
- {
- global $db_praefix;
- $link = connectDB();
- $query = "SELECT * FROM ".$db_praefix."group WHERE group_key = $group_key";
- $result = mysql_query($query);
- closeDB($link);
- return $result;
- }
- /**
- * returns all replacings for export
- * @return resource
- */
- function get_replacings()
- {
- global $db_praefix;
- $link = connectDB();
- $query = "SELECT * FROM ".$db_praefix."replacing ORDER BY re_name";
- $result = mysql_query($query);
- closeDB($link);
- return $result;
- }
- /**
- * returns a replacing by replacing key
- * @return resource
- */
- function get_replacing($re_key)
- {
- global $db_praefix;
- $link = connectDB();
- $query = "SELECT * FROM ".$db_praefix."replacing WHERE re_key = $re_key";
- $result = mysql_query($query);
- closeDB($link);
- return $result;
- }
- /**
- * returns all export folders
- * @return resource
- */
- function get_exportfolders()
- {
- global $db_praefix;
- $link = connectDB();
- $query = "SELECT page_key,page_path,page_title,page_exportfolder FROM ".$db_praefix."page WHERE page_start = 1 ORDER BY page_title";
- $result = mysql_query($query);
- closeDB($link);
- return $result;
- }
- /**
- * returns a export folder by folder key
- * @return resource
- */
- function get_exportfolder($page_key)
- {
- global $db_praefix;
- $link = connectDB();
- $query = "SELECT page_key,page_title,page_exportfolder FROM ".$db_praefix."page WHERE page_key = $page_key";
- $result = mysql_query($query);
- closeDB($link);
- return $result;
- }
- /**
- * returns all accounts
- * @return resource
- */
- function get_accounts()
- {
- global $db_praefix;
- $link = connectDB();
- $query = "SELECT * FROM ".$db_praefix."account WHERE (account_group != 0) ORDER BY account_lastname";
- $result = mysql_query($query);
- closeDB($link);
- return $result;
- }
- /**
- * returns all active accounts of the group registered users
- * @return resource
- */
- function get_freeaccounts()
- {
- global $db_praefix;
- $link = connectDB();
- $query = "SELECT * FROM ".$db_praefix."account WHERE (account_group = 1) AND (account_lock = 0) ORDER BY account_lastname";
- $result = mysql_query($query);
- closeDB($link);
- return $result;
- }
- /**
- * returns all active authors and administrators
- * @return resource
- */
- function get_adminaccounts()
- {
- global $db_praefix;
- $link = connectDB();
- $query = "SELECT * FROM ".$db_praefix."account WHERE (account_group != 1) AND (account_group != 0) AND (account_lock = 0) ORDER BY account_lastname";
- $result = mysql_query($query);
- closeDB($link);
- return $result;
- }
- /**
- * returns all active accounts with newsletter flag
- * @return resource
- */
- function get_infoaccounts()
- {
- global $db_praefix;
- $link = connectDB();
- $query = "SELECT * FROM ".$db_praefix."account WHERE (account_group != 0) AND (account_lock = 0) AND (account_info = 1) ORDER BY account_lastname";
- $result = mysql_query($query);
- closeDB($link);
- return $result;
- }
- /**
- * returns a account search result
- * @return resource
- */
- function search_accounts($accounts_lastname,$accounts_email,$accounts_group)
- {
- global $db_praefix;
- $link = connectDB();
- $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";
- $result = mysql_query($query);
- closeDB($link);
- return $result;
- }
- /**
- * updates an account record
- */
- 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)
- {
- global $db_praefix;
- $link = connectDB();
- if ($accountn_password != "")
- {
- $accountn_password = md5($accountn_password);
- $query = "UPDATE ".$db_praefix."account SET account_password = '$accountn_password' WHERE account_key = $accountn_key";
- $result = mysql_query($query);
- }
- $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";
- $result = mysql_query($query);
- closeDB($link);
- $pagekey = get_page_key($page_key);
- ?>
- <script language="JavaScript">
- location.href = "website.php?id=<?= $pagekey["page_path"]; ?>&admin=accounts";
- </script>
- <?
- }
- /**
- * returns an account by accout key
- * @return resource
- */
- function get_account($account_key)
- {
- global $db_praefix;
- $link = connectDB();
- $query = "SELECT * FROM ".$db_praefix."account WHERE account_key = $account_key";
- $result = mysql_query($query);
- closeDB($link);
- return $result;
- }
- /**
- * inserts an account record
- */
- function addAccount($page_key,$accountn_email,$accountn_password,$accountn_firstname,$accountn_lastname,$accountn_telefon,$accountn_company,$accountn_group,$accountn_lock)
- {
- global $db_praefix;
- $link = connectDB();
- $query = "SELECT * FROM ".$db_praefix."account WHERE account_email = '$accountn_email'";
- $result2 = mysql_query($query);
- closeDB($link);
- if (mysql_num_rows($result2) == 0)
- {
- $accountn_password = md5($accountn_password);
- $link = connectDB();
- $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')";
- $result = mysql_query($query);
- closeDB($link);
- $pagekey = get_page_key($page_key);
- ?>
- <script language="JavaScript">
- location.href = "website.php?id=<?= $pagekey["page_path"]; ?>&admin=accounts";
- </script>
- <?
- }
- else
- {
- ?>
- <script language="JavaScript">
- alert("Username exists!");
- location.href = "website.php?id=<?= $pagekey["page_path"]; ?>&admin=accounts&action=addaccount";
- </script>
- <?
- }
- }
- /**
- * deletes an account record
- */
- function deleteAccount($account_key)
- {
- global $db_praefix;
- $link = connectDB();
- $query = "DELETE FROM ".$db_praefix."account WHERE account_key = $account_key";
- $result = mysql_query($query);
- closeDB($link);
- }
- /**
- * updates a content of a page
- */
- function updateText($page_key,$page_edit,$page_input)
- {
- global $db_praefix,$site_url,$site_staging,$site_admin;
- $link = connectDB();
- $page_input = ereg_replace($site_url."/","",$page_input);
- $page_input = ereg_replace("'","'", $page_input);
- $page_input = ereg_replace("<oe:site_url/>",$site_url, $page_input);
- $page_input = ereg_replace("<oe:site_admin/>",$site_admin, $page_input);
- if ($site_staging == 0)
- {
- $query = "UPDATE ".$db_praefix."page SET $page_edit = '$page_input' WHERE page_key = $page_key";
- $result = mysql_query($query);
- }
- else
- {
- $query = "SELECT stage_key FROM ".$db_praefix."stage WHERE stage_edit = '$page_edit' AND page_key = $page_key";
- $result = mysql_query($query);
- if (mysql_num_rows($result) == 0)
- {
- $query = "INSERT ".$db_praefix."stage (page_key,stage_edit,stage_input) VALUES ('$page_key','$page_edit','$page_input')";
- $result = mysql_query($query);
- }
- else
- {
- $query = "UPDATE ".$db_praefix."stage SET stage_input = '$page_input' WHERE stage_edit = '$page_edit' AND page_key = $page_key";
- $result = mysql_query($query);
- }
- }
- closeDB($link);
- $pagekey = get_page_key($page_key);
- ?>
- <script language="JavaScript">
- window.opener.location.href = "website.php?id=<?= $pagekey["page_path"]; ?>";
- window.close();
- </script>
- <?
- }
- /**
- * updates a content of a page
- */
- function updateTextNoCache($page_key,$page_edit,$page_input)
- {
- global $db_praefix,$site_url,$site_staging,$site_admin;
- $link = connectDB();
- $page_input = ereg_replace($site_url."/","",$page_input);
- $page_input = ereg_replace("'","'", $page_input);
- $query = "UPDATE ".$db_praefix."page SET $page_edit = '$page_input' WHERE page_key = $page_key";
- $result = mysql_query($query);
- closeDB($link);
- $pagekey = get_page_key($page_key);
- $pageparent = get_page_key($pagekey["page_parent"]);
- ?>
- <script language="JavaScript">
- window.opener.location.href = "website.php?id=<?= $pageparent["page_path"]; ?>";
- window.close();
- </script>
- <?
- }
- /**
- * returns the next navigation
- * @return array
- */
- function nextpage()
- {
- global $db_praefix,$page;
- $account_status = 0;
- $access = "";
- if (empty($_GET["export"]))
- {
- $account_status = $_SESSION["account_group"];
- if ($_SESSION["account_group"] == 1)
- {
- $account_access = $_SESSION["account_access"];
- $access = " AND (page_access <= $account_access)";
- }
- }
- $link = connectDB();
- $parent_key = $page["page_parent"];
- $page_order = $page["page_order"] - 1;
- $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)";
- $result = mysql_query($query);
- closeDB($link);
- $next_array = mysql_fetch_array($result);
- return $next_array;
- }
- /**
- * returns the back navigation
- * @return array
- */
- function backpage()
- {
- global $db_praefix,$page;
- $account_status = 0;
- $access = "";
- if (empty($_GET["export"]))
- {
- $account_status = $_SESSION["account_group"];
- if ($_SESSION["account_group"] == 1)
- {
- $account_access = $_SESSION["account_access"];
- $access = " AND (page_access <= $account_access)";
- }
- }
- $link = connectDB();
- $parent_key = $page["page_parent"];
- $page_order = $page["page_order"] + 1;
- $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)";
- $result = mysql_query($query);
- closeDB($link);
- $back_array = mysql_fetch_array($result);
- return $back_array;
- }
- /**
- * writes admin log in folder /logfiles
- */
- function writeLog($log_user,$log_action,$log_page)
- {
- global $log_path;
- if ($log_path != "")
- {
- $log_time = date("ymdhis");
- $log_file = $log_path."/admin_log.csv";
- $fp = fopen($log_file,"a");
- $log_text = $log_user.";".$log_action.";".$log_page.";".$log_time."\n";
- fputs($fp,$log_text);
- fclose($fp);
- }
- }
- /**
- * returns string pool value
- * @return string
- */
- function stringpool($name,$select)
- {
- global $db_praefix;
- $link = connectDB();
- $query = "SELECT * FROM ".$db_praefix."stringpool WHERE str_name = '$name' AND str_select = '$select'";
- $result = mysql_query($query);
- if (mysql_num_rows($result) == 0)
- {
- return "";
- }
- else
- {
- $stringpool_arr = mysql_fetch_array($result);
- return $stringpool_arr["str_value"];
- }
- closeDB($link);
- }
- /**
- * check if $page_parent is a parent page of the current page
- * @return bool
- */
- function isParent($parent_key)
- {
- global $path;
- $isParent = false;
- if (isset($path))
- {
- foreach ($path as $value)
- {
- if ($value["page_key"] == $parent_key)
- {
- $isParent = true;
- }
- }
- }
- return $isParent;
- }
- ?>
Documentation generated on Tue, 16 Aug 2005 17:32:18 +0200 by phpDocumentor 1.3.0RC3