Beispiel #1
1
 public function send()
 {
     global $jlistConfig;
     // Initialise variables.
     $data = JRequest::getVar('jform', array(), 'post', 'array');
     $app = JFactory::getApplication();
     $name = array_key_exists('name', $data) ? $data['name'] : '';
     $email = array_key_exists('email', $data) ? $data['email'] : '';
     $file_id = array_key_exists('file_id', $data) ? intval($data['file_id']) : 0;
     $file_title = array_key_exists('file_title', $data) ? $data['file_title'] : '';
     $file_name = array_key_exists('url_download', $data) ? $data['url_download'] : '';
     $cat_id = array_key_exists('cat_id', $data) ? $data['cat_id'] : 0;
     $cat_title = array_key_exists('cat_title', $data) ? $data['cat_title'] : '';
     $reason = array_key_exists('reason', $data) ? intval($data['reason']) : 0;
     $text = array_key_exists('text', $data) ? $data['text'] : '';
     switch ($reason) {
         case 0:
             $reason_text = '';
             break;
         case 1:
             $reason_text = JText::_('COM_JDOWNLOADS_REPORT_REASON_MISSING');
             break;
         case 2:
             $reason_text = JText::_('COM_JDOWNLOADS_REPORT_REASON_BAD_FILE');
             break;
         case 3:
             $reason_text = JText::_('COM_JDOWNLOADS_REPORT_REASON_OTHERS');
             break;
     }
     // get the users IP
     $ip = JDHelper::getRealIp();
     // automatically removes html formatting
     $text = JFilterInput::getInstance()->clean($text, 'string');
     $name = JFilterInput::getInstance()->clean($name, 'string');
     $email = JFilterInput::getInstance()->clean($email, 'string');
     // Get all users email addresses in an array
     $recipients = explode(';', $jlistConfig['send.mailto.report']);
     // Check to see if there are any users in this group before we continue
     if (!count($recipients)) {
         $this->setError(JText::_('COM_JDOWNLOADS_NO_EMAIL_RECIPIENT_FOUND'));
         return false;
     }
     // Get the Mailer
     $mailer = JFactory::getMailer();
     // Build email message format.
     $mailer->setSender(array($app->getCfg('mailfrom'), $app->getCfg('fromname')));
     $mailer->setSubject('jDownloads - ' . stripslashes(JDHelper::getOnlyLanguageSubstring($jlistConfig['report.mail.subject'])));
     $message = JDHelper::getOnlyLanguageSubstring($jlistConfig['report.mail.layout']);
     $message = str_replace('{category}', $cat_title, $message);
     $message = str_replace('{cat_id}', $cat_id, $message);
     $message = str_replace('{file_id}', $file_id, $message);
     $message = str_replace('{file_title}', $file_title, $message);
     $message = str_replace('{file_name}', $file_name, $message);
     $message = str_replace('{name}', $name, $message);
     $message = str_replace('{mail}', $email, $message);
     $message = str_replace('{ip}', $ip, $message);
     $date_format = JDHelper::getDateFormat();
     $message = str_replace('{date_time}', JHtml::date($input = 'now', $date_format['long'], true), $message);
     $message = str_replace('{reason}', $reason_text, $message);
     $message = str_replace('{message}', $text, $message);
     $mailer->setBody($message);
     // Example: Optional file attached
     // $mailer->addAttachment(JPATH_COMPONENT.'/assets/document.pdf');
     // Example: Optionally add embedded image
     // $mailer->AddEmbeddedImage( JPATH_COMPONENT.'/assets/logo128.jpg', 'logo_id', 'logo.jpg', 'base64', 'image/jpeg' );
     // Needed for use HTML
     $mailer->IsHTML(true);
     $mailer->Encoding = 'base64';
     // Add recipients
     $mailer->addRecipient($recipients);
     // Send the Mail
     $result = $mailer->Send();
     if ($result !== true) {
         $this->setError($result->getError());
         return false;
     } else {
         JError::raiseNotice(100, JText::_('COM_JDOWNLOADS_EMAIL_SUCCESSFUL_SENDED'));
         return true;
     }
 }
Beispiel #2
0
 if ($cat_link_itemidsPlg) {
     for ($i = 0; $i < count($cat_link_itemidsPlg); $i++) {
         $cat_link_itemidsPlg[$i]['catid'] = substr(strrchr($cat_link_itemidsPlg[$i]['link'], '='), 1);
     }
 }
 // get current category menu ID when exist and all needed menu IDs for the header links
 global $menuItemids;
 $menuItemids = JDHelper::getMenuItemids();
 // get all other menu category IDs so we can use it when we needs it
 global $cat_link_itemids;
 $cat_link_itemids = JDHelper::getAllJDCategoryMenuIDs();
 // "Home" menu link itemid
 global $root_itemid;
 $root_itemid = $menuItemids['root'];
 global $date_format;
 $date_format = JDHelper::getDateFormat();
 //Globals definition
 $GLOBALS['jDFPitemid'] = jd_CalcItemid();
 $GLOBALS['jDFPOnlineLayout'] = '';
 $GLOBALS['jlistConfigM'] = buildjlistConfigM();
 $GLOBALS['jDownloadsMessage'] = 0;
 $GLOBALS['jDownloadsTested'] = 0;
 $GLOBALS['jDownloadsInstalled'] = 0;
 $GLOBALS['jDownloadsVersion'] = 0;
 $GLOBALS['jDFPconsiderrights'] = 1;
 $GLOBALS['jDFPv14'] = 0;
 $GLOBALS['jDFPsfolders'] = jd_SymbolFolders();
 $GLOBALS['jDFPpluginversion'] = '1.5';
 $GLOBALS['jDFPrank'] = 1;
 $GLOBALS['jDFPison'] = 1;
 $GLOBALS['jDFPcatids'] = '';