CPG 1.6 (PHP7) Upgrade/Install Aid - Page 3 CPG 1.6 (PHP7) Upgrade/Install Aid - Page 3
 

News:

cpg1.5.48 Security release - upgrade mandatory!
The Coppermine development team is releasing a security update for Coppermine in order to counter a recently discovered vulnerability. It is important that all users who run version cpg1.5.46 or older update to this latest version as soon as possible.
[more]

Main Menu

CPG 1.6 (PHP7) Upgrade/Install Aid

Started by ron4mac, March 31, 2017, 10:34:08 PM

Previous topic - Next topic

0 Members and 4 Guests are viewing this topic.

VLK

Quote from: ron4mac on January 22, 2019, 07:38:26 PM
It is being caused by your theme.
http://www.valonkuvaaja.com/kuvagalleria/thumbnails.php?album=28&theme=curve

Look in your theme.php file and change any mysql_xxx_xxx to cpg_db_xxx_xxx.

Thank you very much  :D

Dutch_Master

Regret to report the script isn't working for me.

Script is located at the <web-root>/coppermine/ directory and made executable (chmod +x cpg_installer_stub.php)
Page shows in the webbrowser and I can select the bullet-points I want, but no progress beyond this. Server runs a fully functioning pbpBB3 board (3.2.7 on php7). Apache2 is restarted several times.
Both script and the above /coppermine directory are owned by the same user that owns the phpBB3 directory. Using standard Firefox-esr from Devuan ASCII repo.

Advise is much appreciated. TIA!

ron4mac

#42
What happens when you click this button?


Dutch_Master

It's not there, I'm afraid. (screen-shot possible, if needed)

ron4mac

Can you provide a link to your site or PM me with a link to it?

Dutch_Master

Can't edit messages (or haven't found the button yet!)
This is the contents of the script I have:
cat cpg_installer_stub.php

<?php
/**
 * Coppermine Photo Gallery
 *
 * v1.0 originally written by Gregory Demar
 *
 * @copyright  Copyright (c) 2003-2019 Coppermine Dev Team
 * @license    GNU General Public License version 3 or later; see LICENSE
 *
 * cpg_installer_stub.php (v3.2)
 * @since  1.6.06
 */
error_reporting(-1);
define('UPDATER_LOG''installer.log.txt');

// ================================================== //
// to be added appropriately to the language file(s)
$lang_install_php['no_zip_extn'] = 'The extension providing ZipArchive is not available';
$lang_install_php['delete_log'] = 'Please first delete the log file: <code>'.UPDATER_LOG.'</code>';
$lang_install_php['files_placed_title'] = 'Package files placed';
$lang_install_php['files_placed_msg'] = 'All package files were successfully placed. Click below to complete the install.';
$lang_install_php['complete_install'] = 'Complete Install';
$lang_install_php['select_install'] = 'Please select the package to install.';
$lang_install_php['available_packages'] = 'Available Install Packages';
$lang_install_php['not_writeable'] = '<b>Installation can not be performed</b><br />The following directories are not writeable: ';
$lang_install_php['perform_install'] = 'Install Selected Package';
$lang_install_php['no_installs_title'] = 'No install available';
$lang_install_php['no_installs_msg'] = 'No packages are currently available for you to install';
$lang_install_php['not_possible'] = 'The server is not configured to allow this method to function.<br />PHP needs allow_url_fopen or cURL enabled.';
$lang_install_php['not_found'] = 'Releases of CPG not found at Github';
$lang_install_php['save_error'] = 'Could not save package file. Operation aborted.';
$lang_install_php['pre_warning'] = '<span style="color:red">WARNING: This is a pre-release version!</span>';
$lang_install_php['location'] = 'Install location:';
$lang_install_php['loc_curdir'] = 'New install in the current directory';
$lang_install_php['loc_separate'] = 'New install in a separate directory';
$lang_install_php['upgrade_current'] = 'Upgrade/update the current CPG installation';
// ================================================== //

if (file_exists(UPDATER_LOG)) die($lang_install_php['delete_log']);

if (!
extension_loaded('zip')) {
die($lang_install_php['no_zip_extn']);
}

echo <<<EOT
<!DOCTYPE html>
<html>
<head>
<title>Coppermine Photo Gallery Installer Stub</title>
<script src="//ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js"></script>
<style type="text/css">
input, button, label {cursor: pointer}
button { font-size: 1em }
div.contain { padding: 4em; }
.shead { font-size: 1.2em; font-weight: bold; }
.tableb { background-color: #EEE; }
td.bleed { background-color: #F77; color: #FFB; }
.iloc { margin-bottom: 1em; }
.updt { border-collapse: collapse; margin-bottom: 1em; }
.iloc input, .updt input { margin-left: 1em; margin-right: .5em; }
.oblk:hover { background-color: #EFE }
div.cpg_message_info { background-color: #E8FFE8; border: 1px solid #3C3; border-radius: 4px; padding: 1em; margin-bottom: 1em; }
span.cpg_message_info { }
</style>
</head>
<body>
<div class="contain">
EOT;

$updater = new CPG_Updater();
if (isset(
$_POST['doinst'])) {
$indir = ($_POST['inLoc'] == 's') ? 'cpg16x/' '';
$updater->performUpdate($_POST['updid'], $indir);
$pstrun = ($_POST['inLoc'] == 'u') ? 'update.php' 'install.php';
msg_box($lang_install_php['files_placed_title'], $lang_install_php['files_placed_msg'], 'cpg_message_info'$lang_install_php['complete_install'], $pstrun);
echo <<<EOT
<a href="{$indir}{$pstrun}"><button>{$lang_install_php['complete_install']}</button></a>
EOT;
} else {

echo <<<EOT
<script type="text/javascript">
function hasUpdSelect(frm)
{
if (!$("input[name='updid']:checked").val()) {
alert('
{$lang_install_php['select_install']}');
return false;
}
$('#doinst').hide();
$('#upding').show();
return true;
}
</script>
EOT;

$updates $updater->getUpdates();
//echo'<pre>';var_dump($updates);echo'</pre>';
if ($updates) {
$badDirs $updater->checkCpgDirs();
if ($badDirs) {
$bdmsg implode(','$badDirs);
msg_box('',$lang_install_php['not_writeable'].$bdmsg'cpg_message_error''''');
}
echo '<form id="updForm" action="" method="post" onsubmit="return hasUpdSelect(this);">';
$baseURL $_SERVER['HTTP_HOST'] . dirname($_SERVER['REQUEST_URI']);
$dirURL $baseURL '/cpg16x';
$urad '';
$cChk 'checked ';
if (file_exists('include/config.inc.php')) {
include 'include/config.inc.php';
}
if (!empty($CONFIG['TABLE_PREFIX'])) {
$urad '<input type="radio" name="inLoc" id="inLoc0" value="u" checked /><label for="inLoc0">'.$lang_install_php['upgrade_current'].'</label><br/>';
$cChk '';
}
echo <<<EOT
<div class="iloc">
<span class="shead">
{$lang_install_php['location']}</span><br />
{$urad}
<input type="radio" name="inLoc" id="inLoc1" value="c" 
{$cChk}/><label for="inLoc1">{$lang_install_php['loc_curdir']}</label> ({$baseURL})<br/>
<input type="radio" name="inLoc" id="inLoc2" value="s" /><label for="inLoc2">
{$lang_install_php['loc_separate']}</label> ({$dirURL})
</div>
EOT;
echo '<table class="updt">';
echo '<tr><td colspan="2" class="lhead shead">'.$lang_install_php['available_packages'].'</td></tr>';
foreach ($updates as $k => $updt) {
$xmsg '';
if ($updt['pre']) { $xmsg .= '<br />'.$lang_install_php['pre_warning']; }
$tclass $k%'tableb_alternate' 'tableb';
echo <<<EOT
<tr class="oblk {$tclass}">
<td><input type="radio" name="updid" value="
{$updt['id']}" id="t{$updt['id']}" /></td>
<td><label for="t
{$updt['id']}"><p><b>{$updt['name']}</b>{$xmsg}<br />{$updt['body']}</p></label></td>
</tr>

EOT;
}
echo '<tr class="oblk"><td class="bleed">';
echo '<input type="radio" name="updid" value="-1" id="bldv" />';
echo '</td><td class="bleed">';
echo '<label for="bldv"><p>Get the very latest package (unreleased) with all current developer changes.<br />Recommended only for special circumstances.</p></label>';
echo '</td></tr></table>';
if (!$badDirs) echo '<button type="submit" name="doinst" id="doinst" class="admin">'.$lang_install_php['perform_install'].'</button>';
echo '<img id="upding" width="16" height="16" alt="" src="data:image/gif;base64,R0lGODlhEAAQAPIAANHX3AAAAJ+kqDY3OQAAAFBSVGpucHh7fiH/C05FVFNDQVBFMi4wAwEAAAAh/hpDcmVhdGVkIHdpdGggYWpheGxvYWQuaW5mbwAh+QQJCgAAACwAAAAAEAAQAAADMwi63P4wyklrE2MIOggZnAdOmGYJRbExwroUmcG2LmDEwnHQLVsYOd2mBzkYDAdKa+dIAAAh+QQJCgAAACwAAAAAEAAQAAADNAi63P5OjCEgG4QMu7DmikRxQlFUYDEZIGBMRVsaqHwctXXf7WEYB4Ag1xjihkMZsiUkKhIAIfkECQoAAAAsAAAAABAAEAAAAzYIujIjK8pByJDMlFYvBoVjHA70GU7xSUJhmKtwHPAKzLO9HMaoKwJZ7Rf8AYPDDzKpZBqfvwQAIfkECQoAAAAsAAAAABAAEAAAAzMIumIlK8oyhpHsnFZfhYumCYUhDAQxRIdhHBGqRoKw0R8DYlJd8z0fMDgsGo/IpHI5TAAAIfkECQoAAAAsAAAAABAAEAAAAzIIunInK0rnZBTwGPNMgQwmdsNgXGJUlIWEuR5oWUIpz8pAEAMe6TwfwyYsGo/IpFKSAAAh+QQJCgAAACwAAAAAEAAQAAADMwi6IMKQORfjdOe82p4wGccc4CEuQradylesojEMBgsUc2G7sDX3lQGBMLAJibufbSlKAAAh+QQJCgAAACwAAAAAEAAQAAADMgi63P7wCRHZnFVdmgHu2nFwlWCI3WGc3TSWhUFGxTAUkGCbtgENBMJAEJsxgMLWzpEAACH5BAkKAAAALAAAAAAQABAAAAMyCLrc/jDKSatlQtScKdceCAjDII7HcQ4EMTCpyrCuUBjCYRgHVtqlAiB1YhiCnlsRkAAAOwAAAAAAAAAAAA==" style="display:none" />';
echo '</form>';
} else {
msg_box($lang_install_php['no_installs_title'], $lang_install_php['no_installs_msg'], 'cpg_message_warning''''');
}
}
echo <<<EOT
</div>
</body>
</html>
EOT;

function 
msg_box ($title$message$class$button=''$link='')
{
echo <<<EOT
<div class={$class}><span class={$class}>{$message}</span></div>
EOT;
}

class 
CPG_Updater
{
protected $updates = array();

public function __construct ()
{
global $lang_install_php;

$urld $this->getUrlData('https://api.github.com:443/repos/coppermine-gallery/cpg1.6.x/releases');
$releases json_decode($urld);
if (!$releases) {
die($lang_install_php['not_found']);
}
foreach ($releases as $r) {
// if ($r->prerelease) continue; // don't offer any prereleases
$tag $r->tag_name;
if (preg_match('/\d+\.\d+\.\d+/'$tag$m)) {
$this->updates[] = array(
'id' => $r->id,
'tag' => $m[0],
'pre' => $r->prerelease,
'ball' => $r->zipball_url,
'tball' => $r->tarball_url,
'name' => $r->name,
'body' => nl2br($r->body)
);
}
}
}

public function getUpdates ()
{
return $this->updates;
}

public function performUpdate ($id$inDir='')
{
global $lang_install_php;

$updt null;
if ($id 0) {
$updt = array('tag'=>'v1.6.devlop''ball'=>'https://github.com/coppermine-gallery/cpg1.6.x/archive/develop.zip');
} else foreach ($this->updates as $u) {
if ($u['id'] == $id) {
$updt $u;
break;
}
}

if (!$updt) return;

@unlink(UPDATER_LOG);
$this->logIt("GETTING: {$updt['tag']}");
$tmpf = (sys_get_temp_dir() ?: 'albums/edit').'/cpg_upd_'.time().'.zip';
$newUpdate $this->getUrlData($updt['ball']);
$dlHandler fopen($tmpf'w');
if (!fwrite($dlHandler$newUpdate)) { die($lang_install_php['save_error']); }
fclose($dlHandler);

$f2p = array('anycontent.php'); //files to preserve if they already exist
$p2s = array(); //paths to skip (whether they exist or not)
$zip = new ZipArchive;
$res $zip->open($tmpf);
if ($res === TRUE) {
if ($inDir) {
@mkdir($inDir);
$this->logIt("DIR: {$inDir}");
}
for ($i 0$i $zip->numFiles$i++ ) {
$stat $zip->statIndex($i);
list($bd,$fp) = explode('/'$stat['name'], 2);
if (substr($fp, -1) == '/') {
if ($this->matchedPath($fp$p2s)) continue;
$fp $inDir $fp;
if (!is_dir($fp)) @mkdir($fp);
$this->logIt("DIR: {$fp}");
} elseif ($fp) {
if (in_array($fp$f2p) && file_exists($fp)) continue;
if ($this->matchedPath($fp$p2s)) continue;
$fc $zip->getFromIndex($i);
$fp $inDir $fp;
file_put_contents($fp$fc);
$this->logIt("PUT: {$fp}");
}
}
$zip->close();
} else {
echo 'failed, code:' $res;
}

unlink($tmpf);
}

public function checkCpgDirs ()
{
$cpgDirs = array('.');
$ng = array();
foreach ($cpgDirs as $dir) {
if (!(is_dir($dir) && is_writable($dir))) $ng[] = $dir;
}
return $ng;
}

private function getUrlData ($url)
{
$ua 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_9_3) AppleWebKit/537.75.14 (KHTML, like Gecko) Version/7.0.3 Safari/537.75.14';
if (ini_get('allow_url_fopen')) {
ini_set('user_agent'$ua);
$rfc file_get_contents($url); //var_dump(get_headers($url),$http_response_header);
if (!$rfc) return $this->curly($url$ua);
return $rfc;
} else {
return $this->curly($url$ua);
}
}

private function curly ($url$agent)
{
if (!function_exists('curl_init')) die($lang_install_php['not_possible']);
// create curl resource
$ch curl_init();
// set url
curl_setopt($chCURLOPT_URL$url);
//return the transfer as a string
curl_setopt($chCURLOPT_RETURNTRANSFER1);
curl_setopt($chCURLOPT_USERAGENT$agent);
// curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
// curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0);
curl_setopt($chCURLOPT_FOLLOWLOCATION1);
// $output contains the output string
$output curl_exec($ch);
// close curl resource to free up system resources
curl_close($ch);
// return the data
return $output;
}

private function matchedPath ($file$paths)
{
foreach ($paths as $p) {
$p str_replace('/','\/',$p);
if (preg_match("/^{$p}/"$file)) return true;
}
return false;
}

private function logIt ($msg)
{
file_put_contents(UPDATER_LOG"{$msg}\n"FILE_APPEND);
}

}
//EOF

I'm attempting a clean install of cpg 1.6.06.

The server is on my local LAN (not accessible from the web) as a testbed for future deployment of my forum (which is online but not involved as such). It does have full web access by itself.

ron4mac

The only reason the 'install' button would not show is if the directory is not writeable by your web server (but I thought you should get some message about that). The coppermine directory should be owned by www-data (or whatever your web server group is).

Dutch_Master

Right. I'll change that (the ownership) right-away.

Below the screenshot, I blacked-out some things for privacy reasons, but the full page is shown (no scroll-bars).

Dutch_Master

Right, now I do have the install button! Changing ownership of the coppermine directory to www-data solved the problem. Thanks so much!

MTapester

Hi,

Trying to upgrade from 1.5.42 to the latest

I tossed the upgrader & cpg_installer_stub on the server  and both seem to come up with this Parse error: syntax error, unexpected ':' in /home/content/06/6372506/html/cpg15x/upgrader.php on line 167

looking at that line and it seems to be the same for both.

$tmpf = (sys_get_temp_dir() ?: 'albums/edit').'/cpg_upd_'.time().'.zip';

Anyone run into this before?

ron4mac


MTapester

The server is currently running 5.6

MTapester

Never mind...I jump the gun and 5.6 wasn't active yet....it works now. Sorry and thanks for the help

ninouee

Hello

I'm in 1.5.46 (stable)on ma gallery http://ddstv.fr/galerie/index.php


And when i try to upgrade with "cpg_installer_stub.php" i have this message "No packages are currently available for you to install".

Can you tell me what can i do to fix this?

Thank you

ron4mac

Quote from: ninouee on September 13, 2019, 11:09:11 AM
And when i try to upgrade with "cpg_installer_stub.php" i have this message "No packages are currently available for you to install".
Can you tell me what can i do to fix this?
Your host/site must allow access to remote url data or have the curl extension available for use.  If neither of these can be made available, you will have to update manually.

wburling

I ran the installer and got this error.  How can I correct this?

Coppermine critical error:
Unable to connect to database !

MySQLi said: :

wburling

I reran the update.php and got this.


Welcome to Coppermine update
• • • ERROR • • •
The following errors were encountered and need to be corrected first:
Could not connect to database: vwc1430012575696.
MySQLi said: :
Welcome to Coppermine update
• • • ERROR • • •
The following errors were encountered and need to be corrected first:
Could not connect to database: vwc1430012575696.
MySQLi said: :

ron4mac

In most cases the dbserver in include/config.inc.php should be simply localhost.

$CONFIG['dbserver'] = 'localhost'; // Your database server


Check that...

lkmorlan

Quote from: ron4mac on March 31, 2017, 10:34:08 PM
For currently running CPG 1.5.20+ installations, an assistive script to use for upgrading to a release version of CPG 1.6 was made available here.

Are there any instructions for upgrading from earlier versions? I have been asked to do an upgrade from 1.5.8.

ron4mac

#59
Quote from: lkmorlan on January 28, 2020, 12:47:12 AM
Are there any instructions for upgrading from earlier versions? I have been asked to do an upgrade from 1.5.8.

You should update to CPG 1.5.48 first.
https://documentation.coppermine-gallery.net/en/upgrading.htm
Then you can upgrade to CPG 1.6.x.