Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@kazumich
Last active August 19, 2016 23:56
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 kazumich/d6ddf7511f948e8d62b4 to your computer and use it in GitHub Desktop.
Save kazumich/d6ddf7511f948e8d62b4 to your computer and use it in GitHub Desktop.
ファーストサーバーの Zenlogc に a-blog cms 2.6.1.3 をインストールするためのインストーラーです。 ioncube ローダーも標準インストールされていますが、コントロールパネルで ioncube ローダーのモジュールを有効にする必要があります。
<?php
// --------------------------
//
// Zenlogic用 a-blog cms 2.6.1.3 インストーラー
//
// --------------------------
# インストーラー の
# MySQL の設定を事前に行う場合に
# ここを設定してください。
$dbHost = '127.0.0.1';
$dbName = 'DBacms';
$dbCreate = 'checked';
$dbUser = 'root';
$dbPass = '';
// --------------------------
// a-blog cms Ver. 2.6.1.3 設定
// --------------------------
# ダウンロード元 URL
$download55 = "http://www.a-blogcms.jp/_download/2613/php53x/acms2613_install_53x.zip";
$download56 = "http://www.a-blogcms.jp/_download/2613/php56x/acms2613_install_56x.zip";
# ダウンロード後のZipファイル名
$zipFile = "./acms2613_install.zip";
# 解凍後の全体フォルダ名
$zipAfterDirName55 = "acms2613_install_53x";
$zipAfterDirName56 = "acms2613_install_56x";
# 解凍後の a-blog cms のフォルダ名
$cmsDirName = "ablogcms";
$installPath = realpath('.');
$phpName = basename($_SERVER['PHP_SELF']);
// --------------------------
// バージョンのチェック
// --------------------------
$versionArray = explode(".", phpversion());
$version = $versionArray[0].".".$versionArray[1];
if ($versionArray[1] >= 6) {
$download = $download56;
$zipAfterDirName = $zipAfterDirName56;
} else {
$download = $download55;
$zipAfterDirName = $zipAfterDirName55;
}
$ablogcmsDir = $installPath."/".$zipAfterDirName."/".$cmsDirName."/";
// --------------------------
// a-blog cms ファイルをダウンロード
// --------------------------
$fp = fopen($download, "r");
if ($fp !== FALSE) {
file_put_contents($zipFile, "");
while(!feof($fp)) {
$buffer = fread($fp, 4096);
if ($buffer !== FALSE) {
file_put_contents($zipFile, $buffer, FILE_APPEND);
}
}
fclose($fp);
} else {
echo 'a-blog cms download Error ! : '.$download;
exit;
}
// --------------------------
// a-blog cms ファイルを解凍
// --------------------------
$zip = new ZipArchive();
$res = $zip->open($zipFile);
if($res === true){
$zip->extractTo($installPath);
$zip->close();
} else {
echo 'a-blog cms unZip Error ! : '. $zipFile;
exit;
}
// --------------------------
// a-blog cms ディレクトリを移動
// --------------------------
if ($handle = opendir($ablogcmsDir)) {
while(false !== ($entry = readdir($handle))) {
if ($entry != "." && $entry != "..") {
rename($ablogcmsDir.$entry, $installPath ."/". $entry);
}
}
closedir($handle);
} else {
echo 'a-blog cms move Error ! :'.$ablogcmsDir;
exit;
}
// --------------------------
// .htaccess の設定
// --------------------------
rename($installPath."/htaccess.txt", $installPath.'/.htaccess');
rename($installPath."/archives/htaccess.txt", $installPath.'/archives/.htaccess');
rename($installPath."/private/htaccess.txt", $installPath.'/private/.htaccess');
// --------------------------
// DB 初期設定
// --------------------------
$data = sprintf("<?php
\$dbDefaultHost = '%s';
\$dbDefaultName = '%s';
\$dbDefaultCreate = '%s'; // '' or 'checked'
\$dbDefaultUser = '%s';
\$dbDefaultPass = '%s';
\$dbDefaultPrefix = 'acms_';",$dbHost,$dbName,$dbCreate,$dbUser,$dbPass);
$db_default = $installPath."/setup/lib/db_default.php";
file_put_contents($db_default, $data);
// --------------------------
// ファイルの削除
// --------------------------
unlink($zipFile);
unlink($phpName);
# index.html があった時にリネームしておく
if (is_file("./zenlogic-default.html")) {
rename("./zenlogic-default.html", "_zenlogic-default.html");
}
# プログラム以外のディレクトリを削除
dir_shori("delete", $zipAfterDirName);
// --------------------------
// インストーラーに飛ぶ
// --------------------------
$jump = str_replace($phpName, "", $_SERVER['SCRIPT_NAME']);
header("Location: " . $jump);
// --------------------------
// ディレクトリを操作 function ( move / copy / delete )
// --------------------------
function dir_shori ($shori, $nowDir , $newDir="") {
if ($shori != "delete") {
if (!is_dir($newDir)) {
mkdir($newDir);
}
}
if (is_dir($nowDir)) {
if ($handle = opendir($nowDir)) {
while (($file = readdir($handle)) !== false) {
if ($file != "." && $file != "..") {
if ($shori == "copy") {
if (is_dir($nowDir."/".$file)) {
dir_shori("copy", $nowDir."/".$file, $newDir."/".$file);
} else {
copy($nowDir."/".$file, $newDir."/".$file);
}
} elseif ($shori == "move") {
rename($nowDir."/".$file, $newDir."/".$file);
} elseif ($shori == "delete") {
if (filetype($nowDir."/".$file) == "dir") {
dir_shori("delete", $nowDir."/".$file, "");
} else {
unlink($nowDir."/".$file);
}
}
}
}
closedir($handle);
}
}
if ($shori == "move" || $shori == "delete") {
rmdir($nowDir);
}
return true;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment