Beispiel #1
0
 /**
  * Moves a file that has been uploaded via a wiki pages resource form
  * to its correct position in the resources folder so it shows up for
  * that page
  *
  * @param string $tmp_type tmp location that uploaded file initially stored
  *  at
  * @param string $file_name file name of file that has been uploaded
  * @param string $mime_type mime type of uploaded file
  * @param int $group_id group identifier of group wiki page belongs to
  * @param int $page_id identifier for page want copy a page resource for
  */
 function copyFileToGroupPageResource($tmp_name, $file_name, $mime_type, $group_id, $page_id)
 {
     $folders = $this->getGroupPageResourcesFolders($group_id, $page_id);
     if (!$folders) {
         return false;
     }
     list($folder, $thumb_folder) = $folders;
     if (move_uploaded_file($tmp_name, "{$folder}/{$file_name}")) {
         $file_string = file_get_contents("{$folder}/{$file_name}");
     } else {
         return false;
     }
     if (in_array($mime_type, array('image/png', 'image/gif', 'image/jpeg'))) {
         $image = @imagecreatefromstring($file_string);
         $thumb_string = ImageProcessor::createThumb($image);
         file_put_contents("{$thumb_folder}/{$file_name}.jpg", $thumb_string);
         clearstatcache("{$thumb_folder}/{$file_name}.jpg");
     }
     if (defined('FFMPEG') && in_array($mime_type, array('video/mp4', 'video/webm', 'video/ogg', 'video/avi', 'video/quicktime'))) {
         $make_thumb_string = FFMPEG . " -i \"{$folder}/{$file_name}\" -vframes 1 -map 0:v:0" . " -vf \"scale=" . THUMB_DIM . ":" . THUMB_DIM . "\" " . "\"{$thumb_folder}/{$file_name}.jpg\" 2>&1";
         exec($make_thumb_string);
         clearstatcache("{$thumb_folder}/{$file_name}.jpg");
     }
 }
Beispiel #2
0
 /**
  * Used to update the fields stored in a USERS row according to
  * an array holding new values
  *
  * @param array $user updated values for a USERS row
  */
 function updateUser($user)
 {
     $user_id = $user['USER_ID'];
     if (isset($user['IMAGE_STRING'])) {
         $folder = $this->getUserIconFolder($user_id);
         $image = @imagecreatefromstring($user['IMAGE_STRING']);
         $thumb_string = ImageProcessor::createThumb($image);
         file_put_contents($folder . "/user_icon.jpg", $thumb_string);
         clearstatcache($folder . "/user_icon.jpg");
     }
     unset($user['USER_ID']);
     unset($user['USER_NAME']);
     unset($user['IMAGE_STRING']);
     unset($user['USER_ICON']);
     $sql = "UPDATE USERS SET ";
     $comma = "";
     $params = array();
     if ($user == array()) {
         return;
     }
     foreach ($user as $field => $value) {
         $sql .= "{$comma} {$field}=? ";
         $comma = ",";
         if ($field == "PASSWORD") {
             $params[] = crawlCrypt($value);
         } else {
             $params[] = $value;
         }
     }
     $sql .= " WHERE USER_ID=?";
     $params[] = $user_id;
     $this->db->execute($sql, $params);
 }