#! /usr/bin/perl use strict; use warnings; use HTML::Parser; use WWW::Mechanize; my ($status, $status2) = (0,0); my ($channel, $channel_number, $date, $time, $title, $description, $ca +tegory, $rating); my $parse = HTML::Parser->new( api_version => 3, text_h => [ \&text, "dtext" ], start_h => [\&start, "tagname, attr"], end_h => [\&end, "tagname"], ); #$parse->parse_file("guide.html"); my $mech = WWW::Mechanize->new(); $mech->agent_alias( 'Linux Mozilla' ); $mech->get('http://www.tvguide.co.uk/?systemid=3'); my @channels = $mech->find_all_links(url_regex => qr/channellisting.as +p\?ch=/i); foreach my $link_obj (@channels) { next unless defined $link_obj->url and defined $link_obj->attrs->{'tit +le'}; ($channel, $channel_number) = $link_obj->attrs->{'title'} =~ m/\[Cli +ck for (.*?) full day TV listings\].*?\[Channel Numbers<br>.*?Freevie +w:(\d+)/; my ($channel_id) = $link_obj->url =~ m/channellisting.asp\?ch=(\d+)/ +i; next unless defined $channel and defined $channel_number and defined + $channel_id; sleep 5; my $url = 'http://www.tvguide.co.uk/channellisting.asp\?ch='.$channe +l_id; $mech->get($url); print $channel.' '.$channel_id."\n"; print $link_obj->url."\n"; $parse->parse($mech->content); print "\n\n\n"; undef $channel; undef $channel_number; undef $channel_id; } exit; sub start { my ($tag, $attr) = @_; return if !$attr->{'class'} or $status != 2; my %other_stat = ( 0 => 'programmeheading', 2 => 'programmetext', 4 => 'tvchannel', 6 => 'programmetext', 8 => 'programmetext', ); return unless exists $other_stat{$status2} and $attr->{'class'} eq $other_stat{$status2}; $status2++; } sub end { my ($tag) = @_; return unless $tag eq 'span' and $status == 2; foreach (1,3,5,7,9) { $status2++ if $status2 == $_; } } sub text { my ($text, $atr) = @_; $text =~ s/\s+/ /; return if $text eq ' ' or !defined $text; print $text."\n" if !$status and $text =~ /HTTP\/1\.\d \d+ /; if (!$status and $text =~ /^\w+, \w+ \d\d, \d{4}$/) { $date .= $text if defined $date and defined $text; $date = $text if !defined $date and defined $text; print $text."\n\n\n"; ++$status; } elsif ($status == 1 and $text =~ /\d{1,2}:\d\d\w\w/) { $time .= $text if defined $time and defined $text; $time = $text if !defined $time and defined $text; ++$status; } elsif ($status == 2 and $status2 == 1) { $title .= $text if defined $title and defined $text; $title = $text if !defined $title and defined $text; } elsif ($status == 2 and $status2 == 3) { $description .= $text if defined $description and defined $text; $description = $text if !defined $description and defined $text; } elsif ($status == 2 and $status2 == 7) { $category .= $text if defined $category and defined $text; $category = $text if !defined $category and defined $text; #print $text."\n"; } elsif ($status == 2 and $status2 == 9 and $text eq 'Rating') { #print $text."\n"; } elsif ($status == 2 and $status2 == 10 and $text =~ /^\d+/) { $rating .= $text if defined $rating and defined $text; $rating = $text if !defined $rating and defined $text; $description = 'unknown' if !defined $description; print $time."\n".$title."\n".$description."\n".$category."\n".$rat +ing."\n\n"; undef $time; undef $title; undef $description; undef $category; undef $rating; ($status, $status2) = (1,0); } } sub database { my ($channel, $date, $time, $title, $description, $category, $rating +) = @_; my $program_exists = $schema->resultset('Programmes')->count({ 'name' => $title, 'date' => $date, 'time' => $time }); return 0 if $program_exists; my $category_id = $schema->resultset('Categories')->find_or_create({ name => $category})->id; $channel = 'BBC One'; my $channel_id = $schema->resultset('Channels')->find_or_create({ name => $channel, chan => $channel_number})->id; print $title.' '.$time." being added!\n"; my $new = $schema->resultset('Programmes')->create({ name => $title, description => $description, date => $date, category_id => $category_id, channel_id => $channel_id, rating => $rating }); $new->time($time); $new->update; return 1; } #CREATE TABLE categories ( #id INTEGER PRIMARY KEY, #name TEXT, #colour TEXT #); #CREATE TABLE channels ( #id INTEGER PRIMARY KEY, #name TEXT, #chan INTEGER, #logo TEXT #); #CREATE TABLE programmes ( #id INTEGER PRIMARY KEY, #name TEXT, #description TEXT, #date TEXT, #time TEXT, #rating INTEGER, #channel_id INTEGER, #category_id INTEGER #);
[download]
www.debianhelp.co.uk
http://tinyurl.com/whyxhtml
sph-plugin-list-pages.php
<?php /** * @package sph-plugin-list-pages * @author simon * @version 1.5 */ /* Plugin Name: SPH Plugin List Pages Plugin URI: http://wordpress.org/# Description: This is a plugin to setup multiple coloured menus. just u +se sph_plugin_list_pages() in your template. hide pages in pagemash t +o remove them from this menu, use these hidden pages with sph_plugin_ +list_excluded_pages() in your template. Version: 1.0 Author URI: http://??? */ function sph_plugin_list_pages($post_parent=0){ global $wpdb, $wp_version; $excludePagesList = get_option('exclude_pages'); $my_array = array('red','blue','green','orange','yellow','brown','wh +ite'); $my_i = 0; if($wp_version >= 2.1){ $pageposts = $wpdb->get_results("SELECT * FROM $wpdb->posts WHERE +post_type = 'page' AND post_parent = '$post_parent' ORDER BY menu_ord +er"); } else{ $pageposts = $wpdb->get_results("SELECT * FROM $wpdb->posts WHERE +post_status = 'static' AND post_parent = '$post_parent' ORDER BY menu +_order"); } if ($pageposts == true){ foreach ($pageposts as $page): $status = $page->post_status; if(get_option('exclude_pages')){ if(in_array($page->ID, $exclude +PagesList)) continue; } if ($status == 'draft' || $status == 'pending') { continue; } if (0 === $post_parent) { echo '<ul id="list_pages_'.$my_array[$my_i].'" class="menu">'. +"\n"; echo '<li class="menu_title">'.$page->post_title."</li>\n"; sph_plugin_list_pages($page->ID); echo "</ul>\n"; $my_i++; } else { if (is_page($page->ID)) { echo '<li class="active"><a href="'.get_bloginfo('wpurl').'? +page_id='.$page->ID.'" class="menu_item">'.$page->post_title."</a></l +i>\n"; } else { echo '<li><a href="'.get_bloginfo('wpurl').'?page_id='.$page +->ID.'" class="menu_item">'.$page->post_title."</a></li>\n"; } } endforeach; return true; } else { return false; } } function sph_plugin_list_excluded_pages(){ global $wpdb; $excludePagesList = get_option('exclude_pages'); echo '<ul id="">'."\n"; foreach ($excludePagesList as $page_id): $page = get_post($page_id); if ($page == true){ echo '<li><a href="'.get_bloginfo('wpurl').'?page_id='.$page->ID +.'">'.$page->post_title.'</a></li>'."\n"; } endforeach; echo "</ul>\n"; } ?>
[download]
[IMPORT] mysql -u username -p db_name < db_name.sql [EXPORT] mysqldump --user=username --password db_name > db_name.sql [LOCALHOST -> REMOTEHOST] scp -r domain.com user@domain.com: rsync -rc /home/localhost_username/domain.com/ username@domain.com:/h +ome/username/public_html [REMOTEHOST -> LOCALHOST] scp -r emma@domain.com:pulic_html/ domain.com rsync -rc username@domain.com:/home/username/public_html/ /home/local +host_username/domain.com/ [PERMISSIONS] grant all privileges on db_name.* to 'username'@'localhost' identified + by 'password';
[download]
#! /usr/bin/perl use strict; use warnings; use CGI; my @sizes = (0,500,750,1200); my @prices = (10,9.5,8.75); my $per_units = 50; my $total = '0.00'; my $q = CGI->new(); print $q->header; print $q->start_html(-style => 'this.css'); if ($q->param('feet') and $q->param('feet') =~ /^\d+$/) { if ($q->param('feet') > $sizes[$#sizes]) { query_us(); } else { calc_total($q->param('feet')); total_form($q->param('feet')); } } else { if ($q->param('feet') and $q->param('feet') =~ /^\d+\.\d+$/) { calc_total(int $q->param('feet')); total_form(int $q->param('feet')); } else { total_form(); } } print $q->end_html; sub calc_total { my ($feet) = @_; for my $i (0..$#sizes-1) { if ($feet > $sizes[$i] and $feet <= $sizes[$i+1]) { $total = ($feet / $per_units) * $prices[$i]; } } } sub total_form { my ($feet) = @_; $feet = 0 if !$feet; print $q->start_form; print '<table border="0" cellspacing="0" cellpadding="0"><tr>', '<th class="headers" rowspan="2">Total Amount Of Footage</th>', '<th> <span class="feet">ft</span></th>', '<th><span class="total_title">Total Cost</span></th>', '</tr><tr>', '<td><input type="text" name="feet" value="'.$feet.'">', '<input type="submit" name="submit" class="submit" value="" />', '</td>', '<td id="total_cost">£'.$total.'</td>', '</tr><tr class="other">', '<th>extra copies</th>', '<td colspan="2">£10 each</td>', '</tr><tr class="other">', '<th>minimum charge</th>', '<td colspan="2">£50</td>', '</tr></table>'; print $q->end_form; } sub query_us { print "over 1200"; }
[download]
* {padding:0;margin:0;} body {padding:10px;} table {text-align:left;border:1px solid #000;font-size:1em;} table td, table th {padding:2px;} input { width:120px; height:55px; font-size:3em; text-align:right; border:0; border:1px solid #ddd; color:grey; padding-right:3px; padding-top:5px; } input.submit {height:62px;width:20px;font-size:2.9em;border-left:0;} #total_cost {font-size:3em;width:200px;text-align:right;padding-top:5p +x;} .headers {width:150px;border-right:1px solid #000;font-size:0.8em;} .other td, .other th { height:50px; border-top:1px solid #000; font-size:0.8em; } .other th {border-right:1px solid #000;} .total_title {font-size:0.6em;margin-left:30px;position:relative;top:5 +px;} .feet {font-size:0.6em;float:right;position:relative;top:20px;left:-22 +px;}
[download]