Jump to content

Ninjakreborn

Members
  • Posts

    3,922
  • Joined

  • Last visited

Everything posted by Ninjakreborn

  1. [regex] if (preg_match_all('/<input type\=\"radio\"(.*?)\/>/is', $data, $matches)) { echo '<pre>'; print_r($matches); echo '</pre>'; }else { exit; } [/regex] I want to return everything that is a radio button. This does not work. Any advice. I have modified this from Regex I was using to get everything in a select option list (which works fine), it's just this modified version to get radio results, does not work. I may want to restrict it to only ones with a certain name after this, but right now I just want to get the basic working. Any advice?
  2. I do really need to learn them. Maybe I will play with it more and try. I am going to try out some of these web interfaces with 1and1 and see how they work. These look promising. Thanks for the link, this should help a lot.
  3. I have always had issues with Cron Jobs. I am not much of a server tech, and I have always had issues setting up crons. Mostly because I can never get the timing to actual work, even if it's been added to the cron (I have only really tried on 1and1.com servers). So is there a third party system that'll service cron URL's at specified times? Or perhaps, a cron system that is third party, but is reliable? Or is there another method to do PHP scripts on timed intervals without having to setup a cron.
  4. <?php /* Register footer widget */ if (function_exists('register_footercounter') ) register_footercounter(array( 'before_widget' => '', 'after_widget' => '', 'before_title' => '', 'after_title' => '', )); ?> How exactly does this syntax work. I am not use to seeing this. It is an if statement without brackets. It uses a function inside of it with an array. So, I do not exactly understand what is happening here. I have used php for a long time and just now started working with Wordpress awhile back, and reviewing how to do themes, and I am seeing this kind of funky syntax all over the place. Thanks again.
  5. I think I am going about this the wrong way. Instead, I am going to break it up into a few different options. I will do the core stuff in a cron, and do the rest dynamically on the fly. Thanks again for the feedback about Flush.
  6. I am not trying to show to browser. I am writing a crawler. It is going to be used to get data from a site. Eventually it's going to be doing three prime operations (one for each site). Right now, it's only getting data from one site. I have gotten all the code done to get the data from the site. I needed it in an array, so I can loop through it and put it into an array. SO, that's the weird part. It's entirely not working. I mean it loads for a LONG time, then goes to a "Error" page in Chrome, and a "Internet Connectivity" error page in IE. Strange. I will try the flush content, and see how that goes. I need to do something to allow it to finish loading.
  7. I have a PHP Page. It is doing a lot of site crawling, throughout a lot of loops. Basically it's getting a massive array together and it's huge. However, it's so big that PHP times out beyond belief. I mean there is no error or nothing. Google throws a major error about page not found, IE shows an internet connection error. It really times out big time. Even though it's not really "A LOT". Any advice on what to do in that situation. I can't show the site/code because of NDA, but was curious if someone had ever done that much work on a PHP page before to have it do that?
  8. I tried using that extensively as well as tried many things with HTML Simple Dom. The stuff I am trying to do doesn't seem to be working here. Is it easier/better to parse HTML using Regex and getting what you need as you need it from the pages instead?
  9. This doesn't work. Based off what I have seen online, it is suppose to. Basically, this is what I tried, and the quote is what was returned. I have no idea how to get this to work. It should have been pretty standard based off of the PHP documentation. The Xpath idea I got from someone else. Either way if I try to use find element by id or tag name it still returns an empty array, no matter what. Any advice on what I am doing wrong is appreciated. It doesn't matter what URL I try, none of them seem to work. <?php $school_data = file_get_contents('http://www.infotechnologist.biz'); $doc = new DOMDocument(); $doc->validateOnParse = true; $doc->loadHTML($school_data); $xpath = new DOMXPath($doc); $tags = $xpath->query('div'); echo '<pre>'; print_r($tags); echo '</pre>'; ?>
  10. I echo'd the post variables on my script, then pulled up the one for the site I am trying to get data from using Firefox by looking at the Post requests. They matched up. I am not sure about the other stuff. This is one of my first times working with Curl.
  11. I am trying to go to http://lirr42.mta.info/ and get the data from the submitted form. I have rebuilt the form exactly as needed, and done a few adjustments. The posts that I am sending from MY form, are the same as the one on the site. This site allows public data mining by the way. So does someone seem something wrong with my code? I know the basics are working. I have another page that is working fine. It's just this one ends up returning something..it returns part of the data but it's something wrong with it. Any advice is appreciated. <?php define( 'DEBUG', true ); define( 'DEFAULT_STOP', 'Broadway' ); // report all errors during development/debug mode if ( DEBUG ) error_reporting( E_ALL ); else error_reporting( 0 ); include( 'simplehtmldom/simple_html_dom.php' ); $mta_post_url = 'http://lirr42.mta.info/schedules.php'; // GTFS Specification File Definitions $gtfs_files = array ( 'agency' => 'agency.txt', // required 'stops' => 'stops.txt', // required 'routes' => 'routes.txt', // required 'trips' => 'trips.txt', // required 'stop_times' => 'stop_times.txt', // required 'calendar' => 'calendar.txt', // required 'calendar_dates' => 'calendar_dates.txt', 'fare_rules' => 'fare_rules.txt', 'fare_attributes' => 'fare_attributes.txt', 'shapes' => 'shapes.txt', 'frequencies' => 'frequencies.txt', 'transfers' => 'transfers.txt' ); $gtfs_pickup_codes = array ( 0 => 'Regularly scheduled pickup', 1 => 'No pickup available', 2 => 'Must phone agency to arrange pickup', 3 => 'Must coordinate with driver to arrange pickup' ); $gtfs_dropoff_codes = array ( 0 => 'Regularly scheduled drop off', 1 => 'No drop off available', 2 => 'Must phone agency to arrange drop off', 3 => 'Must coordinate with driver to arrange drop off' ); // load stops file $stopsFile = fopen( 'data/lir/' . $gtfs_files[ 'stops' ], "r" ); if ( $stopsFile ) { // get (and toss) header row $stopsHeader = fgetcsv( $stopsFile, 1000 ); // print_r( $stopsHeader ); // will hold HTML output for Select dropdown for stops $stopSelectOptions = ''; // build array from file data while ( $data = fgetcsv( $stopsFile, 1000 ) ) { $stopsData[ $data[1] ] = $data[0]; } // get a sorted array of the stop names ( yes this could be done with array_multisort or usort but I didnj't feel like it right now ) $stopNames = array_keys( $stopsData ); sort( $stopNames ); // loop through sorted array and create SELECT options with default SELECTED at Grand Central Terminal foreach( $stopNames as $stop ) $stopSelectOptions .= sprintf( '<option %s value="%d">%s</option>', ( DEFAULT_STOP == $stop ) ? 'selected="selected"' : '' , $stopsData[ $stop ], $stop ) . "\n\r"; } fclose( $stopsFile ); // load ads file $adsFile = fopen( 'ads.txt', "r" ); if ( $adsFile ) { // get (and toss) header row $adsHeader = fgetcsv( $adsFile, 1000 ); // will hold ads available for stops $ads = array(); // build array from file data while ( $data = fgetcsv( $adsFile, 1000 ) ) { $ads[ $data[0] ] = array ( 'filename' => $data[1], 'url' => $data[2], 'text' => $data[3] ); } fclose( $adsFile ); } // printout the html header require_once( 'header.php' ); if ( 'POST' == $_SERVER[ 'REQUEST_METHOD' ] ) { $from_stop = $_POST[ 'FromStation' ]; // @todo Filter! http://www.php.net/manual/en/filter.filters.validate.php $orig_station = $from_stop; $to_stop = $_POST[ 'ToStation' ]; // @todo Filter! http://www.php.net/manual/en/filter.filters.validate.php $dest_station = $to_stop; if ( $to_stop == $from_stop ) { $error = 'Originating and Destination stops are the same.'; } else { print_ad( $orig_station, $dest_station, $location='top' ); $travel_date = $_POST[ 'RequestDate' ]; $requestTime = $_POST[ 'RequestTime' ]; $am_pm = $_POST[ 'RequestAMPM' ]; $filter = $_POST[ 'sortBy' ]; /* * Lets post this to MTA.info */ $mta_curl = curl_init(); $mta_curl_options = array ( CURLOPT_FAILONERROR => true, CURLOPT_FOLLOWLOCATION => false, // CURLOPT_MUTE => true, CURLOPT_POST => true, CURLOPT_RETURNTRANSFER => true, CURLOPT_CONNECTTIMEOUT => 30, CURLOPT_TIMEOUT => 30, CURLOPT_URL => $mta_post_url, CURLOPT_REFERER => 'http://lirr42.mta.info/', CURLOPT_USERAGENT => 'MTA Info Scrape/1.0', CURLOPT_POSTFIELDS => http_build_query( $_POST ) ); curl_setopt_array( $mta_curl, $mta_curl_options ); $mta_response = curl_exec( $mta_curl ); if ( false === $mta_response ) { curl_close( $mta_curl ); die( sprintf( 'Response Code:%s, Curl Error No:%s, Curl Error Message:%s', curl_getinfo( $mta_curl, CURLINFO_HTTP_CODE ),curl_errno( $mta_curl ), curl_error( $mta_curl ) ) ); } else { curl_close( $mta_curl ); echo '<pre>' . htmlentities( $mta_response ) . '</pre>'; $html = new simple_html_dom(); $html->load( $mta_response ); $schedule_table = $html->find( 'table', 0 ); // find second table in the response $row_count = 0; // will hold HTML output for table $stopSchedule = '<table><th>Departs</th><th>Arrives</th><th>Minutes</th><th>Transfer</th><th>Fare</th></tr>'; foreach ( $schedule_table->find('tr') as $schedule_row ) { $row_count++; // check for and skip header row if ( 1 == $row_count ) continue; // check for and skip last row which first TD has rowspan attribute if ( $schedule_row->children(0)->colspan ) { continue; } // extract table data for this row $depart_time = $schedule_row->children( 0 )->innertext; $arrive_time = $schedule_row->children( 2 )->innertext; $minutes_traveled = $schedule_row->children( 4 )->innertext; $transfer = $schedule_row->children( 5 )->innertext; $fare = $schedule_row->children( 6 )->plaintext; // add table row to html output $stopSchedule .= sprintf( '<tr><td>%s</td><td>%s</td><td>%s</td><td>%s</td><td>%s</td></tr>', $depart_time, $arrive_time, $minutes_traveled, $transfer, $fare ) . "\n\r"; } // end foreach schedule_row // add table end tag to html output $stopSchedule .= '</table>'; // output table to browser echo $stopSchedule; print_ad( $orig_station, $dest_station, $location='bottom' ); } // end if mta response } // end if not same orig and dest } // end if POST if ( 'GET' == $_SERVER[ 'REQUEST_METHOD' ] || ! empty( $error ) ) { print_ad( null, null, $location = 'default' ); ?> <form method="post"> <?php if ( ! empty ( $error ) ) { echo sprintf( '<div class="error">%s</div>', $error ); } ?> From:<br /> <select id="orig_station" name="FromStation" tabindex="2"> <?php echo $stopSelectOptions; ?> </select> <br /> <br /> To:<br /> <select id="dest_station" name="ToStation" tabindex="3"> <?php echo $stopSelectOptions; ?> </select> <br /> <br /> <input id="date1" name="RequestDate" size="12" maxlength="10" tabindex="4" value="<?php echo date( 'm/d/Y' ); ?>" /> <?php $currentHour = trim( date( 'h' ) ); $currentMinutes = trim( date( 'i' ) ); $currentMinutesFloor = sprintf( '%02d' , $currentMinutes - ( $currentMinutes % 30 ) ); $currentAMPM = trim ( date( 'A' ) ); $start_time = strtotime( '1:00 AM' ); $end_time = strtotime( '1:00 PM' ); ?> <select name="RequestTime" tabindex="5"> <?php while( $start_time < $end_time ) { $option_time = date( 'h:i', $start_time ); $option_hour = trim( date( 'h', $start_time ) ); $option_minutes = trim( date( 'i', $start_time ) ); $option_selected = ( $option_hour == $currentHour && $option_minutes == $currentMinutesFloor ); echo sprintf( '<option %s>%s</option>', ( $option_selected ) ? 'selected="selected"' : '', $option_time ) . "\r\n"; $start_time = $start_time + 30*60; } ?> </select> <select name="RequestAMPM" tabindex="6"> <option value="AM" <?php echo ( 'AM' == $currentAMPM ) ? 'selected="SELECTED"' : ''; ?>>AM</option> <option value="PM" <?php echo ( 'PM' == $currentAMPM ) ? 'selected="SELECTED"' : ''; ?>>PM</option> </select> <input name="sortBy" type="hidden" value="1" /> <input type="submit" name="submit" value="Check Schedule" /> </form> <!-- images/base/ ic_menu_back.png ic_menu_home.png --> <?php } require_once( 'footer.php' ); ?>
  12. Url: http://www.nrmkids.com Right now all the URLS do their own thing. Most of the time the structure is very simple. www.nrmkids.com/pagename. That is fine. For the products listing it's www.nrmkids.com/pagename/category Then for the product details view it's www.nrmkids.com/pagename/category/productid Those are all great. There is one problem. If you go to the site and click on "Kids Wall Art" or "Boys Wall Art" it takes them to the right page www.nrmkids.com/pagename/categorynumber Which is great. Well that works, when they also click on a product that is great. However, I need for it to be different for the pagination> If you click on the next page in Pagination (for example with Bosy Wall Art) it does this. http://www.nrmkidswallart.com/index.php?page=2&c=1 What I want to do is change that to still have boyswallart in the name. I want to do the same for kidswallart, and girlswallart. However that conflicts with the other URLS (like for showing product details). Does anyone have any advice on this. HTAccess File RewriteEngine on php_value upload_max_filesize "10M" php_value post_max_size "10M" php_value memory_limit "256M" RewriteCond %{HTTP_HOST} ^nrmkidswallart.net$ [OR] RewriteCond %{HTTP_HOST} ^www.nrmkidswallart.net$ RewriteRule ^(.*)$ "http\:\/\/www\.nrmkidswallart\.com\/$1" [R=301,L] RewriteCond %{HTTP_HOST} ^nrmkids.com$ [OR] RewriteCond %{HTTP_HOST} ^www.nrmkids.com$ RewriteRule ^(.*)$ "http\:\/\/www\.nrmkidswallart\.com\/$1" [R=301,L] RewriteBase / RewriteRule ^([a-zA-Z0-9_-]+)$ index.php?page=$1 RewriteRule ^([a-zA-Z0-9_-]+)/$ index.php?page=$1 RewriteRule ^([a-zA-Z0-9_-]+)/([a-zA-Z0-9_-]+)$ index.php?page=$1&c=$2 RewriteRule ^([a-zA-Z0-9_-]+)/([a-zA-Z0-9_-]+)/$ index.php?page=$1&c=$2 RewriteRule ^([a-zA-Z0-9_-]+)/([a-zA-Z0-9_-]+)/([a-zA-Z0-9_-]+)$ index.php?page=$1&c=$2&p=$3 RewriteRule ^([a-zA-Z0-9_-]+)/([a-zA-Z0-9_-]+)/([a-zA-Z0-9_-]+)/$ index.php?page=$1&c=$2&p=$3 RewriteRule ^([a-zA-Z0-9_-]+)/([a-zA-Z0-9_-]+)/([a-zA-Z0-9_-]+)/([a-zA-Z0-9_-]+)$ index.php?page=$1&c=$2&p=$3&ct=$4 RewriteRule ^([a-zA-Z0-9_-]+)/([a-zA-Z0-9_-]+)/([a-zA-Z0-9_-]+)/([a-zA-Z0-9_-]+)/$ index.php?page=$1&c=$2&p=$3&ct=$4 RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule . /index.php [L]
  13. http://stackoverflow.com/questions/2265055/how-to-get-google-maps-api-to-set-the-correct-zoom-level-for-a-country I found this link. It shows me how to zoom to a country in Google Maps. I am trying to do the same thing with Google Earth, and it's not working. Does anyone know how to zoom into a specific country using Google Earth by just the country name (like it does in Google Map). I have been digging through Google API Documentation, and Google and have found no evidence yet of how to do this. Thanks again.
  14. I am working on an existing system. It has the GD library (I think). The system is very hard to understand because of how it was built. Either way, I am trying to add new fonts. I notice each font the other developer uses has a .php, .ttf, .t18 and .afm. Each one of the font has each one of those files, named the same as the font. I am going crazy, trying to figure out how to add more fonts. The client has requested that I add another 5-15 fonts. Pretty much whatever I can get my hands on. So I was curious, where can I find these kinds of fonts. Since there is a .php file, I assumed this was located somewhere as a php resource. I have search all over, but don't know what I am looking for. Or do I have to use any font, and then custom build the php file for that font, based off how that font works. How would someone learn how the internal workings would work, for a specific font?
  15. OK I got one of the queries working. Thanks, I forgot about those reserved words. however, there is one more query. 'I don't see anything else in this query that is a reserved word, and the code looks fine. Any more words I am missing on this one. I think I got them all, I got or and to and those were the only ones I have seen here.
  16. CREATE TABLE " . $table_name4 . " ( user_id int(11) NOT NULL, rpg int(11), apg int(4), stpg int(4), bpg int(4), ppg int(4), threepg int(4), topg int(4), ft_percent int(4), ftmpg int(4), fg_percent int(4), fgapg int(4), rstd int(4), astd int(4), ststd float(10,, bstd int(3), pstd int(4), threestd int(4), tostd int(4), ftstd int(4), ftmstd int(4), fgstd int(4), mod int(4), score int(4), rank int(4) ) ENGINE=MyISAM; CREATE TABLE " . $table_name5 . " ( user_id int(11) NOT NULL, gp int(11), min int(4), fgm int(4), fga int(4), threem int(4), threea int(4), ftm int(4), fta int(4), or int(4), tr int(4), as int(4), st int(4), to int(4), bk float(10,, pf int(3), dq int(4), pts int(4), tc int(4), ej int(4), ff int(4), sta int(4), rpg int(4), apg int(4), stpg int(4), bpg int(4), ppg int(4), threepg int(4), topg float(10,, ft_percent int(3), ftmpg int(11), fg_percent int(11), fgapg int(11) ) ENGINE=MyISAM;"; I am building a wordpress plugin. The syntax on these queries seems to be wrong. I have tried manually removing them and putting them into Mysql PHPMyadmin but it still returns syntax error. Is there anything wrong with these two table creation sql scripts.
  17. Actually I think I am good. This tutorial code is working out well. Saves me from having to write it. I just used the same table definition. Then I am rewriting the entry code into a Collector_model in Codeignitor. Then all I need is a display page. I think this'll work pretty well, and took me under 20 minutes. Thanks again for the feedback. I had ran across this code shortly after posting here. I was originally looking through Google for scripts and things, and then ended up doing a search on tutorial to see if I could find written code to make it faster.
  18. I want to keep it really simple. So far I am thinking of using code from http://www.devshed.com/c/a/PHP/Tracking-Website-Statistics-with-PHP/ To get it done. I was just wanting to see if there was a third party class, or script I haven't messed with. I am guessing it would take me about an hour or 2 to build something decent, and I want to avoid that time. Mostly looking for basic information, IP address, page from, page on, and some other basic details. I am currently thinking about implementing the code in that tutorial. But if someone knew of a class that they have used before, or something that they re-use that would be even cooler.
  19. Anyone know of a really good third party system that manages stat information. I have seen a lot, but I am looking for one that is really easy to plug in play. If possible. I can build one, but it's on an existing project and it's a new feature they are wanting. I am wanting to try and see it very simple instead of trying to build the entire thing from scratch. Any advice is appreciated, thanks.
  20. If your working with Yahoo API, or Yahoo Scraping, is there a way to detect the 999 error. I have an App that deals heavily with Yahoo scraping. However, Yahoo after awhile has the 999 error. What I want to do is detect when it returns the error, serialize all the arrays up into a database, and allow the client to try it again later when Yahoo has removed it's blocking restriction (after about an hour). So, what I have thought about is doing a standard detection script. Just to see if the text 999 was found. SO the function that I use to get data from Yahoo, after awhile it returns: What I want to do is supress that error (Which I can do with Error Reporting, or the @ symbol. That is easy. What I also want to do is put up a conditional. if (file_get_contents($url) throws a warning) { // Do some database work. } I can't figure out the best way to approach this. Any advice?
  21. Wow, very nice. I took what you posted and adapted it to my code. It works great. Thanks again.
  22. Here is what I have created so far. This does what I want, but screws up the file. <?php require_once('config.php'); $file_id = mysql_real_escape_string($_REQUEST['file_id']); $sql = "SELECT * FROM order_files WHERE file_id = '" . $file_id . "'"; $query = mysql_query($sql); header("Content-Type: application/force-download"); while ($row = mysql_fetch_array($query, MYSQL_ASSOC)) { $file = '../' . $row['file_name']; $filename = explode('/', $file); $filename = $filename[2]; header( "Content-Disposition: attachment; filename=../" . $filename); } echo $file; if (file_exists($file)) { readfile($file); } ?> It does prompt download no matter what the filetype is. The only bad thing is, it messes up the file. So if it's an image file, it won't let me open that image file. If it was a PDF it corrupts it. I don't want to have to do a file detection, because I am not sure what all types of files it might be. It could be virtually any type of file. Without having to analyze every possible extension.
  23. Is there a way (in PHP) to prompt to download file regardless of it's type? I have taken someone's suggestions and put files in a folder with HTAccess protection. ALL I want to do is just grab the files and prompt download (regardless of what the type of file is), is there an easy way to do this in PHP.
×
×
  • 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.