homepage Welcome to WebmasterWorld Guest from 23.20.77.156
register, free tools, login, search, pro membership, help, library, announcements, recent posts, open posts,
Become a Pro Member
Visit PubCon.com
Home / Forums Index / Code, Content, and Presentation / PHP Server Side Scripting
Forum Library, Charter, Moderators: coopster & jatar k

PHP Server Side Scripting Forum

    
Time(date-year) is wrong in this code. please help
winpeace




msg:3155950
 7:49 am on Nov 14, 2006 (gmt 0)

<?/*
* $Id: combomax.php
*/?><?php
defined( '_VALID_MOS' ) or die( 'Direct Access to this location is not allowed.' );

require_once( $mainframe->getPath( 'front_html' ) );
require_once( $mainframe->getPath( 'class' ) );
require_once("includes/patTemplate/patTemplate.php");

$mainframe->setPageTitle('Comment on article');

$tmpl = new patTemplate();
$tmpl->setBasedir("components/com_combomax/templates/");
$tmpl->setNameSpace('pxt');

$task = mosGetParam($_REQUEST,'task','');
$page = mosGetParam($_REQUEST,'page','');

switch ($task) {

case "save":
saveComment($database, $tmpl);
break;

case "preview":
PreviewComments($database, $tmpl);
break;

case "sendreport":
sendreport($database, $tmpl);
break;

default:
break;

}

switch ($page) {
case "reportComment":
reportComment($database);
break;
}

function PreviewComments($database, $tmpl) {
global $mosConfig_offset;

$tmpl->readTemplatesFromFile("previewcomments.tpl");

$name = mosGetParam($_POST,'name','');
$email = mosGetParam($_POST,'email','');
$url = mosGetParam($_POST,'url','');

// look for images in template if available
$starImageOn = mosAdminMenus::ImageCheck( 'rating_star.png', '/images/M_images/' );
$starImageOff = mosAdminMenus::ImageCheck( 'rating_star_blank.png', '/images/M_images/' );

$row->rating = mosGetParam($_POST,'user_rating','');
$img = "";
for ($i=0; $i < $row->rating; $i++) {
$img .= $starImageOn;
}
for ($i=$row->rating; $i < 5; $i++) {
$img .= $starImageOff;
}
$html = '<span class="content_rating">';
$html .= $img;
$html .= "</span>";
$tmpl->addVar("previewForm", 'ratingimage', $html);

$comment = mosGetParam($_POST,'comment','');
$comment = mosHTML::cleanText($comment);
$comment = smile::smileReplace($comment);
$comment = replace_linebreaks($comment);
$comment = stripslashes($comment);

$rawcomment = mosGetParam($_POST,'comment','');
$rawcomment = mosHTML::cleanText($rawcomment);
$rawcomment = replace_linebreaks($rawcomment);
$rawcomment = stripslashes(stripslashes($rawcomment));

$tmpl->addVar("previewForm", 'name', stripslashes(mosGetParam($_POST,'name','')));
$tmpl->addVar("previewForm", 'contentid', stripslashes(mosGetParam($_POST,'contentid','')));
$tmpl->addVar("previewForm", 'email', stripslashes(mosGetParam($_POST,'email','')));
$tmpl->addVar("previewForm", 'url', stripslashes(mosGetParam($_POST,'url','')));
$tmpl->addVar("previewForm", 'comment', $comment);
$tmpl->addVar("previewForm", 'rawcomment', ($rawcomment));
$tmpl->addVar("previewForm", 'ip', stripslashes(mosGetParam($_SERVER,'REMOTE_ADDR','')));
$tmpl->addVar("previewForm", 'browser', stripslashes(mosGetParam($_SERVER,'HTTP_USER_AGENT','')));
$tmpl->addVar("previewForm", 'user_rating', stripslashes(mosGetParam($_POST,'user_rating','')));
$tmpl->addVar("previewForm", 'vote'.$row->rating, " checked=\"checked\" ");

$d = date( "Y-m-d H:i:s" );
$d = mosFormatDate( $d, '%Y-%m-%d %H:%M:%S', -$mosConfig_offset * 60 * 60 );
$tmpl->addVar("previewForm", 'date', $d);

$tmpl->parseTemplate("previewForm");
$tmpl->displayParsedTemplate("previewForm") ;
}

function saveComment($database, $tmpl) {

global $my, $mosConfig_offset, $maxLanguage, $mosConfig_live_site, $mainframe;

$maxConfig = new maxConfig();

$row = new mosComment($database);
$_contentid = mosGetParam($_POST,'contentid','');
$row->bind($_POST);
$comment =$row->comment;
$comment = addslashes($comment);
$row->comment = $comment;
$row->myid = $my->id;
$row->state = $maxConfig->auto_publish;
$row->approved = $maxConfig->auto_approve;
$row->ip = mosGetParam($_SERVER,'REMOTE_ADDR','');
$row->browser = mosGetParam($_SERVER,'HTTP_USER_AGENT','');
$d = date( "Y-m-d H:i:s" );
$row->date = mosFormatDate( $d, '%Y-%m-%d %H:%M:%S', -$mosConfig_offset * 60 * 60 );
$row->store();

$subject = $maxLanguage->EMAIL_SUBJECT_ADMIN_ALERT;

$tmpl = new patTemplate();
$tmpl->setBasedir("components/com_combomax/templates/");
$tmpl->setNameSpace('pxt');
$tmpl->readTemplatesFromFile("showcomment.tpl");
$tmpl->addVar("emailcomment", "NAME", stripslashes(stripslashes($row->name)));
$tmpl->addVar("emailcomment", 'email', stripslashes($row->email));
$tmpl->addVar("emailcomment", 'url', stripslashes($row->url));
$tmpl->addVar("emailcomment", 'comment', smile::smileReplace(stripslashes(stripslashes($row->comment))));
$tmpl->addVar("emailcomment", 'ip', stripslashes($row->ip));
$tmpl->addVar("emailcomment", 'browser', stripslashes($row->browser));
$tmpl->addVar("emailcomment", 'date', stripslashes($row->date));
$tmpl->addVar("emailcomment", 'reporturl', 'index.php?option=com_combomax&page=reportComment&commentid='.$row->id.'');

$tmpl->addVar("emailcomment", 'livesite', $mosConfig_live_site);
$tmpl->addVar("emailcomment", 'template', $mainframe->getTemplate());

$tmpl->addVar("emailcomment", 'contenttitle', getContentTitle($row->contentid));
$tmpl->addVar("emailcomment", 'linktocontent', $mosConfig_live_site.'/index.php?option=com_content&task=view&Itemid=1&id='.$row->contentid);

$tmpl->parseTemplate("emailcomment");
$message = $tmpl->getParsedTemplate("emailcomment");

// SEND Email to admins
if ($maxConfig->alert_admin == 1) {
$database->setQuery( "SELECT name, email FROM #__users"
."\n WHERE LOWER(usertype)='superadministrator' OR LOWER(usertype)='super administrator'" );
$rows = $database->loadObjectList();
foreach ($rows as $row){
$adminName = $row->name;
$adminEmail = $row->email;
mosMail($adminEmail, $adminName, $adminEmail, $subject, $message,1);
}
}

// Send emails to subscribed Users
if ($maxConfig->alert_users == 1) {
$database->SetQuery("SELECT email from #__combomax WHERE subscribe = 1 AND contentid = ".$_contentid);
$rows = $database->loadobjectlist();

foreach ($rows as $row){
mosMail($adminEmail,$adminName,$row->email,$subject,$message,1);
}
}

//record vote
$user_rating = mosGetParam($_REQUEST,'user_rating',null);
if ($user_rating){
comment_recordVote($user_rating,$_contentid,$database);
}
mosRedirect(sefRelToAbs('index.php?option=com_content&task=view&id='.$_contentid.'#read-comments'),'Comment Saved');

}

function reportComment($database){

$commentid = mosGetParam($_REQUEST,'commentid','');

$tmpl = new patTemplate();
$tmpl->setBasedir("components/com_combomax/templates/");
$tmpl->setNameSpace('pxt');
$tmpl->readTemplatesFromFile("showcomment.tpl");

$database->SetQuery("SELECT * from #__combomax WHERE id ='".$commentid."'");
$rows = $database->loadObjectList();
$row = $rows[0];

$tmpl->addVar("showcomment", "NAME", stripslashes(stripslashes($row->name)));
$tmpl->addVar("showcomment", 'email', stripslashes($row->email));
$tmpl->addVar("showcomment", 'url', stripslashes($row->url));
$tmpl->addVar("showcomment", 'comment', smile::smileReplace(stripslashes(stripslashes($row->comment))));
$tmpl->addVar("showcomment", 'ip', stripslashes($row->ip));
$tmpl->addVar("showcomment", 'browser', stripslashes($row->browser));
$tmpl->addVar("showcomment", 'date', stripslashes($row->date));
$tmpl->addVar("showcomment", 'reporturl', 'index.php?option=com_combomax&page=reportComment&commentid='.$row->id.'');

$tmpl->parseTemplate("showcomment");
$commentHTML = $tmpl->getParsedTemplate("showcomment");

$tmpl->readTemplatesFromFile("reportcomment.tpl");
$tmpl->addVar("reportcomment", 'comment_to_report', $commentHTML);
$tmpl->addVar("reportcomment", 'commentid', $commentid);
$tmpl->displayParsedTemplate("reportcomment");
}

function sendreport($database, $tmpl){

global $maxLanguage, $mosConfig_live_site, $mainframe;

$subject = $maxLanguage->EMAIL_SUBJECT_REPORTED_COMMENT;

$commentid = mosGetParam($_REQUEST,'commentid','');

$row = new mosComment($database);
$row->load($commentid);

$tmpl = new patTemplate();
$tmpl->setBasedir("components/com_combomax/templates/");
$tmpl->setNameSpace('pxt');
$tmpl->readTemplatesFromFile("reportcomment.tpl");
$tmpl->addVar("reportcommentemail", "NAME", stripslashes(stripslashes($row->name)));
$tmpl->addVar("reportcommentemail", 'email', stripslashes($row->email));
$tmpl->addVar("reportcommentemail", 'url', stripslashes($row->url));
$tmpl->addVar("reportcommentemail", 'comment', smile::smileReplace(stripslashes(stripslashes($row->comment))));
$tmpl->addVar("reportcommentemail", 'ip', stripslashes($row->ip));
$tmpl->addVar("reportcommentemail", 'browser', stripslashes($row->browser));
$tmpl->addVar("reportcommentemail", 'date', stripslashes($row->date));
$tmpl->addVar("reportcommentemail", 'reporturl', 'index.php?option=com_combomax&page=reportComment&commentid='.$row->id.'');

$tmpl->addVar("reportcommentemail", 'livesite', $mosConfig_live_site);
$tmpl->addVar("reportcommentemail", 'template', $mainframe->getTemplate());

$tmpl->addVar("reportcommentemail", 'contenttitle', getContentTitle($row->contentid));
$tmpl->addVar("reportcommentemail", 'linktocontent', $mosConfig_live_site.'/index.php?option=com_content&task=view&Itemid=1&id='.$row->contentid);

$tmpl->addVar("reportcommentemail", 'reportersname', mosGetParam($_REQUEST,'name',''));
$tmpl->addVar("reportcommentemail", 'reportersemail', mosGetParam($_REQUEST,'email',''));
$tmpl->addVar("reportcommentemail", 'reportersreason', mosGetParam($_REQUEST,'reason',''));

$tmpl->parseTemplate("reportcommentemail");
$message = $tmpl->getParsedTemplate("reportcommentemail");

// SEND Email to admins
$database->setQuery( "SELECT name, email FROM #__users"
."\n WHERE usertype='superadministrator' OR usertype='Super Administrator' " );
$rows = $database->loadObjectList();
foreach ($rows as $row){
$adminName = $row->name;
$adminEmail = $row->email;
mosMail(mosGetParam($_REQUEST,'email',''), mosGetParam($_REQUEST,'name',''), $adminEmail, $subject, $message,1);
}

//Tag comment as reported
$row = new mosComment($database);
$row->load($commentid);
$row->reported = 1;
$row->store();

$tmpl->parseTemplate("thankyou");
$tmpl->displayParsedTemplate("thankyou");
}
?>

this code says 2003-04-05 07:34
how to solve this problem.
how to year-date-time get server in this code.
please help me

 

tomda




msg:3155961
 8:28 am on Nov 14, 2006 (gmt 0)

$d = date( "Y-m-d H:i:s" );
$d = mosFormatDate( $d, '%Y-%m-%d %H:%M:%S', -$mosConfig_offset * 60 * 60 );

The first line is the format of the date that you want to use (year-month-day)

The second line is calling a function (mosFormatDate) that adjust the time (either local server time either local user time). Just look for this function, my guess is that it takes the UCT time - using gmdate() - and adjust the time (by removing/adding hours).

PS. No need to post such long post!

winpeace




msg:3155967
 8:38 am on Nov 14, 2006 (gmt 0)

thank you
but I don't understand because I am student in php
Can you fix this code for me please

winpeace




msg:3155993
 9:25 am on Nov 14, 2006 (gmt 0)

I remove mosformat date and add this code;
$zone=3600*3//TURKEY
$d = date( "Y-m-d H:i:s" );
$d = gmdate( $d, "D M Y H:i", time() + $zone);

but this error comes:
Parse error: parse error, unexpected T_VARIABLE in /home/content/m/e/l/melgulg/html/components/com_combomax/combomax.php on line 93

dragonthoughts




msg:3156002
 9:39 am on Nov 14, 2006 (gmt 0)

you've missed a semicolon to end the
$zone=.. line
winpeace




msg:3156003
 9:40 am on Nov 14, 2006 (gmt 0)

$zone=3600*3//TURKEY line
like this?

and line 93 this ---> $d = date( "Y-m-d H:i:s" );

barns101




msg:3156054
 11:10 am on Nov 14, 2006 (gmt 0)

Like this:


$zone = 3600*3; //TURKEY
$d = date( "Y-m-d H:i:s" );
$d = gmdate( $d, "D M Y H:i", time() + $zone);

Global Options:
 top home search open messages active posts  
 

Home / Forums Index / Code, Content, and Presentation / PHP Server Side Scripting
rss feed

All trademarks and copyrights held by respective owners. Member comments are owned by the poster.
Home ¦ Free Tools ¦ Terms of Service ¦ Privacy Policy ¦ Report Problem ¦ About ¦ Library ¦ Newsletter
WebmasterWorld is a Developer Shed Community owned by Jim Boykin.
© Webmaster World 1996-2014 all rights reserved