Skip to content

Commit

Permalink
Added the GPLv3 License
Browse files Browse the repository at this point in the history
* Made a few code styling changes (PEAR style), more changes to come...
* Added output buffering.
  • Loading branch information
Mayhem93 committed Dec 27, 2011
1 parent ae0b7b1 commit 667ae86
Show file tree
Hide file tree
Showing 13 changed files with 948 additions and 35 deletions.
674 changes: 674 additions & 0 deletions COPYING

Large diffs are not rendered by default.

24 changes: 24 additions & 0 deletions init.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,28 @@
<?php
/**
* Script that initializes everything.
*
* @author Răzvan Botea<utherr.ghujax@gmail.com>
* @license http://www.gnu.org/licenses/gpl.txt
* @copyright 2011-2012 Răzvan Botea
*
* PHP 5
*
* This file is part of Simblog.
*
* Simblog 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 3 of the License, or
* (at your option) any later version.
*
* Simblog 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 General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with Simblog. If not, see <http://www.gnu.org/licenses/>.
*/
error_reporting(E_ERROR | E_WARNING | E_PARSE);

// The "super global" of the web site
Expand Down
25 changes: 24 additions & 1 deletion initAjax.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,28 @@
<?php

/**
* Initializes resources for use with AJAX requests through lazy loading.
*
* @author Răzvan Botea<utherr.ghujax@gmail.com>
* @license http://www.gnu.org/licenses/gpl.txt
* @copyright 2011-2012 Răzvan Botea
*
* PHP 5
*
* This file is part of Simblog.
*
* Simblog 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 3 of the License, or
* (at your option) any later version.
*
* Simblog 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 General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with Simblog. If not, see <http://www.gnu.org/licenses/>.
*/
DEFINE('BLOG_PUBLIC_ROOT',getcwd());
DEFINE('BLOG_ROOT',realpath(BLOG_PUBLIC_ROOT.'/..'));
DEFINE('PLUGIN_DIR',realpath(BLOG_PUBLIC_ROOT.'/plugins'));
Expand Down
4 changes: 2 additions & 2 deletions internal/BlogEvent.class.php
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?php

class BlogEvent {
class BlogEvent
{
private $name;
private $callback;
private $params;
Expand Down
4 changes: 2 additions & 2 deletions internal/BlogEventHandler.php
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?php

class BlogEventHandler {
class BlogEventHandler
{
//private $event;
private $callback;

Expand Down
35 changes: 29 additions & 6 deletions internal/Blog_Plugin.class.php
Original file line number Diff line number Diff line change
@@ -1,11 +1,34 @@
<?php
/**
* The abstract class Blog_Plugin. All plugins must extend from this class.
*
* @author Răzvan Botea<utherr.ghujax@gmail.com>
* @license http://www.gnu.org/licenses/gpl.txt
* @copyright 2011-2012 Răzvan Botea
*
* PHP 5
*
* This file is part of Simblog.
*
* Simblog 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 3 of the License, or
* (at your option) any later version.
*
* Simblog 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 General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with Simblog. If not, see <http://www.gnu.org/licenses/>.
*/
DEFINE("PLUGIN_JS_BLOG_PAGES", 1);
DEFINE("PLUGIN_JS_ADMIN_PAGE", 2);
DEFINE("PLUGIN_JS_PLUGIN_PAGE", 4);

DEFINE("PLUGIN_JS_BLOG_PAGES");
DEFINE("PLUGIN_JS_ADMIN_PAGE");
DEFINE("PLUGIN_JS_PLUGIN_PAGE");

abstract class Blog_Plugin {

abstract class Blog_Plugin
{
private $type = "";
private $name = "";
private $description = "";
Expand Down
37 changes: 30 additions & 7 deletions internal/Plugin_Controller.class.php
Original file line number Diff line number Diff line change
@@ -1,15 +1,38 @@
<?php

class Plugin_Controller implements Iterator, ArrayAccess, Countable {

/**
* The plugin controller class which controls plugins.
*
* @author Răzvan Botea<utherr.ghujax@gmail.com>
* @license http://www.gnu.org/licenses/gpl.txt
* @copyright 2011-2012 Răzvan Botea
*
* PHP 5
*
* This file is part of Simblog.
*
* Simblog 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 3 of the License, or
* (at your option) any later version.
*
* Simblog 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 General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with Simblog. If not, see <http://www.gnu.org/licenses/>.
*/
class Plugin_Controller implements Iterator, ArrayAccess, Countable
{
private static $instance = null;
private $plugin_list = array();
private $plugin_keys = array();
private $position;

private function __construct() {
$this->position = 0;
$this->populatePluginList();
$this->_populatePluginList();
}

public function __clone() {}
Expand Down Expand Up @@ -53,11 +76,11 @@ public static function disablePlugin($name) {
* Populates the plugin list. Called in the constructor.
* @return void
*/
private function populatePluginList() {
private function _populatePluginList() {
$dir = new DirectoryIterator(PLUGIN_DIR);
foreach ($dir as $d)
if(!$d->isDot() && $d->isDir())
if($this->isValidPlugin((string)$d)) {
if($this->_isValidPlugin((string)$d)) {
$class = ucfirst((string)$d);
$this->plugin_list[(string)$d] = new $class;
$this->plugin_keys[] = (string)$d;
Expand All @@ -71,7 +94,7 @@ private function populatePluginList() {
* @return boolean - True if it's valid, false otherwise.
*/

private function isValidPlugin($name) {
private function _isValidPlugin($name) {
$file_name = PLUGIN_DIR.'/'.$name.'/plugin.conf';
$class_file = realpath(PLUGIN_DIR.'/'.$name.'/'.$name.'.class.php');
$valid = true;
Expand Down
26 changes: 25 additions & 1 deletion internal/Posts.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,29 @@
<?php

/**
* This file contains all the functions that handle blog content.
*
* @author Răzvan Botea<utherr.ghujax@gmail.com>
* @license http://www.gnu.org/licenses/gpl.txt
* @copyright 2011-2012 Răzvan Botea
*
* PHP 5
*
* This file is part of Simblog.
*
* Simblog 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 3 of the License, or
* (at your option) any later version.
*
* Simblog 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 General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with Simblog. If not, see <http://www.gnu.org/licenses/>.
*/

/**
* Adds a post.
* @param string $title Title
Expand Down
25 changes: 24 additions & 1 deletion internal/SPL_autoload.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,28 @@
<?php

/**
* SPL Autoload: autoloads class files.
*
* @author Răzvan Botea<utherr.ghujax@gmail.com>
* @license http://www.gnu.org/licenses/gpl.txt
* @copyright 2011-2012 Răzvan Botea
*
* PHP 5
*
* This file is part of Simblog.
*
* Simblog 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 3 of the License, or
* (at your option) any later version.
*
* Simblog 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 General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with Simblog. If not, see <http://www.gnu.org/licenses/>.
*/
spl_autoload_register("simblogAutoloadLibraries");
spl_autoload_register("simblogAutoloadInternals");
spl_autoload_register("simblogAutoloadPlugins");
Expand Down
25 changes: 24 additions & 1 deletion public_html/ajax.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,28 @@
<?php

/**
* The file where all AJAX requests are made.
*
* @author Răzvan Botea<utherr.ghujax@gmail.com>
* @license http://www.gnu.org/licenses/gpl.txt
* @copyright 2011-2012 Răzvan Botea
*
* PHP 5
*
* This file is part of Simblog.
*
* Simblog 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 3 of the License, or
* (at your option) any later version.
*
* Simblog 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 General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with Simblog. If not, see <http://www.gnu.org/licenses/>.
*/
if(!isset($_SERVER['HTTP_X_REQUESTED_WITH'])) {
header('HTTP/1.1 403 Forbidden');
exit();
Expand Down
55 changes: 42 additions & 13 deletions public_html/index.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,31 @@
<?php

/**
* Where it all starts.
*
* @author Răzvan Botea<utherr.ghujax@gmail.com>
* @license http://www.gnu.org/licenses/gpl.txt
* @copyright 2011-2012 Răzvan Botea
* @link https://github.com/Mayhem93/Simblog
*
* PHP 5
*
* This file is part of Simblog.
*
* Simblog 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 3 of the License, or
* (at your option) any later version.
*
* Simblog 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 General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with Simblog. If not, see <http://www.gnu.org/licenses/>.
*/
ob_start('ob_gzhandler');
if(!file_exists("../global.conf")) {
echo "Configuration file does not exist. Installation has not been carried out. <a href=\"install\">Install here.</a>";
exit();
Expand All @@ -7,29 +34,28 @@

require '../init.php';

if(!isset($_GET['action']))
if (!isset($_GET['action']))
$_GET['action'] = 'show';

session_start();
$js_files = array();

switch($_GET['action']) {
case 'show':
switch ($_GET['action']) {
case 'show':

foreach($simblog['plugin_manager'] as $name => $plugin)
if(containsBit($plugin->getJSreq(), PLUGIN_JS_BLOG_PAGES))
if (containsBit($plugin->getJSreq(), PLUGIN_JS_BLOG_PAGES))
$js_files[] = "plugins/{$name}/".$plugin->getJSfile();

$simblog['smarty']->assign("blog_posts", blog_getPosts());

$simblog['smarty']->assign("page_template", "main.tpl");
$simblog['smarty']->assign("js_files", $js_files);

break;
case 'addpost':

case 'addpost':
//the user interface to add posts
if(!count($_POST)) {
if (!count($_POST)) {
//TODO add posts user interface
}
//where the posts are added
Expand All @@ -42,6 +68,9 @@
try {
$simblog['smarty']->display('index.tpl');
}
catch(SmartyException $e) {
catch (SmartyException $e) {
echo $e->getMessage();
}
}

ob_end_flush();
?>
24 changes: 24 additions & 0 deletions settings.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,28 @@
<?php
/**
* The settings are loaded from the config file.
*
* @author Răzvan Botea<utherr.ghujax@gmail.com>
* @license http://www.gnu.org/licenses/gpl.txt
* @copyright 2011-2012 Răzvan Botea
*
* PHP 5
*
* This file is part of Simblog.
*
* Simblog 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 3 of the License, or
* (at your option) any later version.
*
* Simblog 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 General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with Simblog. If not, see <http://www.gnu.org/licenses/>.
*/
$config_file = new Config_Lite(BLOG_ROOT.'/global.conf');

try {
Expand Down
Loading

0 comments on commit 667ae86

Please sign in to comment.