function delete(){ loadIntClass('sql_query'); $sql = new Sql_query('comments'); $array = $sql->query('SELECT * FROM `comments` WHERE `id`=\''.$this->_id.'\''); $sql->simpleQuery('DELETE FROM `comments` WHERE `id`=\''.$this->_id.'\''); $this->republish($array[0]['Comment']['post_slug']); die('SUCCESS'); }
function __construct($post, $filter = 'ALL', $sort = 'none', $DESC = true){ if(session_check()) { $this->_sort = $sort; $this->_DESC = $DESC; loadIntClass('sql_query'); $sql = new Sql_query('comments'); $this->_comments = $sql->getComments($post,$filter); } else{ die('Your session has expired. Please <a href="'.ADMIN_URL.'/logout" target="_self">login</a> again in order to submit your post.'); } }
function __destruct(){ loadIntClass('sql_query'); $Aut = new Sql_query('authors'); $aut_arr = $Aut->selectAll(); for($i=0; $i < count($aut_arr); ++$i){ if($this->_author === $aut_arr[$i]['Author']['author']){ die('This author already exists. If they are not showing up in your slection menu check the documentation for add_new_author.'); } } $Aut->simpleQuery('INSERT INTO `authors` (author) VALUES(\''.$this->_author.'\')'); die('yes'); }
function getCSS(){ require(ROOT.DS.MAIN.DS.'library'.DS.'simple_html_dom.php'); $html = file_get_html($this->_path.$this->_template.'.php'); $stylesheets = $html->find('link[rel=stylesheet]'); $this->_css = ''; $first = true; foreach($stylesheets as $value){ $this->_css .= $first ? '' : ','; $this->_css .= $value->href; $first = false; } $sql = new Sql_query('tempaltes'); $sql->simpleQuery('UPDATE `templates` SET `css`=\''.$this->_css.'\', `date`=\''.time().'\' WHERE `name`=\''.$this->_template.'\''); die('SUCCESS/'.$this->_template.'/'.time()); }
function logout(){ $pName = hash("sha512",$_COOKIE['username']); loadIntClass('sql_query'); $class = new Sql_query('users'); $userDb = $class->selectWhere('user',$pName); $userDb = $userDb['User']; if($pName === $userDb['user']) { $class->simpleQuery("UPDATE `users` SET `loggedin`='0', `logtime`='0'' WHERE `user`='".$pName."'"); $class->disconnect(); return true; } else{ return false; } }
function template(){ loadIntClass('sql_query'); $posts = new Sql_query('posts'); $num = $posts->selectWhere('slug',$this->_uri); if($num != 0){ if(file_exists(ROOT.DS.MAIN.DS.'reflex'.DS.'templates'.DS.$this->_template.'.php')){ $posts->simpleQuery('UPDATE `posts` SET `template`=\''.$this->_template.'\' WHERE `slug`=\''.$this->_uri.'\''); die('yes'); } else{ die('It seems that the template does not exist anymore.'); } } else{ die('The server could not find the post that you selected.'); } }
function writeRSS(){ $rsshead = '<?xml version="1.0" encoding="UTF-8" ?> <rss version="2.0"> <channel> <title>'.RSS_TITLE.'</title> <description>'.RSS_DESCRIPTION.'</description> <language>en-us</language> <copyright>Copyright (C) '.date('Y').' '.THIS_DOMAIN.'</copyright> <link>http://'.THIS_DOMAIN.'/'.RSS_URI.'</link> <lastBuildDate>'.date('D, d M Y H:i:s T').'</lastBuildDate>'; loadIntClass('sql_query'); $sql = new Sql_query('posts'); $postArr = $sql->query('SELECT * FROM `posts` WHERE `publish`=\'1\''); $count = count($postArr); if($count === 0){ die('There are no posts'); } reset($postArr); $latest =$postArr[0]['Post']['publishdate']; $rssbody=''; for($i = 0; $i < $count;++$i){ $p = $postArr[$i]['Post']; if($p['slug'] === '_index_') $p['slug'] =''; $link = 'http://'.THIS_DOMAIN.'/'.($p['category'] !=='none'?$p['category'].'/':'').$p['slug']; $rssbody .= ' <item> <title>'.$p['title'].'</title> <description>'.$p['description'].'</description> <link>'.$link.'</link> <guid isPermaLink="true">'.$link.'</guid> <pubDate>'.date('D, d M Y H:i:s T',intval($p['publishdate'])).'</pubDate> </item> '; if(intval($latest)<intval($p['publishdate'])){ $latest = $p['publishdate']; } } $rsshead.=' <pubDate>'.date('D, d M Y H:i:s T',intval($latest)).'</pubDate>'; $rssbody.='</channel> </rss>'; header("Content-Type: application/rss+xml"); echo $rsshead,$rssbody; exit; }
function __destruct(){ loadIntClass('sql_query'); $Cat = new Sql_query('categories'); $cat_arr = $Cat->selectAll(); for($i=0; $i < count($cat_arr); ++$i){ if($this->_category === $cat_arr[$i]['Categorie']['category']){ die('This category already exists. If it is not showing up in your slection menu check the documentation for add_new_category.'); } } if(is_dir(ROOT.DS.MAIN.DS.'reflex'.DS.'documents'.DS.'_categories_'.DS.$this->_category)){ die('This category already exists. If it is not showing up in your slection menu check the documentation for add_new_category.'); } $Cat->simpleQuery('INSERT INTO `categories` (category) VALUES(\''.$this->_category.'\')'); $Cat->disconnect(); if(!mkdir(ROOT.DS.MAIN.DS.'reflex'.DS.'documents'.DS.'_categories_'.DS.$this->_category)){ die('The server failed to write the folder. Check the documentation for add_new_category.'); } die('yes'); }
function republish() { loadIntClass('sql_query'); $posts = new Sql_query('posts'); $num = $posts->numRows('slug',$this->_uri); if($num !== 0){ $post_arr = $posts->selectWhere('slug',$this->_uri); $post_arr = $post_arr['Post']; $this->_post = $post_arr['post']; $this->_title = $post_arr['title']; $this->_slug = $post_arr['slug']; $this->_description = $post_arr['description']; $this->_template = $post_arr['template']; $this->_category = $post_arr['category']; $this->_author = $post_arr['author']; $this->_commentbool = $post_arr['commentbool']; $this->_pingbacks = $post_arr['pingbacks']; $this->_pingbool = $post_arr['pingbool']; $this->_publish = $post_arr['publish']; $this->_cachepub = $post_arr['cachepub']; ob_start(); require(ROOT.DS.MAIN.DS.'reflex'.DS.'templates'.DS.$this->_template.'.php'); $html_string = ob_get_clean(); $html_string = str_replace('<php>','<?php ',$html_string); $html_string = str_replace('</php>',' ?>',$html_string); if($this->_category == 'none'){ $fileloc = fopen(ROOT.DS.MAIN.DS.'reflex'.DS.'documents'.DS.$this->_slug.'.php', 'w'); fwrite($fileloc,$html_string); fclose($fileloc); } else{ $fileloc = fopen(ROOT.DS.MAIN.DS.'reflex'.DS.'documents'.DS.'_categories_'.$this->_category.DS.$this->_slug.'.php', 'w'); fwrite($fileloc,$html_string); fclose($fileloc); } $posts->simpleQuery('UPDATE `posts` SET `publish`=\'1\' WHERE `slug`=\''.$this->_slug.'\''); die('yes'); } else{ die('The server could not find the post that you selected.'); } }
function delete(){ loadIntClass('sql_query'); $posts = new Sql_query('posts'); $num = $posts->numRows('slug',$this->_uri); if($num !== 0){ $post_arr = $posts->selectWhere('slug',$this->_uri); $post_arr = $post_arr['Post']; if($post_arr['category'] == 'none'){ @unlink(ROOT.DS.MAIN.DS.'reflex'.DS.'documents'.DS.$this->_uri.'.php'); $posts->simpleQuery('DELETE FROM `posts` WHERE `slug`=\''.$this->_uri.'\''); die('yes'); } else{ @unlink(ROOT.DS.MAIN.DS.'reflex'.DS.'documents'.DS.'_categories_'.DS.$this->_uri.'.php'); $posts->simpleQuery('DELETE FROM `posts` WHERE `slug`=\''.$this->_uri.'\''); die('yes'); } } else{ die('The server could not find the post that you selected.'); } }
function session_create(){ if(array_key_exists('username', $_POST) && array_key_exists('password', $_POST)){ $pName = hash("sha512",$_POST['username']); $pPass = hash("sha512",$_POST['password']); loadIntClass('sql_query'); $sql = new Sql_query('users'); $thisDB = $sql->selectAll(); $userexists = false; $int = 0; for($i = 0; $i<count($thisDB); ++$i){ if($pName === $thisDB[$i]['User']['user']) $userexists = true; $int = $i; } if($userexists){ if($thisDB[$int]['User']['password'] === $pPass){ if(!array_key_exists('username', $_COOKIE)){ //One year setcookie('username',$_POST['username'],time()+60*60*24*365,'/'); } $time = time()+60*60; $sql->simpleQuery("UPDATE `users` SET `loggedin`='1', `logtime`='".$time."' WHERE `user`='".$pName."'"); $sql->disconnect(); return true; } else{ return false; } } else{ return false; } } else{ return false; } }
function unpublish(){ loadIntClass('sql_query'); $posts = new Sql_query('posts'); $num = $posts->numRows('slug',$this->_uri); if($num != 0){ if(file_exists(ROOT.DS.MAIN.DS.'reflex'.DS.'documents'.DS.$this->_loc.'.php') || file_exists(ROOT.DS.MAIN.DS.'reflex'.DS.'documents'.DS.'_categories_'.DS.$this->_loc.'.php')){ $post_arr = $posts->selectWhere('slug',$this->_uri); $post_arr = $post_arr['Post']; if($post_arr['category'] == 'none'){ if(unlink(ROOT.DS.MAIN.DS.'reflex'.DS.'documents'.DS.$this->_loc.'.php')){ $posts->simpleQuery('UPDATE `posts` SET `publish`=\'0\' WHERE `slug`=\''.$this->_uri.'\''); die('yes'); } else{ die('The server failed to delete the post you selected.'); } } else{ if(unlink(ROOT.DS.MAIN.DS.'reflex'.DS.'documents'.DS.'_categories_'.DS.$this->_loc.'.php')){ $posts->simpleQuery('UPDATE `posts` SET `publish`=\'0\' WHERE `slug`=\''.$this->_uri.'\''); die('yes'); } else{ die('The server failed to delete the post you selected.'); } } } else{ $post_arr = $posts->selectWhere('slug',$this->_uri); $post_arr = $post_arr['Post']; if($post_arr['publish'] == 0){ die('yes'); } else{ $posts->simpleQuery('UPDATE `posts` SET `publish`=\'0\' WHERE `slug`=\''.$this->_uri.'\''); die('yes'); } } } else{ die('The server could not find the post that you selected.'); } }
function session_check() { if(array_key_exists('username', $_COOKIE)){ loadIntClass('sql_query'); $pName = hash("sha512",$_COOKIE['username']); $sql = new Sql_query('users'); $thisDB = $sql->selectAll(); $userexists = false; $int = 0; for($i = 0; $i<count($thisDB); ++$i){ if($pName === $thisDB[$i]['User']['user']) $userexists = true; $int = $i; } if($userexists) { if(intval($thisDB[$int]['User']['loggedin'])===1) { if(intval($thisDB[$int]['User']['logtime'])>time()){ return true; } else{ $sql->simpleQuery("UPDATE `users` SET `loggedin`='0', `logtime`='0'' WHERE `user`='".$pName."'"); $sql->disconnect(); return false; } } else{ $sql->simpleQuery("UPDATE `users` SET `logtime`='0' WHERE `user`='".$pName."'"); $sql->disconnect(); return false; } } else{ setcookie('username',$_COOKIE['username'], time()-60*60*24); return false; } } else{ return false; } }
function db_create($directory) { $commentbool = $this->_commentbool ? 1 : 0; $publish = $this->_publish ? 1 : 0; $pingbool = $this->_pingbool ? 1 : 0; $cachepub = $this->_cachepub ? 1 : 0; $time = time(); $posts = new Sql_query('posts'); $num = $posts->numRows('slug',$this->_slug); if($num !== 0){ $posts->simpleQuery('UPDATE `posts` SET `title`=\''.$this->_title.'\', `description`=\''.$this->_description.'\, `template`=\''.$this->_template.'\', `category`=\''.$this->_category.'\', `author`=\''.$this->_author.'\', `commentbool`=\''.$commentbool.'\', `publish`=\''.$publish.'\', `post`=\''.$this->_post.'\', `pingbool`=\''.$pingbool.'\', `publishdate`=\''.$time.'\', `cachepub`=\''.$cachepub.'\, `comments_off`=\''.$this->_commentsdate.'\' WHERE `slug`=\''.$this->_slug.'\''); $posts->disconnect(); } else{ $posts->simpleQuery('INSERT INTO `posts` (title, slug, description, template, category, author, commentbool, publish, post, pingbool, publishdate, cachepub, comments_off) VALUES ( \''.$this->_title.'\', \''.$this->_slug.'\', \''.$this->_description.'\', \''.$this->_template.'\', \''.$this->_category.'\', \''.$this->_author.'\', \''.$commentbool.'\', \''.$publish.'\', \''.$this->_post.'\', \''.$pingbool.'\', \''.$time.'\', \''.$cachepub.'\', \''.$this->_commentsdate.'\')'); $posts->disconnect(); } $string_url = 'http://'.THIS_DOMAIN.'/'; $string_url .= $this->_category === 'none' ? ($this->_slug ==='_index_' ? '' : $this->_slug) : $this->_category.'/'.$this->_slug; if($this->_publish=='true'){ $this->publish($directory,$string_url); } die('Your new post has been saved. Simply go to Posts, when you\'re ready to publish it. When it is published its url will be "'.$string_url.'".'); }
<?php $postKey = $this->_postName === '' ? 'index' : $this->_postName; $docArray = array( 'index' => array('title' => 'Create a New Post', 'css' => 'newpost'), 'posts' => array('title'=>'Browse Your Posts','css'=>'posts'), 'templates' => array('title'=>'Browse your Templates','css'=>'templates'), 'upload-files' => array('title'=>'Upload/Browse Your Files','css'=>'media'), 'comments' => array('title'=>'Browse Your Comments','css'=>'comments'), 'settings' => array('title'=>'Adjust Your Settings','css'=>'settings'), ); loadIntClass('sql_query'); $header_posts = new Sql_query('posts'); $unpublished_i = $header_posts->numRows('publish','0'); $comments = new Sql_query('comments'); $unapproved_i = $comments->numRows('approved','pending'); ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /> <title>Reflexion - <? echo $docArray[$postKey]['title']?></title> <base href="<? echo 'http://'.THIS_DOMAIN.'/';?>" /> <link rel="stylesheet" href="css/admin/reset.css" /> <link rel="stylesheet" href="css/admin/<? echo $docArray[$postKey]['css']?>.css" /> </head> <body> <div id="header"> <div id="logo"></div> <p class="alternate"> <? if($postKey !== 'comments'){
<?php require(ROOT.DS.MAIN.DS.'reflex'.DS.'admin'.DS.'documents'.DS.'headnavfoot'.DS.'header.php'); require(ROOT.DS.MAIN.DS.'config'.DS.'posts.php'); require(ROOT.DS.MAIN.DS.'config'.DS.'comments.php'); require(ROOT.DS.MAIN.DS.'config'.DS.'rss.php'); loadIntClass('sql_query'); $sql1 = new Sql_query('templates'); $templates = $sql1->selectAll(); $sql2 = new Sql_query('categories'); $categories = $sql2->selectAll(); $sql3 = new Sql_query('authors'); $authors = $sql3->selectAll(); $moderationStr = ''; for($i = 0; $i < count($moderate); ++$i){ if($i !== 0 ) $moderationStr .= ', '; $moderationStr .= $moderate[$i]; } $spamStr = ''; for($i = 0; $i < count($spam); ++$i){ if($i !== 0 ) $spamStr .= ', '; $spamStr .= $spam[$i]; } $opt_temp = ' <option value="'.DEFAULT_TEMPLATE.'">'.DEFAULT_TEMPLATE.'</option> '; $opt_cat = ' <option value="'.DEFAULT_CATEGORY.'">'.DEFAULT_CATEGORY.'</option> '; $opt_aut = ' <option value="'.DEFAULT_AUTHOR.'">'.DEFAULT_AUTHOR.'</option> '; for($i = 0; $i < count($templates); ++$i){
<?php require(ROOT.DS.MAIN.DS.'reflex'.DS.'admin'.DS.'documents'.DS.'headnavfoot'.DS.'header.php'); $sql_temp = new Sql_query('templates'); $template_arr = $sql_temp->selectAll(); $temp_table = ''; for($i=0; $i < count($template_arr); ++$i){ $value = $template_arr[$i]['Template']; $temp_table .= ' <tr id="'.$value['name'].'"> <td>'.$value['name'].'</td> <td class="date">'.date('m/d/Y',intval($value['date'])).'</td> </tr>'; } ?> <p class="in_main">All you need to do, in order to add a new template, is to upload the file from your computer, and add the relevant media files later. When you upload a new template the file name will be the name of the template. If you would like to replace a template, simply upload a file of the same name.</p><br /> <form id="add_temp"> <div id="swfupload-control"></div> <input type="button" class="button" id="new_temp" /> </form> <table id="templates_table" class="tablesorter"> <thead> <tr> <th>Name</th> <th>Date Last Modified</th> </tr> </thead> <tbody id="table_body"> <? echo $temp_table;?> </tbody> </table> <? require(ROOT.DS.MAIN.DS.'reflex'.DS.'admin'.DS.'documents'.DS.'headnavfoot'.DS.'footer.php');?> <script type="text/javascript" src="scripts/admin/swfupload.js"></script>
</tr> '; switch($comments[$i]['approved']){ case 'approved': $approved+=1; break; case 'pending': $pending+=1; break; case 'spam': $spam+=1; break; } } $all = $pending + $approved + $spam; $sql2 = new Sql_query('posts'); $posts = $sql2->query('SELECT * FROM `posts` WHERE `commentbool`=\'1\' OR `pingbool`=\'1\''); ?> <p id="para" class="in_main">You may not view all comments. You may view all the comments for a particular posts, or all pending, or spam comments from your entire site.</p> <form class="in_main"> <select id="posts_select"> <? if(array_key_exists('post',$_GET)){ echo '<option value="',$_GET['post'],'">',$_GET['post'],'</option> <option value="AP">All Pending and Spam</option>'; for($i = 0; $i < count($posts); ++$i){ if($posts[$i]['Post']['slug'] !== $_GET['post']){ echo '<option value="',str_replace('/','_',$posts[$i]['Post']['slug']),'">',$posts[$i]['Post']['slug'],'</option> '; } }
<?php require(ROOT.DS.MAIN.DS.'reflex'.DS.'admin'.DS.'documents'.DS.'headnavfoot'.DS.'header.php'); require(ROOT.DS.MAIN.DS.'config'.DS.'posts.php'); $sql1 = new Sql_query('templates'); $template_arr = $sql1->selectAll(); $sql2 = new Sql_query('categories'); $cat_arr = $sql2->selectAll(); $sql3 = new Sql_query('authors'); $aut_arr = $sql3->selectAll(); if(array_key_exists('edit',$_GET)){ $slug = $_GET['edit'] !== '_index_' ? str_replace('_','/',$_GET['edit']) : $_GET['edit']; if($slug !== ''){ $sql4 = new Sql_query('posts'); $post_arr = $sql4->selectWhere('slug',$slug); $post_arr = $post_arr['Post']; } } $post = isset($post_arr) ? true : false; $cat = ''; if(isset($post_arr) && $post_arr['category'] !== 'none'){ $slug = explode('/',$slug); $cat = $slug[0]; array_shift($slug); $slug = $slug[0]; } $template_table = ''; $category_table = ''; $author_table = ''; if($post){ $template_table = ' <option value="'.$post_arr['template'].'">'.$post_arr['template'].'</option> ';