PDA

View Full Version : limit the number of free ads at any one time ?



Pete Young
March 12, 2013, 11:13 AM
I understand that in free ads it asks for number of free ads before paying / but this is for total ads and once used it is used, but can i edit the system to allow the number given to represent the number of free ads at any one time not total time.

for example if I set it to say 10 then it would allow them to have up to 10 free ads at any one time, from there they would need to go paid / or if they wanted to they could delete one of the free ads and then add another free ad, and they could do this forever and a day so long as they never exceeded the free allocations set.

Abelardo Leal
March 12, 2013, 04:28 PM
Hi , You have to add some valitacion to add_listing.inc.php around line 645 is this block of code:


if ( $rlListings -> create( $plan_info, $data, $category_fields ) )
{
$listing_id = $rlListings -> id;
$_SESSION['add_listing']['listing_id'] = $listing_id;

$rlHook -> load('afterListingCreate');

/* tmp category controller */
if ( $_SESSION['add_listing']['tmp_id'] == $_SESSION['add_listing']['tmp_category_id'] )
{
$rlDb -> query("UPDATE `". RL_DBPREFIX ."tmp_categories` SET `Account_ID` = '{$account_info['ID']}' WHERE `ID` = '{$_SESSION['add_listing']['tmp_category_id']}' LIMIT 1");
}
else
{
$rlDb -> query("DELETE FROM `". RL_DBPREFIX ."tmp_categories` WHERE `ID` = '{$_SESSION['add_listing']['tmp_category_id']}' LIMIT 1");
}
}



I modified this if $plan_info['price'] > 0 I continue normal, if not I query for free listings with days published < 365 on the logued Account['ID']. this is the code modified:



//chk mod (verify if price > 0)
if($plan_info['price'] > '0') {
//end chk mod
$valid = true;

if ( $rlListings -> create( $plan_info, $data, $category_fields ) )
{
$listing_id = $rlListings -> id;
$_SESSION['add_listing']['listing_id'] = $listing_id;

$rlHook -> load('afterListingCreate');

/* tmp category controller */
if ( $_SESSION['add_listing']['tmp_id'] == $_SESSION['add_listing']['tmp_category_id'] )
{
$rlDb -> query("UPDATE `". RL_DBPREFIX ."tmp_categories` SET `Account_ID` = '{$account_info['ID']}' WHERE `ID` = '{$_SESSION['add_listing']['tmp_category_id']}' LIMIT 1");
}
else
{
$rlDb -> query("DELETE FROM `". RL_DBPREFIX ."tmp_categories` WHERE `ID` = '{$_SESSION['add_listing']['tmp_category_id']}' LIMIT 1");
}
}

//chk mod
} else {

$listings = $rlDb -> getAll("SELECT `list`.`ID`, DATEDIFF(NOW(), `list`.`Pay_date`) AS `days_published` FROM `mpt_listings` AS `list` INNER JOIN `mpt_listing_plans` AS `plan` ON `list`.`Plan_ID` = `plan`.`ID` WHERE `list`.`Account_ID` = '".$account_info['ID']."' AND `plan`.`Price` = '0' AND (DATEDIFF(NOW(), `list`.`Pay_date`) <= '365') AND `list`.`Status` = 'Active' ");
//var_dump($listings);

if(empty($listings)) {
$valid = true;
if ( $rlListings -> create( $plan_info, $data, $category_fields ) )
{
$listing_id = $rlListings -> id;
$_SESSION['add_listing']['listing_id'] = $listing_id;

$rlHook -> load('afterListingCreate');

/* tmp category controller */
if ( $_SESSION['add_listing']['tmp_id'] == $_SESSION['add_listing']['tmp_category_id'] )
{
$rlDb -> query("UPDATE `". RL_DBPREFIX ."tmp_categories` SET `Account_ID` = '{$account_info['ID']}' WHERE `ID` = '{$_SESSION['add_listing']['tmp_category_id']}' LIMIT 1");
}
else
{
$rlDb -> query("DELETE FROM `". RL_DBPREFIX ."tmp_categories` WHERE `ID` = '{$_SESSION['add_listing']['tmp_category_id']}' LIMIT 1");
}
}
} else {
$valid = false;
$errors[] = $lang['free_plan_validation'];
$rlSmarty -> assign_by_ref('errors', $errors);
}
}
//end chk mod
}

//chk mod (validation)
if($valid) {
//end chk mod
/* redirect to related controller */
$redirect = SEO_BASE;
$redirect .= $config['mod_rewrite'] ? $page_info['Path'] .'/'. $category['Path'] .'/'. $next_step['path'] .'.html' : '?page='. $page_info['Path'] .'&id='. $category['ID'] .'&step=' .$next_step['path'];
$reefless -> redirect( null, $redirect );
//chk mod (validation)
}
//end chk mod


Hi hope this could help you.

Pete Young
March 12, 2013, 09:58 PM
really appreciated, thank you

Kemoid Wilson
June 5, 2013, 03:28 AM
This is exactly what I am looking for but I am not very technical. Could you please explain it simpler?

Pete Young
June 5, 2013, 01:46 PM
This is exactly what I am looking for but I am not very technical. Could you please explain it simpler?

Kemoid, for this I have just applied a limit to the number of free ads that people can have and restricted this to 52 ( in my case or an average of one free listing / upgrade a week ) and i have set up a yearly listing plan and will create a new listing plan for 52 free ads each year as a way to work around this.

There is a small error in the system where it claims hack detected and I have written in fr some support on this. http://www.flynax.com/forum/showthread.php?1185-HACK-DETECTED-You-are-not-allowed-to-use-the-plans-please-choose-another-one&highlight=hack+detected

Kemoid Wilson
June 5, 2013, 04:55 PM
Did you fix the hack error? If yes can you please explain in details which files to edit on my server to get this to work.

Pete Young
June 6, 2013, 01:42 AM
Did you fix the hack error? If yes can you please explain in details which files to edit on my server to get this to work.

No not at this stage I have lodged a ticket and am awaiting reply from them.

Kemoid Wilson
June 14, 2013, 09:23 PM
Did you get this problem fix?

Pete Young
June 15, 2013, 02:14 PM
We are still working on it and I will report back here once it has been done.

Pete Young
June 18, 2013, 01:20 PM
http://www.screenr.com/5USH

For those with a hack problem try looking at this, from what i can see if you have edited the number of free updates and downsized it like i have done from 90 to 52 the number shown in the Plan Using section of your admin panel is higher than the current allocated allowed free listings.

for example I had a number of 55 as the number remaining > higher than the now allocated 52, so this ran an error / caused the hack detected error, now even if I set it to 52 it will show an error as one must already exist, so the number must be below your setting to avoid the error.

See video attached.

Kemoid Wilson
July 1, 2013, 05:09 PM
Can't implement code please help

Pete Young
July 1, 2013, 11:04 PM
Can't implement code please help

Kemoid, I did not impliment the code, what i done was set up a limit on the number of times the free option could be used in one year, this gives people an average number of times it can be used over the 12 months, once they are gone they are gone.

it may not be the best way to do it, but it does give me a balance where the smaller biz and mom and pops can place their free ads, big business or people who want to push massive ads, its time to pay the fiddler man.

well that will be the plan at this stage but i have a lot of building now to do with the site, most stuff i am getting now is spam so i delete it out.

Kemoid Wilson
July 2, 2013, 12:35 AM
Kemoid, I did not impliment the code, what i done was set up a limit on the number of times the free option could be used in one year, this gives people an average number of times it can be used over the 12 months, once they are gone they are gone.

it may not be the best way to do it, but it does give me a balance where the smaller biz and mom and pops can place their free ads, big business or people who want to push massive ads, its time to pay the fiddler man.

well that will be the plan at this stage but i have a lot of building now to do with the site, most stuff i am getting now is spam so i delete it out.

You don't understand. Every time I copy and paste your code I keep getting a mysql error
552

Pete Young
July 2, 2013, 11:51 AM
? what code are you copy and pasting buddy ? can you please show me from where / what ?

thanks

Kemoid Wilson
July 2, 2013, 03:14 PM
I don't know how you edited the code can you please help me

Pete Young
July 2, 2013, 03:45 PM
Kermoid, I unclear, how i edited what code where, I have no idea on what you are talking about and it why I asked you to show me / a link / description of exactly what you are talking about.

I have expalined i did not add the code above but limited my free package to a number, this is a system setting that requires no change to any codes, as above if you can show me what your trying to do with what code I might be able to clarify.