Пример #1
0
 public static function getAll()
 {
     $numChannels = count(static::$channels);
     $insts = array();
     for ($i = 1; $i <= $channels; $i++) {
         $insts[] = Channel::load($i);
     }
     return $insts;
 }
Пример #2
0
function update_channel()
{
	global $user;
	global $CONF;

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

	$user = $_SESSION['user'];	

	$channel = new Channel();
	if (isset($_GET['channelid_update_channel'])){
		$channel->setId($_GET['channelid_update_channel']);
		$channel->load();
		if ( ($user->getId()!=$channel->getUser()->getId()) || ($user->isAnon()) )
			return array('ok'=>false, 'error'=>'you are not the owner');
	} else {
		return array('ok'=>false, 'error'=>'no id');
	}

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

	//system("echo \"$description\" > log.txt");

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

	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']);

	if ($channel->save()=='ok'){
		return array('ok'=>true, 'error'=>'');
	}
	else
		return array('ok'=>false, 'error'=>'problems with this channel');
}
Пример #3
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";
	}
Пример #4
0
	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
	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;
	}