Skip to content

Instantly share code, notes, and snippets.

@hissy

hissy/site_post.php Secret

Last active Dec 27, 2015
Embed
What would you like to do?
<?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
You can’t perform that action at this time.