PageRenderTime 48ms CodeModel.GetById 17ms RepoModel.GetById 0ms app.codeStats 0ms

/v1.4/puslapiai/dievai/straipsniai.php

http://mightmedia.googlecode.com/
PHP | 272 lines | 228 code | 26 blank | 18 comment | 58 complexity | 659e7a461f9b987bf63c7ce4a3caf972 MD5 | raw file
Possible License(s): AGPL-1.0, LGPL-2.0, GPL-2.0
  1. <?php
  2. /**
  3. * @Projektas: MightMedia TVS
  4. * @Puslapis: www.coders.lt
  5. * @$Author$
  6. * @copyright CodeRS Š2008
  7. * @license GNU General Public License v2
  8. * @$Revision$
  9. * @$Date$
  10. **/
  11. if (!defined("OK") || !ar_admin(basename(__file__)))
  12. {
  13. header('location: ?');
  14. exit();
  15. }
  16. unset($text, $extra);
  17. $buttons = <<< HTML
  18. <button onclick="location.href='?id,{$_GET['id']};a,{$_GET['a']};v,2'">{$lang['system']['createcategory']}</button>
  19. <button onclick="location.href='?id,{$_GET['id']};a,{$_GET['a']};v,3'">{$lang['system']['editcategory']}</button>
  20. <button onclick="location.href='?id,{$_GET['id']};a,{$_GET['a']};v,5'">{$lang['system']['createsubcategory']}</button>
  21. <button onclick="location.href='?id,{$_GET['id']};a,{$_GET['a']};v,4'">{$lang['admin']['article_edit']}</button>
  22. <button onclick="location.href='?id,{$_GET['id']};a,{$_GET['a']};v,7'">{$lang['admin']['article_create']}</button>
  23. <button onclick="location.href='?id,{$_GET['id']};a,{$_GET['a']};v,6'">{$lang['admin']['article_unpublished']}</button>
  24. HTML;
  25. if (empty($_GET['v']))
  26. {
  27. $_GET['v'] = 0;
  28. }
  29. lentele($lang['admin']['Articles'], $buttons);
  30. unset($buttons);
  31. include_once ("priedai/kategorijos.php");
  32. kategorija("straipsniai", true);
  33. if (isset($_GET['p']))
  34. {
  35. $result = mysql_query1("UPDATE `" . LENTELES_PRIESAGA . "straipsniai` SET rodoma='TAIP'
  36. WHERE `id`=" . escape($_GET['p']) . ";
  37. ");
  38. if ($result)
  39. {
  40. msg($lang['system']['done'], "{$lang['admin']['article_activated']}.");
  41. }
  42. else
  43. {
  44. klaida("{$lang['system']['error']}", " <br><b>" . mysql_error() . "</b>");
  45. }
  46. }
  47. $tags = array("p" => 1, "br" => 0, "a" => 1, "img" => 0, "li" => 1, "ol" => 1, "ul" => 1, "b" => 1, "i" => 1, "em" => 1, "strong" => 1, "del" => 1, "ins" => 1, "u" => 1, "code" => 1, "pre" => 1, "blockquote" => 1, "hr" => 0, "span" => 1, "font" => 1, "h1" => 1, "h2" => 1, "h3" => 1, "table" => 1, "tr" => 1, "td" => 1, "th" => 1, "tbody" => 1, "div" => 1, "embed" => 1);
  48. if (((isset($_POST['action']) && $_POST['action'] == $lang['admin']['delete'] && LEVEL == 1 && isset($_POST['edit_new']) && $_POST['edit_new'] > 0)) || isset($url['t']) && LEVEL == 1)
  49. {
  50. if (isset($url['t']))
  51. {
  52. $trinti = (int)$url['t'];
  53. } elseif (isset($_POST['edit_new']))
  54. {
  55. $trinti = (int)$_POST['edit_new'];
  56. }
  57. $ar = mysql_query1("DELETE FROM `" . LENTELES_PRIESAGA . "straipsniai` WHERE id=" . escape($trinti) . " LIMIT 1") or die(mysql_error());
  58. if ($ar)
  59. {
  60. msg($lang['system']['done'], "{$lang['admin']['article_Deleted']}");
  61. }
  62. else
  63. {
  64. klaida("{$lang['system']['error']}", " <br><b>" . mysql_error() . "</b>");
  65. }
  66. mysql_query1("DELETE FROM `" . LENTELES_PRIESAGA . "kom` WHERE pid='puslapiai/straipsnis' AND kid=" . escape($trinti) . "");
  67. //redirect("?id,".$_GET['id'].";a,".$_GET['a'],"header");
  68. } elseif (isset($_POST['action']) && isset($_POST['str']) && $_POST['action'] == $lang['admin']['edit'])
  69. {
  70. //apsauga nuo kenksmingo kodo
  71. include_once ('priedai/safe_html.php');
  72. $apr = safe_html(str_replace(array("&#39;"), array("'"), $_POST['apr']), $tags);
  73. $str = safe_html(str_replace(array("&#39;"), array("'"), $_POST['str']), $tags);
  74. $komentaras = (isset($_POST['kom']) && $_POST['kom'] == 'taip' ? 'taip' : 'ne');
  75. $rodoma = (isset($_POST['rodoma']) && $_POST['rodoma'] == 'TAIP' ? 'TAIP' : 'NE');
  76. $kategorija = (int)$_POST['kategorija'];
  77. $pavadinimas = strip_tags($_POST['pav']);
  78. $id = ceil((int)$_POST['idas']);
  79. if ($komentaras == 'ne')
  80. {
  81. mysql_query1("DELETE FROM `" . LENTELES_PRIESAGA . "kom` WHERE pid=" . escape((int)$_GET['id']) . " AND kid=" . escape($id));
  82. }
  83. $resultas = mysql_query1("UPDATE `" . LENTELES_PRIESAGA . "straipsniai` SET
  84. `kat` = " . escape($kategorija) . ",
  85. `pav` = " . escape($pavadinimas) . ",
  86. `t_text` = " . escape($apr) . ",
  87. `f_text` = " . escape($str) . ",
  88. `kom` = " . escape($komentaras) . ",
  89. `rodoma` = " . escape($rodoma) . "
  90. WHERE `id`=" . escape($id) . ";
  91. ") or klaida("{$lang['system']['error']}", " <br><b>" . mysql_error() . "</b>");
  92. if ($resultas)
  93. {
  94. msg($lang['system']['done'], "{$lang['admin']['article_updated']}.");
  95. }
  96. else
  97. {
  98. klaida("{$lang['system']['error']}", " <br><b>" . mysql_error() . "</b>");
  99. }
  100. } elseif (isset($_POST['action']) && $_POST['action'] == $lang['admin']['article_create'])
  101. {
  102. //apsauga nuo kenksmingo kodo
  103. include_once ('priedai/safe_html.php');
  104. $apr = safe_html(str_replace(array("&#39;"), array("'"), $_POST['apr']), $tags);
  105. $str = safe_html(str_replace(array("&#39;"), array("'"), $_POST['str']), $tags);
  106. $komentaras = (isset($_POST['kom']) && $_POST['kom'] == 'taip' ? 'taip' : 'ne');
  107. $kategorija = (int)$_POST['kategorija'];
  108. $pavadinimas = strip_tags($_POST['pav']);
  109. $rodoma = (isset($_POST['rodoma']) && $_POST['rodoma'] == 'TAIP' ? 'TAIP' : 'NE');
  110. $autorius = $_SESSION['username'];
  111. $autoriusid = $_SESSION['id'];
  112. if (empty($str) || empty($pavadinimas))
  113. {
  114. $error = "{$lang['admin']['article_emptyfield']}.";
  115. }
  116. if (!isset($error))
  117. {
  118. $result = mysql_query1("INSERT INTO `" . LENTELES_PRIESAGA . "straipsniai` SET
  119. `kat` = " . escape($kategorija) . ",
  120. `pav` = " . escape($pavadinimas) . ",
  121. `t_text` = " . escape($apr) . ",
  122. `f_text` = " . escape($str) . ",
  123. `date` = " . time() . ",
  124. `autorius` = " . escape($autorius) . ",
  125. `autorius_id` = " . escape($autoriusid) . ",
  126. `kom` = " . escape($komentaras) . ",
  127. `rodoma` = " . escape($rodoma) . "");
  128. if ($result)
  129. {
  130. msg($lang['system']['done'], "{$lang['admin']['article_created']}");
  131. }
  132. else
  133. {
  134. klaida("{$lang['system']['error']}", " <br><b>" . mysql_error() . "</b>");
  135. }
  136. }
  137. else
  138. {
  139. klaida("{$lang['system']['error']}", $error);
  140. }
  141. unset($rodoma, $pavadinimas, $kategorija, $komentaras, $str, $apr, $_POST['action'], $result);
  142. redirect("?id," . $_GET['id'] . ";a," . $_GET['a'] . "", "meta");
  143. }
  144. //straipsnio redagavimas
  145. elseif (((isset($_POST['edit_new']) && isNum($_POST['edit_new']) && $_POST['edit_new'] > 0)) || isset($url['h']))
  146. {
  147. if (isset($url['h']))
  148. {
  149. $redaguoti = (int)$url['h'];
  150. } elseif (isset($_POST['edit_new']))
  151. {
  152. $redaguoti = (int)$_POST['edit_new'];
  153. }
  154. $extra = mysql_query1("SELECT * FROM `" . LENTELES_PRIESAGA . "straipsniai` WHERE `id`=" . escape($redaguoti) . " LIMIT 1");
  155. $extra = mysql_fetch_assoc($extra);
  156. }
  157. if (isset($_GET['v']))
  158. {
  159. $sql = mysql_query1("SELECT * FROM `" . LENTELES_PRIESAGA . "grupes` WHERE `kieno`='straipsniai' AND `path`=0 ORDER BY `id` DESC") or die(mysql_error());
  160. if (mysql_num_rows($sql) > 0)
  161. {
  162. while ($row = mysql_fetch_assoc($sql))
  163. {
  164. $sql2 = mysql_query1("SELECT * FROM `" . LENTELES_PRIESAGA . "grupes` WHERE `kieno`='straipsniai' AND path!=0 and `path` like '" . $row['id'] . "%' ORDER BY `id` ASC");
  165. if (mysql_num_rows($sql2) > 0)
  166. {
  167. $subcat = '';
  168. while ($path = mysql_fetch_assoc($sql2))
  169. {
  170. $subcat .= "->" . $path['pavadinimas'];
  171. $kategorijos[$row['id']] = $row['pavadinimas'];
  172. $kategorijos[$path['id']] = $row['pavadinimas'] . $subcat;
  173. }
  174. }
  175. else
  176. {
  177. $kategorijos[$row['id']] = $row['pavadinimas'];
  178. }
  179. }
  180. }
  181. /*else
  182. {
  183. $kategorijos[] = "{$lang['system']['nocategories']}";
  184. }*/
  185. $kategorijos[0] = "--";
  186. }
  187. $sql2 = mysql_query1("SELECT id, pav FROM `" . LENTELES_PRIESAGA . "straipsniai` ORDER BY ID DESC");
  188. if (mysql_num_rows($sql2) > 0)
  189. {
  190. while ($row2 = mysql_fetch_assoc($sql2))
  191. {
  192. $straipsniai[$row2['id']] = $row2['pav'];
  193. }
  194. }
  195. else
  196. {
  197. $straipsniai[] = "{$lang['admin']['article_no']}";
  198. }
  199. include_once ("priedai/class.php");
  200. $bla = new forma();
  201. if ($_GET['v'] == 4)
  202. {
  203. $redagavimas = array("Form" => array("action" => "?id,{$_GET['id']};a,{$_GET['a']};v,7", "method" => "post", "name" => "reg"), "{$lang['admin']['article']}:" => array("type" => "select", "value" => $straipsniai, "name" => "edit_new"), " " => array("type" => "submit", "name" => "action", "value" => "{$lang['admin']['edit']}"), "" => array("type" => "submit", "name" => "action",
  204. "value" => "{$lang['admin']['delete']}"));
  205. lentele($lang['admin']['article_edit'], $bla->form($redagavimas));
  206. }
  207. if ($_GET['v'] == 7 || isset($url['h']))
  208. {
  209. if ($i = 1)
  210. {
  211. $ar = array("TAIP" => "{$lang['admin']['yes']}", "NE" => "{$lang['admin']['no']}");
  212. $straipsnis = array("Form" => array("action" => "?id," . $_GET['id'] . ";a," . $_GET['a'] . "", "method" => "post", "name" => "reg"), "{$lang['admin']['article_title']}:" => array("type" => "text", "value" => input((isset($extra)) ? $extra['pav'] : ''), "name" => "pav", "style" => "width:100%"), "" => array("type" => "hidden", "name" => "idas", "value" => (isset($extra['id']) ?
  213. input($extra['id']) : '')), "{$lang['admin']['article_comments']}:" => array("type" => "select", "value" => array('taip' => $lang['admin']['yes'], 'ne' => $lang['admin']['no']), "name" => "kom", "class" => "input", "style" => "width:100%"), "{$lang['system']['category']}:" => array("type" => "select", "value" => $kategorijos, "name" => "kategorija", "class" => "input", "style" =>
  214. "width:100%", "selected" => (isset($extra['kat']) ? input($extra['kat']) : '')), "{$lang['admin']['article_shown']}:" => array("type" => "select", "value" => $ar, "name" => "rodoma", "class" => "input", "style" => "width:100%", "selected" => (isset($extra['rodoma']) ? input($extra['rodoma']) : '')), "{$lang['admin']['article']}:" => array("type" => "string", "value" =>
  215. editorius('spaw', 'standartinis', array('apr' => 'Straipsnio ?žanga', 'str' => 'straipsnis'), array('apr' => (isset($extra)) ? $extra['t_text'] : $lang['admin']['article_preface'], 'str' => (isset($extra)) ? $extra['f_text'] : $lang['admin']['article']))), (isset($extra)) ? $lang['admin']['edit'] : $lang['admin']['article_create'] => array("type" => "submit", "name" => "action",
  216. "value" => (isset($extra)) ? $lang['admin']['edit'] : $lang['admin']['article_create']), );
  217. if (isset($extra['id']))
  218. {
  219. $naujiena[''] = array("type" => "text", "name" => "idas", "value" => (isset($extra['id']) ? input($extra['id']) : ''));
  220. }
  221. lentele($lang['admin']['article_create'], $bla->form($straipsnis));
  222. }
  223. else
  224. {
  225. klaida("{$lang['system']['warning']}", "{$lang['system']['nocategories']}.");
  226. }
  227. } elseif ($_GET['v'] == 6)
  228. {
  229. $q = mysql_query1("SELECT * FROM `" . LENTELES_PRIESAGA . "straipsniai` WHERE rodoma='NE'");
  230. if ($q)
  231. {
  232. include_once ("priedai/class.php");
  233. $bla = new Table();
  234. $info = array();
  235. while ($sql = mysql_fetch_assoc($q))
  236. {
  237. $sql2 = mysql_fetch_assoc(mysql_query1("SELECT nick FROM `" . LENTELES_PRIESAGA . "users` WHERE id='" . $sql['autorius'] . "'"));
  238. $info[] = array("ID" => $sql['id'], "{$lang['admin']['article']}:" => '<a href="#" title="<b>' . $sql['pav'] . '</b>
  239. <br />' . $lang['admin']['article_author'] . ': <b>' . $sql2['nick'] . '</b><br />' . $lang['admin']['article_date'] . ': <b>' . date('Y-m-d H:i:s ', $sql['date']) . ' - ' . kada(date('Y-m-d H:i:s ', $sql['date'])) . '</b>" target="_blank">' . $sql['pav'] . '</a>', "{$lang['admin']['action']}:" => "<a href='?id,{$_GET['id']};a,{$_GET['a']};p," . $sql['id'] . "'title='{$lang['admin']['acept']}'><img src='images/icons/icon_accept.gif' border='0'></a> <a href='?id,{$_GET['id']};a,{$_GET['a']};t," .
  240. $sql['id'] . "' title='{$lang['admin']['delete']}'><img src='images/icons/cross.png' border='0'></a> <a href='?id,{$_GET['id']};a,{$_GET['a']};h," . $sql['id'] . "' title='{$lang['admin']['edit']}'><img src='images/icons/pencil.png' border='0'></a>");
  241. }
  242. lentele($lang['admin']['article_unpublished'], $bla->render($info));
  243. }
  244. }
  245. //unset($_POST);
  246. ?>