
MySQL_Narb
Members-
Posts
250 -
Joined
-
Last visited
Everything posted by MySQL_Narb
-
How does one simply...."grab" that image?
MySQL_Narb replied to MySQL_Narb's topic in PHP Coding Help
I figured it out. I was making an unnecessary request. Appreciate all the help. -
How does one simply...."grab" that image?
MySQL_Narb replied to MySQL_Narb's topic in PHP Coding Help
Well, is it possible to download a CAPTCHA image without "requesting" it again (maybe from a page that is already loaded)? Say you use cURL to load the page and grab the url of the image; you then tell cURL to download that image in the URL. It downloads the CAPTCHA image; however, when you go to download the image, is that not another request resulting in a changed CAPTCHA picture? -
Hi, I've been working on this problem for the past hour. I can't seem to figure out how to save a CAPTCHA image. As we all know, a CAPTCHA image is only generated once. So this complicates things for me. http://api.solvemedia.com/papi/challenge.noscript?k=YofwLNxxBvEMSuDl.BVlHV-zV-MV8L61 As you can see in the above URL, any attempt to visit the direct image link will still result in a new image. Is there any possible way to get the image as is when you first load the webpage? I'm starting to think this is near impossible in PHP.
-
Whenever I create my scripts, it's easy enough to just put in "localhost."; however, how do I obtain the actual host name of the MySQL database for third-party connections?
-
I need to be communicating through the TCP/IP protocol.
-
I just finished up a PayPal IPN script for a website we're working on; however, when a user buys "points", we need to somehow get it to the game server (where they can buy in-game items with there new virtual points). Let's assume this server is a Minecraft server. How would I, with PHP, be able to send something along the lines of a packet to say: "Hey, so and so now has 200 points. Update their point count."
-
I'm trying to make a cool little script that reads the shoutbox on a site, and makes automatic replies with a AI API. However, when I try to access the site in cURL, it's as if it's getting blocked or something. curl_setopt($ch, CURLOPT_REFERER, 'http://nodusgriefing.com/index.php'); curl_setopt($ch, CURLOPT_USERAGENT, 'Mozilla/5.0 (Windows NT 6.1; WOW64; rv:14.0) Gecko/20100101 Firefox/14.0.1'); As you can see, I did try setting the user agent; however, it was to no avail. All I see is a blank page, and the tab title is just "->". Any ideas on how I can go about this?
-
//do some validation on the url if($url == 'http://www.youtube.comhttp://www.youtube.com'): $url == 'http://www.youtube.com'; elseif(preg_match('~youtube.com\/\/(.+?)~', $url)): $url = preg_replace('~.com\/\/~', '.com/', $url); endif; VS. //do some validation on the url if($url == 'http://www.youtube.comhttp://www.youtube.com'){ $url == 'http://www.youtube.com'; }elseif(preg_match('~youtube.com\/\/(.+?)~', $url)){ $url = preg_replace('~.com\/\/~', '.com/', $url); echo $url; } The second one is usually what I do, but it always gives me a bad feeling just leaving the "elseif" there as if there's always suppose to be an "else" to end a elseif statement. Not sure why I have this feeling. :/
-
Not too sure if this helps, but there's an entire page on it. http://php.net/manual/en/function.stripos.php
-
In the PHP section because I believe the error is on the PHP side. I got my index page: <html> <head> <title>YTBypass</title> <script type="text/javascript" src="jquery.js"></script> <script type="text/javascript"> $(document).ready(function(){ requestPage(); $('a[href]').click(function( e ){ e.preventDefault(); url = $(this).attr('href'); url = (url == '/') ? 'http://www.youtube.com' : url; requestPage(url); }); function requestPage(pageURL){ $('#loading').show(1500); //request page $.ajax({ url: 'getpage.php?page='+ pageURL }).done(function( retrn ){ $('#loading').hide(0); if(retrn == 'fail'){ alert('Failed to request page.'); }else{ alert(retrn); $('#content').html(retrn); } }); } }); </script> </head> <body> <div id="loading" style="display:none;"> <b><font size="4">Your request is loading...</font></b> </div> <div id="content"> </div> </body> </html> As you can see, it calls this page upon loading: <?php $url = (!isset($_GET['page']) || empty($_GET['page'])) ? 'http://www.youtube.com' : $_GET['page']; //initiate $ch = curl_init(); //set cURL data curl_setopt($ch, CURLOPT_URL, $url); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); //execute & close $page = curl_exec($ch); curl_close($ch); echo $page; ?> applesauce But for some reason, it doesn't seem to grab the data from the $page variable that the PHP code echoes out. It only returns applesauce.
-
Hah, wow. I always know it's something so simple, but no matter how long I look through the code I miss these things. Thanks.
-
<!DOCTYPE html> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> <title>Pfft</title> <style> body { background-color:black; } .post { padding:25px; margin-left:auto; margin-right:auto; background-color:#980000; border:1px solid #580000; width:650px; } .message { margin-left:auto; margin-right:auto; background-color:#980000; border:1px solid #580000; width:650px; } .hidden { display:none; } </style> <script type="text/javascript" src="jquery.js"></script> <script type="text/javascript"> $(document).ready(function(){ var step1 = $('#step1'); var step2 = $('#step2'); $('input[name="type"]').change(function(){ hideAll(); step2.show('fast'); if($('input[name="type"]:checked').val() == 'posts'){ $('tr[id="is_posts"]').show(); } }); $('button[name="reset"]').click(function(){ hideAll(); step1.show(); $('input[name="thread"]').val(''); $('input[name="forum"]').val(''); $('textarea[name="content"]').val(''); }); function hideAll(){ step1.hide('fast'); step2.hide('fast'); } }); </script> </head> <body> <div class="post"> <form action="index.php" method="POST"> <div id="step1"> <input type="radio" name="type" value="threads">Threads or <input type="radio" name="type" value="posts"> Posts </div> <div id="step2" class="hidden"> <table> <tr> <td>Forum ID<td/> <td><input type="text" name="forum"></td> </tr> <tr id="is_posts" class="hidden"> <td>Thread ID</td> <td><input type="text" name="thread"></td> </tr> <tr> <td><button name="step3">Continue</button></td> <td><button name="reset">Reset</button></td> </tr> </table> </div> </form> </div> <?php if(isset($_POST['message']) && ctype_digit($_POST['amount'])){ ?> <div class="message"> Your messages are being sent. </div> <?php } ?> </body> </html> Whenever the tr with the id #is_posts isn't hidden, the first tr in the table becomes deformed. Here's a picture: http://puu.sh/24laL
-
First attempt at designing an MVC for my new project
MySQL_Narb replied to MySQL_Narb's topic in Application Design
There's more than one file.... It's all in the attachment. -
First attempt at designing an MVC for my new project
MySQL_Narb posted a topic in Application Design
I have a new project that will replicate an existing forum software that is very unique; I've done it before, but I want to do it again with better designed code. I've been looking into using the MVC pattern, and would like to make sure I'm on the right track. I've read several online articles about MVCs and checked out some examples, so I want to make sure I properly understand it. So basically, could anyone take a quick look and tell me if I have the right idea? Thanks! http://www.mediafire...yk22l1n136bvjfq (or download attachment) MVC Base.zip -
Aha, thank you. Forgot about this. It turns out the string had extra whitespaces in it. Thanks.
-
FULL source: http://paste2.org/p/2847150 foreach($results as $result){ //skill name $skill = $result->firstChild->nodeValue; $info = $result->getElementsByTagName('td'); //skill info $rank = $info->item(1)->nodeValue; $level = $info->item(2)->nodeValue; $xp = $info->item(3)->nodeValue; if($skill != 'Skill'){ echo '<b>'. $skill .'</b> <b>'. $xp .'</b> <hr>'; if($skill == 'Overall' && $xp == '-'){ $exists = false; break; } //SKILL:RANK:LEVEL:XP $skill_info[] = $skill .':'. $rank .':'. $level .':'. $xp; } } In the above code, why doesn't the following if statement work: if($skill == 'Overall' && $xp == '-'){ $exists = false; break; } As you can see, I echoed out the variables and both are what they should be. I even checked the page source to see if there were any special surprises, and there wasn't. Any ideas? PICTURE OF ECHOED RESULTS: http://puu.sh/20E4q
-
Thank you. I was personally avoiding DOMDocument until I could spend some time to familiarize myself with it; however, I'll be sure to check it out once I finish my current project. I appreciate the help.
-
<div id="playerskills" align="center"> Personal scores for <br /><br /> <table> <tr> <td>Skill</td> <td>Rank</td> <td>Level</td> <td>XP</td> </tr> <tr> <td>Not Ranked</td> <td>-</td> <td>-</td> </tr> <tr> <td>Not Ranked</td> <td>-</td> <td>-</td> </tr> <tr> <td>Not Ranked</td> <td>-</td> <td>-</td> </tr> <tr> <td>Not Ranked</td> <td>-</td> <td>-</td> </tr> <tr> <td>Not Ranked</td> <td>-</td> <td>-</td> </tr> <tr> <td>Not Ranked</td> <td>-</td> <td>-</td> </tr> <tr> <td>Not Ranked</td> <td>-</td> <td>-</td> </tr> <tr> <td>Not Ranked</td> <td>-</td> <td>-</td> </tr> <tr> <td>Not Ranked</td> <td>-</td> <td>-</td> </tr> <tr> <td>Not Ranked</td> <td>-</td> <td>-</td> </tr> <tr> <td>Not Ranked</td> <td>-</td> <td>-</td> </tr> <tr> <td>Not Ranked</td> <td>-</td> <td>-</td> </tr> <tr> <td>Not Ranked</td> <td>-</td> <td>-</td> </tr> <tr> <td>Not Ranked</td> <td>-</td> <td>-</td> </tr> <tr> <td>Not Ranked</td> <td>-</td> <td>-</td> </tr> <tr> <td>Not Ranked</td> <td>-</td> <td>-</td> </tr> <tr> <td>Not Ranked</td> <td>-</td> <td>-</td> </tr> <tr> <td>Not Ranked</td> <td>-</td> <td>-</td> </tr> <tr> <td>Not Ranked</td> <td>-</td> <td>-</td> </tr> <tr> <td>Not Ranked</td> <td>-</td> <td>-</td> </tr> <tr> <td>Not Ranked</td> <td>-</td> <td>-</td> </tr> <tr> <td>Not Ranked</td> <td>-</td> <td>-</td> </tr> <tr> <td>Not Ranked</td> <td>-</td> <td>-</td> </tr> <tr> <td>Not Ranked</td> <td>-</td> <td>-</td> </tr> <tr> <td>Not Ranked</td> <td>-</td> <td>-</td> </tr> <tr> <td>Not Ranked</td> <td>-</td> <td>-</td> </tr> </table> </div> Do you guys have any idea as to why the following REGEX does not pickup the above code? ~<div id="playerskills" align="center">((.|\n)+?)</div>~m It works fine when the content between the divs is on one single line; however, with the HTML I provided, it tends to break due to the multiple lines. Any ideas? Thanks. Using http://gskinner.com/RegExr/ to test.
-
<tr> <td>3</td> <td>868</td> <td>9,167,674</td> </tr> <tr> <td>4</td> <td>60</td> <td>285,497</td> </tr> I'm curious, is there an easy way using preg_match to get the contents of the 3rd <td></td> occurrence?
-
Just wanted to post two quick questions about the usage of cURL. If I set CURLOPT_PROXY, do I have to re-declare it after every execution of the cURL handle/session (I'm assuming since it's a >session<, I don't - but I'd like to just make this clearer for myself)? Also, if you're using cURL to login to another website, does it store the cookies from that login during the entire session? Thanks.
-
The exact reasoning behind this. Easier control among everything.
-
I've been trying to make a more centralized OOP structure, where one class can ease communication between all other classes (server being the head/main class). Any feedback on this? <?php class server{ public function loadClass($class){ if($this->$class == null){ if(file_exists($class.'.php')){ include($class.'.php'); $this->$class = new $class(); }else{ $this->throwError('class '. $class.' does not exist'); } }else{ $this->throwError($class. 'already loaded.'); } } public function dropClass($class){ $this->$class = null; } public function runMethod($class, $method, array $params = array()){ if($this->isLoaded($class)){ if(count($params) != 0){ $par = ''; $i = 1; foreach($params as $key => $value){ $par .= ($i == count($params)) ? $method : $method.','; $i++; } } $this->$class->$method(($par != null) ? $par : null); }else{ $this->throwError($class .' is not loaded.'); } } protected function isLoaded($class){ return ($this->$class == null) ? false : true; } protected function throwError($error){ die('<font color="red">'. $error .'</font>'); } } ?> Example of usage <?php require('server.php'); $parent = new server(); $parent->loadClass('base'); $parent->runMethod('base', 'hey'); ?>
-
I have a field in my database called long_name (tinytext), what would be considered the neater code? (the below codes represent the value of what it will be when entered into the database) isset($_POST['long_name']) ? $_POST['long_name'] : '' or $_POST['long_name'] Is it really necessary, if the field from a form is empty, you should replace the null with '' Thanks.
-
Let me make my previous statement come to your attention: Also, ignore the missing echo before str_replace - it's there, just not when I copied it over. It's not being used to modify the original variable/value. I'm echoing the results of the str_replace function.
-
I do look in the view source, and it doesn't change. Also, ignore the missing echo before str_replace - it's there, just not when I copied it over.