rpicms

A CMS for the Raspberry Pi
git clone git://archive.git.mtrnord.blog/RpicmsTeam/rpicms.git
Log | Files | Refs | README | LICENSE

commit 5948aeb84ee286665f69141d7c468f1fd25af960
parent 686f2cf40b098db3ec8f70bc28577aa2503d21e6
Author: MTRNord <mtrnord1@gmail.com>
Date:   Sat, 22 Nov 2014 20:43:05 +0100

Added missing files

Diffstat:
Acore/backend/blog/posts.php | 35+++++++++++++++++++++++++++++++++++
Acore/libs/security/aes.php | 140+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Dthemes/accentbox/templates/header_login.php | 67-------------------------------------------------------------------
3 files changed, 175 insertions(+), 67 deletions(-)

diff --git a/core/backend/blog/posts.php b/core/backend/blog/posts.php @@ -0,0 +1,35 @@ +<?php +/** +* Get posts from Database +* +* This script will the post variables with the database data. +* +* @author Marcel Radzio <info@nordgedanken.de> +* @version 0.2 17/08/2014 19:39 +*/ + include('../../core/inc/db_connect.inc.php'); + //Check if Database connection established + if (mysqli_connect_errno()) { + printf("Verbindung fehlgeschlagen: %s\n", mysqli_connect_error()); + exit(); + } + + //Check if Data in it + if ($resultat = $connection->query('SELECT * FROM posts')) { + //Put database data in variables + while($daten = $resultat->fetch_object() ){ + $post_title = $daten->title; + $post_text = $daten->text; + $post_author = $daten->name; + $post_date = $daten->date; + $post_categrory = $daten->category; + } + $resultat->close(); + } else { + //If no data in Database give error + echo "Es konnten keine Daten aus der Datenbank ausgelesen werden"; + } + +// Close database connection +$connection->close(); + diff --git a/core/libs/security/aes.php b/core/libs/security/aes.php @@ -0,0 +1,140 @@ +<?php + /** + Aes encryption + */ + class AES { + const M_CBC = 'cbc'; + const M_CFB = 'cfb'; + const M_ECB = 'ecb'; + const M_NOFB = 'nofb'; + const M_OFB = 'ofb'; + const M_STREAM = 'stream'; + protected $key; + protected $cipher; + protected $data; + protected $mode; + protected $IV; + /** + * + * @param type $data + * @param type $key + * @param type $blockSize + * @param type $mode + */ + function __construct($data = null, $key = null, $blockSize = null, $mode = null) { + $this->setData($data); + $this->setKey($key); + $this->setBlockSize($blockSize); + $this->setMode($mode); + $this->setIV(""); + } + /** + * + * @param type $data + */ + public function setData($data) { + $this->data = $data; + } + /** + * + * @param type $key + */ + public function setKey($key) { + $this->key = $key; + } + /** + * + * @param type $blockSize + */ + public function setBlockSize($blockSize) { + switch ($blockSize) { + case 128: + $this->cipher = MCRYPT_RIJNDAEL_128; + break; + case 192: + $this->cipher = MCRYPT_RIJNDAEL_192; + break; + case 256: + $this->cipher = MCRYPT_RIJNDAEL_256; + break; + } + } + /** + * + * @param type $mode + */ + public function setMode($mode) { + switch ($mode) { + case AES::M_CBC: + $this->mode = MCRYPT_MODE_CBC; + break; + case AES::M_CFB: + $this->mode = MCRYPT_MODE_CFB; + break; + case AES::M_ECB: + $this->mode = MCRYPT_MODE_ECB; + break; + case AES::M_NOFB: + $this->mode = MCRYPT_MODE_NOFB; + break; + case AES::M_OFB: + $this->mode = MCRYPT_MODE_OFB; + break; + case AES::M_STREAM: + $this->mode = MCRYPT_MODE_STREAM; + break; + default: + $this->mode = MCRYPT_MODE_ECB; + break; + } + } + /** + * + * @return boolean + */ + public function validateParams() { + if ($this->data != null && + $this->key != null && + $this->cipher != null) { + return true; + } else { + return FALSE; + } + } + public function setIV($IV) { + $this->IV = $IV; + } + protected function getIV() { + if ($this->IV == "") { + $this->IV = mcrypt_create_iv(mcrypt_get_iv_size($this->cipher, $this->mode), MCRYPT_RAND); + } + return $this->IV; + } + /** + * @return type + * @throws Exception + */ + public function encrypt() { + if ($this->validateParams()) { + return trim(base64_encode( + mcrypt_encrypt( + $this->cipher, $this->key, $this->data, $this->mode, $this->getIV()))); + } else { + throw new Exception('Invlid params!'); + } + } + /** + * + * @return type + * @throws Exception + */ + public function decrypt() { + if ($this->validateParams()) { + return trim(mcrypt_decrypt( + $this->cipher, $this->key, base64_decode($this->data), $this->mode, $this->getIV())); + } else { + throw new Exception('Invlid params!'); + } + } + } +?> diff --git a/themes/accentbox/templates/header_login.php b/themes/accentbox/templates/header_login.php @@ -1,67 +0,0 @@ -<!DOCTYPE html> -<html> - <head> - <meta http-equiv="content-type" content="text/html; charset=UTF-8"> - <?php - include('../../core/config/variables.config.php'); - echo "<title>$blog_name | $page</title>"; - ?> - - <!--iOS/android/handheld specific --> - <meta name="viewport" content="width=device-width, initial-scale=1.0"> - <meta name="apple-mobile-web-app-capable" content="yes"> - <meta name="apple-mobile-web-app-status-bar-style" content="black"> - - <link rel="stylesheet" type="text/css" media="all" href="css/style.css"> - - <!--[if lt IE 9]> - <script src="http://html5shim.googlecode.com/svn/trunk/html5.js"></script> - <![endif]--> - - <script src="js/modernizr.min.js"></script> - <script src="js/customscript.js" type="text/javascript"></script> - - <style type="text/css"> - #header h1, #header h2 { - text-indent: -999em; - min-width:200px; margin-top: 0; - } - #header h1 a, #header h2 a{ - background: url(images/logo.png) no-repeat; - min-width: 200px; - display: block; - min-height: 80px; - line-height: 28px; - } - .more a, .bubble a:hover, #commentform input#submit { - background-color: #79ACCD; - } - a, .title a:hover, #navigation ul ul li a:hover, #navigation > ul > li > a:hover { - color:#79ACCD; - } - </style> -<!--<script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/2.0.3/jquery.min.js"></script>!--> -<script type="text/javascript" src="./sha.js"></script> -<script type="text/javascript"> -window.setTimeout("reload_timeout()", 295000); -function reload_timeout() { -var token = document.getElementById('token').innerHTML; -self.location.href='./del_token.php?token='+token; -} -function go() { -var token = document.getElementById('token').innerHTML; -var username = document.getElementById('username').value; -var passwd = document.getElementById('passwd').value; -var shaObj = new jsSHA(passwd+username, "TEXT"); -var hash = shaObj.getHash("SHA-512", "HEX"); -//document.write(hash); -var shaObj1 = new jsSHA(hash+token, "TEXT"); -var hash = shaObj1.getHash("SHA-512", "HEX"); -//document.write('<br/>'); -//document.write(hash); -var anfragestr = './login_handling.php?username='+username+'&token='+token+'&hash='+hash; -self.location.href=anfragestr; -} - -</script> - </head>