コード例 #1
0
ファイル: uploader.php プロジェクト: 01J/topm
 public static function uploader()
 {
     $params = modPwebcontactHelper::getParams();
     // check if upload is enabled
     if (!$params->get('show_upload', 0)) {
         if (PWEBCONTACT_DEBUG) {
             modPwebcontactHelper::setLog('Uploader disabled');
         }
         return array('status' => 402, 'files' => array());
     }
     jimport('joomla.filesystem.file');
     jimport('joomla.filesystem.folder');
     $path = $params->get('upload_path');
     if (!JFolder::exists($path)) {
         JFolder::create($path, 0777);
     }
     if (!is_writable($path) and JPath::canChmod($path)) {
         JPath::setPermissions($path, null, '0777');
     }
     if (!is_writable($path)) {
         if (PWEBCONTACT_DEBUG) {
             modPwebcontactHelper::setLog('Upload dir is not writable');
         }
         return array('status' => 403, 'files' => array());
     }
     // load uploader
     $uploader = new modPWebContactUploader(array('upload_dir' => $params->get('upload_path'), 'upload_url' => $params->get('upload_url'), 'accept_file_types' => '/(\\.|\\/)(' . $params->get('upload_allowed_ext', '.+') . ')$/i', 'max_file_size' => (double) $params->get('upload_size_limit', 1) * 1024 * 1024, 'image_versions' => array(), 'delete_type' => 'POST'), false, array(1 => JText::_('MOD_PWEBCONTACT_UPLOAD_ERR_1'), 3 => JText::_('MOD_PWEBCONTACT_UPLOAD_ERR_3'), 4 => JText::_('MOD_PWEBCONTACT_UPLOAD_ERR_4'), 6 => JText::_('MOD_PWEBCONTACT_UPLOAD_ERR_6'), 7 => JText::_('MOD_PWEBCONTACT_UPLOAD_ERR_7'), 8 => JText::_('MOD_PWEBCONTACT_UPLOAD_ERR_8'), 'post_max_size' => JText::_('MOD_PWEBCONTACT_UPLOAD_ERR_1'), 'max_file_size' => JText::_('MOD_PWEBCONTACT_UPLOAD_SIZE_ERR'), 'accept_file_types' => JText::_('MOD_PWEBCONTACT_UPLOAD_TYPE_ERR')));
     $response = $uploader->handleRequest();
     if (PWEBCONTACT_DEBUG) {
         modPwebcontactHelper::setLog('Uploader exit');
     }
     return $response;
 }
コード例 #2
0
ファイル: helper.php プロジェクト: 01J/topm
 public static function sendEmailAjax()
 {
     self::initAjaxResponse();
     if (($response = self::checkToken()) !== true) {
         return $response;
     }
     if (PWEBCONTACT_DEBUG) {
         self::$logs[] = 'Sending emails';
     }
     $params = self::getParams();
     try {
         $response = self::sendEmail();
     } catch (Exception $e) {
         self::$logs[] = $e->getMessage() . ' in ' . $e->getFile() . ' on line ' . $e->getLine();
         $response = array('status' => 300, 'msg' => JText::_('MOD_PWEBCONTACT_JOOMLA_ERR'));
     }
     // delete atachments
     if ($params->get('show_upload', 0) and $params->get('attachment_delete') and $params->get('attachment_type', 1) == 1 and ($response['status'] < 200 or $response['status'] >= 300)) {
         if (PWEBCONTACT_DEBUG) {
             self::$logs[] = 'Deleting attachments';
         }
         try {
             modPWebContactUploader::deleteAttachments();
             $response['deleted'] = true;
         } catch (Exception $e) {
             self::$logs[] = $e->getMessage() . ' in ' . $e->getFile() . ' on line ' . $e->getLine();
             $response = array('status' => 401, 'msg' => JText::_('MOD_PWEBCONTACT_JOOMLA_ERR'));
         }
     }
     $response['debug'] = self::closeAjaxResponse();
     return $response;
 }