Example #1
0
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.
**/
require_once 'Auth.php';
$auth = new Auth();
try {
    $auth->authenticate();
    require_once 'Comment.php';
    require_once 'Media.php';
    require_once 'Posts.php';
    require_once 'Profile.php';
    require_once 'Skillet.php';
    require_once 'Utils.php';
    if (isset($_GET["get"]) && $_GET["get"] == "posts") {
        $posts = new Posts($auth);
        $posts->getPosts();
        print $posts->printOutput();
    } else {
        if (isset($_GET["get"]) && $_GET["get"] == "media") {
            $media = new Media($auth);
            $media->getMedia();
            print $media->printOutput();
        } else {
            if (isset($_POST['changepass'])) {
                $auth->changePassword();
                print $auth->printOutput();
            } else {
                if (isset($_POST["comment"])) {
                    $posts = new Posts($auth);
                    $posts->post();
                    print $posts->printOutput();
Example #2
0
 public function setMainImage($image, $id, $overwrite)
 {
     $grldPosts = new Posts($this->auth, $id);
     $grldPosts->getPosts();
     $output = $grldPosts->getOutput();
     $post = $output["msg"]["posts"][0];
     //var_dump($grldPosts->printOutput());
     if ($post["image"] == null || $overwrite == true) {
         $stmt = $this->getDb()->prepare("update contents set\n\t\t\t\timage=:image \n\t\t\t\twhere id=:id");
         $stmt->bindValue(':image', $id . "/img_profile_" . $image . ".jpeg", PDO::PARAM_STR);
         $stmt->bindValue(':id', intval($id), PDO::PARAM_INT);
         $stmt->execute();
         $this->setOutput(self::$SUCCESS, "Set main image: " . $image);
     }
 }
Example #3
0
<?php

include 'conf/conf.php';
$obj = new Posts();
$postsPDO = $obj->getPosts();
$posts = array();
foreach ($postsPDO as $key => $value) {
    $posts[$key]['id'] = $value['id'];
    $posts[$key]['title'] = $value['title'];
    $posts[$key]['content'] = $value['content'];
}
// pr($posts);
?>

<DOCTYPE! html>
<html>
  <head>
    <meta charset="utf-8">
    <title>Interacting With Database</title>
  </head>

  <body>
    <h1 style="text-align:center">Blog</h1>

    <h2>Post</h2>
    <form action="formcontroller.php" method="POST">
      Title:<br>
      <input type="text" name="post_title" size="102"><br>
      Content:<br>
      <textarea name="post_content" rows="20" cols="100"></textarea>
      <br>
Example #4
0
<?php

include 'conf/conf.php';
$id = $_GET["id"];
$data["condition"] = "id = {$id}";
$obj = new Posts();
$postsPDO = $obj->getPosts($data);
foreach ($postsPDO as $key => $value) {
    $posts[$key]['id'] = $value['id'];
    $posts[$key]['title'] = $value['title'];
    $posts[$key]['content'] = $value['content'];
}
$post = reset($posts);
?>
<!DOCTYPE html>
<html>
  <head>
    <meta charset="utf-8">
    <title></title>
  </head>
  <body>
    <h1><?php 
echo $post['title'];
?>
</h1>
    <p><?php 
echo $post['content'];
?>
</p>
    <a href="index.php">Back</a>
  </body>