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

Documentation generated on Tue, 16 Aug 2005 17:32:19 +0200 by phpDocumentor 1.3.0RC3