-<?php\r
- /*\r
- * Nucleus: PHP/MySQL Weblog CMS (http://nucleuscms.org/)\r
- * Copyright (C) 2002-2005 The Nucleus Group\r
- *\r
- * This program is free software; you can redistribute it and/or\r
- * modify it under the terms of the GNU General Public License\r
- * as published by the Free Software Foundation; either version 2\r
- * of the License, or (at your option) any later version.\r
- * (see nucleus/documentation/index.html#license for more info)\r
- * This script will install the Nucleus tables in your SQL-database, and initialize the data in\r
- * those tables.\r
- */\r
- /**\r
- * Below is a friendly way of letting users on non-php systems know that Nucleus won't run there.\r
- * @license http://nucleuscms.org/license.txt GNU General Public License\r
- * @copyright Copyright (C) 2002-2005 The Nucleus Group\r
- * @version $Id: install.php,v 1.5 2005-04-20 06:53:20 kimitake Exp $\r
- */\r
- ?><div style="font-size: xx-large;">If you see this text in your browser when you open <i>install.php</i>, your web server is not able to run PHP-scripts, and therefor Nucleus will not be able to run there. </div><div style="display: none"><?php */\r
-\r
- /*\r
- This part of the install.php code allows for customization of the install process.\r
- When distributing plugins or skins together with a Nucleus installation, the\r
- configuration below will instruct to install them\r
-\r
- -- Start Of Configurable Part --\r
- */\r
-\r
- // array with names of plugins to install. Plugin files must be present in the nucleus/plugin/\r
- // directory.\r
- //\r
- // example:\r
- // array('NP_TrackBack', 'NP_MemberGoodies')\r
- $aConfPlugsToInstall = array('NP_SkinFiles');\r
-\r
-\r
- // array with skins to install. skins must be present under the skins/ directory with\r
- // a subdirectory having the same name that contains a skinbackup.xml file\r
- //\r
- // example:\r
- // array('base','rsd')\r
- $aConfSkinsToImport = array('default');\r
-\r
- /*\r
- -- End Of Configurable Part --\r
- */\r
-\r
- // don't give warnings for uninitialized vars\r
- error_reporting(E_ERROR | E_WARNING | E_PARSE);\r
-\r
- // make sure there's no unnecessary escaping:\r
- set_magic_quotes_runtime(0);\r
-\r
- // if there are some plugins or skins to import, do not include vars\r
- // in globalfunctions.php again... so set a flag\r
- if ((count($aConfPlugsToInstall) > 0) || (count($aConfSkinsToImport) > 0)) {\r
- global $CONF;\r
- $CONF['installscript']=1;\r
- }\r
- if (phpversion() >= '4.1.0')\r
- include_once('nucleus/libs/vars4.1.0.php');\r
- else\r
- include_once('nucleus/libs/vars4.0.6.php');\r
-\r
- // check if mysql support is installed\r
- if (!function_exists('mysql_query'))\r
- _doError('Your PHP version does not have support for MySQL :(');\r
-\r
- if (postVar('action') == 'go')\r
- doInstall();\r
- else\r
- showInstallForm();\r
- exit;\r
-\r
- function showInstallForm() {\r
-\r
- // 0. pre check if all necessary files exist\r
- doCheckFiles();\r
-\r
- ?>\r
- <!DOCTYPE html\r
- PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">\r
- <html xmlns="http://www.w3.org/1999/xhtml">\r
- <head>\r
- <meta http-equiv="content-type" content="application/xhtml+xml; charset=UTF-8" />\r
- <title>Nucleusのインストール</title>\r
- <style type="text/css"><!--\r
- @import url('nucleus/documentation/styles/manual.css');\r
- --></style>\r
- <script type="text/javascript"><!--\r
- // function to make sure the submit button only gets pressed once\r
- var submitcount=0;\r
- function checkSubmit() {\r
- if (submitcount == 0) {\r
- submitcount++;\r
- return true;\r
- } else {\r
- return false;\r
- }\r
- }\r
- --></script>\r
- </head>\r
- <body>\r
-\r
- <div style='text-align:center'><img src='./nucleus/styles/logo.gif' /></div> <!-- Nucleus logo -->\r
-\r
- <form method="post" action="install.php">\r
-\r
- <h1>Install Nucleus</h1>\r
-\r
- <p>\r
- このスクリプトはNucleusのインストールを手助けします。MySQLテーブルのセットアップと、<i>config.php</i>に入力するための情報を表示します(config.phpのパーミッションを0666にしておけば、後者の作業は自動的に行われます)。これをなす為に、いくつかの情報を入力する必要があります。\r
- </p>\r
-\r
- <p>\r
- すべての欄の入力が必要です。オプション情報はインストールが完了したら、Nucleusの管理領域から設定可能です。\r
- </p>\r
-\r
- <h1>PHP & MySQL Versions</h1>\r
-\r
- <p>\r
- 以下はあなたのウェブホストにおけるPHPインタープリターとMySQLサーバーのバージョンです。Nucleusのサポートフォーラムに問題を報告するときは、この情報を書き添えてください。\r
- </p>\r
-\r
- <ul>\r
- <li>PHP: <?php echo phpversion();\r
- $minVersion = '4.0.6';\r
-\r
- if (phpversion() < $minVersion)\r
- echo ' <span class="warning">注意: Nucleusの動作には少なくともバージョン ',$minVersion,' が必要とされます</span>';\r
- ?></li>\r
- <li>MySQL: <?php\r
- // note: this piece of code is taken from phpMyAdmin\r
-\r
- $result = @mysql_query('SELECT VERSION() AS version');\r
- if ($result != FALSE && @mysql_num_rows($result) > 0) {\r
- $row = mysql_fetch_array($result);\r
- $match = explode('.', $row['version']);\r
- } else {\r
- $result = @mysql_query('SHOW VARIABLES LIKE \'version\'');\r
- if ($result != FALSE && @mysql_num_rows($result) > 0){\r
- $row = mysql_fetch_row($result);\r
- $match = explode('.', $row[1]);\r
- } else {\r
- $match[0] = '?';\r
- $match[1] = '?';\r
- $match[2] = '?';\r
- }\r
- }\r
-\r
- if (!isset($match) || !isset($match[0])) {\r
- $match[0] = 3;\r
- }\r
- if (!isset($match[1])) {\r
- $match[1] = 21;\r
- }\r
- if (!isset($match[2])) {\r
- $match[2] = 0;\r
- }\r
-\r
- if ($match[0] != '?') {\r
- $match[0] = intval($match[0]);\r
- $match[1] = intval($match[1]);\r
- }\r
-\r
- $mysqlVersion = implode($match, '.');\r
- $minVersion = '3.23';\r
-\r
- echo $mysqlVersion;\r
-\r
- if ($mysqlVersion < $minVersion)\r
- echo ' <span class="warning">注意: Nucleusの動作には少なくともバージョン ',$minVersion,' が必要とされます</span>';\r
- ?></li>\r
- </ul>\r
-\r
-<?php\r
- // tell people how they can have their config file filled out automatically\r
- if (@file_exists('config.php') && @!is_writable('config.php')) {\r
-?>\r
- <h1><i>config.php</i>の自動アップデート</h1>\r
-\r
- <p>\r
- もし<em>config.php</em>を自動的に更新するようにしたいなら、書き込み可能にする必要があります。<em>config.php</em>のパーミッションを<strong>666</strong>にしてください。Nucleusのインストール成功後に、パーミッションを<strong>444</strong>に戻さなければなりません(<a href="nucleus/documentation/tips.html#filepermissions">パーミッション変更の簡易ガイド</a>)。\r
- </p>\r
-\r
- <p>\r
- もしファイルに書き込まないという選択をした(あるいは行えない)場合:ご心配なく。インストールの過程で<em>config.php</em>の中身が提供されます。ですから、それをご自身でアップロードしてください。\r
- </p>\r
-\r
-<?php } ?>\r
-\r
- <h1>MySQLのログインデータ</h1>\r
-\r
- <p>\r
- MySQLのデータを以下に入力してください。それらはデータベース・テーブルを作成し情報を入力するために必要なものです。後で、<i>config.php</i>にも記入する必要があります(上記の自動アップデートを利用する場合、その手順は省略されます)。\r
- </p>\r
-\r
- <p>\r
- もしこの情報がわからなければ、システム管理者かホスティング元に連絡をとってください。ほとんどの場合、ホスト名は'localhost'です。もしNucleusがあなたのサーバのPHP設定から'default MySQL host'を検知したなら、'ホスト名'に既に記入されているはずです。もっとも、この情報が正確であるという保証はありません。\r
- </p>\r
-\r
- <fieldset>\r
- <legend>基本のデータベース設定</legend>\r
- <table><tr>\r
- <td>ホスト名:</td>\r
- <td><input name="mySQL_host" value="<?php echo htmlspecialchars(@ini_get('mysql.default_host'))?>" /></td>\r
- </tr><tr>\r
- <td>ユーザー名:</td>\r
- <td><input name="mySQL_user" /></td>\r
- </tr><tr>\r
- <td>パスワード:</td>\r
- <td><input name="mySQL_password" type="password" /></td>\r
- </tr><tr>\r
- <td>データベース名:</td>\r
- <td><input name="mySQL_database" /> (<input name="mySQL_create" value="1" type="checkbox" id="mySQL_create"><label for="mySQL_create" />データベースを作成する必要がある</label>)</td>\r
- </tr></table>\r
- </fieldset>\r
-\r
- <fieldset>\r
- <legend>高等なデータベース設定</legend>\r
- <table><tr>\r
- <td><input name="mySQL_usePrefix" value="1" type="checkbox" id="mySQL_usePrefix"><label for="mySQL_usePrefix" />テーブル・プリフィックスを利用</label></td>\r
- <td><input name="mySQL_tablePrefix" value="" /></td>\r
- </tr></table>\r
- <p>一つのデータベースに複数のNucleusをインストールしており、自分が何をやっているのか理解されている場合を除いては、<strong>これを変更する必要はありません</strong>。</p>\r
- <p>Nucleusによって生成されたすべてのデータベーステーブルは、このプリフィックスが頭につきます。</p>\r
- </fieldset>\r
-\r
- <h1>ディレクトリとURL</h1>\r
-\r
- <p>\r
- このインストールスクリプトはNucleusがインストールされているディレクトリとURLを見つけようとしました。下の値をチェックして必要なら訂正してください。ファイルへのパスとURLはスラッシュ'/'で終わらなくてはなりません。\r
- </p>\r
-\r
- <fieldset>\r
- <legend>URLs and directories</legend>\r
- <table><tr>\r
- <td>Site <strong>URL</strong>:</td>\r
- <td>\r
- <input name="IndexURL" size="60" value="<?php $url = "http://" . serverVar('HTTP_HOST') . serverVar('PHP_SELF');\r
- $url = str_replace("install.php",'',$url);\r
- $url = str_replace("\\","/",$url);\r
- // add slash at end if necessary\r
- if (!endsWithSlash($url)) $url .= '/';\r
- echo $url;\r
- ?>" />\r
- </td>\r
- </tr><tr>\r
- <td>Admin-area <strong>URL</strong>:</td>\r
- <td><input name="AdminURL" size="60" value="<?php if ($url) echo $url . 'nucleus/';\r
- ?>" />\r
- </td>\r
- </tr><tr>\r
- <td>Admin-area <strong>path</strong>:</td>\r
- <td><input name="AdminPath" size="60" value="<?php $path = str_replace("install.php",'',serverVar('SCRIPT_FILENAME'));\r
- $path = str_replace("\\","/",$path);\r
- // add slash at end if necessary\r
- if (!endsWithSlash($path)) $path .= '/';\r
- if($path) echo $path . 'nucleus/';\r
- ?>" />\r
- </td>\r
- </tr><tr>\r
- <td>Media files <strong>URL</strong>:</td>\r
- <td><input name="MediaURL" size="60" value="<?php if ($url) echo $url . 'media/';\r
- ?>" />\r
- </td>\r
- </tr><tr>\r
- <td>Media directory <strong>path</strong>:</td>\r
- <td><input name="MediaPath" size="60" value="<?php $path = str_replace("install.php",'',serverVar('SCRIPT_FILENAME'));\r
- $path = str_replace("\\","/",$path);\r
- // add slash at end if necessary\r
- if (!endsWithSlash($path)) $path .= '/';\r
- if ($path) echo $path . 'media/';\r
- ?>" />\r
- </td>\r
- </tr><tr>\r
- <td>Extra skin files <strong>URL</strong>:</td>\r
- <td><input name="SkinsURL" size="60" value="<?php if ($url) echo $url . 'skins/';\r
- ?>" />\r
- <br />(インポートされたスキンが使用)\r
- </td>\r
- </tr><tr>\r
- <td>Extra skin files directory <strong>path</strong>:</td>\r
- <td><input name="SkinsPath" size="60" value="<?php $path = str_replace("install.php",'',serverVar('SCRIPT_FILENAME'));\r
- $path = str_replace("\\","/",$path);\r
- // add slash at end if necessary\r
- if (!endsWithSlash($path)) $path .= '/';\r
- if ($path) echo $path . 'skins/';\r
- ?>" />\r
- <br />(インポートされたスキンのファイル類を置く場所)\r
- </td>\r
- </tr><tr>\r
- <td>Plugin files <strong>URL</strong>:</td>\r
- <td><input name="PluginURL" size="60" value="<?php if ($url) echo $url . 'nucleus/plugins/';\r
- ?>" />\r
- </td>\r
- </tr><tr>\r
- <td>Action <strong>URL</strong>:</td>\r
- <td><input name="ActionURL" size="60" value="<?php if ($url) echo $url . 'action.php';\r
- ?>" />\r
- <br />(<tt>action.php</tt>へのhttp://から始まるURL)\r
- </td>\r
- </tr></table>\r
- </fieldset>\r
-\r
- <p class="note">\r
- <strong>付記:</strong> 相対パスではなく<strong>絶対パスを使ってください</strong>。通常、絶対パスは<tt>/home/username/public_html/</tt>のような形をとります。Unixシステム(ほとんどのサーバーがそうです)において、パスはスラッシュから始まります。もしこれらの情報入力に問題が生じたら、あなたのサーバ管理者にたずねるべきです。\r
- </p>\r
-\r
- <h1>管理権限をもつユーザー</h1>\r
-\r
- <p>以下に、サイトの最初のユーザーを作成するためのいくつかの情報を入力してください。</p>\r
-\r
- <fieldset>\r
- <legend>管理権限を持つユーザー</legend>\r
- <table><tr>\r
- <td>表示される名前:</td>\r
- <td>\r
- <input name="User_name" value="" />\r
- <small>(許可される文字:a-z と 0-9、最初と最後以外のスペース)</small>\r
- </td>\r
- </tr><tr>\r
- <td>本名(ハンドル名):</td>\r
- <td><input name="User_realname" value="" /></td>\r
- </tr><tr>\r
- <td>パスワード:</td>\r
- <td><input name="User_password" type="password" value="" /></td>\r
- </tr><tr>\r
- <td>パスワードの確認:</td>\r
- <td><input name="User_password2" type="password" value="" /></td>\r
- </tr><tr>\r
- <td>メールアドレス:</td>\r
- <td>\r
- <input name="User_email" value="" />\r
- <small>(利用可能なメールアドレスを入れてください)</small>\r
- </td>\r
- </tr></table>\r
- </fieldset>\r
-\r
- <h1>ウェブログのデータ</h1>\r
-\r
- <p>以下に、デフォルトのweblogを作成するためにいくつかの情報を入力してください。このweblogの名前は、サイト名としても利用されます。</p>\r
-\r
- <fieldset>\r
- <legend>ウェブログのデータ</legend>\r
- <table><tr>\r
- <td>Blog名:</td>\r
- <td><input name="Blog_name" size="60" value="My Nucleus CMS" /></td>\r
- </tr><tr>\r
- <td>Blogの短縮名:</td>\r
- <td>\r
- <input name="Blog_shortname" value="mynucleuscms" />\r
- <small>(許可される文字:a-z と 0-9、スペースは不可)</small>\r
- </td>\r
- </tr></table>\r
- </fieldset>\r
-\r
- <h1>データの送信</h1>\r
-\r
- <p>\r
- 上に書いてきたデータが正しいか確かめてください。よければデータベース・テーブルと最初のデータを設定するために下のボタンを押してください。少し時間がかかるかもしれませんがご辛抱を。<b>ボタンをクリックするのは一回だけにしてください。</b>\r
- </p>\r
-\r
- <p>\r
- <input name="action" value="go" type="hidden" />\r
- <input type="submit" value="Nucleus CMSのインストール" onclick="return checkSubmit();" />\r
- </p>\r
-\r
- </form>\r
-\r
- </body>\r
- </html>\r
-\r
-\r
- <?php }\r
-\r
- function tableName($unPrefixed)\r
- {\r
- global $mysql_usePrefix, $mysql_prefix;\r
- if ($mysql_usePrefix == 1)\r
- return $mysql_prefix . $unPrefixed;\r
- else\r
- return $unPrefixed;\r
- }\r
-\r
- function doInstall() {\r
- global $mysql_usePrefix, $mysql_prefix;\r
-\r
- // 0. put all POST-vars into vars\r
- $mysql_host = postVar('mySQL_host');\r
- $mysql_user = postVar('mySQL_user');\r
- $mysql_password = postVar('mySQL_password');\r
- $mysql_database = postVar('mySQL_database');\r
- $mysql_create = postVar('mySQL_create');\r
- $mysql_usePrefix = postVar('mySQL_usePrefix');\r
- $mysql_prefix = postVar('mySQL_tablePrefix');\r
- $config_indexurl = postVar('IndexURL');\r
- $config_adminurl = postVar('AdminURL');\r
- $config_adminpath = postVar('AdminPath');\r
- $config_mediaurl = postVar('MediaURL');\r
- $config_skinsurl = postVar('SkinsURL');\r
- $config_pluginurl = postVar('PluginURL');\r
- $config_actionurl = postVar('ActionURL');\r
- $config_mediapath = postVar('MediaPath');\r
- $config_skinspath = postVar('SkinsPath');\r
- $user_name = postVar('User_name');\r
- $user_realname = postVar('User_realname');\r
- $user_password = postVar('User_password');\r
- $user_password2 = postVar('User_password2');\r
- $user_email = postVar('User_email');\r
- $blog_name = postVar('Blog_name');\r
- $blog_shortname = postVar('Blog_shortname');\r
- $config_adminemail = $user_email;\r
- $config_sitename = $blog_name;\r
-\r
-\r
- $config_indexurl = str_replace("\\","/",$config_indexurl);\r
- $config_adminurl = str_replace("\\","/",$config_adminurl);\r
- $config_mediaurl = str_replace("\\","/",$config_mediaurl);\r
- $config_skinsurl = str_replace("\\","/",$config_skinsurl);\r
- $config_pluginurl = str_replace("\\","/",$config_pluginurl);\r
- $config_actionurl = str_replace("\\","/",$config_actionurl);\r
- $config_adminpath = str_replace("\\","/",$config_adminpath);\r
- $config_skinspath = str_replace("\\","/",$config_skinspath);\r
-\r
- // 1. check all the data\r
- $errors = array();\r
-\r
- if (!$mysql_database)\r
- array_push($errors,"mySQL database name missing");\r
- if (($mysql_usePrefix == 1) && (strlen($mysql_prefix) == 0))\r
- array_push($errors,"mySQL prefix was selected, but prefix is empty");\r
- if (($mysql_usePrefix == 1) && (!eregi('^[a-zA-Z0-9_]+$', $mysql_prefix)))\r
- array_push($errors,"mySQL prefix should only contain characters from the ranges A-Z, a-z, 0-9 or underscores");\r
- if (!endsWithSlash($config_indexurl) || !endsWithSlash($config_adminurl)\r
- || !endsWithSlash($config_mediaurl)\r
- || !endsWithSlash($config_pluginurl)\r
- || !endsWithSlash($config_skinsurl)\r
- // TODO: add action.php check\r
- )\r
- array_push($errors,"One of the URLs does not end with a slash, or action url does not end with 'action.php'");\r
- if (!endsWithSlash($config_adminpath))\r
- array_push($errors,"The path of the administration area does not end with a slash");\r
- if (!endsWithSlash($config_mediapath))\r
- array_push($errors,"The media path does not end with a slash");\r
- if (!endsWithSlash($config_skinspath))\r
- array_push($errors,"The skins path does not end with a slash");\r
- if (!is_dir($config_adminpath))\r
- array_push($errors,"The path of the administration area does not exist on your server");\r
- if (!_isValidMailAddress($user_email))\r
- array_push($errors,"Invalid e-mail address given for user");\r
- if (!_isValidDisplayName($user_name))\r
- array_push($errors,"User name is not a valid display name (allowed chars: a-zA-Z0-9 and spaces)");\r
- if (!$user_password || !$user_password2)\r
- array_push($errors, "User password is empty");\r
- if ($user_password != $user_password2)\r
- array_push($errors, "User password do not match");\r
- if (!_isValidShortName($blog_shortname))\r
- array_push($errors, "Invalid short name given for blog (allowed chars: a-z0-9, no spaces)");\r
- if (sizeof($errors) > 0)\r
- showErrorMessages($errors);\r
-\r
- // 2. try to log in to mySQL\r
- $connection = @mysql_connect($mysql_host, $mysql_user, $mysql_password);\r
- if ($connection == false)\r
- _doError("Could not connect to mySQL server: " . mysql_error());\r
-\r
- // 3. try to create database (if needed)\r
- if ($mysql_create == 1) {\r
- mysql_query("CREATE DATABASE " . $mysql_database) or _doError("Could not create database. Make sure you have the rights to do so. SQL error was: " . mysql_error());\r
- }\r
-\r
- // 4. try to select database\r
- mysql_select_db($mysql_database) or _doError("Could not select database. Make sure it exists");\r
-\r
- // 5. execute queries\r
- $filename = "install.sql";\r
- $fd = fopen ($filename, "r");\r
- $queries = fread ($fd, filesize ($filename));\r
- fclose ($fd);\r
-\r
- $queries = split("(;\n|;\r)",$queries);\r
-\r
- $aTableNames = array(\r
- 'nucleus_actionlog',\r
- 'nucleus_ban',\r
- 'nucleus_blog',\r
- 'nucleus_category',\r
- 'nucleus_comment',\r
- 'nucleus_config',\r
- 'nucleus_item',\r
- 'nucleus_karma',\r
- 'nucleus_member',\r
- 'nucleus_plugin',\r
- 'nucleus_skin',\r
- 'nucleus_template',\r
- 'nucleus_team',\r
- 'nucleus_activation',\r
- 'nucleus_tickets'\r
-// these are unneeded (one of the replacements above takes care of them)\r
-// 'nucleus_plugin_event',\r
-// 'nucleus_plugin_option',\r
-// 'nucleus_plugin_option_desc',\r
-// 'nucleus_skin_desc',\r
-// 'nucleus_template_desc',\r
- );\r
- $aTableNamesPrefixed = array(\r
- $mysql_prefix . 'nucleus_actionlog',\r
- $mysql_prefix . 'nucleus_ban',\r
- $mysql_prefix . 'nucleus_blog',\r
- $mysql_prefix . 'nucleus_category',\r
- $mysql_prefix . 'nucleus_comment',\r
- $mysql_prefix . 'nucleus_config',\r
- $mysql_prefix . 'nucleus_item',\r
- $mysql_prefix . 'nucleus_karma',\r
- $mysql_prefix . 'nucleus_member',\r
- $mysql_prefix . 'nucleus_plugin',\r
- $mysql_prefix . 'nucleus_skin',\r
- $mysql_prefix . 'nucleus_template',\r
- $mysql_prefix . 'nucleus_team',\r
- $mysql_prefix . 'nucleus_activation',\r
- $mysql_prefix . 'nucleus_tickets'\r
-// these are unneeded (one of the replacements above takes care of them)\r
-// $mysql_prefix . 'nucleus_plugin_event',\r
-// $mysql_prefix . 'nucleus_plugin_option',\r
-// $mysql_prefix . 'nucleus_plugin_option_desc',\r
-// $mysql_prefix . 'nucleus_skin_desc',\r
-// $mysql_prefix . 'nucleus_template_desc',\r
- );\r
-\r
- for ($idx = 0;$idx<sizeof($queries);$idx++) {\r
- $query = trim($queries[$idx]);\r
- // echo "QUERY = <small>" . htmlspecialchars($query) . "</small><p>";\r
- if ($query) {\r
- if ($mysql_usePrefix == 1)\r
- $query = str_replace($aTableNames, $aTableNamesPrefixed, $query);\r
- mysql_query($query) or _doError("Error while executing query (<small>" . htmlspecialchars($query) . "</small>): " . mysql_error());\r
- }\r
-\r
- }\r
-\r
- // 6. update global settings\r
- updateConfig('IndexURL', $config_indexurl);\r
- updateConfig('AdminURL', $config_adminurl);\r
- updateConfig('MediaURL', $config_mediaurl);\r
- updateConfig('SkinsURL', $config_skinsurl);\r
- updateConfig('PluginURL', $config_pluginurl);\r
- updateConfig('ActionURL', $config_actionurl);\r
- updateConfig('AdminEmail', $config_adminemail);\r
- updateConfig('SiteName', $config_sitename);\r
-\r
-\r
- // 7. update GOD member\r
- $query = 'UPDATE ' . tableName('nucleus_member')\r
- . " SET mname='" . addslashes($user_name) . "',"\r
- . " mrealname='". addslashes($user_realname) . "',"\r
- . " mpassword='". md5(addslashes($user_password)) . "',"\r
- . " murl='" . addslashes($config_indexurl) . "',"\r
- . " memail='" . addslashes($user_email) . "',"\r
- . " madmin=1,"\r
- . " mcanlogin=1"\r
- . " WHERE mnumber=1";\r
- mysql_query($query) or _doError("Error while setting member settings: " . mysql_error());\r
-\r
- // 8. update weblog settings\r
- $query = 'UPDATE ' . tableName('nucleus_blog')\r
- . " SET bname='" . addslashes($blog_name) . "',"\r
- . " bshortname='". addslashes($blog_shortname) . "',"\r
- . " burl='" . addslashes($config_indexurl) . "'"\r
- . " WHERE bnumber=1";\r
- mysql_query($query) or _doError("Error while setting weblog settings: " . mysql_error());\r
-\r
- // 9. update item date\r
- $query = 'UPDATE ' . tableName('nucleus_item')\r
- . " SET itime='". date("Y-m-d H:i:s",time()) ."'"\r
- . " WHERE inumber=1";\r
- mysql_query($query) or _doError("Error with query: " . mysql_error());\r
-\r
- global $aConfPlugsToInstall, $aConfSkinsToImport;\r
- $aSkinErrors = array();\r
- $aPlugErrors = array();\r
- if ((count($aConfPlugsToInstall) > 0) || (count($aConfSkinsToImport) > 0)) {\r
- // 10. set global variables\r
- global $MYSQL_HOST, $MYSQL_USER, $MYSQL_PASSWORD, $MYSQL_DATABASE, $MYSQL_PREFIX;\r
- $MYSQL_HOST = $mysql_host;\r
- $MYSQL_USER = $mysql_user;\r
- $MYSQL_PASSWORD = $mysql_password;\r
- $MYSQL_DATABASE = $mysql_database;\r
- $MYSQL_PREFIX = ($mysql_usePrefix == 1)?$mysql_prefix:'';\r
- global $DIR_NUCLEUS, $DIR_MEDIA, $DIR_SKINS, $DIR_PLUGINS, $DIR_LANG, $DIR_LIBS;\r
- $DIR_NUCLEUS = $config_adminpath;\r
- $DIR_MEDIA = $config_mediapath;\r
- $DIR_SKINS = $config_skinspath;\r
- $DIR_PLUGINS = $DIR_NUCLEUS . 'plugins/';\r
- $DIR_LANG = $DIR_NUCLEUS . 'language/';\r
- $DIR_LIBS = $DIR_NUCLEUS . 'libs/';\r
-\r
- // close database connection (needs to be closed if we want to include globalfunctions.php)\r
- mysql_close();\r
-\r
- $manager = '';\r
- include_once($DIR_LIBS . 'globalfunctions.php');\r
-\r
- // 11. install custom skins\r
- $aSkinErrors = installCustomSkins($manager);\r
-\r
- // 12. install custom plugins\r
- $aPlugErrors = installCustomPlugs($manager);\r
-\r
- }\r
-\r
-\r
- // 12. Write config file ourselves (if possible)\r
- $bConfigWritten = 0;\r
- if (@file_exists('config.php') && is_writable('config.php') && $fp = @fopen('config.php', 'w')) {\r
- $config_data = "<" . "?php \n";\r
- $config_data .= "\n";\r
- $config_data .= " // mySQL connection information\n";\r
- $config_data .= " \$MYSQL_HOST = '" . $mysql_host . "';\n";\r
- $config_data .= " \$MYSQL_USER = '" . $mysql_user . "';\n";\r
- $config_data .= " \$MYSQL_PASSWORD = '" . $mysql_password . "';\n";\r
- $config_data .= " \$MYSQL_DATABASE = '" . $mysql_database . "';\n";\r
- $config_data .= " \$MYSQL_PREFIX = '" . (($mysql_usePrefix == 1)?$mysql_prefix:'') . "';\n";\r
- $config_data .= "\n";\r
- $config_data .= " // main nucleus directory\n";\r
- $config_data .= " \$DIR_NUCLEUS = '" . $config_adminpath . "';\n";\r
- $config_data .= "\n";\r
- $config_data .= " // path to media dir\n";\r
- $config_data .= " \$DIR_MEDIA = '" . $config_mediapath . "';\n";\r
- $config_data .= "\n";\r
- $config_data .= " // extra skin files for imported skins\n";\r
- $config_data .= " \$DIR_SKINS = '" . $config_skinspath . "';\n";\r
- $config_data .= "\n";\r
- $config_data .= " // these dirs are normally sub dirs of the nucleus dir, but \n";\r
- $config_data .= " // you can redefine them if you wish\n";\r
- $config_data .= " \$DIR_PLUGINS = \$DIR_NUCLEUS . 'plugins/';\n";\r
- $config_data .= " \$DIR_LANG = \$DIR_NUCLEUS . 'language/';\n";\r
- $config_data .= " \$DIR_LIBS = \$DIR_NUCLEUS . 'libs/';\n";\r
- $config_data .= "\n";\r
- $config_data .= " // include libs\n";\r
- $config_data .= " include(\$DIR_LIBS.'globalfunctions.php');\n";\r
- $config_data .= " if (!extension_loaded('mbstring')) {\n";\r
- $config_data .= " include(\$DIR_LIBS.'mb_emulator/mb-emulator.php');\n";\r
- $config_data .= " }\n";\r
- $config_data .= "?" . ">";\r
-\r
- $result = @fputs($fp, $config_data, strlen($config_data));\r
- fclose($fp);\r
-\r
- if ($result)\r
- $bConfigWritten = 1;\r
- }\r
-\r
- ?>\r
-<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">\r
- <html xmlns="http://www.w3.org/1999/xhtml">\r
- <head>\r
- <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />\r
- <title>Nucleusのインストール</title>\r
- <style>\r
- @import url('nucleus/styles/manual.css');\r
- </style>\r
- </head>\r
- <body>\r
- <div style='text-align:center'><img src='./nucleus/styles/logo.gif' /></div> <!-- Nucleus logo -->\r
-<?php\r
- $aAllErrors = array_merge($aSkinErrors, $aPlugErrors);\r
- if (count($aAllErrors) > 0) {\r
- echo '<h1>Skin/Plugin Install errors</h1>';\r
- echo '<ul><li>'.implode('</li><li>', $aAllErrors).'</li></ul>';\r
- }\r
-\r
- if (!$bConfigWritten) { ?>\r
- <h1>インストールはほぼ完了しました!</h1>\r
- <p>\r
- データベーステーブルの初期値入力が成功しました。後は<i>config.php</i>を書き換えるだけです。以下に書き換えるべき内容を表示します(mysqlのパスワードはマスクされています。ここは実際のものに書き換えてください)\r
- </p>\r
-\r
- <pre>\r
-<?php\r
- // mySQL connection information\r
- $MYSQL_HOST = '<b><?php echo $mysql_host?></b>';\r
- $MYSQL_USER = '<b><?php echo $mysql_user?></b>';\r
- $MYSQL_PASSWORD = '<i><b>xxxxxxxxxxx</b></i>';\r
- $MYSQL_DATABASE = '<b><?php echo $mysql_database?></b>';\r
- $MYSQL_PREFIX = '<b><?php echo ($mysql_usePrefix == 1)?$mysql_prefix:''?></b>';\r
-\r
- // main nucleus directory\r
- $DIR_NUCLEUS = '<b><?php echo $config_adminpath?></b>';\r
-\r
- // path to media dir\r
- $DIR_MEDIA = '<b><?php echo $config_mediapath?></b>';\r
-\r
- // extra skin files for imported skins\r
- $DIR_SKINS = '<b><?php echo $config_skinspath?></b>';\r
-\r
- // these dirs are normally sub dirs of the nucleus dir, but\r
- // you can redefine them if you wish\r
- $DIR_PLUGINS = $DIR_NUCLEUS . 'plugins/';\r
- $DIR_LANG = $DIR_NUCLEUS . 'language/';\r
- $DIR_LIBS = $DIR_NUCLEUS . 'libs/';\r
-\r
- // include libs\r
- include($DIR_LIBS.'globalfunctions.php');\r
- if (!extension_loaded('mbstring')) {\r
- include($DIR_LIBS.'mb_emulator/mb-emulator.php');\r
- }\r
-?>\r
- </pre>\r
-\r
- <p>あなたのコンピュータ上のファイルを書き換えたら、FTPを使ってウェブサーバにアップロードしてください。ASCIIモードで送信してファイルを上書きします。\r
- </p>\r
-\r
- <div class="note">\r
- <b>付記:</b> <i>config.php</i>の最初や終わりにスペースを空けないようにしましょう。実行時にエラーを引き起こす原因となります。\r
- <br />\r
- したがって、config.phpの最初の文字は "<"で最後の文字は">"としなければなりません。\r
- </div>\r
-\r
-<?php } else { ?>\r
- <h1>インストールは完了しました!</h1>\r
-\r
- <p>Nucleusはインストールされ、<code>config.php</code>はアップデートされました。</p>\r
-\r
- <p>セキュリティのため<code>config.php</code>のパーミッションを444に戻すことを忘れないでください(<a href="nucleus/documentation/tips.html#filepermissions">パーミッション変更の簡易ガイド</a>)。</p>\r
-<?php } ?>\r
- <h1>インストールファイルの削除</h1>\r
-\r
- <p>ウェブサーバから次のファイルを削除してください:</p>\r
-\r
- <ul>\r
- <li><b>install.sql</b>:テーブルの構造を内包するファイル</li>\r
- <li><b>install.php</b>:このファイル</li>\r
- </ul>\r
-\r
- <p>もしこれらのファイルを削除していなければ、管理領域を開くことが出来ません。</p>\r
-\r
- <h1>ウェブサイトの確認</h1>\r
- <p>\r
- ウェブサイトを使う準備が整いました。\r
- <ul>\r
- <li><a href="<?php echo $config_adminurl?>">管理領域にログインしてサイトの設定を行う</a></li>\r
- <li><a href="<?php echo $config_indexurl?>">すぐにサイトへ行ってみる</a></li>\r
- </ul>\r
- </p>\r
-\r
- </body>\r
- </html>\r
- <?php\r
- }\r
-\r
-\r
- function installCustomPlugs(&$manager) {\r
- global $aConfPlugsToInstall, $DIR_LIBS;\r
-\r
- $aErrors = array();\r
-\r
- if (count($aConfPlugsToInstall) == 0)\r
- return $aErrors;\r
-\r
- $numCurrent = mysql_num_rows(sql_query('SELECT * FROM '.sql_table('plugin')));\r
-\r
- foreach ($aConfPlugsToInstall as $plugName) {\r
- // do this before calling getPlugin (in case the plugin id is used there)\r
- $query = 'INSERT INTO '.sql_table('plugin').' (porder, pfile) VALUES ('.(++$numCurrent).',"'.addslashes($plugName).'")';\r
- sql_query($query);\r
-\r
- // get and install the plugin\r
- $plugin =& $manager->getPlugin($plugName);\r
- if (!$plugin) {\r
- sql_query('DELETE FROM ' . sql_table('plugin') . ' WHERE pfile=\''. addslashes($plugName).'\'');\r
- $numCurrent--;\r
- array_push($aErrors, 'Unable to install plugin ' . $plugName);\r
- continue;\r
- }\r
- $plugin->install();\r
- }\r
-\r
- // SYNC PLUGIN EVENT LIST\r
- sql_query('DELETE FROM '.sql_table('plugin_event'));\r
- // loop over all installed plugins\r
- $res = sql_query('SELECT pid, pfile FROM '.sql_table('plugin'));\r
- while($o = mysql_fetch_object($res)) {\r
- $pid = $o->pid;\r
- $plug =& $manager->getPlugin($o->pfile);\r
- if ($plug)\r
- {\r
- $eventList = $plug->getEventList();\r
- foreach ($eventList as $eventName) \r
- sql_query('INSERT INTO '.sql_table('plugin_event').' (pid, event) VALUES ('.$pid.', \''.$eventName.'\')');\r
- }\r
- }\r
-\r
- return $aErrors;\r
- }\r
-\r
- function installCustomSkins(&$manager) {\r
- global $aConfSkinsToImport, $DIR_LIBS, $DIR_SKINS;\r
-\r
- $aErrors = array();\r
-\r
- if (count($aConfSkinsToImport) == 0)\r
- return $aErrors;\r
-\r
- // load skinie class\r
- include_once($DIR_LIBS . 'skinie.php');\r
-\r
- $importer = new SKINIMPORT();\r
-\r
- foreach ($aConfSkinsToImport as $skinName) {\r
- $importer->reset();\r
-\r
- $skinFile = $DIR_SKINS . $skinName . '/skinbackup.xml';\r
- if (!@file_exists($skinFile)) {\r
- array_push($aErrors, 'Unable to import ' . $skinFile . ' : file does not exist');\r
- continue;\r
- }\r
- $error = $importer->readFile($skinFile);\r
- if ($error) {\r
- array_push($aErrors, 'Unable to import ' . $skinName . ' : ' . $error);\r
- continue;\r
- }\r
- $error = $importer->writeToDatabase(1);\r
- if ($error) {\r
- array_push($aErrors, 'Unable to import ' . $skinName . ' : ' . $error);\r
- continue;\r
- }\r
- }\r
-\r
- return $aErrors;\r
- }\r
-\r
- // give an error if one or more nucleus are not accessible\r
- function doCheckFiles() {\r
- $missingfiles = array();\r
-\r
- if (!is_readable('install.sql'))\r
- array_push($missingfiles, "File <b>install.sql</b> is missing or not readable");\r
- if (!is_readable('index.php'))\r
- array_push($missingfiles, "File <b>index.php</b> is missing or not readable");\r
- if (!is_readable('action.php'))\r
- array_push($missingfiles, "File <b>action.php</b> is missing or not readable");\r
- if (!is_readable('nucleus/index.php'))\r
- array_push($missingfiles, "File <b>nucleus/index.php</b> is missing or not readable");\r
- if (!is_readable('nucleus/libs/globalfunctions.php'))\r
- array_push($missingfiles, "File <b>nucleus/libs/globalfunctions.php</b> is missing or not readable");\r
- if (!is_readable('nucleus/libs/ADMIN.php'))\r
- array_push($missingfiles, "File <b>nucleus/libs/ADMIN.php</b> is missing or not readable");\r
- if (!is_readable('nucleus/libs/BLOG.php'))\r
- array_push($missingfiles, "File <b>nucleus/libs/BLOG.php</b> is missing or not readable");\r
- if (!is_readable('nucleus/libs/COMMENT.php'))\r
- array_push($missingfiles, "File <b>nucleus/libs/COMMENT.php</b> is missing or not readable");\r
- if (!is_readable('nucleus/libs/COMMENTS.php'))\r
- array_push($missingfiles, "File <b>nucleus/libs/COMMENTS.php</b> is missing or not readable");\r
- if (!is_readable('nucleus/libs/ITEM.php'))\r
- array_push($missingfiles, "File <b>nucleus/libs/ITEM.php</b> is missing or not readable");\r
- if (!is_readable('nucleus/libs/MEMBER.php'))\r
- array_push($missingfiles, "File <b>nucleus/libs/MEMBER.php</b> is missing or not readable");\r
- if (!is_readable('nucleus/libs/SKIN.php'))\r
- array_push($missingfiles, "File <b>nucleus/libs/SKIN.php</b> is missing or not readable");\r
- if (!is_readable('nucleus/libs/TEMPLATE.php'))\r
- array_push($missingfiles, "File <b>nucleus/libs/TEMPLATE.php</b> is missing or not readable");\r
- if (!is_readable('nucleus/libs/MEDIA.php'))\r
- array_push($missingfiles, "File <b>nucleus/libs/MEDIA.php</b> is missing or not readable");\r
- if (!is_readable('nucleus/libs/ACTIONLOG.php'))\r
- array_push($missingfiles, "File <b>nucleus/libs/ACTIONLOG.php</b> is missing or not readable");\r
- if (!is_readable('nucleus/media.php'))\r
- array_push($missingfiles, "File <b>nucleus/media.php</b> is missing or not readable");\r
-\r
-\r
- if (sizeof($missingfiles) > 0)\r
- showErrorMessages($missingfiles);\r
-\r
-\r
- }\r
-\r
- function updateConfig($name, $val) {\r
- $name = addslashes($name);\r
- $val = trim(addslashes($val));\r
-\r
- $query = 'UPDATE ' . tableName('nucleus_config')\r
- . " SET value='$val'"\r
- . " WHERE name='$name'";\r
-\r
- mysql_query($query) or _doError("Query error while trying to update config: " . mysql_error());\r
- return mysql_insert_id();\r
- }\r
-\r
- function endsWithSlash($s) {\r
- return (strrpos($s,'/') == strlen($s) - 1);\r
- }\r
-\r
- /**\r
- * Checks if email address is valid\r
- */\r
- function _isValidMailAddress($address) {\r
- if (preg_match("/^[a-zA-Z0-9\._-]+@+[A-Za-z0-9\._-]+\.+[A-Za-z]{2,4}$/", $address))\r
- return 1;\r
- else\r
- return 0;\r
- }\r
-\r
- // returns true if the given string is a valid shortname\r
- // (to check short blog names and nicknames)\r
- // logic: starts and ends with a non space, can contain spaces in between\r
- // min 2 chars\r
- function _isValidShortName($name) {\r
- if (eregi("^[a-z0-9]+$", $name))\r
- return 1;\r
- else\r
- return 0;\r
- }\r
-\r
-\r
-\r
- // returns true if the given string is a valid display name\r
- // (to check nicknames)\r
- function _isValidDisplayName($name) {\r
- if (eregi("^[a-z0-9]+[a-z0-9 ]*[a-z0-9]+$", $name))\r
- return 1;\r
- else\r
- return 0;\r
- }\r
-\r
- function _doError($msg) {\r
- ?>\r
-<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">\r
- <html xmlns="http://www.w3.org/1999/xhtml">\r
- <head>\r
- <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />\r
- <title>Nucleus Install</title>\r
- <style>\r
- @import url('nucleus/styles/manual.css');\r
- </style>\r
- </head>\r
- <body>\r
- <div style='text-align:center'><img src='./nucleus/styles/logo.gif' /></div> <!-- Nucleus logo -->\r
- <h1>Error!</h1>\r
- <p>\r
- Error message was: "<?php echo $msg?>";\r
- </p>\r
-\r
- <p>\r
- <a href="install.php" onclick="history.back();return false;">Go Back</a>\r
- </p>\r
- </body>\r
- </html>\r
- <?php exit;\r
- }\r
-\r
- function showErrorMessages($errors) {\r
- ?>\r
-<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">\r
- <html xmlns="http://www.w3.org/1999/xhtml">\r
- <head>\r
- <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />\r
- <title>Nucleus Install</title>\r
- <style>\r
- @import url('nucleus/styles/manual.css');\r
- </style>\r
- </head>\r
- <body>\r
- <div style='text-align:center'><img src='./nucleus/styles/logo.gif' /></div> <!-- Nucleus logo -->\r
- <h1>Errors!</h1>\r
- <p>\r
- Errors were found:\r
- </p>\r
-\r
- <ul>\r
- <?php while($msg = array_shift($errors))\r
- echo "<li>$msg</li>";\r
- ?>\r
- </ul>\r
-\r
- <p>\r
- <a href="install.php" onclick="history.back();return false;">Go Back</a>\r
- </p>\r
- </body>\r
- </html>\r
- <?php exit;\r
- }\r
-\r
-\r
- /* for the non-php systems that decide to show the contents:\r
- ?></div><?php */\r
-\r
-?>\r
+<?php
+/*
+ * Nucleus: PHP/MySQL Weblog CMS (http://nucleuscms.org/)
+ * Copyright (C) 2002-2006 The Nucleus Group
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ * (see nucleus/documentation/index.html#license for more info)
+ * This script will install the Nucleus tables in your SQL-database, and initialize the data in
+ * those tables.
+ *
+ * Below is a friendly way of letting users on non-php systems know that Nucleus won't run there.
+ * ?><div style="font-size: xx-large;">If you see this text in your browser when you open <i>install.php</i>, your web server is not able to run PHP-scripts, and therefor Nucleus will not be able to run there. </div><div style="display: none"><?php
+ */
+
+/**
+ * @license http://nucleuscms.org/license.txt GNU General Public License
+ * @copyright Copyright (C) 2002-2006 The Nucleus Group
+ * @version $Id: install.php,v 1.6 2006-07-17 19:59:46 kimitake Exp $
+ * $NucleusJP$
+ */
+
+/*
+ This part of the install.php code allows for customization of the install process.
+ When distributing plugins or skins together with a Nucleus installation, the
+ configuration below will instruct to install them
+
+ -- Start Of Configurable Part --
+*/
+
+// array with names of plugins to install. Plugin files must be present in the nucleus/plugin/
+// directory.
+//
+// example:
+// array('NP_TrackBack', 'NP_MemberGoodies')
+$aConfPlugsToInstall = array('NP_SkinFiles');
+
+
+// array with skins to install. skins must be present under the skins/ directory with
+// a subdirectory having the same name that contains a skinbackup.xml file
+//
+// example:
+// array('base','rsd')
+$aConfSkinsToImport = array('default');
+
+/*
+ -- End Of Configurable Part --
+*/
+
+// don't give warnings for uninitialized vars
+error_reporting(E_ERROR | E_WARNING | E_PARSE);
+
+// make sure there's no unnecessary escaping:
+set_magic_quotes_runtime(0);
+
+// if there are some plugins or skins to import, do not include vars
+// in globalfunctions.php again... so set a flag
+if ((count($aConfPlugsToInstall) > 0) || (count($aConfSkinsToImport) > 0) ) {
+ global $CONF;
+ $CONF['installscript'] = 1;
+}
+
+if (phpversion() >= '4.1.0') {
+ include_once('nucleus/libs/vars4.1.0.php');
+} else {
+ include_once('nucleus/libs/vars4.0.6.php');
+}
+
+include_once('nucleus/libs/mysql.php');
+
+// check if mysql support is installed
+ if (!function_exists('mysql_query') ) {
+ _doError('Your PHP version does not have support for MySQL :(');
+ }
+
+ if (postVar('action') == 'go') {
+ doInstall();
+ } else {
+ showInstallForm();
+ }
+
+ exit;
+
+function showInstallForm() {
+ // 0. pre check if all necessary files exist
+ doCheckFiles();
+
+ ?>
+ <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
+ <html xmlns="http://www.w3.org/1999/xhtml">
+ <head>
+ <meta http-equiv="content-type" content="application/xhtml+xml; charset=UTF-8" />
+ <title>Nucleusのインストール</title>
+ <style type="text/css"><!--
+ @import url('nucleus/documentation/styles/manual.css');
+ --></style>
+ <script type="text/javascript"><!--
+ var submitcount = 0;
+
+ // function to make sure the submit button only gets pressed once
+ function checkSubmit() {
+ if (submitcount == 0) {
+ submitcount++;
+ return true;
+ } else {
+ return false;
+ }
+ }
+ --></script>
+ </head>
+ <body>
+ <div style="text-align:center"><img src="./nucleus/styles/logo.gif" /></div> <!-- Nucleus logo -->
+ <form method="post" action="install.php">
+
+ <h1>Install Nucleus</h1>
+
+ <p>このスクリプトはNucleusのインストールを手助けします。MySQLテーブルのセットアップと、<i>config.php</i>に入力するための情報を表示します(config.phpのパーミッションを0666にしておけば、後者の作業は自動的に行われます)。これをなす為に、いくつかの情報を入力する必要があります。</p>
+
+ <p>すべての欄の入力が必要です。オプション情報はインストールが完了したら、Nucleusの管理領域から設定可能です。</p>
+
+ <h1>PHP & MySQL Versions</h1>
+
+ <p>以下はあなたのウェブホストにおけるPHPインタープリターとMySQLサーバーのバージョンです。Nucleusのサポートフォーラムに問題を報告するときは、この情報を書き添えてください。</p>
+
+ <ul>
+ <li>PHP:
+
+<?php
+ echo phpversion();
+ $minVersion = '4.0.6';
+
+ if (phpversion() < $minVersion) {
+ echo ' <span class="warning">注意: Nucleusの動作には少なくともバージョン ',$minVersion,' が必要とされます</span>';
+ }
+?>
+
+ </li>
+ <li>MySQL:
+
+<?php
+ // note: this piece of code is taken from phpMyAdmin
+ $result = @mysql_query('SELECT VERSION() AS version');
+
+ if ($result != FALSE && @mysql_num_rows($result) > 0) {
+ $row = mysql_fetch_array($result);
+ $match = explode('.', $row['version']);
+ } else {
+ $result = @mysql_query('SHOW VARIABLES LIKE \'version\'');
+
+ if ($result != FALSE && @mysql_num_rows($result) > 0) {
+ $row = mysql_fetch_row($result);
+ $match = explode('.', $row[1]);
+ } else {
+ $match[0] = '?';
+ $match[1] = '?';
+ $match[2] = '?';
+ }
+ }
+
+ if (!isset($match) || !isset($match[0]) ) {
+ $match[0] = 3;
+ }
+
+ if (!isset($match[1]) ) {
+ $match[1] = 21;
+ }
+
+ if (!isset($match[2]) ) {
+ $match[2] = 0;
+ }
+
+ if ($match[0] != '?') {
+ $match[0] = intval($match[0]);
+ $match[1] = intval($match[1]);
+ }
+
+ $mysqlVersion = implode($match, '.');
+ $minVersion = '3.23';
+
+ echo $mysqlVersion;
+
+ if ($mysqlVersion < $minVersion) {
+ echo ' <span class="warning">注意: Nucleusの動作には少なくともバージョン ',$minVersion,' が必要とされます</span>';
+ }
+?>
+
+ </li>
+ </ul>
+
+<?php
+ // tell people how they can have their config file filled out automatically
+ if (@file_exists('config.php') && @!is_writable('config.php') ) {
+?>
+
+ <h1><i>config.php</i>の自動アップデート</h1>
+
+ <p>もし<em>config.php</em>を自動的に更新するようにしたいなら、書き込み可能にする必要があります。<em>config.php</em>のパーミッションを<strong>666</strong>にしてください。Nucleusのインストール成功後に、パーミッションを<strong>444</strong>に戻さなければなりません(<a href="nucleus/documentation/tips.html#filepermissions">パーミッション変更の簡易ガイド</a>)。</p>
+
+ <p>もしファイルに書き込まないという選択をした(あるいは行えない)場合:ご心配なく。インストールの過程で<em>config.php</em>の中身が提供されます。ですから、それをご自身でアップロードしてください。</p>
+
+<?php } ?>
+
+ <h1>MySQLのログインデータ</h1>
+
+ <p>MySQLのデータを以下に入力してください。それらはデータベース・テーブルを作成し情報を入力するために必要なものです。後で、<i>config.php</i>にも記入する必要があります(上記の自動アップデートを利用する場合、その手順は省略されます)。</p>
+
+ <p>もしこの情報がわからなければ、システム管理者かホスティング元に連絡をとってください。ほとんどの場合、ホスト名は'localhost'です。もしNucleusがあなたのサーバのPHP設定から'default MySQL host'を検知したなら、'ホスト名'に既に記入されているはずです。もっとも、この情報が正確であるという保証はありません。</p>
+
+ <fieldset>
+ <legend>基本のデータベース設定</legend>
+ <table>
+ <tr>
+ <td>ホスト名:</td>
+ <td><input name="mySQL_host" value="<?php echo htmlspecialchars(@ini_get('mysql.default_host') )?>" /></td>
+ </tr>
+ <tr>
+ <td>ユーザー名:</td>
+ <td><input name="mySQL_user" /></td>
+ </tr>
+ <tr>
+ <td>パスワード:</td>
+ <td><input name="mySQL_password" type="password" /></td>
+ </tr>
+ <tr>
+ <td>データベース名:</td>
+ <td><input name="mySQL_database" /> (<input name="mySQL_create" value="1" type="checkbox" id="mySQL_create"><label for="mySQL_create" />データベースを作成する必要がある</label>)</td>
+ </tr>
+ </table>
+ </fieldset>
+
+ <fieldset>
+ <legend>高等なデータベース設定</legend>
+ <table>
+ <tr>
+ <td><input name="mySQL_usePrefix" value="1" type="checkbox" id="mySQL_usePrefix"><label for="mySQL_usePrefix" />テーブル・プリフィックスを利用</label></td>
+ <td><input name="mySQL_tablePrefix" value="" /></td>
+ </tr>
+ </table>
+
+ <p>一つのデータベースに複数のNucleusをインストールしており、自分が何をやっているのか理解されている場合を除いては、<strong>これを変更する必要はありません</strong>。</p>
+ <p>Nucleusによって生成されたすべてのデータベーステーブルは、このプリフィックスが頭につきます。</p>
+ </fieldset>
+
+ <h1>ディレクトリとURL</h1>
+
+ <p>このインストールスクリプトはNucleusがインストールされているディレクトリとURLを見つけようとしました。下の値をチェックして必要なら訂正してください。ファイルへのパスとURLはスラッシュ'/'で終わらなくてはなりません。</p>
+
+<?php
+
+ // no need to this all! dirname(__FILE__) is all we need -- moraes
+ /*
+ // discover full path
+ $fullPath = serverVar('PATH_TRANSLATED');
+
+ if ($fullPath == '') {
+ $fullPath = serverVar('SCRIPT_FILENAME');
+ }
+
+ $basePath = str_replace('install.php', '', $fullPath);
+ $basePath = replaceDoubleBackslash($basePath);
+ $basePath = replaceDoubleBackslash($basePath);
+
+ // add slash at end if necessary
+ if (!endsWithSlash($basePath) ) {
+ $basePath .= '/';
+ }
+ */
+
+ $basePath = dirname(__FILE__) . '/';
+?>
+
+ <fieldset>
+ <legend>URLs and directories</legend>
+ <table>
+ <tr>
+ <td>Site <strong>URL</strong>:</td>
+ <td><input name="IndexURL" size="60" value="<?php
+ $url = 'http://' . serverVar('HTTP_HOST') . serverVar('PHP_SELF');
+ $url = str_replace('install.php', '', $url);
+ $url = replaceDoubleBackslash($url);
+
+ // add slash at end if necessary
+ if (!endsWithSlash($url) ) {
+ $url .= '/';
+ }
+
+ echo $url; ?>" /></td>
+ </tr>
+ <tr>
+ <td>Admin-area <strong>URL</strong>:</td>
+ <td><input name="AdminURL" size="60" value="<?php
+ if ($url) {
+ echo $url, 'nucleus/';
+ } ?>" /></td>
+ </tr>
+ <tr>
+ <td>Admin-area <strong>path</strong>:</td>
+ <td><input name="AdminPath" size="60" value="<?php
+ if($basePath) {
+ echo $basePath, 'nucleus/';
+ } ?>" /></td>
+ </tr>
+ <tr>
+ <td>Media files <strong>URL</strong>:</td>
+ <td><input name="MediaURL" size="60" value="<?php
+ if ($url) {
+ echo $url, 'media/';
+ } ?>" /></td>
+ </tr>
+ <tr>
+ <td>Media directory <strong>path</strong>:</td>
+ <td><input name="MediaPath" size="60" value="<?php
+ if ($basePath) {
+ echo $basePath, 'media/';
+ } ?>" /></td>
+ </tr>
+ <tr>
+ <td>Extra skin files <strong>URL</strong>:</td>
+ <td><input name="SkinsURL" size="60" value="<?php
+ if ($url) {
+ echo $url, 'skins/';
+ } ?>" />
+ <br />(インポートされたスキンが使用)
+ </td>
+ </tr>
+ <tr>
+ <td>Extra skin files directory <strong>path</strong>:</td>
+ <td><input name="SkinsPath" size="60" value="<?php
+ if ($basePath) {
+ echo $basePath, 'skins/';
+ } ?>" />
+ <br />(インポートされたスキンのファイル類を置く場所)
+ </td>
+ </tr>
+ <tr>
+ <td>Plugin files <strong>URL</strong>:</td>
+ <td><input name="PluginURL" size="60" value="<?php
+ if ($url) {
+ echo $url, 'nucleus/plugins/';
+ } ?>" /></td>
+ </tr>
+ <tr>
+ <td>Action <strong>URL</strong>:</td>
+ <td><input name="ActionURL" size="60" value="<?php
+ if ($url) {
+ echo $url, 'action.php';
+ } ?>" />
+ <br />(<tt>action.php</tt>へのhttp://から始まるURL)
+ </td>
+ </tr>
+ </table>
+ </fieldset>
+
+ <p class="note"><strong>付記:</strong> 相対パスではなく<strong>絶対パスを使ってください</strong>。通常、絶対パスは<tt>/home/username/public_html/</tt>のような形をとります。Unixシステム(ほとんどのサーバーがそうです)において、パスはスラッシュから始まります。もしこれらの情報入力に問題が生じたら、あなたのサーバ管理者にたずねるべきです。</p>
+
+ <h1>管理権限をもつユーザー</h1>
+
+ <p>以下に、サイトの最初のユーザーを作成するためのいくつかの情報を入力してください。</p>
+
+ <fieldset>
+ <legend>管理権限を持つユーザー</legend>
+ <table>
+ <tr>
+ <td>表示される名前:</td>
+ <td><input name="User_name" value="" /> <small>(許可される文字:a-z と 0-9、最初と最後以外のスペース)</small></td>
+ </tr>
+ <tr>
+ <td>本名(ハンドル名):</td>
+ <td><input name="User_realname" value="" /></td>
+ </tr>
+ <tr>
+ <td>パスワード:</td>
+ <td><input name="User_password" type="password" value="" /></td>
+ </tr>
+ <tr>
+ <td>パスワードの確認:</td>
+ <td><input name="User_password2" type="password" value="" /></td>
+ </tr>
+ <tr>
+ <td>メールアドレス:</td>
+ <td><input name="User_email" value="" /> <small>(利用可能なメールアドレスを入れてください)</small></td>
+ </tr>
+ </table>
+ </fieldset>
+
+ <h1>ウェブログのデータ</h1>
+
+ <p>以下に、デフォルトのweblogを作成するためにいくつかの情報を入力してください。このweblogの名前は、サイト名としても利用されます。</p>
+
+ <fieldset>
+ <legend>ウェブログのデータ</legend>
+ <table>
+ <tr>
+ <td>Blog名:</td>
+ <td><input name="Blog_name" size="60" value="My Nucleus CMS" /></td>
+ </tr>
+ <tr>
+ <td>Blogの短縮名:</td>
+ <td><input name="Blog_shortname" value="mynucleuscms" /> <small>(許可される文字:a-z と 0-9、スペースは不可)</small></td>
+ </tr>
+ </table>
+ </fieldset>
+
+ <h1>データの送信</h1>
+
+ <p>上に書いてきたデータが正しいか確かめてください。よければデータベース・テーブルと最初のデータを設定するために下のボタンを押してください。少し時間がかかるかもしれませんがご辛抱を。<b>ボタンをクリックするのは一回だけにしてください。</b></p>
+
+ <p><input name="action" value="go" type="hidden" /> <input type="submit" value="Nucleus CMSのインストール" onclick="return checkSubmit();" /></p>
+
+ </form>
+ </body>
+</html>
+
+<?php }
+
+function tableName($unPrefixed) {
+ global $mysql_usePrefix, $mysql_prefix;
+
+ if ($mysql_usePrefix == 1) {
+ return $mysql_prefix . $unPrefixed;
+ } else {
+ return $unPrefixed;
+ }
+}
+
+function doInstall() {
+ global $mysql_usePrefix, $mysql_prefix;
+
+ // 0. put all POST-vars into vars
+ $mysql_host = postVar('mySQL_host');
+ $mysql_user = postVar('mySQL_user');
+ $mysql_password = postVar('mySQL_password');
+ $mysql_database = postVar('mySQL_database');
+ $mysql_create = postVar('mySQL_create');
+ $mysql_usePrefix = postVar('mySQL_usePrefix');
+ $mysql_prefix = postVar('mySQL_tablePrefix');
+ $config_indexurl = postVar('IndexURL');
+ $config_adminurl = postVar('AdminURL');
+ $config_adminpath = postVar('AdminPath');
+ $config_mediaurl = postVar('MediaURL');
+ $config_skinsurl = postVar('SkinsURL');
+ $config_pluginurl = postVar('PluginURL');
+ $config_actionurl = postVar('ActionURL');
+ $config_mediapath = postVar('MediaPath');
+ $config_skinspath = postVar('SkinsPath');
+ $user_name = postVar('User_name');
+ $user_realname = postVar('User_realname');
+ $user_password = postVar('User_password');
+ $user_password2 = postVar('User_password2');
+ $user_email = postVar('User_email');
+ $blog_name = postVar('Blog_name');
+ $blog_shortname = postVar('Blog_shortname');
+ $config_adminemail = $user_email;
+ $config_sitename = $blog_name;
+
+ $config_indexurl = replaceDoubleBackslash($config_indexurl);
+ $config_adminurl = replaceDoubleBackslash($config_adminurl);
+ $config_mediaurl = replaceDoubleBackslash($config_mediaurl);
+ $config_skinsurl = replaceDoubleBackslash($config_skinsurl);
+ $config_pluginurl = replaceDoubleBackslash($config_pluginurl);
+ $config_actionurl = replaceDoubleBackslash($config_actionurl);
+ $config_adminpath = replaceDoubleBackslash($config_adminpath);
+ $config_skinspath = replaceDoubleBackslash($config_skinspath);
+
+ // 1. check all the data
+ $errors = array();
+
+ if (!$mysql_database) {
+ array_push($errors, 'mySQL database name missing');
+ }
+
+ if (($mysql_usePrefix == 1) && (strlen($mysql_prefix) == 0) ) {
+ array_push($errors, 'mySQL prefix was selected, but prefix is empty');
+ }
+
+ if (($mysql_usePrefix == 1) && (!eregi('^[a-zA-Z0-9_]+$', $mysql_prefix) ) ) {
+ array_push($errors, 'mySQL prefix should only contain characters from the ranges A-Z, a-z, 0-9 or underscores');
+ }
+
+ // TODO: add action.php check
+ if (!endsWithSlash($config_indexurl) || !endsWithSlash($config_adminurl) || !endsWithSlash($config_mediaurl) || !endsWithSlash($config_pluginurl) || !endsWithSlash($config_skinsurl) ) {
+ array_push($errors, 'One of the URLs does not end with a slash, or action url does not end with \'action.php\'');
+ }
+
+ if (!endsWithSlash($config_adminpath) ) {
+ array_push($errors, 'The path of the administration area does not end with a slash');
+ }
+
+ if (!endsWithSlash($config_mediapath) ) {
+ array_push($errors, 'The media path does not end with a slash');
+ }
+
+ if (!endsWithSlash($config_skinspath) ) {
+ array_push($errors, 'The skins path does not end with a slash');
+ }
+
+ if (!is_dir($config_adminpath) ) {
+ array_push($errors, 'The path of the administration area does not exist on your server');
+ }
+
+ if (!_isValidMailAddress($user_email) ) {
+ array_push($errors, 'Invalid e-mail address given for user');
+ }
+
+ if (!_isValidDisplayName($user_name) ) {
+ array_push($errors, 'User name is not a valid display name (allowed chars: a-zA-Z0-9 and spaces)');
+ }
+
+ if (!$user_password || !$user_password2) {
+ array_push($errors, 'User password is empty');
+ }
+
+ if ($user_password != $user_password2) {
+ array_push($errors, 'User password do not match');
+ }
+
+ if (!_isValidShortName($blog_shortname) ) {
+ array_push($errors, 'Invalid short name given for blog (allowed chars: a-z0-9, no spaces)');
+ }
+
+ if (sizeof($errors) > 0) {
+ showErrorMessages($errors);
+ }
+
+ // 2. try to log in to mySQL
+ global $MYSQL_CONN;
+ $MYSQL_CONN = @mysql_connect($mysql_host, $mysql_user, $mysql_password);
+
+ if ($MYSQL_CONN == false) {
+ _doError('Could not connect to mySQL server: ' . mysql_error() );
+ }
+
+ // 3. try to create database (if needed)
+ if ($mysql_create == 1) {
+ mysql_query('CREATE DATABASE ' . $mysql_database) or _doError('Could not create database. Make sure you have the rights to do so. SQL error was: ' . mysql_error() );
+ }
+
+ // 4. try to select database
+ mysql_select_db($mysql_database) or _doError('Could not select database. Make sure it exists');
+
+ // 5. execute queries
+ $filename = 'install.sql';
+ $fd = fopen($filename, 'r');
+ $queries = fread($fd, filesize($filename) );
+ fclose($fd);
+
+ $queries = split("(;\n|;\r)", $queries);
+
+ $aTableNames = array(
+ 'nucleus_actionlog',
+ 'nucleus_ban',
+ 'nucleus_blog',
+ 'nucleus_category',
+ 'nucleus_comment',
+ 'nucleus_config',
+ 'nucleus_item',
+ 'nucleus_karma',
+ 'nucleus_member',
+ 'nucleus_plugin',
+ 'nucleus_skin',
+ 'nucleus_template',
+ 'nucleus_team',
+ 'nucleus_activation',
+ 'nucleus_tickets'
+ );
+// these are unneeded (one of the replacements above takes care of them)
+// 'nucleus_plugin_event',
+// 'nucleus_plugin_option',
+// 'nucleus_plugin_option_desc',
+// 'nucleus_skin_desc',
+// 'nucleus_template_desc',
+
+ $aTableNamesPrefixed = array(
+ $mysql_prefix . 'nucleus_actionlog',
+ $mysql_prefix . 'nucleus_ban',
+ $mysql_prefix . 'nucleus_blog',
+ $mysql_prefix . 'nucleus_category',
+ $mysql_prefix . 'nucleus_comment',
+ $mysql_prefix . 'nucleus_config',
+ $mysql_prefix . 'nucleus_item',
+ $mysql_prefix . 'nucleus_karma',
+ $mysql_prefix . 'nucleus_member',
+ $mysql_prefix . 'nucleus_plugin',
+ $mysql_prefix . 'nucleus_skin',
+ $mysql_prefix . 'nucleus_template',
+ $mysql_prefix . 'nucleus_team',
+ $mysql_prefix . 'nucleus_activation',
+ $mysql_prefix . 'nucleus_tickets'
+ );
+// these are unneeded (one of the replacements above takes care of them)
+// $mysql_prefix . 'nucleus_plugin_event',
+// $mysql_prefix . 'nucleus_plugin_option',
+// $mysql_prefix . 'nucleus_plugin_option_desc',
+// $mysql_prefix . 'nucleus_skin_desc',
+// $mysql_prefix . 'nucleus_template_desc',
+
+ $count = count($queries);
+
+ for ($idx = 0; $idx < $count; $idx++) {
+ $query = trim($queries[$idx]);
+ // echo "QUERY = <small>" . htmlspecialchars($query) . "</small><p>";
+
+ if ($query) {
+
+ if ($mysql_usePrefix == 1) {
+ $query = str_replace($aTableNames, $aTableNamesPrefixed, $query);
+ }
+
+ mysql_query($query) or _doError('Error while executing query (<small>' . htmlspecialchars($query) . '</small>): ' . mysql_error() );
+ }
+ }
+
+ // 6. update global settings
+ updateConfig('IndexURL', $config_indexurl);
+ updateConfig('AdminURL', $config_adminurl);
+ updateConfig('MediaURL', $config_mediaurl);
+ updateConfig('SkinsURL', $config_skinsurl);
+ updateConfig('PluginURL', $config_pluginurl);
+ updateConfig('ActionURL', $config_actionurl);
+ updateConfig('AdminEmail', $config_adminemail);
+ updateConfig('SiteName', $config_sitename);
+
+ // 7. update GOD member
+ $query = 'UPDATE ' . tableName('nucleus_member')
+ . " SET mname='" . addslashes($user_name) . "',"
+ . " mrealname='" . addslashes($user_realname) . "',"
+ . " mpassword='" . md5(addslashes($user_password) ) . "',"
+ . " murl='" . addslashes($config_indexurl) . "',"
+ . " memail='" . addslashes($user_email) . "',"
+ . " madmin=1, mcanlogin=1"
+ . " WHERE mnumber=1";
+
+ mysql_query($query) or _doError('Error while setting member settings: ' . mysql_error() );
+
+ // 8. update weblog settings
+ $query = 'UPDATE ' . tableName('nucleus_blog')
+ . " SET bname='" . addslashes($blog_name) . "',"
+ . " bshortname='" . addslashes($blog_shortname) . "',"
+ . " burl='" . addslashes($config_indexurl) . "'"
+ . " WHERE bnumber=1";
+
+ mysql_query($query) or _doError('Error while setting weblog settings: ' . mysql_error() );
+
+ // 9. update item date
+ $query = 'UPDATE ' . tableName('nucleus_item')
+ . " SET itime='" . date('Y-m-d H:i:s', time() ) ."'"
+ . " WHERE inumber=1";
+
+ mysql_query($query) or _doError('Error with query: ' . mysql_error() );
+
+ global $aConfPlugsToInstall, $aConfSkinsToImport;
+ $aSkinErrors = array();
+ $aPlugErrors = array();
+
+ if ((count($aConfPlugsToInstall) > 0) || (count($aConfSkinsToImport) > 0) ) {
+ // 10. set global variables
+ global $MYSQL_HOST, $MYSQL_USER, $MYSQL_PASSWORD, $MYSQL_DATABASE, $MYSQL_PREFIX;
+
+ $MYSQL_HOST = $mysql_host;
+ $MYSQL_USER = $mysql_user;
+ $MYSQL_PASSWORD = $mysql_password;
+ $MYSQL_DATABASE = $mysql_database;
+ $MYSQL_PREFIX = ($mysql_usePrefix == 1)?$mysql_prefix:'';
+
+ global $DIR_NUCLEUS, $DIR_MEDIA, $DIR_SKINS, $DIR_PLUGINS, $DIR_LANG, $DIR_LIBS;
+
+ $DIR_NUCLEUS = $config_adminpath;
+ $DIR_MEDIA = $config_mediapath;
+ $DIR_SKINS = $config_skinspath;
+ $DIR_PLUGINS = $DIR_NUCLEUS . 'plugins/';
+ $DIR_LANG = $DIR_NUCLEUS . 'language/';
+ $DIR_LIBS = $DIR_NUCLEUS . 'libs/';
+
+ // close database connection (needs to be closed if we want to include globalfunctions.php)
+ mysql_close();
+
+ $manager = '';
+ include_once($DIR_LIBS . 'globalfunctions.php');
+
+ // 11. install custom skins
+ $aSkinErrors = installCustomSkins($manager);
+
+ // 12. install custom plugins
+ $aPlugErrors = installCustomPlugs($manager);
+ }
+
+ // 12. Write config file ourselves (if possible)
+ $bConfigWritten = 0;
+
+ if (@file_exists('config.php') && is_writable('config.php') && $fp = @fopen('config.php', 'w') ) {
+ $config_data = '<' . '?php' . "\n\n";
+ //$config_data .= "\n"; (extraneous, just added extra \n to previous line
+ $config_data .= " // mySQL connection information\n";
+ $config_data .= " \$MYSQL_HOST = '" . $mysql_host . "';\n";
+ $config_data .= " \$MYSQL_USER = '" . $mysql_user . "';\n";
+ $config_data .= " \$MYSQL_PASSWORD = '" . $mysql_password . "';\n";
+ $config_data .= " \$MYSQL_DATABASE = '" . $mysql_database . "';\n";
+ $config_data .= " \$MYSQL_PREFIX = '" . (($mysql_usePrefix == 1)?$mysql_prefix:'') . "';\n";
+ $config_data .= "\n";
+ $config_data .= " // main nucleus directory\n";
+ $config_data .= " \$DIR_NUCLEUS = '" . $config_adminpath . "';\n";
+ $config_data .= "\n";
+ $config_data .= " // path to media dir\n";
+ $config_data .= " \$DIR_MEDIA = '" . $config_mediapath . "';\n";
+ $config_data .= "\n";
+ $config_data .= " // extra skin files for imported skins\n";
+ $config_data .= " \$DIR_SKINS = '" . $config_skinspath . "';\n";
+ $config_data .= "\n";
+ $config_data .= " // these dirs are normally sub dirs of the nucleus dir, but \n";
+ $config_data .= " // you can redefine them if you wish\n";
+ $config_data .= " \$DIR_PLUGINS = \$DIR_NUCLEUS . 'plugins/';\n";
+ $config_data .= " \$DIR_LANG = \$DIR_NUCLEUS . 'language/';\n";
+ $config_data .= " \$DIR_LIBS = \$DIR_NUCLEUS . 'libs/';\n";
+ $config_data .= "\n";
+ $config_data .= " // include libs\n";
+ $config_data .= " include(\$DIR_LIBS.'globalfunctions.php');\n";
+ $config_data .= " if (!extension_loaded('mbstring')) {\n";
+ $config_data .= " include(\$DIR_LIBS.'mb_emulator/mb-emulator.php');\n";
+ $config_data .= " }\n";
+ $config_data .= "?" . ">";
+
+ $result = @fputs($fp, $config_data, strlen($config_data) );
+ fclose($fp);
+
+ if ($result) {
+ $bConfigWritten = 1;
+ }
+ }
+
+?>
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
+<html xmlns="http://www.w3.org/1999/xhtml">
+<head>
+ <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
+ <title>Nucleusのインストール</title>
+ <style>@import url('nucleus/styles/manual.css');</style>
+</head>
+<body>
+ <div style='text-align:center'><img src='./nucleus/styles/logo.gif' /></div> <!-- Nucleus logo -->
+
+<?php
+ $aAllErrors = array_merge($aSkinErrors, $aPlugErrors);
+
+ if (count($aAllErrors) > 0) {
+ echo '<h1>Skin/Plugin Install errors</h1>';
+ echo '<ul><li>' . implode('</li><li>', $aAllErrors) . '</li></ul>';
+ }
+
+ if (!$bConfigWritten) { ?>
+ <h1>インストールはほぼ完了しました!</h1>
+
+ <p>データベーステーブルの初期値入力が成功しました。後は<i>config.php</i>を書き換えるだけです。以下に書き換えるべき内容を表示します(mysqlのパスワードはマスクされています。ここは実際のものに書き換えてください)</p>
+
+ <pre><code><?php
+ // mySQL connection information
+ $MYSQL_HOST = '<b><?php echo $mysql_host?></b>';
+ $MYSQL_USER = '<b><?php echo $mysql_user?></b>';
+ $MYSQL_PASSWORD = '<i><b>xxxxxxxxxxx</b></i>';
+ $MYSQL_DATABASE = '<b><?php echo $mysql_database?></b>';
+ $MYSQL_PREFIX = '<b><?php echo ($mysql_usePrefix == 1)?$mysql_prefix:''?></b>';
+
+ // main nucleus directory
+ $DIR_NUCLEUS = '<b><?php echo $config_adminpath?></b>';
+
+ // path to media dir
+ $DIR_MEDIA = '<b><?php echo $config_mediapath?></b>';
+
+ // extra skin files for imported skins
+ $DIR_SKINS = '<b><?php echo $config_skinspath?></b>';
+
+ // these dirs are normally sub dirs of the nucleus dir, but
+ // you can redefine them if you wish
+ $DIR_PLUGINS = $DIR_NUCLEUS . 'plugins/';
+ $DIR_LANG = $DIR_NUCLEUS . 'language/';
+ $DIR_LIBS = $DIR_NUCLEUS . 'libs/';
+
+ // include libs
+ include($DIR_LIBS.'globalfunctions.php');
+ if (!extension_loaded('mbstring')) {
+ include($DIR_LIBS.'mb_emulator/mb-emulator.php');
+ }
+?></code></pre>
+
+ <p>あなたのコンピュータ上のファイルを書き換えたら、FTPを使ってウェブサーバにアップロードしてください。ASCIIモードで送信してファイルを上書きします。</p>
+
+ <div class="note">
+ <b>付記:</b> <i>config.php</i>の最初や終わりにスペースを空けないようにしましょう。実行時にエラーを引き起こす原因となります。<br />
+ したがって、config.phpの最初の文字は "<"で最後の文字は">"としなければなりません。
+ </div>
+
+<?php } else { ?>
+
+ <h1>インストールは完了しました!</h1>
+
+ <p>Nucleusはインストールされ、<code>config.php</code>はアップデートされました。</p>
+
+ <p>セキュリティのため<code>config.php</code>のパーミッションを444に戻すことを忘れないでください(<a href="nucleus/documentation/tips.html#filepermissions">パーミッション変更の簡易ガイド</a>)。</p>
+
+<?php } ?>
+
+ <h1>インストールファイルの削除</h1>
+
+ <p>ウェブサーバから次のファイルを削除してください:</p>
+
+ <ul>
+ <li><b>install.sql</b>:テーブルの構造を内包するファイル</li>
+ <li><b>install.php</b>:このファイル</li>
+ </ul>
+
+ <p>もしこれらのファイルを削除していなければ、管理領域を開くことが出来ません。</p>
+
+ <h1>ウェブサイトの確認</h1>
+
+ <p>ウェブサイトを使う準備が整いました。
+ <ul>
+ <li><a href="<?php echo $config_adminurl?>">管理領域にログインしてサイトの設定を行う</a></li>
+ <li><a href="<?php echo $config_indexurl?>">すぐにサイトへ行ってみる</a></li>
+ </ul>
+ </p>
+
+</body>
+</html>
+
+<?php
+}
+
+function installCustomPlugs(&$manager) {
+ global $aConfPlugsToInstall, $DIR_LIBS;
+
+ $aErrors = array();
+
+ if (count($aConfPlugsToInstall) == 0) {
+ return $aErrors;
+ }
+
+ $res = sql_query('SELECT * FROM ' . sql_table('plugin') );
+ $numCurrent = mysql_num_rows($res);
+
+ foreach ($aConfPlugsToInstall as $plugName) {
+ // do this before calling getPlugin (in case the plugin id is used there)
+ $query = 'INSERT INTO ' . sql_table('plugin') . ' (porder, pfile) VALUES (' . (++$numCurrent) . ', "' . addslashes($plugName) . '")';
+ sql_query($query);
+
+ // get and install the plugin
+ $plugin =& $manager->getPlugin($plugName);
+
+ if (!$plugin) {
+ sql_query('DELETE FROM ' . sql_table('plugin') . ' WHERE pfile=\'' . addslashes($plugName) . '\'');
+ $numCurrent--;
+ array_push($aErrors, 'Unable to install plugin ' . $plugName);
+ continue;
+ }
+
+ $plugin->install();
+ }
+
+ // SYNC PLUGIN EVENT LIST
+ sql_query('DELETE FROM ' . sql_table('plugin_event') );
+
+ // loop over all installed plugins
+ $res = sql_query('SELECT pid, pfile FROM ' . sql_table('plugin') );
+
+ while($o = mysql_fetch_object($res) ) {
+ $pid = $o->pid;
+ $plug =& $manager->getPlugin($o->pfile);
+
+ if ($plug) {
+ $eventList = $plug->getEventList();
+
+ foreach ($eventList as $eventName) {
+ sql_query('INSERT INTO ' . sql_table('plugin_event') . ' (pid, event) VALUES (' . $pid . ', \'' . $eventName . '\')');
+ }
+ }
+ }
+
+ return $aErrors;
+}
+
+function installCustomSkins(&$manager) {
+ global $aConfSkinsToImport, $DIR_LIBS, $DIR_SKINS;
+
+ $aErrors = array();
+
+ if (count($aConfSkinsToImport) == 0) {
+ return $aErrors;
+ }
+
+ // load skinie class
+ include_once($DIR_LIBS . 'skinie.php');
+
+ $importer = new SKINIMPORT();
+
+ foreach ($aConfSkinsToImport as $skinName) {
+ $importer->reset();
+ $skinFile = $DIR_SKINS . $skinName . '/skinbackup.xml';
+
+ if (!@file_exists($skinFile) ) {
+ array_push($aErrors, 'Unable to import ' . $skinFile . ' : file does not exist');
+ continue;
+ }
+
+ $error = $importer->readFile($skinFile);
+
+ if ($error) {
+ array_push($aErrors, 'Unable to import ' . $skinName . ' : ' . $error);
+ continue;
+ }
+
+ $error = $importer->writeToDatabase(1);
+
+ if ($error) {
+ array_push($aErrors, 'Unable to import ' . $skinName . ' : ' . $error);
+ continue;
+ }
+ }
+
+ return $aErrors;
+}
+
+// give an error if one or more nucleus are not accessible
+function doCheckFiles() {
+ $missingfiles = array();
+ $files = array(
+ 'install.sql',
+ 'index.php',
+ 'action.php',
+ 'nucleus/index.php',
+ 'nucleus/libs/globalfunctions.php',
+ 'nucleus/libs/ADMIN.php',
+ 'nucleus/libs/BLOG.php',
+ 'nucleus/libs/COMMENT.php',
+ 'nucleus/libs/COMMENTS.php',
+ 'nucleus/libs/ITEM.php',
+ 'nucleus/libs/MEMBER.php',
+ 'nucleus/libs/SKIN.php',
+ 'nucleus/libs/TEMPLATE.php',
+ 'nucleus/libs/MEDIA.php',
+ 'nucleus/libs/ACTIONLOG.php',
+ 'nucleus/media.php'
+ );
+
+ $count = count($files);
+
+ for ($i = 0; $i < $count; $i++) {
+ if (!is_readable($files[$i]) ) {
+ array_push($missingfiles, 'File <b>' . $files[$i] . '</b> is missing or not readable.');
+ }
+ }
+
+// The above code replaces several if statements of the form:
+
+// if (!is_readable('install.sql') ) {
+// array_push($missingfiles, 'File <b>install.sql</b> is missing or not readable');
+// }
+
+ if (count($missingfiles) > 0) {
+ showErrorMessages($missingfiles);
+ }
+}
+
+function updateConfig($name, $val) {
+ $name = addslashes($name);
+ $val = trim(addslashes($val) );
+
+ $query = 'UPDATE ' . tableName('nucleus_config')
+ . " SET value='$val'"
+ . " WHERE name='$name'";
+
+ mysql_query($query) or _doError('Query error while trying to update config: ' . mysql_error() );
+ return mysql_insert_id();
+}
+
+function replaceDoubleBackslash($input) {
+ return str_replace('\\', '/', $input);
+}
+
+function endsWithSlash($s) {
+ return (strrpos($s, '/') == strlen($s) - 1);
+}
+
+/**
+ * Checks if email address is valid
+ */
+function _isValidMailAddress($address) {
+ if (preg_match("/^[a-zA-Z0-9\._-]+@+[A-Za-z0-9\._-]+\.+[A-Za-z]{2,4}$/", $address) ) {
+ return 1;
+ } else {
+ return 0;
+ }
+}
+
+// returns true if the given string is a valid shortname
+// (to check short blog names and nicknames)
+// logic: starts and ends with a non space, can contain spaces in between
+// min 2 chars
+function _isValidShortName($name) {
+ if (eregi("^[a-z0-9]+$", $name) ) {
+ return 1;
+ } else {
+ return 0;
+ }
+}
+
+
+
+// returns true if the given string is a valid display name
+// (to check nicknames)
+function _isValidDisplayName($name) {
+ if (eregi("^[a-z0-9]+[a-z0-9 ]*[a-z0-9]+$", $name) ) {
+ return 1;
+ } else {
+ return 0;
+ }
+}
+
+function _doError($msg) {
+ ?>
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
+<html xmlns="http://www.w3.org/1999/xhtml">
+<head>
+ <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
+ <title>Nucleus Install</title>
+ <style>@import url('nucleus/styles/manual.css');</style>
+</head>
+<body>
+ <div style='text-align:center'><img src='./nucleus/styles/logo.gif' /></div> <!-- Nucleus logo -->
+ <h1>Error!</h1>
+
+ <p>Error message was: "<?php echo $msg?>";</p>
+
+ <p><a href="install.php" onclick="history.back();return false;">Go Back</a></p>
+</body>
+</html>
+
+<?php
+ exit;
+}
+
+function showErrorMessages($errors) {
+ ?>
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
+<html xmlns="http://www.w3.org/1999/xhtml">
+<head>
+ <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
+ <title>Nucleus Install</title>
+ <style>@import url('nucleus/styles/manual.css');</style>
+</head>
+<body>
+ <div style='text-align:center'><img src='./nucleus/styles/logo.gif' /></div> <!-- Nucleus logo -->
+ <h1>Errors!</h1>
+
+ <p>Errors were found:</p>
+
+ <ul>
+
+<?php
+ while($msg = array_shift($errors) ) {
+ echo '<li>', $msg, '</li>';
+ }
+?>
+
+ </ul>
+
+ <p><a href="install.php" onclick="history.back();return false;">Go Back</a></p>
+</body>
+</html>
+
+<?php
+ exit;
+}
+
+/* for the non-php systems that decide to show the contents:
+?></div><?php */
+
+?>
\ No newline at end of file
-<?php\r
-/**\r
- * Nucleus: PHP/MySQL Weblog CMS (http://nucleuscms.org/) \r
- * Copyright (C) 2002-2005 The Nucleus Group\r
- *\r
- * This program is free software; you can redistribute it and/or\r
- * modify it under the terms of the GNU General Public License\r
- * as published by the Free Software Foundation; either version 2\r
- * of the License, or (at your option) any later version.\r
- * (see nucleus/documentation/index.html#license for more info)\r
- *\r
- * This script allows adding items to Nucleus through bookmarklets. The member must be logged in\r
- * in order to use this.\r
- *\r
- * $Id: bookmarklet.php,v 1.6 2005-08-13 07:33:58 kimitake Exp $\r
- * $NucleusJP: bookmarklet.php,v 1.5 2005/03/16 07:55:53 kimitake Exp $\r
- */\r
-\r
-// bookmarklet is part of admin area (might need XML-RPC)\r
-$CONF = array();\r
-$CONF['UsingAdminArea'] = 1;\r
-\r
-// include all classes and config data \r
-include('../config.php');\r
-\r
-$action = requestVar('action');\r
-\r
-if ($action == 'contextmenucode') {\r
- bm_doContextMenuCode();\r
- exit;\r
-}\r
-\r
-if (!$member->isLoggedIn()) {\r
- bm_loginAndPassThrough();\r
- exit;\r
-}\r
-\r
-// on successfull login\r
-if (($action == 'login') && ($member->isLoggedIn()))\r
- $action = requestVar('nextaction');\r
-if ($action == '')\r
- $action = 'add';\r
- \r
-sendContentType('application/xhtml+xml', 'bookmarklet-'.$action); \r
-\r
-// check ticket\r
-$action = strtolower($action);\r
-$aActionsNotToCheck = array('login', 'add', 'edit');\r
-if (!in_array($action, $aActionsNotToCheck))\r
-{\r
- if (!$manager->checkTicket())\r
- bm_doError(_ERROR_BADTICKET);\r
-} \r
-\r
-\r
-// find out what to do\r
-switch ($action) {\r
- case 'additem':\r
- bm_doAddItem(); // adds the item for real\r
- break;\r
- case 'edit':\r
- bm_doEditForm(); // shows the edit item form\r
- break;\r
- case 'edititem': // edits the item for real\r
- bm_doEditItem();\r
- break;\r
- case 'login': // on login, 'action' gets changed to 'nextaction'\r
- bm_doError('Something went wrong');\r
- break;\r
- case 'add':\r
- default:\r
- bm_doShowForm(); // shows the fill in form\r
- break;\r
-}\r
- \r
-function bm_doAddItem() {\r
- global $member, $manager, $CONF;\r
- \r
- $manager->loadClass('ITEM');\r
- $result = ITEM::createFromRequest();\r
- \r
- if ($result['status'] == 'error')\r
- bm_doError($result['message']);\r
-\r
- $blogid = getBlogIDFromItemID($result['itemid']);\r
- $blog =& $manager->getBlog($blogid);\r
- \r
- if ($result['status'] == 'newcategory') {\r
- $message = _BOOKMARKLET_NEW_CATEGORY <a href="index.php?action=categoryedit&blogid='.$blogid.'&catid='.$result['catid'].'" onclick="if (event && event.preventDefault) event.preventDefault(); window.open(this.href); return false;" title="Opens in new window">ここをクリックしてカテゴリーの名前と説明を編集してください。</a>';\r
- $extrahead = '';\r
- } elseif ((postVar('actiontype') == 'addnow') && $blog->pingUserland()) {\r
- $message = _BOOKMARKLET_SEND_PING;\r
- $extrahead = '<meta http-equiv="refresh" content="1; url=index.php?action=sendping&blogid=' . $blogid . '" />';\r
- } else {\r
- $message = _ITEM_ADDED;\r
- $extrahead = '';\r
- }\r
- \r
- bm_message(_ITEM_ADDED, _ITEM_ADDED, $message,$extrahead);\r
-}\r
-\r
-function bm_doEditItem() {\r
- global $member, $manager, $CONF;\r
- \r
- $itemid = intRequestVar('itemid');\r
- $catid = postVar('catid');\r
- \r
- // only allow if user is allowed to alter item\r
- if (!$member->canUpdateItem($itemid, $catid))\r
- bm_doError(_ERROR_DISALLOWED);\r
-\r
- $body = postVar('body');\r
- $title = postVar('title');\r
- $more = postVar('more');\r
- $closed = intPostVar('closed');\r
- $actiontype = postVar('actiontype');\r
- \r
- // redirect to admin area on delete (has delete confirmation)\r
- if ($actiontype == 'delete') {\r
- redirect('index.php?action=itemdelete&itemid='.$itemid);\r
- exit; \r
- }\r
- \r
- // create new category if needed (only on edit/changedate)\r
- if (strstr($catid,'newcat')) {\r
- // get blogid \r
- list($blogid) = sscanf($catid,"newcat-%d");\r
-\r
- // create\r
- $blog =& $manager->getBlog($blogid);\r
- $catid = $blog->createNewCategory();\r
-\r
- // show error when sth goes wrong\r
- if (!$catid) \r
- bm_doError('Could not create new category');\r
- } \r
-\r
- // only edit action is allowed for bookmarklet edit\r
- switch ($actiontype) {\r
- case 'changedate':\r
- $publish = 1;\r
- $wasdraft = 0;\r
- $timestamp = mktime(postVar('hour'), postVar('minutes'), 0, postVar('month'), postVar('day'), postVar('year'));\r
- break;\r
- case 'edit':\r
- $publish = 1;\r
- $wasdraft = 0;\r
- $timestamp = 0;\r
- break;\r
- default:\r
- bm_doError('Something went wrong');\r
- }\r
- \r
- // update item for real\r
- ITEM::update($itemid, $catid, $title, $body, $more, $closed, $wasdraft, $publish, $timestamp);\r
- \r
- // show success message\r
- if ($catid != intPostVar('catid'))\r
- bm_message(_ITEM_UPDATED, _ITEM_UPDATED, _BOOKMARKLET_NEW_CATEGORY<a href="index.php?action=categoryedit&blogid='.$blog->getID().'&catid='.$catid.'" onclick="if (event && event.preventDefault) event.preventDefault(); window.open(this.href); return false;" title="Opens in new window">ここをクリックしてカテゴリーの名前と説明を編集してください。</a>', '');\r
- else\r
- bm_message(_ITEM_UPDATED, _ITEM_UPDATED, _ITEM_UPDATED, '');\r
-}\r
-\r
-function bm_loginAndPassThrough() {\r
-\r
- $blogid = intRequestVar('blogid');\r
- $log_text = requestVar('logtext');\r
- $log_link = requestVar('loglink');\r
- $log_linktitle = requestVar('loglinktitle');\r
- \r
- ?>\r
-<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">\r
- <html xmlns="http://www.w3.org/1999/xhtml">\r
- <head>\r
- <meta http-equiv="Content-Type" content="text/html; charset=<?php echo _CHARSET ?>" />\r
- <title>Nucleus</title>\r
- <?php bm_style(); ?>\r
- </head>\r
- <body>\r
- <h1><?php echo _LOGIN_PLEASE?></h1>\r
- \r
- <form method="post" action="bookmarklet.php">\r
- <p>\r
- <input name="action" value="login" type="hidden" />\r
- <input name="blogid" value="<?php echo htmlspecialchars($blogid) ?>" type="hidden" />\r
- <input name="logtext" value="<?php echo htmlspecialchars($log_text) ?>" type="hidden" />\r
- <input name="loglink" value="<?php echo htmlspecialchars($log_link) ?>" type="hidden" />\r
- <input name="loglinktitle" value="<?php echo htmlspecialchars($log_linktitle) ?>" type="hidden" />\r
- <?php echo _LOGINFORM_NAME?>:\r
- <br /><input name="login" />\r
- <br /><?php echo _LOGINFORM_PWD?>:\r
- <br /><input name="password" type="password" />\r
- <br /><br />\r
- <br /><input type="submit" value="<?php echo _LOGIN?>" />\r
- </p>\r
- </form>\r
- <p><a href="bookmarklet.php" onclick="window.close();"><?php echo _POPUP_CLOSE?></a></p>\r
- </body>\r
- </html>\r
- <?php\r
-}\r
-\r
-function bm_doShowForm() {\r
- global $member;\r
- \r
- $blogid = intRequestVar('blogid');\r
- $log_text = trim(requestVar('logtext'));\r
- $log_link = requestVar('loglink');\r
- $log_linktitle = requestVar('loglinktitle');\r
-\r
- $log_text = uniDecode($log_text,_CHARSET);\r
- $log_linktitle = uniDecode($log_linktitle,_CHARSET);\r
- \r
- if (!BLOG::existsID($blogid))\r
- bm_doError(_ERROR_NOSUCHBLOG);\r
-\r
- if (!$member->isTeamMember($blogid))\r
- bm_doError(_ERROR_NOTONTEAM);\r
- \r
- $logje = '';\r
- if ($log_text)\r
- $logje .= '<blockquote><div>"' . htmlspecialchars($log_text) .'"</div></blockquote>' . "\n";\r
- if (!$log_linktitle)\r
- $log_linktitle = $log_link;\r
- if ($log_link) \r
- $logje .= '<a href="'. htmlspecialchars($log_link) . '">'. htmlspecialchars($log_linktitle).'</a>';\r
- \r
-\r
- $item['body'] = $logje;\r
- $item['title'] = htmlspecialchars($log_linktitle);\r
-\r
- $factory = new PAGEFACTORY($blogid);\r
- $factory->createAddForm('bookmarklet',$item);\r
-}\r
-\r
-function bm_doEditForm() {\r
- global $member, $manager;\r
- \r
- $itemid = intRequestVar('itemid');\r
- \r
- if (!$manager->existsItem($itemid, 0, 0)) \r
- bm_doError(_ERROR_NOSUCHITEM);\r
- \r
- if (!$member->canAlterItem($itemid))\r
- bm_doError(_ERROR_DISALLOWED);\r
- \r
- $item =& $manager->getItem($itemid,1,1);\r
- $blog =& $manager->getBlog(getBlogIDFromItemID($itemid));\r
- \r
- $manager->notify('PrepareItemForEdit', array('item' => &$item));\r
-\r
- if ($blog->convertBreaks()) {\r
- $item['body'] = removeBreaks($item['body']);\r
- $item['more'] = removeBreaks($item['more']);\r
- }\r
-\r
- $formfactory = new PAGEFACTORY($blog->getID());\r
- $formfactory->createEditForm('bookmarklet',$item); \r
-\r
-}\r
-\r
-function bm_doError($msg) {\r
- bm_message(_ERROR,_ERRORMSG,$msg);\r
- die;\r
-}\r
-\r
-function bm_message($title, $head, $msg, $extrahead = '') {\r
- ?>\r
-<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">\r
- <html xmlns="http://www.w3.org/1999/xhtml">\r
- <head>\r
- <meta http-equiv="Content-Type" content="text/html; charset=<?php echo _CHARSET ?>" />\r
- <title><?php echo $title ?></title>\r
- <?php bm_style(); ?>\r
- <?php echo $extrahead?>\r
- </head>\r
- <body>\r
- <h1><?php echo $head ?></h1>\r
- <p><?php echo $msg ?></p>\r
- <p><a href="bookmarklet.php" onclick="window.close();"><?php echo _POPUP_CLOSE?></a></p>\r
- </body>\r
- </html>\r
- \r
- <?php }\r
-\r
-function bm_style() {\r
- echo '<link rel="stylesheet" type="text/css" href="styles/bookmarklet.css" />';\r
- echo '<link rel="stylesheet" type="text/css" href="styles/addedit.css" />'; \r
-}\r
-\r
-function bm_doContextMenuCode() {\r
- global $CONF;\r
- ?>\r
-<script type="text/javascript" defer="defer">\r
-doc=external.menuArguments.document;\r
-lt=escape(doc.selection.createRange().text);\r
-loglink=escape(external.menuArguments.location.href);\r
-loglinktitle=escape(doc.title);\r
-wingm=window.open('<?php echo $CONF['AdminURL']?>bookmarklet.php?blogid=<?php echo intGetVar('blogid')?>&logtext='+lt+'&loglink='+loglink+'&loglinktitle='+loglinktitle,'nucleusbm','scrollbars=yes,width=600,height=500,left=10,top=10,status=yes,resizable=yes');\r
-wingm.focus();\r
-</script> \r
- <?php\r
-}\r
-\r
-function uniDecode($str,$charcode){\r
- $text = preg_replace_callback("/%u[0-9A-Za-z]{4}/",toUtf8,$str);\r
- return mb_convert_encoding($text, $charcode, 'UTF-8');\r
-}\r
-function toUtf8($ar){\r
- foreach($ar as $val){\r
- $val = intval(substr($val,2),16);\r
- if($val < 0x7F){ // 0000-007F\r
- $c .= chr($val);\r
- }elseif($val < 0x800) { // 0080-0800\r
- $c .= chr(0xC0 | ($val / 64));\r
- $c .= chr(0x80 | ($val % 64));\r
- }else{ // 0800-FFFF\r
- $c .= chr(0xE0 | (($val / 64) / 64));\r
- $c .= chr(0x80 | (($val / 64) % 64));\r
- $c .= chr(0x80 | ($val % 64));\r
- }\r
- }\r
- return $c;\r
-}\r
-\r
-?>\r
+<?php
+/*
+ * Nucleus: PHP/MySQL Weblog CMS (http://nucleuscms.org/)
+ * Copyright (C) 2002-2006 The Nucleus Group
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ * (see nucleus/documentation/index.html#license for more info)
+ */
+/**
+ * This script allows adding items to Nucleus through bookmarklets. The member must be logged in
+ * in order to use this.
+ *
+ * @license http://nucleuscms.org/license.txt GNU General Public License
+ * @copyright Copyright (C) 2002-2006 The Nucleus Group
+ * @version $Id: bookmarklet.php,v 1.7 2006-07-17 20:01:39 kimitake Exp $
+ * $NucleusJP: bookmarklet.php,v 1.6 2005/08/13 07:33:58 kimitake Exp $
+ */
+
+// bookmarklet is part of admin area (might need XML-RPC)
+$CONF = array();
+$CONF['UsingAdminArea'] = 1;
+
+// include all classes and config data
+include('../config.php');
+
+$action = requestVar('action');
+
+if ($action == 'contextmenucode') {
+ bm_doContextMenuCode();
+ exit;
+}
+
+if (!$member->isLoggedIn()) {
+ bm_loginAndPassThrough();
+ exit;
+}
+
+// on successfull login
+if (($action == 'login') && ($member->isLoggedIn()))
+ $action = requestVar('nextaction');
+if ($action == '')
+ $action = 'add';
+
+sendContentType('application/xhtml+xml', 'bookmarklet-'.$action);
+
+// check ticket
+$action = strtolower($action);
+$aActionsNotToCheck = array('login', 'add', 'edit');
+if (!in_array($action, $aActionsNotToCheck))
+{
+ if (!$manager->checkTicket())
+ bm_doError(_ERROR_BADTICKET);
+}
+
+
+// find out what to do
+switch ($action) {
+ case 'additem':
+ bm_doAddItem(); // adds the item for real
+ break;
+ case 'edit':
+ bm_doEditForm(); // shows the edit item form
+ break;
+ case 'edititem': // edits the item for real
+ bm_doEditItem();
+ break;
+ case 'login': // on login, 'action' gets changed to 'nextaction'
+ bm_doError('Something went wrong');
+ break;
+ case 'add':
+ default:
+ bm_doShowForm(); // shows the fill in form
+ break;
+}
+
+function bm_doAddItem() {
+ global $member, $manager, $CONF;
+
+ $manager->loadClass('ITEM');
+ $result = ITEM::createFromRequest();
+
+ if ($result['status'] == 'error')
+ bm_doError($result['message']);
+
+ $blogid = getBlogIDFromItemID($result['itemid']);
+ $blog =& $manager->getBlog($blogid);
+
+ if ($result['status'] == 'newcategory') {
+ $message = 'Item was added, and a new category was created. <a href="index.php?action=categoryedit&blogid='.$blogid.'&catid='.$result['catid'].'" onclick="if (event && event.preventDefault) event.preventDefault(); window.open(this.href); return false;" title="Opens in new window">Click here to edit the name and description of the category.</a>';
+ $extrahead = '';
+ } elseif ((postVar('actiontype') == 'addnow') && $blog->pingUserland()) {
+ $message = 'Item was added successfully. Now pinging weblogs.com. Please hold on... (can take a while)';
+ $pingUrl = $manager->addTicketToUrl($CONF['AdminURL'] . 'index.php?action=sendping&blogid=' . intval($blogid));
+ $extrahead = '<meta http-equiv="refresh" content="1; url=' . htmlspecialchars($pingUrl). '" />';
+ } else {
+ $message = _ITEM_ADDED;
+ $extrahead = '';
+ }
+
+ bm_message(_ITEM_ADDED, _ITEM_ADDED, $message,$extrahead);
+}
+
+function bm_doEditItem() {
+ global $member, $manager, $CONF;
+
+ $itemid = intRequestVar('itemid');
+ $catid = postVar('catid');
+
+ // only allow if user is allowed to alter item
+ if (!$member->canUpdateItem($itemid, $catid))
+ bm_doError(_ERROR_DISALLOWED);
+
+ $body = postVar('body');
+ $title = postVar('title');
+ $more = postVar('more');
+ $closed = intPostVar('closed');
+ $actiontype = postVar('actiontype');
+
+ $draftid = intPostVar('draftid');
+
+ // redirect to admin area on delete (has delete confirmation)
+ if ($actiontype == 'delete') {
+ redirect('index.php?action=itemdelete&itemid='.$itemid);
+ exit;
+ }
+
+ // create new category if needed (only on edit/changedate)
+ if (strstr($catid,'newcat')) {
+ // get blogid
+ list($blogid) = sscanf($catid,"newcat-%d");
+
+ // create
+ $blog =& $manager->getBlog($blogid);
+ $catid = $blog->createNewCategory();
+
+ // show error when sth goes wrong
+ if (!$catid)
+ bm_doError('Could not create new category');
+ }
+
+ // only edit action is allowed for bookmarklet edit
+ switch ($actiontype) {
+ case 'changedate':
+ $publish = 1;
+ $wasdraft = 0;
+ $timestamp = mktime(postVar('hour'), postVar('minutes'), 0, postVar('month'), postVar('day'), postVar('year'));
+ break;
+ case 'edit':
+ $publish = 1;
+ $wasdraft = 0;
+ $timestamp = 0;
+ break;
+ default:
+ bm_doError('Something went wrong');
+ }
+
+ // update item for real
+ ITEM::update($itemid, $catid, $title, $body, $more, $closed, $wasdraft, $publish, $timestamp);
+
+ if ($draftid > 0) {
+ ITEM::delete($draftid);
+ }
+
+ // show success message
+ if ($catid != intPostVar('catid'))
+ bm_message(_ITEM_UPDATED, _ITEM_UPDATED, 'Item was added, and a new category was created. <a href="index.php?action=categoryedit&blogid='.$blog->getID().'&catid='.$catid.'" onclick="if (event && event.preventDefault) event.preventDefault(); window.open(this.href); return false;" title="Opens in new window">Click here to edit the name and description of the category.</a>', '');
+ else
+ bm_message(_ITEM_UPDATED, _ITEM_UPDATED, _ITEM_UPDATED, '');
+}
+
+function bm_loginAndPassThrough() {
+
+ $blogid = intRequestVar('blogid');
+ $log_text = requestVar('logtext');
+ $log_link = requestVar('loglink');
+ $log_linktitle = requestVar('loglinktitle');
+
+ ?>
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
+ <html xmlns="http://www.w3.org/1999/xhtml">
+ <head>
+ <meta http-equiv="Content-Type" content="text/html; charset=<?php echo _CHARSET ?>" />
+ <title>Nucleus</title>
+ <?php bm_style(); ?>
+ </head>
+ <body>
+ <h1><?php echo _LOGIN_PLEASE?></h1>
+
+ <form method="post" action="bookmarklet.php">
+ <p>
+ <input name="action" value="login" type="hidden" />
+ <input name="blogid" value="<?php echo htmlspecialchars($blogid) ?>" type="hidden" />
+ <input name="logtext" value="<?php echo htmlspecialchars($log_text) ?>" type="hidden" />
+ <input name="loglink" value="<?php echo htmlspecialchars($log_link) ?>" type="hidden" />
+ <input name="loglinktitle" value="<?php echo htmlspecialchars($log_linktitle) ?>" type="hidden" />
+ <?php echo _LOGINFORM_NAME?>:
+ <br /><input name="login" />
+ <br /><?php echo _LOGINFORM_PWD?>:
+ <br /><input name="password" type="password" />
+ <br /><br />
+ <br /><input type="submit" value="<?php echo _LOGIN?>" />
+ </p>
+ </form>
+ <p><a href="bookmarklet.php" onclick="window.close();"><?php echo _POPUP_CLOSE?></a></p>
+ </body>
+ </html>
+ <?php
+}
+
+function bm_doShowForm() {
+ global $member;
+
+ $blogid = intRequestVar('blogid');
+ $log_text = trim(requestVar('logtext'));
+ $log_link = requestVar('loglink');
+ $log_linktitle = requestVar('loglinktitle');
+
+ $log_text = uniDecode($log_text,_CHARSET);
+ $log_linktitle = uniDecode($log_linktitle,_CHARSET);
+
+ if (!BLOG::existsID($blogid))
+ bm_doError(_ERROR_NOSUCHBLOG);
+
+ if (!$member->isTeamMember($blogid))
+ bm_doError(_ERROR_NOTONTEAM);
+
+ $logje = '';
+ if ($log_text)
+ $logje .= '<blockquote><div>"' . htmlspecialchars($log_text) .'"</div></blockquote>' . "\n";
+ if (!$log_linktitle)
+ $log_linktitle = $log_link;
+ if ($log_link)
+ $logje .= '<a href="'. htmlspecialchars($log_link) . '">'. htmlspecialchars($log_linktitle).'</a>';
+
+
+ $item['body'] = $logje;
+ $item['title'] = htmlspecialchars($log_linktitle);
+
+ $factory = new PAGEFACTORY($blogid);
+ $factory->createAddForm('bookmarklet',$item);
+}
+
+function bm_doEditForm() {
+ global $member, $manager;
+
+ $itemid = intRequestVar('itemid');
+
+ if (!$manager->existsItem($itemid, 0, 0))
+ bm_doError(_ERROR_NOSUCHITEM);
+
+ if (!$member->canAlterItem($itemid))
+ bm_doError(_ERROR_DISALLOWED);
+
+ $item =& $manager->getItem($itemid,1,1);
+ $blog =& $manager->getBlog(getBlogIDFromItemID($itemid));
+
+ $manager->notify('PrepareItemForEdit', array('item' => &$item));
+
+ if ($blog->convertBreaks()) {
+ $item['body'] = removeBreaks($item['body']);
+ $item['more'] = removeBreaks($item['more']);
+ }
+
+ $formfactory = new PAGEFACTORY($blog->getID());
+ $formfactory->createEditForm('bookmarklet',$item);
+
+}
+
+function bm_doError($msg) {
+ bm_message(_ERROR,_ERRORMSG,$msg);
+ die;
+}
+
+function bm_message($title, $head, $msg, $extrahead = '') {
+ ?>
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
+ <html xmlns="http://www.w3.org/1999/xhtml">
+ <head>
+ <meta http-equiv="Content-Type" content="text/html; charset=<?php echo _CHARSET ?>" />
+ <title><?php echo $title ?></title>
+ <?php bm_style(); ?>
+ <?php echo $extrahead?>
+ </head>
+ <body>
+ <h1><?php echo $head ?></h1>
+ <p><?php echo $msg ?></p>
+ <p><a href="bookmarklet.php" onclick="window.close();"><?php echo _POPUP_CLOSE?></a></p>
+ </body>
+ </html>
+
+ <?php }
+
+function bm_style() {
+ echo '<link rel="stylesheet" type="text/css" href="styles/bookmarklet.css" />';
+ echo '<link rel="stylesheet" type="text/css" href="styles/addedit.css" />';
+}
+
+function bm_doContextMenuCode() {
+ global $CONF;
+ ?>
+<script type="text/javascript" defer="defer">
+doc=external.menuArguments.document;
+lt=escape(doc.selection.createRange().text);
+loglink=escape(external.menuArguments.location.href);
+loglinktitle=escape(doc.title);
+wingm=window.open('<?php echo $CONF['AdminURL']?>bookmarklet.php?blogid=<?php echo intGetVar('blogid')?>&logtext='+lt+'&loglink='+loglink+'&loglinktitle='+loglinktitle,'nucleusbm','scrollbars=yes,width=600,height=500,left=10,top=10,status=yes,resizable=yes');
+wingm.focus();
+</script>
+ <?php
+}
+
+function uniDecode($str,$charcode){
+ $text = preg_replace_callback("/%u[0-9A-Za-z]{4}/",toUtf8,$str);
+ return mb_convert_encoding($text, $charcode, 'UTF-8');
+}
+function toUtf8($ar){
+ foreach($ar as $val){
+ $val = intval(substr($val,2),16);
+ if($val < 0x7F){ // 0000-007F
+ $c .= chr($val);
+ }elseif($val < 0x800) { // 0080-0800
+ $c .= chr(0xC0 | ($val / 64));
+ $c .= chr(0x80 | ($val % 64));
+ }else{ // 0800-FFFF
+ $c .= chr(0xE0 | (($val / 64) / 64));
+ $c .= chr(0x80 | (($val / 64) % 64));
+ $c .= chr(0x80 | ($val % 64));
+ }
+ }
+ return $c;
+}
+
+?>
\ No newline at end of file
-<?php\r
-/*\r
- * Nucleus: PHP/MySQL Weblog CMS (http://nucleuscms.org/)\r
- * Copyright (C) 2002-2005 The Nucleus Group\r
- *\r
- * This program is free software; you can redistribute it and/or\r
- * modify it under the terms of the GNU General Public License\r
- * as published by the Free Software Foundation; either version 2\r
- * of the License, or (at your option) any later version.\r
- * (see nucleus/documentation/index.html#license for more info)\r
- */\r
-/**\r
- * Media popup window for Nucleus\r
- *\r
- * Purpose:\r
- * - can be openen from an add-item form or bookmarklet popup\r
- * - shows a list of recent files, allowing browsing, search and\r
- * upload of new files\r
- * - close the popup by selecting a file in the list. The file gets\r
- * passed through to the add-item form (linkto, popupimg or inline img)\r
- *\r
- * @license http://nucleuscms.org/license.txt GNU General Public License\r
- * @copyright Copyright (C) 2002-2005 The Nucleus Group\r
- * @version $Id: media.php,v 1.5 2005-08-13 07:33:45 kimitake Exp $\r
- * $NucleusJP: media.php,v 1.4 2005/03/16 07:55:04 kimitake Exp $\r
- *\r
- */\r
- \r
-$CONF = array();\r
-\r
-// defines how much media items will be shown per page. You can override this\r
-// in config.php if you like. (changing it in config.php instead of here will\r
-// allow your settings to be kept even after a Nucleus upgrade)\r
-$CONF['MediaPerPage'] = 10;\r
-\r
-// include all classes and config data\r
-include('../config.php');\r
-include($DIR_LIBS . 'MEDIA.php'); // media classes\r
-\r
-sendContentType('application/xhtml+xml', 'media');\r
-\r
-// user needs to be logged in to use this\r
-if (!$member->isLoggedIn()) {\r
- media_loginAndPassThrough();\r
- exit;\r
-}\r
-\r
-// check if member is on at least one teamlist\r
-$query = 'SELECT * FROM ' . sql_table('team'). ' WHERE tmember=' . $member->getID();\r
-$teams = mysql_query($query);\r
-if (mysql_num_rows($teams) == 0)\r
- media_doError(_ERROR_DISALLOWEDUPLOAD);\r
- \r
-// get action\r
-$action = requestVar('action');\r
-if ($action == '')\r
- $action = 'selectmedia';\r
- \r
-// check ticket\r
-$aActionsNotToCheck = array('selectmedia', _MEDIA_FILTER_APPLY, _MEDIA_COLLECTION_SELECT);\r
-if (!in_array($action, $aActionsNotToCheck))\r
-{\r
- if (!$manager->checkTicket())\r
- media_doError(_ERROR_BADTICKET);\r
-} \r
-\r
-\r
-switch($action) {\r
- case 'chooseupload':\r
- case _MEDIA_UPLOAD_TO:\r
- case _MEDIA_UPLOAD_NEW:\r
- media_choose();\r
- break;\r
- case 'uploadfile':\r
- media_upload();\r
- break;\r
- case _MEDIA_FILTER_APPLY:\r
- case 'selectmedia':\r
- case _MEDIA_COLLECTION_SELECT:\r
- default:\r
- media_select();\r
- break;\r
-}\r
-\r
-// select a file\r
-function media_select() {\r
- global $member, $CONF, $DIR_MEDIA, $manager;\r
- \r
- media_head();\r
- \r
- // show 10 files + navigation buttons \r
- // show msg when no files\r
- // show upload form\r
- // files sorted according to last modification date\r
-\r
- // currently selected collection\r
- $currentCollection = requestVar('collection');\r
- if (!$currentCollection || !@is_dir($DIR_MEDIA . $currentCollection))\r
- $currentCollection = $member->getID();\r
- \r
- \r
- // get collection list\r
- $collections = MEDIA::getCollectionList();\r
-\r
- if (sizeof($collections) > 1) {\r
- ?>\r
- <form method="post" action="media.php"><div>\r
- <label for="media_collection"><?php echo htmlspecialchars(_MEDIA_COLLECTION_LABEL)?></label>\r
- <select name="collection" id="media_collection">\r
- <?php foreach ($collections as $dirname => $description) {\r
- echo '<option value="',htmlspecialchars($dirname),'"';\r
- if ($dirname == $currentCollection) {\r
- echo ' selected="selected"';\r
- }\r
- echo '>',htmlspecialchars($description),'</option>';\r
- }\r
- ?>\r
- </select>\r
- <input type="submit" name="action" value="<?php echo htmlspecialchars(_MEDIA_COLLECTION_SELECT) ?>" title="<?php echo htmlspecialchars(_MEDIA_COLLECTION_TT)?>" />\r
- <input type="submit" name="action" value="<?php echo htmlspecialchars(_MEDIA_UPLOAD_TO) ?>" title="<?php echo htmlspecialchars(_MEDIA_UPLOADLINK) ?>" />\r
- <?php $manager->addTicketHidden() ?>\r
- </div></form>\r
- <?php } else {\r
- ?>\r
- <form method="post" action="media.php" style="float:right"><div>\r
- <input type="hidden" name="collection" value="<?php echo htmlspecialchars($currentCollection)?>" />\r
- <input type="submit" name="action" value="<?php echo htmlspecialchars(_MEDIA_UPLOAD_NEW) ?>" title="<?php echo htmlspecialchars(_MEDIA_UPLOADLINK) ?>" />\r
- <?php $manager->addTicketHidden() ?>\r
- </div></form> \r
- <?php } // if sizeof\r
- \r
- $filter = requestVar('filter'); \r
- $offset = intRequestVar('offset'); \r
- $arr = MEDIA::getMediaListByCollection($currentCollection, $filter);\r
-\r
- ?>\r
- <form method="post" action="media.php"><div>\r
- <label for="media_filter"><?php echo htmlspecialchars(_MEDIA_FILTER_LABEL)?></label>\r
- <input id="media_filter" type="text" name="filter" value="<?php echo htmlspecialchars($filter)?>" />\r
- <input type="submit" name="action" value="<?php echo htmlspecialchars(_MEDIA_FILTER_APPLY) ?>" />\r
- <input type="hidden" name="collection" value="<?php echo htmlspecialchars($currentCollection)?>" /> \r
- <input type="hidden" name="offset" value="<?php echo intval($offset)?>" /> \r
- </div></form> \r
- \r
- <?php\r
- \r
- ?> \r
- <table width="100%">\r
- <caption><?php echo _MEDIA_COLLECTION_LABEL . htmlspecialchars($collections[$currentCollection])?></caption>\r
- <tr>\r
- <th><?php echo _MEDIA_MODIFIED?></th><th><?php echo _MEDIA_FILENAME?></th><th><?php echo _MEDIA_DIMENSIONS?></th>\r
- </tr>\r
- \r
- <?php \r
- \r
- if (sizeof($arr)>0) {\r
- \r
- if (($offset + $CONF['MediaPerPage']) >= sizeof($arr))\r
- $offset = sizeof($arr) - $CONF['MediaPerPage'];\r
-\r
- if ($offset < 0) $offset = 0;\r
- \r
- $idxStart = $offset;\r
- $idxEnd = $offset + $CONF['MediaPerPage'];\r
- $idxNext = $idxEnd;\r
- $idxPrev = $idxStart - $CONF['MediaPerPage'];\r
-\r
- if ($idxPrev < 0) $idxPrev = 0;\r
-\r
- if ($idxEnd > sizeof($arr))\r
- $idxEnd = sizeof($arr);\r
-\r
- for($i=$idxStart;$i<$idxEnd;$i++) {\r
- $obj = $arr[$i];\r
- $filename = $DIR_MEDIA . $currentCollection . '/' . $obj->filename;\r
-\r
- $old_level = error_reporting(0);\r
- $size = @GetImageSize($filename); \r
- error_reporting($old_level);\r
- $width = $size[0];\r
- $height = $size[1];\r
- $filetype = $size[2];\r
- \r
- echo "<tr>";\r
- echo "<td>". date("Y-m-d",$obj->timestamp) ."</td>";\r
- \r
- // strings for javascript\r
- $jsCurrentCollection = str_replace("'","\\'",$currentCollection);\r
- $jsFileName = str_replace("'","\\'",$obj->filename);\r
-\r
- if ($filetype != 0) {\r
- // image (gif/jpg/png/swf)\r
- echo "<td><a href=\"media.php\" onclick=\"chooseImage('", htmlspecialchars($jsCurrentCollection), "','", htmlspecialchars($jsFileName), "',"\r
- . "'", htmlspecialchars($width), "','" , htmlspecialchars($height), "'"\r
- . ")\" title=\"" . htmlspecialchars($obj->filename). "\">"\r
- . htmlspecialchars(shorten($obj->filename,25,'...'))\r
- ."</a>";\r
- echo ' (<a href="', htmlspecialchars($CONF['MediaURL'] . $currentCollection . '/' . $obj->filename), '" onclick="window.open(this.href); return false;" title="',htmlspecialchars(_MEDIA_VIEW_TT),'">',_MEDIA_VIEW,'</a>)';\r
- echo "</td>";\r
- } else {\r
- // no image (e.g. mpg)\r
- echo "<td><a href='media.php' onclick=\"chooseOther('" , htmlspecialchars($jsCurrentCollection), "','", htmlspecialchars($jsFileName), "'"\r
- . ")\" title=\"" . htmlspecialchars($obj->filename). "\">"\r
- . htmlspecialchars(shorten($obj->filename,30,'...'))\r
- ."</a></td>";\r
-\r
- }\r
- echo '<td>' , htmlspecialchars($width) , 'x' , htmlspecialchars($height) , '</td>';\r
- echo '</tr>';\r
- }\r
- } // if (sizeof($arr)>0)\r
- ?>\r
- \r
- </table>\r
- <?php \r
- if ($idxStart > 0)\r
- echo "<a href='media.php?offset=$idxPrev&collection=".urlencode($currentCollection)."'>". _LISTS_PREV."</a> ";\r
- if ($idxEnd < sizeof($arr))\r
- echo "<a href='media.php?offset=$idxNext&collection=".urlencode($currentCollection)."'>". _LISTS_NEXT."</a> ";\r
- \r
- ?>\r
- <input id="typeradio0" type="radio" name="typeradio" onclick="setType(0);" checked="checked" /><label for="typeradio0"><?php echo _MEDIA_INLINE?></label>\r
- <input id="typeradio1" type="radio" name="typeradio" onclick="setType(1);" /><label for="typeradio1"><?php echo _MEDIA_POPUP?></label>\r
- <?php \r
- media_foot();\r
- \r
- \r
-}\r
-\r
-/**\r
- * Shows a screen where you can select the file to upload\r
- */\r
-function media_choose() {\r
- global $CONF, $member, $manager;\r
-\r
- $currentCollection = requestVar('collection');\r
- \r
- $collections = MEDIA::getCollectionList();\r
-\r
- media_head();\r
- ?>\r
- <h1><?php echo _UPLOAD_TITLE?></h1>\r
- \r
- <p><?php echo _UPLOAD_MSG?></p>\r
- \r
- <form method="post" enctype="multipart/form-data" action="media.php">\r
- <div>\r
- <input type="hidden" name="action" value="uploadfile" />\r
- <?php $manager->addTicketHidden() ?>\r
- <input type="hidden" name="MAX_FILE_SIZE" value="<?php echo $CONF['MaxUploadSize']?>" />\r
- File:\r
- <br />\r
- <input name="uploadfile" type="file" size="40" />\r
- <?php if (sizeof($collections) > 1) {\r
- ?>\r
- <br /><br /><label for="upload_collection">Collection:</label>\r
- <br /><select name="collection" id="upload_collection">\r
- <?php foreach ($collections as $dirname => $description) {\r
- echo '<option value="',htmlspecialchars($dirname),'"';\r
- if ($dirname == $currentCollection) {\r
- echo ' selected="selected"';\r
- }\r
- echo '>',htmlspecialchars($description),'</option>';\r
- }\r
- ?>\r
- </select>\r
- <?php } else {\r
- ?>\r
- <input name="collection" type="hidden" value="<?php echo htmlspecialchars(requestVar('collection'))?>" /> \r
- <?php } // if sizeof\r
- ?> \r
- <br /><br />\r
- <input type="submit" value="<?php echo _UPLOAD_BUTTON?>" />\r
- </div>\r
- </form>\r
- \r
- <?php \r
- media_foot();\r
-}\r
-\r
-\r
-/**\r
- * accepts a file for upload\r
- */\r
-function media_upload() {\r
- global $DIR_MEDIA, $member, $CONF;\r
-\r
- $uploadInfo = postFileInfo('uploadfile');\r
- \r
- $filename = $uploadInfo['name'];\r
- $filetype = $uploadInfo['type'];\r
- $filesize = $uploadInfo['size'];\r
- $filetempname = $uploadInfo['tmp_name'];\r
- \r
- if ($filesize > $CONF['MaxUploadSize'])\r
- media_doError(_ERROR_FILE_TOO_BIG);\r
- \r
- // check file type against allowed types\r
- $ok = 0;\r
- $allowedtypes = explode (',', $CONF['AllowedTypes']);\r
- foreach ( $allowedtypes as $type ) \r
- if (eregi("\." .$type. "$",$filename)) $ok = 1; \r
- if (!$ok) media_doError(_ERROR_BADFILETYPE);\r
- \r
- if (!is_uploaded_file($filetempname)) \r
- media_doError(_ERROR_BADREQUEST);\r
-\r
- // prefix filename with current date (YYYY-MM-DD-)\r
- // this to avoid nameclashes\r
- if ($CONF['MediaPrefix'])\r
- $filename = strftime("%Y%m%d-", time()) . $filename;\r
-\r
- $collection = requestVar('collection');\r
- $res = MEDIA::addMediaObject($collection, $filetempname, $filename);\r
-\r
- if ($res != '') \r
- media_doError($res);\r
- \r
- // shows updated list afterwards\r
- media_select();\r
-}\r
-\r
-function media_loginAndPassThrough() {\r
- media_head();\r
- ?>\r
- <h1><?php echo _LOGIN_PLEASE?></h1>\r
- \r
- <form method="post" action="media.php">\r
- <div>\r
- <input name="action" value="login" type="hidden" />\r
- <input name="collection" value="<?php echo htmlspecialchars(requestVar('collection'))?>" type="hidden" /> \r
- <?php echo _LOGINFORM_NAME?>: <input name="login" />\r
- <br /><?php echo _LOGINFORM_PWD?>: <input name="password" type="password" />\r
- <br /><input type="submit" value="<?php echo _LOGIN?>" />\r
- </div>\r
- </form>\r
- <p><a href="media.php" onclick="window.close();"><?php echo _POPUP_CLOSE?></a></p>\r
- <?php media_foot();\r
- exit;\r
-}\r
-\r
-function media_doError($msg) {\r
- media_head();\r
- ?>\r
- <h1><?php echo _ERROR?></h1>\r
- <p><?php echo $msg?></p>\r
- <p><a href="media.php" onclick="history.back()"><?php echo _BACK?></a></p>\r
- <?php media_foot();\r
- exit;\r
-}\r
-\r
-\r
-function media_head() {\r
-?>\r
- <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">\r
- <html xmlns="http://www.w3.org/1999/xhtml">\r
- <head>\r
- <meta http-equiv="Content-Type" content="text/html; charset=<?php echo _CHARSET ?>" />\r
- <title>Nucleus Media</title>\r
- <link rel="stylesheet" type="text/css" href="styles/popups.css" />\r
- <script type="text/javascript">\r
- var type = 0;\r
- function setType(val) { type = val; }\r
- \r
- function chooseImage(collection, filename, width, height) {\r
- window.opener.focus(); \r
- window.opener.includeImage(collection,\r
- filename, \r
- type == 0 ? 'inline' : 'popup',\r
- width,\r
- height\r
- );\r
- window.close();\r
- }\r
- \r
- function chooseOther(collection, filename) {\r
- window.opener.focus(); \r
- window.opener.includeOtherMedia(collection, filename);\r
- window.close();\r
- \r
- }\r
- </script>\r
- </head>\r
- <body> \r
-<?php }\r
-\r
-function media_foot() {\r
-?>\r
- </body>\r
- </html> \r
-<?php } \r
-\r
-?>\r
+<?php
+/*
+ * Nucleus: PHP/MySQL Weblog CMS (http://nucleuscms.org/)
+ * Copyright (C) 2002-2006 The Nucleus Group
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ * (see nucleus/documentation/index.html#license for more info)
+ */
+/**
+ * Media popup window for Nucleus
+ *
+ * Purpose:
+ * - can be openen from an add-item form or bookmarklet popup
+ * - shows a list of recent files, allowing browsing, search and
+ * upload of new files
+ * - close the popup by selecting a file in the list. The file gets
+ * passed through to the add-item form (linkto, popupimg or inline img)
+ *
+ * @license http://nucleuscms.org/license.txt GNU General Public License
+ * @copyright Copyright (C) 2002-2006 The Nucleus Group
+ * @version $Id: media.php,v 1.6 2006-07-17 20:01:39 kimitake Exp $
+ * $NucleusJP: media.php,v 1.5 2005/08/13 07:33:45 kimitake Exp $
+ *
+ */
+
+$CONF = array();
+
+// defines how much media items will be shown per page. You can override this
+// in config.php if you like. (changing it in config.php instead of here will
+// allow your settings to be kept even after a Nucleus upgrade)
+$CONF['MediaPerPage'] = 10;
+
+// include all classes and config data
+include('../config.php');
+include($DIR_LIBS . 'MEDIA.php'); // media classes
+
+sendContentType('application/xhtml+xml', 'media');
+
+// user needs to be logged in to use this
+if (!$member->isLoggedIn()) {
+ media_loginAndPassThrough();
+ exit;
+}
+
+// check if member is on at least one teamlist
+$query = 'SELECT * FROM ' . sql_table('team'). ' WHERE tmember=' . $member->getID();
+$teams = mysql_query($query);
+if (mysql_num_rows($teams) == 0)
+ media_doError(_ERROR_DISALLOWEDUPLOAD);
+
+// get action
+$action = requestVar('action');
+if ($action == '')
+ $action = 'selectmedia';
+
+// check ticket
+$aActionsNotToCheck = array('selectmedia', _MEDIA_FILTER_APPLY, _MEDIA_COLLECTION_SELECT);
+if (!in_array($action, $aActionsNotToCheck))
+{
+ if (!$manager->checkTicket())
+ media_doError(_ERROR_BADTICKET);
+}
+
+
+switch($action) {
+ case 'chooseupload':
+ case _MEDIA_UPLOAD_TO:
+ case _MEDIA_UPLOAD_NEW:
+ media_choose();
+ break;
+ case 'uploadfile':
+ media_upload();
+ break;
+ case _MEDIA_FILTER_APPLY:
+ case 'selectmedia':
+ case _MEDIA_COLLECTION_SELECT:
+ default:
+ media_select();
+ break;
+}
+
+// select a file
+function media_select() {
+ global $member, $CONF, $DIR_MEDIA, $manager;
+
+ media_head();
+
+ // show 10 files + navigation buttons
+ // show msg when no files
+ // show upload form
+ // files sorted according to last modification date
+
+ // currently selected collection
+ $currentCollection = requestVar('collection');
+ if (!$currentCollection || !@is_dir($DIR_MEDIA . $currentCollection))
+ $currentCollection = $member->getID();
+
+
+ // get collection list
+ $collections = MEDIA::getCollectionList();
+
+ if (sizeof($collections) > 1) {
+ ?>
+ <form method="post" action="media.php"><div>
+ <label for="media_collection"><?php echo htmlspecialchars(_MEDIA_COLLECTION_LABEL)?></label>
+ <select name="collection" id="media_collection">
+ <?php foreach ($collections as $dirname => $description) {
+ echo '<option value="',htmlspecialchars($dirname),'"';
+ if ($dirname == $currentCollection) {
+ echo ' selected="selected"';
+ }
+ echo '>',htmlspecialchars($description),'</option>';
+ }
+ ?>
+ </select>
+ <input type="submit" name="action" value="<?php echo htmlspecialchars(_MEDIA_COLLECTION_SELECT) ?>" title="<?php echo htmlspecialchars(_MEDIA_COLLECTION_TT)?>" />
+ <input type="submit" name="action" value="<?php echo htmlspecialchars(_MEDIA_UPLOAD_TO) ?>" title="<?php echo htmlspecialchars(_MEDIA_UPLOADLINK) ?>" />
+ <?php $manager->addTicketHidden() ?>
+ </div></form>
+ <?php } else {
+ ?>
+ <form method="post" action="media.php" style="float:right"><div>
+ <input type="hidden" name="collection" value="<?php echo htmlspecialchars($currentCollection)?>" />
+ <input type="submit" name="action" value="<?php echo htmlspecialchars(_MEDIA_UPLOAD_NEW) ?>" title="<?php echo htmlspecialchars(_MEDIA_UPLOADLINK) ?>" />
+ <?php $manager->addTicketHidden() ?>
+ </div></form>
+ <?php } // if sizeof
+
+ $filter = requestVar('filter');
+ $offset = intRequestVar('offset');
+ $arr = MEDIA::getMediaListByCollection($currentCollection, $filter);
+
+ ?>
+ <form method="post" action="media.php"><div>
+ <label for="media_filter"><?php echo htmlspecialchars(_MEDIA_FILTER_LABEL)?></label>
+ <input id="media_filter" type="text" name="filter" value="<?php echo htmlspecialchars($filter)?>" />
+ <input type="submit" name="action" value="<?php echo htmlspecialchars(_MEDIA_FILTER_APPLY) ?>" />
+ <input type="hidden" name="collection" value="<?php echo htmlspecialchars($currentCollection)?>" />
+ <input type="hidden" name="offset" value="<?php echo intval($offset)?>" />
+ </div></form>
+
+ <?php
+
+ ?>
+ <table width="100%">
+ <caption><?php echo _MEDIA_COLLECTION_LABEL . htmlspecialchars($collections[$currentCollection])?></caption>
+ <tr>
+ <th><?php echo _MEDIA_MODIFIED?></th><th><?php echo _MEDIA_FILENAME?></th><th><?php echo _MEDIA_DIMENSIONS?></th>
+ </tr>
+
+ <?php
+
+ if (sizeof($arr)>0) {
+
+ if (($offset + $CONF['MediaPerPage']) >= sizeof($arr))
+ $offset = sizeof($arr) - $CONF['MediaPerPage'];
+
+ if ($offset < 0) $offset = 0;
+
+ $idxStart = $offset;
+ $idxEnd = $offset + $CONF['MediaPerPage'];
+ $idxNext = $idxEnd;
+ $idxPrev = $idxStart - $CONF['MediaPerPage'];
+
+ if ($idxPrev < 0) $idxPrev = 0;
+
+ if ($idxEnd > sizeof($arr))
+ $idxEnd = sizeof($arr);
+
+ for($i=$idxStart;$i<$idxEnd;$i++) {
+ $obj = $arr[$i];
+ $filename = $DIR_MEDIA . $currentCollection . '/' . $obj->filename;
+
+ $old_level = error_reporting(0);
+ $size = @GetImageSize($filename);
+ error_reporting($old_level);
+ $width = $size[0];
+ $height = $size[1];
+ $filetype = $size[2];
+
+ echo "<tr>";
+ echo "<td>". date("Y-m-d",$obj->timestamp) ."</td>";
+
+ // strings for javascript
+ $jsCurrentCollection = str_replace("'","\\'",$currentCollection);
+ $jsFileName = str_replace("'","\\'",$obj->filename);
+
+ if ($filetype != 0) {
+ // image (gif/jpg/png/swf)
+ echo "<td><a href=\"media.php\" onclick=\"chooseImage('", htmlspecialchars($jsCurrentCollection), "','", htmlspecialchars($jsFileName), "',"
+ . "'", htmlspecialchars($width), "','" , htmlspecialchars($height), "'"
+ . ")\" title=\"" . htmlspecialchars($obj->filename). "\">"
+ . htmlspecialchars(shorten($obj->filename,25,'...'))
+ ."</a>";
+ echo ' (<a href="', htmlspecialchars($CONF['MediaURL'] . $currentCollection . '/' . $obj->filename), '" onclick="window.open(this.href); return false;" title="',htmlspecialchars(_MEDIA_VIEW_TT),'">',_MEDIA_VIEW,'</a>)';
+ echo "</td>";
+ } else {
+ // no image (e.g. mpg)
+ echo "<td><a href='media.php' onclick=\"chooseOther('" , htmlspecialchars($jsCurrentCollection), "','", htmlspecialchars($jsFileName), "'"
+ . ")\" title=\"" . htmlspecialchars($obj->filename). "\">"
+ . htmlspecialchars(shorten($obj->filename,30,'...'))
+ ."</a></td>";
+
+ }
+ echo '<td>' , htmlspecialchars($width) , 'x' , htmlspecialchars($height) , '</td>';
+ echo '</tr>';
+ }
+ } // if (sizeof($arr)>0)
+ ?>
+
+ </table>
+ <?php
+ if ($idxStart > 0)
+ echo "<a href='media.php?offset=$idxPrev&collection=".urlencode($currentCollection)."'>". _LISTS_PREV."</a> ";
+ if ($idxEnd < sizeof($arr))
+ echo "<a href='media.php?offset=$idxNext&collection=".urlencode($currentCollection)."'>". _LISTS_NEXT."</a> ";
+
+ ?>
+ <input id="typeradio0" type="radio" name="typeradio" onclick="setType(0);" checked="checked" /><label for="typeradio0"><?php echo _MEDIA_INLINE?></label>
+ <input id="typeradio1" type="radio" name="typeradio" onclick="setType(1);" /><label for="typeradio1"><?php echo _MEDIA_POPUP?></label>
+ <?php
+ media_foot();
+
+
+}
+
+/**
+ * Shows a screen where you can select the file to upload
+ */
+function media_choose() {
+ global $CONF, $member, $manager;
+
+ $currentCollection = requestVar('collection');
+
+ $collections = MEDIA::getCollectionList();
+
+ media_head();
+ ?>
+ <h1><?php echo _UPLOAD_TITLE?></h1>
+
+ <p><?php echo _UPLOAD_MSG?></p>
+
+ <form method="post" enctype="multipart/form-data" action="media.php">
+ <div>
+ <input type="hidden" name="action" value="uploadfile" />
+ <?php $manager->addTicketHidden() ?>
+ <input type="hidden" name="MAX_FILE_SIZE" value="<?php echo $CONF['MaxUploadSize']?>" />
+ File:
+ <br />
+ <input name="uploadfile" type="file" size="40" />
+ <?php if (sizeof($collections) > 1) {
+ ?>
+ <br /><br /><label for="upload_collection">Collection:</label>
+ <br /><select name="collection" id="upload_collection">
+ <?php foreach ($collections as $dirname => $description) {
+ echo '<option value="',htmlspecialchars($dirname),'"';
+ if ($dirname == $currentCollection) {
+ echo ' selected="selected"';
+ }
+ echo '>',htmlspecialchars($description),'</option>';
+ }
+ ?>
+ </select>
+ <?php } else {
+ ?>
+ <input name="collection" type="hidden" value="<?php echo htmlspecialchars(requestVar('collection'))?>" />
+ <?php } // if sizeof
+ ?>
+ <br /><br />
+ <input type="submit" value="<?php echo _UPLOAD_BUTTON?>" />
+ </div>
+ </form>
+
+ <?php
+ media_foot();
+}
+
+
+/**
+ * accepts a file for upload
+ */
+function media_upload() {
+ global $DIR_MEDIA, $member, $CONF;
+
+ $uploadInfo = postFileInfo('uploadfile');
+
+ $filename = $uploadInfo['name'];
+ $filetype = $uploadInfo['type'];
+ $filesize = $uploadInfo['size'];
+ $filetempname = $uploadInfo['tmp_name'];
+ $fileerror = intval($uploadInfo['error']);
+
+ switch ($fileerror)
+ {
+ case 0: // = UPLOAD_ERR_OK
+ break;
+ case 1: // = UPLOAD_ERR_INI_SIZE
+ case 2: // = UPLOAD_ERR_FORM_SIZE
+ media_doError(_ERROR_FILE_TOO_BIG);
+ case 3: // = UPLOAD_ERR_PARTIAL
+ case 4: // = UPLOAD_ERR_NO_FILE
+ case 6: // = UPLOAD_ERR_NO_TMP_DIR
+ case 7: // = UPLOAD_ERR_CANT_WRITE
+ default:
+ // include error code for debugging
+ // (see http://www.php.net/manual/en/features.file-upload.errors.php)
+ media_doError(_ERROR_BADREQUEST . ' (' . $fileerror . ')');
+ }
+
+ if ($filesize > $CONF['MaxUploadSize'])
+ media_doError(_ERROR_FILE_TOO_BIG);
+
+ // check file type against allowed types
+ $ok = 0;
+ $allowedtypes = explode (',', $CONF['AllowedTypes']);
+ foreach ( $allowedtypes as $type )
+ if (eregi("\." .$type. "$",$filename)) $ok = 1;
+ if (!$ok) media_doError(_ERROR_BADFILETYPE);
+
+ if (!is_uploaded_file($filetempname))
+ media_doError(_ERROR_BADREQUEST);
+
+ // prefix filename with current date (YYYY-MM-DD-)
+ // this to avoid nameclashes
+ if ($CONF['MediaPrefix'])
+ $filename = strftime("%Y%m%d-", time()) . $filename;
+
+ $collection = requestVar('collection');
+ $res = MEDIA::addMediaObject($collection, $filetempname, $filename);
+
+ if ($res != '')
+ media_doError($res);
+
+ // shows updated list afterwards
+ media_select();
+}
+
+function media_loginAndPassThrough() {
+ media_head();
+ ?>
+ <h1><?php echo _LOGIN_PLEASE?></h1>
+
+ <form method="post" action="media.php">
+ <div>
+ <input name="action" value="login" type="hidden" />
+ <input name="collection" value="<?php echo htmlspecialchars(requestVar('collection'))?>" type="hidden" />
+ <?php echo _LOGINFORM_NAME?>: <input name="login" />
+ <br /><?php echo _LOGINFORM_PWD?>: <input name="password" type="password" />
+ <br /><input type="submit" value="<?php echo _LOGIN?>" />
+ </div>
+ </form>
+ <p><a href="media.php" onclick="window.close();"><?php echo _POPUP_CLOSE?></a></p>
+ <?php media_foot();
+ exit;
+}
+
+function media_doError($msg) {
+ media_head();
+ ?>
+ <h1><?php echo _ERROR?></h1>
+ <p><?php echo $msg?></p>
+ <p><a href="media.php" onclick="history.back()"><?php echo _BACK?></a></p>
+ <?php media_foot();
+ exit;
+}
+
+
+function media_head() {
+?>
+ <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
+ <html xmlns="http://www.w3.org/1999/xhtml">
+ <head>
+ <meta http-equiv="Content-Type" content="text/html; charset=<?php echo _CHARSET ?>" />
+ <title>Nucleus Media</title>
+ <link rel="stylesheet" type="text/css" href="styles/popups.css" />
+ <script type="text/javascript">
+ var type = 0;
+ function setType(val) { type = val; }
+
+ function chooseImage(collection, filename, width, height) {
+ window.opener.focus();
+ window.opener.includeImage(collection,
+ filename,
+ type == 0 ? 'inline' : 'popup',
+ width,
+ height
+ );
+ window.close();
+ }
+
+ function chooseOther(collection, filename) {
+ window.opener.focus();
+ window.opener.includeOtherMedia(collection, filename);
+ window.close();
+
+ }
+ </script>
+ </head>
+ <body>
+<?php }
+
+function media_foot() {
+?>
+ </body>
+ </html>
+<?php }
+
+?>