Example #1
0
    /**
     * Function loads an attachment, and switches between file as attachment and file as field.
     * The files are stored in web/upload dir containing WorkflowID/WorkflowversionID/md5(date_filename)
     * @param sfWebRequest $request
     * @return <type>
     */
    public function executeShowAttachment(sfWebRequest $request) {
        $versionid = $request->getParameter('versionid');
        $workflowid = $request->getParameter('workflowid');
        $attachmentid = $request->getParameter('attachmentid');
        $file = $request->getParameter('file');

        if ($file == 1) {
            $attachment = WorkflowSlotFieldFileTable::instance()->geFileById($attachmentid)->toArray(); // file from field
        }
        else {
            $attachment = WorkflowVersionAttachmentTable::instance()->getAttachmentsById($attachmentid)->toArray(); // file from attachment table
        }
        $filepath = sfConfig::get('sf_upload_dir') . '/' . $workflowid . '/' . $versionid . '/' . $attachment[0]['hashname'];
        $file = new File();

        $filecontent = $file->getFileContent($filepath); // open file and get content
        $contenttyoe = $file->getContenttype($attachment[0]['hashname']);

        $response = $this->getResponse();
        $response->clearHttpHeaders();

        $response->setHttpHeader('Content-Type', 'application/octet-stream'); // set content type of response
        $this->getResponse()->setHttpHeader('Content-Disposition', 'attachment; filename=' . $attachment[0]['filename']);
        $response->setHttpHeader('Content-Length', @filesize($filepath)); // add filesize
        $response->sendHttpHeaders(); // send the headers before the file
        $response->setContent($filecontent); // set file string
        return sfView::NONE;
    }
 function getConfigByUnique($dbUnique)
 {
     importClass('File');
     $tmpConfig = TMP . 'config_' . $dbUnique . '.php';
     $dbConfig = @unserialize(File::getFileContent($tmpConfig));
     if (!is_array($dbConfig)) {
         error('reading config error');
     }
     return $dbConfig;
 }
 public function recoverTable($table, $startid, $endid)
 {
     for ($t = $startid; $t <= $endid; $t++) {
         $sql = File::getFileContent($this->getFileName($t));
         if ($t == $startid && preg_match('~#--Table `' . $table . '` Begin(.*)$~is', $sql, $m)) {
             $sql = $m[1];
         }
         if ($t == $endid && preg_match('~(.*?)#Table End~is', $sql, $s)) {
             $sql = preg_replace('~(.*?)#Table End.*$~is', '\\1', $sql);
         }
         $this->sqlExecute($sql);
     }
 }
 public function getRecoverTableFilesID($tableName)
 {
     importClass('File');
     $content = File::getFileContent($this->getTraceFile());
     $mat = '~`' . $tableName . '`\\|(\\d+)\\|[^`]*[^\\|]*\\|(\\d+)~is';
     if (preg_match($mat, $content, $m)) {
         $startid = $m[1];
         $endid = $m[2];
     } else {
         if (preg_match('~`' . $tableName . '`\\|(\\d+)\\|~is', $content, $m)) {
             $startid = $m[1];
             $endid = $this->sqlFilesNum;
         } else {
             return array(NULL, NULL);
         }
     }
     return array($startid, $endid);
 }
 public function sendEmail() {
     $this->emailConfig = $this->getEmailConfiguration();
     $this->setMailer();
     $mailerObject = Swift_Mailer::newInstance($this->transport);
     #$mailerObject = sfContext::getInstance()->getMailer();
     $message = Swift_Message::newInstance()
         ->setFrom($this->sender)
         ->setTo($this->receiver)
         ->setSubject($this->subject)
         ->setContentType($this->contentType)
         ->setBody($this->body);
     if(isset($this->attachments)) {
         foreach($this->attachments as $file) {
             $fileObj = new File();
             $filecontent = $fileObj->getFileContent($file['filepath']);
             $message->attach(Swift_Attachment::newInstance($filecontent, $file['filename']));
         }
     }
     try {
         if($this->emailConfig['allowemailtransport'] == 1) {
             $mailerObject->send($message);
         }
     }
     catch (Exception $e) {
         
     }
     
 }
Example #6
0
 /**
  * Lefordítja a javascript-ben lévő nyelvi elemeket.
  * @param $pout_String                  A fordítandó javascript file
  * @return string                       A lefordított script
  * @throws \Exception
  * @version 1.0
  * @access public
  */
 public static function translateScript($pout_String) : string
 {
     self::$_templateName = md5($pout_String);
     self::$_templateSource[self::$_templateName] = File::getFileContent($pout_String);
     return self::renderTemplate()->compiled;
 }
 public function readTmpContent()
 {
     if (!file_exists($this->getTmpContenFile())) {
         return '';
     }
     $content = File::getFileContent($this->getTmpContenFile());
     if (empty($content)) {
         return '';
     }
     return $content;
 }