Esempio n. 1
0
<?php

use Enpowi\App;
use Enpowi\Modules\DataIn;
use Enpowi\Types;
use Enpowi\Modules\Module;
Module::is();
$post = Types::Blog_Post((new DataIn())->in('post'));
$post->bean();
$user = App::user();
if ($user->hasPerm('*', '*') || $post->user()->email === $user->email) {
    $post->replace(App::param('content'));
    echo 1;
} else {
    echo -1;
}
Esempio n. 2
0
<?php

use Enpowi\App;
use Enpowi\Modules\Module;
use Enpowi\Files\Gallery;
use Enpowi\Types;
Module::is();
$galleryId = App::paramInt('g');
$gallery = new Gallery($galleryId);
if ($gallery->exists()) {
    $images = App::paramFiles('files', 'Enpowi\\Files\\Image');
    foreach ($images as $i => $_image) {
        $image = Types::Files_Image($_image);
        if ($image->upload()) {
            $gallery->addImage($image);
        } else {
            echo -1;
            die;
        }
    }
    $gallery->save();
    echo 1;
} else {
    echo -1;
}
Esempio n. 3
0
<?php

use Enpowi\App;
use Enpowi\Files\Image;
use Enpowi\Modules\Module;
Module::is();
$image = \Enpowi\Types::Files_Image(Image::getFromHash(App::param('image')));
if ($image !== null && $image->inShare()) {
    if (App::paramIs('thumb')) {
        echo $image->toThumbString();
    } else {
        echo $image->toString();
    }
}
Esempio n. 4
0
<?php

use Enpowi\App;
use Enpowi\Types;
use Enpowi\Modules\DataIn;
use Enpowi\Users\User;
use Enpowi\Modules\Module;
Module::is();
if (!isset($user)) {
    $user = App::user();
}
$_user = Types::Users_User((new DataIn())->in('user'));
$password = App::param('password');
$passwordRepeat = App::param('passwordRepeat');
$update = App::paramBool('update');
$stopEmail = false;
$stopPassword = false;
if (empty($password)) {
    $stopPassword = true;
}
if (!$stopPassword && $password !== $passwordRepeat) {
    Module::paramRespond('passwordRepeat', 'Passwords do not match');
    $stopPassword = true;
}
if (!$stopPassword && !User::isValidPassword($password)) {
    Module::paramRespond('password', 'Invalid');
    $stopPassword = true;
}
if ($user->email !== $_user->email && !User::isEmailValid($_user->email)) {
    Module::paramRespond('email', 'Not a valid email');
    $stopEmail = true;
Esempio n. 5
0
<?php

use Enpowi\Modules\DataIn;
use Enpowi\Types;
use Enpowi\Modules\Module;
Module::is();
$dataIn = new DataIn();
$user = Types::Users_User($dataIn->in('user'));
$groups = $dataIn->in('groups');
$user->ensureExists()->removeAllGroups();
foreach ($groups as $group) {
    Types::Users_Group($group)->ensureExists()->addUser($user);
}
echo 1;
Esempio n. 6
0
<?php

use Enpowi\App;
use Enpowi\Modules\DataIn;
use Enpowi\Types;
use Enpowi\Modules\Module;
Module::is();
$page = Types::Pages_Page((new DataIn())->in('page'));
$page->replace(App::param('content'));
echo 1;