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

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