Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

fixed a shitload of class related bugs

started turning plugins into classes.
started to write a shorturl plugin
some #content styling
updated gitignore
  • Loading branch information...
commit 86ae821cc6d4e7f6f3e8b485f932a620fbf215db 1 parent 9c969d6
@alpha1 authored
View
6 .gitignore
@@ -1,14 +1,12 @@
<<<<<<< HEAD
.project
=======
-serenity.wk
notes.txt
-settings.ini.php
+seings.ini.phptt
.project
new2.txt
serenity.wk
-cookies.php
-userclass.php
_menu*
menu-admin.php
rss.xml
+error.ini
View
22 .htaccess
@@ -1,17 +1,17 @@
<IfModule mod_rewrite.c>
RewriteEngine on
-RewriteBase /
+RewriteBase /$siteurl/
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
-RewriteCond %{REQUEST_FILENAME}.php -f
-RewriteRule ^(.+)$ /$1.php [L,QSA]
-RewriteRule ^tags([^/]*).*$ tags.php?%{QUERY_S­TRING} [L,QSA]
-RewriteRule ^profile([^/]*).*$ profile.php?%{QUERY_S­TRING} [L,QSA]
-#RewriteRule ^edit([^/]*).*$ edit.php?%{QUERY_S­TRING} [L,QSA]
+RewriteRule ^index([^/]*).*$ index.php?%{QUERY_STRING} [L,QSA]
+RewriteRule ^tags([^/]*).*$ tags.php?%{QUERY_STRING} [L,QSA]
+RewriteRule ^profile([^/]*).*$ profile.php?%{QUERY_STRING} [L,QSA]
+#RewriteRule ^edit([^/]*).*$ edit.php?%{QUERY_STRING} [L,QSA]
</IfModule>
-ErrorDocument 400 /errors.php?error=400
-ErrorDocument 401 /errors.php?error=401
-ErrorDocument 403 /errors.php?error=403
-ErrorDocument 404 /errors.php?error=404
-ErrorDocument 500 /errors.php?error=500
+#ErrorDocument 400 /errors.php?error=400
+#ErrorDocument 401 /errors.php?error=401
+#ErrorDocument 403 /errors.php?error=403
+#ErrorDocument 404 /errors.php?error=404
+#ErrorDocument 500 /errors.php?error=500
+#ErrorDocument 500 /errors.php?error=500
View
11 admin.php
@@ -24,7 +24,16 @@
echo "</div> \n";
}
}
-
+/* if(isset($active)){
+ if($active == function_exists($active .'_default')){
+ echo '<div class="plugin_settings">'."\n";
+ echo $active;
+ $active = new $active("rss");
+ call_user_method("__construct", $active);
+ //call_user_method($activ);
+ echo "</div> \n";
+ }
+ } */
}
else {
login("dashboard");
View
6 classes.php
@@ -7,7 +7,6 @@ class site {
public $title;
public $slogan;
public $version;
-public $modrewrite;
function __construct(){
$this->setSiteInfo();
@@ -21,7 +20,7 @@ function setSiteInfo(){
$this->slogan = $row["site_slogan"];
$this->url = $row["site_url"];
$this->version = $row["site_cms_version"];
- $this->modrewrite = $row['mod_rewrite_on'];
+ $this->modrewrite = $row["mod_rewrite_on"];
}
}
function getSiteInfo($input){
@@ -30,6 +29,9 @@ function getSiteInfo($input){
function displaySiteInfo($input){
echo $this->getSiteInfo($input);
}
+ // function updateSiteInfo($input)
+ // $this->$input;
+ // }
}
//==============User==============================================================
class user {
View
6 content.php
@@ -1,9 +1,6 @@
<div id="content">
<?php
-$query = $_SERVER['QUERY_STRING'];
-if($query == NULL){
-$query = "index";
-}
+$query = useModRewrite();
if(function_exists('breadcrumbs')) {
breadcrumbs("page");
}
@@ -57,6 +54,7 @@
$post_tags = explode(",", $post_tags);
echo '<span class="tags-meta">' . "\n";
foreach ($post_tags as $tag) {
+ $tag = trim($tag);
echo '<a rel="tag" class="tagslink" href="'. $site->getSiteInfo("url") .'tags'. $link. $tag .'">'. $tag .'</a>' ."\n";
}
echo '</span>' ."\n";
View
22 functions.php
@@ -1,7 +1,7 @@
<?php
$pageUrl = 'http://'. $_SERVER["HTTP_HOST"] . $_SERVER["REQUEST_URI"];
$pageTitle = $_SERVER["QUERY_STRING"];
-$link = getLink();
+
function getPluginsArray(){
$dir = opendir("plugins");
@@ -24,21 +24,11 @@ function getPluginsArray(){
for($x = 0; $x <= $count; $x++){
include("plugins/$pluginsArray[$x]");
}
-
-function getLink(){
- if(function_exists("checkModRewrite")){
- if(checkModRewrite() == true){
- $link = '/';
- }
- else {
- $link = ".php?";
- }
- $link = $link;
- }
- else {
- $link = ".php?";
- }
- return $link;
+if(function_exists("head_install_modrwrite")){
+$link = head_install_modrwrite();
+}
+else {
+$link = ".php?";
}
function getTheTitle(){
View
9 header.php
@@ -22,14 +22,13 @@
for($x = 0; $x <= $count; $x++){
$pluginsArrayLink = str_replace("_", "", $pluginsArray[$x]);
$pluginsArrayLink = str_replace(".php", "", $pluginsArrayLink);
-
-if(function_exists('head_install_'. $pluginsArrayLink)){
-call_user_func('head_install_'. $pluginsArrayLink, "");
+ if(function_exists('head_install_'. $pluginsArrayLink)){
+ call_user_func('head_install_'. $pluginsArrayLink, "");
+ }
+}
if(function_exists('install_rss')){
appendMenu($share, 'RSS', 'rss.xml', 'bottom');
}
-}
-}
?>
</head>
<body>
View
25 plugins/_googleanalytics.php
@@ -1,4 +1,8 @@
<?php
+/*
+==To Do
+create column if not exists
+*/
function googleanalytics_default(){
if(function_exists("googleanalytics_settings")){
googleanalytics_settings();
@@ -10,23 +14,28 @@ function googleanalytics_default(){
function googleanalytics_settings(){
if(isset($_POST['setga'])){
$uid = $_POST['uaid'];
- $sql_alter = mysql_query("ALTER TABLE `info` ADD `googleanalytics_uid` VARCHAR(13) NOT NULL", $GLOBALS['mysql_connect']);
$sql_check = mysql_query("SELECT googleanalytics_uid from info", $GLOBALS['mysql_connect']);
- if(mysql_num_rows($sql_check) == false){
- if($sql_alter){
- echo "interting now";
+ if($sql_check){
+ if(mysql_query("UPDATE info SET googleanalytics_uid='$uid' WHERE `info_id`=1", $GLOBALS['mysql_connect'])){
}
else {
- echo "inserting failed";
+ notification("failed", "inserting Data failed", "you probably need to create a google analytics column");
}
}
else {
- mysql_query("UPDATE `info` SET `googleanalytics_uid` = 'UA-32512990-1' WHERE `info`.`info_id` =1", $GLOBALS['mysql_connect']);
+ notification("failed", "inserting Data failed", "you probably need to create a google analytics column");
}
}
+ $sql = mysql_query("SELECT googleanalytics_uid FROM info limit 0,1", $GLOBALS['mysql_connect']);
+ while($row = mysql_fetch_array($sql)){
+ $uid = $row["googleanalytics_uid"];
+ }
+ if(!isset($uid)){
+ $uid = "";
+ }
echo '<div class="forms">';
- echo '<form method="post" action="admin.php">'."\n";
- echo '<label>UA-ID</label><input type="text" name="uaid" maxlength="13" size="13" value="">'."\n<br>";
+ echo '<form method="post" action="">'."\n";
+ echo '<label>UA-ID</label><input type="text" name="uaid" maxlength="13" size="13" value="'.$uid.'">'."\n<br>";
echo '<input type="submit" class="save" name="setga" value="Set Google Analytics">'."\n";
echo '</form></div>'."\n";
}
View
98 plugins/_modrewrite.php
@@ -1,5 +1,4 @@
<?php
-$rewrite = $site->getSiteInfo("modrewrite");
function modrewrite_default(){
if(function_exists("modrewrite_settings")){
modrewrite_settings();
@@ -9,19 +8,24 @@ function modrewrite_default(){
}
}
function modrewrite_settings(){
+if(function_exists('firstrun_modrewrite')){
+firstrun_modrewrite();
+}
if(isset($_POST['togglemodrewrite'])){
if(isset($_POST['modrewriteon'])){
$modrewriteon = $_POST['modrewriteon'];
+ $modrewriteon = 1;
}
else {
$modrewriteon = 0;
}
-mysql_query("UPDATE `info` SET `mod_rewrite_on` = '$modrewriteon' WHERE `info`.`info_id` =1 LIMIT 1", $GLOBALS['mysql_connect']);
+mysql_query("UPDATE `plugins` SET `on` = '$modrewriteon' WHERE `pluginname`='modrewrite' LIMIT 0,1", $GLOBALS['mysql_connect']);
+checkModRewrite();
}
-$rewrite = $GLOBALS['rewrite'];
+$rewrite = checkModRewrite();
echo '<div class="forms"><form method="post" action="">'."\n";
-if($rewrite == "1"){
-echo '<input type="checkbox" checked="checked" value="" name="modrewriteon">."\n"';
+if($rewrite == "true"){
+echo '<input type="checkbox" checked="checked" value="" name="modrewriteon">'."\n";
}
else {
echo '<input type="checkbox" value="" name="modrewriteon">'."\n";
@@ -31,7 +35,7 @@ function modrewrite_settings(){
}
function install_modrwrite(){
-$siteurl = getSiteInfo("url");
+$siteurl = $GLOBALS['siteUrl'];
echo <<<EOT
<IfModule mod_rewrite.c>
RewriteEngine on
@@ -43,22 +47,30 @@ function install_modrwrite(){
RewriteRule ^profile([^/]*).*$ profile.php?%{QUERY_STRING} [L,QSA]
#RewriteRule ^edit([^/]*).*$ edit.php?%{QUERY_STRING} [L,QSA]
</IfModule>
-ErrorDocument 400 /errors.php?error=400
-ErrorDocument 401 /errors.php?error=401
-ErrorDocument 403 /errors.php?error=403
-ErrorDocument 404 /errors.php?error=404
-ErrorDocument 500 /errors.php?error=500
+#ErrorDocument 400 /errors.php?error=400
+#ErrorDocument 401 /errors.php?error=401
+#ErrorDocument 403 /errors.php?error=403
+#ErrorDocument 404 /errors.php?error=404
+#ErrorDocument 500 /errors.php?error=500
EOT;
}
-//function head_install_modrwrite(){}
+function head_install_modrwrite(){
+ if(checkModRewrite() == true){
+ $link = '/';
+ }
+ else {
+ $link = ".php?";
+ }
+ $link = $link;
+ return $link;
+}
//function footer_install_modrwrite(){}
function checkModRewrite(){
if (file_exists(".htaccess")) {
-$htaccess = true;
-$getModrewrite = "SELECT * FROM `info` LIMIT 0,1";
-$mod_rewrite_on = mysql_query($getModrewrite, $GLOBALS['mysql_connect']);
+$mod_rewrite_on = mysql_query("SELECT * FROM `plugins` WHERE pluginname='modrewrite' LIMIT 0,1", $GLOBALS['mysql_connect']);
+if(mysql_num_rows($mod_rewrite_on)){
while($row = mysql_fetch_array($mod_rewrite_on)){
- if($row["mod_rewrite_on"] = "1"){
+ if($row["on"] = "1"){
$modrewrite = true;
}
else {
@@ -67,41 +79,41 @@ function checkModRewrite(){
}
}
else {
-$htaccess = false;
+$modrewrite = false;
+}
+}
+else {
$modrewrite = false;
}
return $modrewrite;
}
-
function useModRewrite(){
-$query = $_SERVER["QUERY_STRING"];
-if($query == NULL){
-$query = "index";
-}
-$url = $_SERVER["REQUEST_URI"];
- if(checkModRewrite()==true){
- $rmphp = strrpos($url, ".php", -1);
- if ($rmphp === false) {
- $array = explode("/", $url);
- $query = array_pop($array);
- }
- else {
- if($query == null){
- $query = "All input";
- }
- else {
- $query = $query;
- }
- }
+$url = $_SERVER['REQUEST_URI'];
+$url = str_replace("http://", "", $url);
+$url = str_replace("https://", "", $url);
+$url = str_replace("?", "/", $url);
+$urlarray = explode("/", $url);
+array_shift($urlarray);
+array_shift($urlarray);
+$home = 'http://'. $_SERVER["HTTP_HOST"] . $url;
+if($GLOBALS['siteUrl'] == $home){
+$currentpage = "index";
+}
+else {
+$currentpage = array_pop($urlarray);
+}
+return $currentpage;
+}
+
+function firstrun_modrewrite(){
+$firstrun = mysql_query("SELECT * FROM `plugins` WHERE pluginname='modrewrite'", $GLOBALS['mysql_connect']);
+if(mysql_num_rows($firstrun)==0){
+ if(mysql_query("INSERT INTO plugins (pluginname, `on`) VALUES ('modrewrite', '0')", $GLOBALS['mysql_connect'])){
}
else {
- if($query == null){
- $query = "All $input";
- }
- else {
- $query = $query;
+ notification('failed', 'Could not install plugin', 'Make sure the Database and table "plugins" exist');
}
+} else {
}
-return $query;
}
?>
View
56 plugins/_plugin.php
@@ -1,20 +1,56 @@
<?php
-function PLUGIN_default(){
- if(function_exists("PLUGIN_settings")){
- PLUGIN_settings();
+$siteUrl = $site->getSiteInfo("url");
+$siteTitle = $site->getSiteInfo("title");
+$siteSlogan = $site->getSiteInfo("slogan");
+class plugin {
+public $name;
+public $api;
+public $email;
+public $password;
+public $siteurl;
+public $sitentitle;
+public $siteslogan;
+
+
+function __construct($name){
+$this->name = $name;
+$this->siteurl = $GLOBALS["siteUrl"];
+$this->sitetitle = $GLOBALS["siteTitle"];
+$this->siteslogan = $GLOBALS["siteSlogan"];
+ if(method_exists("this","settings")){
+ $this->settings();
}
else {
- echo "PLUGIN has no settings \n";
+ echo $this->name ."Has no settings";
}
+ if(method_exists("this", "firstrun")){
+ $this->firstrun();
+ }
+}
+function setSettings($prop, $newProp){
+$this->$prop = $newProp;
+}
+function getSettings($input){
+return $this->$input;
}
-function PLUGIN_settings(){
-//if things need to be set this is where to build the form
+function displaySettings($input){
+echo $this->$input;
+}
+function firstrun(){
+$firstrun = mysql_query("SELECT * FROM `plugins` WHERE pluginname='$this->name'", $GLOBALS['mysql_connect']);
+ if(mysql_num_rows($firstrun)==0){
+ if(mysql_query("INSERT INTO plugins(pluginname, `on`) VALUES ('$this->name', '0')")){
+ }
+ else {
+ notification("failed", "Could not install plugin: $this->name", "Make sure the Database and table plugins exist");
+ }
+ }
}
-function install_PLUGIN(){
-//sets the files if needed, otherwise just does shit
+function head_install(){
+child::head_install();
}
-function head_install_PLUGIN(){
+function footer_install(){
+child::footer_install();
}
-function footer_install_PLUGIN(){
}
?>
View
65 plugins/_rss2.php
@@ -0,0 +1,65 @@
+<?php
+
+class rss extends plugin {
+ public $name;
+ public $api;
+ public $email;
+ public $password;
+ public $siteurl;
+ public $sitentitle;
+ public $siteslogan;
+
+
+ function __construct($name){
+$this->name = $name;
+$this->siteurl = $GLOBALS["siteUrl"];
+$this->sitetitle = $GLOBALS["siteTitle"];
+$this->siteslogan = $GLOBALS["siteSlogan"];
+ if(method_exists("firstrun")){
+ $this->firstrun();
+ }
+ }
+
+ function install(){
+ $rssxml = "rss.xml";
+ $rssfile = fopen($rssxml, 'w') or die("Cannot open file");
+ fwrite($rssfile, '<?xml version="1.0" encoding="ISO-8859-1" ?>'."\n");
+ fwrite($rssfile, '<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">'."\n");
+ fwrite($rssfile, "<channel>\n");
+ fwrite($rssfile, '<atom:link href="'. $siteUrl . $rssxml .'" rel="self" type="application/rss+xml" />'."\n");
+ fwrite($rssfile, '<title>'. $siteTitle .'</title>'."\n");
+ fwrite($rssfile, '<copyright>'. $siteTitle .'</copyright>'."\n");
+ fwrite($rssfile, '<link>'. $siteUrl . $rssxml. '</link>'."\n");
+ fwrite($rssfile, '<pubDate>'.date("r") .'</pubDate>'."\n");
+ fwrite($rssfile, '<ttl>1</ttl>'."\n");
+ fwrite($rssfile, '<description>'. $siteTitle .' Feed</description>'."\n");
+ fwrite($rssfile, '<generator>Serenity CMS installed at '. $siteUrl .'</generator>'."\n");
+ $sql = mysql_query("SELECT * FROM `posts` ORDER BY `posts`.`post_date` DESC LIMIT 0, 10", $GLOBALS['mysql_connect']);
+ while($row = mysql_fetch_array($sql)){
+ fwrite($rssfile, " <item>\n");
+ fwrite($rssfile, "<title>" .$row['post_title'] ."</title>\n");
+ fwrite($rssfile, "<link>". $siteUrl .'?'. $row['post_url'] ."</link>\n");
+ fwrite($rssfile, "<pubDate>". date('r',strtotime($row['post_date']))."</pubDate>\n");
+ //fwrite($rssfile, "<author>". $row['post_author'] ."</author>\n");
+ //fwrite($rssfile, "<category>". ."</category>\n");
+ fwrite($rssfile, "<description>". strip_tags($row['post_data']) ."</description>\n");
+ fwrite($rssfile, " </item>\n");
+ }
+ fwrite($rssfile, "</channel>\n");
+ fwrite($rssfile, "</rss>\n");
+ fclose($rssfile);
+ }
+
+ function head_install(){
+ $siteUrl = $GLOBALS['siteUrl'];
+ $siteTitle = $GLOBALS['siteTitle'];
+ echo '<link rel="alternate" type="application/rss+xml" title="'. $this->sitetitle .'Feed" href="'. $this->siteurl .'rss.xml">'."\n";
+ }
+
+ function footer_install(){
+ child::footer_install();
+ }
+ function settings(){
+ echo $this->name ."Has no settings";
+ }
+}
View
22 plugins/_shorturl.php
@@ -1,23 +1,27 @@
<?php
-function short_url_default(){
- if(function_exists("short_url_settings")){
- short_url_settings();
+function shorturl_default(){
+ if(function_exists("shorturl_settings")){
+ shorturl_settings();
}
else {
echo "short_url has no settings \n";
}
}
-function short_url_settings(){
-//if things need to be set this is where to build the form
+function shorturl_settings(){
+if(isset($_POST["savebitlydata"])){
+$bitlyUsername = $_POST['bitlyUsername'];
+$bitlyApikey = $_POST['bitlyApikey'];
+}
?>
<form class="forms" method="post" action="">
-<input type="text" name="bitlyUsername" value="" required>
-<input type="text" name="bitlyApikey" value="" required>
-<input type="submit" name="Submit" value="Submit>
+<label for="bitlyUsername">Bit.ly Username</label><input type="text" name="bitlyUsername" value="" required><br>
+<label for="bitlyApikey">Bit.ly Api Key</label><input type="text" name="bitlyApikey" value="" required><br>
+<label for="shortlinkon">Turn on Shortlink meta tag?</label><input type="checkbox" name="shortlinkon" value="" required><br>
+<input type="submit" class="save" name="savebitlydata" value="Submit">
</form>
<?php
}
-function install_short_url(){
+function install_shorturl(){
//sets the files if needed, otherwise just does shit
}
// function head_install_short_url(){}
View
6 settings.ini.php
@@ -0,0 +1,6 @@
+<?php
+$mysql_server="localhost";
+$mysql_username="root";
+$mysql_password="";
+$mysql_database="serenityalpha";
+?>
View
77 styles.css
@@ -171,46 +171,16 @@ background-color:#99CA3C;
background-color:#99CA3C;
}
#sidebar .entry-title {
-font-size: 28px;
+font-size: 24px;
text-indent: 10px;
}
#sidebar .author-meta{
-font-size: 24px;
+font-size: 20px;
text-indent: 20px;
}
#selected-title,#selected-meta {
background-color:#99CA3C;
}
-#content article{
-padding: 20px;
-}
-#content .meta-info {
-color: #99CA3C;
-background: #333333;
-font-size: 14px;
-display: block;
-text-transform: capitalize;
-}
-#content .author-meta, #content .datetime-meta {
-height: 48px;
-line-height: 48px;
-width: 100%;
-text-indent: 32px;
-display: block;
-background-position: left center !IMPORTANT;
-}
-#content .author-meta {
-}
-#content.datetime-meta {
-}
-#content .title-meta a{
-padding-left: 10px;
-display: block;
-font-size: 28px;
-text-transform: capitalize;
-text-decoration: none;
-font-weight: bold;
-}
.draftpost {
color: #118CEA;
}
@@ -220,11 +190,6 @@ width: -webkit-calc(100%-320px);
width: calc(100%-320px);
margin-left: 320px;
}
-#content article {
-display: block;
-line-height: 24px;
-font-size: 18px;
-}
.tags-meta {
width: 100%;
text-indent: 32px;
@@ -427,5 +392,39 @@ line-height: 24px;
}
/*** CONTENT STYLES ***/
#content article {
-
-}
+display: block;
+line-height: 24px;
+font-size: 18px;
+padding: 20px;
+}
+#content .meta-info {
+color: #99CA3C;
+background: #333333;
+font-size: 14px;
+display: block;
+text-transform: capitalize;
+}
+#content .author-meta, #content .datetime-meta {
+height: 48px;
+line-height: 48px;
+width: 100%;
+text-indent: 32px;
+display: block;
+background-position: left center !IMPORTANT;
+}
+#content .author-meta {
+}
+#content.datetime-meta {
+}
+#content .title-meta a{
+padding-left: 10px;
+display: block;
+font-size: 28px;
+text-transform: capitalize;
+text-decoration: none;
+font-weight: bold;
+}
+#content article img{
+padding: 10px;
+background: #202020;
+}
Please sign in to comment.
Something went wrong with that request. Please try again.