-
Notifications
You must be signed in to change notification settings - Fork 1
/
admin_docs.php
executable file
·159 lines (122 loc) · 3.74 KB
/
admin_docs.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
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
<?php
/* I codici qui inseriti sono proprietà di
* Francesco Stasi, pertanto ne è vietata la
* vendita e la cessione a terzi senza previa
* autorizzazione dell' autore.
*/
require_once("config.php");
require_once("libs/common.php");
require_once("libs/character_lib.php");
require_once("libs/docs_lib.php");
if(!isset($_SESSION))
{
session_start();
}
logged();
$MyChar_obj=new Character(null,$_SESSION['char_name']);
$MyChar_obj->parseFromDb();
if(!($MyChar_obj->exists())){
echo "Personaggio inesistente.";
exit();
}
$_SESSION['modlevel']=$MyChar_obj->Account()->getModLevel();
$list=new DocList();
?>
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8" />
<meta name="author" content="Francesco Stasi"/>
<title>Gestione Documenti</title>
<!--[if IE]>
<script src="http://html5shiv.googlecode.com/svn/trunk/html5.js"></script>
<![endif]-->
</head>
<body>
<?php
if (isset($_REQUEST['s'])){
//salvo
if(isset($_REQUEST['id']) && !empty($_REQUEST['id']))
$lookId=$_REQUEST['id'];
else
$lookId=null;
$addDoc=new Document(null,$lookId);
$addDoc->readFromDb();
if($addDoc->getEditLevel()>$_SESSION['modlevel']){
echo "Spiacente, permessi insufficienti per modificare il documento.";
}elseif($_REQUEST['delete']==1){
$addDoc->deleteDoc($MyChar_obj->Account());
echo "Documento Cancellato";
}else{
if($addDoc->editDoc($_REQUEST['nome'], $_REQUEST['content'], $MyChar_obj,$_REQUEST['edit_level']) ){
echo "Documento Creato/Modificato";
}
}
}
if (isset($_REQUEST['n'])){
//creazione nuovo documento
$doc_name="";
$doc_content="";
$doc_editTime="";
$doc_editBy="";
$doc_editLevel="";
$flag=true;
}
elseif (isset($_REQUEST['e']) && $_REQUEST['e']>0){
//modifica Documento
$old_doc=new Document(null,$_REQUEST['e']);
$old_doc->readFromDb();
$doc_id=$old_doc->getId();
$doc_name=$old_doc->getName();
$doc_content=$old_doc->getContent();
$doc_editTime=$old_doc->getLastEditTime();
$doc_editBy=$old_doc->getLastEditBy();
$doc_editLevel=$old_doc->getEditLevel();
$flag=true;
}
if($flag){
foreach ($acc_level_array as $key=>$value){
$select="";
if($doc_editLevel==$key) $select="selected=\"select\" ";
$accLst.="<option value=\"$key\" $select >$value</option>\n";
}
?>
<h1>Modifica/Creazione Documento</h1>
<form action="admin_docs.php?s=1" method="post">
<input type="hidden" value="<?php echo $doc_id; ?>" name="id" id="id" />
<div class="width90 center">
<table>
<tr><td width="10%">Nome del Documento</td><td><input type="text" name="nome" value="<?php echo $doc_name; ?>" /></td></tr>
<tr><td>Contenuto</td><td><textarea name="content" style="width:90%" rows="30" ><?php echo $doc_content; ?></textarea></td></tr>
<tr><td>Livello richiesto per modificare</td><td><select name="edit_level"><?php echo $accLst; ?></select></td></tr>
<tr><td colspan="2"> </td></tr>
<tr><td>!!Cancella permanentemente questo Documento</td><td><input type="checkbox" name="delete" value="1" /></td></tr>
<tr><td><a href="admin_docs.php">Indietro</a></td><td><input type="submit" value="Salva"/></td><td></td><td></td></tr>
</table>
</div>
</form>
<?php
}
else {
$list->populateList();
?>
<h1>Gestione della Documentazione</h1>
<ul>
<li><a href="admin_docs.php?n=1">Crea nuovo Documento</a></li>
<li>Modifica esistente
<ul>
<?php
foreach($list->getList() as $k=>$v){
if($v->getEditLevel()>$_SESSION['modlevel'])
continue;
echo "<li><a href=\"admin_docs.php?e={$v->getId()}\">{$v->getName()} (id: {$v->getId()} )</a></li>\n";
}
?>
</ul>
</li>
</ul>
<?php
}
?>
</body>
</html>