예제 #1
0
	function getJsonTags(){
		if ( (empty($this->idchannel) || $this->idchannel<=0) ) {
			if (isset($_GET['channel']) && !empty($_GET['channel'])) { 
				require_once("class/Channel.php");
				$tmp = new Channel(); $tmp->setUrlname($_GET['channel']);
				$this->idchannel=$tmp->getId();
				if (empty($this->idchannel)) $this->idchannel=-1;
			}
		}
		if ($this->listType=='cloneUFLast')
			$query = Topic::cloneUFLast($this->qtd, $this->lastorderid, $this->idchannel);
		elseif ($this->listType=='cloneFollowed')
			$query = Topic::cloneFollowed($this->qtd, $this->lastorderid, $this->idchannel);
		elseif ($this->listType=='cloneSearch')
			$query = Topic::cloneSearch($this->search, $this->qtd, $this->orderid);
		elseif ($this->listType=='cloneUpdated')
			$query = Topic::cloneUpdated($this->ids, $this->counters, $this->qtd, $this->orderid, $this->idchannel);
		elseif ($this->listType=='cloneNew')
			$query = Topic::cloneNew($this->lastid, $this->qtd, $this->orderid, $this->idchannel);
		elseif ($this->listType=='cloneByUser')
			$query = Topic::cloneByUser($this->user, $this->qtd, $this->orderid, $this->sorting, $this->idchannel);
		elseif ($this->listType=='cloneByUserPost')
			$query = Topic::cloneByUserPost($this->user, $this->qtd, $this->orderid, $this->sorting, $this->idchannel);
		elseif ($this->listType=='cloneByDate')
			$query = Topic::cloneByDate($this->user, $this->year, $this->month, $this->day);
		elseif ($this->listType=='cloneChannelFollowed')
			$query = Topic::cloneChannelFollowed($this->qtd, $this->orderid, $this->lastorderid, $this->sorting);
		else
			$query = Topic::cloneLast($this->qtd, $this->orderid, $this->sorting, $this->idchannel);

		$result = array();

		if ($query!=null){
			global $CONF;
			if ($this->with_posts){
				require_once('template/TListPost.php');
				foreach ($query as $topic){
					$tlistpost = new TListPost(); $tlistpost->setTopic($topic);
					$ttopic = new TTopic(); $ttopic->setTopic($topic);
					array_push($result, array('topic'=>$ttopic->getJsonTags(), "posts"=>$tlistpost->getJsonTags()) );
				}
			} else {
				foreach ($query as $topic){
					$tmp=$topic->getJsonTags();
					if ($this->onlysubsumed)
						unset($tmp['msg']);
					array_push($result, $tmp);
				}
			}
		}

		return $result;
	}
예제 #2
0
	public function save(){		//Salva o objeto no BD (se ja foi salvo faz update)
		$this->_new=false;
		$db = clone $GLOBALS['maindb'];

		if (empty($this->subject))
			return 'error null subject';
		
		if (empty($this->msg))
			return 'error null message';
		$isanon=$this->getUser()->isAnon();
		if (!($isanon))
			$isanon = 'FALSE';
		else
			$isanon = 'TRUE';

		if (!isset($this->id) || ($this->id==null)){	//Insert
			$db->query("SELECT nextval('topic_id_seq') as id;");
			$_gotid_req = $db->fetch();
			$_gotid = $_gotid_req['id'];
			$lang = $this->getLang();
			if (empty($lang)){
				$this->lang = $this->getUser()->getLang();
			}
			if (!empty($this->channel))
				$_channelid=$this->channel->getId();
			elseif (isset($_GET['channel'])){
				require_once('class/Channel.php');
				$tmpchannel=new Channel();
				$tmpchannel->setUrlname($_GET['channel']);
				$tmpchannel->load();
				$_channelid = $tmpchannel->getId();
			} else 
				$_channelid = 'null';
			if (empty($_channelid)) $_channelid = 'null';

			$db->query("INSERT INTO topic(id,subject,msg,anon,userid,lang, channelid) VALUES('{$_gotid}','{$this->getSubject()}','{$this->getMsg()}','$isanon', '{$this->getUser()->getId()}', '{$this->getLang()}', {$_channelid});");
			$row = $db->fetch();
			$this->id = $_gotid;
		} else {					//Update
			$_alsoupdate='';
			if ($this->_update_subject==true) $_alsoupdate.=",subject='{$this->getSubject()}'";
			$db->query("UPDATE topic set msg='{$this->getMsg()}',anon='$isanon', userid='{$this->getUser()->getId()}' {$_alsoupdate} WHERE id='{$this->id}';");
			$row = $db->fetch();
		}
		$this->_flush=true;
		return "ok";
	}
예제 #3
0
function add_channel()
{
	global $CONF;
	global $LANGALL;
	$user = $_SESSION['user'];

	if ($user->getBanned()>0){
		return array('ok'=>false, 'error'=>'banned '.$user->getBanned());
	}

	if (isset($_SESSION['channel_last_flood_time'])){

		if ((time() - $_SESSION['channel_last_flood_time']) < $CONF['channel_time_to_wait_flood']){
			$time_to_wait = $CONF['channel_time_to_wait_flood'] - (time() - $_SESSION['channel_last_flood_time']);
			//return array('ok'=>false, 'error'=>'flood '.$time_to_wait);
		}

	}

	$_SESSION['channel_last_flood_time']=time();

	$user = $_SESSION['user'];	
	if ($user->isAnon())
		return array('ok'=>false, 'error'=>'anonymous cannot create channel');

	$channel = new Channel();
	$channel->setUser($user);

	$name = strip_tags($_POST['name']);
	if (strlen(str_replace(' ', '', $name)) < $CONF['channel_min_name'])
		return array('ok'=>false, 'error'=>'too short name');
	$channel->setName($name);

	$description = $_POST['description'];
	$description = strip_tags($description, $CONF['permitted_tags_msg']);
	$description = text_linkify($description);
	$description = str_replace('&nbsp;',' ',$description);
	$channel->setDescription($description);

	if (isset($_POST['lang']) && !empty($_POST['lang']))
		$channel->setLang($_POST['lang']);

	if (!isset($_POST['urlname']))
		$channel->setUrlname( Channel::prettyUrlAvailable($_POST['name']) );
	else {
		if ($_POST['urlname']!=Channel::prettyUrlAvailable($_POST['urlname']))
			return array('ok'=>false, 'error'=>'invalid urlname');
		else
			$channel->setUrlname($_POST['urlname']);
	}

	if (isset($_POST['asktofollow'])) $channel->setAsktofollow($_POST['asktofollow']);
	if (isset($_POST['perm_member'])) $channel->setPermMember($_POST['perm_member']);
	if (isset($_POST['perm_reguser'])) $channel->setPermReguser($_POST['perm_reguser']);
	if (isset($_POST['perm_anon'])) $channel->setPermAnon($_POST['perm_anon']);

	$result=$channel->save();
	if ($result=='ok'){
		$channel->follow();

		/*if ($channel->getLang()=='pt_br'){
			$title=$LANGALL['pt_br']['addchannel_welcome_title'];
			$message=$LANGALL['pt_br']['addchannel_welcome_message'];
		} else {
			$title=$LANGALL['en_us']['addchannel_welcome_title'];
			$message=$LANGALL['en_us']['addchannel_welcome_message'];
		}
		require_once('class/Topic.php');
		require_once('class/User.php');
		$user=new RegUser();
		$user->setId(1);
		$topic=new Topic();
		$topic->setSubject($title);
		$topic->setMsg($message);
		$topic->setChannel($channel);
		$topic->setUser($user);
		$topic->save();*/
		
		return array('ok'=>true, 'error'=>'', 'id'=>$channel->getId());
	}
	elseif ($result=='error channel already exists'){
		return array('ok'=>false, 'error'=>'error channel already exists','id'=>null);
	} elseif ($result=='error you created many channels'){
		return array('ok'=>false, 'error'=>'error you created many channels','id'=>null);
	} elseif ($result=='error user anon'){
		return array('ok'=>false, 'error'=>'error user anon','id'=>null);
	} else
		return array('ok'=>false, 'error'=>'problems with this channel - '.$result,'id'=>null);
}
예제 #4
0
<?php
	require_once('conf/location.php');
	require_once('conf/session.php');
	require_once("class/User.php");
	require_once("class/Channel.php");

	//require_once("class/Addthis.php");

	global $CONF;

	$user=$_SESSION['user'];	

	if (isset($_GET['urlname']))
	{
		$channel = new Channel();
		$channel->setUrlname($_GET['urlname']);
		$channel->load();


		if ($channel->getId()>0)
		{
			$OG['request'] = 'openchannel';
			$OG['channel_name'] = $channel->getName();
			$OG['channel_desc'] = $channel->getDescription();
			$OG['channel_logo'] = $CONF['url_path'] . $channel->getLogoFile('big');

			if (isset($_GET['sms_ss'])){
				$db = clone $GLOBALS['maindb'];
				$_anon=($user->isAnon())?'true':'false';
				$db->query("INSERT INTO addthis(channelid,sms_ss,at_xt,userid,anon,ip) values ('{$channel->getId()}','".$_GET['sms_ss']."','".$_GET['at_xt']."','{$user->getId()}','{$_anon}','".$_SERVER['REMOTE_ADDR']."');");
			}
예제 #5
0
function engine_doit(){
	global $CONF;
	$whats = explode(',', $_GET['what']);
	$result = null;

	if (isset($_GET['SYSTEM_redirect'])){
		unset($_GET['SYSTEM_redirect']);
		switch($_GET['what']){
			case 'topic':
				include('basichtml/viewtopic.php');
				break;
			case 'datetopics':
				include('basichtml/topic_list.php');
				break;
			case 'confirm_user':
				include('controller/confirm_user.php');
				break;
			case 'user_stopmail':
				include('controller/user_stopmail.php');
				break;
			case 'add_email':
				include('controller/add_email.php');
				break;
			case 'remove_email':
				include('controller/remove_email.php');
				break;
			case 'restore_password':
				include('controller/restore_password.php');
				break;
			case 'followchannel_acceptreject':
				include('controller/followchannel_acceptreject.php');
				break;
			case 'autoopenchannel':
				include('controller/autoopenchannel.php');
				break;
			case 'autoopentopic':
				include('controller/autoopentopic.php');
				break;
/*			case 'ETUEngine':
				include('tool/ETUEngine.php');
				$etu=new ETUEngine();
				$etu->start(1);
				break;
*/

		}
		return;
	} 
	foreach ($whats as $what)
	{
		switch($what)
		{
			case 'fromname':
				require_once("controller/fromname.php");
				$result['fromname'] = fromname($_GET['id_fromname']);
				break;
			case 'setuserfrom':
				require_once("class/User.php");
				$tuser = new RegUser();
				$tuser->setNickname($_GET['nick_setuserfrom']);
				$valid = $tuser->validatePassword($_GET['pass_setuserfrom']);
				if ($valid)
				{
					$tuser->load();
					$tuser->setCameFrom($_GET['fromid_setuserfrom']);
					$tuser->save();
				}
				break;
			case 'message':
				require_once('template/TMessage.php');
				require_once('class/Message.php');
				$message = new Message(); 
				if (isset($_GET['id_message']) && !empty($_GET['id_message']))
					$message->setId($_GET['id_message']);
				else { $result['message']=array(); break; }
				$tmessage = new TMessage(); $tmessage->setMessage($message);
				$result['message']=$tmessage->getJsonTags();
				break;
			case 'mymessages':
				require_once('template/TListMessage.php');
				$tlist = new TListMessage();	$tlist->setListType("cloneMy"); $tlist->setOnlySubsumed(true);
				if (isset($_GET['sorting_mymessages'])) $tlist->setSorting($_GET['sorting_mymessages']);
				if (isset($_GET['lastid_mymessages'])) $tlist->setLastId($_GET['lastid_mymessages']);
				$result['mymessages']=$tlist->getJsonTags();
				break;
			case 'regchannel':
				require_once("template/TChannel.php");
				require_once("class/Channel.php");
				$t = new TChannel();
				$o=new Channel();
				$prettyUrl='';
				if (isset($_GET['id_regchannel'])) {
					$o->setId($_GET['id_regchannel']);
				} elseif (isset($_GET['name_regchannel'])) {
					if (substr($_GET['name_regchannel'],-1,1)=='-'){
						$result['regchannel']=array("ok"=>false,"error"=>"invalid name","exist"=>true,'prettyUrl'=>'');
						break;
					} else {
						$o->setName($_GET['name_regchannel']);
						$prettyUrl=Channel::prettyUrlAvailable($_GET['name_regchannel']);
					}
				} elseif (isset($_GET['urlname_regchannel'])) {
					if ($_GET['urlname_regchannel'] != Channel::prettyUrl($_GET['urlname_regchannel'])){
						$result['regchannel']=array("ok"=>false,"error"=>"invalid url","exist"=>true, 'prettyUrl'=>'');
						break;
					}
					$o->setUrlname($_GET['urlname_regchannel']);
					$prettyUrl=$_GET['urlname_regchannel'];
				} else {
					$result['regchannel']=array("ok"=>false,"error"=>"no param", "exist"=>true, 'prettyUrl'=>'');
					break;
				}
				$t->setChannel($o);
				$r=$t->getJsonTags();
				if ($r['id']==null || $r['name']==null || $r['lang']==null)
					$result['regchannel']=array("ok"=>true,"error"=>"","exist"=>false,'prettyUrl'=>$prettyUrl);
				else
					$result['regchannel']=array("ok"=>true,"error"=>"","exist"=>true,'prettyUrl'=>$r['urlname']);
				break;
			case 'channels':
				require_once('template/TListChannel.php');
				$tlist = new TListChannel();	$tlist->setListType("cloneAll"); $tlist->setOnlySubsumed(true);
				if (isset($_GET['sorting_channels'])) $tlist->setSorting($_GET['sorting_channels']);
				$result['channels']=$tlist->getJsonTags();
				break;
			case 'followedchannels':
				require_once('template/TListChannel.php');
				$tlist = new TListChannel();
				if ($_SESSION['user']->isAnon())
					$tlist->setListType("cloneAll");
				else
					$tlist->setListType("cloneFollowed"); 
				$tlist->setOnlySubsumed(true);
				if (isset($_GET['sorting_followedchannels'])) $tlist->setSorting($_GET['sorting_followedchannels']);
				$result['followedchannels']=$tlist->getJsonTags();
				break;
			case 'mychannels':
				require_once('template/TListChannel.php');
				$tlist = new TListChannel();	$tlist->setListType("cloneMy"); $tlist->setOnlySubsumed(false);
				if (isset($_GET['sorting_mychannels'])) $tlist->setSorting($_GET['sorting_mychannels']);
				$result['mychannels']=$tlist->getJsonTags();
				break;
			case 'mostvisitedchannels':
				require_once('template/TListChannel.php');
				$tlist = new TListChannel();	$tlist->setListType("cloneMostVisited"); $tlist->setOnlySubsumed(false);
				if (isset($_GET['qtd_mostvisitedchannels'])) $tlist->setQtd($_GET['qtd_mostvisitedchannels']);
				if (isset($_GET['signed_mostvisitedchannels'])) $tlist->setSigned($_GET['signed_mostvisitedchannels']);
				$result['mostvisitedchannels']=$tlist->getJsonTags();
				break;
			case 'recommendedchannels':
				require_once('template/TListChannel.php');
				$tlist = new TListChannel();	$tlist->setListType("cloneRecommended"); $tlist->setOnlySubsumed(false);
				if (isset($_GET['qtd_recommendedchannels'])) $tlist->setQtd($_GET['qtd_recommendedchannels']);
				$result['recommendedchannels']=$tlist->getJsonTags();
				break;
			case 'channel':
				require_once('template/TChannel.php');
				require_once('class/Channel.php');
				$channel = new Channel(); 
				if (isset($_GET['id_channel']) && !empty($_GET['id_channel']))
					$channel->setId($_GET['id_channel']);
				elseif (isset($_GET['name_channel']) && !empty($_GET['name_channel'])) 
					$channel->setName($_GET['name_channel']);
				else { $result['channel']=array(); break; }
				$tchannel = new TChannel(); $tchannel->setChannel($channel);
				$result['channel']=(array('channel'=>$tchannel->getJsonTags(), "topics"=>array() ));
				break;
			case 'followedchanneltopics':
				require_once('template/TListTopic.php');
				$tlisttopic = new TListTopic();	$tlisttopic->setListType("cloneChannelFollowed"); $tlisttopic->setOnlySubsumed(true);
				if (isset($_GET['orderid_followedchanneltopics'])) $tlisttopic->setOrderId($_GET['orderid_followedchanneltopics']);
				if (isset($_GET['lastorderid_followedchanneltopics'])) $tlisttopic->setLastOrderId($_GET['lastorderid_followedchanneltopics']);
				if (isset($_GET['sorting_followedchanneltopics'])) $tlisttopic->setSorting($_GET['sorting_followedchanneltopics']);
				if (isset($_GET['qtd_followedchanneltopics'])) $tlisttopic->setQtd($_GET['qtd_followedchanneltopics']);
				$result['followedchanneltopics']=$tlisttopic->getJsonTags();
				break;
			case 'recenttopics':
				require_once('getter/recenttopics.php');
				$result['recenttopics']=recenttopics();
				break;
			case 'datetopics':
				require_once('template/TListTopic.php');
				if (!isset($_GET['year_datetopics'])) {
					$result['datetopics']=array();
					break;
				}
				$tlisttopic = new TListTopic();	$tlisttopic->setListType("cloneByDate"); $tlisttopic->setOnlySubsumed(true);
				$tlisttopic->setYear($_GET['year_datetopics']);
				if (isset($_GET['month_datetopics'])) $tlisttopic->setMonth($_GET['month_datetopics']);
				if (isset($_GET['day_datetopics'])) $tlisttopic->setDay($_GET['day_datetopics']);
				$result['datetopics']=$tlisttopic->getJsonTags();
				break;
			case 'searchtopics':
				require_once('template/TListTopic.php');
				require_once('tool/SearchTopic.php');
				if (isset($_GET['words_searchtopics'])){
					$tlisttopic = new TListTopic();	$tlisttopic->setListType("cloneSearch"); $tlisttopic->setOnlySubsumed(true);
					$tlisttopic->setSearch(SearchTopic::getQuery($_GET['words_searchtopics']));
					if (isset($_GET['orderid_searchtopics'])) $tlisttopic->setOrderId($_GET['orderid_searchtopics']);
					$result['searchtopics']=$tlisttopic->getJsonTags();
				} else $result['searchtopics']=array("ok"=>false,"error"=>"no words");
				break;
			case 'searchmain':
				require_once('template/TListChannel.php');
				require_once('tool/SearchEngine.php');
				if (isset($_GET['words_searchmain'])){
					$tlisttopic = new TListChannel(); $tlisttopic->setListType("cloneSearch"); $tlisttopic->setOnlySubsumed(true);
					$tlisttopic->setSearch(SearchEngine::getQueryChannels(unescape_ampersand($_GET['words_searchmain'])));
					//if (isset($_GET['orderid_searchtopics'])) $tlisttopic->setOrderId($_GET['orderid_searchtopics']);
					$result['searchmain']['channels']=$tlisttopic->getJsonTags();
				} else $result['searchmain']=array("ok"=>false,"error"=>"no words");
				break;
			case 'usertopics':
				require_once('template/TListTopic.php');
				require_once('class/User.php');
				if (isset($_GET['nickname_usertopics'])){
					$tlisttopic = new TListTopic();	$tlisttopic->setListType("cloneByUser"); $tlisttopic->setOnlySubsumed(true);
					if (isset($_GET['sorting_usertopics'])) $tlisttopic->setSorting($_GET['sorting_usertopics']);
					$u=new RegUser();
					$u->setNickname($_GET['nickname_usertopics']); $u->load();
					$tlisttopic->setUser($u);
					if (isset($_GET['orderid_usertopics'])) $tlisttopic->setOrderId($_GET['orderid_usertopics']);
					if (isset($_GET['idchannel_usertopics'])) $tlisttopic->setIdChannel($_GET['idchannel_usertopics']);
					$result['usertopics']=$tlisttopic->getJsonTags();
				} else $result['usertopics']=array();
				break;
			case 'userposttopics':
				require_once('template/TListTopic.php');
				require_once('class/User.php');
				if (isset($_GET['nickname_userposttopics'])){
					$tlisttopic = new TListTopic();	$tlisttopic->setListType("cloneByUserPost"); $tlisttopic->setOnlySubsumed(true);
					if (isset($_GET['sorting_userposttopics'])) $tlisttopic->setSorting($_GET['sorting_userposttopics']);
					$u=new RegUser();
					$u->setNickname($_GET['nickname_userposttopics']); $u->load();
					$tlisttopic->setUser($u);
					if (isset($_GET['orderid_userposttopics'])) $tlisttopic->setOrderId($_GET['orderid_userposttopics']);
					if (isset($_GET['idchannel_userposttopics'])) $tlisttopic->setIdChannel($_GET['idchannel_userposttopics']);
					$result['userposttopics']=$tlisttopic->getJsonTags();
				} else $result['userposttopics']=array();
				break;
			case 'uft':
				require_once('getter/uft.php');
				$result['uft']=uft();
				break;
			case 'followedtopics':
				require_once('conf/session.php');
				require_once('template/TListTopic.php');
				$tlisttopic = new TListTopic();	$tlisttopic->setListType("cloneFollowed"); $tlisttopic->setOnlySubsumed(true);
				if (isset($_GET['orderid_followedtopics'])) $tlisttopic->setOrderId($_GET['orderid_followedtopics']);
				if (isset($_GET['idchannel_followedtopics'])) $tlisttopic->setIdChannel($_GET['idchannel_followedtopics']);
				$result['followedtopics']=$tlisttopic->getJsonTags() ;
				break;
		
			case 'topic':
				if (!isset($_GET['id_topic']) || empty($_GET['id_topic'])) { $result['topic']=array(); break; }
				require_once('template/TTopic.php');
				require_once('template/TListPost.php');
				require_once('class/Topic.php');
				require_once('class/Channel.php');
				$topic = new Topic(); $topic->setId($_GET['id_topic']);
				if (!$topic->getChannel()->canIRead()){ $result['topic']=array("error"=>'you cant see this topic'); break; }
				$ttopic = new TTopic(); $ttopic->setTopic($topic);
				$tlistpost = new TListPost(); $tlistpost->setTopic($topic);
				$tlistpostbest = new TListPost(); $tlistpostbest->setTopic($topic); $tlistpostbest->setQtd($CONF['post_best_qt']); $tlistpostbest->setSorting("likes desc,date desc");
				$result['topic']=(array('topic'=>$ttopic->getJsonTags(), "posts"=>$tlistpost->getJsonTags(), "bestposts"=>$tlistpostbest->getJsonTags()) );
				break;

			case 'refresh_topic_previews':
				if (!isset($_GET['ids_refresh_topic_previews']) || empty($_GET['ids_refresh_topic_previews'])) { $result['refresh_topic_previews']=array(); break;}
				if (!isset($_GET['versions_refresh_topic_previews']) || empty($_GET['versions_refresh_topic_previews'])) { $result['refresh_topic_previews']=array(); break;}
				require_once("template/TListTopic.php");
				$tlisttopic = new TListTopic();	$tlisttopic->setListType("cloneUpdated"); $tlisttopic->setOnlySubsumed(true);
				$tlisttopic->setIds(explode(",",$_GET['ids_refresh_topic_previews']));
				$tlisttopic->setCounters(explode(",",$_GET['versions_refresh_topic_previews']));
				$result['refresh_topic_previews']=$tlisttopic->getJsonTags();
				break;
			case 'refresh_topics':
				if (!isset($_GET['ids_refresh_topics']) || empty($_GET['ids_refresh_topics'])) { $result['refresh_topics']=array(); break;}
				if (!isset($_GET['versions_refresh_topics']) || empty($_GET['versions_refresh_topics'])){ $result['refresh_topics']=array(); break;}
				require_once("template/TListTopic.php");
				$tlisttopic = new TListTopic();	$tlisttopic->setListType("cloneUpdated"); $tlisttopic->setWithPosts(true);
				if (isset($_GET['idchannel_refresh_topics'])) $tlisttopic->setIdChannel($_GET['idchannel_refresh_topics']);
				$tlisttopic->setIds(explode(",",$_GET['ids_refresh_topics']));
				$tlisttopic->setCounters(explode(",",$_GET['versions_refresh_topics']));
				$result['refresh_topics']=$tlisttopic->getJsonTags();
				break;
			case 'new_topic_previews':
				require_once("getter/new_topic_previews.php");
				$result['new_topic_previews']=new_topic_previews();
				break;
			case 'reguser':
				require_once("template/TUser.php");
				require_once("class/User.php");
				$tuser = new TUser();
				$u=new RegUser();
				if (isset($_GET['id_reguser'])) $u->setId($_GET['id_reguser']);
				elseif (isset($_GET['email_reguser'])) $u->setEmail($_GET['email_reguser']);
				elseif (isset($_GET['nickname_reguser'])) {
					if (substr($_GET['nickname_reguser'],-1,1)=='-'){
						$result['reguser']=array("ok"=>true,"error"=>"","exist"=>true);
						break;
					} else {
						$u->setNickname($_GET['nickname_reguser']);
					}
				} else {
					$result['reguser']=array("ok"=>false,"error"=>"no param");
					break;
				}
				$tuser->setUser($u);
				$r=$tuser->getJsonTags();
				if ($r['id']==null || $r['nickname']==null || $r['lang']==null)
					$result['reguser']=array("ok"=>true,"error"=>"","exist"=>false);
				else
					$result['reguser']=array("ok"=>true,"error"=>"","exist"=>true);
				break;
			case 'userscamefrom':
				require_once('template/TListUser.php');
				$tlist = new TListUser(); $tlist->setListType("cloneLastCameFrom");
				if (isset($_GET['camefrom_userscamefrom']))
					$tlist->setCameFrom($_GET['camefrom_userscamefrom']);
				if (isset($_GET['qtd_userscamefrom']))
					$tlist->setQtd($_GET['qtd_userscamefrom']);
				$result['userscamefrom']=$tlist->getJsonTags();
				break;
			case 'user':
				require_once("template/TUser.php");
				require_once("class/User.php");
				global $user;
				$tuser = new TUser(); 
				if (!isset($_GET['id_user']) || !isset($_GET['anon_user'])){
					$tuser->setUser($user);
					$tuser->setWithEmail(true);
				} else{
					if ($_GET['anon_user']){
						$u = new AnonUser(); $u->setId($_GET['id_user']);
					} else {
						$u = new RegUser(); $u->setId($_GET['id_user']); 
					}
					$tuser->setUser($u);
				}
				$result['user']=$tuser->getJsonTags();	
				break;
			case 'add_topic':
				require_once('controller/add_topic.php');
				$result['add_topic']=add_topic();
				break;
			case 'add_message':
				require_once('controller/add_message.php');
				$result['add_message']=add_message();
				break;
			case 'read_message':
				require_once('controller/read_message.php');
				$result['read_message']=read_message();
				break;
			case 'add_channel':
				require_once('controller/add_channel.php');
				$result['add_channel']=add_channel();
				break;
			case 'add_post':
				require_once('controller/add_post.php');
				$result['add_post']=add_post();
				break;
			case 'update_channel':
				require_once('controller/update_channel.php');
				$result['update_channel']=update_channel();
				break;
			case 'update_topic':
				require_once('controller/update_topic.php');
				$result['update_topic']=update_topic();
				break;
			case 'update_post':
				require_once('controller/update_post.php');
				$result['update_post']=update_post();
				break;
			case 'followtopic':
				require_once('controller/followtopic.php');
				$result['followtopic']=followtopic();
				break;
			case 'unfollowtopic':
				require_once('controller/unfollowtopic.php');
				$result['unfollowtopic']=unfollowtopic();
				break;
			case 'followchannel':
				require_once('controller/followchannel.php');
				$result['followchannel']=followchannel($_GET['channelid_followchannel']);
				break;
			case 'followchannels':
				require_once('controller/followchannel.php');
				$chids=explode(",",$_GET['channelids_followchannels']);
				for ($i=0;$i<count($chids);$i++)
					$result['followchannels'][$i]=followchannel($chids[$i]);
				break;
			case 'unfollowchannel':
				require_once('controller/unfollowchannel.php');
				$result['unfollowchannel']=unfollowchannel();
				break;
			case 'create_account':
				require_once('controller/create_account.php');
				$result['create_account']=create_account();
				break;
			case 'update_user_avatar':
				require_once('controller/update_user_avatar.php');
				$result['update_user_avatar'] = update_user_avatar($_GET['file'],$_GET['x1'],$_GET['y1'],$_GET['x2'],$_GET['y2']);
				break;
			case 'upload_temp_avatar':
				require_once('controller/upload_temp_avatar.php');
				$result['upload_temp_avatar'] = upload_temp_avatar();
				break;
			case 'update_channel_logo':
				require_once('controller/update_channel_logo.php');
				$result['update_channel_logo'] = update_channel_logo($_GET['file'],$_GET['x1'],$_GET['y1'],$_GET['x2'],$_GET['y2']);
				break;
			case 'upload_temp_logo':
				require_once('controller/upload_temp_logo.php');
				$result['upload_temp_logo'] = upload_temp_logo();
				break;
			case 'update_user':
				require_once('controller/update_user.php');
				$result['update_user'] = update_user();
				break;
			case 'change_user_lang':
				require_once('controller/change_user_lang.php');
				$result['change_user_lang']=change_user_lang();
				break;
			case 'like_dislike_this':
				require_once("controller/like_dislike_this.php");
				$result['like_dislike_this'] = like_dislike_this();
				break;
			case 'signin':
				$result['signin'] = signin($_POST['nickname_signin'], $_POST['password_signin'], false, $_POST['staysignedin_signin']);
				break;
			case 'signout':
				require_once("controller/signout.php");
				$result['signout'] = signout();
				break;
			case 'request_restore_password':
				require_once('controller/request_restore_password.php');
				$result['request_restore_password']=request_restore_password();
				break;
			case 'visittopic':
				require_once('class/Topic.php');
				if (!isset($_GET['topicid_visittopic'])) 
					$result['visittopic']=array("ok"=>false,"error"=>"error no id");
				else {
					$topic = new Topic();
					$topic->setId($_GET['topicid_visittopic']);
					if ($topic->visit())
						$result['visittopic']=array("ok"=>true,"error"=>"");
					else
						$result['visittopic']=array("ok"=>false,"error"=>"error db");
				}
				break;
			case 'deletetopic':
				require_once('controller/deletetopic.php');
				$result['deletetopic']=deletetopic();
				break;
			case 'lang':
				require_once('conf/location.php');
				global $LANG;
				$result['lang']=$LANG['JSON'];
				break;
			default:
				break;
		}
	}
	
	return $result;
}
예제 #6
0
	static function prettyUrlAvailable($name)
	{
		require_once('tool/utility.php');
		$url = normalize_chars($name);
		$url = strtolower($url);
		$url = preg_replace('/[^a-zA-Z0-9]/','-',$url);
		$url = preg_replace('/-+/','-',$url);

		$ok=false;
		$url_prefix=$url;
		$cnt=1;
		while ($ok==false){
			$tmpc = new Channel();
			$tmpc->setUrlname($url); $tmpc->load();
			$_id=$tmpc->getId();
			$_lang=$tmpc->getLang();
			if (empty($_id) && empty($_lang))
				$ok=true;
			else
				$url=$url_prefix."_".($cnt);
			$cnt++;
		}
		return $url;
	}