当前位置: 首页>>代码示例>>PHP>>正文


PHP decideFilePath函数代码示例

本文整理汇总了PHP中decideFilePath函数的典型用法代码示例。如果您正苦于以下问题:PHP decideFilePath函数的具体用法?PHP decideFilePath怎么用?PHP decideFilePath使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了decideFilePath函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: generateAttachments

 /**
  * @param $key
  * @param $value
  * @param $context \Workflow\VTEntity
  * @return array|void
  */
 public function generateAttachments($key, $value, $context)
 {
     global $current_user;
     $adb = \PearDatabase::getInstance();
     $url = $value[2]['val'];
     $url = \Workflow\VTTemplate::parse($url, $context);
     $filename = \Workflow\VTTemplate::parse($value[2]['name'], $context);
     if (empty($filename)) {
         $filename = basename($url);
     }
     $filecontent = \Workflow\VtUtils::getContentFromUrl($url);
     if (empty($filecontent)) {
         return array();
     }
     $filename = preg_replace('/[^A-Za-z0-9-_.]/', '_', $filename);
     if ($this->_mode === self::MODE_NOT_ADD_NEW_ATTACHMENTS) {
         $tmpfile = tempnam(sys_get_temp_dir(), 'Url');
         @unlink($tmpfile);
         file_put_contents($tmpfile, $filecontent);
         $this->addAttachmentRecord('PATH', $tmpfile, $filename);
         return;
     }
     $upload_file_path = decideFilePath();
     $next_id = $adb->getUniqueID("vtiger_crmentity");
     file_put_contents($upload_file_path . $next_id . "_" . $filename, $filecontent);
     $filesize = filesize($upload_file_path . $next_id . "_" . $filename);
     $filetype = "application/octet-stream";
     $sql1 = "insert into vtiger_crmentity (crmid,smcreatorid,smownerid,setype,description,createdtime,modifiedtime) values(?, ?, ?, ?, ?, ?, ?)";
     $params1 = array($next_id, $current_user->id, $current_user->id, "Documents Attachment", 'Documents Attachment', date("Y-m-d H:i:s"), date("Y-m-d H:i:s"));
     $adb->pquery($sql1, $params1);
     $sql2 = "insert into vtiger_attachments(attachmentsid, name, description, type, path) values(?, ?, ?, ?, ?)";
     $params2 = array($next_id, $filename, '', $filetype, $upload_file_path);
     $adb->pquery($sql2, $params2);
     $this->addAttachmentRecord('ID', $next_id);
 }
开发者ID:cin-system,项目名称:cinrepo,代码行数:41,代码来源:URL.inc.php

示例2: doAction

 /**
  * @param $key
  * @param $value
  * @param $context \Workflow\VTEntity
  * @return array|void
  */
 public function doAction($configuration, $filepath, $filename, $context, $targetRecordIds = array())
 {
     $adb = \PearDatabase::getInstance();
     require_once 'modules/Documents/Documents.php';
     $focus = new \Documents();
     $focus->parentid = $context->getId();
     $docTitle = $configuration["title"];
     $docDescr = nl2br($configuration["description"]);
     $docTitle = \Workflow\VTTemplate::parse($docTitle, $context);
     $docDescr = \Workflow\VTTemplate::parse($docDescr, $context);
     $focus->column_fields['notes_title'] = $docTitle;
     $focus->column_fields['assigned_user_id'] = $context->get('assigned_user_id');
     $focus->column_fields['filename'] = $filename;
     $focus->column_fields['notecontent'] = $docDescr;
     $focus->column_fields['filetype'] = 'application/pdf';
     $focus->column_fields['filesize'] = filesize($filepath);
     $focus->column_fields['filelocationtype'] = 'I';
     $focus->column_fields['fileversion'] = '';
     $focus->column_fields['filestatus'] = 'on';
     $focus->column_fields['folderid'] = $configuration["folderid"];
     $focus->save('Documents');
     $upload_file_path = decideFilePath();
     $date_var = date("Y-m-d H:i:s");
     $next_id = $adb->getUniqueID("vtiger_crmentity");
     copy($filepath, $upload_file_path . $next_id . "_" . $filename);
     $sql1 = "insert into vtiger_crmentity (crmid,smcreatorid,smownerid,setype,description,createdtime,modifiedtime) values(?, ?, ?, ?, ?, ?, ?)";
     $params1 = array($next_id, $context->get('assigned_user_id'), $context->get('assigned_user_id'), "Documents Attachment", 'Documents Attachment', date("Y-m-d H:i:s"), date("Y-m-d H:i:s"));
     $adb->pquery($sql1, $params1);
     $filetype = "application/octet-stream";
     $sql2 = "insert into vtiger_attachments(attachmentsid, name, description, type, path) values(?, ?, ?, ?, ?)";
     $params2 = array($next_id, $filename, $docDescr, $filetype, $upload_file_path);
     $adb->pquery($sql2, $params2, true);
     $sql3 = 'insert into vtiger_seattachmentsrel values(?,?)';
     $adb->pquery($sql3, array($focus->id, $next_id));
     if ($configuration["relation"] === "1") {
         foreach ($targetRecordIds as $id) {
             $sql = "INSERT INTO vtiger_senotesrel SET crmid = " . $id . ", notesid = " . $focus->id;
             $adb->query($sql);
         }
     } else {
         $sql = "DELETE FROM vtiger_senotesrel WHERE crmid = " . $context->getId() . " AND notesid = " . $focus->id;
         $adb->query($sql);
     }
     $newContext = \Workflow\VTEntity::getForId($focus->id, "Documents");
     if ($configuration['workflowid'] !== "") {
         $objWorkflow = new \Workflow\Main($configuration['workflowid'], false, $context->getUser());
         $objWorkflow->setContext($newContext);
         $objWorkflow->isSubWorkflow(true);
         $objWorkflow->start();
     }
 }
开发者ID:cin-system,项目名称:cinrepo,代码行数:57,代码来源:Documents.inc.php

示例3: SaveAttachmentFile

/**
 * Save the attachment to the file
 */
function SaveAttachmentFile($attachid, $filename, $filecontent)
{
    global $adb;
    $dirname = decideFilePath();
    if (!is_dir($dirname)) {
        mkdir($dirname);
    }
    $description = $filename;
    $filename = str_replace(' ', '_', $filename);
    $saveasfile = "{$dirname}{$attachid}" . "_{$filename}";
    if (!file_exists($saveasfile)) {
        $fh = fopen($saveasfile, 'wb');
        fwrite($fh, base64_decode($filecontent));
        fclose($fh);
    }
    $mimetype = MailAttachmentMIME::detect($saveasfile);
    $adb->pquery("INSERT INTO vtiger_attachments SET attachmentsid=?, name=?, description=?, type=?, path=?", array($attachid, $filename, $description, $mimetype, $dirname));
}
开发者ID:casati-dolibarr,项目名称:corebos,代码行数:21,代码来源:AttachmentHelper.php

示例4: generateAttachments

 /**
  * @param $key
  * @param $value
  * @param $context \Workflow\VTEntity
  * @return array|void
  */
 public function generateAttachments($key, $value, $context)
 {
     global $current_user;
     $adb = \PearDatabase::getInstance();
     $file = \Workflow\InterfaceFiles::getFile($value[2]['val'], $context->getModuleName(), $context->getId());
     if ($this->_mode === self::MODE_NOT_ADD_NEW_ATTACHMENTS) {
         $this->addAttachmentRecord('PATH', $file['path'], $file['name']);
         return;
     }
     $upload_file_path = decideFilePath();
     $next_id = $adb->getUniqueID("vtiger_crmentity");
     copy($file['path'], $upload_file_path . $next_id . "_" . $file['name']);
     $filetype = "application/octet-stream";
     $sql1 = "insert into vtiger_crmentity (crmid,smcreatorid,smownerid,setype,description,createdtime,modifiedtime) values(?, ?, ?, ?, ?, ?, ?)";
     $params1 = array($next_id, $current_user->id, $current_user->id, "Workflow Attachment", 'Workflow Attachment', date("Y-m-d H:i:s"), date("Y-m-d H:i:s"));
     $adb->pquery($sql1, $params1);
     $sql2 = "insert into vtiger_attachments(attachmentsid, name, description, type, path) values(?, ?, ?, ?, ?)";
     $params2 = array($next_id, $file['name'], '', $filetype, $upload_file_path);
     $adb->pquery($sql2, $params2);
     $this->addAttachmentRecord('ID', $next_id);
 }
开发者ID:swarnat,项目名称:Workflow-Designer-Developer,代码行数:27,代码来源:External.inc.php

示例5: saveAttachment

 /**
  * Creates an Attachments
  * @global PearDataBase $adb
  * @global Array $upload_badext
  * @global Users $current_user
  */
 function saveAttachment()
 {
     global $adb, $upload_badext, $current_user;
     $uploadPath = decideFilePath();
     $fileName = $this->getName();
     if (!empty($fileName)) {
         $attachid = $adb->getUniqueId('vtiger_crmentity');
         //sanitize the filename
         $binFile = sanitizeUploadFileName($fileName, $upload_badext);
         $fileName = ltrim(basename(" " . $binFile));
         $saveAttachment = $this->save($uploadPath . $attachid . "_" . $fileName);
         if ($saveAttachment) {
             $description = $fileName;
             $date_var = $adb->formatDate(date('YmdHis'), true);
             $usetime = $adb->formatDate($date_var, true);
             $adb->pquery("INSERT INTO vtiger_crmentity(crmid, smcreatorid, smownerid,\n\t\t\t\tmodifiedby, setype, description, createdtime, modifiedtime, presence, deleted)\n\t\t\t\tVALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?)", array($attachid, $current_user->id, $current_user->id, $current_user->id, "Documents Attachment", $description, $usetime, $usetime, 1, 0));
             $mimetype = MailAttachmentMIME::detect($uploadPath . $attachid . "_" . $fileName);
             $adb->pquery("INSERT INTO vtiger_attachments SET attachmentsid=?, name=?, description=?, type=?, path=?", array($attachid, $fileName, $description, $mimetype, $uploadPath));
             return $attachid;
         }
     }
     return false;
 }
开发者ID:nouphet,项目名称:vtigercrm-6.0.0-ja,代码行数:29,代码来源:UploadController.php

示例6: uploadAndSaveFile

 /**
  *      This function is used to upload the attachment in the server and save that attachment information in db.
  *      @param int $id  - entity id to which the file to be uploaded
  *      @param string $module  - the current module name
  *      @param array $file_details  - array which contains the file information(name, type, size, tmp_name and error)
  *      return void
  */
 function uploadAndSaveFile($id, $module, $file_details)
 {
     global $log;
     $log->debug("Entering into uploadAndSaveFile({$id},{$module},{$file_details}) method.");
     global $current_user;
     global $upload_badext;
     $date_var = date('Y-m-d H:i:s');
     //to get the owner id
     $ownerid = isset($this->column_fields['assigned_user_id']) ? $this->column_fields['assigned_user_id'] : '';
     if (!isset($ownerid) || $ownerid == '') {
         $ownerid = $current_user->id;
     }
     // Arbitrary File Upload Vulnerability fix - Philip
     $binFile = $file_details['name'];
     $ext_pos = strrpos($binFile, ".");
     $ext = substr($binFile, $ext_pos + 1);
     if (in_array($ext, $upload_badext)) {
         $binFile .= ".txt";
     }
     // Vulnerability fix ends
     $current_id = $this->db->getUniqueID("ec_crmentity");
     $filename = explode_basename($binFile);
     $filetype = $file_details['type'];
     $filesize = $file_details['size'];
     $filetmp_name = $file_details['tmp_name'];
     //get the file path inwhich folder we want to upload the file
     $upload_file_path = decideFilePath();
     //upload the file in server
     if (is_uploaded_file($filetmp_name)) {
         $encode_file = base64_encode_filename($binFile);
         $upload_status = move_uploaded_file($filetmp_name, $upload_file_path . $current_id . "_" . $encode_file);
     }
     $save_file = 'true';
     //only images are allowed for these modules
     if ($module == 'Contacts' || $module == 'Products') {
         echo "222";
         $save_file = validateImageFile($file_details);
     }
     if ($save_file == 'true' && $upload_status == 'true') {
         //This is only to update the attached filename in the ec_notes ec_table for the Notes module
         if ($module == 'Notes') {
             $sql = "update ec_notes set filename='" . $filename . "' where notesid = " . $id;
             $this->db->query($sql);
         } else {
             if ($module == 'Documents') {
                 $sql = "update ec_documents set filename='" . $filename . "' where documentsid = " . $id;
                 $this->db->query($sql);
             }
         }
         $description = "";
         if (isset($this->column_fields['description'])) {
             $description = $this->column_fields['description'];
         }
         $sql1 = "insert into ec_crmentity (crmid,setype) values(" . $current_id . ",'" . $module . " Attachment')";
         $this->db->query($sql1);
         $sql = "insert into ec_attachments(attachmentsid,name,description,type,setype,path,smcreatorid,createdtime) values(";
         $sql .= $current_id . ",'" . $filename . "','" . $description . "','" . $filetype . "','" . $module . "','" . $upload_file_path . "','" . $ownerid . "','" . $date_var . "')";
         $result = $this->db->query($sql);
         if (isset($_REQUEST['mode']) && $_REQUEST['mode'] == 'edit') {
             if ($id != '' && isset($_REQUEST['fileid']) && $_REQUEST['fileid'] != '') {
                 $delquery = 'delete from ec_seattachmentsrel where crmid = ' . $id . ' and attachmentsid = ' . $_REQUEST['fileid'];
                 $this->db->query($delquery);
             }
         }
         if ($module == 'Notes' || $module == 'Documents') {
             $query = "delete from ec_seattachmentsrel where crmid = " . $id;
             $this->db->query($query);
         }
         $sql3 = 'insert into ec_seattachmentsrel values(' . $id . ',' . $current_id . ')';
         $this->db->query($sql3);
         return true;
     } else {
         $log->debug("Skip the save attachment process.");
         return false;
     }
 }
开发者ID:honj51,项目名称:taobaocrm,代码行数:83,代码来源:CRMEntity.php

示例7: __SaveAttachmentFile

 /**
  * Save the Mail Attachments to DB
  * @global PearDataBase Instance $db
  * @global Users Instance $currentUserModel
  * @global Array $upload_badext
  * @param String $filename - name of the file
  * @param Text $filecontent
  * @return Array with attachment information
  */
 public function __SaveAttachmentFile($filename, $filecontent)
 {
     require_once 'modules/Settings/MailConverter/handlers/MailAttachmentMIME.php';
     $db = PearDatabase::getInstance();
     $currentUserModel = Users_Record_Model::getCurrentUserModel();
     $filename = imap_utf8($filename);
     $dirname = decideFilePath();
     $usetime = $db->formatDate(date('ymdHis'), true);
     $binFile = sanitizeUploadFileName($filename, vglobal('upload_badext'));
     $attachid = $db->getUniqueId('vtiger_crmentity');
     $saveasfile = "{$dirname}/{$attachid}" . "_" . $binFile;
     $fh = fopen($saveasfile, 'wb');
     fwrite($fh, $filecontent);
     fclose($fh);
     $mimetype = MailAttachmentMIME::detect($saveasfile);
     $db->pquery("INSERT INTO vtiger_crmentity(crmid, smcreatorid, smownerid,\n\t\t\t\tmodifiedby, setype, description, createdtime, modifiedtime, presence, deleted)\n\t\t\t\tVALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?)", array($attachid, $currentUserModel->getId(), $currentUserModel->getId(), $currentUserModel->getId(), "MailManager Attachment", $binFile, $usetime, $usetime, 1, 0));
     $db->pquery("INSERT INTO vtiger_attachments SET attachmentsid=?, name=?, description=?, type=?, path=?", array($attachid, $binFile, $binFile, $mimetype, $dirname));
     $attachInfo = array('attachid' => $attachid, 'path' => $dirname, 'name' => $binFile, 'type' => $mimetype, 'size' => filesize($saveasfile));
     return $attachInfo;
 }
开发者ID:cannking,项目名称:vtigercrm-debug,代码行数:29,代码来源:Message.php

示例8: saveForwardAttachments

 function saveForwardAttachments($id, $module, $file_details)
 {
     global $log;
     $log->debug("Entering into saveForwardAttachments({$id},{$module},{$file_details}) method.");
     global $adb, $current_user;
     global $upload_badext;
     require_once 'modules/Webmails/MailBox.php';
     $mailbox = $_REQUEST["mailbox"];
     $MailBox = new MailBox($mailbox);
     $mail = $MailBox->mbox;
     $binFile = sanitizeUploadFileName($file_details['name'], $upload_badext);
     $filename = ltrim(basename(" " . $binFile));
     //allowed filename like UTF-8 characters
     $filetype = $file_details['type'];
     $filesize = $file_details['size'];
     $filepart = $file_details['part'];
     $transfer = $file_details['transfer'];
     $file = imap_fetchbody($mail, $_REQUEST['mailid'], $filepart);
     if ($transfer == 'BASE64') {
         $file = imap_base64($file);
     } elseif ($transfer == 'QUOTED-PRINTABLE') {
         $file = imap_qprint($file);
     }
     $current_id = $adb->getUniqueID("vtiger_crmentity");
     $date_var = date('Y-m-d H:i:s');
     //to get the owner id
     $ownerid = $this->column_fields['assigned_user_id'];
     if (!isset($ownerid) || $ownerid == '') {
         $ownerid = $current_user->id;
     }
     $upload_file_path = decideFilePath();
     file_put_contents($upload_file_path . $current_id . "_" . $filename, $file);
     $sql1 = "insert into vtiger_crmentity (crmid,smcreatorid,smownerid,setype,description,createdtime,modifiedtime) values(?,?,?,?,?,?,?)";
     $params1 = array($current_id, $current_user->id, $ownerid, $module . " Attachment", $this->column_fields['description'], $adb->formatDate($date_var, true), $adb->formatDate($date_var, true));
     $adb->pquery($sql1, $params1);
     $sql2 = "insert into vtiger_attachments(attachmentsid, name, description, type, path) values(?,?,?,?,?)";
     $params2 = array($current_id, $filename, $this->column_fields['description'], $filetype, $upload_file_path);
     $result = $adb->pquery($sql2, $params2);
     if ($_REQUEST['mode'] == 'edit') {
         if ($id != '' && $_REQUEST['fileid'] != '') {
             $delquery = 'delete from vtiger_seattachmentsrel where crmid = ? and attachmentsid = ?';
             $adb->pquery($delquery, array($id, $_REQUEST['fileid']));
         }
     }
     $sql3 = 'insert into vtiger_seattachmentsrel values(?,?)';
     $adb->pquery($sql3, array($id, $current_id));
     return true;
     $log->debug("exiting from  saveforwardattachment function.");
 }
开发者ID:hardikk,项目名称:HNH,代码行数:49,代码来源:Emails.php

示例9: uploadAndSaveFile

 /** Function to upload the file to the server and add the file details in the attachments table
  * @param $id -- user id:: Type varchar
  * @param $module -- module name:: Type varchar
  * @param $file_details -- file details array:: Type array
  */
 function uploadAndSaveFile($id, $module, $file_details)
 {
     $log = vglobal('log');
     $log->debug("Entering into uploadAndSaveFile({$id},{$module},{$file_details}) method.");
     $current_user = vglobal('current_user');
     global $upload_badext;
     $date_var = date('Y-m-d H:i:s');
     //to get the owner id
     $ownerid = $this->column_fields['assigned_user_id'];
     if (!isset($ownerid) || $ownerid == '') {
         $ownerid = $current_user->id;
     }
     $saveFile = 'true';
     //only images are allowed for these modules
     if ($module == 'Users') {
         $saveFile = validateImageFile($file_details);
     }
     if ($saveFile == 'false') {
         return;
     }
     $file = $file_details['name'];
     $binFile = sanitizeUploadFileName($file, $upload_badext);
     $filename = ltrim(basename(" " . $binFile));
     //allowed filename like UTF-8 characters
     $filetype = $file_details['type'];
     $filesize = $file_details['size'];
     $filetmp_name = $file_details['tmp_name'];
     $current_id = $this->db->getUniqueID("vtiger_crmentity");
     //get the file path inwhich folder we want to upload the file
     $upload_file_path = decideFilePath($module);
     //upload the file in server
     $upload_status = move_uploaded_file($filetmp_name, $upload_file_path . $current_id . "_" . $binFile);
     if ($saveFile == 'true') {
         $sql1 = "insert into vtiger_crmentity (crmid,smcreatorid,smownerid,setype,description,createdtime,modifiedtime) values(?,?,?,?,?,?,?)";
         $params1 = array($current_id, $current_user->id, $ownerid, $module . " Attachment", $this->column_fields['description'], $this->db->formatDate($date_var, true), $this->db->formatDate($date_var, true));
         $this->db->pquery($sql1, $params1);
         $sql2 = "insert into vtiger_attachments(attachmentsid, name, description, type, path) values(?,?,?,?,?)";
         $params2 = array($current_id, $filename, $this->column_fields['description'], $filetype, $upload_file_path);
         $result = $this->db->pquery($sql2, $params2);
         if ($id != '') {
             $delquery = 'delete from vtiger_salesmanattachmentsrel where smid = ?';
             $this->db->pquery($delquery, array($id));
         }
         $sql3 = 'insert into vtiger_salesmanattachmentsrel values(?,?)';
         $this->db->pquery($sql3, array($id, $current_id));
         //we should update the imagename in the users table
         $this->db->pquery("update vtiger_users set imagename=? where id=?", array($filename, $id));
     } else {
         $log->debug("Skip the save attachment process.");
     }
     $log->debug("Exiting from uploadAndSaveFile({$id},{$module},{$file_details}) method.");
     return;
 }
开发者ID:Bergdahls,项目名称:YetiForceCRM,代码行数:58,代码来源:Users.php

示例10: strrpos

 $ownerid = $current_user->id;
 // Arbitrary File Upload Vulnerability fix - Philip
 $binFile = $file_details['name'];
 $ext_pos = strrpos($binFile, ".");
 $ext = substr($binFile, $ext_pos + 1);
 if (in_array($ext, $upload_badext)) {
     $binFile .= ".txt";
 }
 // Vulnerability fix ends
 $current_id = $adb->getUniqueID("ec_crmentity");
 $filename = explode_basename($binFile);
 $filetype = $file_details['type'];
 $filesize = $file_details['size'];
 $filetmp_name = $file_details['tmp_name'];
 //get the file path inwhich folder we want to upload the file
 $upload_file_path = decideFilePath();
 //upload the file in server
 $upload_status = false;
 if (is_uploaded_file($filetmp_name)) {
     $encode_file = base64_encode_filename($binFile);
     $upload_status = move_uploaded_file($filetmp_name, $upload_file_path . $current_id . "_" . $encode_file);
 }
 if ($upload_status) {
     $description = "";
     $adb->query("insert into ec_crmentity (crmid,setype) values('" . $current_id . "','Maillists Attachment')");
     $sql = "insert into ec_attachments(attachmentsid,name,description,type,setype,path,smcreatorid,createdtime) values(";
     $sql .= $current_id . ",'" . $filename . "','" . $description . "','" . $filetype . "','Maillists','" . $upload_file_path . "','" . $current_user->id . "'," . $date_var . ")";
     $adb->query($sql);
     $query_attachment = "delete from ec_seattachmentsrel where crmid = " . $sjid;
     $adb->query($query_attachment);
     $query_attachment = 'insert into ec_seattachmentsrel values(' . $sjid . ',' . $current_id . ')';
开发者ID:honj51,项目名称:taobaocrm,代码行数:31,代码来源:uploadfileInfo.php

示例11: handleUpload

 function handleUpload()
 {
     global $upload_maxsize;
     $allowedFileExtension = array();
     $uploadLimit = ConfigPrefs::get('MAXUPLOADLIMIT', $upload_maxsize);
     $filePath = decideFilePath();
     $upload = new MailManager_Uploader($allowedFileExtension, $uploadLimit);
     return $upload->handleUpload($filePath, false);
 }
开发者ID:casati-dolibarr,项目名称:corebos,代码行数:9,代码来源:Draft.php

示例12: handleUpload

 public function handleUpload()
 {
     $allowedFileExtension = array();
     $uploadLimit = MailManager_Config_Model::get('MAXUPLOADLIMIT', vglobal('upload_maxsize'));
     $filePath = decideFilePath();
     $upload = new MailManager_Upload_Action($allowedFileExtension, $uploadLimit);
     return $upload->handleUpload($filePath, false);
 }
开发者ID:cannking,项目名称:vtigercrm-debug,代码行数:8,代码来源:Draft.php

示例13: createPDFAndSaveFile

function createPDFAndSaveFile($templates, $focus, $modFocus, $file_name, $moduleName, $language)
{
    global $x0b, $x0c, $x0d, $x0e, $x0f, $x10, $x11, $x12, $x13, $x14, $x15, $x16, $x17, $x18, $x19, $x1a, $x1b, $x1c, $x1d, $x1e, $x1f, $x20, $x21, $x22, $x23, $x24, $x25, $x26;
    $db = "adb";
    $cu = "current_user";
    $dl = "default_language";
    global ${$db}, ${$cu}, ${$dl};
    $date_var = $x10("Y-m-d H:i:s");
    $ownerid = $focus->column_fields["assigned_user_id"];
    if (!isset($ownerid) || $ownerid == "") {
        $ownerid = ${$cu}->id;
    }
    $current_id = ${$db}->getUniqueID("vtiger_crmentity");
    $templates = $x1d($templates, ";");
    $Templateids = $x11(";", $templates);
    $x17("memory_limit", "128M");
    $name = "";
    if (!$language || $language == "") {
        $language = ${$dl};
    }
    foreach ($Templateids as $templateid) {
        $PDFContent = new PDFContent($templateid, $moduleName, $modFocus, $language);
        $pdf_content = $PDFContent->getContent();
        $Settings = $PDFContent->getSettings();
        if ($name == "") {
            $name = $PDFContent->getFilename();
        }
        $header_html = $x14($pdf_content["header"], ENT_COMPAT, "utf-8");
        $body_html = $x14($pdf_content["body"], ENT_COMPAT, "utf-8");
        $footer_html = $x14($pdf_content["footer"], ENT_COMPAT, "utf-8");
        $encoding = $Settings["encoding"];
        if ($Settings["orientation"] == "landscape") {
            $format = $Settings["format"] . "-L";
        } else {
            $format = $Settings["format"];
        }
        if (!isset($mpdf)) {
            $mpdf = new mPDF('', $format, '', 'Arial', $Settings["margin_left"], $Settings["margin_right"], 0, 0, $Settings["margin_top"], $Settings["margin_bottom"]);
            $mpdf->SetAutoFont();
            @$mpdf->SetHTMLHeader($header_html);
        } else {
            @$mpdf->SetHTMLHeader($header_html);
            @$mpdf->WriteHTML('<pagebreak sheet-size="' . $format . '" margin-left="' . $Settings["margin_left"] . 'mm" margin-right="' . $Settings["margin_right"] . 'mm" margin-top="0mm" margin-bottom="0mm" margin-header="' . $Settings["margin_top"] . 'mm" margin-footer="' . $Settings["margin_bottom"] . 'mm" />');
        }
        @$mpdf->SetHTMLFooter($footer_html);
        @$mpdf->WriteHTML($body_html);
    }
    $upload_file_path = decideFilePath();
    if ($name != "") {
        $file_name = $name . ".pdf";
    }
    $mpdf->Output($upload_file_path . $current_id . "_" . $file_name);
    $filesize = $x13($upload_file_path . $current_id . "_" . $file_name);
    $filetype = "application/pdf";
    $sql1 = "insert into vtiger_crmentity (crmid,smcreatorid,smownerid,setype,description,createdtime,modifiedtime) values(?, ?, ?, ?, ?, ?, ?)";
    $params1 = array($current_id, ${$cu}->id, $ownerid, "Documents Attachment", $focus->column_fields["description"], ${$db}->formatDate($date_var, true), ${$db}->formatDate($date_var, true));
    ${$db}->pquery($sql1, $params1);
    $sql2 = "insert into vtiger_attachments(attachmentsid, name, description, type, path) values(?, ?, ?, ?, ?)";
    $params2 = array($current_id, $file_name, $focus->column_fields["description"], $filetype, $upload_file_path);
    $result = ${$db}->pquery($sql2, $params2);
    $sql3 = 'insert into vtiger_seattachmentsrel values(?,?)';
    ${$db}->pquery($sql3, array($focus->id, $current_id));
    $sql4 = "UPDATE vtiger_notes SET filesize=?, filename=? WHERE notesid=?";
    ${$db}->pquery($sql4, array($filesize, $file_name, $focus->id));
    return true;
}
开发者ID:jmangarret,项目名称:vtigercrm,代码行数:66,代码来源:InventoryPDF.php

示例14: uploadAndSaveFile

 /**
  *      This function is used to upload the attachment in the server and save that attachment information in db.
  *      @param int $id  - entity id to which the file to be uploaded
  *      @param string $module  - the current module name
  *      @param array $file_details  - array which contains the file information(name, type, size, tmp_name and error)
  *      return void
  */
 function uploadAndSaveFile($id, $module, $file_details, $attachmentType = 'Attachment')
 {
     $log = LoggerManager::getInstance();
     $log->debug("Entering into uploadAndSaveFile({$id},{$module},{$file_details}) method.");
     $adb = PearDatabase::getInstance();
     $current_user = vglobal('current_user');
     $date_var = date("Y-m-d H:i:s");
     //to get the owner id
     $ownerid = $this->column_fields['assigned_user_id'];
     if (!isset($ownerid) || $ownerid == '') {
         $ownerid = $current_user->id;
     }
     if (isset($file_details['original_name']) && $file_details['original_name'] != null) {
         $file_name = $file_details['original_name'];
     } else {
         $file_name = $file_details['name'];
     }
     $saveFile = 'true';
     //only images are allowed for Image Attachmenttype
     $mimeType = Vtiger_Functions::getMimeContentType($file_details['tmp_name']);
     $mimeTypeContents = explode('/', $mimeType);
     // For contacts and products we are sending attachmentType as value
     if ($attachmentType == 'Image' || $file_details['size'] && $mimeTypeContents[0] == 'image') {
         $saveFile = validateImageFile($file_details);
     }
     if ($saveFile == 'false') {
         return false;
     }
     $binFile = sanitizeUploadFileName($file_name, AppConfig::main('upload_badext'));
     $current_id = $adb->getUniqueID('vtiger_crmentity');
     $filename = ltrim(basename(' ' . $binFile));
     //allowed filename like UTF-8 characters
     $filetype = $file_details['type'];
     $filesize = $file_details['size'];
     $filetmp_name = $file_details['tmp_name'];
     //get the file path inwhich folder we want to upload the file
     $upload_file_path = decideFilePath($module);
     //upload the file in server
     $upload_status = move_uploaded_file($filetmp_name, $upload_file_path . $current_id . '_' . $binFile);
     $save_file = 'true';
     //only images are allowed for these modules
     if ($module == 'Contacts' || $module == 'Products') {
         $save_file = validateImageFile($file_details);
     }
     if ($save_file == 'true' && $upload_status == 'true') {
         //This is only to update the attached filename in the vtiger_notes vtiger_table for the Notes module
         $params = ['crmid' => $current_id, 'smcreatorid' => $current_user->id, 'smownerid' => $ownerid, 'setype' => $module . " Image", 'description' => $this->column_fields['description'], 'createdtime' => $adb->formatDate($date_var, true), 'modifiedtime' => $adb->formatDate($date_var, true)];
         if ($module == 'Contacts' || $module == 'Products') {
             $params['setype'] = $module . " Image";
         } else {
             $params['setype'] = $module . " Attachment";
         }
         $adb->insert('vtiger_crmentity', $params);
         $params = ['attachmentsid' => $current_id, 'name' => $filename, 'description' => $this->column_fields['description'], 'type' => $filetype, 'path' => $upload_file_path];
         $adb->insert('vtiger_attachments', $params);
         if ($_REQUEST['mode'] == 'edit') {
             if ($id != '' && vtlib_purify($_REQUEST['fileid']) != '') {
                 $delparams = [$id, vtlib_purify($_REQUEST['fileid'])];
                 $adb->delete('vtiger_seattachmentsrel', 'crmid = ? AND attachmentsid = ?', $delparams);
             }
         }
         if ($module == 'Documents') {
             $adb->delete('vtiger_seattachmentsrel', 'crmid = ?', [$id]);
         }
         if ($module == 'Contacts') {
             $att_sql = "select vtiger_seattachmentsrel.attachmentsid  from vtiger_seattachmentsrel inner join vtiger_crmentity on vtiger_crmentity.crmid=vtiger_seattachmentsrel.attachmentsid where vtiger_crmentity.setype='Contacts Image' and vtiger_seattachmentsrel.crmid=?";
             $res = $adb->pquery($att_sql, array($id));
             $attachmentsid = $adb->query_result($res, 0, 'attachmentsid');
             if ($attachmentsid != '') {
                 $adb->delete('vtiger_seattachmentsrel', 'crmid = ? AND attachmentsid = ?', [$id, $attachmentsid]);
                 $adb->delete('vtiger_crmentity', 'crmid = ?', [$attachmentsid]);
                 $adb->insert('vtiger_seattachmentsrel', ['crmid' => $id, 'attachmentsid' => $current_id]);
             } else {
                 $adb->insert('vtiger_seattachmentsrel', ['crmid' => $id, 'attachmentsid' => $current_id]);
             }
         } else {
             $adb->insert('vtiger_seattachmentsrel', ['crmid' => $id, 'attachmentsid' => $current_id]);
         }
         return true;
     } else {
         $log->debug("Skip the save attachment process.");
         return false;
     }
 }
开发者ID:HoererUndFlamme,项目名称:YetiForceCRM,代码行数:91,代码来源:CRMEntity.php

示例15: while

            ${"GLOBALS"}["dwueotishfr"] = "result";
            ${${"GLOBALS"}["cnpunorkudj"]} = $adb->query(${${"GLOBALS"}["qmkfkak"]}, true);
            if ($adb->num_rows(${${"GLOBALS"}["dwueotishfr"]}) == 0) {
                ${${"GLOBALS"}["qultpew"]}["context"]->unlinkTempFiles();
            }
        }
        if (time() < ${${"GLOBALS"}["bmukduyjbf"]} + ${${"GLOBALS"}["wkyilpg"]} * 60) {
            ${${"GLOBALS"}["keuetfu"]} = \Workflow\Queue::getQueueEntry();
        } else {
            ${${"GLOBALS"}["keuetfu"]} = false;
        }
    } while (${${"GLOBALS"}["keuetfu"]} !== false);
}
echo "Workflow2 Scheduler Started\n";
\Workflow\Scheduler::execute();
echo "Workflow2 Scheduler Finished\n";
echo "Workflow2 Cronjob Start Cleaning\n";
${${"GLOBALS"}["gvudxdr"]} = decideFilePath();
@chmod(dirname(dirname(${${"GLOBALS"}["gvudxdr"]})), 0777);
@chmod(dirname(${$cfcoklxwq}), 0777);
@chmod(${${"GLOBALS"}["gvudxdr"]}, 0777);
if (mt_rand(1, 100) > 90) {
    \Workflow2::purgeLogs();
    \Workflow2::purgeQueue();
}
\Workflow2::cleanQueue();
${${"GLOBALS"}["jvrworyisrg"]} = new \Workflow2();
$obj->repoUpdateCheck();
\Workflow2::${${"GLOBALS"}["nimkcgvrvs"]} = false;
unlink(sys_get_temp_dir() . "/workflow2_lock");
echo "Workflow2 Cronjob Finished\n";
开发者ID:cin-system,项目名称:cinrepo,代码行数:31,代码来源:cronjobHandler.php


注:本文中的decideFilePath函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。