Esempio n. 1
0
 static function delete($templateId)
 {
     if ($id = intval($templateId)) {
         $db = Registry::getInstance()->get('db');
         $attachment = new attachment(self::TABLE, $id);
         $attachment->unlinkAll();
         parent::delete($id);
     }
 }
Esempio n. 2
0
function archive_attachment($aid,$key) {
    if (!$aid)
        return;
    $oattachment=new attachment();
    $attachment=$oattachment->getrow('aid='.$aid);
    if (is_array($attachment) &&isset($attachment[$key]))
        return $attachment[$key];
    else
        return;
}
 function import_vcard($params)
 {
     include_once 'class.imap_functions.inc.php';
     $objImap = new imap_functions();
     $msg_number = $params['msg_number'];
     $idx_file = $params['idx_file'];
     $msg_part = $params['msg_part'];
     $msg_folder = $params['msg_folder'];
     $from_ajax = $params['from_ajax'];
     $encoding = strtolower($params['encoding']);
     $fileContent = "";
     $cirus_delimiter = $params['cirus_delimiter'];
     $expFolder = explode($cirus_delimiter, $msg_folder);
     if ($msg_number != null && $msg_part != null && $msg_folder != null && intval($idx_file == '0' ? '1' : $idx_file)) {
         require_once PHPGW_INCLUDE_ROOT . '/expressoMail/inc/class.attachment.inc.php';
         $attachmentObj = new attachment();
         $attachmentObj->setStructureFromMail($msg_folder, $msg_number);
         $fileContent = $attachmentObj->getAttachment($msg_part);
         $info = $attachmentObj->getAttachmentInfo($msg_part);
         $filename = $info['name'];
     } else {
         $filename = $idx_file;
     }
     // It's necessary to access calendar method.
     $GLOBALS['phpgw_info']['flags']['noappheader'] = True;
     $GLOBALS['phpgw_info']['flags']['noappfooter'] = True;
     $GLOBALS['phpgw_info']['flags']['currentapp'] = 'calendar';
     if (isset($params['selected']) || isset($params['readable'])) {
         $_REQUEST['data'] = $fileContent;
         $_REQUEST['type'] = 'iCal';
         $_REQUEST['params']['calendar'] = isset($params['selected']) ? $params['selected'] : false;
         $_REQUEST['readable'] = isset($params['readable']) && $params['readable'] ? true : false;
         $_REQUEST['analize'] = isset($params['analize']) ? true : false;
         $_REQUEST['params']['status'] = isset($params['status']) ? $params['status'] : false;
         $_REQUEST['params']['owner'] = $params['uidAccount'];
         if (isset($params['acceptedSuggestion'])) {
             $_REQUEST['params']['acceptedSuggestion'] = $params['acceptedSuggestion'];
             $_REQUEST['params']['from'] = $params['from'];
         }
         ob_start();
         include_once PHPGW_INCLUDE_ROOT . '/prototype/converter.php';
         $output = ob_get_clean();
         $valid = json_decode($output, true);
         if ($_REQUEST['readable']) {
             if (!is_array($valid)) {
                 $output = unserialize($output);
                 foreach ($output as $key => $value) {
                     return $value;
                 }
             }
             return false;
         }
         if (empty($output)) {
             return "error";
         }
         return "ok";
     }
     include_once PHPGW_INCLUDE_ROOT . '/header.inc.php';
     $uiicalendar = CreateObject("calendar.uiicalendar");
     if (strtoupper($expFolder[0]) == 'USER' && $expFolder[1]) {
         include_once 'class.ldap_functions.inc.php';
         $ldap = new ldap_functions();
         $account['uid'] = $expFolder[1];
         $account['uidnumber'] = $ldap->uid2uidnumber($expFolder[1]);
         $account['mail'] = $ldap->getMailByUid($expFolder[1]);
         return $uiicalendar->import_from_mail($fileContent, $from_ajax, $account);
     } else {
         return $uiicalendar->import_from_mail($fileContent, $from_ajax);
     }
 }
Esempio n. 4
0
 function assignTo($userId)
 {
     global $dbInst, $loginInst;
     if (!$loginInst->hasAccess("request.assignTo")) {
         return false;
     }
     $taskInst = new task();
     $taskInst->subject = $this->subject;
     $taskInst->body = $this->body;
     $taskInst->projectId = $this->projectId;
     $taskInst->typeId = $this->typeId;
     $taskInst->priorityId = $this->priorityId;
     $taskInst->userId = $userId;
     $taskInst->statusId = TASK_STATUS_REQUEST;
     $taskInst->posterId = $loginInst->id;
     $taskInst->attachments = $this->attachments;
     $taskId = $taskInst->insert();
     if (!$taskId) {
         return false;
     }
     // task saved successfully. Now whe can assign the attachments to the task id
     $taskInst->id = $taskId;
     while ($element = current($taskInst->attachments)) {
         $attachment = new attachment($element);
         $attachment->taskId = $taskId;
         $attachment->update();
         next($taskInst->attachments);
     }
     // the attachments are now assigned to the task -> so we should
     // clean the attachment array in the request instance, to prevent
     // deleting of the attachments
     $this->attachments = array();
     if ($this->delete()) {
         return $taskId;
     }
     return false;
 }
 function get($attach_id)
 {
     global $db;
     $sql = "SELECT * FROM " . ATTACHMENTS_TABLE . " WHERE attach_id=" . intval($attach_id);
     $result = $db->sql_query($sql);
     $attach_data = $db->sql_fetchrow($result);
     $db->sql_freeresult($result);
     if (!$attach_data) {
         //attachment does not exist, return false
         return false;
     }
     return attachment::from_array($attach_data);
 }
Esempio n. 6
0
 function download_all_attachments($params)
 {
     require_once dirname(__FILE__) . '/class.attachment.inc.php';
     $atObj = new attachment();
     $atObj->setStructureFromMail($params['folder'], $params['num_msg']);
     $attachments = $atObj->getAttachmentsInfo();
     $id_number = $params['num_msg'];
     $tempDir = $this->tempDir;
     $tempSubDir = $_SESSION['phpgw_session']['session_id'];
     $fileNames = '';
     exec('mkdir ' . $tempDir . '/' . $tempSubDir . '; cd ' . $tempDir . '/' . $tempSubDir);
     $this->folder = $params['folder'];
     $this->folder = mb_convert_encoding($this->folder, "UTF7-IMAP", "UTF-8");
     $fileNames = array();
     $attachments_count = count($attachments);
     for ($i = 0; $i < $attachments_count; ++$i) {
         $attachments[$i]['name'] = $this->remove_accents($attachments[$i]['name']);
         $fileNames[$i] = $attachments[$i]['name'];
     }
     $attachments_count = count($attachments);
     for ($i = 0; $i < $attachments_count; ++$i) {
         $fileName = $attachments[$i]['name'];
         $result = array_keys($fileNames, $fileName);
         // Detecta duplicatas
         if (count($result) > 1) {
             $result_count = count($result);
             for ($j = 1; $j < $result_count; ++$j) {
                 $replacement = '(' . $j . ')$0';
                 if (preg_match('/\\.\\w{2,4}$/', $fileName)) {
                     $fileNames[$result[$j]] = preg_replace('/\\.\\w{2,4}$/', $replacement, $fileName);
                 } else {
                     $fileNames[$result[$j]] .= "({$j})";
                 }
                 $attachments[$result[$j]]['name'] = $fileNames[$result[$j]];
             }
         }
         // Fim detecta duplicatas
         $f = fopen($tempDir . '/' . $tempSubDir . '/' . $fileName, "wb");
         if (!$f) {
             return False;
         }
         $fileContent = $atObj->getAttachment($attachments[$i]['pid']);
         fputs($f, $fileContent);
         fclose($f);
     }
     imap_close($this->mbox_stream);
     $nameFileZip = '';
     if (!empty($fileNames)) {
         $nameFileZip = $this->createFileZip($fileNames, $tempDir . '/' . $tempSubDir);
         if ($nameFileZip) {
             $file = $tempDir . '/' . $tempSubDir . '/' . $nameFileZip;
         } else {
             $file = false;
         }
     } else {
         $file = false;
     }
     include_once dirname(__FILE__) . '/../../prototype/library/utils/Logger.php';
     Logger::info('expressomail', 'downloadAllAttachment', $atObj->messageId);
     return $file;
 }
Esempio n. 7
0
 function deleteattachment_action() {
     $attachment=new attachment();
     $id = intval(front::get('id'));
     $attachment->del($id);
 }
Esempio n. 8
0
 /**
  * Constructor
  * 
  * @param string $data        File data
  * @param string $name        Name of attachment (filename)
  * @param string $contentType Content type of file
  * @param string $encoding    What encoding to use
  */
 public function __construct($data, $name = '', $contentType = 'application/octet-stream', $encoding = null)
 {
     $encoding = is_null($encoding) ? new Base64Encoding() : $encoding;
     parent::__construct($data, $name, $contentType, $encoding);
 }
Esempio n. 9
0
 /**
  * 采集内容
  * @param string $url    采集地址
  * @param array $config  配置参数
  * @param integer $page  分页采集模式
  */
 public static function get_content($url, $config, $page = 0)
 {
     set_time_limit(300);
     static $oldurl = array();
     $page = intval($page) ? intval($page) : 0;
     if ($html = self::get_html($url, $config)) {
         if (empty($page)) {
             //获取标题
             if ($config['title_rule']) {
                 $title_rule = self::replace_sg($config['title_rule']);
                 $data['title'] = self::replace_item(self::cut_html($html, $title_rule[0], $title_rule[1]), $config['title_html_rule']);
             }
             //获取作者
             if ($config['author_rule']) {
                 $author_rule = self::replace_sg($config['author_rule']);
                 $data['author'] = self::replace_item(self::cut_html($html, $author_rule[0], $author_rule[1]), $config['author_html_rule']);
             }
             //获取来源
             if ($config['comeform_rule']) {
                 $comeform_rule = self::replace_sg($config['comeform_rule']);
                 $data['comeform'] = self::replace_item(self::cut_html($html, $comeform_rule[0], $comeform_rule[1]), $config['comeform_html_rule']);
             }
             //获取时间
             if ($config['time_rule']) {
                 $time_rule = self::replace_sg($config['time_rule']);
                 $data['time'] = strtotime(self::replace_item(self::cut_html($html, $time_rule[0], $time_rule[1]), $config['time_html_rule']));
             }
             if (empty($data['time'])) {
                 $data['time'] = SYS_TIME;
             }
             //对自定义数据进行采集
             if ($config['customize_config'] = string2array($config['customize_config'])) {
                 foreach ($config['customize_config'] as $k => $v) {
                     if (empty($v['rule'])) {
                         continue;
                     }
                     $rule = self::replace_sg($v['rule']);
                     $data[$v['en_name']] = self::replace_item(self::cut_html($html, $rule[0], $rule[1]), $v['html_rule']);
                 }
             }
         }
         //获取内容
         if ($config['content_rule']) {
             $content_rule = self::replace_sg($config['content_rule']);
             $data['content'] = self::replace_item(self::cut_html($html, $content_rule[0], $content_rule[1]), $config['content_html_rule']);
         }
         //处理分页
         if (in_array($page, array(0, 2)) && !empty($config['content_page_start']) && !empty($config['content_page_end'])) {
             $oldurl[] = $url;
             $tmp[] = $data['content'];
             $page_html = self::cut_html($html, $config['content_page_start'], $config['content_page_end']);
             //上下页模式
             if ($config['content_page_rule'] == 2 && in_array($page, array(0, 2)) && $page_html) {
                 preg_match_all('/<a[^>]*href=[\'"]?([^>\'" ]*)[\'"]?[^>]*>([^<\\/]*)<\\/a>/i', $page_html, $out);
                 if (!empty($out[1]) && !empty($out[2])) {
                     foreach ($out[2] as $k => $v) {
                         if (strpos($v, $config['content_nextpage']) === false) {
                             continue;
                         }
                         if ($out[1][$k] == '#') {
                             continue;
                         }
                         $out[1][$k] = self::url_check($out[1][$k], $url, $config);
                         if (in_array($out[1][$k], $oldurl)) {
                             continue;
                         }
                         $oldurl[] = $out[1][$k];
                         $results = self::get_content($out[1][$k], $config, 2);
                         if (!in_array($results['content'], $tmp)) {
                             $tmp[] = $results['content'];
                         }
                     }
                 }
             }
             //全部罗列模式
             if ($config['content_page_rule'] == 1 && $page == 0 && $page_html) {
                 preg_match_all('/<a[^>]*href=[\'"]?([^>\'" ]*)[\'"]?/i', $page_html, $out);
                 if (is_array($out[1]) && !empty($out[1])) {
                     $out = array_unique($out[1]);
                     foreach ($out as $k => $v) {
                         if ($out[1][$k] == '#') {
                             continue;
                         }
                         $v = self::url_check($v, $url, $config);
                         $results = self::get_content($v, $config, 1);
                         if (!in_array($results['content'], $tmp)) {
                             $tmp[] = $results['content'];
                         }
                     }
                 }
             }
             $data['content'] = $config['content_page'] == 1 ? implode('[page]', $tmp) : implode('', $tmp);
         }
         if ($page == 0) {
             self::$url = $url;
             self::$config = $config;
             $data['content'] = preg_replace('/<img[^>]*src=[\'"]?([^>\'"\\s]*)[\'"]?[^>]*>/ie', "self::download_img('\$0', '\$1')", $data['content']);
             //下载内容中的图片到本地
             if (empty($page) && !empty($data['content']) && $config['down_attachment'] == 1) {
                 pc_base::load_sys_class('attachment', '', 0);
                 $attachment = new attachment('collection', '0', get_siteid());
                 $data['content'] = $attachment->download('content', $data['content'], $config['watermark']);
             }
         }
         return $data;
     }
 }
Esempio n. 10
0
 /**
  * Generate post from array data. Data is assumed to be loaded from database, thus the message is decoded.
  *
  * @param array $post_data
  * @return Gn36\OoPostingApi\post
  */
 static function from_array($post_data)
 {
     global $db;
     if (!is_array($post_data)) {
         trigger_error('post::from_array - $post_data not an array');
     }
     //create object and fill in data
     $post = new post();
     $post->post_id = $post_data['post_id'];
     $post->topic_id = $post_data['topic_id'];
     $post->forum_id = $post_data['forum_id'];
     $post->poster_id = $post_data['poster_id'];
     $post->post_username = $post_data['post_username'];
     $post->poster_ip = $post_data['poster_ip'];
     $post->icon_id = $post_data['icon_id'];
     $post->post_time = $post_data['post_time'];
     $post->post_postcount = $post_data['post_postcount'];
     $post->post_visibility = $post_data['post_visibility'];
     $post->post_reported = $post_data['post_reported'];
     $post->enable_bbcode = $post_data['enable_bbcode'];
     $post->enable_smilies = $post_data['enable_smilies'];
     $post->enable_magic_url = $post_data['enable_magic_url'];
     $post->enable_sig = $post_data['enable_sig'];
     $post->post_subject = $post_data['post_subject'];
     if (isset($post_data['post_attachment'])) {
         $post->post_attachment = $post_data['post_attachment'];
     }
     $post->post_edit_time = $post_data['post_edit_time'];
     $post->post_edit_reason = $post_data['post_edit_reason'];
     $post->post_edit_user = $post_data['post_edit_user'];
     $post->post_edit_count = $post_data['post_edit_count'];
     $post->post_delete_reason = $post_data['post_delete_reason'];
     $post->post_delete_time = $post_data['post_delete_time'];
     $post->post_delete_user = $post_data['post_delete_user'];
     //parse message
     decode_message($post_data['post_text'], $post_data['bbcode_uid']);
     $post_data['post_text'] = str_replace(array('&#58;', '&#46;'), array(':', '.'), $post_data['post_text']);
     $post->post_text = $post_data['post_text'];
     //attachments
     if ($post->post_attachment) {
         $sql = "SELECT * FROM " . ATTACHMENTS_TABLE . " WHERE post_msg_id=" . $post->post_id;
         $result = $db->sql_query($sql);
         while ($attach_row = $db->sql_fetchrow($result)) {
             $post->attachments[] = attachment::from_array($attach_row);
         }
     }
     return $post;
 }
 function getForwardingAttachment($folder, $uid, $part, $rfc_822bodies = true, $info = true)
 {
     include_once dirname(__FILE__) . '/class.attachment.inc.php';
     $attachment = new attachment();
     $attachment->decodeConf['rfc_822bodies'] = $rfc_822bodies;
     //Forçar a não decodificação de mensagens em anexo.
     $folder = urldecode($folder);
     $attachment->setStructureFromMail($folder, $uid);
     if ($info === true) {
         $return = $attachment->getAttachmentInfo($part);
         $return['source'] = $attachment->getAttachment($part);
         return $return;
     }
     return $attachment->getAttachment($part);
 }
Esempio n. 12
0
 /**
  * Write in $$attachments, array with the information of attachment 
  * @param <type> $structure 
  * @param <type> $attachments 
  * @param <type> $pIndex 
  */
 private function _pushAttachmentsInfo(&$structure, &$attachments, $pIndex = '0')
 {
     $name = '';
     if (isset($structure->d_parameters['filename']) && $structure->d_parameters['filename']) {
         $name = $structure->d_parameters['filename'];
     } else {
         if (isset($structure->ctype_parameters['name']) && $structure->ctype_parameters['name']) {
             $name = $structure->ctype_parameters['name'];
         } else {
             if (strtolower($structure->ctype_primary) == 'text' && strtolower($structure->ctype_secondary) == 'calendar') {
                 $name = 'calendar.ics';
             }
         }
     }
     //Attachments com nomes grandes são quebrados em varias partes VER RFC2231
     if (!$name && isset($structure->disposition) && (strtolower($structure->disposition) === 'attachment' || strtolower($structure->ctype_primary) == 'image' || strtolower($structure->ctype_primary . '/' . $structure->ctype_secondary) == 'application/octet-stream')) {
         foreach ($structure->d_parameters as $i => $v) {
             if (strpos($i, 'filename') !== false) {
                 $name .= urldecode(str_ireplace(array('ISO-8859-1', 'UTF-8', 'US-ASCII'), '', $v));
             }
         }
     }
     if (!$name && isset($structure->disposition) && (strtolower($structure->disposition) === 'attachment' || strtolower($structure->ctype_primary) == 'image' || strtolower($structure->ctype_primary . '/' . $structure->ctype_secondary) == 'application/octet-stream')) {
         foreach ($structure->ctype_parameters as $i => $v) {
             if (strpos($i, 'name') !== false) {
                 $name .= urldecode(str_ireplace(array('ISO-8859-1', 'UTF-8', 'US-ASCII'), '', $v));
             }
         }
     }
     ////////////////////////////////////////////////////////////////////////////////////
     if ($structure->ctype_primary == 'message') {
         $attach = new attachment();
         $attach->setStructureFromRawMail($structure->body);
         if (!$name) {
             $name = isset($attach->structure->headers['subject']) ? $attach->structure->headers['subject'] : 'no title';
         }
         if (!preg_match("/\\.eml\$/", $name)) {
             $name .= '.eml';
         }
     }
     if (!$name && strtolower($structure->ctype_primary) == 'image') {
         if (strlen($structure->ctype_secondary) === 3) {
             $ext = strtolower($structure->ctype_secondary);
         }
         $name = 'Embedded-Image.' . $ext;
     }
     if ($name) {
         $codificao = mb_detect_encoding($name . 'x', 'UTF-8, ISO-8859-1');
         if ($codificao == 'UTF-8') {
             $name = utf8_decode($name);
         }
         $definition['pid'] = $pIndex;
         $definition['name'] = addslashes(mb_convert_encoding($name, "ISO-8859-1"));
         $definition['encoding'] = $structure->headers['content-transfer-encoding'];
         $definition['type'] = strtolower($structure->ctype_primary) . '/' . strtolower($structure->ctype_secondary);
         $definition['fsize'] = mb_strlen($structure->body, $structure->headers['content-transfer-encoding']);
         array_push($attachments, $definition);
     }
 }
Esempio n. 13
0
		* Expresso Livre                                                           * 
		* http://www.expressolivre.org                                             * 
		* --------------------------------------------                             * 
		*  This program is free software; you can redistribute it and/or modify it * 
		*  under the terms of the GNU General Public License as published by the   * 
		*  Free Software Foundation; either version 2 of the License, or (at your  * 
		*  option) any later version.                                              * 
		\**************************************************************************/
/*
 * Requieres
 */
require_once '../../header.session.inc.php';
require_once dirname(__FILE__) . '/class.attachment.inc.php';
//------------------------//
/*
 * Get variables
 */
$msgFolder = $_GET['msg_folder'];
$msgNumber = $_GET['msg_num'];
$embeddedPart = $_GET['msg_part'];
//-------------------------------------//
/*
 * Main
 */
$attachmentObj = new attachment();
$attachmentObj->setStructureFromMail($msgFolder, $msgNumber);
$fileContent = $attachmentObj->getAttachment($embeddedPart);
header("Content-Type: image/jpeg");
header("Content-Disposition: inline");
echo $fileContent;
//------------------------------------------//
Esempio n. 14
0
 /**
  * boolean update()
  * updates a task in database
  * @return true on success, else false
  * @access public
  */
 function update()
 {
     global $dbInst, $config, $toolInst, $loginInst;
     if (!$loginInst->hasAccess("task.update")) {
         return false;
     }
     if (!$this->check()) {
         return false;
     }
     if ($this->id == $this->mountId) {
         $toolInst->errorStatus("recursion error: unable to mount task into itself");
         return false;
     }
     if (in_array($this->id, $this->treeId($this->mountId))) {
         $toolInst->errorStatus("recursion error: unable to mount task into one of its members");
         return false;
     }
     $query = "update " . $dbInst->config['table_task'] . " set " . "finish = '" . $this->finish . "'," . "plannedhours = '" . $this->plannedHours . "',";
     if ($loginInst->hasAccess("task.fixedPrice")) {
         $query .= "fixedprice = '" . str_replace(',', '.', $this->fixedPrice) . "',";
     }
     $query .= "body = '" . $this->body . "'," . "type_id = '" . $this->typeId . "'," . "user_id = '" . $this->userId . "'," . "subject = '" . $this->subject . "'," . "mount_id = '" . $this->mountId . "'," . "status_id = '" . $this->statusId . "'," . "poster_id = '" . $this->posterId . "'," . "project_id = '" . $this->projectId . "'," . "priority_id = '" . $this->priorityId . "' where id = '" . $this->id . "'";
     $result = $dbInst->query($query);
     $dbInst->status($result[1], "u");
     if ($result[1] == 1 || $result[1] == 0) {
         // notification mail to manager, if task set to done
         if ($result[1] == 1 && $this->isDone()) {
             $projectInst = new project($this->projectId);
             $this->mail($projectInst->managerId, " --== TASK DONE ==--\n\nused time: " . $toolInst->formatTime($this->getSummary()));
         }
         // logging
         $userInst = new user($this->userId);
         $this->logger->info("changed task (" . $this->subject . ") for " . $userInst->name);
         if (tool::secureFiles('userfile', 'name') && @file_exists(tool::secureFiles('userfile', 'tmp_name'))) {
             // attachment successfully uploaded, we can save it
             $attach = new attachment();
             $attach->taskId = $this->id;
             $attach->insert();
             $this->logger->info("added attachment (" . $this->file . ") to task " . $this->subject);
             unset($_FILES['userfile']);
         }
         // process all childs
         $childs = $this->childs();
         while ($element = current($childs)) {
             $child = new task($element);
             // we need to update the project id in all child tasks
             $child->projectId = $this->projectId;
             // task is set to status "done", we should start all child tasks now
             if ($this->isDone()) {
                 $child->start();
                 $child->mail($child->userId, "There's an automatically started task for you:");
             }
             $child->update();
             next($childs);
         }
         return true;
     }
     return false;
 }
Esempio n. 15
0
 public function crop_upload()
 {
     if (isset($GLOBALS["HTTP_RAW_POST_DATA"])) {
         $pic = $GLOBALS["HTTP_RAW_POST_DATA"];
         if (isset($_GET['width']) && !empty($_GET['width'])) {
             $width = intval($_GET['width']);
         }
         if (isset($_GET['height']) && !empty($_GET['height'])) {
             $height = intval($_GET['height']);
         }
         if (isset($_GET['file']) && !empty($_GET['file'])) {
             $_GET['file'] = str_ireplace(';', '', 'php', $_GET['file']);
             if (is_image($_GET['file']) == false || stripos($_GET['file'], '.php') !== false) {
                 exit;
             }
             if (strpos($_GET['file'], pc_base::load_config('system', 'upload_url')) !== false) {
                 $file = $_GET['file'];
                 $basename = basename($file);
                 if (strpos($basename, 'thumb_') !== false) {
                     $file_arr = explode('_', $basename);
                     $basename = array_pop($file_arr);
                 }
                 $new_file = 'thumb_' . $width . '_' . $height . '_' . $basename;
             } else {
                 pc_base::load_sys_class('attachment', '', 0);
                 $module = trim($_GET['module']);
                 $catid = intval($_GET['catid']);
                 $siteid = $this->get_siteid();
                 $attachment = new attachment($module, $catid, $siteid);
                 $uploadedfile['filename'] = basename($_GET['file']);
                 $uploadedfile['fileext'] = fileext($_GET['file']);
                 if (in_array($uploadedfile['fileext'], array('jpg', 'gif', 'jpeg', 'png', 'bmp'))) {
                     $uploadedfile['isimage'] = 1;
                 }
                 $file_path = $this->upload_path . date('Y/md/');
                 pc_base::load_sys_func('dir');
                 dir_create($file_path);
                 $new_file = date('Ymdhis') . rand(100, 999) . '.' . $uploadedfile['fileext'];
                 $uploadedfile['filepath'] = date('Y/md/') . $new_file;
                 $aid = $attachment->add($uploadedfile);
             }
             $filepath = date('Y/md/');
             file_put_contents($this->upload_path . $filepath . $new_file, $pic);
         } else {
             return false;
         }
         echo pc_base::load_config('system', 'upload_url') . $filepath . $new_file;
         exit;
     }
 }
Esempio n. 16
0
 function delete_before($id) {
     $arc = new archive();
     $info = $arc->getrow($id);
     $attachment = new attachment();
     $res = $attachment->getrows(array("aid"=>$id));
     if(is_array($res) && !empty($res)){
     	foreach($res as $v){
     		@unlink($v['path']);
     	}
     }
     
     if(category::getarcishtml($info)) {
         $path=ROOT.preg_replace("%".THIS_URL."[\\/]%",'',archive::url($info));
         if(file_exists($path)) unlink($path);
     }
     
 }
Esempio n. 17
0
 /**
  * Constructor
  *
  * @param string $infilename  Name of input file
  * @param string $outfilename Name of file to use as attachment
  * @param string $contentType Content type of file
  * @param string $encoding    What encoding to use
  */
 public function __construct($infilename, $outfilename, $contentType = 'application/octet-stream', $encoding = null)
 {
     $encoding = is_null($encoding) ? new Base64Encoding() : $encoding;
     parent::__construct(file_get_contents($infilename), $outfilename, $contentType, $encoding);
 }
Esempio n. 18
0
}
?>

  <form method="post" name="form3" action="taskdetails.php">
  <input type="hidden" name="action" value="deleteattach">
  <input type="hidden" name="id" value="">
  <tr class="light">
    <td><?php 
echo $lang['common_attachment'];
?>
</td>
    <td>
      <table border="0" cellpadding="2" cellspacing="1" width="100%">
      <?php 
while ($a = current($taskInst->attachments)) {
    $attachment = new attachment($a);
    echo "<tr class=light>\n";
    echo "<td><a href=\"" . tool::encodeUrl("fileget.php?created=" . $attachment->created . "&filename=" . $attachment->name) . "\" title=\"" . $lang['common_open'] . " " . $attachment->name . " " . $lang['common_inANewWindow'] . "\">" . $attachment->name . "</a></td>\n";
    echo "<td>" . $attachment->getSize() . "</td>\n";
    ?>
<td align=right><a href="javascript:document.form3.id.value='<?php 
    echo $a;
    ?>
';document.form3.submit()"><img src="grafx/delete.gif" onClick="return Check();" width="16" height="15" border="0" title="<?php 
    echo $lang['tasks_deleteThisJob'];
    ?>
"></a></td><?php 
    next($taskInst->attachments);
    echo "</tr>\n";
}
?>
Esempio n. 19
0
    }
    if ($num < 65536) {
        return chr(($num >> 12) + 224) . chr(($num >> 6 & 63) + 128) . chr(($num & 63) + 128);
    }
    if ($num < 2097152) {
        return chr(($num >> 18) + 240) . chr(($num >> 12 & 63) + 128) . chr(($num >> 6 & 63) + 128) . chr(($num & 63) + 128);
    }
    return '';
}
//-----------------------//
/*
 * Main
 */
if ($msgNumber != 'null' && $indexPart !== null && $msgFolder) {
    require_once dirname(__FILE__) . '/class.attachment.inc.php';
    $attachment = new attachment();
    $attachment->setStructureFromMail($msgFolder, $msgNumber);
    $fileContent = $attachment->getAttachment($indexPart);
    $info = $attachment->getAttachmentInfo($indexPart);
    $filename = $newFilename ? $newFilename : $info['name'];
    $filename = unhtmlentities($filename);
    $messageId = $attachment->messageId;
} else {
    if ($image && $_SESSION['phpgw_info']['expressomail']['contact_photo']) {
        $image = "thumbnail";
        $photo = array('width' => 60, 'height' => 80, 'quality' => 100);
        $fileContent = $_SESSION['phpgw_info']['expressomail']['contact_photo'][0];
        unset($_SESSION['phpgw_info']['expressomail']['contact_photo']);
    }
    $filename = $indexFile;
}