Jump to content

Maybe a simple fix.


mynewcar

Recommended Posts

Hi guys,

 

So I'm fairly new to PHP and someone made a script for me a while ago and made me pay up front etc and I'm in the dumps and have a major issue or simple issue, I don't know, I don't want to hire ANOTHER freelancer to drop me in the dumps again and not respond to my emails or anything like that, again.

 

So the issue I'm having here is; I'm receiving this error;

 

"Warning: Declaration of thread::canView($id, $username, $powerLevel) should be compatible with forum::canView($id, $rank) in /*************/structure/forum.thread.php on line 0"

 

In every Forum catagory I made on my test site.

 

This is the full corresponding code in question:

<?php
/*
 * @FORUM:THREAD
 * ~~~~~~~~~~~~
 * @FILE DESCRIPTION: For threads
 * @LAST MODIFIED: June 5, 2012
 */

class thread extends forum
{ 		public function retrieveThreads($start, $per_page, $f) {		return $this->database->processQuery("SELECT `id`,`title`,`username`,`lastpost`,`date`,`lastposter`,`sticky`,`lock`,`hidden`,`moved` FROM `threads` WHERE `parent` = ? ORDER BY `sticky` DESC, `lastpost` DESC LIMIT $start,$per_page", array($f), true);	}
    /*
     * @METHOD  checkExistence
     * @DESC    check if the thread exists
     */
    
    public function checkExistence($id)
    {
        $this->database->processQuery("SELECT * FROM `threads` WHERE `id` = ? LIMIT 1", array($id), false);
        return ($this->database->getRowCount() == 1) ? $x = true : $x = false;
    }
    
    
    /*
     * @METHOD  canView
     * @DESC    checks if the user has permissions to see thread
     */
    
    public function canView($id, $username, $powerLevel)
    {
        //extract thread details
        $thread = $this->database->processQuery("SELECT `parent`,`hidden` FROM `threads` WHERE `id` = ? LIMIT 1", array($id), true);
        
        $canSee = true;

        //get the parent's type
        $parent = $this->database->processQuery("SELECT `type` FROM `forums` WHERE `id` = ? LIMIT 1", array($thread[0]['parent']), true);

        if($parent[0]['type'] > 2)
        {
            //if it's a protected forum, make sure they are the thread owner or staff in order to view
            if($parent[0]['type'] == 3 && ($username != $thread[0]['username'] && $powerLevel < 3)) $canSee = false;
			
            //forum moderator forum, let only moderators view it
            if($parent[0]['type'] == 4 && $powerLevel < 3) $canSee = false;

            //administrator forum, let only administrators see it
            if($parent[0]['type'] == 5 && $powerLevel < 4) $canSee = false;
            
            //member forum, let only members see it
            if($parent[0]['type'] == 6 && !isset($_COOKIE['user'])) $canSee = false;
        }

        //only let staff view hidden threads
        if($thread[0]['hidden'] == 1 && $powerLevel < 3) $canSee = false;
            
        return $canSee;
    }
    
    /*
     * @METHOD  coverThread
     * @DESC    hides the thread (users can still visit, though)
     */
    
    public function coverThread($id, $rank)
    {
        //extract current status of post
        $status = $this->database->processQuery("SELECT `status` FROM `threads` WHERE `id` = ? LIMIT 1", array($id), true);
        
        if($rank > 2) $this->database->processQuery("UPDATE `threads` SET `status` = ? WHERE `id` = ? LIMIT 1", array(($status[0]['status'] == 0) ? 1 : 0, $id), false);
    }
    
    /*
     * @METHOD  Thread
     * @DESC    hides the thread
     */
    
    public function hideThread($id, $rank)
    {
        //extract current status of post
        $status = $this->database->processQuery("SELECT `hidden` FROM `threads` WHERE `id` = ? LIMIT 1", array($id), true);
        
        if($rank > 2) $this->database->processQuery("UPDATE `threads` SET `hidden` = ? WHERE `id` = ? LIMIT 1", array(($status[0]['hidden'] == 0) ? 1 : 0, $id), false);
    }
    
    /*
     * @METHOD  lock
     * @DESC    locks a thread
     */
    
    public function lock($id, $rank = 0)
    {
        //make sure it exists
        $thread = $this->database->processQuery("SELECT `lock` FROM `threads` WHERE `id` = ? LIMIT 1", array($id), true);

		//take action if they are staff
        if($this->database->getRowCount() == 1 && $rank > 2) $this->database->processQuery("UPDATE `threads` SET `lock` = ? WHERE `id` = ? LIMIT 1", array(($thread[0]['lock'] == 1) ? $do = 0 : $do = 1,$id), false);
    }
    
    /*
     * @METHOD  escalate
     * @DESC    function for mods to get an admin to quickly see thread
     * @DESC    only escalate if not already escalated
     */
    
    public function escalate($id, $rank, $reason)
    {
        if(!$this->isEscalated($id) && $rank > 2) $this->database->processQuery("UPDATE `threads` SET `escalated` = 1, `reason` = ? WHERE `id` = ? LIMIT 1", array($reason, $id), false);
    }
    
    /*
     * @METHOD  isEscalated
     * @DESC    checks if the thread is escalated
     */
    
    public function isEscalated($id)
    {
        $thread = $this->database->processQuery("SELECT `escalated` FROM `threads` WHERE `id` = ? LIMIT 1", array($id), true);
        return ($thread[0]['escalated'] == 1) ? true : false;
    }
    
    /*
     * @METHOD  canReply
     * @DESC    checks if the user is allowed to reply
     */
    
    public function canReply($id, $powerLevel)
    {
        //extract thread details
        $thread = $this->database->processQuery("SELECT `lock`,`moved` FROM `threads` WHERE `id` = ? LIMIT 1", array($id), true);
        
        //return if they can reply or not
        return (($thread[0]['lock'] == 1 && $powerLevel < 3) || !empty($thread[0]['moved']) || !isset($_COOKIE['user'])) ? $canReply = false : $canReply = true;
    }
    
    /*
     * @METHOD  preTitle
     * @DESC    get the lock/sticky icon before the thread's title 
     * @PARAM   $rank       rank of the user viewing
     * @PARAM   $location   where the user is at (viewforum.php/viewthread.php)
     */
    
    public function preTitle($id, $rank, $location = 1)
    {
        $data = $this->database->processQuery("SELECT `lock`,`sticky` FROM `threads` WHERE `id` = ?", array($id), true);
        $extra = '';
        
        if($rank > 2 && $location == 0) $extra .= '<input type="checkbox" name="selection[]" value="'. $id .'"> <img src="../img/forum/modify.png" id="thread-'. $id .'"> ';
        if($data[0]['sticky'] == 1) $extra .= '<i class="fa fa-sticky-note"></i> ';
        if($data[0]['lock'] == 1) $extra .= '<i class="fa fa-lock"></i> ';
        
        return $extra;
    }
    
    /*
     *@METHOD   hasReplies
     *@DESC     returns number of replies
     */
    
    public function getReplies($id)
    {
        $this->database->processQuery("SELECT * FROM `posts` WHERE `thread` = ?", array($id), false);
        return $this->database->getRowCount();
    }
    
    /*
     * @METHOD  getPostType
     * @DESC    gets the type of the post to display (like hidden, fmod, etc)
     * @PARAM   $id : id of the thread
     * @PARAM   $status : status (hidden/public) of the thread
     * @PARAM   $rank : the rank of the user that posted it
     */
    
    public function getPostType($status, $creator, $hide = false, $highlight = false)
    {
        $data = $this->database->processQuery("SELECT `acc_status`,`donator` FROM `users` WHERE `username` = ? LIMIT 1", array($creator), true);
        $rank = $data[0]['acc_status'];
        
        if($status == 1)
        {
            $type = 'message hid';
        }
        elseif($hide)
        {
            $type = 'message moved';
        }
        elseif($data[0]['donator'] == 1 && $rank < 2)
        {
            $type = 'message donator';
        }
        else
        {
            $included = ($highlight) ? 'msghighlight' : null; 
            
            switch($rank)
            {
                case 3:
                    $type = 'message mod '. $included;
                    break;
                case 4:
                    $type = 'message jmod '. $included;
                    break;
                default:
                    //$type = 'message '. (($_COOKIE['halloween_theme'] == 'true') ? 'halloween' : '') . $included; HALLOWEEN
                    $type = 'message '. $included;
                    break;
            }
        }
        
        return $type;
    }
    
    /*
     * @METHOD  getPageNum
     * @DESC    gets the page of the specifided post
     * @PARAM   $post       the id of the post (NOT THREAD) we'll be going to
     * @PARAM   $thread     the id of the thread
     * @PARAM   $per_page   derp
     */
    
    public function getPageNum($post, $thread, $per_page = 10)
    {
        //make sure the selected post exists
        $this->database->processQuery("SELECT * FROM `posts` WHERE `thread` = ? AND `id` = ? LIMIT 1", array($thread, $post), false);
        
        if($this->database->getRowCount() == 1)
        {
            //get number of results
            $thread = $this->database->processQuery("SELECT * FROM `posts` WHERE `thread` = ? ORDER BY `id` ASC", array($thread), true);

            //place holders
            $i = 0; //the position of post
            $x = 0; //0 = not found : 1 = found

            while($x == 0)
            {
                if($thread[$i]['id'] == $post) $x = 1;
                $i++;
            }
            
            return ceil($i/$per_page);
        }
        else
        {
             return false;
        }
    }
    
    /*
     * @METHOD  formatPost
     * @DESC    converts text to smileys, adds forum quotes, filters/cleans post, add signatures
     */
    
    public function formatPost($content, $username, base $base, user $user, forum $forum = null)
    {
        //config
        $config = $base->loadConfig();
        
        //get the rank of the user
        $rank = $user->getRank($username);
        $donator = $user->isDonator($username);
        
        //username of viewer
        $viewer = $user->getUsername($_COOKIE['user'], 2);
        
        
        //users & fmods
        if($rank < 2)
        {
            //apply filter for USERS if the forum variable is set
            if(!is_null($forum) && $rank < 3) $forum->filter($content);
            
            //remove HTML
            $content = htmlentities($content);
        }
        
        //youtube bbcode is seperate from other bbcodes, because only the youtube bbcodes can be toggled on/off for members
        if($rank > 1 || $config['bbcode_members']) $content = preg_replace('#\[youtube\](.+?)\[\/youtube\]#', '<iframe width="560" height="315" src="http://www.youtube.com/embed/$1?rel=0" frameborder="0" allowfullscreen></iframe>', $content);
            
        //show content within [donator] tags only to donators
        $content = preg_replace('#\[donator\](.+?)\[\/donator\]#is', ($user->isDonator($viewer) || $user->getRank($viewer) > 1) ? '<div class="donor_only"><center><font color="00FFFF">Donator Only</font></center><br/>$1</div>' : '<i>This content can only be seen by donators.</i>', $content);
        $content = preg_replace(array('#@(\d{1,1}-\d{1,1}-\d{4,4}-\d{5,5})#i', '#:iloveyou:#i', '#:pumpkin:#i'), array('<a href="jump.php?qfc=$1">$1</a>', '<img src="../img/forum/smileys/heart.png" width="15" height="15">', '<img src="../img/forum/smileys/pumpkin.png" width="15" height="15">'), $content);
        
        //now let's do BBCode for mods and admins
        if($rank > 2 || $donator)
        {
            //bcode and some smileys
            $bbcode = array('#\[b\](.+?)\[\/b\]#i', '#\[i\](.+?)\[\/i\]#i', '#\[url=(.+?)](.+?)\[\/url\]#i', '#\[u\](.+?)\[\/u\]#i', '#:lolbert:#i', '#\[img\](.+?)\[\/img\]#i', '#:donator:#i', '#:cheken:#i');
            $replace = array('<b>$1</b>', '<i>$1</i>', '<a href="$1">$2</a>', '<u>$1</u>', '<img src="../img/forum/smileys/lolbert.png">', '<img src="$1" border="0">', '<img src="../img/forum/smileys/blue_partyhat.gif" width="15" height="15">', '<img src="../img/forum/smileys/cheken.png" width="15" height="15">');
            $content = preg_replace($bbcode, $replace, $content);
            
            if($rank == 4)
            {
                    //convert QUOTE BBcode to actual HTML format
                    $content = stripslashes(preg_replace('/\[quote\=(.+?)](.+?)\[\/quote\]/s', '<blockquote>
<h5><strong>Original Post</strong> - Posted by: <strong>$1</strong></h5>

<p><i>$2</i></p>
</blockquote>
', $content)); 
            }
        }
        
        //add smileys
        if($user->smileyC()){
            $text = array(':)', ';)', ':P', ':(', ':|', 'O_o', ':D', '^^', ':O', ':@');
            $smileys = array('<img src="../img/forum/smileys/smile.gif">', 
            '<img src="../img/forum/smileys/wink.gif">', 
            '<img src="../img/forum/smileys/tongue.gif">', 
            '<img src="../img/forum/smileys/sad.gif">', 
            '<img src="../img/forum/smileys/nosmile.gif">', 
            '<img src="../img/forum/smileys/o.O.gif">', 
            '<img src="../img/forum/smileys/bigsmile.gif">', 
            '<img src="../img/forum/smileys/^^.gif">',
            '<img src="../img/forum/smileys/shocked.gif">', 
            '<img src="../img/forum/smileys/angry.gif">');
        }
                
                
                $signature = $user->getSignature($username);
                if($rank > 3){
                    $content = $content.((strlen($signature) > 0) ? '<br/><br/>'.$user->getSignature($username) : '');
                }
		return $content = stripslashes(str_replace($text, $smileys, $content));
    }
    
    public function getActionBar($rank, $id, $forum)
    {
        //check if the post is already reported
        $this->database->processQuery("SELECT * FROM `reports` WHERE `reported` = ?", array($id.':t'), true);
        $report = ($this->database->getRowCount() >= 1) ? '<span style="color:#C0C0C0">Report</span>' : '<a href="report.php?forum='. $forum .'&id='. $id. '&type=2">Report</a>';
        
        //set the base url
        $base_url = '?forum='. $forum .'&id='. $id;
        
        //display their action bar
        switch($rank)
        {
            case 1:
            case 2:
                $bar = $report;
                break;
            case 3:
                $bar = '<a href="edit.php'. $base_url .'&type=2">Edit</a>';
                break;
            case 4:
                $bar = '<div class="button invert"><a href="reply.php'. $base_url .'&quote='. $id .'&qt=2">Quote</a> | <a href="edit.php'. $base_url .'&type=2">Edit</a></div>';
                break;
        }
        
        return $bar;
    }
    
    public function bumpThread($id, $username)
    {
        $thread = $this->database->processQuery("SELECT `username` FROM `threads` WHERE `id` = ? LIMIT 1", array($id), true);
        
        if($thread[0]['username'] == $username) $this->database->processQuery("UPDATE `threads` SET `lastbump` = ? WHERE `id` = ?", array(time(), $id), false);
    }
}

?>

If anybody is to help me I will be very very greatful for any advice and help to reassure the issue.

If you'd like to see the horrible mess I've been left with, then please message me :).

 

 

 

PS:

 

I know the website probably has other bugs but this is coming to me as a "Major NEED" to sort out as soon as I can, I paid for a custom forum for my website to be created on, however that's gone pair-shaped.

Edited by mynewcar
Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.