Beispiel #1
0
<?php

//include mysql settings
include_once $_SERVER['DOCUMENT_ROOT'] . '/202-config/connect.php';
//check to see if this is already installed, if so dob't do anything
if (upgrade_needed() == false) {
    _die("<h2>Already Upgraded</h2>\n\t\t\t   Your Prosper202 version {$version} is already upgraded.");
}
if ($_SERVER['REQUEST_METHOD'] == 'POST') {
    if (UPGRADE::upgrade_databases() == true) {
        $success = true;
    } else {
        $error = true;
    }
}
//only show install setup, if it, of course, isn't install already.
if ($success != true) {
    info_top();
    ?>
	
	
	<?php 
    if ($error == true) {
        ?>
	
		<h2 style="color: #900;">An error occured</h2>
		<span style="color: #900;">An unexpected error occured while you were trying to upgrade, please try again or if you keep encountering problems please contact <a href="http://prosper202.com/forum">our support forum</a>.</span>
		<br/><br/>
	<?php 
    }
    ?>
Beispiel #2
0
function update_needed()
{
    global $version;
    $rss = fetch_rss('http://my.tracking202.com/clickserver/currentversion/');
    if (isset($rss->items) && 0 != count($rss->items)) {
        $rss->items = array_slice($rss->items, 0, 1);
        foreach ($rss->items as $item) {
            $latest_version = $item['title'];
            //if current version, is older than the latest version, return true for an update is now needed.
            if (version_compare($version, $latest_version) == '-1') {
                if ($item['autoupgrade'] == 'true') {
                    $decimals = explode('.', $latest_version);
                    $versionCount = count($decimals);
                    $lastDecimal = substr($latest_version, strrpos($latest_version, '.') + 1);
                    if ($versionCount == 2) {
                        $calcVersion = $decimals[0] - 1 . '.9.9';
                    } else {
                        if ($versionCount == 3) {
                            if ($lastDecimal == '1') {
                                if ($decimals[1] == '0') {
                                    $calcVersion = $decimals[0] . '.0';
                                } else {
                                    $calcVersion = $decimals[0] . '.' . $decimals[1] . '.0';
                                }
                            } else {
                                if ($lastDecimal == '0') {
                                    $calcVersion = $decimals[0] . '.' . ($decimals[1] - 1) . '.9';
                                } else {
                                    $calcVersion = $decimals[0] . '.' . $decimals[1] . '.' . ($lastDecimal - 1);
                                }
                            }
                        }
                    }
                    if ($calcVersion == $version) {
                        //Auto upgrade without user confirmation
                        $GetUpdate = @file_get_contents($item['link']);
                        if ($GetUpdate) {
                            if (temp_exists()) {
                                $downloadUpdate = @file_put_contents($_SERVER['DOCUMENT_ROOT'] . '/202-config/temp/prosper202_' . $latest_version . '.zip', $GetUpdate);
                                if ($downloadUpdate) {
                                    $zip = @zip_open($_SERVER['DOCUMENT_ROOT'] . '/202-config/temp/prosper202_' . $latest_version . '.zip');
                                    if ($zip) {
                                        while ($zip_entry = @zip_read($zip)) {
                                            $thisFileName = zip_entry_name($zip_entry);
                                            if (substr($thisFileName, -1, 1) == '/') {
                                                if (is_dir($_SERVER['DOCUMENT_ROOT'] . '/' . $thisFileName)) {
                                                } else {
                                                    if (@mkdir($_SERVER['DOCUMENT_ROOT'] . '/' . $thisFileName, 0755, true)) {
                                                    } else {
                                                    }
                                                }
                                            } else {
                                                $contents = zip_entry_read($zip_entry, zip_entry_filesize($zip_entry));
                                                $file_ext = array_pop(explode(".", $thisFileName));
                                                if ($updateThis = @fopen($_SERVER['DOCUMENT_ROOT'] . '/' . $thisFileName, 'wb')) {
                                                    fwrite($updateThis, $contents);
                                                    fclose($updateThis);
                                                    unset($contents);
                                                } else {
                                                    $log .= "Can't update file:" . $thisFileName . "! Operation aborted";
                                                }
                                            }
                                            $FilesUpdated = true;
                                        }
                                        zip_close($zip);
                                    }
                                } else {
                                    $FilesUpdated = false;
                                }
                            } else {
                                $FilesUpdated = false;
                            }
                        } else {
                            $FilesUpdated = false;
                        }
                        if ($FilesUpdated == true) {
                            include_once $_SERVER['DOCUMENT_ROOT'] . '/202-config/functions-upgrade.php';
                            if (UPGRADE::upgrade_databases(null) == true) {
                                $version = $latest_version;
                                $upgrade_done = true;
                            } else {
                                $upgrade_done = false;
                            }
                        }
                        if ($upgrade_done) {
                            return false;
                        } else {
                            return true;
                        }
                    } else {
                        return true;
                    }
                } else {
                    return true;
                }
            } else {
                return false;
            }
        }
    }
}