Example #1
0
 public function ShowAction($id = '')
 {
     global $CONFIG;
     $id += 0;
     if (!$id) {
         throw new ApplicationException("404 File Not Found");
     }
     $size = reqs('size');
     $is_preview = reqi('preview');
     if ($is_preview) {
         $item = $this->model->one($id);
         if ($item['is_image']) {
             $this->model->transmit_file($id, $size, 'inline');
         } else {
             #if it's not an image and requested preview - return std image
             $filepath = $CONFIG['site_root'] . '/img/att_file.png';
             # TODO move to web.config or to model?
             header('Content-type: ' . UploadUtils::get_mime4ext($item['ext']));
             $fp = fopen($filepath, 'rb');
             fpassthru($fp);
         }
     } else {
         $this->model->transmit_file($id, $size, 'inline');
     }
 }
Example #2
0
 public function SaveAction()
 {
     global $CONFIG;
     #special case login
     if (req('save_type') == 'facebook') {
         $this->SaveFacebook();
         return;
     }
     try {
         $login = trim($_REQUEST['item']['login']);
         $pwd = $_REQUEST['item']['pwdh'];
         if ($_REQUEST["item"]["chpwd"] == "1") {
             $pwd = $_REQUEST['item']['pwd'];
         }
         $pwd = substr(trim($pwd), 0, 32);
         if (!strlen($login) || !strlen($pwd)) {
             $this->ferr("REGISTER", True);
             throw new ApplicationException("");
         }
         $hU = db_row("select * from users where email=" . dbq($login) . " and pwd=" . dbq($pwd));
         if (!isset($hU['access_level']) || $hU['status'] != 0) {
             throw new ApplicationException(lng("User Authentication Error"));
         }
         $this->model->do_login($hU['id']);
         $gourl = reqs('gourl');
         if ($gourl && !preg_match("/^http/i", $gourl)) {
             #if url set and not external url (hack!) given
             fw::redirect($gourl);
         } else {
             fw::redirect($CONFIG['LOGGED_DEFAULT_URL']);
         }
     } catch (ApplicationException $ex) {
         $this->fw->G['err_ctr'] = reqi('err_ctr') + 1;
         $this->set_form_error($ex->getMessage());
         $this->route_redirect("Index");
     }
 }
Example #3
0
 public function SelectAction()
 {
     $category_icode = reqs("category");
     $att_categories_id = reqi("att_categories_id");
     $AttCat = $this->fw->model('AttCategories');
     if ($category_icode > '') {
         $att_cat = $AttCat->one_by_icode($category_icode);
         if (count($att_cat)) {
             $att_categories_id = $att_cat['id'];
         }
     }
     $rows = $this->model->ilist_by_category($att_categories_id);
     foreach ($rows as $key => $row) {
         $row['direct_url'] = $this->model->get_url_direct($row);
     }
     $ps = array('att_dr' => $rows, 'select_att_categories_id' => $AttCat->get_select_options($att_categories_id));
     return $ps;
 }