No changes
This commit is contained in:
parent
8680a02b13
commit
b6b398f5bf
17374 changed files with 2475441 additions and 0 deletions
207
modules/update/blacklist.css
Normal file
207
modules/update/blacklist.css
Normal file
|
|
@ -0,0 +1,207 @@
|
|||
span.chattrLock{
|
||||
padding-left: 20px;
|
||||
background: url(../../images/locked.png) no-repeat left center;
|
||||
color: black;
|
||||
font-size: 12px;
|
||||
height: 16px;
|
||||
}
|
||||
|
||||
span.chattrUnlock{
|
||||
padding-left: 20px;
|
||||
background: url(../../images/unlocked.png) no-repeat left center;
|
||||
color: black;
|
||||
font-size: 12px;
|
||||
height: 16px;
|
||||
}
|
||||
|
||||
div.chattrButton{
|
||||
color: white;
|
||||
font-size: 12px;
|
||||
height: 16px;
|
||||
text-align: center;
|
||||
vertical-align: middle;
|
||||
padding-right: 16px;
|
||||
cursor:pointer;
|
||||
-webkit-border-radius: 9px;
|
||||
-moz-border-radius: 9px;
|
||||
border-radius: 9px;
|
||||
padding-bottom:2px;
|
||||
width: 150px;
|
||||
}
|
||||
|
||||
/* UNLOCKED */
|
||||
div.chattrButton.unlocked i{
|
||||
background: url(../../images/unlocked.png) no-repeat left center;
|
||||
height:16px;
|
||||
width:16px;
|
||||
display: inline-block;
|
||||
float:left;
|
||||
}
|
||||
|
||||
div.chattrButton.unlocked{
|
||||
border-bottom:2px solid #1e5799;
|
||||
border-right:2px solid #1e5799;
|
||||
border-top:2px solid #7db9e8;
|
||||
border-left:2px solid #7db9e8;
|
||||
background: #7db9e8; /* Old browsers */
|
||||
background: -moz-linear-gradient(top, #7db9e8 0%, #207cca 49%, #2989d8 50%, #1e5799 100%); /* FF3.6+ */
|
||||
background: -webkit-gradient(linear, left top, left bottom, color-stop(0%,#7db9e8), color-stop(49%,#207cca), color-stop(50%,#2989d8), color-stop(100%,#1e5799)); /* Chrome,Safari4+ */
|
||||
background: -webkit-linear-gradient(top, #7db9e8 0%,#207cca 49%,#2989d8 50%,#1e5799 100%); /* Chrome10+,Safari5.1+ */
|
||||
background: -o-linear-gradient(top, #7db9e8 0%,#207cca 49%,#2989d8 50%,#1e5799 100%); /* Opera 11.10+ */
|
||||
background: -ms-linear-gradient(top, #7db9e8 0%,#207cca 49%,#2989d8 50%,#1e5799 100%); /* IE10+ */
|
||||
background: linear-gradient(to bottom, #7db9e8 0%,#207cca 49%,#2989d8 50%,#1e5799 100%); /* W3C */
|
||||
filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#1e5799', endColorstr='#7db9e8',GradientType=0 ); /* IE6-9 */
|
||||
}
|
||||
|
||||
div.chattrButton.unlocked:active{
|
||||
border-top:2px solid #1e5799;
|
||||
border-left:2px solid #1e5799;
|
||||
border-bottom:2px solid #7db9e8;
|
||||
border-right:2px solid #7db9e8;
|
||||
background: #1e5799; /* Old browsers */
|
||||
background: -moz-linear-gradient(top, #1e5799 0%, #2989d8 50%, #207cca 51%, #7db9e8 100%); /* FF3.6+ */
|
||||
background: -webkit-gradient(linear, left top, left bottom, color-stop(0%,#1e5799), color-stop(50%,#2989d8), color-stop(51%,#207cca), color-stop(100%,#7db9e8)); /* Chrome,Safari4+ */
|
||||
background: -webkit-linear-gradient(top, #1e5799 0%,#2989d8 50%,#207cca 51%,#7db9e8 100%); /* Chrome10+,Safari5.1+ */
|
||||
background: -o-linear-gradient(top, #1e5799 0%,#2989d8 50%,#207cca 51%,#7db9e8 100%); /* Opera 11.10+ */
|
||||
background: -ms-linear-gradient(top, #1e5799 0%,#2989d8 50%,#207cca 51%,#7db9e8 100%); /* IE10+ */
|
||||
background: linear-gradient(to bottom, #1e5799 0%,#2989d8 50%,#207cca 51%,#7db9e8 100%); /* W3C */
|
||||
filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#7db9e8', endColorstr='#1e5799',GradientType=0 ); /* IE6-9 */
|
||||
}
|
||||
|
||||
/* LOCKED */
|
||||
div.chattrButton.locked i{
|
||||
background: url(../../images/locked.png) no-repeat left center;
|
||||
height:16px;
|
||||
width:16px;
|
||||
display: inline-block;
|
||||
float:left;
|
||||
}
|
||||
|
||||
div.chattrButton.locked{
|
||||
border-bottom:2px solid #e73827;
|
||||
border-right:2px solid #e73827;
|
||||
border-top:2px solid #f85032;
|
||||
border-left:2px solid #f85032;
|
||||
background: #f85032; /* Old browsers */
|
||||
background: -moz-linear-gradient(top, #f85032 0%, #f16f5c 50%, #f6290c 51%, #f02f17 71%, #e73827 100%); /* FF3.6+ */
|
||||
background: -webkit-gradient(linear, left top, left bottom, color-stop(0%,#f85032), color-stop(50%,#f16f5c), color-stop(51%,#f6290c), color-stop(71%,#f02f17), color-stop(100%,#e73827)); /* Chrome,Safari4+ */
|
||||
background: -webkit-linear-gradient(top, #f85032 0%,#f16f5c 50%,#f6290c 51%,#f02f17 71%,#e73827 100%); /* Chrome10+,Safari5.1+ */
|
||||
background: -o-linear-gradient(top, #f85032 0%,#f16f5c 50%,#f6290c 51%,#f02f17 71%,#e73827 100%); /* Opera 11.10+ */
|
||||
background: -ms-linear-gradient(top, #f85032 0%,#f16f5c 50%,#f6290c 51%,#f02f17 71%,#e73827 100%); /* IE10+ */
|
||||
background: linear-gradient(to bottom, #f85032 0%,#f16f5c 50%,#f6290c 51%,#f02f17 71%,#e73827 100%); /* W3C */
|
||||
filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#f85032', endColorstr='#e73827',GradientType=0 ); /* IE6-9 */
|
||||
}
|
||||
|
||||
div.chattrButton.locked:active{
|
||||
border-top:2px solid #e73827;
|
||||
border-left:2px solid #e73827;
|
||||
border-bottom:2px solid #f85032;
|
||||
border-right:2px solid #f85032;
|
||||
background: #e73827; /* Old browsers */
|
||||
background: -moz-linear-gradient(top, #e73827 0%, #f02f17 29%, #f6290c 49%, #f16f5c 50%, #f85032 100%); /* FF3.6+ */
|
||||
background: -webkit-gradient(linear, left top, left bottom, color-stop(0%,#e73827), color-stop(29%,#f02f17), color-stop(49%,#f6290c), color-stop(50%,#f16f5c), color-stop(100%,#f85032)); /* Chrome,Safari4+ */
|
||||
background: -webkit-linear-gradient(top, #e73827 0%,#f02f17 29%,#f6290c 49%,#f16f5c 50%,#f85032 100%); /* Chrome10+,Safari5.1+ */
|
||||
background: -o-linear-gradient(top, #e73827 0%,#f02f17 29%,#f6290c 49%,#f16f5c 50%,#f85032 100%); /* Opera 11.10+ */
|
||||
background: -ms-linear-gradient(top, #e73827 0%,#f02f17 29%,#f6290c 49%,#f16f5c 50%,#f85032 100%); /* IE10+ */
|
||||
background: linear-gradient(to bottom, #e73827 0%,#f02f17 29%,#f6290c 49%,#f16f5c 50%,#f85032 100%); /* W3C */
|
||||
filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#e73827', endColorstr='#f85032',GradientType=0 ); /* IE6-9 */
|
||||
}
|
||||
|
||||
.viewitem{
|
||||
height:16px;
|
||||
}
|
||||
|
||||
/* File Operations */
|
||||
.file-operations{
|
||||
height:36px;
|
||||
}
|
||||
|
||||
.operations-button{
|
||||
border-bottom:1px solid black;
|
||||
border-right:1px solid black;
|
||||
border-top:1px solid gray;
|
||||
border-left:1px solid gray;
|
||||
display:block;
|
||||
float:left;
|
||||
padding:5px 5px 2px 5px;
|
||||
vertical-align:middle;
|
||||
-webkit-border-radius: 9px;
|
||||
-moz-border-radius: 9px;
|
||||
border-radius: 9px;
|
||||
cursor:pointer;
|
||||
margin-left:5px;
|
||||
margin-bottom:5px;
|
||||
background:#DEDEDE;
|
||||
-webkit-user-select: none;
|
||||
-moz-user-select: none;
|
||||
user-select: none;
|
||||
width:17.5%;
|
||||
}
|
||||
|
||||
.operations-button:active{
|
||||
background:#EFEFEF;
|
||||
border-top:1px solid black;
|
||||
border-left:1px solid black;
|
||||
border-bottom:1px solid gray;
|
||||
border-right:1px solid gray;
|
||||
}
|
||||
|
||||
.operations-button > div{
|
||||
display:block;
|
||||
float:left;
|
||||
position:relative;
|
||||
bottom:2px;
|
||||
}
|
||||
|
||||
.operations-button i{
|
||||
display:block;
|
||||
float:left;
|
||||
width:16px;
|
||||
height:16px;
|
||||
background-size: 16px 16px !important;
|
||||
}
|
||||
|
||||
#remove i{
|
||||
background: url(action-images/remove.gif);
|
||||
}
|
||||
|
||||
#rename i{
|
||||
background: url(action-images/rename.gif);
|
||||
}
|
||||
|
||||
#move i{
|
||||
background: url(action-images/move.gif);
|
||||
}
|
||||
|
||||
#copy i{
|
||||
background: url(action-images/copy.gif);
|
||||
}
|
||||
|
||||
#compress i{
|
||||
background: url(action-images/compress.gif);
|
||||
}
|
||||
|
||||
#uncompress i{
|
||||
background: url(action-images/uncompress.gif);
|
||||
}
|
||||
|
||||
#create_file i{
|
||||
background: url(action-images/create_file.gif);
|
||||
}
|
||||
|
||||
#create_folder i{
|
||||
background: url(action-images/create_folder.gif);
|
||||
}
|
||||
|
||||
#upload i{
|
||||
background: url(action-images/upload.gif);
|
||||
}
|
||||
|
||||
#send_by_email i{
|
||||
background: url(action-images/send_by_email.gif);
|
||||
}
|
||||
|
||||
progress:indeterminate::-moz-progress-bar {
|
||||
background-color: gray;
|
||||
}
|
||||
|
||||
257
modules/update/blacklist.php
Normal file
257
modules/update/blacklist.php
Normal file
|
|
@ -0,0 +1,257 @@
|
|||
<script type="text/javascript" src="js/modules/update.js"></script>
|
||||
<?php
|
||||
/*
|
||||
*
|
||||
* OGP - Open Game Panel
|
||||
* Copyright (C) 2008 - 2018 The OGP Development Team
|
||||
*
|
||||
* http://www.opengamepanel.org/
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License
|
||||
* as published by the Free Software Foundation; either version 2
|
||||
* of the License, or any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
*
|
||||
*/
|
||||
|
||||
function show_back()
|
||||
{
|
||||
if( isset($_SESSION['fm_cwd']) && preg_match("/^\/*$/",$_SESSION['fm_cwd']) == 0 )
|
||||
return "<tr>\n".
|
||||
"<td align=left colspan='2' >\n".
|
||||
"<a href=\"?m=".$_GET['m']."&p=blacklist&back\" style='padding-left:5px;' > .. ".get_lang("level_up")."</a>\n".
|
||||
"</td>\n".
|
||||
"</tr>\n";
|
||||
}
|
||||
|
||||
function path_check()
|
||||
{
|
||||
if (isset($_GET['path']) and !isset( $_POST['save_to_blacklist'] ))
|
||||
{
|
||||
$path = $_GET['path'];
|
||||
// Make sure nobody tries to get outside thier game server by referencing the .. directory
|
||||
if(preg_match("/\.\.|\||;/", $path))
|
||||
{
|
||||
print_failure(get_lang("unallowed_char"));
|
||||
$_SESSION['fm_cwd'] = NULL;
|
||||
return FALSE;
|
||||
}
|
||||
else
|
||||
{
|
||||
$_SESSION['fm_cwd'] = @$_SESSION['fm_cwd'] . "/" . $path;
|
||||
}
|
||||
}
|
||||
|
||||
// To go back a dir, we just use dirname to strip the last directory or file off the path
|
||||
if (isset($_GET['back']) and !isset( $_POST['save_to_blacklist'] ))
|
||||
{
|
||||
$_SESSION['fm_cwd'] = str_replace( "\\", "", dirname( $_SESSION['fm_cwd'] ) );
|
||||
}
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
function exec_ogp_module()
|
||||
{
|
||||
global $db, $view;
|
||||
|
||||
$blacklist = array ('/install.php',
|
||||
'/modules/gamemanager/rsync_sites_local.list');
|
||||
|
||||
$current_blacklist = array();
|
||||
|
||||
$blacklisted_files = $db->resultQuery('SELECT file_path FROM `OGP_DB_PREFIXupdate_blacklist`;');
|
||||
if($blacklisted_files !== FALSE)
|
||||
{
|
||||
$current_blacklist = array();
|
||||
foreach($blacklisted_files as $blacklisted_file)
|
||||
{
|
||||
$current_blacklist[] = $blacklisted_file['file_path'];
|
||||
}
|
||||
}
|
||||
|
||||
if( isset( $_POST['save_to_blacklist'] ) )
|
||||
{
|
||||
foreach($_POST['blacklist'] as $file)
|
||||
{
|
||||
$file = $db->real_escape_string($file);
|
||||
$db->query("INSERT INTO `OGP_DB_PREFIXupdate_blacklist` SET file_path='$file';");
|
||||
}
|
||||
|
||||
foreach($_POST['folder_files'] as $file)
|
||||
{
|
||||
if(in_array($file,$current_blacklist))
|
||||
{
|
||||
if(!in_array($file,$_POST['blacklist']))
|
||||
{
|
||||
$file = $db->real_escape_string($file);
|
||||
$db->query("DELETE FROM `OGP_DB_PREFIXupdate_blacklist` WHERE file_path='$file';");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$blacklisted_files = $db->resultQuery('SELECT file_path FROM `OGP_DB_PREFIXupdate_blacklist`;');
|
||||
if($blacklisted_files !== FALSE)
|
||||
{
|
||||
$current_blacklist = array();
|
||||
foreach($blacklisted_files as $blacklisted_file)
|
||||
{
|
||||
$current_blacklist[] = $blacklisted_file['file_path'];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$current_blacklist = array_merge($current_blacklist,$blacklist);
|
||||
|
||||
path_check();
|
||||
|
||||
echo "<h2>";
|
||||
echo get_lang('blacklist_files');
|
||||
echo "</h2>";
|
||||
|
||||
$baseDir = str_replace( "modules" . DIRECTORY_SEPARATOR . $_GET['m'],"",dirname(__FILE__) );
|
||||
$path = clean_path($baseDir."/".@$_SESSION['fm_cwd']);
|
||||
if (!file_exists($path))
|
||||
{
|
||||
while(!file_exists($path))
|
||||
{
|
||||
$path = dirname($path);
|
||||
$_SESSION['fm_cwd'] = dirname($_SESSION['fm_cwd']);
|
||||
if($path == clean_path($baseDir))
|
||||
{
|
||||
print_failure(get_lang_f("dir_not_found",$path));
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
echo "<table class='center' style='width:100%;' ><tr>\n".
|
||||
"<td colspan='3' ><h3>".
|
||||
get_lang_f('currently_viewing',$path)."</h3></td>".
|
||||
"</tr></table>";
|
||||
|
||||
$dirlist = scandir($path);
|
||||
|
||||
if (!is_array($dirlist))
|
||||
{
|
||||
if($dirlist === -1)
|
||||
{
|
||||
if ( $path != $baseDir . "/" )
|
||||
$view->refresh('?m='.$_GET['m'].'&p=blacklist',0);
|
||||
else
|
||||
print_failure('The path is too long or there is a file with a very long name inside of your game server\'s home folder.');
|
||||
}
|
||||
else
|
||||
{
|
||||
if (file_exists($path))
|
||||
{
|
||||
if(strpos($path, '/') !== FALSE)
|
||||
{
|
||||
$ePath = explode('/', $path);
|
||||
$filename = end($ePath);
|
||||
}
|
||||
else if(strpos($path, '\\') !== FALSE)
|
||||
{
|
||||
$ePath = explode('\\', $path);
|
||||
$filename = end($ePath);
|
||||
}
|
||||
|
||||
$_SESSION['fm_cwd'] = str_replace( "\\", "", dirname( $_SESSION['fm_cwd'] ) );
|
||||
$view->refresh('?m='.$_GET['m'].'&p=blacklist'.'&path='.$filename,0);
|
||||
}
|
||||
else
|
||||
{
|
||||
print_failure(get_lang("failed_list"));
|
||||
}
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
if ( empty($dirlist) )
|
||||
{
|
||||
print_lang('empty_directory');
|
||||
}
|
||||
else
|
||||
{
|
||||
echo "<form method=POST>".
|
||||
"<table class='center' style='width:100%;' >\n"
|
||||
.show_back().
|
||||
"<tr>\n".
|
||||
"<td style='width:10px;' >\n".
|
||||
"<input type='checkbox' onclick='toggleChecked(this.checked)'>\n".
|
||||
"</td>\n".
|
||||
"<td align=left>\n".
|
||||
get_lang('filename').
|
||||
"\n</td>\n".
|
||||
"</tr>\n";
|
||||
|
||||
$directorys = array();
|
||||
$files = array();
|
||||
$x = 0;
|
||||
$basedir_path = rtrim($_SERVER['DOCUMENT_ROOT'].dirname($_SERVER['SCRIPT_NAME']),DIRECTORY_SEPARATOR);
|
||||
$preg_basedir_path = preg_quote($basedir_path,"/");
|
||||
foreach( $dirlist as $item )
|
||||
{
|
||||
# dirlist FM returns an array. Each element has 5 fields separated by the | character
|
||||
if($item == "." or $item == "..")
|
||||
continue;
|
||||
$filename = $item;
|
||||
$filepath = clean_path( $path . "/" . $filename );
|
||||
|
||||
// Directory
|
||||
if(is_dir($filepath))
|
||||
{
|
||||
$directorys[$x]['filename'] = $filename;
|
||||
}
|
||||
// File
|
||||
else
|
||||
{
|
||||
$files[$x]['filename'] = $filename;
|
||||
$files[$x]['filepath'] = preg_replace("/^".$preg_basedir_path."/","",$filepath);
|
||||
}
|
||||
$x++;
|
||||
}
|
||||
|
||||
foreach($directorys as $directory)
|
||||
{
|
||||
echo "<tr>\n".
|
||||
"<td>".
|
||||
"</td>".
|
||||
"<td align=left>".
|
||||
"<img class=\"viewitem\" src=\"images/folder.png\" alt=\"Directory\" /> ".
|
||||
"<a href=\"?m=".$_GET['m']."&p=blacklist&path=" . $directory['filename'] . "\">".
|
||||
$directory['filename'] . "</a></td></tr>\n";
|
||||
}
|
||||
$i = 0;
|
||||
$unchecked = array();
|
||||
foreach($files as $file)
|
||||
{
|
||||
$checked = in_array($file['filepath'],$current_blacklist) ? "checked='checked'" : "";
|
||||
echo "<tr>\n".
|
||||
"<td>".
|
||||
"<input type=checkbox name='blacklist[$i]' value='" . $file['filepath'] . "' class='item' $checked/>\n".
|
||||
"<input type=hidden name='folder_files[$i]' value='" . $file['filepath'] . "' />\n".
|
||||
"</td>".
|
||||
"<td align=left>";
|
||||
echo "<img class=\"viewitem\" src=\"images/txt.png\" alt=\"Text file\" /> ".
|
||||
$file['filename'] . "</td>\n".
|
||||
"</tr>\n";
|
||||
$i++;
|
||||
}
|
||||
|
||||
echo "</table>\n".
|
||||
"<input type=submit name='save_to_blacklist' value='".get_lang('save_to_blacklist')."' />\n".
|
||||
"</form>\n";
|
||||
|
||||
}
|
||||
echo create_back_button($_GET['m']);
|
||||
}
|
||||
?>
|
||||
42
modules/update/module.php
Normal file
42
modules/update/module.php
Normal file
|
|
@ -0,0 +1,42 @@
|
|||
<?php
|
||||
/*
|
||||
*
|
||||
* OGP - Open Game Panel
|
||||
* Copyright (C) 2008 - 2018 The OGP Development Team
|
||||
*
|
||||
* http://www.opengamepanel.org/
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License
|
||||
* as published by the Free Software Foundation; either version 2
|
||||
* of the License, or any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
*
|
||||
*/
|
||||
|
||||
// Module general information
|
||||
$module_title = "Update";
|
||||
$module_version = "1.0";
|
||||
$db_version = 0; // avoid 'duplicate table' error message.
|
||||
$module_required = TRUE;
|
||||
$module_menus = array(
|
||||
array( 'subpage' => '', 'name'=>'Update', 'group'=>'admin' )
|
||||
);
|
||||
|
||||
UNIQUE NOT NULL
|
||||
) ENGINE=MyISAM DEFAULT CHARSET=latin1;");
|
||||
> 1)
|
||||
) AS A
|
||||
);",
|
||||
"ALTER TABLE ".OGP_DB_PREFIX."update_blacklist MODIFY file_path VARCHAR(1000);",
|
||||
"ALTER TABLE ".OGP_DB_PREFIX."update_blacklist ADD UNIQUE (file_path);"
|
||||
);
|
||||
?>
|
||||
6
modules/update/navigation.xml
Normal file
6
modules/update/navigation.xml
Normal file
|
|
@ -0,0 +1,6 @@
|
|||
<navigation>
|
||||
<page key="default" file="update.php" access="admin" />
|
||||
<page key="updating" file="updating.php" access="admin" />
|
||||
<page key="blacklist" file="blacklist.php" access="admin" />
|
||||
<page key="postupdate" file="post_update.php" access="admin" />
|
||||
</navigation>
|
||||
33
modules/update/post_update.php
Normal file
33
modules/update/post_update.php
Normal file
|
|
@ -0,0 +1,33 @@
|
|||
<?php
|
||||
/*
|
||||
*
|
||||
* OGP - Open Game Panel
|
||||
* Copyright (C) 2008 - 2018 The OGP Development Team
|
||||
*
|
||||
* http://www.opengamepanel.org/
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License
|
||||
* as published by the Free Software Foundation; either version 2
|
||||
* of the License, or any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
*
|
||||
*/
|
||||
|
||||
// todo, make checking and updating functions for updateing on the background.
|
||||
// todo, more specified updates in smaller packages
|
||||
|
||||
function exec_ogp_module()
|
||||
{
|
||||
global $db, $settings;
|
||||
runPostUpdateOperations();
|
||||
}
|
||||
?>
|
||||
126
modules/update/unzip.php
Normal file
126
modules/update/unzip.php
Normal file
|
|
@ -0,0 +1,126 @@
|
|||
<?php
|
||||
/*
|
||||
*
|
||||
* OGP - Open Game Panel
|
||||
* Copyright (C) 2008 - 2018 The OGP Development Team
|
||||
*
|
||||
* http://www.opengamepanel.org/
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License
|
||||
* as published by the Free Software Foundation; either version 2
|
||||
* of the License, or any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
*
|
||||
*/
|
||||
|
||||
function extractZip( $zipFile, $extract_path, $remove_path = '', $blacklist = '', $whitelist = '' )
|
||||
{
|
||||
$temp_path = rtrim(sys_get_temp_dir(), DIRECTORY_SEPARATOR) . DIRECTORY_SEPARATOR;
|
||||
$base_path = rtrim(getcwd(), DIRECTORY_SEPARATOR) . DIRECTORY_SEPARATOR;
|
||||
|
||||
if(!file_exists($extract_path))
|
||||
{
|
||||
return "Destination path (${extract_path}) does not exists.\n";
|
||||
}
|
||||
|
||||
if(!is_writable($extract_path))
|
||||
{
|
||||
return "Can't extract to ${extract_path}, not writable.\n";
|
||||
}
|
||||
|
||||
if($zipFile == '' or $extract_path == '')
|
||||
return "Invalid arguments.\n";
|
||||
if( ! file_exists( $zipFile ) )
|
||||
return "Unable to read ${zipFile}.\n";
|
||||
$zip = zip_open($zipFile);
|
||||
$remove_path = addcslashes($remove_path,"/");
|
||||
|
||||
if (is_resource($zip))
|
||||
{
|
||||
$i=0;
|
||||
$i2=0;
|
||||
$extracted_files = array();
|
||||
$ignored_files = array();
|
||||
while ($zip_entry = zip_read($zip))
|
||||
{
|
||||
$filename = zip_entry_name( $zip_entry );
|
||||
$file_path = preg_replace( "/$remove_path/", "", $filename );
|
||||
$dir_path = preg_replace( "/$remove_path/", "", dirname( $filename ) );
|
||||
|
||||
if( isset( $blacklist ) and is_array( $blacklist ) and in_array( $file_path , $blacklist ) )
|
||||
{
|
||||
if( isset( $whitelist ) and is_array( $whitelist ) and in_array( $filename , $whitelist ) )
|
||||
{
|
||||
$ignored_files[$i2] = $file_path;
|
||||
$i2++;
|
||||
}
|
||||
continue;
|
||||
}
|
||||
if( isset( $whitelist ) and is_array( $whitelist ) and !in_array( $filename , $whitelist ) )
|
||||
continue;
|
||||
|
||||
$completePath = $extract_path . $dir_path;
|
||||
$completeName = $extract_path . $file_path;
|
||||
$escaped_temp_path = str_replace('\\', '\\\\', $temp_path);// For Windows paths backslashes
|
||||
$root = preg_match("#^$escaped_temp_path#", $completePath)?$temp_path:$base_path;
|
||||
$escaped_root = str_replace('\\', '\\\\', $root);
|
||||
$relative_path = preg_replace("#^$escaped_root(.*)$#","$1",$completePath);
|
||||
|
||||
// Walk through path to create non existing directories
|
||||
// This won't apply to empty directories ! They are created further below
|
||||
if(!file_exists($completePath) && preg_match( '/^' . $remove_path .'/', dirname(zip_entry_name($zip_entry)) ) )
|
||||
{
|
||||
$tmp = $root;
|
||||
foreach(preg_split('/(\/|\\\\)/',$relative_path) AS $k)
|
||||
{
|
||||
if( $k != "" )
|
||||
{
|
||||
$tmp .= $k.DIRECTORY_SEPARATOR;
|
||||
if( !file_exists($tmp) )
|
||||
{
|
||||
if(!mkdir($tmp, 0777))
|
||||
{
|
||||
return "Unable to write folder ${tmp}.\n";
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (zip_entry_open($zip, $zip_entry, "r"))
|
||||
{
|
||||
if( preg_match( '/^' . $remove_path .'/', dirname(zip_entry_name($zip_entry)) ) )
|
||||
{
|
||||
if ( ! preg_match( "/\/$/", $completeName) )
|
||||
{
|
||||
if ( $fd = fopen($completeName, 'w+'))
|
||||
{
|
||||
fwrite($fd, zip_entry_read($zip_entry, zip_entry_filesize($zip_entry)));
|
||||
fclose($fd);
|
||||
$extracted_files[$i]['filename'] = zip_entry_name($zip_entry);
|
||||
$i++;
|
||||
}
|
||||
else
|
||||
{
|
||||
return "Unable to write file ${completeName}.\n";
|
||||
}
|
||||
}
|
||||
}
|
||||
zip_entry_close($zip_entry);
|
||||
}
|
||||
}
|
||||
zip_close($zip);
|
||||
return array('ignored_files' => $ignored_files, 'extracted_files' => $extracted_files);
|
||||
}
|
||||
return "${zipFile} is corrupt.\n";
|
||||
}
|
||||
?>
|
||||
39
modules/update/update.php
Normal file
39
modules/update/update.php
Normal file
|
|
@ -0,0 +1,39 @@
|
|||
<?php
|
||||
/*
|
||||
*
|
||||
* OGP - Open Game Panel
|
||||
* Copyright (C) 2008 - 2018 The OGP Development Team
|
||||
*
|
||||
* http://www.opengamepanel.org/
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License
|
||||
* as published by the Free Software Foundation; either version 2
|
||||
* of the License, or any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
*
|
||||
*/
|
||||
|
||||
// todo, make checking and updating functions for updateing on the background.
|
||||
// todo, more specified updates in smaller packages
|
||||
function exec_ogp_module()
|
||||
{
|
||||
global $db, $settings;
|
||||
define('REPONAME', 'OGP-Website');
|
||||
|
||||
if ($_SESSION['users_group'] != "admin")
|
||||
{
|
||||
print_failure(get_lang('no_access'));
|
||||
return;
|
||||
}
|
||||
echo "To update the panel, visit our git at http://git.iaregamer.com:3000, download the panel and replace your files.";
|
||||
|
||||
}
|
||||
6
modules/update/updating.css
Normal file
6
modules/update/updating.css
Normal file
|
|
@ -0,0 +1,6 @@
|
|||
h4{
|
||||
width:50%;
|
||||
text-transform:uppercase;
|
||||
text-align:left;
|
||||
margin:0;
|
||||
}
|
||||
310
modules/update/updating.php
Normal file
310
modules/update/updating.php
Normal file
|
|
@ -0,0 +1,310 @@
|
|||
<?php
|
||||
/*
|
||||
*
|
||||
* OGP - Open Game Panel
|
||||
* Copyright (C) 2008 - 2018 The OGP Development Team
|
||||
*
|
||||
* http://www.opengamepanel.org/
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License
|
||||
* as published by the Free Software Foundation; either version 2
|
||||
* of the License, or any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
*
|
||||
*/
|
||||
|
||||
function rmdir_recurse($path) {
|
||||
$path = rtrim($path, '/').'/';
|
||||
$handle = opendir($path);
|
||||
while(false !== ($file = readdir($handle))) {
|
||||
if($file != '.' and $file != '..' ) {
|
||||
$fullpath = $path.$file;
|
||||
if(is_dir($fullpath)) rmdir_recurse($fullpath); else unlink($fullpath);
|
||||
}
|
||||
}
|
||||
closedir($handle);
|
||||
rmdir($path);
|
||||
}
|
||||
|
||||
function exec_ogp_module()
|
||||
{
|
||||
define('REPONAME', 'OGP-Website');
|
||||
if($_SESSION['users_group'] != "admin")
|
||||
{
|
||||
print_failure( get_lang("no_access") );
|
||||
return;
|
||||
}
|
||||
|
||||
global $db, $settings;
|
||||
global $view;
|
||||
|
||||
// GitHub URL
|
||||
if(function_exists("getOGPGitHubURL") && function_exists("getOGPGitHubURLUnstrict")){
|
||||
$gitHubUsername = $settings["custom_github_update_username"];
|
||||
$gitHubURL = getOGPGitHubURL($gitHubUsername, REPONAME);
|
||||
}else{
|
||||
$gitHubURL = "https://github.com/OpenGamePanel/";
|
||||
}
|
||||
|
||||
$vtype = "HubGit";
|
||||
|
||||
echo "<h4>" . get_lang("dwl_update") . "</h4>\n";
|
||||
|
||||
//This is usefull when you are downloading big files, as it
|
||||
//will prevent time out of the script
|
||||
set_time_limit(0);
|
||||
error_reporting(E_ALL);
|
||||
ini_set('display_errors',true);
|
||||
|
||||
$baseDir = str_replace( "modules" . DIRECTORY_SEPARATOR . $_GET['m'],"",dirname(__FILE__) );
|
||||
|
||||
if( !is_writable( $baseDir ) )
|
||||
{
|
||||
if ( ! @chmod( $baseDir, 0755 ) )
|
||||
{
|
||||
print_failure( get_lang_f( 'base_dir_not_writable', $baseDir ) );
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
$temp = get_temp_dir(dirname(__FILE__));
|
||||
|
||||
if( is_writable( $temp ) )
|
||||
{
|
||||
// Download file to temporary folder
|
||||
$temp_dwl = $temp . DIRECTORY_SEPARATOR . $_GET['version'] . '.zip';
|
||||
$dwl = $gitHubURL . REPONAME . '/archive/'.$_GET['version'].'.zip';
|
||||
$zip_raw_data = file_get_contents($dwl);
|
||||
if(! $zip_raw_data)
|
||||
{
|
||||
print_failure( get_lang_f( 'dwl_failed', $url ) );
|
||||
return;
|
||||
}
|
||||
|
||||
file_put_contents($temp_dwl, $zip_raw_data);
|
||||
|
||||
// Check if the file exists and the size is bigger than a 404 error page from sf.net
|
||||
if( file_exists( $temp_dwl ) )
|
||||
{
|
||||
$stat = stat( $temp_dwl );
|
||||
}
|
||||
else
|
||||
{
|
||||
print_failure( get_lang_f( 'dwl_failed', $url ) );
|
||||
return;
|
||||
}
|
||||
|
||||
if( $stat['size'] > 1500 )
|
||||
{
|
||||
print_success(get_lang("dwl_complete"));
|
||||
}
|
||||
else
|
||||
{
|
||||
print_failure( get_lang_f( 'dwl_failed', $url ) );
|
||||
return;
|
||||
}
|
||||
|
||||
echo "<h4>". get_lang("install_update") . "</h4>\n";
|
||||
|
||||
// Set default values for file checkings before installing
|
||||
$not_writable = get_lang("can_not_update_non_writable_files") . " :<br>";
|
||||
$filename = "";
|
||||
$overwritten = 0;
|
||||
$new = 0;
|
||||
$all_writable = TRUE;
|
||||
$filelist = "";
|
||||
$overwritten_files = "";
|
||||
$new_files = "";
|
||||
|
||||
$unwanted_path = REPONAME . "-" . $_GET['version'];
|
||||
$extract_path = $temp . DIRECTORY_SEPARATOR . "OGP_update";
|
||||
if( !file_exists($extract_path) )
|
||||
mkdir($extract_path, 0775);
|
||||
|
||||
$blacklist = array ('/install.php',
|
||||
'/modules/gamemanager/rsync_sites_local.list');
|
||||
|
||||
$blacklisted_files = $db->resultQuery('SELECT file_path FROM `OGP_DB_PREFIXupdate_blacklist`;');
|
||||
if($blacklisted_files !== FALSE)
|
||||
{
|
||||
$current_blacklist = array();
|
||||
foreach($blacklisted_files as $blacklisted_file)
|
||||
{
|
||||
$current_blacklist[] = $blacklisted_file['file_path'];
|
||||
}
|
||||
$blacklist = array_merge($current_blacklist,$blacklist);
|
||||
}
|
||||
|
||||
include ( 'unzip.php' ); // array|false extractZip( string $zipFile, string $extract_path [, string $remove_path, array $blacklist, array $whitelist] )
|
||||
$result = extractZip( $temp_dwl, $extract_path, $unwanted_path, '', '' );
|
||||
if ( is_array( $result['extracted_files'] ) and count($result['extracted_files']) > 0 )
|
||||
{
|
||||
// Check file by file if already exists, if it matches, compares both files
|
||||
// looking for changes determining if the file needs to be updated.
|
||||
// Also determines if the file is writable
|
||||
$filelist = array();
|
||||
$i = 0;
|
||||
foreach( $result['extracted_files'] as $file )
|
||||
{
|
||||
$filename = str_replace( $unwanted_path, "" , $file['filename'] );
|
||||
$temp_file = $extract_path . DIRECTORY_SEPARATOR . $filename;
|
||||
$web_file = $baseDir . $filename;
|
||||
|
||||
if( file_exists( $web_file ) )
|
||||
{
|
||||
$temp = file_get_contents($temp_file);
|
||||
$web = file_get_contents($web_file);
|
||||
|
||||
if( $temp != $web )
|
||||
{
|
||||
if( !is_writable( $web_file ) )
|
||||
{
|
||||
if ( ! @chmod( $web_file, 0775 ) )
|
||||
{
|
||||
$all_writable = FALSE;
|
||||
$not_writable .= $web_file."<br>";
|
||||
}
|
||||
else
|
||||
{
|
||||
$filelist[$i] = $file['filename'];
|
||||
$i++;
|
||||
$overwritten_files .= $filename . "<br>";
|
||||
$overwritten++;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
$filelist[$i] = $file['filename'];
|
||||
$i++;
|
||||
if( !in_array( $filename, $blacklist ) )
|
||||
{
|
||||
$overwritten_files .= $filename . "<br>";
|
||||
$overwritten++;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
$filelist[$i] = $file['filename'];
|
||||
$i++;
|
||||
if( !in_array( $filename, $blacklist ) )
|
||||
{
|
||||
$new_files .= $filename . "<br>";
|
||||
$new++;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
echo $result;
|
||||
$all_writable = FALSE;
|
||||
}
|
||||
|
||||
// Once checking is done the temp folder is removed
|
||||
if( file_exists( $extract_path ) )
|
||||
{
|
||||
rmdir_recurse( $extract_path );
|
||||
}
|
||||
|
||||
if( $all_writable )
|
||||
{
|
||||
// Extract the files that are set in $filelist, to the folder at $baseDir and removes 'upload' from the beginning of the path.
|
||||
|
||||
$result = extractZip( $temp_dwl, preg_replace("/\/$/","",$baseDir), $unwanted_path, $blacklist, $filelist );
|
||||
if( is_array( $result['ignored_files'] ) and !empty( $result['ignored_files'] ) )
|
||||
{
|
||||
print_failure(get_lang_f('ignored_files',count($result['ignored_files'])));
|
||||
echo get_lang_f("not_updated_files_blacklisted", implode("<br>", $result['ignored_files']) );
|
||||
echo "<br><br><br>";
|
||||
}
|
||||
if( is_array( $result['extracted_files'] ) )
|
||||
{
|
||||
// Updated files
|
||||
if ( $overwritten > 0 )
|
||||
{
|
||||
print_success(get_lang_f('files_overwritten',$overwritten));
|
||||
echo get_lang_f( "updated_files", $overwritten_files );
|
||||
}
|
||||
|
||||
if ( $new > 0 )
|
||||
{
|
||||
print_success(get_lang_f('new_files',$new));
|
||||
echo get_lang_f( "updated_files", $new_files );
|
||||
}
|
||||
|
||||
// update version info in db
|
||||
|
||||
$version = $db->real_escape_string($_GET['version']);
|
||||
$db->query("UPDATE OGP_DB_PREFIXsettings SET value = '$version' WHERE setting = 'ogp_version'");
|
||||
$db->query("UPDATE OGP_DB_PREFIXsettings SET value = '$vtype' WHERE setting = 'version_type'");
|
||||
|
||||
// Remove the downloaded package
|
||||
if( file_exists( $temp_dwl ) )
|
||||
//unlink( $temp_dwl );
|
||||
|
||||
// Remove files that are not related to the panel
|
||||
if( file_exists( $baseDir . DIRECTORY_SEPARATOR . $unwanted_path ) )
|
||||
{
|
||||
rmdir_recurse( $baseDir . DIRECTORY_SEPARATOR . $unwanted_path );
|
||||
}
|
||||
|
||||
echo "<br>\n<h4>" . get_lang("updating_modules") ."</h4>\n";
|
||||
|
||||
require_once('modules/modulemanager/module_handling.php');
|
||||
|
||||
$modules = $db->getInstalledModules();
|
||||
// update module manager first
|
||||
foreach ( $modules as $row )
|
||||
{
|
||||
if($row['folder'] == 'modulemanager')
|
||||
{
|
||||
update_module($db, $row['id'], $row['folder']);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
foreach ( $modules as $row )
|
||||
{
|
||||
if($row['folder'] == 'modulemanager')//already updated
|
||||
continue;
|
||||
update_module($db, $row['id'], $row['folder']);
|
||||
}
|
||||
print_success(get_lang("update_complete"));
|
||||
|
||||
// Inject AJAX to run post update operations again (which will reload functions and helpers in case there are changes there we need now that aren't available once this script finishes running
|
||||
echo '<script type="text/javascript">
|
||||
$.get("home.php?m=update&p=postupdate", function(msg){});
|
||||
</script>';
|
||||
|
||||
// Run post update ops
|
||||
if(function_exists("runPostUpdateOperations")){
|
||||
runPostUpdateOperations();
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
echo $result;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
print_failure($not_writable);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
print_failure( get_lang_f( 'temp_folder_not_writable', $temp ) );
|
||||
}
|
||||
}
|
||||
?>
|
||||
Loading…
Add table
Add a link
Reference in a new issue