Kev 69 Posted October 25, 2013 Report Share Posted October 25, 2013 How to run software from an iPhone Ok folks, this is a complete walkthrough on how I set up my software so as people can run their services on their mobile devices whilst the bots run on my VPS or local pc and running 24/7. The end user, or customer, can access the software via a web form integration from their smart phone or any web browser that feeds the data into a MySQL database which the software will read the data from.Things I use: A jotform account (http://www.jotform.com and you can get a free account - not an affiliate link). Please note, I bought a jotform package on a "Black Friday" deal last year and it cost $69.50 for two years for the professional package. PhpMysql (typically found with any half decent hosting plan. I use liquidweb, amongst others for my database and hosting needs.Here’s the VPS I currently use: http://www.liquidweb.com/managed-vps-hosting/My local box has 8GB ram and 3GHz processor. Not a big techie when it comes to hardware specs to be honest.So with the hardware out of the way here’s what I’m going to cover in this tutorial:How to set up the form and create the databaseHow I connect and read my data from the formHow to set up the bots to run 24/7How I handle memory issuesHow to set up the form and create the databaseOnce you’ve set up your jotform account you will need to submit your form to a specific url. This url will tell you what the form looks like in a fashion that will allow you to set up your database. You’ll only ever need to do this one time for each form you want to integrate with your software.Create a new text file. Inside the text file paste the following code: <?php print_r($_POST); ?>Now, save that text file and then close it out. Now, rename the file to postdetails.phpMake sure to rename the file extension!Upload this php file somewhere on your server. I suggest creating a new folder on your linux hosting and drop that file into it. Take note of the path. The url I use (for your reference) is http://eirtime.com/jfsub/postdetails.phpOk, now go create your web form.For this example let’s just create two fields: your name and your email address. Go do that inside jotform now.Once you’ve created your form go to: Preferences > Advanced Settings > Send Post Data - YESClick Close Settings.Click on the Thank You button at the top. Select Custom URL. In there place the URL to your postdetails.php file.Now preview your form and submit your data.You should see something very similar to this on the thank you page: Array ( [submission_id] => 248504684902184300 [formID] => 32973029077864 [ip] => 123.456.789.123 [name] => Kevin [email] => myemail@gmail.com ) Things to note here (and useful for when programming your software) - the submission_id will ALWAYS be unique. You will never see that number again. It can therefore be used as a “Case number” for when someone submits data. e.g. “Thanks for your submission. Your unique reference number is SUBMISSION_ID”.Ok, so take note of all the names of the array contents (basically ANYTHING inside the square brackets.In the form example above we would take note of: submission_id formID ip name email Now, you’ll need to create a new database inside youe cpanel account. Create a new database, add your user and give the user all privileges and then launch your phpmyadminIn there you’ll need to create a new table. Call the table whatever you like, but take note of the table name. Once you do this it will ask you how many columns you want. In our example we want 5. Call each column by the corresponding names above and select VARCHAR and add 1000 to the value (that is if you don’t know what you’re doing).I’m rushing over the database set up as it’s pretty straight forward, particularly when using the DB creation wizard from within Cpanel. Please ensure to take note of usernames and passwords for the user and database name.Inside cpanel there’s an option for Remote Database connections - you’ll need to add a wild card option there as your bots will be remotely connecting. So, look for that inside your cpanel account. Also, take note of your IP number of your server.Some users may experience difficulty with shared accounts here and shared IPs. I have no experience in this as I have a dedicated IP ($1 per month).Ok so that’s the first step.Next what we need to do is edit a php file. This is going to take a bit of time to do and quite detailed, however it’s NOT difficult, as long as you edit the right things and delete what’s not needed.Copy and paste this code into a new text file <?php function ExtendedAddslash(&$params) { foreach ($params as &$var) { // check if $var is an array. If yes, it will start another ExtendedAddslash() function to loop to each key inside. is_array($var) ? ExtendedAddslash($var) : $var=addslashes($var); unset($var); } } // Initialize ExtendedAddslash() function for every $_POST variable ExtendedAddslash($_POST); $submission_id = $_POST['submission_id']; $formID = $_POST['formID']; $ip = $_POST['ip']; $name = $_POST['name']; $email = $_POST['email']; $db_host = 'localhost'; $db_username = 'changeme'; $db_password = 'changeme'; $db_name = 'changeme'; mysql_connect( $db_host, $db_username, $db_password) or die(mysql_error()); mysql_select_db($db_name); // search submission ID $query = "SELECT * FROM `changeme` WHERE `submission_id` = '$submission_id'"; $sqlsearch = mysql_query($query); $resultcount = mysql_numrows($sqlsearch); if ($resultcount > 0) { mysql_query("UPDATE `changeme` SET `submission_id` = '$submission_id', `formID` = '$formID', `ip` = '$ip', `name` = '$name', `email` = '$email', WHERE `submission_id` = '$submission_id'") or die(mysql_error()); } else { mysql_query("INSERT INTO `changeme` (submission_id, formID, IP, name, email) VALUES ('$submission_id', '$formID', '$ip', '$name', '$email') ") or die(mysql_error()); } header( 'Location: http://google.com' ) ; ?>If you always leave submission_id, formID, IP as they are, you’ll only ever need to change name, email and add any other [array details] to this form. Ensure to add the database connection details to the form above!However, the above form is ready to run when taking into account the information I used from the initial form submission.So, save that file as testsubmission.php and upload it again like the last time, to your server. Take note of the URL.Go back to your form and edit the thank you page - change the custom URL to your new URL.Submit your form and if all works well it should direct you to Google.comIf it doesnt it will tell you where the error is.The above information will take you the most time to figure out, particularly if you are new to all this. However, once you master it it’s a great way to integrate a form with a database, which we then integrate with our ubot code!How I connect and read my data from the form As long as you’ve got redirected to Google.com you’ve got nearly everything set up and ready to now start integrating your ubot code to your database! http://content.screencast.com/users/koconnor00/folders/Jing/media/896d693e-6fdd-4e5a-96e3-ce098a52b471/2013-10-25_1129.png Take a look at the above image.What you will notice is the query with results part has tablename written there. You will need to replace that with whatever you added as your table name when you set up your database. Why did I use LIMIT 1? Well, firstly what it’s doing there is selecting all the data from the tablename form and only the first row. What I do is operate a first row action policy. Whatever information is in the first row gets processed by my software, then that first row gets deleted, moving the row below it up to the top row.This constant rule of checking JUST the first row allows that if there are multiple submits, only the first row is processed and deleted and then moves onto the next row.You will need to edit your SQL query to suit what you need to do, however, you won’t need to learn SQL - there’s plenty of “delete first row in database” tutorials on the web, if you need them.So, once the information from row 1 is added into the &results table, I can then do what I like with the data. Remember, Rows 0,1 and 2 are going to be submission_id, FormID and IP. The other rows are going to be the user inputted data.How to set up the bots to run 24/7This took me a while to get fine tuned, but it works now and works well.I have a Loop While command. EVERYTHING to do with the database and the processing of the results is sitting inside the Loop While. The Loop While is set to a condition that is set when the software is first ran: Set a variable to $true - loop while variable is $trueSo, it will continue to loop infinitely as the variable is $true.Every 15 seconds my bots check the database for any new data. If data appears in the database then it will process it and then add an increment. If there is NO data in the database it obviously doesnt process anything and adds an increment.I have the increment count up to 100 so I have the bot run in total, 100 times and then it will Shell out to a batch file.But Kev, you said this bot would run 24/7? Tehcnically this bot in this set up will run 100 times and then a shell script runs and launches a batch file. However, at that moment in time the software isn’t doing anything. So, I say to myself “I want a fresh instance of the bot”. After the shell command to the batch file, I have a Stop Script.How I handle memory issuesThe reason why I had the 100 loop and then shell to a batch file was because I kept running out of memory. The way I worked around this was simple. To shell out to a batchfile that contained the command to START that very same bot again, with an /auto command!So, as soon as that batch file executed, the original bot came to Stop Script node and simply closed out, meaning I only ever had ONE window of that bot open at any one time. This does mean though that you’ll need to START the initial bot from running the batch file.Here’s a sample of a batch file command: "C:\Users\Administrator\Desktop\botname.exe" /auto(including the quotes)So, I call that batchfile batch.bat and inside my ubot I use the Shell command and navigate to botname.batWhen that shell command is executed it will run that batch file, which will AUTO start the bot called botname.exeSince implementing this method I’ve never had memory issues with my software and it runs 24/7.Things to noteI’ve taken a very simplistic overview of how this whole process works, however, I wanted to ensure that you got the bulk of the technical details at the start to ensure you get the web form integration right. The rest of the information provided is complete however not as detailed. This is simply because you’ll want to make your software do your own things. You might want to schedule it to run on the hour every hour, or once a day, NOT 24/7 like I have. You may also discover coding bugs along the way. For instance I can tell you that sometimes running a 24/7 bot where the website you’re navigating to may be down. What happens to your bot then? How will you know there’s a problem? You’ll need to discover these things yourself.I can tell you though that implementing a similar integration to what I’ve outlined above WILL allow you to run your software as a servive. I use this model as often as I can and hardly ever indicate to a client that they can have a desktop application. I’m pushing for a monthly revenue stream as often as possible and this integration allows me that flexibilty. I can also tell you that once you integrate using a web form you are essentially taking away the need to run software on a desktop PC and now your customers can run the service from their iPhones, iPads or god forbid, even a Mac! About MeI’m NOT a programmer. I’m a marketer. I make products and sell them to other marketers and to local businesses. I’ve been using ubot for about 2 years and can tell you that once I started using the SaaS model in my business I was able to increase my monthly revenue and close more sales simply because I could run demonstrations from my iPad, the client’s iPad or Smart phone, whatever! I didn’t need to lug a laptop with me, or rely on an internet connection. Also, I didn't want to give away the software tools - I wanted to hold onto them, having total control yet giving the customer what they needed. If they don’t pay, I simply disable their web form!Don’t Give Up!If you’re new to ubot stick at it! So many buy it and don’t do anything with it then find fault with ubot. Ubot does exactly what I need it to do. If it doesn't do what you need FIND ANOTHER WAY inside ubot! People assumed bots can only be ran on Windows PCs. Well, I’ve just outlined a detailed plan to get bots running on any device. You just need to come up with the ideas!Ask questions. Learn from other questions posted. Try contribute to other people’s questions and all the while develop on what you know - making things run better and better each time. Here's a screenshot I just took from inside my jotform account with three forms belonging to the same project. Check the volume of submits for them and the software handles everything flawlessly. http://eirtime.com/submits.png Try out a real working form!Click on the image belowhttp://content.screencast.com/users/koconnor00/folders/Jing/media/26098c68-345f-4b42-9f14-37bfb45495fa/2013-10-27_1044.png I hope you got some value out of this tutorial. I enjoyed putting it together and if you have any questions please ask. 12 Quote Link to post Share on other sites
rocket976 62 Posted October 25, 2013 Report Share Posted October 25, 2013 AWESOME and exactly whats been on my mind lately! Thank you very much for sharing Kev Quote Link to post Share on other sites
Kev 69 Posted October 25, 2013 Author Report Share Posted October 25, 2013 AWESOME and exactly whats been on my mind lately! Thank you very much for sharing KevCheers Rich, Took far longer to write it out than I'd thought, but it's there now for everyone. Quote Link to post Share on other sites
jason 101 Posted October 25, 2013 Report Share Posted October 25, 2013 Thanks Kev. Awesome. Quote Link to post Share on other sites
kev123 132 Posted October 25, 2013 Report Share Posted October 25, 2013 really good contribution thankyou Quote Link to post Share on other sites
Kreatus (Ubot Ninja) 422 Posted October 25, 2013 Report Share Posted October 25, 2013 Thanks. This should be handy in the future.. Quote Link to post Share on other sites
wilriv21 16 Posted October 25, 2013 Report Share Posted October 25, 2013 Kev, Thank you very much for taking time to share this with the community. It is greatly appreciated. Regards,William Quote Link to post Share on other sites
Kev 69 Posted October 25, 2013 Author Report Share Posted October 25, 2013 Thanks Kev. Awesome. really good contribution thankyou Thanks. This should be handy in the future.. Kev, Thank you very much for taking time to share this with the community. It is greatly appreciated. Regards,WilliamMy pleasure. I hope it's useful to many. Quote Link to post Share on other sites
Babba 0 Posted October 25, 2013 Report Share Posted October 25, 2013 Thanks for sharing this! It´s the future Quote Link to post Share on other sites
Steve 30 Posted October 25, 2013 Report Share Posted October 25, 2013 Awesome share! Very detailed! Will be using this down the road.. Quote Link to post Share on other sites
Kev 69 Posted October 26, 2013 Author Report Share Posted October 26, 2013 Thanks for sharing this! It´s the future Awesome share! Very detailed! Will be using this down the road..You're welcome Quote Link to post Share on other sites
illmill 87 Posted October 27, 2013 Report Share Posted October 27, 2013 Wow, this is amazing, Kev! Good one, thanks for the detailed info. I've bookmarked this and will be referring back when I move my bots over to this model. Quote Link to post Share on other sites
Code Docta (Nick C.) 638 Posted October 27, 2013 Report Share Posted October 27, 2013 That is so awesome, been wondering if you were gonna share or sell....now we all know. We can all benefit from this it's sooo one of the best shares here at UBot forum. Thanks buddy and I hope others are inspired like myself to share things as awesome as this!! TC Quote Link to post Share on other sites
don 1 Posted October 27, 2013 Report Share Posted October 27, 2013 Great share Kev, would be using it near future (Y) Quote Link to post Share on other sites
wtf 4 Posted October 27, 2013 Report Share Posted October 27, 2013 This is very cool, huge thanks for sharing that Kev. Quote Link to post Share on other sites
Kreatus (Ubot Ninja) 422 Posted October 27, 2013 Report Share Posted October 27, 2013 Hi Kev, Just one question, does it have to be one bot per customer?I mean, if the customer submit a form and then it should run the bot for him/her. What if 10 other more do that at the same time?What is your take on this! Thanks again for sharing this stuff! This is a gem! Quote Link to post Share on other sites
Kev 69 Posted October 27, 2013 Author Report Share Posted October 27, 2013 Hi Kev, Just one question, does it have to be one bot per customer?I mean, if the customer submit a form and then it should run the bot for him/her. What if 10 other more do that?What is your take on this! Thanks again for sharing this stuff! This is a gem!Hey man, No ,not at all! I have one bot, ran in this same fashion, with over 2000 customers all using it. On the launch day I had the same bot running twice just to help with volume and tell folks there may be a slight delay due to volumes (said on the thank you page after submission) but really, I just use one now as the work flow has died down somewhat. So, one bot, lots of customers, one task done at a time. This works well as the tasks dont take long to complete anyway. Quote Link to post Share on other sites
Kev 69 Posted October 27, 2013 Author Report Share Posted October 27, 2013 Bump: folks I've just added a form to the bottom of the thread for you to see it working in real time. Ensure to enter the data correctly (email address) so as you receive the output in your inbox. Typically takes 30-60 seconds. Notice I have the redirect coming back to this page. If it were a membership site it could go there (which it does). Enjoy! 1 Quote Link to post Share on other sites
Sirfrank 17 Posted November 15, 2013 Report Share Posted November 15, 2013 (edited) Holy crap MAN, i am using all these mentioned resources ( jotform, etc) and also think i am much of a "think outside of the box" guy, but this one..... DROPPED MY JAW! Excellent!!! Edited November 15, 2013 by Sirfrank Quote Link to post Share on other sites
Kev 69 Posted November 15, 2013 Author Report Share Posted November 15, 2013 Holy crap MAN, i am using all these mentioned resources ( jotform, etc) and also think i am much of a "think outside of the box" guy, but this one..... DROPPED MY JAW! Excellent!!! I'm just joining the dots, that is all Quote Link to post Share on other sites
positivity13 4 Posted November 16, 2013 Report Share Posted November 16, 2013 Hi Kev, This is gold!!! One thing I'm stuck on is closing the bot down. I shell out to a batch.bat which has /botname.exe But I can't find a way to close the old bot window down as the cmd window is still open and doesn't close. So I have 10 bots open and 10 batch files. What am I doing wrong? 1 Quote Link to post Share on other sites
pftg4 102 Posted November 16, 2013 Report Share Posted November 16, 2013 use aymens free plugin close bot pftg4 Quote Link to post Share on other sites
Kev 69 Posted November 16, 2013 Author Report Share Posted November 16, 2013 When you Shell out to the batch file, simply do a Stop Script and that should shut the original bot down for you. Quote Link to post Share on other sites
positivity13 4 Posted November 16, 2013 Report Share Posted November 16, 2013 Hi Kev, It seems its not getting to the stop script part, as the shell batch command I guess doesnt register it is finished. Because it just opens a new cmd window and then a new bot, so say I let it loop 30 times there would be 30 cmd windows and 30 bots open. I am using windows 8, does that make a difference? example bot code compiled and called test.exe: set(#value, 0, "Global")loop(10) { increment(#value) load html(#value) wait(1)}shell("C:\\Users\\Mark\\Desktop\\Batch.bat")stop script The Batch file is this: "C:\Users\Mark\Desktop\test.exe" /auto What am I doing wrong? Quote Link to post Share on other sites
positivity13 4 Posted November 16, 2013 Report Share Posted November 16, 2013 Ignore that, worked it out, stuck the shell in a thread command set(#value, 0, "Global")loop(10) { increment(#value) load html(#value) wait(1)}thread { shell("C:\\Users\\Mark\\Desktop\\Batch.bat")}stop script Quote Link to post Share on other sites
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.