Skip to content

Instantly share code, notes, and snippets.

@hissy
Last active December 27, 2015 07:59
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save hissy/5a24f12024f26f3cd464 to your computer and use it in GitHub Desktop.
Save hissy/5a24f12024f26f3cd464 to your computer and use it in GitHub Desktop.
<?php
$path = 'http://concrete5-japan.org/tools/get_latest_version_number/?APP_VERSION=5.6.1.2';
$req = Request::get();
if ($req->getRequestPath() == 'check_file_get_content') {
$file = Loader::helper('file');
$contents = $file->getContents($path);
if (empty($contents)) {
echo 'ng';
} else {
header('Content-type: text/xml');
echo $contents;
}
exit;
}
if ($req->getRequestPath() == 'check_download_remote_file') {
Loader::library("marketplace");
$r = Marketplace::downloadRemoteFile($path);
if (empty($r) || $r == Package::E_PACKAGE_DOWNLOAD) {
$response = array(Package::E_PACKAGE_DOWNLOAD);
} else if ($r == Package::E_PACKAGE_SAVE) {
$response = array($r);
}
if (isset($response)) {
$errors = Package::mapError($response);
header('Content-Type:text/html; charset=UTF-8');
print_r($errors);
} else {
echo 'ok';
}
exit;
}
if ($req->getRequestPath() == 'check_local_updates') {
Loader::library('update');
$upd = new Update();
$updates = $upd->getLocalAvailableUpdates();
if($updates){
foreach ($updates as $update) {
print_r($update->getUpdateVersion());
}
} else {
echo 'no update';
}
exit;
}
if ($req->getRequestPath() == 'check_updates_contents') {
Loader::library('update');
$fh = Loader::helper('file');
$contents = $fh->getDirectoryContents(DIR_APP_UPDATES);
if($contents) {
foreach($contents as $con) {
if (is_dir(DIR_APP_UPDATES . '/' . $con)) {
$obj = ApplicationUpdate::get($con);
if (is_object($obj)) {
if (version_compare($obj->getUpdateVersion(), APP_VERSION, '>')) {
echo $obj->getUpdateVersion();
} else {
echo 'app version not enough';
}
} else {
echo 'application update is not available';
}
} else {
echo 'directory '.$con.' is not exists';
}
}
} else {
echo 'no directories in updates';
}
exit;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment