-
Notifications
You must be signed in to change notification settings - Fork 3
/
upload.php
164 lines (150 loc) · 7.57 KB
/
upload.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
160
161
162
163
164
<?php
/*
##########################################################################
# #
# Version 4 / / / #
# -----------__---/__---__------__----__---/---/- #
# | /| / /___) / ) (_ ` / ) /___) / / #
# _|/_|/__(___ _(___/_(__)___/___/_(___ _/___/___ #
# Free Content / Management System #
# / #
# #
# #
# Copyright 2005-2011 by webspell.org #
# #
# visit webSPELL.org, webspell.info to get webSPELL for free #
# - Script runs under the GNU GENERAL PUBLIC LICENSE #
# - It's NOT allowed to remove this copyright-tag #
# -- http://www.fsf.org/licensing/licenses/gpl.html #
# #
# Code based on WebSPELL Clanpackage (Michael Gruber - webspell.at), #
# Far Development by Development Team - webspell.org #
# #
# visit webspell.org #
# #
##########################################################################
##########################################################################
# #
# Version 4 / / / #
# -----------__---/__---__------__----__---/---/- #
# | /| / /___) / ) (_ ` / ) /___) / / #
# _|/_|/__(___ _(___/_(__)___/___/_(___ _/___/___ #
# Society / Edition #
# / #
# #
# modified by webspell|k3rmit (Stefan Giesecke) in 2009 #
# #
# - Modifications are released under the GNU GENERAL PUBLIC LICENSE #
# - It is NOT allowed to remove this copyright-tag #
# - http://www.fsf.org/licensing/licenses/gpl.html #
# #
##########################################################################
*/
include("_mysql.php");
include("_settings.php");
include("_functions.php");
$_language->read_module('upload');
if(!isanyadmin($userID)) die($_language->module['no_access']);
if(isset($_GET['cwID'])) {
$filepath = "images/clanwar-screens/";
$table = "clanwars";
$tableid = "cwID";
$id = $_GET['cwID'];
}
elseif(isset($_GET['newsID'])) {
$filepath = "images/news-pics/";
$table = "news";
$tableid = "newsID";
$id = $_GET['newsID'];
}
elseif(isset($_GET['articlesID'])) {
$filepath = "images/articles-pics/";
$table = "articles";
$tableid = "articlesID";
$id = $_GET['articlesID'];
}
else die($_language->module['invalid_access']);
if(isset($_GET['action'])) $action = $_GET['action'];
else $action = null;
if(isset($_POST['submit'])) {
$screen = $_FILES['screen'];
if(!empty($screen['name'])) {
move_uploaded_file($screen['tmp_name'], $filepath.$screen['name']);
@chmod($filepath.$screen['name'], $new_chmod);
$file_ext=strtolower(mb_substr($screen['name'], strrpos($screen['name'], ".")));
$file=$id.'_'.time().$file_ext;
rename($filepath.$screen['name'], $filepath.$file);
$ergebnis=safe_query("SELECT screens FROM ".PREFIX."$table WHERE $tableid='$id'");
$ds=mysql_fetch_array($ergebnis);
$screens=explode("|", $ds['screens']);
$screens[]=$file;
$screens_string=implode("|", $screens);
safe_query("UPDATE ".PREFIX.$table." SET screens='".$screens_string."' WHERE ".$tableid."='".$id."'");
}
header("Location: upload.php?$tableid=$id");
}
elseif($action=="delete") {
$file = $_GET['file'];
if(file_exists($filepath.$file)) @unlink($filepath.$file);
$ergebnis=safe_query("SELECT screens FROM ".PREFIX."$table WHERE $tableid='$id'");
$ds=mysql_fetch_array($ergebnis);
$screens=explode("|", $ds['screens']);
foreach($screens as $pic) {
if($pic != $file) $newscreens[]=$pic;
}
if(is_array($newscreens)) $newscreens_string=implode("|", $newscreens);
safe_query("UPDATE ".PREFIX."$table SET screens='$newscreens_string' WHERE $tableid='$id'");
header("Location: upload.php?$tableid=$id");
}
else {
echo'<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<meta name="description" content="Website using webSPELL 4 CMS - Society Edition" />
<meta name="author" content="webspell.org" />
<meta name="keywords" content="webspell, webspell4, cms, society, edition" />
<meta name="copyright" content="Copyright © 2005 - 2011 by webspell.org" />
<meta name="generator" content="webSPELL" />
<title>'.$_language->module['file_upload'].'</title>
<script src="js/bbcode.js" language="jscript" type="text/javascript"></script>
<link href="_stylesheet.css" rel="stylesheet" type="text/css" />
</head>
<body>
<center>
<h2>'.$_language->module['file_upload'].':</h2>
<form method="post" action="upload.php?'.$tableid.'='.$id.'" enctype="multipart/form-data">
<table width="100%" cellpadding="4" cellspacing="1" bgcolor="'.BORDER.'">
<tr bgcolor="'.BG_1.'">
<td align="center"><input type="file" name="screen" />
<input type="submit" name="submit" value="'.$_language->module['upload'].'" />
<hr />
<h2>'.$_language->module['existing_files'].':</h2>
<table width="100%" border="0" cellspacing="0" cellpadding="2">';
$ergebnis=safe_query("SELECT screens FROM ".PREFIX."$table WHERE $tableid='$id'");
$ds=mysql_fetch_array($ergebnis);
$screens = array();
if(!empty($ds['screens'])) $screens=explode("|", $ds['screens']);
if(is_array($screens)) {
foreach($screens as $screen) {
if($screen!="") {
echo'<tr>
<td><a href="'.$filepath.$screen.'" target="_blank">'.$screen.'</a></td>
<td><input type="text" name="pic" size="70" value="<img src="'.$filepath.$screen.'" border="0" align="left" style="padding:4px;" alt="" />" /></td>
<td><input type="button" onclick="AddCodeFromWindow(\'[img]'.$filepath.$screen.'[/img] \')" value="'.$_language->module['add_to_message'].'" /></td>
<td><input type="button" onclick="MM_confirm(\''.$_language->module['delete'].'\',\'upload.php?action=delete&'.$tableid.'='.$id.'&file='.$screen.'\')" value="'.$_language->module['delete'].'" /></td>
</tr>';
}
}
}
echo'</table>
</td>
</tr>
</table>
</form>
<br /><br /><input type="button" onclick="javascript:self.close()" value="'.$_language->module['close_window'].'" />
</center>
</body>
</html>';
}
?>