Inheritance: extends TuduX_Controller_OpenApi
コード例 #1
0
 /**
  *	Handles input, by calling according controller,
  *	an sets view depending on url.
  *	@return void
  */
 public function handleInput()
 {
     //Create database, get content catalog
     $db = new Database();
     $contentDAL = new contentDAL($db);
     $Catalog = new contentCatalog();
     $contentController = new ContentController($contentDAL, $Catalog);
     $contentCatalog = $contentController->getContent();
     //Handle login
     if ($this->navigationView->wantsToLogin()) {
         $login = new LoginController($this->users, $this->navigationView);
         $this->IsLoggedIn = $login->doLogin();
         if ($this->IsLoggedIn) {
             $this->navigationView->redirToAdmin();
         } else {
             $this->view = $login->getOutPut();
         }
     } else {
         if ($this->navigationView->wantsToUpload() && isset($_SESSION['user'])) {
             $this->view = new AdminView();
             $uploadController = new uploadController($this->view, $contentDAL, $this->users);
             $uploadController->doUpload();
         } else {
             if ($this->navigationView->wantsToReg()) {
                 $model = new RegFacade($this->userDAL);
                 $this->view = new RegView($this->navigationView);
                 $regControl = new RegisterController($model, $this->view);
                 $regControl->addUser();
                 $this->view = new RegView($this->navigationView);
             } else {
                 if ($this->navigationView->wantsToViewImage()) {
                     $this->view = new ImageView();
                     $imgController = new ImageController($this->view, $contentCatalog);
                     $imgController->getImage();
                 } else {
                     if ($this->navigationView->wantsToViewContent()) {
                         $commentView = new commentView();
                         $this->view = new ContentView($commentView);
                         $id = $this->view->getID();
                         $commentDAL = new commentDAL($db);
                         $commentController = new CommentController($commentView, $commentDAL);
                         $comments = $commentController->doComment($id);
                         $content = $contentController->getContentByID($id);
                         $this->view->createHTML($content, $comments);
                     } else {
                         $this->view = new galleryView();
                         $galController = new GalleryController($this->view);
                         $galController->doGallery($contentCatalog);
                     }
                 }
             }
         }
     }
 }
コード例 #2
0
ファイル: Image.php プロジェクト: elminero/contact_v1.1
 private function setImageParam(ImageController $image)
 {
     $this->_id = $image->getId();
     $this->_personId = $image->getPersonId();
     $this->_pathFile = $image->getPathFile();
     $this->_caption = $image->getCaption();
     $this->_avatar = $image->getAvatar();
     $this->_visible = $image->getVisible();
 }
コード例 #3
0
 * Created by PhpStorm.
 * User: Haziq
 * Date: 1/5/2016
 * Time: 11:50 AM
 */
require_once $_SERVER['DOCUMENT_ROOT'] . '/matrimonialweb/Controller/ImageController.php';
$data = array();
$allowed = array('image/pjpeg', 'image/jpeg', 'image/JPG', 'image/X-PNG', 'image/PNG', 'image/png', 'image/x-png');
if (isset($_FILES['images'])) {
    //check valid extensions
    if (in_array($_FILES['images']['type'], $allowed)) {
        //get image size
        $size = $_FILES['images']['size'];
        $size = $size / 1024 / 1024;
        if ($size <= 10) {
            //get image blob to store in the database
            $binary = file_get_contents($_FILES['images']['tmp_name']);
            $Object = new ImageController();
            $data = $Object->uploadImage($binary);
        } else {
            $message = "Image size should not exceed 10 MB";
            array_push($data, ["Status" => "error", "Message" => $message]);
        }
    } else {
        $message = "Incorrect image format. Allowed extensions are  \n  jpeg, png, png";
        array_push($data, ["Status" => "error", "Message" => $message]);
    }
} else {
    array_push($data, ["Status" => "error", "Message" => "some error occurred"]);
}
echo json_encode($data);
コード例 #4
0
ファイル: CastVote.php プロジェクト: tinggao/woofWarrior
<?php

/**
 * Created by PhpStorm.
 * User: Haziq
 * Date: 10/27/2015
 * Time: 1:48 PM
 */
require_once $_SERVER['DOCUMENT_ROOT'] . '/WoofWorrior/ControllerClasses/ImageController.php';
session_start();
$status = array();
if (isset($_POST['image']) && !empty($_SESSION['id'])) {
    $imageID = $_POST['image'];
    //echo 'ID: ' . $imageID . '<br/>';
    //calling the reference class
    $Object = new ImageController();
    $result = $Object->castVote($imageID, $_SESSION['id']);
    echo json_encode($result);
} else {
    array_push($status, ["Status" => "error", "Message" => "Input was empty or not in correct format"]);
    echo json_encode($status);
}
コード例 #5
0
     $avatar = 0;
 }
 if (!isset($_FILES['file']['name'])) {
     $_FILES['file']['name'] = null;
 }
 if (!isset($_FILES['file']['tmp_name'])) {
     $_FILES['file']['tmp_name'] = null;
 }
 if (!isset($_FILES['file']['size'])) {
     $_FILES['file']['size'] = null;
 }
 if (!isset($_FILES['file']['type'])) {
     $_FILES['file']['type'] = null;
 }
 // $id, $personId, $caption, $avatar, $fileName, $fileType, $fileTmpName, $fileSize
 $cImage = new ImageController((int) $_POST['id'], $_POST['personId'], $_POST['caption'], $avatar, $_FILES['file']['name'], $_FILES['file']['type'], $_FILES['file']['tmp_name'], $_FILES['file']['size']);
 //
 //  if( ($cImage->imageFieldValidate()->$validate['jpeg'] == 1)  && ($cImage->imageFieldValidate()->$validate == 1)  ) {
 if (isset($_GET['action']) && $_GET['action'] === 'create') {
     $validate = $cImage->imageFieldValidate();
     if ($validate['jpeg'] === 1 && $validate['fileSize'] === 1) {
         $cImage->upload($cImage);
         header("Location: ../addphotos.php?id=" . $_POST['personId'] . "&action=update");
     } else {
         header("Location: ../addphotos.php?id=" . $_POST['personId'] . "&validate=error&action=update");
     }
 }
 if (isset($_GET['action']) && $_GET['action'] === 'update') {
     $model = new ImagePDO();
     $model->updateById($cImage);
     header("Location: ../editphotos.php?id=" . $_POST['personId'] . "&action=update");
コード例 #6
0
ファイル: Editor.php プロジェクト: Flasheur111/420px
<?php

/**
 * Created by PhpStorm.
 * User: Francois
 * Date: 07/05/15
 * Time: 02:11
 */
include_once '../controller/ImageController.php';
$image_controller = new ImageController();
include_once '../controller/UserController.php';
$user_controller = new UserController();
if (isset($_POST['q'])) {
    $path = htmlspecialchars($_POST['q']);
    if (isset($_POST['action'])) {
        $action = htmlspecialchars($_POST['action']);
        if ($action == "lesscontrast") {
            $image_controller->contrastImage(false, $path);
        } else {
            if ($action == "morecontrast") {
                $image_controller->contrastImage(true, $path);
            } else {
                if ($action == "lessluminosity") {
                    $image_controller->brightnessImage(false, $path);
                } else {
                    if ($action == "moreluminosity") {
                        $image_controller->brightnessImage(true, $path);
                    } else {
                        if ($action == "sepia") {
                            $image_controller->sepiaImage($path);
                        } else {
コード例 #7
0
ファイル: Upload.php プロジェクト: Flasheur111/420px
<?php

include '../controller/ImageController.php';
$upload = new ImageController();
if (isset($_FILES["fileToUpload"]) && isset($_SESSION["user"])) {
    $target_dir = "../uploads/";
    $target_file = $target_dir . $_SESSION["user"] . '-' . basename($_FILES["fileToUpload"]["name"]);
    $uploadOk = 1;
    $imageFileType = pathinfo($target_file, PATHINFO_EXTENSION);
    $error = "";
    if (isset($_POST["submit"]) && isset($_POST["fileToUpload"]["tmp_name"])) {
        $check = getimagesize($_FILES["fileToUpload"]["tmp_name"]);
        if ($check != false) {
            $uploadOk = 1;
        } else {
            $error = "File is not an image.";
            $uploadOk = 0;
        }
    }
    if ($error == "" && file_exists($target_file)) {
        $error = "Sorry, file already exists.";
        $uploadOk = 0;
    }
    if ($error == "" && $_FILES["fileToUpload"]["size"] > 1000000) {
        $error = "Sorry, your file is too large.";
        $uploadOk = 0;
    }
    if ($error == "" && $imageFileType != "jpg" && $imageFileType != "png" && $imageFileType != "jpeg" && $imageFileType != "gif") {
        $error = "Sorry, only JPG, JPEG, PNG & GIF files are allowed.";
        $uploadOk = 0;
    }
コード例 #8
0
ファイル: admin.php プロジェクト: johnforte/phpcodingexercise
<?php

$images = ImageController::getAllImages();
?>
<html>
<head>
</head>
<body>
<?php 
foreach ($images as &$image) {
    ?>
<div>
<p><?php 
    echo $image->getOwner()->getEmail();
    ?>
</p>
<img src="<?php 
    echo $image->getImageFilePath();
    ?>
" />
</div>
<?php 
}
?>
</body>
</html>
コード例 #9
0
ファイル: routes.php プロジェクト: hyttijan/MyImgur
    View::make("image.html", $content);
});
$routes->get('/uploadImage', function () {
    View::make('uploadImage.html');
});
$routes->post('/comment', function () {
    $params = $_POST;
    $content = CommentController::add($params);
    BaseController::set_flash($content);
    var_dump($params);
    Redirect::to("/image-" . $params["image"]);
});
$routes->post('/uploadImage', function () use($routes) {
    $params = $_POST;
    $fileparams = $_FILES;
    $content = ImageController::uploadImage($params, $fileparams);
    BaseController::set_flash($content);
    if (!array_key_exists("errors", $content)) {
        Redirect::to("/");
    } else {
        Redirect::to("/uploadImage");
    }
});
$routes->post('/deleteImage', function () {
    $params = $_POST;
    $array = array();
    $array[] = $params["imageId"];
    $content = ImageController::deleteImages($array);
    BaseController::set_flash($content);
    Redirect::to("/");
});
コード例 #10
0
ファイル: OtherImage.php プロジェクト: Flasheur111/420px
<?php

include_once '../controller/ImageController.php';
$upload = new ImageController();
include_once '../controller/UserController.php';
$reg = new UserController();
include_once '../controller/RssController.php';
$rss = new RssController();
/**
 * Created by PhpStorm.
 * User: Francois
 * Date: 27/04/15
 * Time: 01:30
 */
$value = "";
if (isset($_POST["q"])) {
    $value = htmlspecialchars($_POST["q"]);
} else {
    if (isset($_GET["q"])) {
        $value = htmlspecialchars($_GET["q"]);
    }
}
if ($value != "" && $reg->checkUserExist($value)) {
    $xml_file = new DOMDocument("1.0");
    $channel = $rss->init_news_rss($xml_file, $value);
    $stack = $upload->listImage($value);
    $id = 0;
    foreach ($stack as &$img) {
        $rss->addItem($xml_file, $channel, $id, $value, $img);
        $id++;
    }
コード例 #11
0
ファイル: UserVotes.php プロジェクト: tinggao/woofWarrior
<?php

/**
 * Created by PhpStorm.
 * User: Haziq
 * Date: 11/2/2015
 * Time: 12:29 PM
 */
//error_reporting(0);
require_once $_SERVER['DOCUMENT_ROOT'] . '/WoofWorrior/ControllerClasses/ImageController.php';
session_start();
if (!empty($_SESSION['id'])) {
    $Object = new ImageController();
    $data = $Object->getUserVotes($_SESSION['id']);
    echo json_encode($data);
} else {
    $array = array();
    array_push($array, ["Status" => "error", "Message" => "Session is not recorded"]);
    echo json_encode($array);
}
コード例 #12
0
ファイル: Upload.php プロジェクト: tinggao/woofWarrior
$status = array();
$allowed = array('image/pjpeg', 'image/jpeg', 'image/JPG', 'image/X-PNG', 'image/PNG', 'image/png', 'image/x-png');
require_once $_SERVER['DOCUMENT_ROOT'] . '/WoofWorrior/ControllerClasses/ImageController.php';
if (in_array($_FILES['images']['type'], $allowed)) {
    //calculate size
    $size = $_FILES['images']['size'];
    $size = $size / 1024 / 1024;
    if ($size <= 10) {
        $tmp = $_FILES['images']['tmp_name'];
        $dir = $_SERVER['DOCUMENT_ROOT'] . '/WoofWorrior/Gallery';
        $dir = $dir . '/' . $_SESSION['name'];
        $dir = $dir . '/' . $_FILES['images']['name'];
        //move the file to the user directory
        if (move_uploaded_file($tmp, $dir)) {
            chmod($dir, 0755);
            $Object = new ImageController();
            $result = $Object->uploadImage($dir, $_SESSION['id'], 'Testing');
            echo json_encode($result);
        } else {
            array_push($status, ["Status" => "error", "Message" => "Uploading error occurred during transfer"]);
            echo json_encode($status);
        }
    } else {
        array_push($status, ["Status" => "error", "Message" => "Maximum file size allowed is 10MB"]);
        echo json_encode($status);
    }
} else {
    array_push($status, ["Status" => "error", "Message" => "Upload file should be image format"]);
    echo json_encode($status);
}
if ($_FILES['images']['error'] > 0) {
コード例 #13
0
ファイル: Colors.php プロジェクト: Flasheur111/420px
<?php

/**
 * Created by PhpStorm.
 * User: Francois
 * Date: 07/05/15
 * Time: 02:11
 */
include_once '../controller/ImageController.php';
$image_controller = new ImageController();
include_once '../controller/UserController.php';
$user_controller = new UserController();
if (isset($_POST['q'])) {
    $colors = htmlspecialchars($_POST['q']);
    $stack = $image_controller->compareWithOtherImages($colors);
    echo '<h1> Color major near : ' . $_POST['q'] . '</h1>';
    foreach ($stack as &$row) {
        echo '<div class="col-lg-3 col-md-4 col-xs-6">
                <div class="thumbnail">
                        <a href="../uploads/' . $row[4] . '">
                            <img class="img-responsive" src="../uploads/' . $row[4] . '"/>
                        </a>
                </div>
          </div>';
        /*echo "User : " . $row[0] . '</br>' .
          'Last edit : ' . $row[1] . '</br>' .
          'Main color : ' . $row[2] . '</br>' .
          'Difference : ' . $row[3] . '</br>' .
          'Path : ' . $row[4] . '</br>';*/
    }
}
コード例 #14
0
ファイル: index.php プロジェクト: hyttijan/MyImgur
ini_set('display_startup_errors', 1);
error_reporting(-1);
if (session_id() == '') {
    session_start();
}
require "Database.php";
Database::connect();
require "controllers/BaseController.php";
require "models/BaseModel.php";
require "controllers/UserController.php";
require "models/User.php";
require "controllers/ImageController.php";
require "models/Image.php";
require "controllers/CommentController.php";
require "models/Comment.php";
require "redirect.php";
require 'vendor/autoload.php';
require "View.php";
if (ImageController::isImageDirectoryEmpty()) {
    $connection = Database::connect();
    $query = "DELETE FROM images";
    $statement = $connection->prepare($query);
    $statement->execute();
    $query = "DELETE FROM comments";
    $statement = $connection->prepare($query);
    $statement->execute();
}
$routes = new \Slim\Slim();
$routes->config('debug', true);
require 'routes.php';
$routes->run();
コード例 #15
0
ファイル: UserImage.php プロジェクト: Flasheur111/420px
<?php

include '../controller/ImageController.php';
$upload = new ImageController();
/**
 * Created by PhpStorm.
 * User: Francois
 * Date: 27/04/15
 * Time: 01:30
 */
if (isset($_POST["removeImage"]) && isset($_SESSION["user"])) {
    $path_remove = $_POST["removeImage"];
    $upload->deleteImage($_SESSION["user"], $path_remove);
}
echo '<div class="col-lg-12">
        <h1 class="page-header"> ' . $_SESSION["user"] . '\'s Gallery </h1>
      </div>';
$stack = $upload->listImage($_SESSION["user"]);
foreach ($stack as &$value) {
    echo '<div class="col-lg-3 col-md-4 col-xs-6">
                <div class="thumbnail">
                        <a href="../uploads/' . $value . '">
                            <img class="img-responsive" src="../uploads/' . $value . '?' . rand() . '"/>
                        </a>
                        <div class="section">
                            <form method="post" id="form_force" action="layout.php?selected=Editor">
                                    <button type="submit" class="btn btn-success btn-md" name="q" value="' . $value . '">
                                        <span class="glyphicon glyphicon-edit" aria-hidden="true"></span> Edit
                                    </button>
                            </form>
                            <form method="post" id="form_force" action="layout.php?selected=UserImage">
コード例 #16
0
ファイル: GetImages.php プロジェクト: tinggao/woofWarrior
<?php

/**
 * Created by PhpStorm.
 * User: Haziq
 * Date: 10/21/2015
 * Time: 12:39 PM
 */
//error_reporting(0);
require_once $_SERVER['DOCUMENT_ROOT'] . '/WoofWorrior/ControllerClasses/ImageController.php';
$Object = new ImageController();
$Data = $Object->getAllImages();
//echo json_encode($Data);
if ($Data[0]['Status'] == 'ok') {
    //echo json_encode(print_r($Data));
    echo json_encode($Data);
    /*
     $Object = new ValidatingPermissions();
     if($Object->revive($Data))
     {
         echo json_encode($Object->getData());
     }
    
    else
    {
        echo json_encode($Object->getStatus());
    }
    */
} else {
    echo json_encode($Data);
    //echo json_encode($Data);
コード例 #17
0
ファイル: index.php プロジェクト: johnforte/phpcodingexercise
        } else {
            if ($request == "login") {
                include __DIR__ . '/../controllers/login.php';
                $user = LoginController::LoginUser($_POST['email'], $_POST['password']);
                if ($user != null) {
                    $_SESSION['User'] = $user;
                    header("Location: dashboard");
                }
            } else {
                if ($request == "register") {
                    include __DIR__ . '/../controllers/register.php';
                    RegisterController::createUser($_POST['email'], $_POST['password1']);
                    header("Location: index");
                } else {
                    if ($request == "delete" && isset($_SESSION['User'])) {
                        include __DIR__ . '/../models/Image.php';
                        include __DIR__ . '/../controllers/images.php';
                        ImageController::DeleteImage($_SESSION['User']->getID(), $_POST['imageid']);
                        header("Location: dashboard");
                    } else {
                        if (isset($_SESSION['User'])) {
                            header("Location: dashboard");
                        } else {
                            include __DIR__ . '/../views/frontpage.php';
                        }
                    }
                }
            }
        }
    }
}
コード例 #18
0
<?php

$images = ImageController::getUsersImages($_SESSION['User']->getID());
?>
<html>
<head>
</head>
<body>
<p>Currently Logged in as <?php 
echo $_SESSION['User']->getUsername();
?>
</p>
<div>
<h3>Upload Image</h3>
<form action="upload" method="post" enctype="multipart/form-data">
<p>Image <input type="file" name="image" /></p>
<button type="submit" name="upload">Upload</button>
</form>
</div>
<div>
<?php 
foreach ($images as &$image) {
    ?>
<div>
<img src="<?php 
    echo $image->getImageFilePath();
    ?>
" />
<form method="post" action="delete">
<input type="hidden" name="imageid" value="<?php 
    echo $image->getID();