[CORE] Move public resources to a /public directory
Advantages: * Increases security by preventing direct access to file/ * We are careful and have a defined('GNUSOCIAL') || die() to prevent direct access to GS files, but we may miss one or a vendor/extlib may not be as careful * Improves directory structure - It's more natural to physically separate what is public from what are GNU social resources
325
index.php
|
@ -1,325 +0,0 @@
|
|||
<?php
|
||||
/**
|
||||
* StatusNet - the distributed open-source microblogging tool
|
||||
* Copyright (C) 2008, 2009, StatusNet, Inc.
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Affero General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Affero General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
* @category StatusNet
|
||||
* @package StatusNet
|
||||
* @author Brenda Wallace <shiny@cpan.org>
|
||||
* @author Brion Vibber <brion@pobox.com>
|
||||
* @author Christopher Vollick <psycotica0@gmail.com>
|
||||
* @author CiaranG <ciaran@ciarang.com>
|
||||
* @author Craig Andrews <candrews@integralblue.com>
|
||||
* @author Evan Prodromou <evan@controlezvous.ca>
|
||||
* @author Gina Haeussge <osd@foosel.net>
|
||||
* @author James Walker <walkah@walkah.net>
|
||||
* @author Jeffery To <jeffery.to@gmail.com>
|
||||
* @author Mike Cochrane <mikec@mikenz.geek.nz>
|
||||
* @author Robin Millette <millette@controlyourself.ca>
|
||||
* @author Sarven Capadisli <csarven@controlyourself.ca>
|
||||
* @author Tom Adams <tom@holizz.com>
|
||||
* @author Zach Copley <zach@status.net>
|
||||
* @copyright 2009 Free Software Foundation, Inc http://www.fsf.org
|
||||
*
|
||||
* @license GNU Affero General Public License http://www.gnu.org/licenses/
|
||||
*/
|
||||
|
||||
$_startTime = microtime(true);
|
||||
$_perfCounters = array();
|
||||
|
||||
// We provide all our dependencies through our own autoload.
|
||||
// This will probably be configurable for distributing with
|
||||
// system packages (like with Debian apt etc. where included
|
||||
// libraries are maintained through repositories)
|
||||
set_include_path('.'); // mainly fixes an issue where /usr/share/{pear,php*}/DB/DataObject.php is _old_ on various systems...
|
||||
|
||||
define('INSTALLDIR', dirname(__FILE__));
|
||||
define('GNUSOCIAL', true);
|
||||
define('STATUSNET', true); // compatibility
|
||||
|
||||
$user = null;
|
||||
$action = null;
|
||||
|
||||
function getPath($req)
|
||||
{
|
||||
$p = null;
|
||||
|
||||
if ((common_config('site', 'fancy') || !array_key_exists('PATH_INFO', $_SERVER))
|
||||
&& array_key_exists('p', $req)
|
||||
) {
|
||||
$p = $req['p'];
|
||||
} else if (array_key_exists('PATH_INFO', $_SERVER)) {
|
||||
$path = $_SERVER['PATH_INFO'];
|
||||
$script = $_SERVER['SCRIPT_NAME'];
|
||||
if (substr($path, 0, mb_strlen($script)) == $script) {
|
||||
$p = substr($path, mb_strlen($script) + 1);
|
||||
} else {
|
||||
$p = $path;
|
||||
}
|
||||
} else {
|
||||
$p = null;
|
||||
}
|
||||
|
||||
// Trim all initial '/'
|
||||
|
||||
$p = ltrim($p, '/');
|
||||
|
||||
return $p;
|
||||
}
|
||||
|
||||
/**
|
||||
* logs and then displays error messages
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
function handleError($error)
|
||||
{
|
||||
try {
|
||||
|
||||
if ($error->getCode() == DB_DATAOBJECT_ERROR_NODATA) {
|
||||
return;
|
||||
}
|
||||
|
||||
$logmsg = "Exception thrown: " . _ve($error->getMessage());
|
||||
if ($error instanceof PEAR_Exception && common_config('log', 'debugtrace')) {
|
||||
$logmsg .= " PEAR: ". $error->toText();
|
||||
}
|
||||
// DB queries often end up with a lot of newlines; merge to a single line
|
||||
// for easier grepability...
|
||||
$logmsg = str_replace("\n", " ", $logmsg);
|
||||
common_log(LOG_ERR, $logmsg);
|
||||
|
||||
// @fixme backtrace output should be consistent with exception handling
|
||||
if (common_config('log', 'debugtrace')) {
|
||||
$bt = $error->getTrace();
|
||||
foreach ($bt as $n => $line) {
|
||||
common_log(LOG_ERR, formatBacktraceLine($n, $line));
|
||||
}
|
||||
}
|
||||
if ($error instanceof DB_DataObject_Error
|
||||
|| $error instanceof DB_Error
|
||||
|| ($error instanceof PEAR_Exception && $error->getCode() == -24)
|
||||
) {
|
||||
//If we run into a DB error, assume we can't connect to the DB at all
|
||||
//so set the current user to null, so we don't try to access the DB
|
||||
//while rendering the error page.
|
||||
global $_cur;
|
||||
$_cur = null;
|
||||
|
||||
$msg = sprintf(
|
||||
// TRANS: Database error message.
|
||||
_('The database for %1$s is not responding correctly, '.
|
||||
'so the site will not work properly. '.
|
||||
'The site admins probably know about the problem, '.
|
||||
'but you can contact them at %2$s to make sure. '.
|
||||
'Otherwise, wait a few minutes and try again.'
|
||||
),
|
||||
common_config('site', 'name'),
|
||||
common_config('site', 'email')
|
||||
);
|
||||
|
||||
$erraction = new DBErrorAction($msg, 500);
|
||||
} elseif ($error instanceof ClientException) {
|
||||
$erraction = new ClientErrorAction($error->getMessage(), $error->getCode());
|
||||
} elseif ($error instanceof ServerException) {
|
||||
$erraction = new ServerErrorAction($error->getMessage(), $error->getCode(), $error);
|
||||
} else {
|
||||
// If it wasn't specified more closely which kind of exception it was
|
||||
$erraction = new ServerErrorAction($error->getMessage(), 500, $error);
|
||||
}
|
||||
$erraction->showPage();
|
||||
|
||||
} catch (Exception $e) {
|
||||
// TRANS: Error message.
|
||||
echo _('An error occurred.');
|
||||
exit(-1);
|
||||
}
|
||||
exit(-1);
|
||||
}
|
||||
|
||||
set_exception_handler('handleError');
|
||||
|
||||
// quick check for fancy URL auto-detection support in installer.
|
||||
if (preg_replace("/\?.+$/", "", $_SERVER['REQUEST_URI']) === preg_replace("/^\/$/", "", (dirname($_SERVER['REQUEST_URI']))) . '/check-fancy') {
|
||||
die("Fancy URL support detection succeeded. We suggest you enable this to get fancy (pretty) URLs.");
|
||||
}
|
||||
|
||||
require_once INSTALLDIR . '/lib/common.php';
|
||||
|
||||
/**
|
||||
* Format a backtrace line for debug output roughly like debug_print_backtrace() does.
|
||||
* Exceptions already have this built in, but PEAR error objects just give us the array.
|
||||
*
|
||||
* @param int $n line number
|
||||
* @param array $line per-frame array item from debug_backtrace()
|
||||
* @return string
|
||||
*/
|
||||
function formatBacktraceLine($n, $line)
|
||||
{
|
||||
$out = "#$n ";
|
||||
if (isset($line['class'])) $out .= $line['class'];
|
||||
if (isset($line['type'])) $out .= $line['type'];
|
||||
if (isset($line['function'])) $out .= $line['function'];
|
||||
$out .= '(';
|
||||
if (isset($line['args'])) {
|
||||
$args = array();
|
||||
foreach ($line['args'] as $arg) {
|
||||
// debug_print_backtrace seems to use var_export
|
||||
// but this gets *very* verbose!
|
||||
$args[] = gettype($arg);
|
||||
}
|
||||
$out .= implode(',', $args);
|
||||
}
|
||||
$out .= ')';
|
||||
$out .= ' called at [';
|
||||
if (isset($line['file'])) $out .= $line['file'];
|
||||
if (isset($line['line'])) $out .= ':' . $line['line'];
|
||||
$out .= ']';
|
||||
return $out;
|
||||
}
|
||||
|
||||
function setupRW()
|
||||
{
|
||||
global $config;
|
||||
|
||||
static $alwaysRW = array('session', 'remember_me');
|
||||
|
||||
$rwdb = $config['db']['database'];
|
||||
|
||||
if (Event::handle('StartReadWriteTables', array(&$alwaysRW, &$rwdb))) {
|
||||
|
||||
// We ensure that these tables always are used
|
||||
// on the master DB
|
||||
|
||||
$config['db']['database_rw'] = $rwdb;
|
||||
$config['db']['ini_rw'] = INSTALLDIR.'/classes/statusnet.ini';
|
||||
|
||||
foreach ($alwaysRW as $table) {
|
||||
$config['db']['table_'.$table] = 'rw';
|
||||
}
|
||||
|
||||
Event::handle('EndReadWriteTables', array($alwaysRW, $rwdb));
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
function isLoginAction($action)
|
||||
{
|
||||
static $loginActions = array('login', 'recoverpassword', 'api', 'doc', 'register', 'publicxrds', 'otp', 'opensearch', 'rsd');
|
||||
|
||||
$login = null;
|
||||
|
||||
if (Event::handle('LoginAction', array($action, &$login))) {
|
||||
$login = in_array($action, $loginActions);
|
||||
}
|
||||
|
||||
return $login;
|
||||
}
|
||||
|
||||
function main()
|
||||
{
|
||||
global $user, $action;
|
||||
|
||||
if (!_have_config()) {
|
||||
$msg = sprintf(
|
||||
// TRANS: Error message displayed when there is no StatusNet configuration file.
|
||||
_("No configuration file found. Try running ".
|
||||
"the installation program first."
|
||||
)
|
||||
);
|
||||
$sac = new ServerErrorAction($msg);
|
||||
$sac->showPage();
|
||||
return;
|
||||
}
|
||||
|
||||
// Make sure RW database is setup
|
||||
|
||||
setupRW();
|
||||
|
||||
// XXX: we need a little more structure in this script
|
||||
|
||||
// get and cache current user (may hit RW!)
|
||||
|
||||
$user = common_current_user();
|
||||
|
||||
// initialize language env
|
||||
|
||||
common_init_language();
|
||||
|
||||
$path = getPath($_REQUEST);
|
||||
|
||||
$r = Router::get();
|
||||
|
||||
$args = $r->map($path);
|
||||
|
||||
// If the request is HTTP and it should be HTTPS...
|
||||
if (GNUsocial::useHTTPS() && !GNUsocial::isHTTPS()) {
|
||||
common_redirect(common_local_url($args['action'], $args));
|
||||
}
|
||||
|
||||
$args = array_merge($args, $_REQUEST ?: []);
|
||||
|
||||
Event::handle('ArgsInitialize', array(&$args));
|
||||
|
||||
$action = basename($args['action']);
|
||||
|
||||
if (!$action || !preg_match('/^[a-zA-Z0-9_-]*$/', $action)) {
|
||||
common_redirect(common_local_url('public'));
|
||||
}
|
||||
|
||||
// If the site is private, and they're not on one of the "public"
|
||||
// parts of the site, redirect to login
|
||||
|
||||
if (!$user && common_config('site', 'private')
|
||||
&& !isLoginAction($action)
|
||||
&& !preg_match('/rss$/', $action)
|
||||
&& $action != 'robotstxt'
|
||||
&& !preg_match('/^Api/', $action)) {
|
||||
|
||||
// set returnto
|
||||
$rargs =& common_copy_args($args);
|
||||
unset($rargs['action']);
|
||||
if (common_config('site', 'fancy')) {
|
||||
unset($rargs['p']);
|
||||
}
|
||||
if (array_key_exists('submit', $rargs)) {
|
||||
unset($rargs['submit']);
|
||||
}
|
||||
foreach (array_keys($_COOKIE) as $cookie) {
|
||||
unset($rargs[$cookie]);
|
||||
}
|
||||
common_set_returnto(common_local_url($action, $rargs));
|
||||
|
||||
common_redirect(common_local_url('login'));
|
||||
}
|
||||
|
||||
$action_class = ucfirst($action).'Action';
|
||||
|
||||
if (!class_exists($action_class)) {
|
||||
// TRANS: Error message displayed when trying to perform an undefined action.
|
||||
throw new ClientException(_('Unknown action'), 404);
|
||||
}
|
||||
|
||||
call_user_func("$action_class::run", $args);
|
||||
}
|
||||
|
||||
main();
|
||||
|
||||
// XXX: cleanup exit() calls or add an exit handler so
|
||||
// this always gets called
|
||||
|
||||
Event::handle('CleanupPlugin');
|
417
install.php
|
@ -1,417 +0,0 @@
|
|||
<?php
|
||||
/**
|
||||
* StatusNet - the distributed open-source microblogging tool
|
||||
* Copyright (C) 2009-2010, StatusNet, Inc.
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Affero General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Affero General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
* @category Installation
|
||||
* @package Installation
|
||||
*
|
||||
* @author Adrian Lang <mail@adrianlang.de>
|
||||
* @author Brenda Wallace <shiny@cpan.org>
|
||||
* @author Brett Taylor <brett@webfroot.co.nz>
|
||||
* @author Brion Vibber <brion@pobox.com>
|
||||
* @author CiaranG <ciaran@ciarang.com>
|
||||
* @author Craig Andrews <candrews@integralblue.com>
|
||||
* @author Eric Helgeson <helfire@Erics-MBP.local>
|
||||
* @author Evan Prodromou <evan@status.net>
|
||||
* @author Mikael Nordfeldth <mmn@hethane.se>
|
||||
* @author Robin Millette <millette@controlyourself.ca>
|
||||
* @author Sarven Capadisli <csarven@status.net>
|
||||
* @author Tom Adams <tom@holizz.com>
|
||||
* @author Zach Copley <zach@status.net>
|
||||
* @copyright 2009 Free Software Foundation, Inc http://www.fsf.org
|
||||
* @license GNU Affero General Public License http://www.gnu.org/licenses/
|
||||
* @version 0.9.x
|
||||
* @link http://status.net
|
||||
*/
|
||||
|
||||
define('INSTALLDIR', __DIR__);
|
||||
|
||||
require INSTALLDIR . '/lib/installer.php';
|
||||
|
||||
/**
|
||||
* Helper class for building form
|
||||
*/
|
||||
class Posted {
|
||||
/**
|
||||
* HTML-friendly escaped string for the POST param of given name, or empty.
|
||||
* @param string $name
|
||||
* @return string
|
||||
*/
|
||||
function value($name)
|
||||
{
|
||||
return htmlspecialchars($this->string($name));
|
||||
}
|
||||
|
||||
/**
|
||||
* The given POST parameter value, forced to a string.
|
||||
* Missing value will give ''.
|
||||
*
|
||||
* @param string $name
|
||||
* @return string
|
||||
*/
|
||||
function string($name)
|
||||
{
|
||||
return strval($this->raw($name));
|
||||
}
|
||||
|
||||
/**
|
||||
* The given POST parameter value, in its original form.
|
||||
* Magic quotes are stripped, if provided.
|
||||
* Missing value will give null.
|
||||
*
|
||||
* @param string $name
|
||||
* @return mixed
|
||||
*/
|
||||
function raw($name)
|
||||
{
|
||||
if (isset($_POST[$name])) {
|
||||
return $this->dequote($_POST[$name]);
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* If necessary, strip magic quotes from the given value.
|
||||
*
|
||||
* @param mixed $val
|
||||
* @return mixed
|
||||
*/
|
||||
function dequote($val)
|
||||
{
|
||||
if (get_magic_quotes_gpc()) {
|
||||
if (is_string($val)) {
|
||||
return stripslashes($val);
|
||||
} else if (is_array($val)) {
|
||||
return array_map(array($this, 'dequote'), $val);
|
||||
}
|
||||
}
|
||||
return $val;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Web-based installer: provides a form and such.
|
||||
*/
|
||||
class WebInstaller extends Installer
|
||||
{
|
||||
/**
|
||||
* the actual installation.
|
||||
* If call libraries are present, then install
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
function main()
|
||||
{
|
||||
if (!$this->checkPrereqs()) {
|
||||
$this->warning(_('Please fix the above stated problems and refresh this page to continue installing.'));
|
||||
return;
|
||||
}
|
||||
|
||||
if ($_SERVER['REQUEST_METHOD'] == 'POST') {
|
||||
$this->handlePost();
|
||||
} else {
|
||||
$this->showForm();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Web implementation of warning output
|
||||
*/
|
||||
function warning($message, $submessage='')
|
||||
{
|
||||
print "<p class=\"error\">$message</p>\n";
|
||||
if ($submessage != '') {
|
||||
print "<p>$submessage</p>\n";
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Web implementation of status output
|
||||
*/
|
||||
function updateStatus($status, $error=false)
|
||||
{
|
||||
echo '<li' . ($error ? ' class="error"': '' ) . ">$status</li>";
|
||||
}
|
||||
|
||||
/**
|
||||
* Show the web form!
|
||||
*/
|
||||
function showForm()
|
||||
{
|
||||
global $dbModules;
|
||||
$post = new Posted();
|
||||
$dbRadios = '';
|
||||
$dbtype = $post->raw('dbtype');
|
||||
foreach (self::$dbModules as $type => $info) {
|
||||
if ($this->checkExtension($info['check_module'])) {
|
||||
if ($dbtype == null || $dbtype == $type) {
|
||||
$checked = 'checked="checked" ';
|
||||
$dbtype = $type; // if we didn't have one checked, hit the first
|
||||
} else {
|
||||
$checked = '';
|
||||
}
|
||||
$dbRadios .= sprintf('<input type="radio" name="dbtype" id="dbtype-%1$s" value="%1$s" %2$s/>%3$s<br />',
|
||||
htmlspecialchars($type), $checked,
|
||||
htmlspecialchars($info['name']));
|
||||
}
|
||||
}
|
||||
|
||||
$ssl = array('always'=>null, 'never'=>null);
|
||||
if (!empty($_SERVER['HTTPS'])) {
|
||||
$ssl['always'] = 'checked="checked"';
|
||||
} else {
|
||||
$ssl['never'] = 'checked="checked"';
|
||||
}
|
||||
|
||||
echo<<<E_O_T
|
||||
<form method="post" action="install.php" class="form_settings" id="form_install">
|
||||
<fieldset>
|
||||
<fieldset id="settings_site">
|
||||
<legend>Site settings</legend>
|
||||
<ul class="form_data">
|
||||
<li>
|
||||
<label for="sitename">Site name</label>
|
||||
<input type="text" id="sitename" name="sitename" value="{$post->value('sitename')}" />
|
||||
<p class="form_guide">The name of your site</p>
|
||||
</li>
|
||||
<li>
|
||||
<label for="fancy-enable">Fancy URLs</label>
|
||||
<input type="radio" name="fancy" id="fancy-enable" value="enable" checked='checked' /> enable<br />
|
||||
<input type="radio" name="fancy" id="fancy-disable" value="" /> disable<br />
|
||||
<p class="form_guide" id='fancy-form_guide'>Enable fancy (pretty) URLs. Auto-detection failed, it depends on Javascript.</p>
|
||||
</li>
|
||||
<li>
|
||||
<label for="ssl">Server SSL</label>
|
||||
<input type="radio" name="ssl" id="ssl-always" value="always" {$ssl['always']} /> enable<br />
|
||||
<input type="radio" name="ssl" id="ssl-never" value="never" {$ssl['never']} /> disable<br />
|
||||
<p class="form_guide" id="ssl-form_guide">Enabling SSL (https://) requires extra webserver configuration and certificate generation not offered by this installation.</p>
|
||||
</li>
|
||||
</ul>
|
||||
</fieldset>
|
||||
|
||||
<fieldset id="settings_db">
|
||||
<legend>Database settings</legend>
|
||||
<ul class="form_data">
|
||||
<li>
|
||||
<label for="host">Hostname</label>
|
||||
<input type="text" id="host" name="host" value="{$post->value('host')}" />
|
||||
<p class="form_guide">Database hostname</p>
|
||||
</li>
|
||||
<li>
|
||||
<label for="dbtype">Type</label>
|
||||
{$dbRadios}
|
||||
<p class="form_guide">Database type</p>
|
||||
</li>
|
||||
<li>
|
||||
<label for="database">Name</label>
|
||||
<input type="text" id="database" name="database" value="{$post->value('database')}" />
|
||||
<p class="form_guide">Database name</p>
|
||||
</li>
|
||||
<li>
|
||||
<label for="dbusername">DB username</label>
|
||||
<input type="text" id="dbusername" name="dbusername" value="{$post->value('dbusername')}" />
|
||||
<p class="form_guide">Database username</p>
|
||||
</li>
|
||||
<li>
|
||||
<label for="dbpassword">DB password</label>
|
||||
<input type="password" id="dbpassword" name="dbpassword" value="{$post->value('dbpassword')}" />
|
||||
<p class="form_guide">Database password (optional)</p>
|
||||
</li>
|
||||
</ul>
|
||||
</fieldset>
|
||||
|
||||
<fieldset id="settings_admin">
|
||||
<legend>Administrator settings</legend>
|
||||
<ul class="form_data">
|
||||
<li>
|
||||
<label for="admin_nickname">Administrator nickname</label>
|
||||
<input type="text" id="admin_nickname" name="admin_nickname" value="{$post->value('admin_nickname')}" />
|
||||
<p class="form_guide">Nickname for the initial user (administrator)</p>
|
||||
</li>
|
||||
<li>
|
||||
<label for="admin_password">Administrator password</label>
|
||||
<input type="password" id="admin_password" name="admin_password" value="{$post->value('admin_password')}" />
|
||||
<p class="form_guide">Password for the initial user (administrator)</p>
|
||||
</li>
|
||||
<li>
|
||||
<label for="admin_password2">Confirm password</label>
|
||||
<input type="password" id="admin_password2" name="admin_password2" value="{$post->value('admin_password2')}" />
|
||||
</li>
|
||||
<li>
|
||||
<label for="admin_email">Administrator e-mail</label>
|
||||
<input id="admin_email" name="admin_email" value="{$post->value('admin_email')}" />
|
||||
<p class="form_guide">Optional email address for the initial user (administrator)</p>
|
||||
</li>
|
||||
</ul>
|
||||
</fieldset>
|
||||
<fieldset id="settings_profile">
|
||||
<legend>Site profile</legend>
|
||||
<ul class="form_data">
|
||||
<li>
|
||||
<label for="site_profile">Type of site</label>
|
||||
<select id="site_profile" name="site_profile">
|
||||
<option value="community">Community</option>
|
||||
<option value="public">Public (open registration)</option>
|
||||
<option value="singleuser">Single User</option>
|
||||
<option value="private">Private (no federation)</option>
|
||||
</select>
|
||||
<p class="form_guide">Initial access settings for your site</p>
|
||||
</li>
|
||||
</ul>
|
||||
</fieldset>
|
||||
<input type="submit" name="submit" class="submit" value="Submit" />
|
||||
</fieldset>
|
||||
</form>
|
||||
|
||||
E_O_T;
|
||||
}
|
||||
|
||||
/**
|
||||
* Handle a POST submission... if we have valid input, start the install!
|
||||
* Otherwise shows the form along with any error messages.
|
||||
*/
|
||||
function handlePost()
|
||||
{
|
||||
echo <<<STR
|
||||
<dl class="system_notice">
|
||||
<dt>Page notice</dt>
|
||||
<dd>
|
||||
<ul>
|
||||
STR;
|
||||
$this->validated = $this->prepare();
|
||||
if ($this->validated) {
|
||||
$this->doInstall();
|
||||
}
|
||||
echo <<<STR
|
||||
</ul>
|
||||
</dd>
|
||||
</dl>
|
||||
STR;
|
||||
if (!$this->validated) {
|
||||
$this->showForm();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Read and validate input data.
|
||||
* May output side effects.
|
||||
*
|
||||
* @return boolean success
|
||||
*/
|
||||
function prepare()
|
||||
{
|
||||
$post = new Posted();
|
||||
$this->host = $post->string('host');
|
||||
$this->dbtype = $post->string('dbtype');
|
||||
$this->database = $post->string('database');
|
||||
$this->username = $post->string('dbusername');
|
||||
$this->password = $post->string('dbpassword');
|
||||
$this->sitename = $post->string('sitename');
|
||||
$this->fancy = (bool)$post->string('fancy');
|
||||
|
||||
$this->adminNick = strtolower($post->string('admin_nickname'));
|
||||
$this->adminPass = $post->string('admin_password');
|
||||
$adminPass2 = $post->string('admin_password2');
|
||||
$this->adminEmail = $post->string('admin_email');
|
||||
|
||||
$this->siteProfile = $post->string('site_profile');
|
||||
|
||||
$this->ssl = $post->string('ssl');
|
||||
|
||||
$this->server = $_SERVER['HTTP_HOST'];
|
||||
$this->path = substr(dirname($_SERVER['PHP_SELF']), 1);
|
||||
|
||||
$fail = false;
|
||||
if (!$this->validateDb()) {
|
||||
$fail = true;
|
||||
}
|
||||
|
||||
if (!$this->validateAdmin()) {
|
||||
$fail = true;
|
||||
}
|
||||
|
||||
if ($this->adminPass != $adminPass2) {
|
||||
$this->updateStatus("Administrator passwords do not match. Did you mistype?", true);
|
||||
$fail = true;
|
||||
}
|
||||
|
||||
if (!in_array($this->ssl, array('never', 'always'))) {
|
||||
$this->updateStatus("Bad value for server SSL enabling.");
|
||||
$fail = true;
|
||||
}
|
||||
|
||||
if (!$this->validateSiteProfile()) {
|
||||
$fail = true;
|
||||
}
|
||||
|
||||
return !$fail;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
?>
|
||||
<?php echo"<?"; ?> xml version="1.0" encoding="UTF-8" <?php echo "?>"; ?>
|
||||
<!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" xml:lang="en_US" lang="en_US">
|
||||
<head>
|
||||
<title>Install GNU social</title>
|
||||
<link rel="shortcut icon" href="favicon.ico"/>
|
||||
<link rel="stylesheet" type="text/css" href="theme/base/css/display.css" media="screen, projection, tv"/>
|
||||
<link rel="stylesheet" type="text/css" href="theme/neo/css/display.css" media="screen, projection, tv"/>
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
|
||||
<script src="js/extlib/jquery.js"></script>
|
||||
<script src="js/install.js"></script>
|
||||
</head>
|
||||
<body id="install">
|
||||
<div id="wrap">
|
||||
<div id="header">
|
||||
<address id="site_contact" class="h-card">
|
||||
<a class="u-url p-name home bookmark org" href=".">
|
||||
<img class="logo u-photo" src="theme/neo/logo.png" alt="GNU social"/>
|
||||
GNU social
|
||||
</a>
|
||||
</address>
|
||||
<div id="site_nav_global_primary"></div>
|
||||
</div>
|
||||
<div id="core">
|
||||
<div id="aside_primary_wrapper">
|
||||
<div id="content_wrapper">
|
||||
<div id="site_nav_local_views_wrapper">
|
||||
<div id="site_nav_local_views"></div>
|
||||
|
||||
<div id="content">
|
||||
<div id="content_inner">
|
||||
<h1>Install GNU social</h1>
|
||||
<?php
|
||||
$installer = new WebInstaller();
|
||||
$installer->main();
|
||||
?>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div id="aside_primary" class="aside"></div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div id="footer"></div>
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
|
@ -1,23 +0,0 @@
|
|||
$(function() {
|
||||
|
||||
function toggleIncomingOptions() {
|
||||
var enabled = $('#emailpost').prop('checked', true);
|
||||
if (enabled) {
|
||||
// Note: button style currently does not respond to disabled in our main themes.
|
||||
// Graying out the whole section with a 50% transparency will do for now. :)
|
||||
// @todo: add a general 'disabled' class style to the base themes.
|
||||
$('#emailincoming').css('opacity', '')
|
||||
.find('input').prop('disabled', false);
|
||||
} else {
|
||||
$('#emailincoming').css('opacity', '0.5')
|
||||
.find('input').prop('disabled', true);
|
||||
}
|
||||
}
|
||||
|
||||
toggleIncomingOptions();
|
||||
|
||||
$('#emailpost').click(function() {
|
||||
toggleIncomingOptions();
|
||||
});
|
||||
|
||||
});
|
|
@ -1 +0,0 @@
|
|||
<html><body>You are being <a href="https://raw.github.com/tapmodo/Jcrop/master/css/Jcrop.gif">redirected</a>.</body></html>
|
|
@ -1,167 +0,0 @@
|
|||
/* jquery.Jcrop.css v0.9.12 - MIT License */
|
||||
/*
|
||||
The outer-most container in a typical Jcrop instance
|
||||
If you are having difficulty with formatting related to styles
|
||||
on a parent element, place any fixes here or in a like selector
|
||||
|
||||
You can also style this element if you want to add a border, etc
|
||||
A better method for styling can be seen below with .jcrop-light
|
||||
(Add a class to the holder and style elements for that extended class)
|
||||
*/
|
||||
.jcrop-holder {
|
||||
direction: ltr;
|
||||
text-align: left;
|
||||
/* IE10 touch compatibility */
|
||||
-ms-touch-action: none;
|
||||
}
|
||||
/* Selection Border */
|
||||
.jcrop-vline,
|
||||
.jcrop-hline {
|
||||
background: #ffffff url("Jcrop.gif");
|
||||
font-size: 0;
|
||||
position: absolute;
|
||||
}
|
||||
.jcrop-vline {
|
||||
height: 100%;
|
||||
width: 1px !important;
|
||||
}
|
||||
.jcrop-vline.right {
|
||||
right: 0;
|
||||
}
|
||||
.jcrop-hline {
|
||||
height: 1px !important;
|
||||
width: 100%;
|
||||
}
|
||||
.jcrop-hline.bottom {
|
||||
bottom: 0;
|
||||
}
|
||||
/* Invisible click targets */
|
||||
.jcrop-tracker {
|
||||
height: 100%;
|
||||
width: 100%;
|
||||
/* "turn off" link highlight */
|
||||
-webkit-tap-highlight-color: transparent;
|
||||
/* disable callout, image save panel */
|
||||
-webkit-touch-callout: none;
|
||||
/* disable cut copy paste */
|
||||
-webkit-user-select: none;
|
||||
}
|
||||
/* Selection Handles */
|
||||
.jcrop-handle {
|
||||
background-color: #333333;
|
||||
border: 1px #eeeeee solid;
|
||||
width: 7px;
|
||||
height: 7px;
|
||||
font-size: 1px;
|
||||
}
|
||||
.jcrop-handle.ord-n {
|
||||
left: 50%;
|
||||
margin-left: -4px;
|
||||
margin-top: -4px;
|
||||
top: 0;
|
||||
}
|
||||
.jcrop-handle.ord-s {
|
||||
bottom: 0;
|
||||
left: 50%;
|
||||
margin-bottom: -4px;
|
||||
margin-left: -4px;
|
||||
}
|
||||
.jcrop-handle.ord-e {
|
||||
margin-right: -4px;
|
||||
margin-top: -4px;
|
||||
right: 0;
|
||||
top: 50%;
|
||||
}
|
||||
.jcrop-handle.ord-w {
|
||||
left: 0;
|
||||
margin-left: -4px;
|
||||
margin-top: -4px;
|
||||
top: 50%;
|
||||
}
|
||||
.jcrop-handle.ord-nw {
|
||||
left: 0;
|
||||
margin-left: -4px;
|
||||
margin-top: -4px;
|
||||
top: 0;
|
||||
}
|
||||
.jcrop-handle.ord-ne {
|
||||
margin-right: -4px;
|
||||
margin-top: -4px;
|
||||
right: 0;
|
||||
top: 0;
|
||||
}
|
||||
.jcrop-handle.ord-se {
|
||||
bottom: 0;
|
||||
margin-bottom: -4px;
|
||||
margin-right: -4px;
|
||||
right: 0;
|
||||
}
|
||||
.jcrop-handle.ord-sw {
|
||||
bottom: 0;
|
||||
left: 0;
|
||||
margin-bottom: -4px;
|
||||
margin-left: -4px;
|
||||
}
|
||||
/* Dragbars */
|
||||
.jcrop-dragbar.ord-n,
|
||||
.jcrop-dragbar.ord-s {
|
||||
height: 7px;
|
||||
width: 100%;
|
||||
}
|
||||
.jcrop-dragbar.ord-e,
|
||||
.jcrop-dragbar.ord-w {
|
||||
height: 100%;
|
||||
width: 7px;
|
||||
}
|
||||
.jcrop-dragbar.ord-n {
|
||||
margin-top: -4px;
|
||||
}
|
||||
.jcrop-dragbar.ord-s {
|
||||
bottom: 0;
|
||||
margin-bottom: -4px;
|
||||
}
|
||||
.jcrop-dragbar.ord-e {
|
||||
margin-right: -4px;
|
||||
right: 0;
|
||||
}
|
||||
.jcrop-dragbar.ord-w {
|
||||
margin-left: -4px;
|
||||
}
|
||||
/* The "jcrop-light" class/extension */
|
||||
.jcrop-light .jcrop-vline,
|
||||
.jcrop-light .jcrop-hline {
|
||||
background: #ffffff;
|
||||
filter: alpha(opacity=70) !important;
|
||||
opacity: .70!important;
|
||||
}
|
||||
.jcrop-light .jcrop-handle {
|
||||
-moz-border-radius: 3px;
|
||||
-webkit-border-radius: 3px;
|
||||
background-color: #000000;
|
||||
border-color: #ffffff;
|
||||
border-radius: 3px;
|
||||
}
|
||||
/* The "jcrop-dark" class/extension */
|
||||
.jcrop-dark .jcrop-vline,
|
||||
.jcrop-dark .jcrop-hline {
|
||||
background: #000000;
|
||||
filter: alpha(opacity=70) !important;
|
||||
opacity: 0.7 !important;
|
||||
}
|
||||
.jcrop-dark .jcrop-handle {
|
||||
-moz-border-radius: 3px;
|
||||
-webkit-border-radius: 3px;
|
||||
background-color: #ffffff;
|
||||
border-color: #000000;
|
||||
border-radius: 3px;
|
||||
}
|
||||
/* Simple macro to turn off the antlines */
|
||||
.solid-line .jcrop-vline,
|
||||
.solid-line .jcrop-hline {
|
||||
background: #ffffff;
|
||||
}
|
||||
/* Fix for twitter bootstrap et al. */
|
||||
.jcrop-holder img,
|
||||
img.jcrop-preview {
|
||||
max-width: none;
|
||||
}
|
29
js/extlib/jquery-jcrop/css/jcrop.min.css
vendored
|
@ -1,29 +0,0 @@
|
|||
/* jquery.Jcrop.min.css v0.9.12 (build:20130521) */
|
||||
.jcrop-holder{-ms-touch-action:none;direction:ltr;text-align:left;}
|
||||
.jcrop-vline,.jcrop-hline{background:#FFF url(Jcrop.gif);font-size:0;position:absolute;}
|
||||
.jcrop-vline{height:100%;width:1px!important;}
|
||||
.jcrop-vline.right{right:0;}
|
||||
.jcrop-hline{height:1px!important;width:100%;}
|
||||
.jcrop-hline.bottom{bottom:0;}
|
||||
.jcrop-tracker{-webkit-tap-highlight-color:transparent;-webkit-touch-callout:none;-webkit-user-select:none;height:100%;width:100%;}
|
||||
.jcrop-handle{background-color:#333;border:1px #EEE solid;font-size:1px;height:7px;width:7px;}
|
||||
.jcrop-handle.ord-n{left:50%;margin-left:-4px;margin-top:-4px;top:0;}
|
||||
.jcrop-handle.ord-s{bottom:0;left:50%;margin-bottom:-4px;margin-left:-4px;}
|
||||
.jcrop-handle.ord-e{margin-right:-4px;margin-top:-4px;right:0;top:50%;}
|
||||
.jcrop-handle.ord-w{left:0;margin-left:-4px;margin-top:-4px;top:50%;}
|
||||
.jcrop-handle.ord-nw{left:0;margin-left:-4px;margin-top:-4px;top:0;}
|
||||
.jcrop-handle.ord-ne{margin-right:-4px;margin-top:-4px;right:0;top:0;}
|
||||
.jcrop-handle.ord-se{bottom:0;margin-bottom:-4px;margin-right:-4px;right:0;}
|
||||
.jcrop-handle.ord-sw{bottom:0;left:0;margin-bottom:-4px;margin-left:-4px;}
|
||||
.jcrop-dragbar.ord-n,.jcrop-dragbar.ord-s{height:7px;width:100%;}
|
||||
.jcrop-dragbar.ord-e,.jcrop-dragbar.ord-w{height:100%;width:7px;}
|
||||
.jcrop-dragbar.ord-n{margin-top:-4px;}
|
||||
.jcrop-dragbar.ord-s{bottom:0;margin-bottom:-4px;}
|
||||
.jcrop-dragbar.ord-e{margin-right:-4px;right:0;}
|
||||
.jcrop-dragbar.ord-w{margin-left:-4px;}
|
||||
.jcrop-light .jcrop-vline,.jcrop-light .jcrop-hline{background:#FFF;filter:alpha(opacity=70)!important;opacity:.70!important;}
|
||||
.jcrop-light .jcrop-handle{-moz-border-radius:3px;-webkit-border-radius:3px;background-color:#000;border-color:#FFF;border-radius:3px;}
|
||||
.jcrop-dark .jcrop-vline,.jcrop-dark .jcrop-hline{background:#000;filter:alpha(opacity=70)!important;opacity:.7!important;}
|
||||
.jcrop-dark .jcrop-handle{-moz-border-radius:3px;-webkit-border-radius:3px;background-color:#FFF;border-color:#000;border-radius:3px;}
|
||||
.solid-line .jcrop-vline,.solid-line .jcrop-hline{background:#FFF;}
|
||||
.jcrop-holder img,img.jcrop-preview{max-width:none;}
|
1694
js/extlib/jquery-jcrop/jcrop.js
vendored
Before Width: | Height: | Size: 212 B |
Before Width: | Height: | Size: 208 B |
Before Width: | Height: | Size: 335 B |
Before Width: | Height: | Size: 207 B |
Before Width: | Height: | Size: 262 B |
Before Width: | Height: | Size: 262 B |
Before Width: | Height: | Size: 332 B |
Before Width: | Height: | Size: 280 B |
Before Width: | Height: | Size: 6.8 KiB |
Before Width: | Height: | Size: 4.4 KiB |
Before Width: | Height: | Size: 6.8 KiB |
Before Width: | Height: | Size: 6.8 KiB |
Before Width: | Height: | Size: 4.4 KiB |
1225
js/extlib/jquery-ui/css/smoothness/jquery-ui.css
vendored
16607
js/extlib/jquery-ui/jquery-ui.js
vendored
|
@ -1,117 +0,0 @@
|
|||
/*!
|
||||
* jQuery Cookie Plugin v1.4.1
|
||||
* https://github.com/carhartl/jquery-cookie
|
||||
*
|
||||
* Copyright 2013 Klaus Hartl
|
||||
* Released under the MIT license
|
||||
*/
|
||||
(function (factory) {
|
||||
if (typeof define === 'function' && define.amd) {
|
||||
// AMD
|
||||
define(['jquery'], factory);
|
||||
} else if (typeof exports === 'object') {
|
||||
// CommonJS
|
||||
factory(require('jquery'));
|
||||
} else {
|
||||
// Browser globals
|
||||
factory(jQuery);
|
||||
}
|
||||
}(function ($) {
|
||||
|
||||
var pluses = /\+/g;
|
||||
|
||||
function encode(s) {
|
||||
return config.raw ? s : encodeURIComponent(s);
|
||||
}
|
||||
|
||||
function decode(s) {
|
||||
return config.raw ? s : decodeURIComponent(s);
|
||||
}
|
||||
|
||||
function stringifyCookieValue(value) {
|
||||
return encode(config.json ? JSON.stringify(value) : String(value));
|
||||
}
|
||||
|
||||
function parseCookieValue(s) {
|
||||
if (s.indexOf('"') === 0) {
|
||||
// This is a quoted cookie as according to RFC2068, unescape...
|
||||
s = s.slice(1, -1).replace(/\\"/g, '"').replace(/\\\\/g, '\\');
|
||||
}
|
||||
|
||||
try {
|
||||
// Replace server-side written pluses with spaces.
|
||||
// If we can't decode the cookie, ignore it, it's unusable.
|
||||
// If we can't parse the cookie, ignore it, it's unusable.
|
||||
s = decodeURIComponent(s.replace(pluses, ' '));
|
||||
return config.json ? JSON.parse(s) : s;
|
||||
} catch(e) {}
|
||||
}
|
||||
|
||||
function read(s, converter) {
|
||||
var value = config.raw ? s : parseCookieValue(s);
|
||||
return $.isFunction(converter) ? converter(value) : value;
|
||||
}
|
||||
|
||||
var config = $.cookie = function (key, value, options) {
|
||||
|
||||
// Write
|
||||
|
||||
if (value !== undefined && !$.isFunction(value)) {
|
||||
options = $.extend({}, config.defaults, options);
|
||||
|
||||
if (typeof options.expires === 'number') {
|
||||
var days = options.expires, t = options.expires = new Date();
|
||||
t.setTime(+t + days * 864e+5);
|
||||
}
|
||||
|
||||
return (document.cookie = [
|
||||
encode(key), '=', stringifyCookieValue(value),
|
||||
options.expires ? '; expires=' + options.expires.toUTCString() : '', // use expires attribute, max-age is not supported by IE
|
||||
options.path ? '; path=' + options.path : '',
|
||||
options.domain ? '; domain=' + options.domain : '',
|
||||
options.secure ? '; secure' : ''
|
||||
].join(''));
|
||||
}
|
||||
|
||||
// Read
|
||||
|
||||
var result = key ? undefined : {};
|
||||
|
||||
// To prevent the for loop in the first place assign an empty array
|
||||
// in case there are no cookies at all. Also prevents odd result when
|
||||
// calling $.cookie().
|
||||
var cookies = document.cookie ? document.cookie.split('; ') : [];
|
||||
|
||||
for (var i = 0, l = cookies.length; i < l; i++) {
|
||||
var parts = cookies[i].split('=');
|
||||
var name = decode(parts.shift());
|
||||
var cookie = parts.join('=');
|
||||
|
||||
if (key && key === name) {
|
||||
// If second argument (value) is a function it's a converter...
|
||||
result = read(cookie, value);
|
||||
break;
|
||||
}
|
||||
|
||||
// Prevent storing a cookie that we couldn't decode.
|
||||
if (!key && (cookie = read(cookie)) !== undefined) {
|
||||
result[name] = cookie;
|
||||
}
|
||||
}
|
||||
|
||||
return result;
|
||||
};
|
||||
|
||||
config.defaults = {};
|
||||
|
||||
$.removeCookie = function (key, options) {
|
||||
if ($.cookie(key) === undefined) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// Must not alter options, thus extending a fresh object...
|
||||
$.cookie(key, '', $.extend({}, options, { expires: -1 }));
|
||||
return !$.cookie(key);
|
||||
};
|
||||
|
||||
}));
|
9209
js/extlib/jquery.js
vendored
|
@ -1,367 +0,0 @@
|
|||
// identica badge -- updated to work with the native API, 12-4-2008
|
||||
// Modified to point to Identi.ca, 2-20-2009 by Zach
|
||||
// Modified for XHTML, 27-9-2009 by Will Daniels
|
||||
// (see http://willdaniels.co.uk/blog/tech-stuff/26-identica-badge-xhtml)
|
||||
// copyright Kent Brewster 2008
|
||||
// see http://kentbrewster.com/identica-badge for info
|
||||
|
||||
function createHTMLElement(tagName) {
|
||||
if(document.createElementNS)
|
||||
var elem = document.createElementNS("http://www.w3.org/1999/xhtml", tagName);
|
||||
else
|
||||
var elem = document.createElement(tagName);
|
||||
|
||||
return elem;
|
||||
}
|
||||
|
||||
function isNumeric(value) {
|
||||
if (value == null || !value.toString().match(/^[-]?\d*\.?\d*$/)) return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
function markupPost(raw, server) {
|
||||
var start = 0; var p = createHTMLElement('p');
|
||||
|
||||
raw.replace(/((http|https):\/\/|\!|@|#)(([\w_]+)?[^\s]*)/g,
|
||||
function(sub, type, scheme, url, word, offset, full)
|
||||
{
|
||||
if(!scheme && !word) return; // just punctuation
|
||||
var label = ''; var href = '';
|
||||
var pretext = full.substr(start, offset - start);
|
||||
|
||||
moniker = word.split('_'); // behaviour with underscores differs
|
||||
if(type == '#') moniker = moniker.join('');
|
||||
else word = moniker = moniker[0].toLowerCase();
|
||||
|
||||
switch(type) {
|
||||
case 'http://': case 'https://': // html links
|
||||
href = scheme + '://' + url; break;
|
||||
case '@': // link users
|
||||
href = 'http://' + server + '/' + moniker; break;
|
||||
case '!': // link groups
|
||||
href = 'http://' + server + '/group/' + moniker; break;
|
||||
case '#': // link tags
|
||||
href = 'http://' + server + '/tag/' + moniker; break;
|
||||
default: // bad call (just reset position for text)
|
||||
start = offset;
|
||||
}
|
||||
if(scheme) { // only urls will have scheme
|
||||
label = sub; start = offset + sub.length;
|
||||
} else {
|
||||
label = word; pretext += type;
|
||||
start = offset + word.length + type.length;
|
||||
}
|
||||
p.appendChild(document.createTextNode(pretext));
|
||||
|
||||
var link = createHTMLElement('a');
|
||||
link.appendChild(document.createTextNode(label));
|
||||
link.href = href; link.target = '_statusnet';
|
||||
p.appendChild(link);
|
||||
});
|
||||
|
||||
if(start != raw.length) {
|
||||
endtext = raw.substr(start);
|
||||
p.appendChild(document.createTextNode(endtext));
|
||||
}
|
||||
return p;
|
||||
}
|
||||
(function() {
|
||||
var trueName = '';
|
||||
for (var i = 0; i < 16; i++) {
|
||||
trueName += String.fromCharCode(Math.floor(Math.random() * 26) + 97);
|
||||
}
|
||||
window[trueName] = {};
|
||||
var $ = window[trueName];
|
||||
$.f = function() {
|
||||
return {
|
||||
runFunction : [],
|
||||
init : function(target) {
|
||||
var theScripts = document.getElementsByTagName('script');
|
||||
for (var i = 0; i < theScripts.length; i++) {
|
||||
if (theScripts[i].src.match(target)) {
|
||||
$.a = {};
|
||||
if (theScripts[i].innerHTML) {
|
||||
$.a = $.f.parseJson(theScripts[i].innerHTML);
|
||||
}
|
||||
if ($.a.err) {
|
||||
alert('bad json!');
|
||||
}
|
||||
$.f.loadDefaults();
|
||||
$.f.buildStructure();
|
||||
$.f.buildPresentation();
|
||||
theScripts[i].parentNode.insertBefore($.s, theScripts[i]);
|
||||
theScripts[i].parentNode.removeChild(theScripts[i]);
|
||||
break;
|
||||
}
|
||||
}
|
||||
},
|
||||
parseJson : function(json) {
|
||||
this.parseJson.data = json;
|
||||
if ( typeof json !== 'string') {
|
||||
return {"err":"trying to parse a non-string JSON object"};
|
||||
}
|
||||
try {
|
||||
var f = Function(['var document,top,self,window,parent,Number,Date,Object,Function,',
|
||||
'Array,String,Math,RegExp,Image,ActiveXObject;',
|
||||
'return (' , json.replace(/<\!--.+-->/gim,'').replace(/\bfunction\b/g,'function­') , ');'].join(''));
|
||||
return f();
|
||||
} catch (e) {
|
||||
return {"err":"trouble parsing JSON object"};
|
||||
}
|
||||
},
|
||||
loadDefaults : function() {
|
||||
$.d = {
|
||||
"user":"7000",
|
||||
"headerText" : "",
|
||||
"height" : 350,
|
||||
"width" : 300,
|
||||
"background" : "#193441",
|
||||
"border" : "1px solid black",
|
||||
"userFontSize" : "inherit",
|
||||
"userColor" : "inherit",
|
||||
"headerBackground" : "transparent",
|
||||
"headerColor" : "white",
|
||||
"evenBackground" : "#fff",
|
||||
"oddBackground" : "#eee",
|
||||
"thumbnailBorder" : "1px solid black",
|
||||
"thumbnailSize" : 24,
|
||||
"padding" : 3,
|
||||
"server" : "identi.ca"
|
||||
};
|
||||
for (var k in $.d) { if ($.a[k] === undefined) { $.a[k] = $.d[k]; } }
|
||||
// fix inout units
|
||||
if(isNumeric($.a.width)) {
|
||||
$.a.innerWidth = ($.a.width - 22) + 'px'; $.a.width += 'px';
|
||||
} else {
|
||||
$.a.innerWidth = 'auto';
|
||||
}
|
||||
if(isNumeric($.a.height)) $.a.height += 'px';
|
||||
},
|
||||
buildPresentation : function () {
|
||||
var setZoom = ''; if(navigator.appName == 'Microsoft Internet Explorer') setZoom = 'zoom:1;';
|
||||
var ns = createHTMLElement('style');
|
||||
document.getElementsByTagName('head')[0].appendChild(ns);
|
||||
if (!window.createPopup) {
|
||||
ns.appendChild(document.createTextNode(''));
|
||||
ns.setAttribute("type", "text/css");
|
||||
}
|
||||
var s = document.styleSheets[document.styleSheets.length - 1];
|
||||
var rules = {
|
||||
"" : "{margin:0px;padding:0px;width:" + $.a.width + ";background:" + $.a.background + ";border:" + $.a.border + ";font:87%/1.2em tahoma, veranda, arial, helvetica, clean, sans-serif;}",
|
||||
"a" : "{cursor:pointer;text-decoration:none;}",
|
||||
"a:hover" : "{text-decoration:underline;}",
|
||||
".cite" : "{" + setZoom + "font-weight:bold;margin:0px 0px 0px 4px;padding:0px;display:block;font-style:normal;line-height:" + ($.a.thumbnailSize/2) + "px;vertical-align:middle;}",
|
||||
".cite a" : "{color:#C15D42;}",
|
||||
".date":"{margin:0px 0px 0px 4px;padding:0px;display:block;font-style:normal;line-height:" + ($.a.thumbnailSize/2) + "px;vertical-align:middle;}",
|
||||
".date:after" : "{clear:both;content:\".\"; display:block;height:0px;visibility:hidden;}",
|
||||
".date a" : "{color:#676;}",
|
||||
"h3" : "{margin:0px;padding:" + $.a.padding + "px;font-weight:bold;background:" + $.a.headerBackground + " url('http://" + $.a.server + "/favicon.ico') " + $.a.padding + "px 50% no-repeat;padding-left:" + ($.a.padding + 20) + "px;}",
|
||||
"h3.loading" : "{background-image:url('http://l.yimg.com/us.yimg.com/i/us/my/mw/anim_loading_sm.gif');}",
|
||||
"h3 a" : "{font-size:92%; color:" + $.a.headerColor + ";}",
|
||||
"h4" : "{font-weight:normal;background:" + $.a.headerBackground + ";text-align:right;margin:0px;padding:" + $.a.padding + "px;}",
|
||||
"h4 a" : "{font-size:92%; color:" + $.a.headerColor + ";}",
|
||||
"img":"{float:left;height:" + $.a.thumbnailSize + "px;width:" + $.a.thumbnailSize + "px;border:" + $.a.thumbnailBorder + ";margin-right:" + $.a.padding + "px;}",
|
||||
"p" : "{margin:2px 0px 0px 0px;padding:0px;width:" + $.a.innerWidth + ";overflow:hidden;line-height:normal;}",
|
||||
"p a" : "{color:#C15D42;}",
|
||||
"ul":"{margin:0px; padding:0px; height:" + $.a.height + ";width:" + $.a.innerWidth + ";overflow:auto;}",
|
||||
"ul li":"{background:" + $.a.evenBackground + ";margin:0px;padding:" + $.a.padding + "px;list-style:none;width:auto;overflow:hidden;border-bottom:1px solid #D8E2D7;}",
|
||||
"ul li:hover":"{background:#f3f8ea;}"
|
||||
};
|
||||
var ieRules = "";
|
||||