-
Notifications
You must be signed in to change notification settings - Fork 0
/
admin_vupdate.php
218 lines (200 loc) · 7.74 KB
/
admin_vupdate.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
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
<?php
if(!defined('e107_INIT'))
{
require_once('../../class2.php');
}
if (!getperms("P"))
{
header("location:" . e_BASE . "index.php");
exit;
}
if (e_LANGUAGE != "English" && file_exists("./languages/eversion/" . e_LANGUAGE . ".php"))
{
include_once("./languages/eversion/" . e_LANGUAGE . ".php");
}
else
{
include_once("./languages/eversion/English.php");
}
require_once(e_ADMIN . "auth.php");
$path = e_CURRENT_PLUGIN;
$xml = e107::getXml();
$evrsn_text = "<table class='fborder' width='97%'>";
if (file_exists("plugin.xml") OR file_exists("plugin.php"))
{
// if the plugin.php file exists
if (is_file("e_update.php"))
{
if (file_exists("plugin.xml")) {
include("e_update.php");
$data = $xml->loadXMLfile("plugin.xml", true);
$eplug_name = $path;
$eplug_version = $data['@attributes']['version'];
$eplug_description = $data['summary']['@attributes']['lan'];
$eplug_description = constant($eplug_description);
$evrsn_plugvsn = explode(".", $eplug_version);
}
elseif (file_exists("plugin.php")) {
// if the e_update.php file exists
include($fullPath."plugin.php");
include($fullPath."e_update.php");
$evrsn_plugvsn = explode(".", $eplug_version);
}
$evrsn_text .= "<tr><td class='fcaption'>" . EVERSION_U11 . "</td></tr>
<tr><td class='forumheader3'>" . EVERSION_U3 . " <strong>" . $eplug_name . "</strong><br />
" . EVERSION_U4 . " <strong>" . $eplug_version . "</strong> " . ($evrsn_plugvsn[2] > 0?EVERSION_U8:"") . " <br />
" . EVERSION_U15 . "<strong> " . $eplug_description . "</strong><br />
</td></tr>
<tr><td class='fcaption'>" . EVERSION_U12 . "</td></tr>";
// Get the current installed version from plugin table
if ($sql->db_Select("plugin", "*", "where plugin_path='{$eplug_name}'", "nowhere", false))
{
$evrsn_prow = $sql->db_Fetch();
$evrsn_pversion = $evrsn_prow['plugin_version'];
$evrsn_tmp = explode(".", $evrsn_pversion);
$evrsn_pcurrent = ($evrsn_tmp[0] * 1000) + ($evrsn_tmp[1] * 100) + ($evrsn_tmp[2] * 1);
}
// Get the file contents
$evrsn_content = file_get_contents($evrsn_url);
if (!empty($evrsn_content))
{
// we use the xml version
$evrsn_data = evrsn_xml_parse($evrsn_content);
$nplugins = count($evrsn_data);
foreach ($evrsn_data as $row)
{
if (strtolower(trim($row->plugin)) == strtolower($eplug_name))
{
$evrsn_serversion = $row->version;
$evrsn_author = $row->author;
$evrsn_date = $row->date;
$evrsn_url = $row->url;
}
} // end for
if (!empty($evrsn_serversion))
{
// if not empty
$evrsn_tmpupdate = explode(".", $evrsn_serversion);
$evrsn_update = ($evrsn_tmpupdate[0] * 1000) + ($evrsn_tmpupdate[1] * 100) + ($evrsn_tmpupdate[2] * 1);
$evrsn_tmpcurrent = explode(".", $eplug_version);
$evrsn_current = ($evrsn_tmpcurrent[0] * 1000) + ($evrsn_tmpcurrent[1] * 100) + ($evrsn_tmpcurrent[2] * 1);
if ($evrsn_pcurrent != $evrsn_current)
{
$evrsn_text .= "<tr><td class='forumheader3'>" . ADMIN_UPGRADEPLUGIN_ICON. EVERSION_U19 . " <strong>" . $evrsn_pversion . "</strong> " . EVERSION_U20 . "</td></tr>";
}
$evrsn_nownotbeta = false;
// Check if now not beta
if ($evrsn_tmpupdate[2] == 0 && $evrsn_tmpcurrent[2] > 0)
{
$evrsn_nownotbeta = true;
}
if ($evrsn_update > $evrsn_current || $evrsn_nownotbeta)
{
// if server version greater than installed version
$evrsn_text .= "<tr><td class='forumheader3'>".ADMIN_FALSE_ICON. EVERSION_U7 . " - <strong>" . $evrsn_serversion . "</strong>";
if ($evrsn_tmpupdate[2] > 0)
{
// is it a beta version?
$evrsn_text .= "<br />" . EVERSION_U8;
}
else
{
$evrsn_text .= "<strong> " . EVERSION_U21 . "</strong>";
}
if ($evrsn_date > 0)
{
$evrsn_con = new convert;
$evrsn_text .= "<br />" . EVERSION_U17 . " : <strong>" . $evrsn_con->convert_date($evrsn_date, "long") . "</strong><br />";
}
if (!empty($evrsn_author))
{
$evrsn_text .= "<br />" . EVERSION_U18 . " : <strong>" . $evrsn_author . "</strong><br />";
}
if (!empty($evrsn_url))
{
$evrsn_text .= "<br /><br />" . EVERSION_U13 . " <a href='" . $evrsn_url . "'>" . EVERSION_U14 . "</a><br /> ";
}
$evrsn_text .= "</td></tr>";
}
else
{
// It is the latest version
$evrsn_text .= "<tr><td class='forumheader3'>".ADMIN_TRUE_ICON.EVERSION_U9;
$evrsn_text .= "<br /><br />" . EVERSION_U13 . " <a href='" . $evrsn_url . "'>" . EVERSION_U14 . "</a><br /></td></tr>";
}
}
else
{
// unable to get details from update site
$evrsn_text .= "<tr><td class='forumheader3'>" . EVERSION_U10 . "</td></tr>";
}
}
else
{
// We can not read the file
$evrsn_text .= "<tr><td class='forumheader3'>" . EVERSION_U6 . "</td></tr>";
}
}
else
{
// the e_update.php does not exist
$evrsn_text .= "<tr><td class='forumheader3'>" . EVERSION_U2 . "</td></tr>";
}
}
else
{
// plugin.php does not exist
$evrsn_text .= "<tr><td class='forumheader3'>" . EVERSION_U1 . "</td></tr>";
}
$evrsn_text .= "</table>";
$ns->tablerender(EVERSION_U16, $evrsn_text);
require_once(e_ADMIN . "footer.php");
function evrsn_xml_parse($evrsn_xml_file)
{
global $current_tag, $evrsn_xml_data, $evrsn_counter, $evrsn_list;
$evrsn_xml_data = array("plugin" => "*PLUGINS*PLUGIN",
"version" => "*PLUGINS*VERSION",
"date" => "*PLUGINS*DATE",
"author" => "*PLUGINS*AUTHOR",
"title" => "*PLUGINS*TITLE",
"url" => "*PLUGINS*URL",
"dlpath" => "*PLUGINS*DLPATH"
);
$evrsn_list = array();
$evrsn_counter = 0;
$evrsn_xml_parser = xml_parser_create();
xml_set_element_handler($evrsn_xml_parser, "evrsn_startTag", "evrsn_endTag");
xml_set_character_data_handler($evrsn_xml_parser, "evrsn_contents");
$data = $evrsn_xml_file;
if (!(xml_parse($evrsn_xml_parser, $data, true)))
{
die("Error on line " . xml_get_current_line_number($evrsn_xml_parser));
}
xml_parser_free($evrsn_xml_parser);
return $evrsn_list;
}
function evrsn_startTag($parser, $data)
{
global $current_tag;
$current_tag .= "*$data";
}
function evrsn_endTag($parser, $data)
{
global $current_tag;
$tag_key = strrpos($current_tag, '*');
$current_tag = substr($current_tag, 0, $tag_key);
}
function evrsn_contents($parser, $data)
{
global $current_tag, $evrsn_xml_data, $evrsn_counter, $evrsn_list;
$key = array_search($current_tag, $evrsn_xml_data);
if ($key)
{
$evrsn_list[$evrsn_counter]->$key = $data;
}
if ($key == "url")
{
$evrsn_counter++;
}
}
?>