コード例 #1
0
ファイル: Collection.php プロジェクト: jubinpatel/horde
 /**
  * Creates a new file in the directory
  *
  * @param string $name Name of the file
  * @param resource|string $data Initial payload
  * @return null|string
  */
 public function createFile($name, $data = null)
 {
     list($app) = explode('/', $this->_path);
     if (is_resource($data)) {
         $content = new Horde_Stream_Existing(array('stream' => $data));
         $type = Horde_Mime_Magic::analyzeData($content->getString(0, 100), $this->_mimedb);
     } else {
         $content = $data;
         $type = Horde_Mime_Magic::analyzeData($content, $this->_mimedb);
     }
     if (!$type) {
         $type = Horde_Mime_Magic::filenameToMime($name);
     }
     try {
         $this->_registry->callByPackage($app, 'put', array($this->_path . '/' . $name, $content, $type));
     } catch (Horde_Exception $e) {
         throw new DAV\Exception($e->getMessage(), $e->getCode(), $e);
     }
 }
コード例 #2
0
ファイル: view.php プロジェクト: DSNS-LAB/Dmail
            }
        } else {
            $file_name = $tmpdir . '/mod_' . $file;
            if (!file_exists($file_name)) {
                copy($tmpdir . '/' . $file, $file_name);
            }
        }
        if (!file_exists($file_name)) {
            Horde::log(sprintf('Image not found [%s]', $file_name), 'ERR');
            exit;
        }
        $file_data = file_get_contents($file_name);
        break;
}
/* Load the image object. */
$type = Horde_Mime_Magic::analyzeData($file_data);
$image = $injector->getInstance('Horde_Core_Factory_Image')->create(array('data' => $file_data, 'type' => $type));
/* Check if no editing action required and send the image to browser. */
if (empty($action)) {
    $image->display();
    exit;
}
/* Image editing required. */
switch ($action) {
    case 'rotate':
        $image->rotate($vars->v);
        break;
    case 'flip':
        $image->flip();
        break;
    case 'mirror':
コード例 #3
0
ファイル: Driver.php プロジェクト: kossamums/horde
 /**
  * Convert an ActiveSync contact message into a hash suitable for
  * importing via self::add().
  *
  * @param Horde_ActiveSync_Message_Contact $message  The contact message
  *                                                   object.
  *
  * @return array  A contact hash.
  */
 public function fromASContact(Horde_ActiveSync_Message_Contact $message)
 {
     $hash = array();
     foreach (self::$_asMap as $turbaField => $asField) {
         if (!$message->isGhosted($asField)) {
             try {
                 $hash[$turbaField] = $message->{$asField};
             } catch (InvalidArgumentException $e) {
             }
         }
     }
     /* Requires special handling */
     try {
         if ($message->getProtocolVersion() >= Horde_ActiveSync::VERSION_TWELVE) {
             if (!empty($message->airsyncbasebody)) {
                 $hash['notes'] = $message->airsyncbasebody->data;
             }
         } else {
             $hash['notes'] = $message->body;
         }
     } catch (InvalidArgumentException $e) {
     }
     // picture ($message->picture *should* already be base64 encdoed)
     if (!$message->isGhosted('picture')) {
         $hash['photo'] = base64_decode($message->picture);
         if (!empty($hash['photo'])) {
             $hash['phototype'] = Horde_Mime_Magic::analyzeData($hash['photo']);
         } else {
             $hash['phototype'] = null;
         }
     }
     /* Email addresses */
     $hash['emails'] = array();
     if (!$message->isGhosted('email1address')) {
         $e = Horde_Icalendar_Vcard::getBareEmail($message->email1address);
         $hash['emails'][] = $hash['email'] = $e ? $e : '';
     }
     if (!$message->isGhosted('email2address')) {
         $e = Horde_Icalendar_Vcard::getBareEmail($message->email2address);
         $hash['emails'][] = $hash['homeEmail'] = $e ? $e : '';
     }
     if (!$message->isGhosted('email3address')) {
         $e = Horde_Icalendar_Vcard::getBareEmail($message->email3address);
         $hash['emails'][] = $hash['workEmail'] = $e ? $e : '';
     }
     $hash['emails'] = implode(',', $hash['emails']);
     /* Categories */
     if (is_array($message->categories) && count($message->categories)) {
         $hash['__tags'] = $message->categories;
     }
     /* Children */
     if (is_array($message->children) && count($message->children)) {
         // We use a comma as incoming delimiter as it's the most
         // common even though it might be used withing a name string.
         $hash['children'] = implode(', ', $message->children);
     } elseif (!$message->isGhosted('children')) {
         $hash['children'] = '';
     }
     /* Birthday and Anniversary */
     if (!empty($message->birthday)) {
         $bday = clone $message->birthday;
         $bday->setTimezone(date_default_timezone_get());
         $hash['birthday'] = $bday->format('Y-m-d');
     } elseif (!$message->isGhosted('birthday')) {
         $hash['birthday'] = '';
     }
     if (!empty($message->anniversary)) {
         $anniversary = clone $message->anniversary;
         $anniversary->setTimezone(date_default_timezone_get());
         $hash['anniversary'] = $anniversary->format('Y-m-d');
     } elseif (!$message->isGhosted('anniversary')) {
         $hash['anniversary'] = '';
     }
     /* Countries */
     include 'Horde/Nls/Countries.php';
     if (!empty($message->homecountry)) {
         if (!empty($this->map['homeCountryFree'])) {
             $hash['homeCountryFree'] = $message->homecountry;
         } else {
             $country = array_search($message->homecountry, $countries);
             if ($country === false) {
                 $country = $message->homecountry;
             }
             $hash['homeCountry'] = $country;
         }
     } elseif (!$message->isGhosted('homecountry')) {
         $hash['homeCountry'] = '';
     }
     if (!empty($message->businesscountry)) {
         if (!empty($this->map['workCountryFree'])) {
             $hash['workCountryFree'] = $message->businesscountry;
         } else {
             $country = array_search($message->businesscountry, $countries);
             if ($country === false) {
                 $country = $message->businesscountry;
             }
             $hash['workCountry'] = $country;
         }
     } elseif (!$message->isGhosted('businesscountry')) {
         $hash['workCountry'] = '';
     }
     if (!empty($message->othercountry)) {
         if (!empty($this->map['otherCountryFree'])) {
             $hash['otherCountryFree'] = $message->othercountry;
         } else {
             $country = array_search($message->othercountry, $countries);
             if ($country === false) {
                 $country = $message->othercountry;
             }
             $hash['otherCountry'] = $country;
         }
     } elseif (!$message->isGhosted('othercountry')) {
         $hash['otherCountry'] = '';
     }
     return $hash;
 }
コード例 #4
0
ファイル: Application.php プロジェクト: raz0rsdge/horde
 /**
  */
 public function download(Horde_Variables $vars)
 {
     global $wicked;
     $page = $vars->get('page', 'Wiki/Home');
     $page_id = ($id = $wicked->getPageId($page)) === false ? $page : $id;
     $version = $vars->version;
     if (empty($version)) {
         try {
             $attachments = $wicked->getAttachedFiles($page_id);
             foreach ($attachments as $attachment) {
                 if ($attachment['attachment_name'] == $vars->file) {
                     $version = $attachment['attachment_version'];
                 }
             }
         } catch (Wicked_Exception $e) {
         }
         if (empty($version)) {
             // If we redirect here, we cause an infinite loop with inline
             // attachments.
             header('HTTP/1.1 404 Not Found');
             exit;
         }
     }
     try {
         $data = $wicked->getAttachmentContents($page_id, $vars->file, $version);
         $wicked->logAttachmentDownload($page_id, $vars->file);
     } catch (Wicked_Exception $e) {
         // If we redirect here, we cause an infinite loop with inline
         // attachments.
         header('HTTP/1.1 404 Not Found');
         echo $e->getMessage();
         exit;
     }
     $type = Horde_Mime_Magic::analyzeData($data, isset($conf['mime']['magic_db']) ? $conf['mime']['magic_db'] : null);
     if ($type === false) {
         $type = Horde_Mime_Magic::filenameToMime($vars->file, false);
     }
     return array('data' => $data, 'file' => $vars->file, 'type' => $type);
 }