Ejemplo n.º 1
0
function NP_UTF8_decode($obj)
{
    if (gettype($obj) == "array") {
        foreach ($obj as $k => $v) {
            $obj[$k] = NP_UTF8_decode($v);
        }
    } else {
        if (gettype($obj) == "object") {
            foreach (get_object_vars($obj) as $k => $v) {
                $obj->{$k} = NP_UTF8_decode($v);
            }
        }
    }
    if (gettype($obj) == "string") {
        return utf8_decode($obj);
    } else {
        return $obj;
    }
}
Ejemplo n.º 2
0
<?php

global $NPADMIN_REL_PATH;
$NPADMIN_REL_PATH = "../";
require_once "../common.php";
$_POST = NP_UTF8_decode($_POST);
$userId = npadmin_loginData()->getUser()->userId;
$contestId = $_POST['contest_id'] !== null ? $_POST['contest_id'] : $_GET['contest_id'];
$contest = Contest::loadContest($contestId);
npadmin_security($contest->getAllowedGroups(), false, _("You are not invited to this contest") . " (ID: " . $contestId . ")", true);
if ($_POST['op'] == 'upload') {
    if ($_FILES['photoFile']['error'] === 0) {
        if ($contest->status === STATUS_OPEN) {
            $photos = $contest->photosOfUser($userId);
            if (count($photos) < $contest->numberPhotos) {
                $photo = new Photo();
                $photo->userId = $userId;
                $photo->contestId = $contestId;
                $photo->title = $_POST['title'];
                $photo->description = $_POST['description'];
                $photo->exif = read_exif_data($_FILES['photoFile']['tmp_name']);
                if ($photo->store()) {
                    $photo_filename = "../" . $photo->getUrl();
                    $photo_filename_thumb = "../" . $photo->getThumbUrl();
                    if (move_uploaded_file($_FILES['photoFile']['tmp_name'], $photo_filename)) {
                        $image = new NP_Image($photo_filename);
                        $image_resized = $image->resizeMaxSize(1024);
                        $image_resized->save($photo_filename);
                        $image_thumb = $image->resizeMaxSize(240);
                        if ($image_thumb->save($photo_filename_thumb)) {
                            echo "OK: " . $photo_filename;