Code Search for Developers
 
 
  

class.old.php from ECP (EliteCore Project) at Krugle


Show class.old.php syntax highlighted

<?php
class module_comments extends module_class {
	const NEWEST_FIRST = 1;
	const OLDEST_FIRST = 2;
	const APPROVED = 1;
	const NOT_APPROVED = 0;
	public function addComment($id,$base,$instance, $comment, $user_id, $name, $email, $website) {
		global $XCS;
		$TA = new TA();
		$TA->addQuery(TA :: SELECT, "xcs_module_comments_settings");
		$TA->addParam("value");
		$TA->WHERE("name='approve'");
		$TA->LIMIT(1);
		$TA->Execute();
		$object = $TA->Result()->FetchObject();
		$TA->removeQuery();
		$approve = $object->value;
		$ip = $_SERVER['REMOTE_ADDR'];
		$host = gethostbyaddr($ip);
		$date=Date :: NOW();
		if (!empty($website) && strpos($website,"http://") === false) $website = "http://".$website;
		if (strlen($website)<10) $website="";
			$TA->addQuery(TA :: INSERT, "xcs_module_comments");
			$TA->addParam("text", TA :: STRING, $comment);
			$TA->addParam("user_id", TA :: NUMBER, $user_id);
			$TA->addParam("name", TA :: STRING, $name);
			$TA->addParam("email", TA :: STRING, $email);
			$TA->addParam("website", TA :: STRING, $website);
			$TA->addParam("time", TA :: STRING, $date);
			$TA->addParam("host", TA :: STRING, $host);
			$TA->addParam("ip", TA :: STRING, $ip);
			$TA->addParam("base", TA :: STRING, $base);
			$TA->addParam("instance", TA :: STRING, $instance);
			$TA->addParam("object", TA :: NUMBER, $id);
			if ($XCS->isRude($comment))
				$TA->addParam("approved", TA :: NUMBER, 0);
			else {
				if ($approve == 0 || $base == 'shoutbox') $approved=1;
				else $approved=0;
				$TA->addParam("approved", TA :: NUMBER, $approved);
			}
			$TA->Execute();
		$TA->End();
		return $date;
	}
	public function getComment($id) {
		$TA = new TA();
		$TA->addQuery(TA :: SELECT, "xcs_module_comments");
		$TA->ORDER("id", TA :: DESCENDING);
		$TA->WHERE("`approved`='1' AND `id`='".$id."'");
		$TA->Execute();
		$object = $TA->Result()->FetchObject();
		if (!$object) return false;

		$object->email = String :: parseEmail($object->email);

		return $object;
	}
	public function readComments($object_id, $base, $instance, $order = module_comments :: OLDEST_FIRST, $limit = 0) {
		$TA = new TA();
		$TA->addQuery(TA :: SELECT, "xcs_module_comments");
		$TA->ORDER("id", TA :: DESCENDING);
		if (Session :: isValid() && User :: isAuthor()) {
			$TA->WHERE("`object`='".$object_id."' AND `base`='".$base."' AND `instance`='".$instance."'");
		}
		else {
			$TA->WHERE("`approved`='1' AND `object`='".$object_id."' AND `base`='".$base."' AND `instance`='".$instance."'");
		}
		$TA->LIMIT($limit);
		$TA->Execute();
		$retval = array ();
		while ($object = $TA->Result()->FetchObject()) {
			$object->email = String :: parseEmail($object->email);
			$retval[] = $object;
		}
		$TA->End();
		if ($order == module_comments :: OLDEST_FIRST) {
			$retval = array_reverse($retval);
		}
		return $retval;
	}
	public function numComments($id, $base, $instance, $approved=module_comments::APPROVED) {
		$TA = new TA();
		$TA->addQuery(TA :: SELECT, "xcs_module_comments");
		$TA->addParam("id");
		$TA->WHERE("`approved`='".(int)$approved."' AND `object`='".$id."' AND `base`='".$base."' AND `instance`='".$instance."'");
		$TA->Execute();
		$num = $TA->Result()->NumRows();
		$TA->End();
		return $num;
	}
	public function getNotApprovedComments() {
		global $XCS;
		$TA = new TA();
		$TA->addQuery(TA :: SELECT, "xcs_module_comments");
		$TA->WHERE("`approved`='".(int)module_comments::NOT_APPROVED."'");
		$TA->Execute();
		$comments = array();
		while ($object = $TA->Result()->FetchObject()) {
			$object->module = $XCS->getModuleNick($object->instance);
			$comments[] = $object;
		}
		$TA->End();
		return $comments;
	}
	public function getNotApprovedCommentsNum() {
		$TA = new TA();
		$TA->addQuery(TA :: SELECT, "xcs_module_comments");
		$TA->addParam("id");
		$TA->WHERE("`approved`='".(int)module_comments::NOT_APPROVED."'");
		$TA->Execute();
		$num = $TA->Result()->NumRows();
		$TA->End();
		return $num;
	}
	public function showAllComments($instance,$article) {
		Engine :: VerifyUser(); // Verify User (spambot protection)
		$tab = new TinyAjaxBehavior(true);
		$comments = $this->readComments($article,'articles',$instance);
		foreach ($comments as $comment) {
			$tab->add(TabInnerHtml :: getBehavior('comment_id_'.$comment->id, $comment->text));
		}
		return $tab->getString();
	}
	public function showComment($id) {
		Engine :: VerifyUser(); // Verify User (spambot protection)
		$comment = $this->getComment($id);
		if ($comment) {
			Ajax::Action(TabInnerHtml :: getBehavior('comment_id_'.$id, $comment->text));
		}
		return Ajax::ReturnValue(true);
	}
	public function sendComment($formData) {
		Engine :: VerifyUser(); // Verify User (spambot protection)
		$formData = Ajax::getPostData($formData);
		$date=$this->addComment($formData['id'],$formData['base'],$formData['instance'], $formData['text'], $formData['user_id'], $formData['name'], $formData['email'], $formData['website']);
		Ajax::Action(TabCallFunction :: getBehavior('commentAdded', Date::format($date)));
		return Ajax::ReturnValue(true);
	}
	public function showForm($id,$currentModule) {
		global $ECP;
		$cssid="_default";
		require ("modules/comments/templates/default/form.php");
	}
	public function showAdmin($comment) {
		global $XCS;
		if (Session :: isValid() && User :: isAuthor()) {
			require ("modules/comments/templates/default/admin.php");
		}
	}
}
Ajax :: Export('comments->showAllComments', array('instance','article'));
Ajax :: Export('comments->showComment', array('id'));
Ajax :: Export('comments->sendComment','newCommentForm');
?>



See more files for this project here

ECP (EliteCore Project)

EliteCore Project is a PHP5.1/Javascript/AJAX/XHTML/CSS framework for creating WEB 2.0 applications and services.The basic open-source instalation can be also used as an interactive personal page or BLOG.This project uses the latest features available.

Project homepage: http://sourceforge.net/projects/elitecore
Programming language(s): JavaScript,PHP,XML
License: cpl

  language/
    czech.xml
    english.xml
  templates/
    default/
      images/
        0.png
        1.png
        delete.png
      admin.php
      content.php
      content_admin.php
      form.php
  admin.old.php
  class.old.php
  config.xml
  install.sql.tpl
  module.old.php
  subroutines.php
  uninstall.sql.tpl