A lightweight forum engine written in PHP. Repository is now obsolete and read-only. http://www.pioder.pl/uforum.html
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

230 lines
7.3 KiB

  1. <?php
  2. /**
  3. * @package uForum
  4. * @file admin/smilelist.php
  5. * @version $Id$
  6. * @copyright 2007-2010 (c) PioDer <pioder@wp.pl>
  7. * @link http://www.pioder.pl/
  8. * @license see LICENSE.txt
  9. **/
  10. define('IN_uF', true);
  11. //include files
  12. include('./../config.php');
  13. include('./../includes/constants.php');
  14. include('./../includes/db.php');
  15. include('./../includes/errors.php');
  16. include('./../includes/classes/class_pms.php');
  17. //connect to database
  18. DataBase::db_connect();
  19. include('./../includes/sessions.php');
  20. include('./../includes/classes/class_user.php');
  21. include('./../common.php');
  22. include('./../includes/admin/class_main.php');
  23. include('./../includes/classes/class_forum.php');
  24. include('./../includes/admin/class_forum.php');
  25. include('./../includes/classes/secure.php');
  26. include('./../lngs/'.Admin_Over::DefaultLang().'/admin.php');
  27. SessDelInvalid();
  28. SessRegister();
  29. SessDeleteOld();
  30. if (User::UserInformation($_SESSION['uid'],'rank')!=2)
  31. {
  32. admin_message_forum($lng['yournotadmin'],'../index.php');
  33. }
  34. if (!isset($_GET['mode']))
  35. {
  36. header('Location: smilelist.php?mode=view');
  37. }
  38. switch($_GET['mode'])
  39. {
  40. case 'add':
  41. {
  42. switch($_GET['submode'])
  43. {
  44. //add one smile
  45. case 'one':
  46. {
  47. if (isset($_POST['word'],$_POST['url']))
  48. {
  49. $sql = "SELECT * FROM ".SMILES_TABLE." ORDER BY `s_id` DESC LIMIT 1";
  50. $query = DataBase::sql_query($sql,CRITICAL,'Could not obtain smilelist item information');
  51. $result = DataBase::fetch($query);
  52. $smile_id = $result['s_id'];
  53. $smile_id = $smile_id +1;
  54. $smile_word = strip_tags($_POST['word']);
  55. $smile_url = strip_tags($_POST['url']);
  56. $sql = "INSERT INTO ".SMILES_TABLE." VALUES('$smile_id','$smile_word','$smile_url')";
  57. DataBase::sql_query($sql,GENERAL,'Could not add smile.');
  58. admin_message_forum($lng['smile_added'],'smilelist.php?mode=view');
  59. }
  60. else
  61. {
  62. $_POST['word']='';
  63. $_POST['url'] = '';
  64. $skin = array(
  65. 'L.smilelist'=>$lng['admin_smilelist'],
  66. 'action'=>'smilelist.php?mode=add&amp;submode=one',
  67. 'L.edit_smile'=>$lng['smilelist_add'],
  68. 'L.smile'=>$lng['smile'],
  69. 'L.url' => $lng['url'],
  70. 'L.save'=>$lng['submit'],
  71. 'L.clear'=>$lng['reset']
  72. );
  73. Admin_Over::GenerateHeader();
  74. include('./template/smilelist_edit_body.tpl');
  75. include('./template/overall_footer.tpl');
  76. }
  77. break;
  78. }
  79. //add smiles with file
  80. case 'file':
  81. {
  82. if (isset($_FILES['file'],$_POST['motive']))
  83. {
  84. $ban_uid = '-2';
  85. $ban_motive = strip_tags($_POST['motive']);
  86. $catalog = '../tmp/';
  87. if(!move_uploaded_file($_FILES['file']['tmp_name'], $catalog.$_FILES['file']['name']))
  88. {
  89. message_die(GENERAL,'Could not upload file.','');
  90. }
  91. $open = @fopen($catalog.$_FILES['file']['name'],'r');
  92. $file = @fread($open, filesize($catalog.$_FILES['file']['name']));
  93. $item = @explode("\n",$file);
  94. $bid = $bid = DataBase::fetch(DataBase::sql_query("SELECT
  95. `s_id` FROM ".SMILES_TABLE." ORDER BY `s_id` DESC",GENERAL,
  96. 'Could not obtain last smile id'));
  97. $sid = $sid['s_id'];
  98. $sid = $sid +1;
  99. for($i=0;$i<count($item);$i++)
  100. {
  101. $subitem = @explode(" :: ",$item[$i]);
  102. $smile_word = $subitem[0];
  103. $smile_url = $subitem[1];
  104. $sql = "INSERT INTO ".SMILES_TABLE." VALUES ('$sid', '$smile_word', '$smile_url')";
  105. DataBase::sql_query($sql,GENERAL,'Could not add smile.');
  106. $sid = $bid +1;
  107. }
  108. admin_message_forum($lng['smiles_added'],'smilelist.php?mode=view');
  109. }
  110. else
  111. {
  112. $_POST['file'] = '';
  113. $skin = array(
  114. 'L.smilelist'=>$lng['admin_smilelist'],
  115. 'action'=>'smilelist.php?mode=add&amp;submode=file',
  116. 'L.add_file'=>$lng['smilelist_add_from_file'],
  117. 'L.file_name'=>$lng['file_name'],
  118. 'L.save'=>$lng['submit'],
  119. 'L.clear'=>$lng['reset'],
  120. 'L.file.HELP' => $lng['smilelist_info_1']
  121. );
  122. Admin_Over::GenerateHeader();
  123. include('./template/smilelist_add_file_body.tpl');
  124. include('./template/overall_footer.tpl');
  125. }
  126. break;
  127. }
  128. }
  129. break;
  130. }
  131. case 'delete':
  132. {
  133. $sid = $_GET['id'];
  134. $sql = "DELETE FROM ".SMILES_TABLE." WHERE `s_id`='$sid'";
  135. DataBase::sql_query($sql,GENERAL,'Could not delete smilelist item.');
  136. admin_message_forum($lng['smile_deleted'],'smilelist.php?mode=view');
  137. break;
  138. }
  139. case 'edit':
  140. {
  141. if (isset($_POST['word'],$_POST['url'],$_GET['id']))
  142. {
  143. $smile_id = strip_tags($_GET['id']);
  144. $smile_word = strip_tags($_POST['word']);
  145. $smile_url = strip_tags($_POST['url']);
  146. $bid = $_GET['id'];
  147. $sql = "UPDATE ".SMILES_TABLE." SET
  148. `smile`='$smile_word',
  149. `url`='$smile_url'
  150. WHERE `s_id`='$smile_id'";
  151. DataBase::sql_query($sql,GENERAL,'Could not update smile.');
  152. admin_message_forum($lng['smile_edited'],'smilelist.php?mode=view');
  153. }
  154. else
  155. {
  156. $sid = intval($_GET['id']);
  157. $sql = "SELECT * FROM ".SMILES_TABLE." WHERE `s_id`='$sid'";
  158. $query = DataBase::sql_query($sql,CRITICAL,'Could not obtain smilelist item information');
  159. $result = DataBase::fetch($query);
  160. if ($result['s_id']=='')
  161. {
  162. admin_message_forum($lng['no_smile'],'smilelist.php?mode=view');
  163. }
  164. $_POST['word']=$result['smile'];
  165. $_POST['url'] = $result['url'];
  166. $skin = array(
  167. 'L.smilelist'=>$lng['admin_smilelist'],
  168. 'action'=>'smilelist.php?mode=edit&id='.$sid,
  169. 'L.edit_smile'=>$lng['smilelist_edit'],
  170. 'L.smile'=>$lng['smile'],
  171. 'L.url' => $lng['url'],
  172. 'L.save'=>$lng['submit'],
  173. 'L.clear'=>$lng['reset']
  174. );
  175. Admin_Over::GenerateHeader();
  176. include('./template/smilelist_edit_body.tpl');
  177. include('./template/overall_footer.tpl');
  178. }
  179. break;
  180. }
  181. case 'clear':
  182. {
  183. $sql = "TRUNCATE `".SMILES_TABLE."`";
  184. DataBase::sql_query($sql, GENERAL,'Could not empty smilelist');
  185. admin_message_forum($lng['smilelist_cleanout'],'smilelist.php?mode=view');
  186. }
  187. case 'view':
  188. {
  189. $sql = "SELECT * FROM ".SMILES_TABLE."";
  190. $query = DataBase::sql_query($sql,CRITICAL,'Could not obtain smilelist items');
  191. $skin=array(
  192. 'L.smilelist'=>$lng['admin_smilelist'],
  193. 'L.select_mode'=>$lng['what_do_you_want'],
  194. 'L.add'=>$lng['smilelist_add'],
  195. 'L.add_file'=>$lng['smilelist_add_from_file'],
  196. 'L.clean_smilelist' => $lng['smilelist_clean']
  197. );
  198. Admin_Over::GenerateHeader();
  199. include('./template/smilelist_view_body.tpl');
  200. if (DataBase::num_rows($query)<1)
  201. {
  202. echo '<table class="maintable"><tr><td width="'.TABLES_WIDTH.'" colspan="8" height="19"
  203. class="fitem"><p class="fstandard" align="center">'.$lng['smilelist_no_items'].'!</p></td></tr></table>';
  204. }
  205. else
  206. {
  207. while($item = DataBase::fetch($query))
  208. {
  209. $skin = array(
  210. 'smile_word'=>$item['smile'],
  211. 'addr'=> $item['url'],
  212. 'visual_smile' => $item['url'],
  213. 's_id'=>$item['s_id'],
  214. 'L.delete'=>$lng['delete'],
  215. 'L.edit'=>$lng['edit']
  216. );
  217. include('./template/smilelist_item_add.tpl');
  218. }
  219. }
  220. include('./template/overall_footer.tpl');
  221. break;
  222. }
  223. default:
  224. {
  225. header('Location: smilelist.php?mode=view');
  226. break;
  227. }
  228. }
  229. ?>