Jump to content

jonsjava

Members
  • Posts

    1,579
  • Joined

  • Last visited

About jonsjava

  • Birthday 07/11/1980

Contact Methods

  • Website URL
    http://jonsjava.com

Profile Information

  • Gender
    Male

jonsjava's Achievements

Member

Member (2/5)

1

Reputation

  1. I have an open source project (https://github.com/jonsjava/patchdashboard) Here's my .htaccess for this: RewriteEngine On RewriteBase "/pm/" RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule /patches/server/(.*)$ patch_list?server= [QSA,NC,L] RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule /packages/server/(.*)$ packages?server= [QSA,NC,L] RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule /search/exact/(.*)$ search?package=&exact=true [QSA,NC,L] RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule /search/(.*)$ search?package= [QSA,NC,L] RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule /rewrite_check/(.*)$ rewrite_check.php [QSA,NC,L] RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule ^([^/]*)$ index.php?page= [QSA,L] Basically, I want it so that no matter where they drop this script ("/", "/patch_dashboard/", "/pb/", etc.) it will redirect as intended. In the example I provided, the document root is "/pm/". When I try to hit a page ("http://dev2.curltools.com/pm/patches/server/demo1" for example), it gives a 404. If I hard code in each rule the base path, it just redirects everything to the main page. Any help would be greatly appreciated.
  2. I am exhausted after hiking half the day, and I have work in 6 hours. If you can wait, just PM me, and I'll help from there in the morning. If not, I'm sure other great PHP guys/gals here can help out in sorting out my code.
  3. Again, this wasn't tested code. Have you checked the error logs, or turned error_reporting to E_ALL for debug?
  4. Did you call the function? $proxy = getProxy(); echo $proxy;
  5. Correct, or at the next time it is called, if the current proxy was activated greater than 5 minutes ago.
  6. Forgot to mention: this does not switch the proxy every 5 minutes. It merely says that if a proxy has a start time greater than 5 minutes, switch it. If this isn't called within that 5 minute window, it will do no good. It might be better to use cron for this.
  7. This was bashed together, not tested, and not made in good coding standards. My IDE screamed at me the whole time, but I put my headphones on while it wept. function getProxy(){ /* Database connection stuff goes here */ $base_sql = "SELECT proxy FROM `proxies` WHERE date_started > NOW() - INTERVAL 5 MINUTE and used=0;"; $get_expired_sql = "SELECT id FROM `proxies` WHERE USED=0 ORDER BY id ASC limit 1;"; $expired_sql = "UPDATE proxies SET used=1 WHERE id='$id'; SELECT proxy FROM proxies WHERE used=0 LIMIT 1 ORDER BY id ASC;"; $reset_proxy_sql = "UPDATE proxies SET used=0; SELECT proxy FROM proxies WHERE used=0 LIMIT 1 ORDER BY id ASC;"; /* First, lets see if we have an active proxy */ $res = mysql_query($base_sql); if (mysql_num_rows($res) == 0){ // Well, that one is expired. Lets see which one is next $res = mysql_query($get_expired_sql); $row = mysql_fetch_assoc($res); $id = $row['id']; $res = mysql_query($expired_sql); $row = mysql_fetch_assoc($res); if (mysql_num_rows($row) == 0){ // Well, we're out of current proxies. time to reset $res = mysql_query($reset_proxy_sql); $row = mysql_fetch_assoc($res); $proxy = $row['proxy']; mysql_query("UPDATE proxies set date_started=NOW() where proxy='$proxy';"); } else{ $proxy = $row['proxy']; mysql_query("UPDATE proxies set date_started=NOW() where proxy='$proxy';"); } } else{ $row = mysql_fetch_assoc($res); $proxy = $row['proxy']; } return $proxy; } ** EDIT: forgot to return something...*sigh* ***EDIT 2: Man, I need to spend more than 5 minutes on code. I forgot to update the proxies to tell it the start time.
  8. That is why you select after reset, without the date factor. you find the one that is next, set the date_started, and go at it all over again.
  9. When a proxy expires, you would do this: UPDATE proxies SET used=1 WHERE proxy='CURRENT PROXY IP GOES HERE'; SELECT proxy FROM proxies WHERE used=0 LIMIT 1 ORDER BY id ASC; If that comes up with zero results, you run this: UPDATE proxies SET used=0; SELECT proxy FROM proxies WHERE used=0 LIMIT 1 ORDER BY id ASC;
  10. Have you went to the WSDL page with a SOAP browser to see the defined methods? Unfortunately, SOAP is something you have to learn. Not quite something most people will code for you. Just go http://59.162.33.102/ArzooWS/services/DOMFlightAvailability%22 and click on the part you want to do. It will tell you the fields and what you can request. Again, there is a learning curve to SOAP, but there are tons of resources out there to help you learn it.
  11. not quite. NOW() is what you want, so it would be: SELECT proxy FROM `proxies` WHERE date_started > NOW() - INTERVAL 5 MINUTE and used=0; This will find any proxy who has a start time more recent than 5 minutes before the current time (i.e., it's still current) make sure to count the results before using them, and if they are zero, rinse and repeate.
  12. add a column with datetime, and name it "date_started" with an index on it. When the time now - INTERVAL 5 MINUTE > date_started, mark it used, and go on to the next. run a select COUNT(id) on proxies where used != 1 when you mark one used. If count comes back zero, update table proxies set used = 0; then start over (I intentionally didn't give the exact proper SQL syntax, so you have a little work to do)
  13. The OP is a kid (watch the video). Based on the voice, I would guess around 12 or thereabouts. Matt, let me say this to you, from a fathers perspective: Think before you act. What you are building I fully understand seems like an awesome idea to you, but it's been done time and time again. Based on the speed that your page loaded in your browser, I'm going to guess shared hosting. *did some research -- back* Ok, kid. you don't want any part of the hosting you're with. 2 reasons why: no email provider in their right mind will allow mail from that hosting. They are full, and I mean chock full of spam sites. They will be black listed across the board, and any information you provided to sign up is most likely being used for nefarious means. Also, sites like this get flagged by 3-letter agencies so fast it is amazing you don't see them outside your house right now. Don't worry, that was a figure of speech. Basically, people who host on this type of site are usually people like Dotcom (but less rich). Even thoug I aplaud your first real project, I would recommend that you do something....less spammy. If you need pointers on what project to take up, let me know. I'll help you code one, even. Jon
  14. Here's an easier way, if you don't mind my complete rewrite of your way of donig it: <?php function RandomPassword($len){ $char_array = array(); for ($i =48; $i<=126;$i++){ $char_array[] = char($i); } $count = 0; $pass = ""; while ($count < $len){ $pass .= $char_array[array_rand($char_array)]; $count++; } return $pass; } //Usage example: $pass = RandomPassword(rand(8,15)); echo $pass; ?> The function will generate an array of characters based on the ASCII table, then select random characters until it reaches the length you select. In my sample call, it selects a random password with a random length between 8 and 15 characters long. EDIT: forgot a couple things EDIT 2: Man, I need sleep. Forgot that if I start with "0", the proper number will be one less than your required lenght.
  15. Could you provide the entire error? It will say the function not defined.
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.