function check()
 {
     if (empty($this->shopper_group_name)) {
         vmError(JText::_('COM_VIRTUEMART_SHOPPERGROUP_RECORDS_MUST_HAVE_NAME'));
         return false;
     } else {
         if (function_exists('mb_strlen')) {
             if (mb_strlen($this->shopper_group_name) > 32) {
                 vmError(JText::_('COM_VIRTUEMART_SHOPPERGROUP_NAME_LESS_THAN_32_CHARACTERS'));
                 return false;
             }
         } else {
             if (strlen($this->shopper_group_name) > 32) {
                 vmError(JText::_('COM_VIRTUEMART_SHOPPERGROUP_NAME_LESS_THAN_32_CHARACTERS'));
                 return false;
             }
         }
     }
     /* commented by PATRICK This set always shoppergroup to 1 if you do a new shoppergroup
     		if(empty($this->virtuemart_shoppergroup_id)){
     			$q = 'SELECT `virtuemart_shoppergroup_id` FROM `#__virtuemart_shoppergroups` WHERE `default`="1" AND `virtuemart_vendor_id`="1" ';
     			$this->_db->setQuery($q);
     			$this->virtuemart_shoppergroup_id=$this->_db->loadResult();
     		}
     */
     return parent::check();
 }
Exemple #2
0
 function check()
 {
     if (empty($this->shopper_group_name)) {
         vmError('COM_VIRTUEMART_SHOPPERGROUP_RECORDS_MUST_HAVE_NAME');
         return false;
     } else {
         if (function_exists('mb_strlen')) {
             $length = mb_strlen($this->shopper_group_name);
         } else {
             $length = strlen($this->shopper_group_name);
         }
         if ($length > 128) {
             vmError('COM_VIRTUEMART_SHOPPERGROUP_NAME_128');
         }
     }
     if ($this->virtuemart_shoppergroup_id == 1) {
         $this->default = 2;
         $this->sgrp_additional = 0;
     }
     if ($this->virtuemart_shoppergroup_id == 2) {
         $this->default = 1;
         $this->sgrp_additional = 0;
     }
     return parent::check();
 }
 function check()
 {
     if (empty($this->notify_email) || !filter_var($this->notify_email, FILTER_VALIDATE_EMAIL)) {
         vmError(JText::_('COM_VIRTUEMART_ENTER_A_VALID_EMAIL_ADDRESS'), JText::_('COM_VIRTUEMART_ENTER_A_VALID_EMAIL_ADDRESS'));
         return false;
     }
     return parent::check();
 }
Exemple #4
0
 /**
  * Validates the userfields record fields.
  *
  * @return boolean True if the table buffer is contains valid data, false otherwise.
  */
 function check($nrOfValues)
 {
     if (preg_match('/[^a-z0-9\\._\\-]/i', $this->group_name) > 0) {
         vmError(JText::_('COM_VIRTUEMART_PERMISSION_GROUP_NAME_INVALID_CHARACTERS'));
         return false;
     }
     return parent::check();
 }
 function check()
 {
     if (!empty($this->customfield_price)) {
         $this->customfield_price = str_replace(array(',', ' '), array('.', ''), $this->customfield_price);
     } else {
         $this->customfield_price = null;
     }
     return parent::check();
 }
Exemple #6
0
 /**
  * Validates the userfields record fields.
  *
  * @return boolean True if the table buffer is contains valid data, false otherwise.
  */
 function check()
 {
     if (preg_match('/[^a-z0-9\\._\\-]/i', $this->name) > 0) {
         vmError(vmText::_('COM_VIRTUEMART_NAME_OF_USERFIELD_CONTAINS_INVALID_CHARACTERS'));
         return false;
     }
     if ($this->name != 'virtuemart_country_id' and $this->name != 'virtuemart_state_id') {
         $reqValues = array('select', 'multiselect', 'radio', 'multicheckbox');
         if (in_array($this->type, $reqValues) and $this->_nrOfValues == 0) {
             vmError(vmText::_('COM_VIRTUEMART_VALUES_ARE_REQUIRED_FOR_THIS_TYPE'));
             return false;
         }
     }
     return parent::check();
 }
 /**
  * Validates the order status record fields.
  *
  * @return boolean True if the table buffer is contains valid data, false otherwise.
  */
 function check()
 {
     $db = JFactory::getDBO();
     $q = 'SELECT count(*),virtuemart_orderstate_id FROM `#__virtuemart_orderstates` ';
     $q .= 'WHERE `order_status_code`="' . $this->order_status_code . '"';
     $db->setQuery($q);
     $row = $db->loadRow();
     if (is_array($row)) {
         if ($row[0] > 0) {
             if ($row[1] != $this->virtuemart_orderstate_id) {
                 vmError(vmText::_('COM_VIRTUEMART_ORDER_STATUS_CODE_EXISTS'));
                 return false;
             }
         }
     }
     return parent::check();
 }
 function check()
 {
     if (empty($this->shopper_group_name)) {
         vmError(JText::_('COM_VIRTUEMART_SHOPPERGROUP_RECORDS_MUST_HAVE_NAME'));
         return false;
     } else {
         if (function_exists('mb_strlen')) {
             if (mb_strlen($this->shopper_group_name) > 32) {
                 vmError(JText::_('COM_VIRTUEMART_SHOPPERGROUP_NAME_LESS_THAN_32_CHARACTERS'));
                 return false;
             }
         } else {
             if (strlen($this->shopper_group_name) > 32) {
                 vmError(JText::_('COM_VIRTUEMART_SHOPPERGROUP_NAME_LESS_THAN_32_CHARACTERS'));
                 return false;
             }
         }
     }
     return parent::check();
 }
 function check()
 {
     $ok = TRUE;
     $notice = TRUE;
     if (empty($this->file_type) and empty($this->file_is_forSale)) {
         $ok = FALSE;
         vmError(vmText::sprintf('COM_VIRTUEMART_MEDIA_NO_TYPE'), $this->file_name);
     }
     if (!empty($this->file_url)) {
         if (function_exists('mb_strlen')) {
             $length = mb_strlen($this->file_url);
         } else {
             $length = strlen($this->file_url);
         }
         if ($length > 254) {
             vmError(JText::sprintf('COM_VIRTUEMART_URL_TOO_LONG', $length));
         }
         if (strpos($this->file_url, '..') !== FALSE) {
             $ok = FALSE;
             vmError(vmText::sprintf('COM_VIRTUEMART_URL_NOT_VALID', $this->file_url));
         }
         if (empty($this->virtuemart_media_id)) {
             $q = 'SELECT `virtuemart_media_id`,`file_url` FROM `' . $this->_tbl . '` WHERE `file_url` = "' . $this->_db->escape($this->file_url) . '" ';
             $this->_db->setQuery($q);
             $unique_id = $this->_db->loadAssocList();
             $count = count($unique_id);
             if ($count !== 0) {
                 if ($count == 1) {
                     if (empty($this->virtuemart_media_id)) {
                         $this->virtuemart_media_id = $unique_id[0]['virtuemart_media_id'];
                     } else {
                         vmError(vmText::_('COM_VIRTUEMART_MEDIA_IS_ALREADY_IN_DB'));
                         $ok = FALSE;
                     }
                 } else {
                     //      			vmError(vmText::_('COM_VIRTUEMART_MEDIA_IS_DOUBLED_IN_DB'));
                     vmError(vmText::_('COM_VIRTUEMART_MEDIA_IS_DOUBLED_IN_DB'));
                     $ok = FALSE;
                 }
             }
         }
     } else {
         vmError(vmText::_('COM_VIRTUEMART_MEDIA_MUST_HAVE_URL'));
         $ok = FALSE;
     }
     if (empty($this->file_title) && !empty($this->file_name)) {
         $this->file_title = $this->file_name;
     }
     if (!empty($this->file_title)) {
         if (strlen($this->file_title) > 126) {
             vmError(vmText::sprintf('COM_VIRTUEMART_TITLE_TOO_LONG', strlen($this->file_title)));
         }
         $q = 'SELECT * FROM `' . $this->_tbl . '` ';
         $q .= 'WHERE `file_title`="' . $this->_db->escape($this->file_title) . '" AND `file_type`="' . $this->_db->escape($this->file_type) . '"';
         $this->_db->setQuery($q);
         $unique_id = $this->_db->loadAssocList();
         $tblKey = 'virtuemart_media_id';
         if (!empty($unique_id)) {
             foreach ($unique_id as $item) {
                 if ($item['virtuemart_media_id'] != $this->virtuemart_media_id) {
                     $lastDir = substr($this->file_url, 0, strrpos($this->file_url, '/'));
                     $lastDir = substr($lastDir, strrpos($lastDir, '/') + 1);
                     if (!empty($lastDir)) {
                         $this->file_title = $this->file_title . '_' . $lastDir;
                     } else {
                         $this->file_title = $this->file_title . '_' . rand(1, 9);
                     }
                 }
             }
         }
     } else {
         vmError(vmText::_('COM_VIRTUEMART_MEDIA_MUST_HAVE_TITLE'));
         $ok = FALSE;
     }
     if (!empty($this->file_description)) {
         if (strlen($this->file_description) > 254) {
             vmError(vmText::sprintf('COM_VIRTUEMART_DESCRIPTION_TOO_LONG', strlen($this->file_description)));
         }
     }
     //		$app = JFactory::getApplication();
     //vmError('Checking '.$this->file_url);
     if (empty($this->file_mimetype)) {
         $rel_path = str_replace('/', DS, $this->file_url);
         //The function mime_content_type is deprecated, we may use
         /*function _mime_content_type($filename)
         			{
         				$result = new finfo();
         
         				if (is_resource($result) === true)
         				{
         					return $result->file($filename, FILEINFO_MIME_TYPE);
         				}
         
         				return false;
         			}
         			if (function_exists ('mime_content_type')) {
         				$ok = TRUE;
         				$app = JFactory::getApplication ();
         
         				if (!$this->file_is_forSale) {
         					$this->file_mimetype = mime_content_type (JPATH_ROOT . DS . $rel_path);
         				}
         				else {
         					$this->file_mimetype = mime_content_type ($rel_path);
         				}
         
         				if (!empty($this->file_mimetype)) {
         					if ($this->file_mimetype == 'directory') {
         						vmError ('cant store this media, is a directory ' . $rel_path);
         						return FALSE;
         					}
         					else {
         						if (strpos ($this->file_mimetype, 'corrupt') !== FALSE) {
         							vmError ('cant store this media, Document corrupt: Cannot read summary info ' . $rel_path);
         							return FALSE;
         						}
         					}
         				}
         				else {
         					vmError ('Couldnt resolve mime ' . $rel_path);
         					return FALSE;
         				}
         
         			}
         			else {*/
         if (!class_exists('JFile')) {
             require VMPATH_LIBS . DS . 'joomla' . DS . 'filesystem' . DS . 'file.php';
         }
         if (!$this->file_is_forSale) {
             $lastIndexOfSlash = strrpos($this->file_url, '/');
             $name = substr($this->file_url, $lastIndexOfSlash + 1);
             $file_extension = strtolower(JFile::getExt($name));
         } else {
             $lastIndexOfSlash = strrpos($this->file_url, DS);
             $name = substr($this->file_url, $lastIndexOfSlash + 1);
             $file_extension = strtolower(JFile::getExt($name));
         }
         if (empty($name)) {
             vmError(vmText::_('COM_VIRTUEMART_NO_MEDIA'));
         } elseif ($file_extension === 'jpg' or $file_extension === 'jpeg' or $file_extension === 'jpe') {
             $this->file_mimetype = 'image/jpeg';
         } elseif ($file_extension === 'gif') {
             $this->file_mimetype = 'image/gif';
         } elseif ($file_extension === 'png') {
             $this->file_mimetype = 'image/png';
         } elseif ($file_extension === 'bmp') {
             vmInfo(vmText::sprintf('COM_VIRTUEMART_MEDIA_SHOULD_NOT_BMP', $name));
             $notice = true;
         } elseif ($file_extension === 'mp3') {
             $this->file_mimetype = 'audio/mpeg';
         } elseif ($file_extension === 'ogg') {
             $this->file_mimetype = 'audio/ogg';
         } elseif ($file_extension === 'oga') {
             $this->file_mimetype = 'audio/vorbis';
         } elseif ($file_extension === 'wma') {
             $this->file_mimetype = 'audio-/x-ms-wma';
         } elseif ($file_extension === 'mp4' or $file_extension === 'mpe' or $file_extension === 'mpeg' or $file_extension === 'mpg' or $file_extension === 'mpga' or $file_extension === 'm2v') {
             $this->file_mimetype = 'video/mpeg';
         } elseif ($file_extension === 'avi') {
             $this->file_mimetype = 'video/x-msvideo';
         } elseif ($file_extension === 'qt' or $file_extension === 'mov') {
             $this->file_mimetype = 'video/quicktime';
         } elseif ($file_extension === 'wmv') {
             $this->file_mimetype = 'video/x-ms-wmv';
         } elseif ($file_extension === '3gp') {
             $this->file_mimetype = 'video/3gpp';
         } elseif ($file_extension === 'ogv') {
             $this->file_mimetype = 'video/ogg';
         } elseif ($file_extension === 'flv') {
             $this->file_mimetype = 'video/x-flv';
         } elseif ($file_extension === 'f4v') {
             $this->file_mimetype = 'video/x-f4v';
         } elseif ($file_extension === 'm4v') {
             $this->file_mimetype = 'video/x-m4v';
         } elseif ($file_extension === 'webm') {
             $this->file_mimetype = 'video/webm';
         } elseif ($file_extension === 'zip') {
             $this->file_mimetype = 'application/zip';
         } elseif ($file_extension === 'pdf') {
             $this->file_mimetype = 'application/pdf';
         } elseif ($file_extension === 'gz') {
             $this->file_mimetype = 'application/x-gzip';
         } elseif ($file_extension === 'exe') {
             $this->file_mimetype = 'application/octet-stream';
         } elseif ($file_extension === 'swf') {
             $this->file_mimetype = 'application/x-shockwave-flash';
         } elseif ($file_extension === 'doc') {
             $this->file_mimetype = 'application/msword';
         } elseif ($file_extension === 'docx') {
             $this->file_mimetype = 'application/vnd.openxmlformats-officedocument.wordprocessingml.document';
         } elseif ($file_extension === 'xls') {
             $this->file_mimetype = 'application/vnd.ms-excel';
         } elseif ($file_extension === 'xlsx') {
             $this->file_mimetype = 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet';
         } elseif ($file_extension === 'ppt') {
             $this->file_mimetype = 'application/vnd.ms-powerpoint';
         } elseif ($file_extension === 'pptx') {
             $this->file_mimetype = 'application/vnd.openxmlformats-officedocument.presentationml.presentation';
         } elseif ($file_extension === 'txt') {
             $this->file_mimetype = 'text/plain';
         } elseif ($file_extension === 'rar') {
             $this->file_mimetype = 'application/x-rar-compressed';
         } else {
             vmInfo(vmText::sprintf('COM_VIRTUEMART_MEDIA_SHOULD_HAVE_MIMETYPE', $name));
             $notice = TRUE;
         }
         //}
     }
     //Nasty small hack, should work as long the word for default is in the language longer than 3 words and the first
     //letter should be always / or something like this
     //It prevents storing of the default path
     $a = trim(substr($this->file_url_thumb, 0, 4));
     $b = trim(substr(vmText::_('COM_VIRTUEMART_DEFAULT_URL'), 0, 4));
     if (strpos($a, $b) !== FALSE) {
         $this->file_url_thumb = null;
     }
     if ($ok) {
         return parent::check();
     } else {
         return FALSE;
     }
 }
Exemple #10
0
 /**
  * Validates the userfields record fields.
  *
  * @return boolean True if the table buffer is contains valid data, false otherwise.
  */
 function check($nrOfValues)
 {
     //		if (!$this->name) {
     //			vmError(JText::_('COM_VIRTUEMART_USERFIELD_MUST_HAVE_NAME'));
     //			return false;
     //		}
     //		if (!$this->title) {
     //			vmError(JText::_('COM_VIRTUEMART_USERFIELD_MUST_HAVE_TITLE'));
     //			return false;
     //		}
     if (preg_match('/[^a-z0-9\\._\\-]/i', $this->name) > 0) {
         vmError(JText::_('COM_VIRTUEMART_NAME_OF_USERFIELD_CONTAINS_INVALID_CHARACTERS'));
         return false;
     }
     $reqValues = array('select', 'multiselect', 'radio', 'multicheckbox');
     if (in_array($this->type, $reqValues) && $nrOfValues == 0) {
         vmError(JText::_('COM_VIRTUEMART_VALUES_ARE_REQUIRED_FOR_THIS_TYPE'));
         return false;
     }
     /**		if ($this->virtuemart_userfield_id == 0) {
     			$_sql = 'SELECT COUNT(*) AS c '
     					. 'FROM `#__virtuemart_userfields`'
     					. "WHERE name = '" . $this->_db->getEscaped($this->name) . "' ";
     
     			$this->_db->setQuery($_sql);
     			$_c = $this->_db->loadResultArray();
     
     			if ($_c[0] > 0) {
     				vmError(JText::_('COM_VIRTUEMART_USERFIELD_ERR_ALREADY', $this->name));
     				return false;
     			}
     		}*/
     return parent::check();
 }
Exemple #11
0
 function check()
 {
     if (empty($this->shopper_group_name)) {
         vmError(vmText::_('COM_VIRTUEMART_SHOPPERGROUP_RECORDS_MUST_HAVE_NAME'));
         return false;
     } else {
         if (function_exists('mb_strlen')) {
             if (mb_strlen($this->shopper_group_name) > 128) {
                 vmError(vmText::_('COM_VIRTUEMART_SHOPPERGROUP_NAME_LESS_THAN_32_CHARACTERS'));
                 return false;
             }
         } else {
             if (strlen($this->shopper_group_name) > 128) {
                 vmError(vmText::_('COM_VIRTUEMART_SHOPPERGROUP_NAME_LESS_THAN_32_CHARACTERS'));
                 return false;
             }
         }
     }
     if ($this->virtuemart_shoppergroup_id == 1) {
         $this->default = 2;
         $this->sgrp_additional = 0;
     }
     if ($this->virtuemart_shoppergroup_id == 2) {
         $this->default = 1;
         $this->sgrp_additional = 0;
     }
     return parent::check();
 }
Exemple #12
0
 function check()
 {
     if (empty($this->order_number)) {
         if (!class_exists('VirtueMartModelOrders')) {
             require JPATH_VM_ADMINISTRATOR . DS . 'models' . DS . 'orders.php';
         }
         $this->order_number = VirtueMartModelOrders::generateOrderNumber((string) time());
     }
     if (empty($this->order_pass)) {
         $this->order_pass = '******' . substr(md5((string) time() . $this->order_number), 0, 5);
     }
     return parent::check();
 }
Exemple #13
0
 function check()
 {
     if (empty($this->order_number)) {
         if (!class_exists('VirtueMartModelOrders')) {
             require JPATH_VM_ADMINISTRATOR . DS . 'models' . DS . 'orders.php';
         }
         $this->order_number = VirtueMartModelOrders::generateOrderNumber((string) time());
     }
     if (empty($this->order_pass)) {
         $this->order_pass = '******' . substr(md5((string) time() . $this->order_number), 0, 5);
     }
     $adminID = JFactory::getSession()->get('vmAdminID');
     if (isset($adminID)) {
         $this->created_by = $adminID;
     }
     return parent::check();
 }
Exemple #14
0
 /**
  * Validates the userfields record fields.
  *
  * @return boolean True if the table buffer is contains valid data, false otherwise.
  */
 function check($nrOfValues)
 {
     if (preg_match('/[^a-z0-9\\._\\-]/i', $this->name) > 0) {
         vmError(JText::_('COM_VIRTUEMART_NAME_OF_USERFIELD_CONTAINS_INVALID_CHARACTERS'));
         return false;
     }
     $reqValues = array('select', 'multiselect', 'radio', 'multicheckbox');
     if (in_array($this->type, $reqValues) && $nrOfValues == 0) {
         vmError(JText::_('COM_VIRTUEMART_VALUES_ARE_REQUIRED_FOR_THIS_TYPE'));
         return false;
     }
     return parent::check();
 }
Exemple #15
0
 public function check()
 {
     $csValue = $this->limit_list_step;
     if (!empty($csValue)) {
         $sequenceArray = explode(',', $csValue);
         foreach ($sequenceArray as &$csV) {
             $csV = (int) trim($csV);
         }
         $this->limit_list_step = implode(',', $sequenceArray);
     }
     return parent::check();
 }
Exemple #16
0
 /**
  *
  * @author Max Milbers
  * @return boolean True if the table buffer is contains valid data, false otherwise.
  */
 function check()
 {
     $ok = true;
     $notice = true;
     if (empty($this->file_type) and empty($this->file_is_forSale)) {
         $ok = false;
         vmError(JText::sprintf('COM_VIRTUEMART_MEDIA_NO_TYPE'), $this->file_name);
     }
     if (!empty($this->file_url)) {
         if (function_exists('mb_strlen')) {
             if (mb_strlen($this->file_url) > 254) {
                 vmError(JText::sprintf('COM_VIRTUEMART_URL_TOO_LONG', mb_strlen($this->file_url)));
             }
         } else {
             if (strlen($this->file_url) > 254) {
                 vmError(JText::sprintf('COM_VIRTUEMART_URL_TOO_LONG', strlen($this->file_url)));
             }
         }
         if (strpos($this->file_url, '..') !== false) {
             $ok = false;
             vmError(JText::sprintf('COM_VIRTUEMART_URL_NOT_VALID', $this->file_url));
         }
         if (empty($this->virtuemart_media_id)) {
             $q = 'SELECT `virtuemart_media_id`,`file_url` FROM `' . $this->_tbl . '` WHERE `file_url` = "' . $this->_db->getEscaped($this->file_url) . '" ';
             $this->_db->setQuery($q);
             $unique_id = $this->_db->loadAssocList();
             $count = count($unique_id);
             if ($count !== 0) {
                 if ($count == 1) {
                     if (empty($this->virtuemart_media_id)) {
                         $this->virtuemart_media_id = $unique_id[0]['virtuemart_media_id'];
                     } else {
                         vmError(JText::_('COM_VIRTUEMART_MEDIA_IS_ALREADY_IN_DB'));
                         $ok = false;
                     }
                 } else {
                     //      			vmError(JText::_('COM_VIRTUEMART_MEDIA_IS_DOUBLED_IN_DB'));
                     vmError(JText::_('COM_VIRTUEMART_MEDIA_IS_DOUBLED_IN_DB'));
                     $ok = false;
                 }
             }
         }
     } else {
         vmError(JText::_('COM_VIRTUEMART_MEDIA_MUST_HAVE_URL'));
         $ok = false;
     }
     if (empty($this->file_title) && !empty($this->file_name)) {
         $this->file_title = $this->file_name;
     }
     if (!empty($this->file_title)) {
         if (strlen($this->file_title) > 126) {
             vmError(JText::sprintf('COM_VIRTUEMART_TITLE_TOO_LONG', strlen($this->file_title)));
         }
         $q = 'SELECT * FROM `' . $this->_tbl . '` ';
         $q .= 'WHERE `file_title`="' . $this->_db->getEscaped($this->file_title) . '" AND `file_type`="' . $this->_db->getEscaped($this->file_type) . '"';
         $this->_db->setQuery($q);
         $unique_id = $this->_db->loadAssocList();
         $tblKey = 'virtuemart_media_id';
         if (!empty($unique_id)) {
             foreach ($unique_id as $item) {
                 if ($item['virtuemart_media_id'] != $this->virtuemart_media_id) {
                     $lastDir = substr($this->file_url, 0, strrpos($this->file_url, '/'));
                     $lastDir = substr($lastDir, strrpos($lastDir, '/') + 1);
                     if (!empty($lastDir)) {
                         $this->file_title = $this->file_title . '_' . $lastDir;
                     } else {
                         $this->file_title = $this->file_title . '_' . rand(1, 9);
                     }
                 }
             }
         }
     } else {
         vmError(JText::_('COM_VIRTUEMART_MEDIA_MUST_HAVE_TITLE'));
         $ok = false;
     }
     if (!empty($this->file_description)) {
         if (strlen($this->file_description) > 254) {
             vmError(JText::sprintf('COM_VIRTUEMART_DESCRIPTION_TOO_LONG', strlen($this->file_description)));
         }
     }
     //		$app = JFactory::getApplication();
     //vmError('Checking '.$this->file_url);
     if (empty($this->file_mimetype)) {
         $rel_path = str_replace('/', DS, $this->file_url);
         //			return JPATH_ROOT.DS.$rel_path.$this->file_name.'.'.$this->file_extension;
         if (function_exists('mime_content_type')) {
             $ok = true;
             $app = JFactory::getApplication();
             //				set_error_handler(array($this, 'handleError'));
             //				try{
             if (!$this->file_is_forSale) {
                 $this->file_mimetype = mime_content_type(JPATH_ROOT . DS . $rel_path);
             } else {
                 $this->file_mimetype = mime_content_type($rel_path);
             }
             if (!empty($this->file_mimetype)) {
                 if ($this->file_mimetype == 'directory') {
                     vmError('cant store this media, is a directory ' . $rel_path);
                     return false;
                 } else {
                     if (strpos($this->file_mimetype, 'corrupt') !== false) {
                         vmError('cant store this media, Document corrupt: Cannot read summary info ' . $rel_path);
                         return false;
                     }
                 }
                 //vmError('file_mime '.$this->file_mimetype.' for '.$rel_path);
             } else {
                 vmError('Couldnt resolve mime ' . $rel_path);
                 return false;
             }
             // 				     vmError('mime'.$this->file_mimetype);
             // 				     if($this->file_mimetype == 'directory'){
             // 				     		vmError('Couldnt resolve mime, because it is a '.$rel_path);
             // 					     return false;
             // 				     }
             // 				} catch (ErrorException $e){
             // 					$ok = false;
             // 				     $app->enqueueMessage('Couldnt resolve mime type for '.$rel_path);
             // 				    return false;
             // 				}
             //				restore_error_handler();
             //$this->file_mimetype = mime_content_type(JPATH_ROOT.DS.$rel_path);
         } else {
             if (!class_exists('JFile')) {
                 require JPATH_VM_LIBRARIES . DS . 'joomla' . DS . 'filesystem' . DS . 'file.php';
             }
             if (!$this->file_is_forSale) {
                 $lastIndexOfSlash = strrpos($this->file_url, '/');
                 $name = substr($this->file_url, $lastIndexOfSlash + 1);
                 $file_extension = strtolower(JFile::getExt($name));
             } else {
                 $lastIndexOfSlash = strrpos($this->file_url, DS);
                 $name = substr($this->file_url, $lastIndexOfSlash + 1);
                 $file_extension = strtolower(JFile::getExt($name));
             }
             if (empty($name)) {
                 vmError(JText::_('COM_VIRTUEMART_NO_MEDIA'));
             } elseif ($file_extension === 'jpg' or $file_extension === 'jpeg' or $file_extension === 'jpe') {
                 $this->file_mimetype = 'image/jpeg';
             } elseif ($file_extension === 'gif') {
                 $this->file_mimetype = 'image/gif';
             } elseif ($file_extension === 'png') {
                 $this->file_mimetype = 'image/png';
             } elseif ($file_extension === 'bmp') {
                 vmInfo(JText::sprintf('COM_VIRTUEMART_MEDIA_SHOULD_NOT_BMP', $name));
                 $notice = true;
             } elseif ($file_extension === 'mp3') {
                 $this->file_mimetype = 'audio/mpeg';
             } elseif ($file_extension === 'ogg') {
                 $this->file_mimetype = 'audio/ogg';
             } elseif ($file_extension === 'oga') {
                 $this->file_mimetype = 'audio/vorbis';
             } elseif ($file_extension === 'wma') {
                 $this->file_mimetype = 'audio-/x-ms-wma';
             } elseif ($file_extension === 'mp4' or $file_extension === 'mpe' or $file_extension === 'mpeg' or $file_extension === 'mpg' or $file_extension === 'mpga') {
                 $this->file_mimetype = 'video/mpeg';
             } elseif ($file_extension === 'avi') {
                 $this->file_mimetype = 'video/x-msvideo';
             } elseif ($file_extension === 'qt' or $file_extension === 'mov') {
                 $this->file_mimetype = 'video/quicktime';
             } elseif ($file_extension === 'wmv') {
                 $this->file_mimetype = 'video/x-ms-wmv';
             } elseif ($file_extension === 'zip') {
                 $this->file_mimetype = 'application/zip';
             } elseif ($file_extension === 'pdf') {
                 $this->file_mimetype = 'application/pdf';
             } elseif ($file_extension === 'gz') {
                 $this->file_mimetype = 'application/x-gzip';
             } elseif ($file_extension === 'exe') {
                 $this->file_mimetype = 'application/octet-stream';
             } elseif ($file_extension === 'swf') {
                 $this->file_mimetype = 'application/x-shockwave-flash';
             } else {
                 vmInfo(JText::sprintf('COM_VIRTUEMART_MEDIA_SHOULD_HAVE_MIMETYPE', $name));
                 $notice = true;
             }
         }
     }
     if ($ok) {
         return parent::check();
     } else {
         return false;
     }
 }
Exemple #17
0
 function check()
 {
     //$this->checkCurrencySymbol();
     return parent::check();
 }