Source for file dialog.php

Documentation is available at dialog.php

  1. <?
  2. /**
  3. * dialog.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. $file_list = array();
  17.  
  18. /**
  19. * checks the export of a page
  20. * @return string
  21. */
  22. function startExport($paKey,$step,$step_size)
  23. {
  24. global $file_list;
  25. $startpage = get_page_key($paKey);
  26. $export_folder = $startpage["page_exportfolder"];
  27. $start_key = $startpage["page_key"];
  28. $start_file = getFile($startpage["page_path"]);
  29. getExFiles($paKey,$export_folder,$start_key,$start_file);
  30. $min_pos = ($step-1) * $step_size;
  31. $max_pos = $step * $step_size;
  32. $counter = 1;
  33. $check_export = 0;
  34. foreach (array_keys($file_list) as $keyo)
  35. {
  36. if (($counter >= $min_pos) && ($counter < $max_pos))
  37. {
  38. $check_export = 1;
  39. exportFile($file_list[$keyo],$export_folder,$start_key,$start_file);
  40. }
  41. $counter++;
  42. }
  43. return $check_export;
  44. }
  45.  
  46. /**
  47. * recursive function to get all export files
  48. */
  49. function getExFiles($page_key,$export_folder,$start_key,$start_file)
  50. {
  51. global $file_list,$db_praefix,$system_directory,$site_url;
  52. $file_list[] = $page_key;
  53. $link = connectDB();
  54. $query = "SELECT page_key FROM ".$db_praefix."page WHERE page_parent = $page_key AND page_status = 0 AND page_start = 0 AND page_lockexport = 0";
  55. $result = mysql_query($query);
  56. closeDB($link);
  57. while ($row = mysql_fetch_array($result))
  58. {
  59. getExFiles($row["page_key"],$export_folder,$start_key,$start_file);
  60. }
  61. }
  62.  
  63. /**
  64. * recursive function to get all status files
  65. * @return string
  66. */
  67. function getStatusFiles($page_key,$page_status,$page_lock,$page_lockexport,$page_access)
  68. {
  69. global $db_praefix;
  70. $link = connectDB();
  71. echo $page_key;
  72. $query = "UPDATE ".$db_praefix."page SET page_status = $page_status,page_lock = $page_lock,page_lockexport = $page_lockexport,page_access = $page_access WHERE page_key = $page_key";
  73. $result = mysql_query($query);
  74. $query = "SELECT page_key FROM ".$db_praefix."page WHERE page_parent = $page_key AND page_start = 0";
  75. $result = mysql_query($query);
  76. closeDB($link);
  77. while ($row = mysql_fetch_array($result))
  78. {
  79. getStatusFiles($row["page_key"],$page_status,$page_lock,$page_lockexport,$page_access);
  80. }
  81. }
  82.  
  83. /**
  84. * updates the css record
  85. */
  86. function updateCss($page_key,$site_css)
  87. {
  88. global $db_praefix;
  89. $link = connectDB();
  90. $query = "UPDATE ".$db_praefix."settings SET site_css = '$site_css'";
  91. $result = mysql_query($query);
  92. closeDB($link);
  93. $pagekey = get_page_key($page_key);
  94. ?>
  95. <script language="JavaScript">
  96. window.opener.location.href = "website.php?id=<?= $pagekey["page_path"]; ?>";
  97. location.href = "website.php?id=<?= $pagekey["page_path"]; ?>&admin=system";
  98. </script>
  99. <?
  100. }
  101.  
  102. /**
  103. * updates the remark record
  104. */
  105. function remarkPage($page_key,$page_remark)
  106. {
  107. global $db_praefix;
  108. $link = connectDB();
  109. $page_remark = htmlencode($page_remark);
  110. $query = "UPDATE ".$db_praefix."page SET page_remark = '$page_remark' WHERE page_key = $page_key";
  111. $result = mysql_query($query);
  112. closeDB($link);
  113. $pagekey = get_page_key($page_key);
  114. ?>
  115. <script language="JavaScript">
  116. window.opener.location.href = "website.php?id=<?= $pagekey["page_path"]; ?>";
  117. window.close();
  118. </script>
  119. <?
  120. }
  121.  
  122. /**
  123. * updates a template record
  124. */
  125. function updateTemplate($page_key,$template_key,$template_name,$template_description,$template_select,$template_hide,$template_short,$template_tree)
  126. {
  127. global $db_praefix;
  128. $link = connectDB();
  129. $query = "UPDATE ".$db_praefix."template SET template_short = '$template_short',template_name = '$template_name',template_description = '$template_description',template_select = '$template_select',template_hide = $template_hide,template_tree = $template_tree WHERE template_key = $template_key";
  130. $result = mysql_query($query);
  131. closeDB($link);
  132. $pagekey = get_page_key($page_key);
  133. ?>
  134. <script language="JavaScript">
  135. location.href = "website.php?id=<?= $pagekey["page_path"]; ?>&admin=templates&step=<?= $_GET["step"]; ?>";
  136. </script>
  137. <?
  138. }
  139.  
  140. /**
  141. * exports a page to the export folder
  142. * @return string
  143. */
  144. function exportFile($page_key,$export_folder,$start_key,$start_file)
  145. {
  146. global $file_list,$db_praefix,$system_directory,$site_url;
  147. $currentpage = get_page_key($page_key);
  148. $page_path = $currentpage["page_path"];
  149. $page_file = getFile($page_path);
  150. $page_folder = getFolder($page_path);
  151. $fp = fopen($site_url."/website.php?id=".$page_path."&export=yes", "r");
  152. $content = "";
  153. while(!feof($fp))
  154. {
  155. $content .= fread($fp,"10000");
  156. }
  157. fclose($fp);
  158. $content = ereg_replace("\?id=", "", $content);
  159. $content = ereg_replace("website.php", "", $content);
  160. $content = ereg_replace($site_url, $site_url.$export_folder, $content);
  161. $link = connectDB();
  162. $query = "SELECT page_key,page_path FROM ".$db_praefix."page WHERE page_status = 0 AND page_lockexport = 0";
  163. $result = mysql_query($query);
  164. closeDB($link);
  165.  
  166. while ($row = mysql_fetch_array($result))
  167. {
  168. $page_path_file = getFile($row["page_path"]);
  169. $content = ereg_replace($row["page_path"], $page_path_file, $content);
  170. }
  171.  
  172. $result_replacings = get_replacings();
  173. while ($row = mysql_fetch_array($result_replacings))
  174. {
  175. $content = ereg_replace($row["re_name"], $row["re_value"], $content);
  176. }
  177. if ($page_key == $start_key)
  178. {
  179. $fp = fopen(".".$export_folder."/".$page_file, "w+");
  180. }
  181. else
  182. {
  183. $fp = fopen(".".$export_folder."/".$page_file, "w+");
  184. }
  185. fputs($fp,$content);
  186. fclose($fp);
  187. }
  188.  
  189. /**
  190. * updates a file
  191. */
  192. function updateFile($file_name,$page_key,$field)
  193. {
  194. global $db_praefix;
  195. $link = connectDB();
  196. $query = "UPDATE ".$db_praefix."page SET $field = '$file_name' WHERE page_key = $page_key";
  197. $result = mysql_query($query);
  198. closeDB($link);
  199. }
  200.  
  201. /**
  202. * deletes an export folder
  203. */
  204. function deleteExportFolder($key)
  205. {
  206. global $system_directory,$db_praefix,$site_pool,$site_staging;
  207. $page_exp = get_page_key($key);
  208. if ($page_exp["page_exportfolder"] != "")
  209. {
  210. $site_pool = ".".$page_exp["page_exportfolder"]."/";
  211. $pool = opendir($site_pool);
  212. while ($file = readdir($pool))
  213. {
  214. if (($file != ".") && ($file != ".."))
  215. {
  216. unlink($site_pool.$file);
  217. }
  218. }
  219. }
  220. }
  221.  
  222. /**
  223. * deletes a file cache
  224. */
  225. function deleteCache($page_path)
  226. {
  227. global $db_praefix,$site_pool,$site_staging;
  228. $site_pool = $site_pool."/";
  229.  
  230. $pool = opendir($site_pool);
  231. $link = connectDB();
  232. $query = "SELECT * FROM ".$db_praefix."page where page_path = '$page_path'";
  233. $result = mysql_query($query);
  234. $menge = mysql_num_fields($result);
  235. $row = mysql_fetch_row ($result);
  236. for($x = 0; $x < $menge; $x++)
  237. {
  238. if (mysql_field_type($result, $x) != "int")
  239. {
  240. $pagekey[mysql_field_name($result,$x)] = mysql_field_name($result,$x);
  241. }
  242. }
  243.  
  244. while ($file = readdir($pool))
  245. {
  246. if (($file != ".") && ($file != ".."))
  247. {
  248. $fields = "SELECT page_key FROM ".$db_praefix."page where";
  249. while(list($arrkey, $arrval) = each ($pagekey))
  250. {
  251. if (($arrkey != "page_key") && ($arrkey != "page_rows"))
  252. {
  253. $fields .= " (".$arrkey." like '%$file%') or";
  254. }
  255. }
  256. reset($pagekey);
  257. $fields = substr($fields,0,strlen($fields)-3);
  258. $result = mysql_query($fields);
  259. if (mysql_num_rows($result) == 0)
  260. {
  261. unlink($site_pool.$file);
  262. }
  263. }
  264. }
  265. closeDB($link);
  266. closedir($pool);
  267. if ($site_staging == 1)
  268. {
  269. $link = connectDB();
  270. $query = "DELETE FROM ".$db_praefix."stage";
  271. $result = mysql_query($query);
  272. closeDB($link);
  273. }
  274. ?>
  275. <script language="JavaScript">
  276. window.opener.location.href = "website.php?id=<?= $page_path; ?>";
  277. location.href = "website.php?id=<?= $page_path; ?>&admin=system";
  278. </script>
  279. <?
  280. }
  281.  
  282. /**
  283. * deletes the stageing content of a page
  284. */
  285. function changesPage($page_key)
  286. {
  287. global $db_praefix;
  288. $link = connectDB();
  289. $query = "DELETE FROM ".$db_praefix."stage WHERE page_key = $page_key";
  290. $result = mysql_query($query);
  291. closeDB($link);
  292. $pagekey = get_page_key($page_key);
  293. ?>
  294. <script language="JavaScript">
  295. window.opener.location.href = "website.php?id=<?= $pagekey["page_path"]; ?>";
  296. window.close();
  297. </script>
  298. <?
  299. }
  300.  
  301. /**
  302. * returns the page statistic
  303. * @return resource
  304. */
  305. function get_statistic()
  306. {
  307. global $db_praefix;
  308. $link = connectDB();
  309. $query = "SELECT * FROM ".$db_praefix."page ORDER BY page_count desc";
  310. $result = mysql_query($query);
  311. closeDB($link);
  312. return $result;
  313. }
  314.  
  315. /**
  316. * deletes the page statistic
  317. */
  318. function delStatistic()
  319. {
  320. global $db_praefix;
  321. $link = connectDB();
  322. $query = "UPDATE ".$db_praefix."page SET page_count = 0";
  323. $result = mysql_query($query);
  324. closeDB($link);
  325. }
  326.  
  327. /**
  328. * releases a text block of a page
  329. */
  330. function releasePage($page_key,$block)
  331. {
  332. global $db_praefix;
  333. $link = connectDB();
  334. $query = "SELECT stage_input FROM ".$db_praefix."stage WHERE stage_edit = '$block' AND page_key = $page_key";
  335. $result = mysql_query($query);
  336. $row = mysql_fetch_array($result);
  337. $input = $row["stage_input"];
  338. $query = "UPDATE ".$db_praefix."page SET $block = '$input' WHERE page_key = $page_key";
  339. $result = mysql_query($query);
  340. $query = "DELETE FROM ".$db_praefix."stage WHERE stage_edit = '$block' AND page_key = $page_key";
  341. $result = mysql_query($query);
  342. closeDB($link);
  343. $pagekey = get_page_key($page_key);
  344. ?>
  345. <script language="JavaScript">
  346. window.opener.location.href = "website.php?id=<?= $pagekey["page_path"]; ?>";
  347. window.close();
  348. </script>
  349. <?
  350. }
  351.  
  352. /**
  353. * updates a page record
  354. */
  355. function updateProperties($page_key,$page_path,$page_path_old,$page_extern,$page_status,$page_headline,$page_title,$page_keywords,$page_description,$page_template,$page_att1,$page_att2,$page_navigation,$page_date_unformated,$page_count,$page_start,$page_lang,$page_lock)
  356. {
  357. global $db_praefix;
  358. if (($page_date_unformated != "") && (strlen($page_date_unformated) == 6))
  359. {
  360. $page_date = substr($page_date_unformated, 4, 2).".".substr($page_date_unformated, 2, 2).".".substr($page_date_unformated, 0, 2);
  361. }
  362. else
  363. {
  364. $page_date = "";
  365. }
  366. $page_path = str_replace(" ","_",$page_path);
  367. $page_headline = htmlencode($page_headline);
  368. $page_title = htmlencode($page_title);
  369. $page_navigation = htmlencode($page_navigation);
  370. $link = connectDB();
  371. $query = "SELECT page_key FROM ".$db_praefix."page WHERE page_path = '$page_path'";
  372. $result = mysql_query($query);
  373. closeDB($link);
  374. $pg_lang = get_page_key($page_key);
  375. if (($page_lang != $pg_lang["page_lang"]) && ($page_start == 1))
  376. {
  377. updateLanguage($pg_lang["page_key"],$page_lang);
  378. }
  379. if ((mysql_num_rows($result) > 0) && ($page_path != $page_path_old))
  380. {
  381. ?>
  382. <script language="JavaScript">
  383. alert("Filename exists!");
  384. history.back();
  385. </script>
  386. <?
  387. }
  388. else
  389. {
  390. $link = connectDB();
  391. $query = "UPDATE ".$db_praefix."page SET page_path = '$page_path',page_extern = '$page_extern',page_status = '$page_status',page_headline = '$page_headline',page_title = '$page_title',page_navigation = '$page_navigation',page_keywords = '$page_keywords',page_description = '$page_description',page_template = '$page_template',page_att1 = '$page_att1',page_att2 = '$page_att2',page_date = '$page_date',page_date_unformated = '$page_date_unformated',page_count = '$page_count',page_start = $page_start,page_lang = '$page_lang',page_lock = $page_lock WHERE page_key = $page_key";
  392. $result = mysql_query($query);
  393. closeDB($link);
  394. ?>
  395. <script language="JavaScript">
  396. window.opener.location.href = "website.php?id=<?= $page_path; ?>";
  397. window.close();
  398. </script>
  399. <?
  400. }
  401. }
  402.  
  403. /**
  404. * updates the language attribute for all subpage
  405. */
  406. function updateLanguage($page_key,$page_lang)
  407. {
  408. global $db_praefix;
  409. $link = connectDB();
  410. $query = "UPDATE ".$db_praefix."page SET page_lang = '$page_lang' WHERE page_key = $page_key";
  411. $result = mysql_query($query);
  412. $query = "SELECT page_key,page_parent FROM ".$db_praefix."page WHERE page_start = 0 AND page_parent = $page_key";
  413. $result = mysql_query($query);
  414. closeDB($link);
  415. while ($row = mysql_fetch_array($result))
  416. {
  417. updateLanguage($row["page_key"],$page_lang);
  418. }
  419. }
  420.  
  421. /**
  422. * updates the page status
  423. */
  424. function updateAuthorization($page_key,$page_status,$page_lock,$page_lockexport,$page_access,$status_subpages)
  425. {
  426. global $db_praefix,$status_list;
  427. $link = connectDB();
  428. $query = "UPDATE ".$db_praefix."page SET page_status = $page_status,page_lock = $page_lock,page_lockexport = $page_lockexport,page_access = $page_access WHERE page_key = $page_key";
  429. $result = mysql_query($query);
  430. if ($status_subpages == 1)
  431. {
  432. getStatusFiles($page_key,$page_status,$page_lock,$page_lockexport,$page_access);
  433. }
  434. closeDB($link);
  435. $pagekey = get_page_key($page_key);
  436. ?>
  437. <script language="JavaScript">
  438. window.opener.location.href = "website.php?id=<?= $pagekey["page_path"]; ?>";
  439. window.close();
  440. </script>
  441. <?
  442. }
  443.  
  444. /**
  445. * returns all newsletters
  446. * @return resource
  447. */
  448. function get_newsletters()
  449. {
  450. global $db_praefix;
  451. $link = connectDB();
  452. $query = "SELECT * FROM ".$db_praefix."newsletter ORDER BY nl_date_unformated DESC";
  453. $result = mysql_query($query);
  454. closeDB($link);
  455. return $result;
  456. }
  457.  
  458. /**
  459. * returns a newsletter by newsletter key
  460. */
  461. function get_newsletter($nl_key)
  462. {
  463. global $db_praefix;
  464. $link = connectDB();
  465. $query = "SELECT * FROM ".$db_praefix."newsletter WHERE nl_key = $nl_key";
  466. $result = mysql_query($query);
  467. closeDB($link);
  468. return $result;
  469. }
  470.  
  471. /**
  472. * returns all newsletter receivers limited by stepsize
  473. * @return resource
  474. */
  475. function get_sender($target,$minimum)
  476. {
  477. global $db_praefix,$newsletter_stepsize;
  478. $link = connectDB();
  479. if (($target == "all") || ($target == ""))
  480. {
  481. $query = "SELECT * FROM ".$db_praefix."account WHERE account_info = 1 AND account_lock = 0 ORDER BY account_key LIMIT $minimum,$newsletter_stepsize";
  482. }
  483. else
  484. {
  485. $query = "SELECT * FROM ".$db_praefix."account WHERE account_info = 1 AND account_lock = 0 ORDER BY account_key AND account_lang = '$target' LIMIT $minimum,$newsletter_stepsize";
  486. }
  487. $result = mysql_query($query);
  488. closeDB($link);
  489. return $result;
  490. }
  491.  
  492. /**
  493. * returns all newsletter receivers
  494. * @return resource
  495. */
  496. function get_sender_all($target)
  497. {
  498. global $db_praefix,$newslette_stepsize;
  499. $link = connectDB();
  500. if (($target == "all") || ($target == ""))
  501. {
  502. $query = "SELECT * FROM ".$db_praefix."account WHERE account_info = 1 AND account_lock = 0";
  503. }
  504. else
  505. {
  506. $query = "SELECT * FROM ".$db_praefix."account WHERE account_info = 1 AND account_lock = 0 AND account_lang = '$target'";
  507. }
  508. $result = mysql_query($query);
  509. closeDB($link);
  510. return mysql_num_rows($result);
  511. }
  512.  
  513. /**
  514. * inserts a newsletter record
  515. */
  516. function addNewsletter($page_key,$nl_subject,$nl_sender,$nl_date,$nl_date_unformated,$nl_test,$nl_text,$nl_html,$nl_status)
  517. {
  518. global $db_praefix;
  519. $link = connectDB();
  520. $query = "INSERT ".$db_praefix."newsletter (nl_subject,nl_sender,nl_date,nl_date_unformated,nl_test,nl_text,nl_html,nl_status) VALUES ('$nl_subject','$nl_sender','$nl_date','$nl_date_unformated','$nl_test','$nl_text','$nl_html','$nl_status')";
  521. $result = mysql_query($query);
  522. closeDB($link);
  523. $pagekey = get_page_key($page_key);
  524. ?>
  525. <script language="JavaScript">
  526. location.href = "website.php?id=<?= $pagekey["page_path"]; ?>&admin=newsletter";
  527. </script>
  528. <?
  529. }
  530.  
  531. /**
  532. * updates a newsletter record
  533. */
  534. function updateNewsletter($page_key,$nl_multi,$nl_subject,$nl_sender,$nl_date_unformated,$nl_test,$nl_text,$nl_html,$nl_status,$nl_target,$nl_key)
  535. {
  536. global $db_praefix;
  537. $link = connectDB();
  538. $query = "UPDATE ".$db_praefix."newsletter SET nl_subject = '$nl_subject',nl_multi = '$nl_multi',nl_sender = '$nl_sender',nl_date_unformated = '$nl_date_unformated',nl_test = '$nl_test',nl_text = '$nl_text',nl_html = '$nl_html',nl_target = '$nl_target',nl_status = $nl_status WHERE nl_key = $nl_key";
  539. $result = mysql_query($query);
  540. closeDB($link);
  541. $pagekey = get_page_key($page_key);
  542. ?>
  543. <script language="JavaScript">
  544. location.href = "website.php?id=<?= $pagekey["page_path"]; ?>&admin=newsletter";
  545. </script>
  546. <?
  547. }
  548.  
  549. /**
  550. * deletes a newsletter record
  551. */
  552. function deleteNewsletter($nl_key)
  553. {
  554. global $db_praefix;
  555. $link = connectDB();
  556. $query = "DELETE FROM ".$db_praefix."newsletter WHERE nl_key = $nl_key";
  557. $result = mysql_query($query);
  558. closeDB($link);
  559. }
  560.  
  561. /**
  562. * copy a newsletter record
  563. */
  564. function copyNewsletter($nl_key)
  565. {
  566. global $db_praefix;
  567. $nl_date = date("d.m.y");
  568. $nl_date_unformated = date("ymd");
  569. $link = connectDB();
  570. $query = "SELECT * FROM ".$db_praefix."newsletter WHERE nl_key = $nl_key";
  571. $result = mysql_query($query);
  572. $copy_array = mysql_fetch_array($result);
  573. $nl_subject = $copy_array["nl_subject"]." [Copy]";
  574. $nl_sender = $copy_array["nl_sender"];
  575. $nl_test = $copy_array["nl_test"];
  576. $nl_text = $copy_array["nl_text"];
  577. $nl_html = $copy_array["nl_html"];
  578. $nl_status = $copy_array["nl_status"];
  579. $nl_multi = $copy_array["nl_multi"];
  580. $nl_target = $copy_array["nl_target"];
  581. $query = "INSERT ".$db_praefix."newsletter (nl_subject,nl_sender,nl_date,nl_date_unformated,nl_test,nl_text,nl_html,nl_status,nl_multi,nl_target) VALUES ('$nl_subject','$nl_sender','$nl_date','$nl_date_unformated','$nl_test','$nl_text','$nl_html','$nl_status','$nl_multi','$nl_target')";
  582. $result = mysql_query($query);
  583. closeDB($link);
  584. }
  585.  
  586. /**
  587. * updates the navigation
  588. */
  589. function updateNavigation($page_key,$keys,$page_hide)
  590. {
  591. global $db_praefix;
  592. $link = connectDB();
  593. $query = "UPDATE ".$db_praefix."page SET page_hide = $page_hide WHERE page_key = $page_key";
  594. $result = mysql_query($query);
  595. $keys = substr($keys,0,strlen($keys)-1);
  596. $array_keys = explode(",",$keys);
  597. $array_keys = array_reverse($array_keys);
  598. $counter = 1;
  599. foreach ($array_keys as $value)
  600. {
  601. $query = "UPDATE ".$db_praefix."page SET page_order = $counter WHERE page_key = $value";
  602. $result = mysql_query($query);
  603. $counter++;
  604. }
  605. closeDB($link);
  606. $pagekey = get_page_key($page_key);
  607. ?>
  608. <script language="JavaScript">
  609. window.opener.location.href = "website.php?id=<?= $pagekey["page_path"]; ?>";
  610. window.close();
  611. </script>
  612. <?
  613. }
  614.  
  615. /**
  616. * updates the group order
  617. */
  618. function updateGroupOrder($page_key,$keys)
  619. {
  620. global $db_praefix;
  621. $link = connectDB();
  622. $keys = substr($keys,0,strlen($keys)-1);
  623. $array_keys = explode(",",$keys);
  624. $array_keys = array_reverse($array_keys);
  625. $counter = 0;
  626. foreach ($array_keys as $value)
  627. {
  628. $query = "UPDATE ".$db_praefix."group SET group_order = $counter WHERE group_key = $value";
  629. $result = mysql_query($query);
  630. $counter++;
  631. }
  632. closeDB($link);
  633. $pagekey = get_page_key($page_key);
  634. ?>
  635. <script language="JavaScript">
  636. window.opener.location.href = "website.php?id=<?= $pagekey["page_path"]; ?>&admin=group";
  637. window.close();
  638. </script>
  639. <?
  640. }
  641.  
  642. /**
  643. * inserts a page record
  644. */
  645. function addPage($page_key,$page_pathnew,$page_status,$page_headline,$page_title,$page_keywords,$page_description,$page_template,$page_att1,$page_att2,$page_navigation,$page_date,$page_date_unformated,$page_lang)
  646. {
  647. global $db_praefix;
  648. $page_parent = $page_key;
  649. $page_pathnew = str_replace(" ","_",$page_pathnew);
  650. $page_headline = htmlencode($page_headline);
  651. $page_title = htmlencode($page_title);
  652. $page_navigation = htmlencode($page_navigation);
  653. $link = connectDB();
  654. $query = "SELECT page_key FROM ".$db_praefix."page WHERE page_path = '$page_pathnew'";
  655. $result = mysql_query($query);
  656. closeDB($link);
  657. if (mysql_num_rows($result) > 0)
  658. {
  659. ?>
  660. <script language="JavaScript">
  661. alert("Filename exists!");
  662. history.back();
  663. </script>
  664. <?
  665. }
  666. else
  667. {
  668. $page_keynew = insertPage($page_parent,$page_pathnew,$page_status,$page_headline,$page_title,$page_keywords,$page_description,$page_template,$page_att1,$page_att2,$page_navigation,$page_date,$page_date_unformated,$page_lang);
  669. $pagekey = get_page_key($page_key);
  670. ?>
  671. <script language="JavaScript">
  672. window.opener.location.href = "website.php?id=<?= $pagekey["page_path"]; ?>";
  673. window.close();
  674. </script>
  675. <?
  676. }
  677. }
  678.  
  679. /**
  680. * inserts a page record
  681. */
  682. function insertPage($page_parent,$page_pathnew,$page_status,$page_headline,$page_title,$page_keywords,$page_description,$page_template,$page_att1,$page_att2,$page_navigation,$page_date,$page_date_unformated,$page_lang)
  683. {
  684. global $db_praefix;
  685. $link = connectDB();
  686. $query = "SELECT page_key FROM ".$db_praefix."page WHERE (page_parent = $page_parent)";
  687. $result = mysql_query($query) or die("ERROR WITH INSERT#3 QUERY! PLEASE GO BACK!");
  688. $page_order = mysql_num_rows($result) + 1;
  689. $query = "INSERT ".$db_praefix."page (page_parent,page_description,page_keywords,page_headline,page_title,page_navigation,page_path,page_status,page_order,page_template,page_att1,page_att2,page_date,page_date_unformated,page_lang) VALUES ('$page_parent','$page_description','$page_keywords','$page_headline','$page_title','$page_navigation','$page_pathnew','$page_status','$page_order','$page_template','$page_att1','$page_att2','$page_date','$page_date_unformated','$page_lang')";
  690. $result = mysql_query($query) or die("ERROR WITH INSERT#4 QUERY! PLEASE GO BACK!");
  691. $page_key = mysql_insert_id();
  692. closeDB($link);
  693. return $page_key;
  694. }
  695.  
  696. /**
  697. * deletes a page record
  698. */
  699. function deletePage($page_key)
  700. {
  701. $pagekey = get_page_key($page_key);
  702. $page_parent = $pagekey["page_parent"];
  703. $page_order = $pagekey["page_order"];
  704. delPage($page_parent,$page_key,$page_order);
  705. $pagekey = get_page_key($page_parent);
  706. ?>
  707. <script language="JavaScript">
  708. window.opener.location.href = "website.php?id=<?= $pagekey["page_path"]; ?>";
  709. window.close();
  710. </script>
  711. <?
  712. die();
  713. }
  714.  
  715. /**
  716. * deletes page record
  717. */
  718. function delPage($page_parent,$page_key,$page_order)
  719. {
  720. global $db_praefix;
  721. $link = connectDB();
  722. $query = "UPDATE ".$db_praefix."page SET page_order = page_order-1 WHERE (page_order >= $page_order) AND (page_parent = $page_parent)";
  723. $result = mysql_query($query) or die("ERROR WITH DELETE#1 QUERY! PLEASE GO BACK!");
  724. closeDB($link);
  725. delPages($page_key);
  726. }
  727.  
  728. /**
  729. * deletes recursiv page records
  730. */
  731. function delPages($page_key)
  732. {
  733. global $db_praefix,$site_staging;
  734. $link = connectDB();
  735. $query = "DELETE FROM ".$db_praefix."page WHERE page_key = $page_key";
  736. $result = mysql_query($query);
  737. if ($site_staging == 1)
  738. {
  739. $query = "DELETE FROM ".$db_praefix."stage WHERE page_key = $page_key";
  740. $result = mysql_query($query);
  741. }
  742. $query = "SELECT page_key FROM ".$db_praefix."page WHERE page_parent = $page_key";
  743. $result = mysql_query($query);
  744. closeDB($link);
  745. while ($row = mysql_fetch_array($result))
  746. {
  747. delPages($row["page_key"]);
  748. }
  749. }
  750.  
  751. /**
  752. * cuts a page
  753. */
  754. function cutPage($page_key,$page_keynew)
  755. {
  756. global $db_praefix;
  757. $link = connectDB();
  758. $query = "SELECT page_key FROM ".$db_praefix."page WHERE (page_parent = $page_keynew)";
  759. $result = mysql_query($query);
  760. $page_order = mysql_num_rows($result) + 1;
  761. $query = "UPDATE ".$db_praefix."page SET page_order = $page_order, page_parent = $page_keynew WHERE (page_key = $page_key)";
  762. $result = mysql_query($query);
  763. closeDB($link);
  764. $pagekey = get_page_key($page_key);
  765. ?>
  766. <script language="JavaScript">
  767. window.opener.location.href = "website.php?id=<?= $pagekey["page_path"]; ?>";
  768. window.close();
  769. </script>
  770. <?
  771. }
  772.  
  773. /**
  774. * copy a page
  775. */
  776. function copyPage($page_key,$page_keynew)
  777. {
  778. global $db_praefix;
  779. $pagekey = get_page_key($page_key);
  780. $page_path_old = $pagekey["page_path"];
  781. $page_path_old = ereg_replace(".htm","", $page_path_old);
  782.  
  783. $fields = "INSERT INTO ".$db_praefix."page (";
  784. while(list($arrkey, $arrval) = each ($pagekey))
  785. {
  786. if (($arrkey != "page_key") && ($arrkey != "page_rows"))
  787. {
  788. $fields .= $arrkey.",";
  789. }
  790. }
  791. $fields = substr($fields,0,strlen($fields)-1);
  792. $fields .= ") VALUES (";
  793. reset ($pagekey);
  794. while(list($arrkey, $arrval) = each ($pagekey))
  795. {
  796. if (($arrkey != "page_key") && ($arrkey != "page_rows"))
  797. {
  798. if ($arrkey == "page_parent")
  799. {
  800. $fields .= "'".$page_keynew."',";
  801. }
  802. elseif ($arrkey == "page_order")
  803. {
  804. $link = connectDB();
  805. $query = "SELECT page_key FROM ".$db_praefix."page WHERE (page_parent = $page_keynew)";
  806. $result = mysql_query($query);
  807. $page_order = mysql_num_rows($result) + 1;
  808. $fields .= "'".$page_order."',";
  809. closeDB($link);
  810. }
  811. elseif ($arrkey == "page_count")
  812. {
  813. $fields .= "'0',";
  814. }
  815. elseif ($arrkey == "page_status")
  816. {
  817. $fields .= "'2',";
  818. }
  819. else
  820. {
  821. $fields .= "'".$arrval."',";
  822. }
  823. }
  824. }
  825. $fields = substr($fields,0,strlen($fields)-1);
  826. $fields .= ")";
  827. $link = connectDB();
  828. $result = mysql_query($fields);
  829. $page_key = mysql_insert_id();
  830. $page_path_new = $page_path_old.$page_key.".htm";
  831. $query = "UPDATE ".$db_praefix."page SET page_path = '$page_path_new' where page_key = $page_key";
  832. $result = mysql_query($query);
  833. closeDB($link);
  834. $pagekey = get_page_key($page_key);
  835. ?>
  836. <script language="JavaScript">
  837. window.opener.location.href = "website.php?id=<?= $pagekey["page_path"]; ?>";
  838. window.close();
  839. </script>
  840. <?
  841. }
  842.  
  843. /**
  844. * sends a message via e-mail
  845. */
  846. function sendMessage($msg_receiver,$msg_subject,$msg_message,$msg_from)
  847. {
  848. global $nl_encoding;
  849. require("system/admin/phpmailer/class.phpmailer.php");
  850. $mail = new phpmailer();
  851. $mail->From = $msg_from;
  852. $mail->FromName = "";
  853. $mail->AddAddress($msg_receiver);
  854. $mail->Subject = $msg_subject;
  855. $mail->Encoding = "8bit";
  856. $mail->CharSet = $nl_encoding;
  857. $text_body = $msg_message;
  858. $mail->Body = $text_body;
  859. $mail->Send();
  860. $mail->ClearAddresses();
  861. $mail->ClearAttachments();
  862. ?>
  863. <script language="Javascript">
  864. window.close();
  865. </script>
  866. <?
  867. }
  868.  
  869. /**
  870. * updates an user record
  871. */
  872. function updateUser($page_key,$accountn_key,$accountn_email,$accountn_password,$accountn_firstname,$accountn_lastname,$accountn_editor,$accountn_menu)
  873. {
  874. global $db_praefix;
  875. $link = connectDB();
  876. if ($accountn_password != "")
  877. {
  878. $accountn_password = md5($accountn_password);
  879. $query = "UPDATE ".$db_praefix."account SET account_password = '$accountn_password' where account_key = $accountn_key";
  880. $result = mysql_query($query);
  881. }
  882. $query = "UPDATE ".$db_praefix."account SET account_email = '$accountn_email', account_firstname = '$accountn_firstname',account_lastname = '$accountn_lastname', account_editor = '$accountn_editor', account_menu = $accountn_menu where account_key = $accountn_key";
  883. $result = mysql_query($query);
  884. closeDB($link);
  885. $_SESSION["account_email"] = $accountn_email;
  886. $_SESSION["account_firstname"] = $accountn_firstname;
  887. $_SESSION["account_lastname"] = $accountn_lastname;
  888. $_SESSION["account_editor"] = $accountn_editor;
  889. $_SESSION["account_menu"] = $accountn_menu;
  890. $pagekey = get_page_key($page_key);
  891. ?>
  892. <script language="JavaScript">
  893. window.opener.location.href = "website.php?id=<?= $pagekey["page_path"]; ?>";
  894. window.close();
  895. </script>
  896. <?
  897. }
  898.  
  899. /**
  900. * returns the newsletter status
  901. * @return bool
  902. */
  903. function checknewsletter()
  904. {
  905. global $db_praefix;
  906. $link = connectDB();
  907. $query = "SELECT account_key FROM ".$db_praefix."account where account_nlsend = 1";
  908. $result = mysql_query($query);
  909. closeDB($link);
  910. if (mysql_num_rows($result) == 0)
  911. {
  912. return true;
  913. }
  914. else
  915. {
  916. return false;
  917. }
  918. }
  919.  
  920. /**
  921. * unlock all receivers for newsletter
  922. */
  923. function unlockNewsletter()
  924. {
  925. global $db_praefix;
  926. $link = connectDB();
  927. $query = "UPDATE ".$db_praefix."account SET account_nlsend = 0";
  928. $result = mysql_query($query);
  929. closeDB($link);
  930. }
  931. ?>

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