|
magicalblender posted:How about something like this: Perfect, thanks! Knew it would be easy...
|
# ? May 25, 2008 23:47 |
|
|
# ? May 15, 2024 11:16 |
|
bt_escm posted:I found this http://www.webservicex.com/airport.asmx and I was able to get a couple of coordinates for a few airports. Thats not quite as comprehensive as I'd like. Anyways, I found airnav.com, which is 100% comprehensive for american airports, which is about as good and I'm going to find I'm afraid. Now, I'm wondering, whats the best way to go about mining the data from the page? I'm looking around the web, but I'm not finding much on how to actually build a web crawler... Anyone know of any good resources/tools for doing something like this?
|
# ? May 26, 2008 00:58 |
|
nbv4 posted:Thats not quite as comprehensive as I'd like. Anyways, I found airnav.com, which is 100% comprehensive for american airports, which is about as good and I'm going to find I'm afraid. To be honest you're best off using Google Maps. If you notice that searching "KBOS" or "LAX" or "LGW" in Google Maps brings up the airport in question it's jut matter of using the API to get the latitude and longitude (or whatever information you're looking for). Much simpler than parsing a page of tables (which the airnav.com page is) to extract data.
|
# ? May 26, 2008 01:29 |
|
Evil Angry Cat posted:To be honest you're best off using Google Maps. If you notice that searching "KBOS" or "LAX" or "LGW" in Google Maps brings up the airport in question it's jut matter of using the API to get the latitude and longitude (or whatever information you're looking for). Much simpler than parsing a page of tables (which the airnav.com page is) to extract data. The reason I wanted to use airnav is because the information is 100% reliable. Relying on Google hits just doesn't seem very robust to me. But anyways, for the hell of it I looked into using the google API, and so far the results I've gotten have been pretty good, so gently caress it, I'll just use google. I have one problem though: Here is the PHP function that I wrote that gets the coordinates and then puts them into the database: code:
nbv4 fucked around with this message at 03:35 on May 26, 2008 |
# ? May 26, 2008 03:20 |
|
nbv4 posted:There is a 3 or 4 second delay for the link to return the XML, which adds to to a lot when you have 500 airports to look up. When I load the page that ends up running this function, the page will just hang until it's 100% done, then display all the contents. What kind of voodoo am I going to have to perform to have it print out the stuff progressively, so the user doesn't think the site is down or something? Does the location of an airport change really frequently or something? Couldn't you just go through the 500 airports once, storing it in a DB, like it seems you are, and query that when you want to display a page? If you can't or don't want to do that for some reason, you could use AJAX, and create a page that has some javascript in it that calls another php script that queries Google for that airport, filling in some element of the page when it's received the location. The first page will load as quickly as is normal, and there are plenty of js frameworks that handle the AJAX bit very easily.
|
# ? May 26, 2008 04:34 |
|
No matter where I put the function alphanumeric part I always get:code:
code:
|
# ? May 26, 2008 06:59 |
|
Phase posted:No matter where I put the function alphanumeric part I always get: Spell it the same way as when you defined it?
|
# ? May 26, 2008 07:20 |
|
magicalblender posted:How about something like this: This would be so much better as a regular expression php:<? $phone = '2145551212'; $formattedString = preg_replace('/(\d{3})(\d{3})(\d{4})/','$1-$2-$3',$phone); ?>
|
# ? May 26, 2008 11:10 |
|
bt_escm posted:This would be so much better as a regular expression Although I think considering the user is so new to php that he thought splitting a string required some sort of loop, substr() is a better method than reg exps.
|
# ? May 26, 2008 12:08 |
|
Evil Angry Cat posted:Although I think considering the user is so new to php that he thought splitting a string required some sort of loop, substr() is a better method than reg exps. Perhaps, but at least now they've seen two ways to do it, and have been given some exposure to a valuable tool. bt_escm fucked around with this message at 15:51 on May 26, 2008 |
# ? May 26, 2008 15:47 |
ilikechapstick posted:Quick question about PHP, I have used it only a couple times and have very limited PHP knowledge. I hope you don't get paid much to "design the webpages" since you can't even google 3 words. http://www.google.com/search?hl=en&safe=off&q=php+phone+format&btnG=Search
|
|
# ? May 27, 2008 08:21 |
|
fletcher posted:I hope you don't get paid much to "design the webpages" since you can't even google 3 words. To be fair design and development although sometimes combined (sometimes in the same person) are usually at opposite ends of the spectrum. I wouldn't ever expect our design team to be able to do that.
|
# ? May 27, 2008 08:46 |
MrEnigma posted:To be fair design and development although sometimes combined (sometimes in the same person) are usually at opposite ends of the spectrum. I wouldn't ever expect our design team to be able to do that. You can just google it and copy paste the examples with 0 knowledge
|
|
# ? May 27, 2008 10:22 |
|
bt_escm posted:Your authentication scheme is fine for a basic site. I'm assuming you have a collection of php pages that contain the layout and any processing logic in them. Doing that is fine for a smaller site or a site that doesn't really do anything. If you goal is to try and build something more complicated than a site with bunch of content and a few contact forms, then I recommend looking into a framework. When you say framework, would something like PEAR's Auth be adequate?
|
# ? May 27, 2008 19:13 |
|
Right now I am building a website that requires users to have the ability to rate and review things. I have very little PHP knowledge, so I would not know where to start coding a system like this. The perfect system would be something like this: http://cityguide.aol.com/washington/bars_and_clubs/ugly-mug/v-190049/ With mySQL integration, etc. It only needs to have 3 simple things, their name, their review, and their rating. I've been scouring the internet for even tutorials on how to write a system like that but haven't found any. Was wondering if maybe you guys knew of anything out there like this?
|
# ? May 27, 2008 23:26 |
ilikechapstick posted:I've been scouring the internet for even tutorials on how to write a system like that but haven't found any. Was wondering if maybe you guys knew of anything out there like this? Did you not like these?
|
|
# ? May 27, 2008 23:35 |
|
Grigori Rasputin posted:When you say framework, would something like PEAR's Auth be adequate? Yes, pear_auth would be fine. By framework I was talking about a framework like the zend framework, cake or syphony or any of the other dozen or so php frameworks.
|
# ? May 28, 2008 02:55 |
|
I'm writing a calendar script for event/project tracking and am trying to figure out how to get the end days of the previous month and/or the beginning days of the following month to fill the calendar.
|
# ? May 30, 2008 21:21 |
|
date('t', $timestamp) will give you the number of days in the timestamp's month.
|
# ? May 30, 2008 21:24 |
|
cal_days_in_month() is fun too.
|
# ? May 31, 2008 00:32 |
The PEAR Calendar object may also be useful to you.
|
|
# ? May 31, 2008 00:48 |
|
I'm working on a little script to let me download an entire directory as an archive instead of file by file. It's kind of a PHP learning project for me, but here's my first stab at it:code:
Also, I'm not sure that my ad hoc text formatting via addcslashes is going to catch all of the cases that might cause problems. Is there another standard method I should be using? What about directories that have an & in the name? How can I pass those through $_GET?
|
# ? Jun 1, 2008 20:36 |
|
iCasm posted:I'm working on a little script to let me download an entire directory as an archive instead of file by file. It's kind of a PHP learning project for me, but here's my first stab at it: Well you really don't want to drop any variables directly from a GET into a shell command, filter them or do something to prevent that from happening. But if you must do it at least use escapeshellarg (http://us3.php.net/manual/en/function.escapeshellarg.php), this will make it somewhat safe (and prevent you from doing doing addslashes/strreplace). As far as deleting the file, look into register_shutdown_function, basically when the script dies it will automatically call the function you specify, in this case you would want to have it call a function that calls unlink. There are also some built in zip functions in php, and if you can use something built in, it's almost always better than having to run stuff directly on the server to get something done, then again the zip stuff might not work for you (http://us3.php.net/manual/en/ref.zip.php) Edit: Some clarification MrEnigma fucked around with this message at 21:10 on Jun 1, 2008 |
# ? Jun 1, 2008 21:00 |
|
I got a PHP/wordpress problem. Basically, I created a template for a page with a custom loop. Here's the code code:
|
# ? Jun 2, 2008 00:07 |
|
clockworkjoe posted:I got a PHP/wordpress problem. Basically, I created a template for a page with a custom loop. Your if and while loops are overlapping instead of one being nested inside the other. Basically, you're doing this: php:<?php while ($condition) : if ($condition) : // do stuff here endwhile; else : // do something else endif; ?> When you should be doing this: php:<?php if ($condition) : while ($condition) : // do stuff here endwhile; else : // do something else endif; ?> Zorilla fucked around with this message at 00:38 on Jun 2, 2008 |
# ? Jun 2, 2008 00:32 |
|
Zorilla posted:Your if and while loops are overlapping instead of one being nested inside the other. So where should I put what? Hmm, here's where the original index.php starts <?php if (have_posts()) : ?> which I replaced with <?php $temp = $wp_query; $wp_query= null; $wp_query = new WP_Query(); $wp_query->query('cat=6&showposts=3'.'&paged='.$paged); ?> How can i rewrite the ELSE to say if there are no posts then do this? or am I off base?
|
# ? Jun 2, 2008 00:36 |
|
clockworkjoe posted:How can i rewrite the ELSE to say if there are no posts then do this? or am I off base? Probably something like: php:<?php if ($wp_query->have_posts) : while ($wp_query->have_posts) : $query->the_post(); ?> <!-- post loop stuff goes here --> <?php endwhile; ?> <?php else: ?> <!-- error message about no posts being found goes here --> <?php endif; ?> I think WordPress handles pages with no entires on them automatically, so there's no need to put an "else" section in your template script. I also thought of something else. It looks like your template is calling a specific set of posts. The correct way to do this is make a template that calls a generic set of posts (i.e. have_posts() instead of wp_query->have_posts() ) and then giving your template a special meaning by using a comment block at the top. Then, you manage that page in the WordPress backend and tell it to use that custom template instead of the default one. In other words, get rid of all that special query stuff and put this at the top instead: php:<?php /* Template Name: My Special Template */ ?> Zorilla fucked around with this message at 00:53 on Jun 2, 2008 |
# ? Jun 2, 2008 00:42 |
|
Where do I put the ('cat=6&showposts=3'.'&paged='.$paged); in that code you posted? I think the else is needed for the formatting - to close off the div tags or something correctly. I have the special template already set up. clockworkjoe fucked around with this message at 00:55 on Jun 2, 2008 |
# ? Jun 2, 2008 00:52 |
|
clockworkjoe posted:Where do I put the ('cat=6&showposts=3'.'&paged='.$paged); in that code you posted? The idea is that you shouldn't have to force the template to call a fixed set of posts. I think your script will end up like this: php:<?php /* Template Name: My Special Page */ ?> <?php get_header(); ?> <?php get_sidebar(); ?> <?php if (have_posts()) : while (have_posts()) : the_post(); ?> <ul class="pmeta"> <li>Posted by <?php the_author() ?></li> <li>On <?php the_time('F j, Y') ?></li> <li><br /><?php the_category(', ') ?></li> <?php if (function_exists('the_tags')) : the_tags('<li>Tags ', '</li>'); ?> <li><br /><?php comments_popup_link('No Comments', '1 Comment', '% Comments' ); ?></li> <?php edit_post_link('Edit', '<li>', '</li>'); ?> </ul> <div class="apost"> <h2 id="post-<?php the_ID(); ?>"> <?php if (function_exists('get_cat_icon')) : get_cat_icon('small=false'); ?> <a href="<?php the_permalink() ?>" rel="bookmark" title="Permanent Link to <?php the_title(); ?>"><?php the_title(); ?></a> </h2> <div class="pmain"> <!-- spost --> <?php the_content('Read more...'); ?> <!-- epost --> </div> <?php if ($count==1) : ?> <!-- PLACE YOUR 468x60 ADSENSE CODE (OR BANNER) BELOW --> <script type="text/javascript"> <!-- google_ad_width = 468; google_ad_height = 60; //--> </script> <script type="text/javascript" src="http://pagead2.googlesyndication.com/pagead/show_ads.js"></script> <!-- PLACE YOUR 468x60 ADSENSE CODE (OR BANNER) ABOVE --> <?php endif; $count = $count + 1;?> </div> <div class="extra"></div> <div class="lead"> <span class="ppre"><?php next_posts_link('« Previous Posts') ?></span> <span class="pnex"><?php previous_posts_link('Next Posts »') ?></span> </div> <?php endwhile; endif; ?> <?php get_footer(); ?> Then go in the WordPress backend and set that category view to use this template instead of the default. There's a pull-down menu somewhere for this, and with that comment block at the top that says "Template Name:", this template (called "My Special Page") will be listed in it. I don't know if this method allows you to limit the view to three posts like you probably want, but there's got to be a better way to do this than through a hardcoded query. You might consider moving your Google AdSense code to header.php as well, assuming Google provides a way to call ads to show up in the middle of the page from a script inside <head>. Zorilla fucked around with this message at 01:28 on Jun 2, 2008 |
# ? Jun 2, 2008 00:57 |
|
Well it's not pretty but it works. Besides, I only want three posts from category 6. I will give this a try though.
|
# ? Jun 2, 2008 01:23 |
|
It seems weird, I'm sure, but the idea is that category 6 is set to use this template, rather than the template looking for category 6 (which would be backwards). Flexibility is the key here- and you want as much stuff as possible to be customizable through the WordPress backend as possible instead of having to open up a code editor any time you want to make changes. If you find no point-and-click way to limit the view to 3 posts, you could probably replace... while (have_posts()) : ...with... for ($i = 0;$i < 3;$i++) : But I would just recommend setting category 6 to paginate every 3 posts. That way, users can view older articles by clicking "Previous Posts" if they wish. Zorilla fucked around with this message at 01:50 on Jun 2, 2008 |
# ? Jun 2, 2008 01:30 |
|
Zorilla posted:It seems weird, I'm sure, but the idea is that category 6 is set to use this template, rather than the template looking for category 6 (which would be backwards). Flexibility is the key here- and you want as much stuff as possible to be customizable through the WordPress backend as possible instead of having to open up a code editor any time you want to make changes. how is category 6 is set to use this template? I see nothing in it that refers to cat 6. I also see nothing about paginating a specific category. The thing is, the main index specifically excludes category 6 posts. I want ONLY blog posts under raillery.tv/blog and everything BUT blog posts on the main index. I see no way of doing that in the backend admin interface. clockworkjoe fucked around with this message at 01:57 on Jun 2, 2008 |
# ? Jun 2, 2008 01:53 |
|
Ok, if there's no way to do that, then yeah, you'd instead need to use your original query method in the template, create a new Page in the WP backend, and then set it to use this template in the pull-down menu.
|
# ? Jun 2, 2008 02:06 |
|
Zorilla posted:Ok, if there's no way to do that, then yeah, you'd instead need to use your original query method in the template, create a new Page in the WP backend, and then set it to use this template in the pull-down menu. How does the code change with the query instead of the If have posts?
|
# ? Jun 2, 2008 02:16 |
|
Just put it back to the way you had it before (except I don't think you needed all those other variable assignments like $temp = $wp_query, as all non-sessioned variables should vanish at the end of a script run. Tell me if I'm totally wrong on this.):php:<?php $wp_query = new WP_Query(); $wp_query->query('cat=6&showposts=3&paged='.$paged); ?> <?php while ($wp_query->have_posts()) : $wp_query->the_post(); ?> <!-- stuff that goes after the post text --> <?php endwhile; ?> Zorilla fucked around with this message at 02:34 on Jun 2, 2008 |
# ? Jun 2, 2008 02:20 |
|
I got it from here http://weblogtoolscollection.com/archives/2008/04/19/paging-and-custom-wordpress-loops/ because query posts breaks prev and next links.
|
# ? Jun 2, 2008 02:34 |
|
Ok, it seems like you have this under control, though it seems like it would just be easier to use a different variable name than $wp_posts to instantiate a new object rather than copying its old value elsewhere, then restoring it at the end of the script. I'm sure there's a reason for doing that I don't realize, so I probably shouldn't say anything more. I think I just wasted 3/4 of a page telling you how to do something that wouldn't actually work. All you really needed to take away from all this is to make sure your if and while loops are nested properly. Zorilla fucked around with this message at 02:42 on Jun 2, 2008 |
# ? Jun 2, 2008 02:38 |
|
Zorilla posted:Ok, it seems like you have this under control, though it seems like it would just be easier to use a different variable name than $wp_posts to instantiate a new object rather than copying its old value elsewhere, then restoring it at the end of the script. I'm sure there's a reason for doing that I don't realize, so I probably shouldn't say anything more. This is what I have code:
|
# ? Jun 2, 2008 03:10 |
|
Also, this is the index.php which works correctly so use that as a referencecode:
|
# ? Jun 2, 2008 03:13 |
|
|
# ? May 15, 2024 11:16 |
|
You have this: <?php endwhile; endif; ?> ...when you should have this (like shown in my example)... <?php endwhile; ?>
|
# ? Jun 2, 2008 03:17 |