-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathpublish.php
executable file
·133 lines (109 loc) · 4.43 KB
/
publish.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
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
<?php
require_once('database.php');
class publish {
private $id;
private $article;
private $publish;
private $published;
private $from_date;
private $to_date;
private $counts;
public function __construct(){
$this->id="";$this->article=""; $this->from_date= date("Y-m-d h:i:s");
$this->to_date=date("Y-m-d h:i:s",mktime(0,0,0,date("m")+6,date("d")+1,date("Y")));
$this->counts="";$this->publish="publish";
$this->published="forever";
}
public function restart(){
$this->id="";$this->article="";
$this->from_date="";$this->to_date="";
$this->counts="";$this->publish="";
$this->published="";
}
public function load_publish($publish_id){
$db= new database();
$sql="SELECT * FROM `publish_articles` as m WHERE m.ID='".$publish_id."'";
list($result,$a)=$db->query($sql);
if($result && mysql_num_rows($result)>0){
while ($podaci = mysql_fetch_array($result)){
$this->id=$podaci['ID'];
$this->article=$podaci['article'];
$this->from_date=$podaci['from'];
$this->to_date=$podaci['to'];
$this->publish=$podaci['status'];
$this->published=$podaci['published'];
$this->counts=$podaci['reads'];
};
};
}
public function load_from_post($p){
$this->from_date=$p['published_start'];
$this->to_date=$p['published_end'];
$this->publish=$p['publish_group'];
$this->published=$p['published_group'];
//$this->counts=$p['published_appearances'];
}
public function save_to_database(){
$db= new database();
$sql="INSERT INTO `publish_articles` VALUES(NULL,'".$this->article."','".$this->from_date."','".$this->to_date."','".$this->counts."','".$this->publish."','".$this->published."')";
list($a,$this->id)=$db->query($sql);
return $this->id;
}
public function update_to_database(){
$db= new database();
$sql="UPDATE `publish_articles` SET article='".$this->article."',from='".$this->from_date."',to='".$this->to_date."',reads='".$this->counts."',status='".$this->publish."',published='".$this->published."' WHERE ID='".$this->id."'";
$db->query($sql);
}
public function delete_from_database(){
$db= new database();
$sql="DELETE FROM `publish_articles` WHERE ID='".$this->id."'";
$db->query($sql);
}
public function show_publish_form(){
echo('
<label>Publish</label>
');
if($this->publish=="publish"){
echo('<input name="publish_group" type="radio" id="publish_group_0" value="publish" checked="checked" />
Published');
} else{
echo('<input name="publish_group" type="radio" id="publish_group_0" value="publish" />
Published');
}
if($this->publish=="draft"){
echo('<input name="publish_group" type="radio" id="publish_group_0" value="draft" checked="checked" />
Draft');
} else{
echo('<input name="publish_group" type="radio" id="publish_group_0" value="draft" />
Draft');
}
echo('<br>
<label>Published</label>
');
if($this->published =="forever"){
echo('
<input name="published_group" type="radio" id="published_group_0" value="forever" checked="checked" />
Forever');
} else{
echo('
<input name="published_group" type="radio" id="published_group_0" value="forever" />
Forever');
}
if($this->published =="from"){
echo('
<input name="published_group" type="radio" id="published_group_0" value="from" checked="checked" />
From date');
} else{
echo('
<input name="published_group" type="radio" id="published_group_0" value="from" />
From date');
};
echo('
<label>Start publishing</label>
<input value="'.$this->from_date.'" name="published_start" id="published_start" onFocus="init()" style="background: url("/js/dtp/calendar.png") no-repeat scroll right center rgb(255, 255, 255); padding-right: 20px;" size="15" />
<label>Finish publishing </label>
<input value="'.$this->to_date.'" name="published_end" id="published_end" onFocus="init()" style="background: url("/js/dtp/calendar.png") no-repeat scroll right center rgb(255, 255, 255); padding-right: 20px;" size="15" />
');
}
}
?>