function checkDB(){
		loadIntClass('sql_query');
		$sql = new Sql_query('templates');
		$num =  $sql->numRows('name', $this->_templateName);
		if($num === 1 && file_exists($this->_path.$this->_filename)){
			$sql->simpleQuery('UPDATE `templates` SET `rep`=\'1\' WHERE `name`=\''.$this->_templateName.'\'');
			if($this->copyFile($_FILES['Filedata']['tmp_name'], $this->_path.$this->_templateName.'.temp.php')){
				die('REPLACE/'.$this->_templateName);	
			}
			else{
				die('The file exists already, and the server was unable to temporarily save the file to assess if you wanted to replace. Please try uploading again.');
			}
		}
		else if($this->copyFile($_FILES['Filedata']['tmp_name'], $this->_path.$this->_filename)){					
				$sql->simpleQuery('INSERT INTO `templates` (name, css, rep, date) VALUES (
					\''.$this->_templateName.'\',
					\'0\',
					\'0\',
					\''.time().'\')');
				$sql->disconnect();
				$this->getCSS();
		}
		else{
			die('The file was not successfully saved. Please try uploading again.');
		}
	}
	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 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 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.'".');
	}
Exemple #6
0
<?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'){