Discussion Forums  >  Self Hosted Control Panels

Replies: 7    Views: 136

leon7000
Lost but trying
Profile
Posts: 58
Reg: Mar 02, 2012
Saudi Arabia
6,080
03/29/12 11:01 AM (13 years ago)

asking :how to limit source code on bt-server

Hi And Hope all user here have Nice day . what i asking about is : i want limit the users on my server from downloading source code after 5 times ...mean ..the user can download his source code just 5 time every month . i try to add table on database with this code: ALTER TABLE `bt_users` ADD `downLimit` INT( 4 ) NULL DEFAULT NULL but really i don't know what i need to add inside:bt_appDownload.php to link it with this table if user reach his monthly download time he can't download it again until 30 days past this well help us to control our server from overload on api key request. Regards
 
Fred@mySkylla com
Android Fan
Profile
Posts: 5259
Reg: Oct 03, 2011
location unknow...
62,560
like
03/29/12 11:28 AM (13 years ago)
Following, interested in solution. Fred
 
GoNorthWest
buzztouch Evangelist
Profile
Posts: 8197
Reg: Jun 24, 2011
Oro Valley, AZ
1,000,000
like
03/29/12 12:53 PM (13 years ago)
One sorta related solution to this is "education." I think it's important to educate all buzztouch users that source code for an app really only needs to be downloaded once...that it's the Configuration File that controls all the design changes they make. If people can understand that, then the download requests should drop significantly. But, since people will do it anyway, I'm interested in the solution as well! Mark
 
David @ buzztouch
buzztouch Evangelist
Profile
Posts: 6866
Reg: Jan 01, 2010
Monterey, CA
78,840
like
03/29/12 01:51 PM (13 years ago)
Good talk here. Naturally there are all sorts of approaches that could be taken to do this. Here's how I would do it. ALTER TABLE `bt_users` ADD `downLimit` INT( 4 ) NULL DEFAULT 5; ALTER TABLE `bt_users` ADD `downCount` INT( 4 ) NULL DEFAULT 0; ALTER TABLE `bt_users` ADD `lastDownloadUTC` datetime NULL DEFAULT NULL; UPDATE `bt_users` SET downLimit = 4; UPDATE `bt_users` SET downCount = 0; One column holds the last download date, the other two hold the number allowed and the total downloaded. The date isn't necessary if you reset the count each month? In either case, it seems appropriate to track the last download date if you plan to limit downloads. Next, updating the database on download. BT-server/BT-server/bt_v15/bt_app/bt_appDownload_AJAX.php does all the heavy lifting when a user packages an app. This is the file you'll need to modify to update the users database record (update download count and last download date). I would do this around line 58, after the api key object is instantiated. //sql statement to execute... $tmp = "UPDATE " . TBL_USERS . " SET downCount = (downCount + 1), lastDownloadUTC = '" . $dtNow . "' WHERE guid = '" . $guid . "'"; //execute the sql statement using the built in fnExecuteNonQueryMethod in the utilities include... fnExecuteNonQuery($tmp, APP_DB_HOST, APP_DB_NAME, APP_DB_USER, APP_DB_PASS); At this point the database is updated. Next, you'll need to figure out how to limit the downloads. I would do this on the download page itself. If the user has already download the max allowed for that user. BT-server/BT-server/bt_v15/bt_app/bt_appDownloadphp is the file that the user sees when they first land on the download page.. In that file, just before all the php ends, on about line 117... //sql for download count and limit $tmpCountSql = "SELECT downCount FROM " . TBL_USERS . " WHERE guid = '" . $guid . "'"; $tmpLimitSql = "SELECT downLimit FROM " . TBL_USERS . " WHERE guid = '" . $guid . "'"; //built in method in utilities file to get one value... $tmpCount = fnGetOneValue($tmpCountSql, APP_DB_HOST, APP_DB_NAME, APP_DB_USER, APP_DB_PASS); $tmpLimit = fnGetOneValue($tmpLimitSql, APP_DB_HOST, APP_DB_NAME, APP_DB_USER, APP_DB_PASS); //if count is greater than or equal to limit, don't allow... if($tmpCount >= $tmpLimit){ $bolCanDownload = false; $canDownloadMessage .= "<br>You have exceeded your download limit."; } I wrote this by hand and did not test it, bet it works ;-) You'll need to engineer a method to update these counts each month.
 
leon7000
Lost but trying
Profile
Posts: 58
Reg: Mar 02, 2012
Saudi Arabia
6,080
like
03/29/12 05:35 PM (13 years ago)
Hi fred , mark Hi david ...and thank you for your help i try to follow the steps but i get this error when i try to add the last step in: bt_appDownloadphp around line 117 ...the error was: (Parse error: syntax error, unexpected $end in C:\wamp\www\BT-server\bt_v15\bt_app\bt_appDownload.php on line 310) and i moved the code to line 55 and it's ok when i request the download page , but no limit message shown and i can click on (Prepare package for download ) i try this on my localhost the tables is ok and i can see the limit count for user :downLimit (4)..downCount (8)
 
leon7000
Lost but trying
Profile
Posts: 58
Reg: Mar 02, 2012
Saudi Arabia
6,080
like
03/29/12 05:51 PM (13 years ago)
great news i find the error after i read the last code carefully this the fix for it : you need to remove the last character in this line : if($tmpCount >= $tmpLimit){{ to be like this: if($tmpCount >= $tmpLimit){ Thank you for great code here ....and it's work fine
 
leon7000
Lost but trying
Profile
Posts: 58
Reg: Mar 02, 2012
Saudi Arabia
6,080
like
05/10/12 05:28 AM (13 years ago)
Hi all buzztouch users ...hopping you have nice day :) today i try the code on my online web but i always have this error : There was a problem parsing the JSON result when i put this code on at line 58 on bt_appDownload_AJAX.php ...i get this error msg but when i remove it it's work i try to add this code to bt_appDownload.php with the another code and it's limit the download but it count +1 if the user just click on download source code link in there account control panel....i try to send david pm msg but i can't find the send pm option //sql statement to execute... $tmp = "UPDATE " . TBL_USERS . " SET downCount = (downCount + 1), lastDownloadUTC = '" . $dtNow . "' WHERE guid = '" . $guid . "'"; //execute the sql statement using the built in fnExecuteNonQueryMethod in the utilities include... fnExecuteNonQuery($tmp, APP_DB_HOST, APP_DB_NAME, APP_DB_USER, APP_DB_PASS); Regards
 
David @ buzztouch
buzztouch Evangelist
Profile
Posts: 6866
Reg: Jan 01, 2010
Monterey, CA
78,840
like
05/10/12 08:32 AM (13 years ago)
@leon7000: It's tough to say what trouble you're having without knowing more about what you've changed, modified, updated. If you're not a PHP programmer and dont' understand how PHP works, you may have to find some professional help. It sounds to me like an issue of your SQL statement not executing properly. This means you'll need to figure out if you've modified the database table the right way (you had to change it's structure to support your goal of limiting app downloads). There is no pm option in my profile because I've turned it off. When I leave it on on receive thousands of requests for technical support (for free). I cannot help everyone with their PHP installations - it's not possible. You have two choices: a) Continue experimenting with changes to code until you find something that suits your needs. b) Hire a professional to help you with your tech support. c) Pay us to do a professional install for you (this will not include modifying the self hosted package to limit the number of source code downloads). I think more than anything you're in over your head a bit? If you're trying to setup a site that encourages other users to use your control panel, then customize the control panel to incorporate specialized custom functions, but don't understand how PHP works or how to customize it, you're going to end up frustrated and confused? I'm not sure if this post is helpful or not but hope it is.
 

Login + Screen Name Required to Post

pointerLogin to participate so you can start earning points. Once you're logged in (and have a screen name entered in your profile), you can subscribe to topics, follow users, and start learning how to make apps like the pros.