Exemple #1
0
 /**
  * Build the form and show the template
  *
  * @global string $CONFIG['URL']
  * @param string $module
  * @param int $id
  * @param array $dirty reference to unverified $_POST
  */
 function formBuild($module, $id, &$dirty)
 {
     // Initialize width & height
     $width = 0;
     $height = 0;
     // Check $id
     if (!filter_var($id, FILTER_VALIDATE_INT) || $id < 1) {
         throw new Exception('Invalid $id');
     }
     // Check $module, assign $table
     $table = $this->getTable($module);
     if (!$table) {
         throw new Exception('Unsuported $module');
     }
     // --------------------------------------------------------------------
     // Form logic
     // --------------------------------------------------------------------
     if (!empty($dirty)) {
         $this->tpl->assign($dirty);
     } else {
         suxValidate::disconnect();
     }
     if (!suxValidate::is_registered_form()) {
         suxValidate::connect($this->tpl, true);
         // Reset connection
         suxValidate::register_validator('integrity', 'integrity:module:id', 'hasIntegrity');
     }
     // --------------------------------------------------------------------
     // Get image from database
     // --------------------------------------------------------------------
     $query = "SELECT users_id, image FROM {$table} WHERE id = ? ";
     $db = suxDB::get();
     $st = $db->prepare($query);
     $st->execute(array($id));
     $image = $st->fetch(PDO::FETCH_ASSOC);
     if (!$image['image']) {
         throw new Exception('$image not found');
     }
     if ($image['users_id'] != $_SESSION['users_id']) {
         // Check that the user is allowed to be here
         if (!$this->user->isRoot()) {
             $access = $this->user->getAccess($module);
             if (!isset($GLOBALS['CONFIG']['ACCESS'][$module]['admin'])) {
                 suxFunct::redirect(suxFunct::getPreviousURL('cropper'));
             } elseif ($access < $GLOBALS['CONFIG']['ACCESS'][$module]['admin']) {
                 suxFunct::redirect(suxFunct::getPreviousURL('cropper'));
             }
         }
     }
     // Assign a url to the fullsize version of the image
     $image = $image['image'];
     $image = rawurlencode(suxPhoto::t2fImage($image));
     $image = "{$GLOBALS['CONFIG']['URL']}/data/{$module}/{$image}";
     $image = suxFunct::myHttpServer() . $image;
     // Double check
     if (!filter_var($image, FILTER_VALIDATE_URL)) {
         $image = null;
     }
     if (!preg_match('/\\.(jpe?g|gif|png)$/i', $image)) {
         $image = null;
     }
     if ($image) {
         list($width, $height) = @getimagesize($image);
     }
     // --------------------------------------------------------------------
     // Template
     // --------------------------------------------------------------------
     if ($image && $width && $height) {
         // Get config variables
         $this->tpl->configLoad('my.conf', $module);
         $this->tpl->assign('module', $module);
         $this->tpl->assign('id', $id);
         $this->tpl->assign('x2', $this->tpl->getConfigVars('thumbnailWidth'));
         // Pavatar
         $this->tpl->assign('y2', $this->tpl->getConfigVars('thumbnailHeight'));
         $this->tpl->assign('url_to_source', $image);
         $this->tpl->assign('width', $width);
         $this->tpl->assign('height', $height);
         $this->tpl->assign('form_url', suxFunct::makeUrl("/cropper/{$module}/{$id}"));
         $this->tpl->assign('prev_url', suxFunct::getPreviousURL('cropper'));
         $this->r->title .= " | {$this->r->gtext['crop_image']}";
         $this->tpl->display('cropper.tpl');
     } else {
         throw new Exception('$image not found');
     }
 }
Exemple #2
0
 /**
  * Get the requested url
  * @return string url
  */
 private function getReqUrl()
 {
     $path = $_SERVER['REQUEST_URI'];
     return suxFunct::myHttpServer() . $path;
 }
Exemple #3
0
 /**
  * Get thumbnail
  *
  * @param int $photoalbums_id
  * @return int
  */
 function getThumbnail($photoalbums_id)
 {
     $image = null;
     $tmp = $this->photo->getThumbnail($photoalbums_id);
     if ($tmp) {
         $image = suxFunct::myHttpServer() . $GLOBALS['CONFIG']['URL'] . '/data/photos/' . rawurlencode($tmp['image']);
     }
     return $image;
 }
Exemple #4
0
 /**
  * myHttpServer Wrapper
  *
  * @return string url
  */
 function myHttpServer()
 {
     return suxFunct::myHttpServer();
 }