function getUserImageByUserId($userId, $width = 200)
{
    $pic = getUserImagePath($userId);
    $ret = new Image($pic);
    $ret->setWidth($width);
    //$ret = "<img src='"  .$pic  ."' width='" .$width ."'>";
    return $ret;
}
function getImageForKategorie($katId)
{
    $sql = "SELECT * FROM stadt_kategorien k WHERE id = " . $katId;
    $result = $_SESSION['config']->DBCONNECT->executeQuery($sql);
    $row = mysql_fetch_array($result);
    if (strlen($row['symbolpic']) > 0) {
        $file = dirname($_SERVER['SCRIPT_NAME']) . "/pics/kategoriesymbole/" . $row['symbolpic'];
        $img = new Image($file);
        $img->setToolTip($row['name']);
        $img->setGenerated(false);
        $img->setWidth(100);
        return $img;
    }
    return new Text("");
}
 public static function getImagesHTML()
 {
     global $REX;
     $return = [];
     /**
      * prepare images from MetaInfo
      */
     if (self::$curArticle->getValue('art_open_graph_images')) {
         $images = explode(',', self::$curArticle->getValue('art_open_graph_images'));
         foreach ($images as $image) {
             $ogImage = new Image();
             $image = \OOMedia::getMediaByFileName($image);
             if (false && \rex_addon::isActivated('seo42')) {
                 $ogImage->setUrl(\seo42::getMediaUrl($image));
             } else {
                 $ogImage->setUrl($REX['SERVER'] . $REX['MEDIA_DIR'] . '/' . $image->getFileName());
             }
             $ogImage->setType($image->getType());
             $ogImage->setWidth($image->getWidth());
             $ogImage->setHeigt($image->getHeight());
             self::addImage($ogImage);
         }
     }
     /** @var Image $image */
     foreach (self::$images as $image) {
         $return[] = '<meta property="og:image" content="' . $image->getUrl() . '">';
         if ($image->getSecureUrl() || $REX['ADDON']['open_graph']['settings']['https']) {
             if (!$image->getSecureUrl()) {
                 if (strpos($image->getUrl(), $REX['SERVER']) == 0) {
                     $image->setSecureUrl(str_replace('http://', 'https://', $image->getUrl()));
                 }
             }
             if ($image->getSecureUrl()) {
                 $return[] = '<meta property="og:image:secure_url" content="' . $image->getSecureUrl() . '">';
             }
         }
         if ($image->getWidth()) {
             $return[] = '<meta property="og:image:width" content="' . $image->getWidth() . '">';
         }
         if ($image->getHeigt()) {
             $return[] = '<meta property="og:image:height" content="' . $image->getHeigt() . '">';
         }
         if ($image->getType()) {
             $return[] = '<meta property="og:image:type" content="' . $image->getType() . '">';
         }
     }
     return implode("\n\t", $return) . "\n\t";
 }
$menu->setYPos(190);
$menu->show();
/* --------------------------------- */
/* ------------------------------------
     Statischer Zurück-Button
  ------------------------------------ */
$backButton = new ButtonBack();
$backButton->setXPos($MAINFRAME['xpos'] + $MAINFRAME['width'] - 83);
$backButton->setYPos($MAINFRAME['ypos'] + $MAINFRAME['border'] + 2);
$backButton->show();
/* --------------------------------- */
/* ------------------------------------
     Banner
   ------------------------------------ */
if (isset($BANNER['activ']) && $BANNER['activ']) {
    $banner = new Image($BANNER_PIC);
    //$BANNER_PIC wird in Public_Vars definiert
    $banner->setXPos(200);
    $banner->setYPos(5);
    $banner->setWidth(600);
    $banner->setHeight(80);
    $banner->show();
}
/* --------------------------------- */
/* ------------------------------------
     BENUTZERSTATUS ANZEIGEN
   ------------------------------------ */
if ($USER_STATUS['aktiv']) {
    $CONFIG->CURRENTUSER->showStatus($USER_STATUS['xpos'], $USER_STATUS['ypos']);
}
/* --------------------------------- */
Example #5
0
 public function setSize($size)
 {
     if (empty($this->data)) {
         throw new \Exception('Data must be set first');
     }
     $this->originalSize = $size;
     $this->moduleSize = ceil($this->originalSize / $this->cols);
     $size = $this->moduleSize * $this->cols;
     parent::setWidth($size);
     parent::setHeight($size);
     return $this;
 }
 /**
  *  Liefert das Grafik-Symbol zurück (als HTML String),
  *  welches zur Alarmgeber-Art passt.
  */
 function getControlArtIconSrc($tooltipActive = true)
 {
     $lnkImg = new Image($this->PIC);
     $lnkImg->setWidth($this->CONTROL_IMAGE_WIDTH);
     if ($tooltipActive) {
         $ttt = $this->getIconTooltip();
         $lnkImg->setToolTip($ttt);
     }
     $lnkImgSrc = $lnkImg->getImgSrc($this->PIC);
     return $lnkImgSrc;
 }
Example #7
0
 /**
  * Returns HTML code for either a checked or unchecked icon
  * for indicating yes/no status
  *
  * For the time being, the unchecked status is represented by
  * an empty space, aka pixel.gif
  * @param   boolean   $status     If true, the checked box is returned,
  *                                the unchecked otherwise
  * @return  string                The HTML code with the checkbox icon
  * @todo    There should be an unchecked icon other than "pixel.gif"
  */
 static function getCheckmark($status = '')
 {
     $objImage = new Image();
     $objImage->setPath($status ? self::ICON_STATUS_CHECKED : self::ICON_STATUS_UNCHECKED);
     $objImage->setWidth(16);
     $objImage->setHeight(16);
     $checkmark_html = self::getImageOriginal($objImage, 'border="0"');
     return $checkmark_html;
 }
Example #8
0
 public function usersPage($param)
 {
     $this->setView('users.php');
     /*
      * Enregistrement du post dans la table users	
      */
     if (isset($_FILES['uploadxml1']) && $_FILES['uploadxml1']['name'] != null) {
         if ($_FILES['uploadxml1']['size'] > Config::UPLOAD_MAX_SIZE_FILE) {
             throw new Exception(__('POST_ADD_ERROR_FILE_SIZE', array('size' => File::humanReadableSize(Config::UPLOAD_MAX_SIZE_FILE))));
         }
         //On déplace le fichier vers le serveur
         if ($filepaths = File::upload('uploadxml1')) {
             if (!preg_match('#\\.xml$#', $filepaths)) {
                 throw new Exception(__('POST_ADD_ERROR_FILE_FORMAT'));
             }
             $name = $filepaths;
         }
         $student = array();
         $path = DATA_DIR . Config::DIR_DATA_TMP . $_FILES['uploadxml1']['name'];
         if (file_exists($path)) {
             $data = simplexml_load_file($path);
             foreach ($data->data as $data) {
                 if (isset($data->username) && isset($data->admin) && isset($data->mail) && isset($data->msn) && isset($data->jabber) && isset($data->address) && isset($data->address) && isset($data->zipcode) && isset($data->city) && isset($data->cellphone) && isset($data->phone) && isset($data->birthday)) {
                     $username = $data->username;
                     $admin = $data->admin;
                     $mail = $data->mail;
                     $msn = $data->msn;
                     $jabber = $data->jabber;
                     $address = $data->address;
                     $zipcode = $data->zipcode;
                     $city = $data->city;
                     $cellphone = $data->cellphone;
                     $phone = $data->phone;
                     $birthday = $data->birthday;
                     if (!$this->model->checkuser($username, 1)) {
                         $this->model->insertUsers($username, $admin, utf8_decode($mail), utf8_decode($msn), utf8_decode($jabber), utf8_decode($address), $zipcode, $city, $cellphone, $phone, $birthday);
                     } else {
                         array_push($student, $username);
                     }
                 } else {
                     throw new Exception(__('ADMIN_UPLOAD_ERROR2'));
                 }
             }
         } else {
             throw new Exception(__('ADMIN_UPLOAD_ERROR'));
         }
         FILE::delete($path);
         $this->set('fail', $student);
     }
     /*
      * Enregistrement du post dans la table students
      */
     if (isset($_FILES['uploadxml2']) && $_FILES['uploadxml2']['name'] != null) {
         if ($_FILES['uploadxml2']['size'] > Config::UPLOAD_MAX_SIZE_FILE) {
             throw new Exception(__('POST_ADD_ERROR_FILE_SIZE', array('size' => File::humanReadableSize(Config::UPLOAD_MAX_SIZE_FILE))));
         }
         if ($filepaths = File::upload('uploadxml2')) {
             if (!preg_match('#\\.xml$#', $filepaths)) {
                 throw new Exception(__('POST_ADD_ERROR_FILE_FORMAT'));
             }
             $name = $filepaths;
         }
         $student = array();
         $path = DATA_DIR . Config::DIR_DATA_TMP . $_FILES['uploadxml2']['name'];
         if (file_exists($path)) {
             $data = simplexml_load_file($path);
             foreach ($data->data as $data) {
                 if (isset($data->username) && isset($data->lastname) && isset($data->firstname) && isset($data->student_number) && isset($data->promo) && isset($data->cesure)) {
                     $username = $data->username;
                     $lastname = $data->lastname;
                     $firstname = $data->firstname;
                     $student_number = $data->student_number;
                     $promo = $data->promo;
                     $cesure = $data->cesure;
                     if (!$this->model->checkuser($username, 2)) {
                         $this->model->insertStudents($username, utf8_decode($lastname), utf8_decode($firstname), $student_number, $promo, $cesure);
                     } else {
                         array_push($student, $username);
                     }
                 } else {
                     throw new Exception(__('ADMIN_UPLOAD_ERROR2'));
                 }
             }
         } else {
             throw new Exception(__('ADMIN_UPLOAD_ERROR'));
         }
         FILE::delete($path);
         $this->set('fail', $student);
     }
     /*
      * Enregistrement des avatars
      */
     if (isset($_FILES['avatar_photo']) && is_array($_FILES['avatar_photo']['name'])) {
         foreach ($_FILES['avatar_photo']['size'] as $size) {
             if ($size > Config::UPLOAD_MAX_SIZE_PHOTO) {
                 throw new Exception(__('POST_ADD_ERROR_PHOTO_SIZE', array('size' => File::humanReadableSize(Config::UPLOAD_MAX_SIZE_PHOTO))));
             }
         }
         $student = array();
         if ($avatarpaths = File::upload('avatar_photo')) {
             foreach ($avatarpaths as $avatarpath) {
                 $uploaded_files[] = $avatarpath;
             }
             foreach ($avatarpaths as $i => $avatarpath) {
                 $name = $_FILES['avatar_photo']['name'][$i];
                 try {
                     $img = new Image();
                     $img->load($avatarpath);
                     $type = $img->getType();
                     if ($type == IMAGETYPE_JPEG) {
                         $ext = 'jpg';
                     } else {
                         if ($type == IMAGETYPE_GIF) {
                             $ext = 'gif';
                         } else {
                             if ($type == IMAGETYPE_PNG) {
                                 $ext = 'png';
                             } else {
                                 throw new Exception();
                             }
                         }
                     }
                     if ($img->getWidth() > 800) {
                         $img->setWidth(800, true);
                     }
                     $img->setType(IMAGETYPE_JPEG);
                     $img->save($avatarpath);
                     // Thumb
                     $avatarthumbpath = $avatarpath . '.thumb';
                     $img->thumb(Config::$AVATARS_THUMBS_SIZES[0], Config::$AVATARS_THUMBS_SIZES[1]);
                     $img->setType(IMAGETYPE_JPEG);
                     $img->save($avatarthumbpath);
                     unset($img);
                     $uploaded_files[] = $avatarthumbpath;
                     $student_data['avatar_path'] = $avatarthumbpath;
                     $student_data['avatar_big_path'] = $avatarpath;
                     $student_data['student_number'] = preg_replace('/\\.[a-z0-9]+$/i', '', $name);
                     if (isset($student_data['avatar_path']) && isset($student_data['student_number']) && File::exists($student_data['avatar_path'])) {
                         $avatar_path = Student_Model::getAvatarPath((int) $student_data['student_number'], true);
                         $avatar_dir = File::getPath($avatar_path);
                         if (!is_dir($avatar_dir)) {
                             File::makeDir($avatar_dir, 0777, true);
                         }
                         File::rename($student_data['avatar_path'], $avatar_path);
                     }
                     if (isset($student_data['avatar_big_path']) && isset($student_data['student_number']) && File::exists($student_data['avatar_big_path'])) {
                         $avatar_path = Student_Model::getAvatarPath((int) $student_data['student_number'], false);
                         $avatar_dir = File::getPath($avatar_path);
                         if (!is_dir($avatar_dir)) {
                             File::makeDir($avatar_dir, 0777, true);
                         }
                         File::rename($student_data['avatar_big_path'], $avatar_path);
                     }
                 } catch (Exception $e) {
                     array_push($student, $name);
                 }
             }
             $this->set('fail2', $student);
             foreach ($uploaded_files as $uploaded_file) {
                 File::delete($uploaded_file);
             }
         }
     }
 }
Example #9
0
 /**
  * Add a group
  */
 public function add($params)
 {
     $this->setView('add.php');
     $this->setTitle(__('GROUP_ADD_TITLE'));
     $is_logged = isset(User_Model::$auth_data);
     $is_admin = $is_logged && User_Model::$auth_data['admin'] == '1';
     // Authorization
     if (!$is_admin) {
         throw new ActionException('Page', 'error404');
     }
     $group = array();
     // Saving data
     if (isset($_POST['name']) && isset($_POST['creation_date']) && isset($_POST['mail']) && isset($_POST['description'])) {
         $uploaded_files = array();
         try {
             // Members
             $members = array();
             if (isset($_POST['members_ids']) && is_array($_POST['members_ids'])) {
                 foreach ($_POST['members_ids'] as $id) {
                     if (ctype_digit($id)) {
                         $id = (int) $id;
                         $members[$id] = array('title' => isset($_POST['member_title_' . $id]) ? $_POST['member_title_' . $id] : '', 'admin' => isset($_POST['member_admin_' . $id]));
                     }
                 }
             }
             // Other info
             $data = array('name' => $_POST['name'], 'creation_date' => $_POST['creation_date'], 'mail' => $_POST['mail'], 'description' => $_POST['description'], 'members' => $members);
             // Avatar
             if (isset($_FILES['avatar']) && !is_array($_FILES['avatar']['name'])) {
                 if ($_FILES['avatar']['size'] > Config::UPLOAD_MAX_SIZE_PHOTO) {
                     throw new FormException('avatar');
                 }
                 if ($avatarpath = File::upload('avatar')) {
                     $uploaded_files[] = $avatarpath;
                     try {
                         $img = new Image();
                         $img->load($avatarpath);
                         $type = $img->getType();
                         if ($type == IMAGETYPE_JPEG) {
                             $ext = 'jpg';
                         } else {
                             if ($type == IMAGETYPE_GIF) {
                                 $ext = 'gif';
                             } else {
                                 if ($type == IMAGETYPE_PNG) {
                                     $ext = 'png';
                                 } else {
                                     throw new Exception();
                                 }
                             }
                         }
                         if ($img->getWidth() > 800) {
                             $img->setWidth(800, true);
                         }
                         $img->setType(IMAGETYPE_JPEG);
                         $img->save($avatarpath);
                         // Thumb
                         $avatarthumbpath = $avatarpath . '.thumb';
                         $img->thumb(Config::$AVATARS_THUMBS_SIZES[0], Config::$AVATARS_THUMBS_SIZES[1]);
                         $img->setType(IMAGETYPE_JPEG);
                         $img->save($avatarthumbpath);
                         unset($img);
                         $uploaded_files[] = $avatarthumbpath;
                         $data['avatar_path'] = $avatarthumbpath;
                         $data['avatar_big_path'] = $avatarpath;
                     } catch (Exception $e) {
                         throw new FormException('avatar');
                     }
                 }
             }
             $url_name = $this->model->create($data);
             Routes::redirect('group', array('group' => $url_name));
         } catch (FormException $e) {
             foreach ($uploaded_files as $uploaded_file) {
                 File::delete($uploaded_file);
             }
             foreach ($data as $key => $value) {
                 $group[$key] = $value;
             }
             $group['members'] = Student_Model::getInfoByUsersIds(array_keys($members));
             foreach ($group['members'] as &$member) {
                 if (isset($members[(int) $member['user_id']])) {
                     $member['title'] = $members[(int) $member['user_id']]['title'];
                     $member['admin'] = $members[(int) $member['user_id']]['admin'] ? '1' : '0';
                 }
             }
             $this->set('form_error', $e->getError());
         }
     }
     $this->set('group', $group);
     $this->addJSCode('Group.initEdit();');
 }
Example #10
0
    $_SESSION['config']->PUBLICVARS['currentMode'] = $_REQUEST['changeMode'];
}
$topSpaceTable = new Table(array(""));
$topSpaceTable->show();
$layoutTable = new Table(array(""));
$layoutTable->setWidth($bannerWidth);
$layoutTable->setAlign("left");
$layoutTable->setBORDER(0);
$layoutTable->setBackgroundColor($_SESSION['config']->COLORS['panel_background']);
$layoutTable->setSpacing(0);
$layoutTable->setPadding(0);
/* ------------------------------------
BANNER
------------------------------------ */
$banner = new Image("pics/Banner.png");
$banner->setWidth($bannerWidth);
if (!$noFrameLayout) {
    $banner->setGenerated(false);
    $contentLayoutRow1 = $layoutTable->createRow();
    $contentLayoutRow1->setAlign("left");
    $contentLayoutRow1->setAttribute(0, $banner);
    $contentLayoutRow1->setStyle("padding", "10px");
    $layoutTable->addRow($contentLayoutRow1);
} else {
    $_SESSION['additionalLayoutHeight'] = 15;
    $bannerHeight = $_SESSION['additionalLayoutHeight'];
}
$modeSwitchComboTbl = new Table(array(""));
$modeSwitchComboTbl->setWidth(100);
$modeSwitchComboTbl->setAlign("center");
$modeSwitchComboTbl->setVAlign("middle");
 /**
  *  Liefert das Grafik-Symbol zurück (Image),
  *  welches zur Sensor-Art passt.
  */
 function getSensorArtIconSrc($tooltip = true, $width = 0)
 {
     $lnkImg = new Image($this->PIC);
     $lnkImg->setWidth($width == 0 ? $this->CONTROL_IMAGE_WIDTH : $width);
     if ($tooltip) {
         $ttt = $this->getIconTooltip();
         $lnkImg->setToolTip($ttt);
     }
     $lnkImgSrc = $lnkImg->getImgSrc($this->PIC);
     return $lnkImgSrc;
 }
Example #12
0
 public function index()
 {
     $this->setView('index.php');
     $is_logged = isset(User_Model::$auth_data);
     $is_student = $is_logged && isset(User_Model::$auth_data['student_number']);
     $is_admin = $is_logged && User_Model::$auth_data['admin'] == '1';
     $this->set(array('username' => User_Model::$auth_data['username'], 'is_logged' => $is_logged, 'is_student' => $is_student, 'is_admin' => $is_admin));
     //Fonction qui met à jour l'annuaire dans mysql et ajoute les avatars
     //$uploaded_files=array();
     if (isset($_FILES['uploadzip'])) {
         if ($_FILES['uploadzip']['size'] > Config::UPLOAD_MAX_SIZE_FILE) {
             throw new Exception(__('POST_ADD_ERROR_FILE_SIZE', array('size' => File::humanReadableSize(Config::UPLOAD_MAX_SIZE_FILE))));
         }
         //On déplace le fichier zipper vers le serveur
         if ($filepaths = File::upload('uploadzip')) {
             // foreach($filepaths as $filepath)
             // $uploaded_files[] = $filepath;
             //foreach($filepaths as $i => $filepath){
             if (!preg_match('#\\.zip$#', $filepaths)) {
                 throw new Exception(__('POST_ADD_ERROR_FILE_FORMAT'));
             }
             $name = $filepaths;
             //}
         }
         $path = DATA_DIR . Config::DIR_DATA_TMP . 'annuaire/';
         // On dézip celui-ci
         if (FILE::exists($path)) {
             FILE::delete($path);
         }
         File::makeDir($path);
         $zip = new ZipArchive();
         $res = $zip->open($name);
         if ($res === TRUE) {
             $zip->extractTo($path);
             $zip->close();
             unlink($name);
         } else {
             throw new Exception(__('ADMIN_POST_ZIPERROR'));
         }
         if (File::delete(DATA_DIR . Config::DIR_DATA_TMP . $name)) {
             // On aplique le chmod a tous les dossiers et fichiers du zip
             FILE::chmodDirectory($path, 0);
             // on traite les fichiers students.csv et users.csv
             if (file_exists($path . 'users.csv')) {
                 $fp = fopen($path . 'users.csv', "r");
             } else {
                 throw new Exception(__('ADMIN_POST_CSVERROR1'));
             }
             $i = 0;
             while (!feof($fp)) {
                 $i = $i + 1;
                 // Tant qu'on n'atteint pas la fin du fichier
                 $ligne = fgets($fp, 4096);
                 /* On lit une ligne */
                 // On récupère les champs séparés par ; dans liste
                 $liste = explode(";", $ligne);
                 // On assigne les variables
                 if (strlen($liste[0]) > 1) {
                     if (isset($liste[0])) {
                         $username = $liste[0];
                     }
                     if (isset($liste[1])) {
                         $admin = $liste[1];
                     }
                     if (isset($liste[2])) {
                         $mail = $liste[2];
                     }
                     if (isset($liste[3])) {
                         $msn = $liste[3];
                     }
                     if (isset($liste[4])) {
                         $jabber = $liste[4];
                     }
                     if (isset($liste[5])) {
                         $address = $liste[5];
                     }
                     if (isset($liste[6])) {
                         $zipcode = $liste[6];
                     }
                     if (isset($liste[7])) {
                         $city = $liste[7];
                     }
                     if (isset($liste[8])) {
                         $cellphone = $liste[8];
                     }
                     if (isset($liste[9])) {
                         $phone = $liste[9];
                     }
                     if (isset($liste[10])) {
                         $birthday = $liste[10];
                     }
                     if (!$this->model->checkuser($username, 1)) {
                         $this->model->insertUsers(trim($username), trim($admin), trim($mail), trim($msn), trim($jabber), trim($address), trim($zipcode), trim($city), trim($cellphone), trim($phone), trim($birthday));
                     }
                 }
             }
             fclose($fp);
             if (file_exists($path . 'students.csv')) {
                 $fp = fopen($path . 'students.csv', "r");
             } else {
                 throw new Exception(__('ADMIN_POST_CSVERROR2'));
             }
             $i = 0;
             while (!feof($fp)) {
                 $i = $i + 1;
                 // Tant qu'on n'atteint pas la fin du fichier
                 $ligne = fgets($fp, 4096);
                 /* On lit une ligne */
                 // On récupère les champs séparés par ; dans liste
                 $liste = explode(";", $ligne);
                 // On assigne les variables
                 if (strlen($liste[0]) > 1) {
                     if (isset($liste[0])) {
                         $username = $liste[0];
                     }
                     if (isset($liste[1])) {
                         $lastname = $liste[1];
                     }
                     if (isset($liste[2])) {
                         $firstname = $liste[2];
                     }
                     if (isset($liste[3])) {
                         $student_number = $liste[3];
                     }
                     if (isset($liste[4])) {
                         $promo = $liste[4];
                     }
                     if (isset($liste[5])) {
                         $cesure = $liste[5];
                     }
                     if (!$this->model->checkuser($username, 2)) {
                         $this->model->insertStudents(trim($username), trim($lastname), trim($firstname), trim($student_number), trim($promo), trim($cesure));
                     }
                     // On déplace et formate les photos dans le dossier avatars
                     $avatarpath = $path . 'photos_students/' . $student_number . '.jpg';
                     $img = new Image();
                     $img->load($avatarpath);
                     $type = $img->getType();
                     if ($type == IMAGETYPE_JPEG) {
                         $ext = 'jpg';
                     } else {
                         if ($type == IMAGETYPE_GIF) {
                             $ext = 'gif';
                         } else {
                             if ($type == IMAGETYPE_PNG) {
                                 $ext = 'png';
                             } else {
                                 throw new Exception();
                             }
                         }
                     }
                     if ($img->getWidth() > 800) {
                         $img->setWidth(800, true);
                     }
                     $img->setType(IMAGETYPE_JPEG);
                     $img->save($avatarpath);
                     // Thumb
                     $avatarthumbpath = $path . 'photos_students/' . $student_number . '_thumb.jpg';
                     $img->thumb(Config::$AVATARS_THUMBS_SIZES[0], Config::$AVATARS_THUMBS_SIZES[1]);
                     $img->setType(IMAGETYPE_JPEG);
                     $img->save($avatarthumbpath);
                     if (FILE::exists(DATA_DIR . Config::DIR_DATA_STORAGE . 'avatars/' . substr($student_number, 0, -2) . '/')) {
                         FILE::move($avatarthumbpath, DATA_DIR . Config::DIR_DATA_STORAGE . 'avatars/' . substr($student_number, 0, -2) . '/');
                         FILE::move($avatarpath, DATA_DIR . Config::DIR_DATA_STORAGE . 'avatars/' . substr($student_number, 0, -2) . '/');
                     } else {
                         FILE::makeDir(DATA_DIR . Config::DIR_DATA_STORAGE . 'avatars/' . substr($student_number, 0, -2) . '/');
                         FILE::move($avatarthumbpath, DATA_DIR . Config::DIR_DATA_STORAGE . 'avatars/' . substr($student_number, 0, -2) . '/');
                         FILE::move($avatarpath, DATA_DIR . Config::DIR_DATA_STORAGE . 'avatars/' . substr($student_number, 0, -2) . '/');
                     }
                     unset($img);
                 }
             }
             fclose($fp);
             // On supprime le tout du dossier temp
             FILE::delete($path);
         }
     }
 }
Example #13
0
 public function castToImage($obj)
 {
     $i = new Image();
     if (isset($obj->imageID)) {
         $i->setImageID($obj->imageID);
     }
     if (isset($obj->size)) {
         $i->setSize($obj->size);
     }
     if (isset($obj->path)) {
         $i->setPath($obj->path);
     }
     if (isset($obj->height)) {
         $i->setHeight($obj->height);
     }
     if (isset($obj->width)) {
         $i->setWidth($obj->width);
     }
     if (isset($obj->partID)) {
         $i->setPartID($obj->partID);
     }
     if (isset($obj->sort)) {
         $i->setSort($obj->sort);
     }
     return $i;
 }
Example #14
0
 function show()
 {
     //Wenn notwendig Eingabemaske, ansonsten Standard-Anzeige
     if (!$this->showInsertMaskIfNeeded()) {
         $rowsToShow = $this->getRowsToShow();
         //Tabelle für gesamte NEWS
         $tbl = new Table(array("News"));
         $tbl->setHeadEnabled(false);
         $tbl->setBorder(0);
         foreach ($rowsToShow as $row) {
             $tt = new Text($row['Text']);
             $tt->setFilter(false);
             $ta = new Text($row['Autor']);
             $tblxTitle = new Table(array("", ""));
             $tblxTitle->setColSizes(array("50"));
             $tblxTitle->setAlign("left");
             $rxtitle = $tblxTitle->createRow();
             $t0 = new Title(getFormatedDate($row['Datum'], "standard") . ":");
             $t0->setWidth(20);
             $rxtitle->setAttribute(0, $t0);
             $t1 = new Title($row['Title']);
             $rxtitle->setAttribute(1, $t1);
             $rxtitle->setAlign("left");
             $tblxTitle->addRow($rxtitle);
             //Tabelle für den jeweiligen Eintrag
             $tblx = new Table(array(""));
             if (strlen($row['pic']) > 0) {
                 $tblx = new Table(array("", ""));
                 $tblx->setColSizes(array("180"));
             }
             $tblx->setBorder($this->CONFIG->GB_CONFIG['border']);
             $tblx->setWidth("100%");
             //TEXT
             $rx = $tblx->createRow();
             if (strlen($row['pic']) > 0 && !(isset($_REQUEST['removeNewsPicId']) && $_REQUEST['removeNewsPicId'] == $row['id'])) {
                 $img = new Image($row['pic']);
                 $img->setWidth(175);
                 $rx->setAttribute(0, $img);
                 $rx->setAttribute(1, $tt);
             } else {
                 $rx->setAttribute(0, $tt);
             }
             $rx->setAlign("left");
             $tblx->addRow($rx);
             $f = new FontType();
             $rx->setFonttypes(array(0 => $f));
             $f = new FontType();
             $f->setFontsize(1);
             $f->setItalic(false);
             $rx->setFonttypes(array(0 => $f));
             $r = $tbl->createRow();
             $r->setAttribute(0, $tblxTitle);
             $tbl->addRow($r);
             $r1 = $tbl->createRow();
             $r1->setAttribute(0, $tblx);
             $tbl->addRow($r1);
             $ytElem = new YouTubeElement($row['yt_video'], "news", "yt_video", $row['id']);
             $r1 = $tbl->createRow();
             $r1->setAttribute(0, $ytElem);
             $tbl->addRow($r1);
             $tbl->addSpacer(0, 7);
             if ($_SESSION['config']->CURRENTUSER->STATUS == "admin" || $_SESSION['config']->CURRENTUSER->STATUS == "user") {
                 $r2 = $tbl->createRow();
                 $xDv = new Div();
                 $xDv->setWidth(450);
                 $xDv->setHeight(40);
                 $txChngePic = new Text("Bild Hochladen/Ändern<br>");
                 $txChngePic->setFilter(false);
                 $newPicLink = new Link("?popupRunLink=imageUploaderPopup&targetPath=pics/news&DbInsertTable=news&DbInsertCol=pic&DbInsertId=" . $row['id'] . "&stayAlive=ok", $txChngePic);
                 $txRemPic = new Text("Bild Entfernen<br>");
                 $txRemPic->setFilter(false);
                 $removePicLink = new Link("?removeNewsPicId=" . $row['id'] . "", $txRemPic);
                 $spTx = new Text("&nbsp;&nbsp;&nbsp;");
                 $spTx->setFilter(false);
                 $xDv->add($newPicLink);
                 if (strlen($row['pic']) > 0) {
                     if (isset($_REQUEST['removeNewsPicId']) && $_REQUEST['removeNewsPicId'] == $row['id']) {
                         $sql = "UPDATE news SET pic = null WHERE id = " . $_REQUEST['removeNewsPicId'];
                         $_SESSION['config']->DBCONNECT->executeQuery($sql);
                     } else {
                         $xDv->add($removePicLink);
                     }
                 }
                 $newPicLink->setPopup(true);
                 $r2->setAttribute(0, $xDv);
                 $tbl->addRow($r2);
             }
             $tbl->addSpacer(0, 35);
         }
         if ($_SESSION['config']->CURRENTUSER->STATUS == "admin" || $_SESSION['config']->CURRENTUSER->STATUS == "user") {
             // Neuer Eintrag- BUTTON
             //--------------------------------
             $insertButton = new Button('dbTableNew', 'News eintragen');
             $form = new Form($_SERVER['SCRIPT_NAME']);
             $form->add($insertButton);
             $form->show();
         }
         // Tabelle anzeigen
         //--------------------------------
         $tbl->show();
         if ($_SESSION['config']->CURRENTUSER->STATUS == "admin" || $_SESSION['config']->CURRENTUSER->STATUS == "user" && $tbl->getRowcount() > 2) {
             // Neuer Eintrag- BUTTON
             //--------------------------------
             $insertButton = new Button('dbTableNew', 'News eintragen');
             $form = new Form($_SERVER['SCRIPT_NAME']);
             $form->add($insertButton);
             $form->show();
         }
     }
 }
Example #15
0
    public function addAttachment($param)
    {
        $this->setView('iframe_add.php');
        $is_logged = isset(User_Model::$auth_data);
        $is_admin = $is_logged && User_Model::$auth_data['admin'] == '1';
        @set_time_limit(0);
        $uploaded_files = array();
        $attachments = array();
        try {
            if ($is_admin && isset($param['id']) && isset($_FILES['attachment_photo']) && is_array($_FILES['attachment_photo']['name'])) {
                foreach ($_FILES['attachment_photo']['size'] as $size) {
                    if ($size > Config::UPLOAD_MAX_SIZE_PHOTO) {
                        throw new Exception(__('POST_ADD_ERROR_PHOTO_SIZE', array('size' => File::humanReadableSize(Config::UPLOAD_MAX_SIZE_PHOTO))));
                    }
                }
                if ($filepaths = File::upload('attachment_photo')) {
                    foreach ($filepaths as $filepath) {
                        $uploaded_files[] = $filepath;
                    }
                    foreach ($filepaths as $i => $filepath) {
                        $name = isset($_FILES['attachment_photo']['name'][$i]) ? $_FILES['attachment_photo']['name'][$i] : '';
                        try {
                            $img = new Image();
                            $img->load($filepath);
                            $type = $img->getType();
                            if ($type == IMAGETYPE_JPEG) {
                                $ext = 'jpg';
                            } else {
                                if ($type == IMAGETYPE_GIF) {
                                    $ext = 'gif';
                                } else {
                                    if ($type == IMAGETYPE_PNG) {
                                        $ext = 'png';
                                    } else {
                                        throw new Exception();
                                    }
                                }
                            }
                            if ($img->getWidth() > 800) {
                                $img->setWidth(800, true);
                            }
                            $img->save($filepath);
                            // Thumb
                            $thumbpath = $filepath . '.thumb';
                            $img->thumb(Config::$THUMBS_SIZES[0], Config::$THUMBS_SIZES[1]);
                            $img->setType(IMAGETYPE_JPEG);
                            $img->save($thumbpath);
                            unset($img);
                            $attachments[] = array($filepath, $name, $thumbpath);
                            $uploaded_files[] = $thumbpath;
                        } catch (Exception $e) {
                            throw new Exception(__('POST_ADD_ERROR_PHOTO_FORMAT'));
                        }
                    }
                }
                // Attach files
                foreach ($attachments as $attachment) {
                    $this->model->attachFile($param['id'], $attachment[0], $attachment[1], isset($attachment[2]) ? $attachment[2] : null);
                }
                $this->addJSCode('
						parent.location = "' . Config::URL_ROOT . Routes::getPage('post', array('id' => $param['id'])) . '";
					');
            }
            Post_Model::clearCache();
        } catch (Exception $e) {
            // Delete all uploading files in tmp
            foreach ($uploaded_files as $uploaded_file) {
                File::delete($uploaded_file);
            }
            $this->addJSCode('
				with(parent){
					Post.errorForm(' . json_encode($e->getMessage()) . ');
				}
			');
        }
    }
Example #16
0
    /**
     * Add a post
     */
    public function iframe_add()
    {
        $this->setView('iframe_add.php');
        @set_time_limit(0);
        $uploaded_files = array();
        try {
            if (!isset(User_Model::$auth_data)) {
                throw new Exception(__('POST_ADD_ERROR_SESSION_EXPIRED'));
            }
            $is_student = isset(User_Model::$auth_data['student_number']);
            // Message
            $message = isset($_POST['message']) ? trim($_POST['message']) : '';
            if ($message == '' || $message == __('PUBLISH_DEFAULT_MESSAGE')) {
                throw new Exception(__('POST_ADD_ERROR_NO_MESSAGE'));
            }
            $message = preg_replace('#\\n{2,}#', "\n\n", $message);
            // Category
            if (!isset($_POST['category']) || !ctype_digit($_POST['category'])) {
                throw new Exception(__('POST_ADD_ERROR_NO_CATEGORY'));
            }
            $category = (int) $_POST['category'];
            // Official post (in a group)
            $official = isset($_POST['official']);
            // Group
            $group = isset($_POST['group']) && ctype_digit($_POST['group']) ? (int) $_POST['group'] : 0;
            if ($group == 0) {
                $group = null;
                $official = false;
            } else {
                $groups_auth = Group_Model::getAuth();
                if (isset($groups_auth[$group])) {
                    if ($official && !$groups_auth[$group]['admin']) {
                        throw new Exception(__('POST_ADD_ERROR_OFFICIAL'));
                    }
                } else {
                    throw new Exception(__('POST_ADD_ERROR_GROUP_NOT_FOUND'));
                }
            }
            // Private message
            $private = isset($_POST['private']);
            if ($private && !$is_student) {
                throw new Exception(__('POST_ADD_ERROR_PRIVATE'));
            }
            $attachments = array();
            // Photos
            if (isset($_FILES['attachment_photo']) && is_array($_FILES['attachment_photo']['name'])) {
                foreach ($_FILES['attachment_photo']['size'] as $size) {
                    if ($size > Config::UPLOAD_MAX_SIZE_PHOTO) {
                        throw new Exception(__('POST_ADD_ERROR_PHOTO_SIZE', array('size' => File::humanReadableSize(Config::UPLOAD_MAX_SIZE_PHOTO))));
                    }
                }
                if ($filepaths = File::upload('attachment_photo')) {
                    foreach ($filepaths as $filepath) {
                        $uploaded_files[] = $filepath;
                    }
                    foreach ($filepaths as $i => $filepath) {
                        $name = isset($_FILES['attachment_photo']['name'][$i]) ? $_FILES['attachment_photo']['name'][$i] : '';
                        try {
                            $img = new Image();
                            $img->load($filepath);
                            $type = $img->getType();
                            if ($type == IMAGETYPE_JPEG) {
                                $ext = 'jpg';
                            } else {
                                if ($type == IMAGETYPE_GIF) {
                                    $ext = 'gif';
                                } else {
                                    if ($type == IMAGETYPE_PNG) {
                                        $ext = 'png';
                                    } else {
                                        throw new Exception();
                                    }
                                }
                            }
                            if ($img->getWidth() > 800) {
                                $img->setWidth(800, true);
                            }
                            $img->save($filepath);
                            // Thumb
                            $thumbpath = $filepath . '.thumb';
                            $img->thumb(Config::$THUMBS_SIZES[0], Config::$THUMBS_SIZES[1]);
                            $img->setType(IMAGETYPE_JPEG);
                            $img->save($thumbpath);
                            unset($img);
                            $attachments[] = array($filepath, $name, $thumbpath);
                            $uploaded_files[] = $thumbpath;
                        } catch (Exception $e) {
                            throw new Exception(__('POST_ADD_ERROR_PHOTO_FORMAT'));
                        }
                    }
                }
            }
            // Vidéos
            /* @uses PHPVideoToolkit : http://code.google.com/p/phpvideotoolkit/
             * @requires ffmpeg, php5-ffmpeg
             */
            if (isset($_FILES['attachment_video']) && is_array($_FILES['attachment_video']['name'])) {
                foreach ($_FILES['attachment_video']['size'] as $size) {
                    if ($size > Config::UPLOAD_MAX_SIZE_VIDEO) {
                        throw new Exception(__('POST_ADD_ERROR_VIDEO_SIZE', array('size' => File::humanReadableSize(Config::UPLOAD_MAX_SIZE_VIDEO))));
                    }
                }
                if ($filepaths = File::upload('attachment_video')) {
                    foreach ($filepaths as $filepath) {
                        $uploaded_files[] = $filepath;
                    }
                    foreach ($filepaths as $i => $filepath) {
                        $name = isset($_FILES['attachment_video']['name'][$i]) ? $_FILES['attachment_video']['name'][$i] : '';
                        try {
                            $video = new ffmpeg_movie($filepath, false);
                            if (!$video->hasVideo()) {
                                throw new Exception('No video stream found in the file');
                            }
                            if (!$video->hasAudio()) {
                                throw new Exception('No audio stream found in the file');
                            }
                        } catch (Exception $e) {
                            throw new Exception(__('POST_ADD_ERROR_VIDEO_FORMAT'));
                        }
                        // Video conversion
                        try {
                            $video_current_width = $video->getFrameWidth();
                            $video_width = min($video_current_width, Config::VIDEO_MAX_WIDTH);
                            if ($video_width % 2 == 1) {
                                // Even number required
                                $video_width--;
                            }
                            $video_height = $video_width * $video->getFrameHeight() / $video_current_width;
                            if ($video_height % 2 == 1) {
                                // Even number required
                                $video_height--;
                            }
                            // Extract thumb
                            $video_thumb = $video->getFrame(round($video->getFrameCount() * 0.2));
                            unset($video);
                            $video_thumb = $video_thumb->toGDImage();
                            $thumbpath = DATA_DIR . Config::DIR_DATA_TMP . File::getName($filepath) . '.thumb';
                            imagejpeg($video_thumb, $thumbpath, 95);
                            unset($video_thumb);
                            $img = new Image();
                            $img->load($thumbpath);
                            $img->setWidth($video_width, true);
                            $img->setType(IMAGETYPE_JPEG);
                            $img->save($thumbpath);
                            $uploaded_files[] = $thumbpath;
                            unset($img);
                            // Convert to FLV
                            if (!preg_match('#\\.flv$#i', $filepath)) {
                                $toolkit = new PHPVideoToolkit();
                                $toolkit->on_error_die = true;
                                // Will throw exception on error
                                $toolkit->setInputFile($filepath);
                                $toolkit->setVideoOutputDimensions($video_width, $video_height);
                                $toolkit->setFormatToFLV(Config::VIDEO_SAMPLING_RATE, Config::VIDEO_AUDIO_BIT_RATE);
                                $toolkit->setOutput(DATA_DIR . Config::DIR_DATA_TMP, File::getName($filepath) . '.flv', PHPVideoToolkit::OVERWRITE_EXISTING);
                                $toolkit->execute(false, false);
                                // Multipass: false, Log: false
                                File::delete($filepath);
                                $filepath = $toolkit->getLastOutput();
                                $filepath = $filepath[0];
                                unset($toolkit);
                            }
                            $attachments[] = array($filepath, $name, $thumbpath);
                            $uploaded_files[] = $filepath;
                        } catch (Exception $e) {
                            throw new Exception(__('POST_ADD_ERROR_VIDEO_CONVERT') . $e->getMessage());
                        }
                    }
                }
            }
            // Audios
            if (isset($_FILES['attachment_audio']) && is_array($_FILES['attachment_audio']['name'])) {
                foreach ($_FILES['attachment_audio']['size'] as $size) {
                    if ($size > Config::UPLOAD_MAX_SIZE_AUDIO) {
                        throw new Exception(__('POST_ADD_ERROR_AUDIO_SIZE', array('size' => File::humanReadableSize(Config::UPLOAD_MAX_SIZE_AUDIO))));
                    }
                }
                if ($filepaths = File::upload('attachment_audio')) {
                    foreach ($filepaths as $filepath) {
                        $uploaded_files[] = $filepath;
                    }
                    foreach ($filepaths as $i => $filepath) {
                        if (!preg_match('#\\.mp3$#', $filepath)) {
                            throw new Exception(__('POST_ADD_ERROR_AUDIO_FORMAT'));
                        }
                        $name = isset($_FILES['attachment_audio']['name'][$i]) ? $_FILES['attachment_audio']['name'][$i] : '';
                        $attachments[] = array($filepath, $name);
                    }
                }
            }
            // Files
            if (isset($_FILES['attachment_file']) && is_array($_FILES['attachment_file']['name'])) {
                foreach ($_FILES['attachment_file']['size'] as $size) {
                    if ($size > Config::UPLOAD_MAX_SIZE_FILE) {
                        throw new Exception(__('POST_ADD_ERROR_FILE_SIZE', array('size' => File::humanReadableSize(Config::UPLOAD_MAX_SIZE_FILE))));
                    }
                }
                if ($filepaths = File::upload('attachment_file')) {
                    foreach ($filepaths as $filepath) {
                        $uploaded_files[] = $filepath;
                    }
                    foreach ($filepaths as $i => $filepath) {
                        if (!preg_match('#\\.[a-z0-9]{2,4}$#i', $filepath)) {
                            throw new Exception(__('POST_ADD_ERROR_FILE_FORMAT'));
                        }
                        if (preg_match('#\\.(jpg|png|gif|mp3|flv)$#i', $filepath)) {
                            throw new Exception(__('POST_ADD_ERROR_FILE_FORMAT2'));
                        }
                        $name = isset($_FILES['attachment_file']['name'][$i]) ? $_FILES['attachment_file']['name'][$i] : '';
                        $attachments[] = array($filepath, $name);
                    }
                }
            }
            // Event
            if (isset($_POST['event_title']) && isset($_POST['event_start']) && isset($_POST['event_end'])) {
                // Title
                $event_title = trim($_POST['event_title']);
                if ($event_title == '') {
                    throw new Exception(__('POST_ADD_ERROR_EVENT_NO_TITLE'));
                }
                // Dates
                if (!($event_start = strptime($_POST['event_start'], __('PUBLISH_EVENT_DATE_FORMAT')))) {
                    throw new Exception(__('POST_ADD_ERROR_EVENT_DATE'));
                }
                if (!($event_end = strptime($_POST['event_end'], __('PUBLISH_EVENT_DATE_FORMAT')))) {
                    throw new Exception(__('POST_ADD_ERROR_EVENT_DATE'));
                }
                $event_start = mktime($event_start['tm_hour'], $event_start['tm_min'], 0, $event_start['tm_mon'] + 1, $event_start['tm_mday'], $event_start['tm_year'] + 1900);
                $event_end = mktime($event_end['tm_hour'], $event_end['tm_min'], 0, $event_end['tm_mon'] + 1, $event_end['tm_mday'], $event_end['tm_year'] + 1900);
                if ($event_start > $event_end) {
                    throw new Exception(__('POST_ADD_ERROR_EVENT_DATE_ORDER'));
                }
                $event = array($event_title, $event_start, $event_end);
            } else {
                $event = null;
            }
            // Survey
            if (isset($_POST['survey_question']) && isset($_POST['survey_end']) && isset($_POST['survey_answer']) && is_array($_POST['survey_answer'])) {
                // Question
                $survey_question = trim($_POST['survey_question']);
                if ($survey_question == '') {
                    throw new Exception(__('POST_ADD_ERROR_SURVEY_NO_QUESTION'));
                }
                // Date
                if (!($survey_end = strptime($_POST['survey_end'], __('PUBLISH_EVENT_DATE_FORMAT')))) {
                    throw new Exception(__('POST_ADD_ERROR_SURVEY_DATE'));
                }
                $survey_end = mktime($survey_end['tm_hour'], $survey_end['tm_min'], 0, $survey_end['tm_mon'] + 1, $survey_end['tm_mday'], $survey_end['tm_year'] + 1900);
                // Multiple answers
                $survey_multiple = isset($_POST['survey_multiple']);
                // Answers
                $survey_answers = array();
                foreach ($_POST['survey_answer'] as $survey_answer) {
                    $survey_answer = trim($survey_answer);
                    if ($survey_answer != '') {
                        $survey_answers[] = $survey_answer;
                    }
                }
                if (count($survey_answers) < 2) {
                    throw new Exception(__('POST_ADD_ERROR_SURVEY_ANSWERS'));
                }
                $survey = array($survey_question, $survey_end, $survey_multiple, $survey_answers);
            } else {
                $survey = null;
            }
            // Creation of the post
            $id = $this->model->addPost((int) User_Model::$auth_data['id'], $message, $category, $group, $official, $private);
            // Attach files
            foreach ($attachments as $attachment) {
                $this->model->attachFile($id, $attachment[0], $attachment[1], isset($attachment[2]) ? $attachment[2] : null);
            }
            // Event
            if (isset($event)) {
                $this->model->attachEvent($id, $event[0], $event[1], $event[2]);
            }
            // Survey
            if (isset($survey)) {
                $this->model->attachSurvey($id, $survey[0], $survey[1], $survey[2], $survey[3]);
            }
            $this->addJSCode('
				parent.location = "' . Config::URL_ROOT . Routes::getPage('home') . '";
			');
        } catch (Exception $e) {
            // Delete all uploading files in tmp
            foreach ($uploaded_files as $uploaded_file) {
                File::delete($uploaded_file);
            }
            $this->addJSCode('
				with(parent){
					Post.errorForm(' . json_encode($e->getMessage()) . ');
				}
			');
        }
    }
 foreach ($scDbTable->ROWS as $etagenRow) {
     $rowId = $etagenRow->getNamedAttribute("rowid");
     $txfName = new Textfield("name" . $rowId, $etagenRow->getNamedAttribute("name"));
     $btnRaumplan = new Button("uploadImage" . $rowId, "Raumplan hochladen");
     $btnDelete = new Button("delete" . $rowId . "homecontrol_etagen", "entfernen");
     $imgRaumplan = "";
     if (isset($_REQUEST["uploadImage" . $rowId]) && $_REQUEST["uploadImage" . $rowId] == "Raumplan hochladen") {
         $hdnImg = new Hiddenfield("uploadImage" . $rowId, $_REQUEST["uploadImage" . $rowId]);
         $imgUploader = new ImageUploader("/pics/raumplan", "RP_", "homecontrol_etagen", "pic", $rowId, $hdnImg, $rowId . ".jpg");
         $imgUploader->show();
         $imgRaumplan = new Image(getDbValue("homecontrol_etagen", "pic", "id=" . $rowId));
     } else {
         $imgRaumplan = new Image(getEtagenImagePath($rowId));
     }
     $imgRaumplan->setGenerated(false);
     $imgRaumplan->setWidth(140);
     $cBtnRaumplan = new Container();
     $cBtnRaumplan->add($btnRaumplan);
     $cBtnRaumplan->add(new Text("<br>JPG Datei mit den Ma&#223;en: 600x340", 1, false, false, false, false));
     $r = $tblEtagen->createRow();
     $r->setStyle("padding", "10px 5px");
     $r->setVAlign("middle");
     $r->setAttribute(0, $txfName);
     $r->setAttribute(1, $imgRaumplan);
     $r->setAttribute(2, $cBtnRaumplan);
     $r->setAttribute(3, $btnDelete);
     $tblEtagen->addRow($r);
 }
 $fEt = new Form();
 $okBtn = new Button("DbTableUpdatehomecontrol_etagen", "Speichern");
 $okBtn->setStyle("display", "none");
Example #18
0
 /**
  * Edit a user
  */
 public function edit($params)
 {
     $this->setView('edit.php');
     $is_logged = isset(User_Model::$auth_data);
     $is_admin = $is_logged && User_Model::$auth_data['admin'] == '1';
     // Authorization
     if (!$is_admin) {
         throw new ActionException('Page', 'error404');
     }
     try {
         $student = $this->model->getInfo($params['username']);
     } catch (Exception $e) {
         throw new ActionException('Page', 'error404');
     }
     $this->setTitle(__('STUDENT_EDIT_TITLE', array('username' => $student['username'])));
     // Birthday
     $student['birthday'] = date(__('USER_EDIT_FORM_BIRTHDAY_FORMAT'), strtotime($student['birthday']));
     // Saving data
     if (isset($_POST['mail']) && isset($_POST['msn']) && isset($_POST['jabber']) && isset($_POST['address']) && isset($_POST['zipcode']) && isset($_POST['city']) && isset($_POST['cellphone']) && isset($_POST['phone']) && isset($_POST['birthday']) && isset($_POST['firstname']) && isset($_POST['lastname']) && isset($_POST['student_number']) && isset($_POST['promo'])) {
         $uploaded_files = array();
         try {
             // Other info
             $user_data = array('mail' => $_POST['mail'], 'msn' => $_POST['msn'], 'jabber' => $_POST['jabber'], 'address' => $_POST['address'], 'zipcode' => $_POST['zipcode'], 'city' => $_POST['city'], 'cellphone' => $_POST['cellphone'], 'phone' => $_POST['phone'], 'birthday' => $_POST['birthday']);
             $student_data = array('firstname' => $_POST['firstname'], 'lastname' => $_POST['lastname'], 'student_number' => $_POST['student_number'], 'promo' => $_POST['promo'], 'cesure' => isset($_POST['cesure']));
             // Avatar
             if (isset($_FILES['avatar']) && !is_array($_FILES['avatar']['name'])) {
                 if ($_FILES['avatar']['size'] > Config::UPLOAD_MAX_SIZE_PHOTO) {
                     throw new FormException('avatar');
                 }
                 if ($avatarpath = File::upload('avatar')) {
                     $uploaded_files[] = $avatarpath;
                     try {
                         $img = new Image();
                         $img->load($avatarpath);
                         $type = $img->getType();
                         if ($type == IMAGETYPE_JPEG) {
                             $ext = 'jpg';
                         } else {
                             if ($type == IMAGETYPE_GIF) {
                                 $ext = 'gif';
                             } else {
                                 if ($type == IMAGETYPE_PNG) {
                                     $ext = 'png';
                                 } else {
                                     throw new Exception();
                                 }
                             }
                         }
                         if ($img->getWidth() > 800) {
                             $img->setWidth(800, true);
                         }
                         $img->setType(IMAGETYPE_JPEG);
                         $img->save($avatarpath);
                         // Thumb
                         $avatarthumbpath = $avatarpath . '.thumb';
                         $img->thumb(Config::$AVATARS_THUMBS_SIZES[0], Config::$AVATARS_THUMBS_SIZES[1]);
                         $img->setType(IMAGETYPE_JPEG);
                         $img->save($avatarthumbpath);
                         unset($img);
                         $uploaded_files[] = $avatarthumbpath;
                         $student_data['avatar_path'] = $avatarthumbpath;
                         $student_data['avatar_big_path'] = $avatarpath;
                     } catch (Exception $e) {
                         throw new FormException('avatar');
                     }
                 }
             }
             $user_model = new User_Model();
             $user_model->save((int) $student['id'], $user_data);
             $this->model->save($student['username'], $student_data);
             Routes::redirect('student', array('username' => $params['username']));
         } catch (FormException $e) {
             foreach ($uploaded_files as $uploaded_file) {
                 File::delete($uploaded_file);
             }
             foreach ($student_data as $key => $value) {
                 $student[$key] = $value;
             }
             foreach ($user_data as $key => $value) {
                 $student[$key] = $value;
             }
             $this->set('form_error', $e->getError());
         }
     }
     $this->set('student', $student);
     $this->addJSCode('User.initEdit();');
 }
Example #19
0
 /**
  * Uploads an image file and stores its information in the database
  * @param   string  $upload_field_name  File input field name
  * @param   string  $target_path        Target path, relative to the
  *                                      document root, including the
  *                                      file name
  * @return  integer                     The new image ID on success,
  *                                      false otherwise
  * @author    Reto Kohli <*****@*****.**>
  */
 static function uploadAndStore($upload_field_name, &$target_path, $image_id = false, $imagetype_key = false, $ord = false)
 {
     // $target_path *SHOULD* be like ASCMS_HOTELCARD_IMAGES_FOLDER.'/folder/name.ext'
     // Strip path offset, if any, from the target path
     $target_path = preg_replace('/^' . preg_quote(ASCMS_PATH_OFFSET, '/') . '/', '', $target_path);
     if (!File::upload_file_http($upload_field_name, $target_path, self::MAXIMUM_UPLOAD_FILE_SIZE, Filetype::MIMETYPE_IMAGES_WEB)) {
         //echo("Image::uploadAndStore($upload_field_name, $target_path, $image_id, $imagetype_key, $ord): Failed to upload<br />");
         return false;
     }
     if ($image_id && $ord === false) {
         $ord = self::getNextOrd($image_id, $imagetype_key);
     }
     $objImage = new Image($ord, $image_id);
     $objImage->setPath($target_path);
     $size = getimagesize(ASCMS_DOCUMENT_ROOT . '/' . $target_path);
     $objImage->setWidth($size[0]);
     $objImage->setHeight($size[1]);
     $objImage->setImageTypeKey($imagetype_key);
     //echo("Image::uploadAndStore(): Made Image:<br />".var_export($objImage, true)."<br />");
     if (!$objImage->store()) {
         //echo("Image::uploadAndStore(): Failed to store<br />");
         //            if (!
         File::delete_file($target_path);
         //            ) {
         //echo("Image::uploadAndStore(): Failed to delete file $target_path<br />");
         //            }
         return false;
     }
     //echo("Image::uploadAndStore(): Successfully stored<br />");
     if ($imagetype_key) {
         if (!$objImage->resize()) {
             File::delete_file($target_path);
             return false;
         }
     }
     return $objImage->id;
 }
$ft->setFontsize(4);
//User-Name
$userRow = $userTable->createRow();
$userRow->setSpawnAll(true);
$userRow->setAlign("center");
$user = new Text($userDBRow->getNamedAttribute("User"));
$userRow->setAttribute(0, $user);
$user->setFonttype($ft);
$userTable->addRow($userRow);
$userTable->addSpacer(0);
//User-Avatar
$userRow1 = $userTable->createRow();
$userRow1->setSpawnAll(true);
$userRow1->setAlign("center");
$img = new Image($currPath . "pics/user/" . $userDBRow->getNamedAttribute("pic"));
$img->setWidth(250);
$userRow1->setAttribute(0, $img);
$userTable->addRow($userRow1);
$userTable->addSpacer(0);
//Name
$userRow2 = $userTable->createRow();
$userFullName = new Text($userDBRow->getNamedAttribute("Vorname") . " " . $userDBRow->getNamedAttribute("Nachname"));
$userRow2->setAttribute(0, "Name:");
$userRow2->setAttribute(1, $userFullName);
$userTable->addRow($userRow2);
//Strasse
$userRow3 = $userTable->createRow();
$userStrasse = new Text($userDBRow->getNamedAttribute("Strasse"));
$userRow3->setAttribute(0, "Strasse:");
$userRow3->setAttribute(1, $userStrasse);
$userTable->addRow($userRow3);