first commit

This commit is contained in:
alazhar
2020-01-02 22:20:31 +07:00
commit 10eb3340ad
5753 changed files with 631345 additions and 0 deletions

View File

@ -0,0 +1,153 @@
<?php
/**
* @package Joomla.Site
* @subpackage com_mailto
*
* @copyright Copyright (C) 2005 - 2013 Open Source Matters, Inc. All rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE.txt
*/
defined('_JEXEC') or die;
/**
* @package Joomla.Site
* @subpackage com_mailto
* @since 1.5
*/
class MailtoController extends JControllerLegacy
{
/**
* Show the form so that the user can send the link to someone
*
* @access public
* @since 1.5
*/
public function mailto()
{
$session = JFactory::getSession();
$session->set('com_mailto.formtime', time());
$this->input->set('view', 'mailto');
$this->display();
}
/**
* Send the message and display a notice
*
* @access public
* @since 1.5
*/
public function send()
{
// Check for request forgeries
JSession::checkToken() or jexit(JText::_('JINVALID_TOKEN'));
$app = JFactory::getApplication();
$session = JFactory::getSession();
$timeout = $session->get('com_mailto.formtime', 0);
if ($timeout == 0 || time() - $timeout < 20)
{
JError::raiseNotice(500, JText::_('COM_MAILTO_EMAIL_NOT_SENT'));
return $this->mailto();
}
$SiteName = $app->getCfg('sitename');
$link = MailtoHelper::validateHash($this->input->get('link', '', 'post'));
// Verify that this is a local link
if (!$link || !JUri::isInternal($link))
{
//Non-local url...
JError::raiseNotice(500, JText::_('COM_MAILTO_EMAIL_NOT_SENT'));
return $this->mailto();
}
// An array of email headers we do not want to allow as input
$headers = array ( 'Content-Type:',
'MIME-Version:',
'Content-Transfer-Encoding:',
'bcc:',
'cc:');
// An array of the input fields to scan for injected headers
$fields = array(
'mailto',
'sender',
'from',
'subject',
);
/*
* Here is the meat and potatoes of the header injection test. We
* iterate over the array of form input and check for header strings.
* If we find one, send an unauthorized header and die.
*/
foreach ($fields as $field)
{
foreach ($headers as $header)
{
if (strpos($_POST[$field], $header) !== false)
{
JError::raiseError(403, '');
}
}
}
/*
* Free up memory
*/
unset ($headers, $fields);
$email = $this->input->post->getString('mailto', '');
$sender = $this->input->post->getString('sender', '');
$from = $this->input->post->getString('from', '');
$subject_default = JText::sprintf('COM_MAILTO_SENT_BY', $sender);
$subject = $this->input->post->getString('subject', $subject_default);
// Check for a valid to address
$error = false;
if (! $email || ! JMailHelper::isEmailAddress($email))
{
$error = JText::sprintf('COM_MAILTO_EMAIL_INVALID', $email);
JError::raiseWarning(0, $error);
}
// Check for a valid from address
if (! $from || ! JMailHelper::isEmailAddress($from))
{
$error = JText::sprintf('COM_MAILTO_EMAIL_INVALID', $from);
JError::raiseWarning(0, $error);
}
if ($error)
{
return $this->mailto();
}
// Build the message to send
$msg = JText::_('COM_MAILTO_EMAIL_MSG');
$link = $link;
$body = sprintf($msg, $SiteName, $sender, $from, $link);
// Clean the email data
$subject = JMailHelper::cleanSubject($subject);
$body = JMailHelper::cleanBody($body);
// To send we need to use punycode.
$from = JStringPunycode::emailToPunycode($from);
$from = JMailHelper::cleanAddress($from);
$email = JStringPunycode::emailToPunycode($email);
// Send the email
if (JFactory::getMailer()->sendMail($from, $sender, $email, $subject, $body) !== true)
{
JError::raiseNotice(500, JText::_('COM_MAILTO_EMAIL_NOT_SENT'));
return $this->mailto();
}
$this->input->set('view', 'sent');
$this->display();
}
}

View File

@ -0,0 +1 @@
<!DOCTYPE html><title></title>

View File

@ -0,0 +1,84 @@
<?php
/**
* @package Joomla.Site
* @subpackage com_mailto
*
* @copyright Copyright (C) 2005 - 2013 Open Source Matters, Inc. All rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE.txt
*/
defined('_JEXEC') or die;
/**
* @package Joomla.Site
* @subpackage com_mailto
*/
abstract class MailtoHelper
{
/**
* Adds a URL to the mailto system and returns the hash
*
* @param string url
* @return URL hash
*/
public static function addLink($url)
{
$hash = sha1($url);
self::cleanHashes();
$session = JFactory::getSession();
$mailto_links = $session->get('com_mailto.links', array());
if (!isset($mailto_links[$hash]))
{
$mailto_links[$hash] = new stdClass;
}
$mailto_links[$hash]->link = $url;
$mailto_links[$hash]->expiry = time();
$session->set('com_mailto.links', $mailto_links);
return $hash;
}
/**
* Checks if a URL is a Flash file
*
* @param string
* @return URL
*/
public static function validateHash($hash)
{
$retval = false;
$session = JFactory::getSession();
self::cleanHashes();
$mailto_links = $session->get('com_mailto.links', array());
if (isset($mailto_links[$hash]))
{
$retval = $mailto_links[$hash]->link;
}
return $retval;
}
/**
* Cleans out old hashes
*
* @since 1.6.1
*/
public static function cleanHashes($lifetime = 1440)
{
// flag for if we've cleaned on this cycle
static $cleaned = false;
if (!$cleaned)
{
$past = time() - $lifetime;
$session = JFactory::getSession();
$mailto_links = $session->get('com_mailto.links', array());
foreach ($mailto_links as $index => $link)
{
if ($link->expiry < $past)
{
unset($mailto_links[$index]);
}
}
$session->set('com_mailto.links', $mailto_links);
$cleaned = true;
}
}
}

View File

@ -0,0 +1 @@
<!DOCTYPE html><title></title>

View File

@ -0,0 +1,19 @@
<?php
/**
* @package Joomla.Site
* @subpackage com_mailto
*
* @copyright Copyright (C) 2005 - 2013 Open Source Matters, Inc. All rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE.txt
*/
defined('_JEXEC') or die;
require_once JPATH_COMPONENT.'/helpers/mailto.php';
require_once JPATH_COMPONENT.'/controller.php';
$controller = JControllerLegacy::getInstance('Mailto');
$controller->registerDefaultTask('mailto');
$controller->execute(JFactory::getApplication()->input->get('task'));
//$controller->redirect();

View File

@ -0,0 +1,32 @@
<?xml version="1.0" encoding="utf-8"?>
<extension type="component" version="3.1" method="upgrade">
<name>com_mailto</name>
<author>Joomla! Project</author>
<creationDate>April 2006</creationDate>
<copyright>(C) 2005 - 2013 Open Source Matters. All rights reserved. </copyright>
<license>GNU General Public License version 2 or later; see LICENSE.txt</license>
<authorEmail>admin@joomla.org</authorEmail>
<authorUrl>www.joomla.org</authorUrl>
<version>3.0.0</version>
<description>COM_MAILTO_XML_DESCRIPTION</description>
<files folder="site">
<filename>controller.php</filename>
<filename>index.html</filename>
<filename>mailto.php</filename>
<folder>views</folder>
</files>
<languages folder="site">
<language tag="en-GB">language/en-GB.com_mailto.ini</language>
</languages>
<administration>
<files folder="admin">
<filename>index.html</filename>
</files>
<languages folder="admin">
<language tag="en-GB">language/en-GB.com_mailto.sys.ini</language>
</languages>
</administration>
<params>
<param name="view" type="filelist" directory="/components/com_mailto/views" hide_none="1" hide_default="0" filter="." default="0" label="View Style" description="The view style for display" />
</params>
</extension>

View File

@ -0,0 +1 @@
<!DOCTYPE html><title></title>

View File

@ -0,0 +1 @@
<!DOCTYPE html><title></title>

View File

@ -0,0 +1,2 @@
<?xml version="1.0"?>
<metadata />

View File

@ -0,0 +1,76 @@
<?php
/**
* @package Joomla.Site
* @subpackage com_mailto
*
* @copyright Copyright (C) 2005 - 2013 Open Source Matters, Inc. All rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE.txt
*/
defined('_JEXEC') or die;
JHtml::_('behavior.keepalive');
?>
<script type="text/javascript">
Joomla.submitbutton = function(pressbutton)
{
var form = document.getElementById('mailtoForm');
// do field validation
if (form.mailto.value == "" || form.from.value == "")
{
alert('<?php echo JText::_('COM_MAILTO_EMAIL_ERR_NOINFO'); ?>');
return false;
}
form.submit();
}
</script>
<?php
$data = $this->get('data');
?>
<div id="mailto-window">
<h2>
<?php echo JText::_('COM_MAILTO_EMAIL_TO_A_FRIEND'); ?>
</h2>
<div class="mailto-close">
<a href="javascript: void window.close()" title="<?php echo JText::_('COM_MAILTO_CLOSE_WINDOW'); ?>">
<span><?php echo JText::_('COM_MAILTO_CLOSE_WINDOW'); ?> </span></a>
</div>
<form action="<?php echo JUri::base() ?>index.php" id="mailtoForm" method="post">
<div class="formelm">
<label for="mailto_field"><?php echo JText::_('COM_MAILTO_EMAIL_TO'); ?></label>
<input type="text" id="mailto_field" name="mailto" class="inputbox" size="25" value="<?php echo $this->escape($data->mailto); ?>"/>
</div>
<div class="formelm">
<label for="sender_field">
<?php echo JText::_('COM_MAILTO_SENDER'); ?></label>
<input type="text" id="sender_field" name="sender" class="inputbox" value="<?php echo $this->escape($data->sender); ?>" size="25" />
</div>
<div class="formelm">
<label for="from_field">
<?php echo JText::_('COM_MAILTO_YOUR_EMAIL'); ?></label>
<input type="text" id="from_field" name="from" class="inputbox" value="<?php echo $this->escape($data->from); ?>" size="25" />
</div>
<div class="formelm">
<label for="subject_field">
<?php echo JText::_('COM_MAILTO_SUBJECT'); ?></label>
<input type="text" id="subject_field" name="subject" class="inputbox" value="<?php echo $this->escape($data->subject); ?>" size="25" />
</div>
<p>
<button class="button" onclick="return Joomla.submitbutton('send');">
<?php echo JText::_('COM_MAILTO_SEND'); ?>
</button>
<button class="button" onclick="window.close();return false;">
<?php echo JText::_('COM_MAILTO_CANCEL'); ?>
</button>
</p>
<input type="hidden" name="layout" value="<?php echo $this->getLayout();?>" />
<input type="hidden" name="option" value="com_mailto" />
<input type="hidden" name="task" value="send" />
<input type="hidden" name="tmpl" value="component" />
<input type="hidden" name="link" value="<?php echo $data->link; ?>" />
<?php echo JHtml::_('form.token'); ?>
</form>
</div>

View File

@ -0,0 +1 @@
<!DOCTYPE html><title></title>

View File

@ -0,0 +1,75 @@
<?php
/**
* @package Joomla.Site
* @subpackage com_mailto
*
* @copyright Copyright (C) 2005 - 2013 Open Source Matters, Inc. All rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE.txt
*/
defined('_JEXEC') or die;
/**
* @package Joomla.Site
* @subpackage com_mailto
* @since 1.5
*/
class MailtoViewMailto extends JViewLegacy
{
/**
* @since 1.5
*/
public function display($tpl = null)
{
$data = $this->getData();
if ($data === false)
{
return false;
}
$this->set('data', $data);
parent::display($tpl);
}
/**
* @since 1.5
*/
function &getData()
{
$user = JFactory::getUser();
$app = JFactory::getApplication();
$data = new stdClass;
$data->link = urldecode(JRequest::getVar('link', '', 'method', 'base64'));
if ($data->link == '')
{
JError::raiseError(403, JText::_('COM_MAILTO_LINK_IS_MISSING'));
$false = false;
return $false;
}
// Load with previous data, if it exists
$mailto = $app->input->post->getString('mailto', '');
$sender = $app->input->post->getString('sender', '');
$from = $app->input->post->getString('from', '');
$subject = $app->input->post->getString('subject', '');
if ($user->get('id') > 0)
{
$data->sender = $user->get('name');
$data->from = $user->get('email');
}
else
{
$data->sender = $sender;
$data->from = JStringPunycode::emailToPunycode($from);
}
$data->subject = $subject;
$data->mailto = JStringPunycode::emailToPunycode($mailto);
return $data;
}
}

View File

@ -0,0 +1 @@
<!DOCTYPE html><title></title>

View File

@ -0,0 +1,11 @@
<?xml version="1.0"?>
<mosparam type="component" version="1.0.0">
<name>Mailto</name>
<author>Andrew Eddie</author>
<creationDate>13 Mar 2006</creationDate>
<copyright>Copyright (C) 2005 - 2013 Open Source Matters. All rights reserved.</copyright>
<license>GNU General Public License version 2 or later; see LICENSE.txt</license>
<authorEmail>admin@joomla.org</authorEmail>
<authorUrl>www.joomla.org</authorUrl>
<description>COM_MAILTO_XML_DESCRIPTION</description>
</mosparam>

View File

@ -0,0 +1,21 @@
<?php
/**
* @package Joomla.Site
* @subpackage com_mailto
*
* @copyright Copyright (C) 2005 - 2013 Open Source Matters, Inc. All rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE.txt
*/
defined('_JEXEC') or die;
?>
<div style="padding: 10px;">
<div style="text-align:right">
<a href="javascript: void window.close()">
<?php echo JText::_('COM_MAILTO_CLOSE_WINDOW'); ?> <?php echo JHtml::_('image', 'mailto/close-x.png', null, null, true); ?></a>
</div>
<h2>
<?php echo JText::_('COM_MAILTO_EMAIL_SENT'); ?>
</h2>
</div>

View File

@ -0,0 +1 @@
<!DOCTYPE html><title></title>

View File

@ -0,0 +1,26 @@
<?php
/**
* @package Joomla.Site
* @subpackage com_mailto
*
* @copyright Copyright (C) 2005 - 2013 Open Source Matters, Inc. All rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE.txt
*/
defined('_JEXEC') or die;
/**
* @package Joomla.Site
* @subpackage com_mailto
* @since 1.5
*/
class MailtoViewSent extends JViewLegacy
{
/**
* @since 1.5
*/
public function display($tpl = null)
{
parent::display($tpl);
}
}