Example #1
0
 public function getRowHeight()
 {
     if (isset(self::$row_height)) {
         return self::$row_height;
     }
     $preset_small = array('width' => 160, 'height' => 160);
     if (!empty($this->options['preset_small'])) {
         $preset_small = cmsCore::getModel('images')->getPresetByName($this->options['preset_small']);
     }
     self::$row_height = $preset_small['height'] ? $preset_small['height'] : $preset_small['width'];
     self::$preset_small = $preset_small['name'];
     return self::$row_height;
 }
    $notImage = false;
    //Change the name of the extention to store on the server so it can be found by the users
    $extention = ".jpg";
} else {
    if ($extention === "image/png") {
        $notImage = false;
        $extention = ".png";
    }
}
if (!$notImage) {
    //We should get the extention here with php, after the file is working directly with server side code.
    //$extention = $_POST['extention'];
    //Get file that is being uploaded
    /*
     */
    $photoUpload = new photos();
    // $pPhoto->description,$pPhoto->idUsr,$pPhoto->nameCat
    $photoUpload->description = $description;
    $photoUpload->idUsr = $idUser;
    $photoUpload->nameCat = $nameCat;
    $photoUpload->extention = $extention;
    $uploadSuccess = $photoUpload->uploadPhotos($photoUpload);
    if ($uploadSuccess != 0) {
        $uploadReturn['success'] = True;
        //Used to rename the uploaded file and store onto server within its category folder.
        $uploadReturn['photoId'] = $uploadSuccess;
    }
    //Get last inserted Id to upload the image onto the server with its corresponding category
    move_uploaded_file($_FILES['file']['tmp_name'], '../../categories/' . $nameCat . '/' . $uploadReturn['photoId'] . $extention);
}
echo json_encode($uploadReturn);
Example #3
0
/**
* controller
*
* @author     Dac Chartrand <*****@*****.**>
* @license    http://www.fsf.org/licensing/licenses/gpl-3.0.html
*/
function sux($action, $params = null)
{
    switch ($action) {
        case 'admin':
            // --------------------------------------------------------------------
            // Admin
            // --------------------------------------------------------------------
            $admin = new photosAdmin();
            if ($admin->formValidate($_POST)) {
                $admin->formProcess($_POST);
                $admin->formSuccess();
            } else {
                $admin->formBuild($_POST);
            }
            break;
        case 'view':
            // --------------------------------------------------------------------
            // View
            // --------------------------------------------------------------------
            if (empty($params[0]) || !filter_var($params[0], FILTER_VALIDATE_INT) || $params[0] < 1) {
                suxFunct::redirect(suxFunct::makeUrl('/photos'));
            }
            $photos = new photos();
            $photos->view($params[0]);
            break;
        case 'upload':
            // --------------------------------------------------------------------
            // Upload
            // --------------------------------------------------------------------
            $edit = new photosUpload(@$params[0]);
            if ($edit->formValidate($_POST)) {
                $edit->formProcess($_POST);
                $edit->formSuccess();
            } else {
                $edit->formBuild($_POST);
            }
            break;
        case 'album':
            // --------------------------------------------------------------------
            // Edit
            // --------------------------------------------------------------------
            if ($params[0] == 'edit') {
                $id = !empty($params[1]) ? $params[1] : null;
                $edit = new photoalbumsEdit($id);
                if ($edit->formValidate($_POST)) {
                    $edit->formProcess($_POST);
                    $edit->formSuccess();
                } else {
                    $edit->formBuild($_POST);
                }
                break;
            } elseif ($params[0] == 'annotate') {
                if (empty($params[1]) || !filter_var($params[1], FILTER_VALIDATE_INT) || $params[1] < 1) {
                    suxFunct::redirect(suxFunct::makeUrl('/photos'));
                }
                $edit = new photosEdit($params[1]);
                if ($edit->formValidate($_POST)) {
                    $edit->formProcess($_POST);
                    $edit->formSuccess();
                } else {
                    $edit->formBuild($_POST);
                }
                break;
            } else {
                if (empty($params[0]) || !filter_var($params[0], FILTER_VALIDATE_INT) || $params[0] < 1) {
                    suxFunct::redirect(suxFunct::makeUrl('/photos'));
                }
                $photos = new photos();
                $photos->album($params[0]);
                break;
            }
        case 'user':
            // --------------------------------------------------------------------
            // User
            // --------------------------------------------------------------------
            if (empty($params[0])) {
                suxFunct::redirect(suxFunct::makeUrl('/photos'));
            }
            $photos = new photos();
            $photos->listing($params[0]);
            break;
        case 'rss':
            // --------------------------------------------------------------------
            // RSS
            // --------------------------------------------------------------------
            $photos = new photos();
            $photos->rss();
            break;
        default:
            $photos = new photos();
            $photos->listing();
            break;
    }
}
 * qascript@ifsoft.co.uk
 *
 * Copyright 2012-2016 Demyanchuk Dmitry (https://vk.com/dmitry.demyanchuk)
 */
include_once $_SERVER['DOCUMENT_ROOT'] . "/core/init.inc.php";
include_once $_SERVER['DOCUMENT_ROOT'] . "/config/api.inc.php";
if (!empty($_POST)) {
    $clientId = isset($_POST['clientId']) ? $_POST['clientId'] : 0;
    $accountId = isset($_POST['accountId']) ? $_POST['accountId'] : 0;
    $accessToken = isset($_POST['accessToken']) ? $_POST['accessToken'] : '';
    $profileId = isset($_POST['profileId']) ? $_POST['profileId'] : 0;
    $photoId = isset($_POST['photoId']) ? $_POST['photoId'] : 0;
    $clientId = helper::clearInt($clientId);
    $accountId = helper::clearInt($accountId);
    $profileId = helper::clearInt($profileId);
    $photoId = helper::clearInt($photoId);
    $result = array("error" => true, "error_code" => ERROR_UNKNOWN);
    $auth = new auth($dbo);
    if (!$auth->authorize($accountId, $accessToken)) {
        api::printError(ERROR_ACCESS_TOKEN, "Error authorization.");
    }
    $photos = new photos($dbo);
    $photos->setRequestFrom($accountId);
    $accessMode = 0;
    if ($accountId == $profileId) {
        $accessMode = 1;
    }
    $result = $photos->get($profileId, $photoId, $accessMode);
    echo json_encode($result);
    exit;
}
<?php

/*!
 * ifsoft.co.uk engine v1.0
 *
 * http://ifsoft.com.ua, http://ifsoft.co.uk
 * qascript@ifsoft.co.uk
 *
 * Copyright 2012-2016 Demyanchuk Dmitry (https://vk.com/dmitry.demyanchuk)
 */
include_once $_SERVER['DOCUMENT_ROOT'] . "/core/init.inc.php";
include_once $_SERVER['DOCUMENT_ROOT'] . "/config/api.inc.php";
if (!empty($_POST)) {
    $clientId = isset($_POST['clientId']) ? $_POST['clientId'] : 0;
    $accountId = isset($_POST['accountId']) ? $_POST['accountId'] : 0;
    $accessToken = isset($_POST['accessToken']) ? $_POST['accessToken'] : '';
    $photoId = isset($_POST['photoId']) ? $_POST['photoId'] : 0;
    $clientId = helper::clearInt($clientId);
    $accountId = helper::clearInt($accountId);
    $photoId = helper::clearInt($photoId);
    $result = array("error" => true, "error_code" => ERROR_UNKNOWN);
    $auth = new auth($dbo);
    if (!$auth->authorize($accountId, $accessToken)) {
        api::printError(ERROR_ACCESS_TOKEN, "Error authorization.");
    }
    $photos = new photos($dbo);
    $photos->setRequestFrom($accountId);
    $result = $photos->remove($photoId);
    echo json_encode($result);
    exit;
}
<?php

/*
	Returns an array with all of the users in the program.
		Information retured:
			-idUsr
			-nameUsr
			-eMail
			-roleUsr
*/
header('Content-Type: application/json');
require '../class.photos.inc';
$allPhotos = photos::allPhotos();
//Return for jason to work with
echo json_encode($allPhotos);
    $accessMode = isset($_POST['accessMode']) ? $_POST['accessMode'] : 0;
    $comment = isset($_POST['comment']) ? $_POST['comment'] : "";
    $originImgUrl = isset($_POST['originImgUrl']) ? $_POST['originImgUrl'] : "";
    $previewImgUrl = isset($_POST['previewImgUrl']) ? $_POST['previewImgUrl'] : "";
    $imgUrl = isset($_POST['imgUrl']) ? $_POST['imgUrl'] : "";
    $clientId = helper::clearInt($clientId);
    $accountId = helper::clearInt($accountId);
    $accessMode = helper::clearInt($accessMode);
    $comment = helper::clearText($comment);
    $comment = preg_replace("/[\r\n]+/", "<br>", $comment);
    //replace all new lines to one new line
    $comment = preg_replace('/\\s+/', ' ', $comment);
    //replace all white spaces to one space
    $comment = helper::escapeText($comment);
    $originImgUrl = helper::clearText($originImgUrl);
    $originImgUrl = helper::escapeText($originImgUrl);
    $previewImgUrl = helper::clearText($previewImgUrl);
    $previewImgUrl = helper::escapeText($previewImgUrl);
    $imgUrl = helper::clearText($imgUrl);
    $imgUrl = helper::escapeText($imgUrl);
    $result = array("error" => true, "error_code" => ERROR_UNKNOWN);
    $auth = new auth($dbo);
    if (!$auth->authorize($accountId, $accessToken)) {
        api::printError(ERROR_ACCESS_TOKEN, "Error authorization.");
    }
    $photos = new photos($dbo);
    $photos->setRequestFrom($accountId);
    $result = $photos->add($accessMode, $comment, $originImgUrl, $previewImgUrl, $imgUrl);
    echo json_encode($result);
    exit;
}
<?php

/*
	Deletes the user with the userId that is passed
		Should be used by admin to controll users and by users themselves to eliminate their account.
*/
header('Content-Type: application/json');
require '../class.photos.inc';
// GET The info from POST called by Ajax method
$idPhoto = $_POST['idPhoto'];
$photo = new photos();
$photo->idPhoto = $idPhoto;
//Calls method to store users onto the database and Returns 1 if the the user was stored and 0 if the user could not be stored
$photoDelete = $photo->deletePhoto($photo);
$returnDelete = array('success' => false);
$retornoEjecucion = array();
$retornoEjecucion = array('idPhoto' => 0);
foreach ($photoDelete as $p => $photo) {
    $retornoEjecucion = $photo;
}
//We check if the image exists and once it is deleted we delete it from the server.
if ($retornoEjecucion['idPhoto'] != 0) {
    unlink('../../categories/' . $retornoEjecucion['nameCat'] . '/' . $retornoEjecucion['idPhoto'] . $retornoEjecucion['extention']);
    $returnDelete['success'] = true;
}
echo json_encode($returnDelete);
Example #9
-1
/*!
 * ifsoft.co.uk engine v1.0
 *
 * http://ifsoft.com.ua, http://ifsoft.co.uk
 * qascript@ifsoft.co.uk
 *
 * Copyright 2012-2016 Demyanchuk Dmitry (https://vk.com/dmitry.demyanchuk)
 */
include_once $_SERVER['DOCUMENT_ROOT'] . "/core/init.inc.php";
if (!admin::isSession()) {
    header("Location: /admin/login.php");
}
$stats = new stats($dbo);
$admin = new admin($dbo);
$report = new report($dbo);
$photoId = 0;
$photoInfo = array();
if (isset($_GET['id'])) {
    $photoId = isset($_GET['id']) ? $_GET['id'] : 0;
    $accessToken = isset($_GET['access_token']) ? $_GET['access_token'] : '';
    $fromUserId = isset($_GET['fromUserId']) ? $_GET['fromUserId'] : 0;
    $photoId = helper::clearInt($photoId);
    $fromUserId = helper::clearInt($fromUserId);
    $photos = new photos($dbo);
    $photos->setRequestFrom($fromUserId);
    $photos->remove($photoId);
    $report->removePhotoReports($photoId);
} else {
    header("Location: /admin/main.php");
    exit;
}