source: mangos/inc/files.post.php@ 5

Last change on this file since 5 was 5, checked in by george, 18 years ago

import

File size: 4.6 KB
Line 
1<?php
2if (INCLUDED!==true) exit('Dieee !!!');
3
4$page['title'] = "$lang[pagetitle_files]";
5$_GET['edit'] = $realm_db->escape($_GET['edit']);
6$cat_words = array($lang['files_type_other'],$lang['files_type_client'],$lang['files_type_patch'],$lang['files_type_wallpaper'],$lang['files_type_video'],$lang['files_type_screenshot']);
7
8if($user['gmlevel'] >= $site['files_publication_gmlevel'])
9{
10 if($_POST['doadd'] && !$_GET['edit'])
11 {
12 $tmp_cur_time = time();
13 $tmp_mess = my_preview($_POST['message'],$user['gmlevel']);
14 $tmp_mess = quote_smart($tmp_mess);
15 $tmp_title = htmlspecialchars(trim("$_POST[title]"));
16 $tmp_format = htmlspecialchars(trim("$_POST[format]"));
17 $tmp_size = (INT)$realm_db->escape($_POST['size']);
18 $query = "INSERT INTO `files` (`type`,`poster`,`posted`,`title`,`text`,`format`,`size`) VALUES
19 ('$_POST[type]','$user[name]','$tmp_cur_time','$tmp_title','$tmp_mess','$tmp_format','$tmp_size')";
20 if($realm_db->query($query)){
21 //print" <meta http-equiv=refresh content='0;url=$_GET[backurl]'> "; exit;
22 header("location:$_GET[backurl]");
23 }else{
24 print" <h2> Error ! </h2>";
25 }
26 }
27 elseif($_POST['doadd'] && $_GET['edit'])
28 {
29 $tmp_mess = my_preview($_POST['message'],$user['gmlevel']);
30 $tmp_mess = quote_smart($tmp_mess);
31 $tmp_title = htmlspecialchars(trim("$_POST[title]"));
32 $tmp_format = htmlspecialchars(trim("$_POST[format]"));
33 $tmp_size = $realm_db->escape($_POST['size']);
34 $query = "UPDATE `files` SET `type`='$_POST[type]',`title`='$tmp_title',`text`='$tmp_mess',`format`='$tmp_format',`size`='$tmp_size' WHERE `id`='$_GET[edit]'";
35 if($realm_db->query($query)){
36 //print" <meta http-equiv=refresh content='0;url=$_GET[backurl]'> "; exit;
37 header("location:$_GET[backurl]");
38 }else{
39 print" <h2> Error ! </h2>";
40 }
41 }
42 if($_GET['edit']){
43 $pageq = $realm_db->query("SELECT * FROM `files` WHERE `id`='$_GET[edit]'");
44 $pagecontent = $realm_db->fetch_assoc($pageq);
45 $pagecontent['text'] = my_previewreverse($pagecontent['text']);
46 $button_value = $lang['edit'];
47 }else{
48 $button_value = $lang['add'];
49 }
50
51 foreach($cat_words as $cid => $cat_word){
52 $cat_s .= "<option value='$cid'".($cid==$pagecontent[type] ? ' selected' : '')."> $cat_word </option>\n";
53 }
54
55include('inc/page.header.php');
56?>
57<div class='blogbody'>
58<center>
59<table border='0' cellpadding='0' cellspacing='0' width='90%'>
60<tbody>
61<tr>
62 <td colspan='2'>
63 <br>
64<form method='post' action='<?php echo$_SERVER['PHP_SELF'];?>?n=files/post&edit=<?php echo$_GET['edit'];?>&backurl=<?php echo urlencode($_GET['backurl']);?>'>
65 <?php echo$lang['author'];?>: <b><?php echo$user['name'];?></b><br>
66 <?php echo$lang['title'];?>: <input type='text' size='50' maxlength='255' name='title' value='<?php echo$pagecontent['title'];?>'> <br>
67 <?php echo$lang['type'];?>: <select name='type'>
68 <optgroup label='<?php echo$lang['type'];?>'>
69 <?php echo$cat_s;?>
70 </optgroup>
71 </select> <br>
72 <?php echo$lang['format'];?>: <input type='text' size='50' maxlength='255' name='format' value='<?php echo$pagecontent['format'];?>'> <br>
73 <?php echo$lang['size'];?>: <input type='text' size='50' maxlength='255' name='size' value='<?php echo$pagecontent['size'];?>'> <br>
74 <?php include('inc/page.editor.php');?>
75 <?php echo$lang['text'];?>: <br>
76 <div class="form-item" id="textarea_block">
77 <textarea name='message' cols='60' rows='12' id='textarea' style="width:95%; height:250px;"><?php echo$pagecontent['text'];?></textarea><br>
78 <input class="addbutton" value="<?php echo$lang['editor_preview'];?>" type="button" style="float:left;" onClick="mypreview('preview','textarea');mytoggleview('preview_block');mytoggleview('textarea_block');">
79 <input class="addbutton" value="<?php echo$lang['editor_clear'];?>" type="reset" style="float:right;margin-right:30px;">
80 </div>
81 <div class="form-item" id="preview_block" style="visibility: hidden; display: none; ">
82 <div id="preview" style="background:#fff;border: 1px solid #BFBFBF;padding: 2px 5px 1px 5px; width:95%; height:250px; overflow:auto; margin-top:2px;"></div>
83 <input class="addbutton" value="<?php echo$lang['editor_backtoedit'];?>" type="button" style="float:left;" onClick="clear_innerHTML('preview');mytoggleview('preview_block');mytoggleview('textarea_block');">
84 </div>
85 <br>
86 <input type='submit' name='doadd' value='<?php echo$button_value;?>' class='addbutton'> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
87 <input type='button' value='<?php echo$lang['back'];?>' onClick="javascript:history.go(-1)" class='addbutton'>
88</form>
89
90 </td>
91</tr>
92</tbody></table>
93</center>
94</div>
95<?php
96}
97include('inc/page.footer.php');
98?>
Note: See TracBrowser for help on using the repository browser.