PDA

View Full Version : Are there a "delete" day for expired listings ?



Peter Jonsson
December 11, 2012, 12:54 AM
Just a simple question, wondering if there are any "delete" day for expired listings ?

Vladimir
December 11, 2012, 03:15 AM
Hello,

No, you can delete expired listings in admin panel.

Viktor
December 11, 2012, 09:47 AM
Hello Peter Jonsson,

Vladimir meant now no code for it :) but you can create it in cron>> index.php
Do you want me to send you code for delete listings after expiration?

Peter Jonsson
December 11, 2012, 10:25 AM
Yes please Viktor.

I also noticed that even if i delete a account from the adminpanel and then from the trashcan it will still be.

Example for what i mean:
I made an account with mail "mymail@hotmail.com" and then delete it.

Then i try to add another account with the same mail. I cant because it says it's already in use.
Isnt the account getting deleted from the database ?

If i delete an account from the site then that person should be able to make a new account with the same mail.

Viktor
December 11, 2012, 10:34 AM
Hello Peter Jonsson,

You should delete account from Trash Box too in admin panel and Then user can add account with same email :)

Viktor
December 11, 2012, 11:31 AM
Hello Peter Jansson,

Please go to ftp:cron>>index.php

and after his code at line ~ 69:


$reefless -> loadClass('ListingTypes', null, false, true);


add this code:



/* EXPIRED LISTINGS CHECKING */
$sql = "SELECT `T1`.*, UNIX_TIMESTAMP(`T1`.`Date`) AS `Date`, `T2`.`Path` AS `Cat_path`, `T2`.`Type` AS `Listing_type` ";
$sql .= "FROM `".RL_DBPREFIX."listings` AS `T1` ";
$sql .= "LEFT JOIN `".RL_DBPREFIX."categories` AS `T2` ON `T1`.`Category_ID` = `T2`.`ID` ";
$sql .= "WHERE `T1`.`Status` = 'expired' ";
$sql .= "LIMIT {$config['listings_number']}";
$listings = $rlDb -> getAll($sql);

if ( $listings )
{
/* how many days listings should be expired before delete*/
$in_days = 5;

foreach ( $listings as $key => $listing )
{
/* remove listing */
if ( $listing['Date'] + ($in_days * 86400) <= time() )
{
$rlListings -> deleteListingData($listing['ID']);
$rlDb -> query("DELETE FROM `". RL_DBPREFIX ."listings` WHERE `ID` = '{$listing['ID']}' LIMIT 1");
}
}
}

Peter Jonsson
December 11, 2012, 12:57 PM
About the account thing, i do delete account from trashcan aswell but it dont get deleted from database even after updating

Thanks for the code Viktor!

Chris Brown
December 11, 2012, 07:16 PM
Please go to ftp:cron>>index.php

and after his code at line ~ 69:


$reefless -> loadClass('ListingTypes', null, false, true);


add this code:



/* EXPIRED LISTINGS CHECKING */
$sql = "SELECT `T1`.*, UNIX_TIMESTAMP(`T1`.`Date`) AS `Date`, `T2`.`Path` AS `Cat_path`, `T2`.`Type` AS `Listing_type` ";
$sql .= "FROM `".RL_DBPREFIX."listings` AS `T1` ";
$sql .= "LEFT JOIN `".RL_DBPREFIX."categories` AS `T2` ON `T1`.`Category_ID` = `T2`.`ID` ";
$sql .= "WHERE `T1`.`Status` = 'expired' ";
$sql .= "LIMIT {$config['listings_number']}";
$listings = $rlDb -> getAll($sql);

if ( $listings )
{
/* how many days listings should be expired before delete*/
$in_days = 5;

foreach ( $listings as $key => $listing )
{
/* remove listing */
if ( $listing['Date'] + ($in_days * 86400) <= time() )
{
$rlListings -> deleteListingData($listing['ID']);
$rlDb -> query("DELETE FROM `". RL_DBPREFIX ."listings` WHERE `ID` = '{$listing['ID']}' LIMIT 1");
}
}
}


Hi Viktor

I too want to do this, just a quick question. By the looks of this code it deletes expired listings after 5 days is that correct? I f i wanted to change this to 30 days do i just change the $in_days = 5
and do i leave the $in_days * 86400) <= time() ) as it is, by the looks of this, this is seconds in a day if i am right

Chris

Viktor
December 12, 2012, 04:20 AM
Hello Chris,


I too want to do this, just a quick question. By the looks of this code it deletes expired listings after 5 days is that correct? I f i wanted to change this to 30 days do i just change the $in_days = 5
and do i leave the $in_days * 86400) <= time() ) as it is, by the looks of this, this is seconds in a day if i am right

Yes you are right you can change only $in_days = 5; this variable.

Viktor
December 12, 2012, 04:21 AM
Hello Peter,


About the account thing, i do delete account from trashcan aswell but it dont get deleted from database even after updating

Would you please send me access for your cpanel in PM I will check it ASAP.

Peter Jonsson
December 12, 2012, 10:21 AM
Hello Peter,



Would you please send me access for your cpanel in PM I will check it ASAP.

Working now, dont know whats going on. I think it went a way when i cleared the whole trash can

Viktor
December 12, 2012, 10:44 AM
Hello Peter,

I don't know exactly.
If you want you can send me ftp access in PM and I will check it.

Wei Hong
August 7, 2013, 04:51 AM
Hi Viktor,
Would you please help me making a cron jobs to do refresh listing for everyday please. So admin won't have to manually click on refresh.
Thank you

Viktor
August 7, 2013, 04:59 AM
Hello Yung Yang,

I don't understand you. What does it mean refresh listings? Please explain in more details.

Wei Hong
August 7, 2013, 05:19 AM
Hi
Sorry for not being clear.
The recount button in refresh section.

Category shows number of listings within, including expired listing.
For example: Electronic (9), but 4 has been expired, so when you click on the cat, you only see 5.
In order to make this show correctly, I have to click recount in admincp, so that it will show Electronic(5).

What i meant was I wanted an automate recount listing that rule out expired one.
Or may be making category only count active one.

Hope that make sense
Thanks

Viktor
August 8, 2013, 03:42 AM
Hello Yung Yang,

Understand now. :)

Of course it's possible.

Go to ftp://cron>>index.php

find line: /* SAVED SEARCH CHECKING */

above add new code:




$reefless -> loadClass('Cache');
$reefless -> loadClass('Actions');

recountListings();
$rlCache -> update();

function recountListings()
{
global $lang, $rlCache, $rlDb;

$start = 0;
$limit = 100;
$while_checked = true;

$rlDb -> query("UPDATE `" . RL_DBPREFIX . "categories` SET `Count` = 0");

/* get all categories */
$rlDb -> setTable('categories');
$categories = $rlDb -> fetch( array('ID', 'Parent_ID'), array('Status' => 'active'), "ORDER BY `Parent_ID`", array($start, $limit) );
$rlDb -> resetTable();

while( $while_checked )
{
/* get all categories */
$rlDb -> setTable('categories');
$categories = $rlDb -> fetch( array('ID', 'Parent_ID'), array('Status' => 'active'), "ORDER BY `Parent_ID`", array($start, $limit) );
$rlDb -> resetTable();

if( count($categories) > 0 )
{
foreach ($categories as $key => $value)
{
$sql = "SELECT COUNT(`T1`.`ID`) AS `Count` FROM `" . RL_DBPREFIX . "listings` AS `T1` ";
$sql .= "WHERE `T1`.`Category_ID` = '{$categories[$key]['ID']}' AND `T1`.`Status` = 'active' ";

$cat_listings = $rlDb -> getRow( $sql );

$update = array(
'fields' => array(
'Count' => $cat_listings['Count']
),
'where' => array(
'ID' => $categories[$key]['ID']
)
);

$GLOBALS['rlActions'] -> updateOne($update, 'categories');

if ( $categories[$key]['Parent_ID'] > 0 )
{
recountListingsAdditional($categories[$key]['Parent_ID'], $cat_listings['Count'] );
}
}
}
else
{
$while_checked = false;
}
unset($categories);
$start += $limit;
}
}

/**
* recount listings number for parent category | recursive method
*
* @param int $parent_id - parent category ID
* @param int $current_count - current category listing number
*
**/
function recountListingsAdditional( $parent_id, $current_number)
{
global $rlDb;

$update = "UPDATE `" . RL_DBPREFIX . "categories` SET `Count` = `Count` + '{$current_number}' WHERE `ID` = '{$parent_id}' LIMIT 1";

$rlDb -> query($update);

$category = $rlDb -> fetch(array('ID', 'Parent_ID'), array('ID' => $parent_id, 'Status' => 'active'), null, 1, 'categories', 'row');

if ( $category['Parent_ID'] > 0 )
{
recountListingsAdditional( $category['Parent_ID'], $current_number );
}
}


save and it should work correctly.

Wei Hong
August 9, 2013, 08:38 PM
Thank you
One question. Where do you adjust the time for this script? Is it going to run everyday? What if I want to change it to every week?

Chris Brown
October 21, 2014, 05:08 PM
Yeah been looking for this for ages, hopefully this works as getting sick of deleting expired listings :D

Would be good for future versions of flynax to have this as a setting in admin, to turn on or off, and set days to delete after expiry

Viktor
October 22, 2014, 04:16 AM
Hello Chris,

But needs to create cron command in cpanel or other panel on server for run file and I think twice a day will be excellent period for running cron file.

Chris Brown
October 22, 2014, 05:33 AM
Yeah thanks, i already have cron set up. All seems to be working, :D expired listings amount going down.