forked from delpino73/Blue-Smiley-Organizer
-
Notifications
You must be signed in to change notification settings - Fork 0
/
add-news.php
86 lines (57 loc) · 2.27 KB
/
add-news.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
<?php
require 'class.base.php';
require 'class.html.php';
require 'class.user.php';
$base_instance=new base();
$html_instance=new html();
$user_instance=new user();
$user_instance->check_for_admin();
$title=isset($_POST['title']) ? $_POST['title'] : '';
$text=isset($_POST['text']) ? $_POST['text'] : '';
if (isset($_POST['save'])) {
$error='';
if (!$title) { $error.='<li> Title cannot be left blank'; }
else {
$title=trim($title);
if (strlen($title)>100) { $error.='<li> Title is too long (Max. 100 Characters)'; }
$title=str_replace('"','"',$title);
}
if (!$error) {
$datetime=$_POST['datetime'];
$base_instance->query('INSERT INTO '.$base_instance->entity['NEWS']['MAIN'].' (datetime,text,title) VALUES ("'.sql_safe($datetime).'","'.sql_safe($text).'","'.sql_safe($title).'")');
$news_id=mysqli_insert_id($base_instance->db_link);
$base_instance->show_message('News saved','<a href="edit-news.php?news_id='.$news_id.'">[Edit]</a> <a href="show-news.php">[Show all]</a>');
}
else {
$html_instance->error_message=$error;
$text=stripslashes($text);
$title=stripslashes($title);
}
}
$js='<script language="JavaScript" type="text/javascript">
function bigger(what,add) {
if (what.style.height==\'\') { what.style.height=\'300px\'; }
newHeight=parseInt(what.style.height)+add;
what.style.height=newHeight+"px";
}
function smaller(what,deduct) {
if ((parseInt(what.style.height)-deduct) > 50) {
newHeight=parseInt(what.style.height)-deduct;
what.style.height=newHeight+"px";
} else { newHeight=50; what.style.height="50px"; }
}
</script>';
$html_instance->add_parameter(
array('ACTION'=>'show_form',
'HEADER'=>'Add News',
'HEAD'=>$js,
'TEXT_CENTER'=>'The text added here will appear at <em>Misc > News</em>.<p>',
'FORM_ACTION'=>$_SERVER['PHP_SELF'],
'BUTTON_TEXT'=>'Save News'
));
$html_instance->add_form_field(array('TYPE'=>'text','NAME'=>'title','VALUE'=>"$title",'SIZE'=>50,'TEXT'=>'Title'));
$html_instance->add_form_field(array('TYPE'=>'textarea','NAME'=>'text','VALUE'=>"$text",'COLS'=>90,'ROWS'=>9));
$html_instance->add_form_field(array('TYPE'=>'label','TEXT'=>'<span class="fakelink" onclick="bigger(document.form1.text,100);">[+]</span>
<span class="fakelink" onclick="smaller(document.form1.text,100);">[-]</span>'));
$html_instance->process();
?>