Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Comparing changes

Choose two branches to see what's changed or to start a new pull request. If you need to, you can also compare across forks.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also compare across forks.
base fork: marcqualie/hoard
base: d3621f6498
...
head fork: marcqualie/hoard
compare: 76da596786
Checking mergeability… Don't worry, you can still create the pull request.
  • 3 commits
  • 6 files changed
  • 0 commit comments
  • 1 contributor
View
4 .htaccess
@@ -0,0 +1,4 @@
+RewriteEngine on
+SetEnv ORG_DOC_ROOT /server
+RewriteCond %{REQUEST_URI} !/server/
+RewriteRule .* /server/$0 [L]
View
6 README.md
@@ -6,10 +6,8 @@ Storage Engine for Event based Data
Console:
php ./install/shell.php \
- --mongodburi=mongodb://admin:admin@127.0.0.1:27017/hoard \
- --docroot=/path/to/install \
- --email=admin@example.com \
- --deleteinstall=true
+ mongodburi=mongodb://user:password@127.0.0.1:27017/hoard \
+ admin=admin@example.com:password
Web (Coming Soon):
View
6 index.php
@@ -1,9 +1,9 @@
<?php
/**
- * Root Redirect
+ * Handler for invalid Server Setup
*
- * This file is only here incase Hoard is installed directly inside a sub folder
+ * This file should only display if there is a problem with .htaccess
*/
-header('Location: ' . str_replace('//', '/', $_SERVER['REQUEST_URI'] . '/server'));
+echo 'Please enable .htaccess on your server for Hoard to function correctly';
View
45 server/install/shell.php
@@ -9,6 +9,7 @@
*/
header('Content-Type: text/plain');
+date_default_timezone_set('UTC');
// Get params from Shell
parse_str(implode('&', array_slice($argv, 1)), $params);
@@ -25,41 +26,48 @@
}
if (!file_exists($docroot . '/router.php'))
{
- echo '[error] invalid docroot [' . $docroot . ']' . PHP_EOL;
+ echo '[Error] Invalid docroot [' . $docroot . ']' . PHP_EOL;
exit;
}
define('DOCROOT', $docroot);
echo 'docroot: ' . $docroot . PHP_EOL;
// Validate email data
-$email = $params['email'];
+$admin = $params['admin'];
+list($email, $password) = explode(':', $admin);
if (!$email)
{
$email = 'admin@' . ($_SERVER['SERVER_NAME'] ? $_SERVER['SERVER_NAME'] : 'example.com');
}
+if (!$password)
+{
+ $password = 'password';
+}
echo 'email: ' . $email . PHP_EOL;
// Get database info and test connection
-$mongodburi = 'mongodb://admin:admin@127.0.0.1:27017/hoard';
+$mongodburi = $params['mongodburi'];
+if (!$mongodburi)
+{
+ $mongodburi = 'mongodb://admin:admin@127.0.0.1:27017/hoard';
+}
echo 'mongodburi: ' . $mongodburi . PHP_EOL;
include DOCROOT . '/lib/mongox.php';
MongoX::init($mongodburi, array('connect' => true));
if (!MongoX::$connected)
{
- echo '[Error] Invalid Mongo Config';
+ echo '[Error] Invalid Mongo Config, cannot connect';
exit;
}
// Create config file from variables
$config_file = DOCROOT . '/config.php';
-if (file_exists($config_file))
+if (0 && file_exists($config_file))
{
- echo 'config file exists [' . $config_file . ']' . PHP_EOL;
+ echo 'config file exists, will overwrite' . PHP_EOL;
}
-else
-{
- $data = date('c');
- $content = <<< EOT
+$data = date('c');
+$content = <<< EOT
<?php
/**
@@ -70,34 +78,33 @@
\$config['email'] = '$email';
// Database
-\$config['mongo_uri'] = '$mongo_uri';
+\$config['mongo_uri'] = '$mongodburi';
// Access Control
\$config['allow_ips'] = array('*'); // allow global access by default
EOT;
- $fh = fopen($config_file, 'w');
- fwrite($fh, $content);
- fclose($fh);
- echo 'config file created [' . $config_file . ']' . PHP_EOL;
-}
+$fh = fopen($config_file, 'w');
+ fwrite($fh, $content);
+ fclose($fh);
+echo 'config file saved [' . $config_file . ']' . PHP_EOL;
// Create admin user in Mongo
$collection = MongoX::selectCollection('user');
$user = $collection->findOne(array('email' => $email));
if ($user['_id'])
{
- echo 'admin user exists' . PHP_EOL;
+ echo 'admin user (' . $email . ') already exists' . PHP_EOL;
}
else
{
$collection->ensureIndex(array('email' => 1), array('unique' => true));
include DOCROOT . '/lib/auth.php';
$token = uniqid();
- echo 'created admin user [email=' . $email . ', password=admin, token=' . $token . ']' . PHP_EOL;
+ echo 'created admin user [email=' . $email . ', password=' . $password . ', token=' . $token . ']' . PHP_EOL;
$collection->insert(array(
'email' => $email,
- 'password' => Auth::password('admin'),
+ 'password' => Auth::password($password),
'token' => $token,
'admin' => 1,
'created' => new MongoDate(),
View
2  server/lib/auth.php
@@ -12,6 +12,8 @@ class Auth
public static function init ()
{
+ self::$cookie = 'u' . crc32(self::$cookie . '.' . $_SERVER['HTTP_HOST']);
+
$cookie = $_COOKIE[self::$cookie];
if (!$cookie)
{
View
10 server/router.php
@@ -4,7 +4,7 @@
include dirname(__FILE__) . '/lib/core.php';
// Restrict IP
-if (!in_array($_SERVER['REMOTE_ADDR'], $config['allow_ips']))
+if (!in_array('*', $config['allow_ips']) && !in_array($_SERVER['REMOTE_ADDR'], $config['allow_ips']))
{
echo "Hoard is only available from your whitelisted IPs. Contact <a href='http://www.marcqualie.com/contact/'>Marc</a> for help";
exit;
@@ -17,14 +17,8 @@
Auth::init();
// Detect Page Method
-$request_uri_base = str_replace($_SERVER['DOCUMENT_ROOT'], '', DOCROOT);
+$request_uri_base = '';
$request_uri = str_replace($request_uri_base, '', $_SERVER['REQUEST_URI']);
-/*
-echo 'server: ' . $_SERVER['DOCUMENT_ROOT'] . '<br/>';
-echo 'doc: ' . DOCROOT . '<br/>';
-echo 'base: ' . $request_uri_base . '<br/>';
-echo 'uri: ' . $request_uri . '<br/>';
-*/
define('URIBASE', $request_uri_base);
$request_method = strtolower($_SERVER['REQUEST_METHOD']);
list ($_uri, $_query) = explode('?', $request_uri);

No commit comments for this range

Something went wrong with that request. Please try again.