Page 1 of 2 12 LastLast
Results 1 to 10 of 11

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

  1. #1
    Join Date
    Nov 2006
    Posts
    65
    Thanks
    0
    Thanked 0 Times in 0 Posts

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

    Code:
    <?/*
    * $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 
    }
    ?>

    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

  2. #2
    Join Date
    Nov 2006
    Posts
    65
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    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

  3. #3
    Join Date
    Mar 2006
    Location
    Illinois, USA
    Posts
    12,164
    Thanks
    265
    Thanked 690 Times in 678 Posts

    Default

    //TURKEY is a random comment... no idea what it's done there. Remove it. Doesn't hurt... but doesn't do anything.

    What is line 93?
    Daniel - Freelance Web Design | <?php?> | <html>| español | Deutsch | italiano | português | català | un peu de français | some knowledge of several other languages: I can sometimes help translate here on DD | Linguistics Forum

  4. #4
    Join Date
    Nov 2006
    Posts
    65
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

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

  5. #5
    Join Date
    Mar 2006
    Location
    Illinois, USA
    Posts
    12,164
    Thanks
    265
    Thanked 690 Times in 678 Posts

    Default

    Remove //TURKEY and put a semicolon at the end of the line.
    Daniel - Freelance Web Design | <?php?> | <html>| español | Deutsch | italiano | português | català | un peu de français | some knowledge of several other languages: I can sometimes help translate here on DD | Linguistics Forum

  6. #6
    Join Date
    Nov 2006
    Posts
    65
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    what is semicolon.I don't know.I am new php . Please give me an example

  7. #7
    Join Date
    Mar 2006
    Location
    Illinois, USA
    Posts
    12,164
    Thanks
    265
    Thanked 690 Times in 678 Posts

    Default

    ;

    As with almost all programming languages, each line must* end with a semi-colon.

    (*in some language, NOT php, such as Javascript, the semi-colon is optional some of the time.)


    Example:

    a = b; c = d;

    AND

    a = b;
    c = d;

    do the same exact thing... the semi-colon ends the line, not the line break.

    In fact,

    a =
    b;

    is valid... I think.

    However, use the
    a = b;
    c = d;
    format just to stay standard and have your code easy to edit.
    Daniel - Freelance Web Design | <?php?> | <html>| español | Deutsch | italiano | português | català | un peu de français | some knowledge of several other languages: I can sometimes help translate here on DD | Linguistics Forum

  8. #8
    Join Date
    Jun 2005
    Location
    英国
    Posts
    11,876
    Thanks
    1
    Thanked 180 Times in 172 Posts
    Blog Entries
    2

    Default

    There are a few instances where it's prettier to use a linebreak. For example, multiple inline assignments:
    Code:
    $a
      = $b
      = $c
      = $d;
    Or a very long left operand:
    Code:
    $myClass->getThing()->returnSomething()->instances['creature']->getOwner()->name
      = 'John';
    Twey | I understand English | 日本語が分かります | mi jimpe fi le jbobau | mi esperanton komprenas | je comprends français | entiendo español | tôi ít hiểu tiếng Việt | ich verstehe ein bisschen Deutsch | beware XHTML | common coding mistakes | tutorials | various stuff | argh PHP!

  9. #9
    Join Date
    Mar 2006
    Location
    Illinois, USA
    Posts
    12,164
    Thanks
    265
    Thanked 690 Times in 678 Posts

    Default

    Sure, there are exceptions.
    At times, I also toss three or four short commands onto one line, just to save space.

    But... generally... stick to the standards.

    Let's just say... if you don't, then have a reason for doing so.
    Daniel - Freelance Web Design | <?php?> | <html>| español | Deutsch | italiano | português | català | un peu de français | some knowledge of several other languages: I can sometimes help translate here on DD | Linguistics Forum

  10. #10
    Join Date
    Dec 2004
    Location
    UK
    Posts
    2,358
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    Quote Originally Posted by djr33 View Post
    Quote Originally Posted by winpeace View Post
    $zone=3600*3//TURKEY
    //TURKEY is a random comment... no idea what it's done there.
    If I had to guess, I would say that it refers to the country, Turkey, in that 10800 is its offset, in seconds, from GMT.

    I thought Turkey was two hours ahead, myself.

    Mike

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •