예제 #1
0
파일: images.php 프로젝트: netixx/frankiz
 function handler_upload($page)
 {
     $page->assign('exception', false);
     $page->assign('image', false);
     if (FrankizUpload::has('file')) {
         $g = Group::from('temp')->select(GroupSelect::castes());
         $temp = $g->caste(Rights::everybody());
         try {
             $upload = FrankizUpload::v('file');
             $secret = uniqid();
             $i = new FrankizImage();
             $i->insert();
             $i->caste($temp);
             $i->label($secret);
             $i->image($upload);
             $page->assign('image', $i);
             $page->assign('secret', $secret);
         } catch (Exception $e) {
             try {
                 if ($i) {
                     $i->delete();
                 }
             } catch (Exception $eb) {
                 $page->assign('exception', $eb);
             }
             $page->assign('exception', $e);
             if ($e instanceof ImageSizeException) {
                 $page->assign('pixels', true);
             } else {
                 if ($e instanceof UploadSizeException) {
                     $page->assign('bytes', true);
                 } else {
                     if ($e instanceof ImageFormatException) {
                         $page->assign('format', true);
                     }
                 }
             }
         }
     }
     if (Env::has('delete')) {
         $image = new FrankizImage(Env::i('iid'));
         $image->select(FrankizImageSelect::base());
         if ($image->label() == Env::s('secret')) {
             $image->delete();
         }
     }
     $page->addCssLink('upload.css');
     $page->changeTpl('images/upload.tpl', SIMPLE);
 }
예제 #2
0
파일: links.php 프로젝트: netixx/frankiz
 function handler_links_new($page)
 {
     if (!S::user()->perms()->hasFlag('admin')) {
         return PL_FORBIDDEN;
     }
     $label = Env::t('label', '');
     $link = Env::t('link', '');
     $description = Env::t('description', '');
     $comment = Env::t('comment', '');
     $type = Env::t('type', '');
     trace($type);
     if (Env::has('create') && $label != '' && $link != '' && ($type == 'partners' || $type == 'usefuls')) {
         $l = new Link();
         $l->insert($type);
         if (FrankizUpload::has('image') && $type == 'partners') {
             try {
                 $group = Group::from('partnership');
                 $group->select(GroupSelect::castes());
                 $image = new FrankizImage();
                 $image->insert();
                 $image->label($label);
                 $image->caste($group->caste(new Rights('everybody')));
                 $image->image(FrankizUpload::v('image'));
                 $l->image($image);
             } catch (Exception $e) {
                 $page->assign('err', $e->getMessage());
             }
         }
         $l->label($label);
         $l->link($link);
         $l->description($description);
         $l->comment($comment);
         pl_redirect('links/' . $type);
     }
     $page->assign('title', 'Nouveau lien');
     $page->addCssLink('links.css');
     $page->changeTpl('links/new_link.tpl');
 }