elgreco

Topic: Fake Jobs on the admin Section

since it is nice to follow if there is any fake job reported..i made a small addon to check it out.

1. /admin/index.php add

Code:
 
            // spam
            case 'spam':
            if(!isset($_SESSION['AdminId']))
            {
                redirect_to(BASE_URL);
                exit;
            }
            require_once 'page_spam.php';
            $flag = 1;
            break;

2. in \admin\templates\header.tpl add after approx line 51

Code:

<li {if $current_category == 'spam'}class="selected"{/if}><a href="{$BASE_URL_ADMIN}spam">Fake Reports</a></li>

3. create page_spam.php in \admin\

Code:

<?php

class Spam
{
    
     
    function __construct()
    { }
    
    public function Reports()
    {
        global $db;
        


        
        
        $sql = 'SELECT count(distinct job_id) AS totalNumberOfReports
                                FROM spam_reports';
        $result = $db->query($sql);
        $row = $result->fetch_assoc();
        
        $totalNumberOfReports = $row['totalNumberOfReports'];
        
        
        $sql = 'SELECT DISTINCT b.title AS title, b.company AS company, a.job_id AS job_id,sp.counter as counter
                                FROM spam_reports a join  jobs b
                                on a.job_id = b.id
                            join (
        select job_id,count(*) as counter  from spam_reports 
        group by job_id) as sp on a.job_id=sp.job_id ORDER BY  counter DESC';
        
        
        
        
        //$sql = 'SELECT * from spam_reports';
         //         $sql = 'SELECT DISTINCT b.title AS title, b.company AS company, a.job_id AS job_id
         //                       FROM spam_reports a, jobs b
         //                       WHERE a.job_id = b.id';
          
        $result = $db->query($sql);
        
        $spam = '';
        while ($row = $result->fetch_assoc())
            $spam .= '<div>' . $row['counter'] .     '   <a href="' . BASE_URL . 'job/' . $row['job_id'] . '/">' . $row['title'] .  '</a> at '. $row['company'] .' </div>';
        
        
        return array('spam' => $spam, 'count' => $totalNumberOfReports);
    }
    
    }
    
    
    $spam = new Spam();
    $smarty->assign('reports', $spam->Reports());
    $smarty->assign('current_category', 'spam');
    $template = 'spam.tpl';
?>
 

3. Create spam.tpl in \admin\templates

Code:
 
{include file="header.tpl"}
        
        <div id="content">
            <h3 class="page-heading">Fake Reports</h3>
            <div id="accordion-list">
                <h3>Jobs marked as Fake:</h3> 
                <ul> 
                    <li>Total: {$reports.count}</li> 
                    </ul>
                <br />
                Total | Job Title @ Company<br />
                {$reports.spam}
                
            </div>
        </div><!-- #content -->

{include file="footer.tpl"}
 

the page is not translated...its just for use it..as it is smile

Tokyoj

Re: Fake Jobs on the admin Section

elgreco,
Thank you. I'll added your code and it works but one minor issue.

In mine,
<li>Total: {$reports.count}</li>
remains at the original '4', but doesn't increase with new reports. The # per job works fine.

A suggestion, IMHO, the ability to manually delete jobs from the list would be helpful. I image after 1,2,3 yrs the list might be pretty long. What do you think?

---------------
Tokyoj
"You can't build a reputation on what you're going to do." (Henry Ford)
"Insanity is doing the same thing over and over, expecting different results." (Albert Einstein)

elgreco

Re: Fake Jobs on the admin Section

hi!

The number Total is the total number of jobs posted as fake. it should increase in number if you report a new job. If you click on one existing job, it will just increase the count of it.

I will add the delete function in a while, but till then you can use the the manage jobs to deactivate or delete it. smile

Tokyoj wrote:

elgreco,
Thank you. I'll added your code and it works but one minor issue.

In mine,
<li>Total: {$reports.count}</li>
remains at the original '4', but doesn't increase with new reports. The # per job works fine.

A suggestion, IMHO, the ability to manually delete jobs from the list would be helpful. I image after 1,2,3 yrs the list might be pretty long. What do you think?

Tokyoj

Re: Fake Jobs on the admin Section

Thanks for the clarification.

---------------
Tokyoj
"You can't build a reputation on what you're going to do." (Henry Ford)
"Insanity is doing the same thing over and over, expecting different results." (Albert Einstein)

F1Peace

Re: Fake Jobs on the admin Section

I followed the instructs above and all I get is a white screen in admin.
I'm using v1.8.

If I delete part 1 I see the admin page and if I click on the link # Fake Reports
I get The page you were looking for was not found.

Any help would be appreciated.

BTW.. shouldn't this be a part of Jobberbase by default?

navjotjsingh

Re: Fake Jobs on the admin Section

This should work in v1.8 albeit with a few tweaks (required only if you have customised job url structure or using database prefix)

Everything remains the same except use this page_spam.php:

Code:

<?php
class Spam
{
    function __construct()
    { }
 
    public function Reports()
    {
        global $db;
       
        $sql = 'SELECT count(distinct job_id) AS totalNumberOfReports
                                FROM '.DB_PREFIX.'spam_reports';
        $result = $db->query($sql);
        $row = $result->fetch_assoc();
        $totalNumberOfReports = $row['totalNumberOfReports'];
        
        $sql = 'SELECT DISTINCT b.title AS title, b.company AS company, a.job_id AS job_id,sp.counter as counter
                                FROM '.DB_PREFIX.'spam_reports a join  '.DB_PREFIX.'jobs b
                                on a.job_id = b.id
                                join (
        select job_id,count(*) as counter  from '.DB_PREFIX.'spam_reports 
        group by job_id) as sp on a.job_id=sp.job_id ORDER BY  counter DESC';
          
        $result = $db->query($sql);
        
        $spam = '';
        while ($row = $result->fetch_assoc())
            $spam .= '<div>' . $row['counter'] .     '   <a href="' . BASE_URL . URL_JOB .'/' . $row['job_id'] . '/">' . $row['title'] .  '</a> at '. $row['company'] .' </div>';
        
        return array('spam' => $spam, 'count' => $totalNumberOfReports);
    }
}

$spam = new Spam();
$smarty->assign('reports', $spam->Reports());
$smarty->assign('current_category', 'spam');
$template = 'spam.tpl';
?>

This should work. I tested it and found it to be working.