Yesterday's News Archive

Custom Search

News Finder

Enter topic, city or zip or try our Advanced Search
 
DSC00733 - Nature - Clouds
DSC00733 - Nature - Clouds
Nature - Clouds Photos - DSC00733
World Photos - www.worldinphotos.com             World Photos - www.worldinphotos.com
 
Featured Services at www.worldofnews.com
Stock Quotes
Stock Quotes www.stockquoteusa.com
Eg. MSFT, GOOG, YHOO
Symbol Lookup
Jobs and careers - www.ejobwizard.com
Jobs, Careers www.jobsncareers.com
Over 500 job sites
WHAT

Job title, keywords or company name
WHERE(optional)

city, state or zip
Coupons, online coupons, internet coupons, discount coupons
Coupons, online coupons,
internet coupons,
discount coupons

Local classifieds, Local jobs, Local Business
Local classifieds,
Local jobs,
Local Business

Real Estate Web Design, Hosting, and Promotion with The Real Estate Listing Manager
Real Estate Web Design,
Hosting, and Promotion.

Web design, Custom WebSites, Content Manager, eCommerce, SEO.
Web design, Custom WebSites,
Content Manager,
eCommerce, SEO.

Indian news, headlines - www.indiasnews.com
Indian News

India, India News, Hotels, Tourism - www.india.tm
India, India News, Hotels, Tourism
Online Profiles, Personal Profiles Create Your Search Engine Profile - www.whataboutu.com
Online Profiles, Personal Profiles Create Your Search Engine Profile
People Profiles, Celebrity Profiles Create Your Profile - www.peopleandprofiles.com
People Profiles, Celebrity Profiles Create Your Profile
Local Merchants Stay Local Deal Global with MerchantSpan.com - www.merchantspan.com
Local Merchants Stay Local Deal Global with MerchantSpan.com


More

X-Powered-By: PHP/5.2.9 Content-type: text/html ###!c:/perl/bin/perl.exe BEGIN { push( @INC, "libs" ); } print "Content-Type: text/html\n\n"; #::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: # Test CPU load use strict; #use warnings; use CGI; use Sys::CpuLoad; my $q = new CGI(); my $skip_cache = $q->param( "skipcache" ); if ( ($ENV{'HTTP_USER_AGENT'} !~ /Googlebot/) && ($ENV{'HTTP_USER_AGENT'} !~ /msnbot/) && ($ENV{'HTTP_USER_AGENT'} !~ /Yahoo\! Slurp/) && ($ENV{'HTTP_USER_AGENT'} !~ /Twiceler/) && ($skip_cache ne 'y') ){ my $min_cpu_load = 2; my $max_cpu_load = 5; my @cpu_load_array = Sys::CpuLoad::load(); # Prevent CPU overloading my $tmp_title = $q->param('title'); $tmp_title =~ s/\-/ /g; if ($cpu_load_array[0] > $max_cpu_load) { print_server_busy_message($tmp_title); } if ($ENV{'HTTP_USER_AGENT'} =~ /(bot[^t]|bot$)/){ if ($cpu_load_array[0] > $min_cpu_load) { print_server_busy_message($tmp_title); } } } #::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: use DBI; use Data::Dumper; use HTML::Entities; use common_libs; use Switch; use PHP::Serialization qw(serialize unserialize); use Time::Local; use POSIX qw(ceil); # Define main variables my $option = $q->param( "option" ); # Debug message #if ($skip_cache ne 'y') { print("Server under maintenance !"); exit(); } #::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: #NOTE: #the public_html directory must have 0751 rights (not 0777) my $worldnewxRootFolder = "/home/worldnew/public_html"; #my $worldnewxRootFolder = "e:/inetpub/wwwroot/worldnewx.com/"; my $worldofnewsRoot = "http://worldofnews.com/index.pl"; my $cache_dir = "/usr/local/cache/won"; #my $cache_dir = "e:/inetpub/wwwroot/worldnewx/cache"; my $config_file_path = "config.xml"; my $template_index = "index.tpl"; my $news_search_link = "http://wssearch.worldnewx.com/ws_search.pl?apikey=worldnewx.com-1277066279"; my $source_list_link = "http://wssearch.worldnewx.com/gapi/index.php?option=exp_slst"; my $category_list_link = "http://wssearch.worldnewx.com/gapi/index.php?option=exp_clst"; my @current_time = localtime(); my $ch = $current_time[ 2 ]; my $cm = $current_time[ 1 ]; my $cs = $current_time[ 0 ]; my $time_in_minutes = $ch * 60 + $cm; my %aArchiveIndex = ( "a" => 1, "b" => 2, "c" => 3, "d" => 4, "e" => 5, "f" => 6, "g" => 7, "h" => 8, "i" => 9, "j" => 10, "k" => 11, "l" => 12, "m" => 13, "n" => 14, "o" => 15, "p" => 16, "q" => 17, "r" => 18, "s" => 19, "t" => 20, "u" => 21, "v" => 22, "w" => 23, "x" => 24, "y" => 25, "z" => 26 ); #::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: #Create and initialize debug object my $DBG = new DEBUG(); $DBG->set_flag( 0 ); #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ my $keyword = $q->param( "keyword" ); my $cat = $q->param( "cat" ); my $bottom_menu_id = $q->param( 'bottom_menu_id' ); my $start_record = $q->param( "s" ); my $news_id = $q->param( "nid" ); $keyword = '' unless defined $keyword; $cat = "Top Stories" unless defined $cat; $option = '' unless defined $option; $bottom_menu_id = '' unless defined $bottom_menu_id; $start_record = 0 unless defined $start_record; $start_record = ( $start_record < 0 ) ? 0 : $start_record; $skip_cache = 'n' unless defined $skip_cache; my $is_first_page = get_first_page_flag( $q ); #Define global script variables for sql queries my $dbh = init_database( $config_file_path ); my $sql; my $sth; my $pps = 18; #pages per sheet #Normalize the time my $step = int( $time_in_minutes / 5 ); my $exact_time = $step * 5; my $show_nav_bar = 0; my $cache_file_name = create_cache_file_name( $cat, $keyword, $news_id, $option, $start_record, $bottom_menu_id ); my $tmp_cache_file_name = ""; #used for hold a temporary unique cache file name #............................................. my $cache_content = ""; my $is_collecting_cache = 'n'; # #Try to get content from cache # my $cache_time = 600; if ( $option eq 'view' ) { $cache_time = 3600 * 24 * 30; visit_news( $news_id ); #$skip_cache = 'y'; } if ( $option eq 'search' ) { $skip_cache = 'y'; } #if ($option eq 'site_map') { $skip_cache = 'y'; } #if ($option eq 'google') { $skip_cache = 'y'; } if ( $skip_cache eq 'n' ) { $DBG->show( "" ); #debug hidden text ( Get From Cache : ) $cache_content = try_to_get_cache( $cache_file_name ); if ( $cache_content ne '' ) { $cache_content = add_comments( $cache_content ); $cache_content = add_visiads( $cache_content, $option ); $cache_content = add_ad_manager( $cache_content, $option ); print $cache_content; $DBG->show( "" ); #debug hidden text ( No ) exit(); } } $DBG->show( "" ); #debug hidden text ( No ) $tmp_cache_file_name = start_collect_cache( $cache_file_name ); $is_collecting_cache = 'y'; ################################################################################ ################################################################################ my @category_array = get_categories_array( $dbh, 1 ); my $wnl_tpl = HTML::Template->new( filename => "templates/$template_index", global_vars => 1 ); $wnl_tpl->param( "first_page_flag" => $is_first_page ); # #Get the image from WorldInPhotos.com # my $WIP_Img = ""; eval { $WIP_Img = get_worldinphotos_image(); $wnl_tpl->param( WIP_Link => $WIP_Img->{ 'images_list' }[ 0 ]{ 'link' } ); $wnl_tpl->param( WIP_Photo => $WIP_Img->{ 'images_list' }[ 0 ]{ 'photo' } ); $wnl_tpl->param( WIP_Title => $WIP_Img->{ 'images_list' }[ 0 ]{ 'title' } ); $wnl_tpl->param( WIP_Category => $WIP_Img->{ 'images_list' }[ 0 ]{ 'category' } ); }; if ( $@ ) { } # #Get the list of channels for World Channels # # - construct the categories arrays for two rows display (right side) my @category_array_l = (); my @category_array_r = (); my $half_way = int( $#category_array / 2 ); for ( my $i = 0 ; $i <= $#category_array ; $i++ ) { if ( $i <= $half_way ) { push( @category_array_l, $category_array[ $i ] ); } else { push( @category_array_r, $category_array[ $i ] ); } } #Assign variables to template $wnl_tpl->param( 'category_array_l' => \@category_array_l ); $wnl_tpl->param( 'category_array_r' => \@category_array_r ); # #Create main menu # my $news_vlist_content = ""; my $ticketnetwork_ads = HTML::Template->new( filename => "templates/ticketnetwork.tpl" ); # $wnl_tpl->param( 'ticketnetwork_ads' => $ticketnetwork_ads->output() ); ########################################################## switch ( $option ) { case 'search' { my $keywords = $q->param( "keywords" ); my $category = $q->param( "category" ); my $source = $q->param( "source" ); my @tmp_news_aray = (); my @news_array; my $nav_bar = ""; if ( $keywords ne '' ) { #Search by keyword @news_array = get_and_unserialize( $news_search_link . "&opt=kwd&nr=$pps&k=$keywords&start=$start_record" ); if ( !$news_array[ 0 ]->{ Error } ) { @tmp_news_aray = @{ $news_array[ 0 ]->{ records } }; $news_vlist_content = create_news_list_content( \@tmp_news_aray ); } #Calculate the number of pages if ( $#tmp_news_aray > -1 ) { $nav_bar = get_nav_bar( $start_record, $pps, $news_array[ 0 ]->{ total_estimated } ); $show_nav_bar = 1; } else { $show_nav_bar = 0; } } elsif ( ( $category ne '' ) || ( $source ne '' ) ) { #Search by category and source @news_array = get_and_unserialize( $news_search_link . "&opt=mix&nr=$pps&c=$category&s=$source&start=$start_record" ); @tmp_news_aray = @{ $news_array[ 0 ]->{ records } }; $news_vlist_content = create_news_list_content( \@tmp_news_aray ); #Calculate the number of pages if ( $#tmp_news_aray > -1 ) { $nav_bar = get_nav_bar( $start_record, $pps, $news_array[ 0 ]->{ total_estimated } ); $show_nav_bar = 1; } else { $show_nav_bar = 0; } } else { #Display advanced search box #Get sources list my @source_name_array = get_and_unserialize( $source_list_link ); #Get categories list my @category_name_array = get_and_unserialize( $category_list_link ); #echo(Dumper(@source_name_array));exit(); #Assign to template my $search_tpl = HTML::Template->new( filename => "templates/search.tpl", global_vars => 1 ); $search_tpl->param( source_name_array => \@{ $source_name_array[ 0 ] } ); $search_tpl->param( category_name_array => \@{ $category_name_array[ 0 ] } ); $news_vlist_content = $search_tpl->output(); $tmp_news_aray[ 0 ]->{ title } = "Advanced Search"; $tmp_news_aray[ 0 ]->{ description } = "WorldOfNews.com Advanced Search"; } $wnl_tpl->param( page_title => "Advanced Search"); $wnl_tpl->param( page_keywords => get_keywords( $tmp_news_aray[ 0 ]->{ description } ) ); $wnl_tpl->param( page_description => get_description( $tmp_news_aray[ 0 ]->{ description } ) ); $wnl_tpl->param( navigation_bar => $nav_bar ); $wnl_tpl->param( show_nav_bar => $show_nav_bar ); $wnl_tpl->param( topstories_content => $news_vlist_content ); } case 'clst' { #Category list #Find out category code my $category_id = CategoryName2Id( $cat ); =debug select (STDOUT); print $news_search_link . "&opt=cat&nr=$pps&c=$category_id&start=$start_record\n"; exit(); =cut my @news_array = get_and_unserialize( $news_search_link . "&opt=cat&nr=$pps&c=$category_id&start=$start_record" ); eval { my @tmp_news_aray = @{ $news_array[ 0 ]->{ records } }; $news_vlist_content = create_news_list_content( \@tmp_news_aray ); #Calculate the number of pages my $nav_bar = ""; if ( $#tmp_news_aray > -1 ) { $nav_bar = get_nav_bar( $start_record, $pps, $news_array[ 0 ]->{ total_estimated } ); $show_nav_bar = 1; } else { $show_nav_bar = 0; } $wnl_tpl->param( navigation_bar => $nav_bar ); }; if ( $@ ) { } $wnl_tpl->param( page_title => "$cat News, World $cat News" ); $wnl_tpl->param( page_keywords => get_keywords( "$cat News, World $cat News" ) ); $wnl_tpl->param( page_description => get_description( "$cat News, World $cat News" ) ); $wnl_tpl->param( topstories_content => $news_vlist_content ); $wnl_tpl->param( show_nav_bar => $show_nav_bar ); } case 'view' { #Item view visit_news( $news_id ); #Display the news my @tmp_arr = get_and_unserialize( $news_search_link . "&opt=arh&permaid=$news_id" ); @tmp_arr = @{ $tmp_arr[ 0 ]->{ records } }; #For option = view we need publication date not and for this we apply the following algorithm # - save the old pubdate my $tmp_pub_date = $tmp_arr[ 0 ]->{ pub_date }; # - process the record my $news_details = adjust_news_object_fields( $tmp_arr[ 0 ], 'n' ); # - process the saved date in the format we need # - restore the date property #echo($tmp_pub_date);exit(); $tmp_arr[ 0 ]->{ pub_date } = decode_mysql_date( $tmp_pub_date ); #Get news by category my $category_id = $news_details->{ cat_id }; my @news_array = get_and_unserialize( $news_search_link . "&opt=cat&nr=6&c=$category_id" ); my @tmp_news_aray = @{ $news_array[ 0 ]->{ records } }; my $aux_topic_content = ""; foreach my $row ( @tmp_news_aray ) { $row = adjust_news_object_fields( $row, 'n' ); my $news_content = HTML::Template->new( filename => "templates/newsheadlines_layout.tpl" ); $news_content->param( 'won_link' => $row->{ won_link } ); $news_content->param( 'title' => $row->{ title } ); $news_content->param( 'source_name' => $row->{ source_name } ); $aux_topic_content .= $news_content->output(); } #Get news by source my $source = $news_details->{ source_name }; @news_array = get_and_unserialize( $news_search_link . "&opt=src&nr=6&s=$source" ); @tmp_news_aray = @{ $news_array[ 0 ]->{ records } }; my $aux_source_content = ""; foreach my $row ( @tmp_news_aray ) { my $news_content = HTML::Template->new( filename => "templates/newsheadlines_layout.tpl" ); $row = adjust_news_object_fields( $row, 'n' ); $news_content->param( 'won_link' => $row->{ won_link } ); $news_content->param( 'title' => $row->{ title } ); $news_content->param( 'source_name' => $row->{ source_name } ); $aux_source_content .= $news_content->output(); } my $newsitem_template = HTML::Template->new( filename => "templates/newsdetails_layout.tpl" ); $newsitem_template->param( id => $news_details->{ permaid } ); $newsitem_template->param( title => $news_details->{ title } ); $newsitem_template->param( description => $news_details->{ description } ); $newsitem_template->param( cname => $news_details->{ cname } ); $newsitem_template->param( enc_category => $news_details->{ enc_category } ); $newsitem_template->param( link => $news_details->{ link } ); $newsitem_template->param( won_link => $news_details->{ won_link } ); $newsitem_template->param( source_name => $news_details->{ source_name } ); $newsitem_template->param( pub_date => $news_details->{ pub_date } ); $newsitem_template->param( aux_topic_content => $aux_topic_content ); $newsitem_template->param( aux_source_content => $aux_source_content ); $wnl_tpl->param( page_title => $news_details->{ title } ); $wnl_tpl->param( page_keywords => get_keywords( $news_details->{ description } ) ); $wnl_tpl->param( page_description => get_description( $news_details->{ description } ) ); $news_vlist_content = $newsitem_template->output(); $wnl_tpl->param( topstories_content => $news_vlist_content ); } case 'site_map' { #construct site map #Get categories list my @category_name_array = get_and_unserialize( $category_list_link ); my @tmp_category_name_array = @{ $category_name_array[ 0 ] }; @category_name_array = (); foreach ( @tmp_category_name_array ) { # echo($_->{name}); $_->{ link } = $_->{ name }; $_->{ link } =~ s/^([\\__]+)//g; $_->{ link } =~ s/( +)/\+/g; push( @category_name_array, $_ ); } my $sitemap_tpl = HTML::Template->new( filename => "templates/site_map.tpl", global_vars => 1 ); $sitemap_tpl->param( tree => \@category_name_array ); $news_vlist_content = $sitemap_tpl->output(); $wnl_tpl->param( page_title => "Site Map" ); $wnl_tpl->param( page_keywords => "WorldOfNews.com Site Map" ); $wnl_tpl->param( page_description => "WorldOfNews.com Site Map" ); $wnl_tpl->param( topstories_content => $news_vlist_content ); =start echo(\@category_name_array); exit(); =cut } case 'rss' { my $category = $q->param( "cat" ); #Find out category code my $category_id = CategoryName2Id( $category ); my @tmp_news_aray = (); my @news_array = (); @news_array = get_and_unserialize( $news_search_link . "&opt=mix&nr=$pps&c=$category_id" ); @news_array = @{ $news_array[ 0 ]->{ records } }; #Workaround to not finish the output here: $wnl_tpl = HTML::Template->new( filename => "templates/rss.tpl" ); foreach ( @news_array ) { #if ( length( $_->{ description } ) > 200 ) { $_->{ description } = substr( $_->{ description }, 0, 200 ) . "..."; } if ( length( $_->{ description } ) > 200 ) { $_->{ description } = get_short_description($_->{ description }); } push( @tmp_news_aray, { 'title' => $_->{ title }, 'won_link' => $_->{ won_link }, 'description' => strip_slashes($_->{ description }), 'source_name' => $_->{ source_name }, 'pub_date' => $_->{ pub_date }, 'img' => $_->{ img }, 'cname' => $_->{ cname } } ); } $wnl_tpl->param( current_content => \@tmp_news_aray ); $wnl_tpl->param( title => $category ); my $clink = $category; $clink =~ s/( +)/\+/g; $wnl_tpl->param( 'link' => "http://www.worldofnews.com/rss/$clink" ); $wnl_tpl->param( 'description' => "$category News, World News, Breaking Stories, News Head Lines, Top Stories, Newspapers, Worldwide News" ); $wnl_tpl->param( 'logo' => 'http://www.worldofnews.com/images/logo.gif' ); $wnl_tpl->param( 'now_date_time' => ( scalar localtime( time() ) ) ); } case 'google' { my $google_tpl = HTML::Template->new( filename => "templates/google.tpl" ); $wnl_tpl->param( page_title => "World News, Breaking Stories, News Head Lines, Top Stories, Newspapers, Worldwide News" ); $wnl_tpl->param( page_keywords => "World News, Breaking Stories, News Head Lines, Top Stories, Newspapers, Worldwide News" ); $wnl_tpl->param( page_description => "World News, Breaking Stories, News Head Lines, Top Stories, Newspapers, Worldwide News" ); $wnl_tpl->param( google_page => 1 ); $wnl_tpl->param( topstories_content => $google_tpl->output() ); } case 'about_us' { my $about_us_tpl = HTML::Template->new( filename => "templates/about_us.tpl" ); $wnl_tpl->param( topstories_content => $about_us_tpl->output() ); $wnl_tpl->param( page_title => "About Us" ); } case 'terms_of_service' { my $tos_tpl = HTML::Template->new( filename => "templates/terms_of_service.tpl" ); $wnl_tpl->param( topstories_content => $tos_tpl->output() ); $wnl_tpl->param( page_title => "Terms of Service" ); } case 'privacy_policy' { my $privacy_policy_tpl = HTML::Template->new( filename => "templates/privacy_policy.tpl" ); $wnl_tpl->param( topstories_content => $privacy_policy_tpl->output() ); $wnl_tpl->param( page_title => "Privacy Policy" ); } case 'contact_us' { my $contact_us_tpl = HTML::Template->new( filename => "templates/contact_us.tpl" ); $wnl_tpl->param( topstories_content => $contact_us_tpl->output() ); $wnl_tpl->param( page_title => "Contact Us" ); } else { #Home page #Get Frontbox content my $frontbox_content .= file_get_contents( "$worldnewxRootFolder/frontbox/feeds/wnl_frontbox.htm" ); #Get Top Stories list my @news_array = get_and_unserialize( $news_search_link . "&opt=cat&nr=$pps&c=2684354584" ); =start select(STDOUT); #print ($news_search_link . "&opt=cat&nr=$pps&c=2684354584");exit(); print Dumper(@news_array);exit(); =cut my @tmp_news_aray = @{ $news_array[ 0 ]->{ records } }; #Calculate the number of pages my $nav_bar = ""; if ( $#tmp_news_aray > -1 ) { $nav_bar = get_nav_bar( $start_record, $pps, $news_array[ 0 ]->{ total_estimated } ); $show_nav_bar = 1; } else { $show_nav_bar = 0; } $wnl_tpl->param( show_nav_bar => $show_nav_bar ); $wnl_tpl->param( navigation_bar => $nav_bar ); $news_vlist_content = create_news_list_content( \@tmp_news_aray ); #Create right section $wnl_tpl->param( 'news_by_cat' => create_right_section( $dbh ) ); $wnl_tpl->param( page_title => $tmp_news_aray[ 0 ]->{ title } ); # $wnl_tpl->param( page_keywords => get_keywords($tmp_news_aray[0]->{description}) ); # $wnl_tpl->param( page_description => get_description($tmp_news_aray[0]->{description}) ); $wnl_tpl->param( page_keywords => "Breaking Stories, News Head Lines, Top Stories, Newspapers, Worldwide News" ); $wnl_tpl->param( page_description => "Breaking Stories, News Head Lines, Top Stories, Newspapers, Worldwide News" ); $wnl_tpl->param( frontbox_content => $frontbox_content ); $wnl_tpl->param( topstories_content => $news_vlist_content ); $wnl_tpl->param( homepage => 1 ); #Create news array for bottom boxes #'Top Stories', 'Business', 'Education', 'Entertainment', 'Health', 'Law', 'Movie', 'Music', 'Sport', 'Technology', 'US', 'World' my @newscateg = ( 'topstories', 'business', 'education', 'entertainment', 'health', 'law', 'movie', 'music', 'sport', 'technology', 'us', 'world' ); foreach my $categ ( @newscateg ) { my $newsbox_tmpl = HTML::Template->new( filename => "$worldnewxRootFolder/newsbox/feeds/" . $categ . "_newsbox.htm" ); $wnl_tpl->param( $categ . "_newsbox" => $newsbox_tmpl->output() ); } } } # Calculate current date for the archive my ($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst)=localtime(time()-86400); $year += 1900; $mon += 1; my $current_date = "$year-$mon-$mday"; $wnl_tpl->param('current_date' => $current_date); my $temporary_content = $wnl_tpl->output; =SEO FIX: Teporary took out # FIX: October 27, 2007. # Updated: 22 Aug 2008 # Reason: SEO optimization (add title on all links) # Remove all 'titles' from links $temporary_content =~ s/]+?)title ?= ?["']?([^<>]+?)(['"]|([> ]))/]+?)title ?= ?["']?([^<>]+?)['" >]/]+?)>([^<>]+?)<\/a>/$2<\/a>/gmi; # @TODO: Add 'alt' to all images =cut print $temporary_content; #print to screen but captured by cache if ( $is_collecting_cache eq 'y' ) { save_to_cache( $tmp_cache_file_name, $cache_file_name ); $temporary_content = add_comments( $temporary_content ); # $temporary_content = add_visiads( $temporary_content, $option ); # $temporary_content = add_ad_manager( $temporary_content, $option ); print $temporary_content; #print to screen } ################################################################################ ################################################################################ #::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: #::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: #::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: sub add_comments { my $content = shift(); my $comments_list = get_comments_list(); $content =~ s/__ALREADY_EXISTING_COMMENTS__/$comments_list/; return $content; } sub add_visiads { my $content = shift(); my $option = shift(); my $visiads_content = ""; my @visiads_output = (); if ($option ne '') { #avoid processing for the home page # Process Visiads.com ads # catch output of PHP code my $time_processing = time(); @visiads_output = `php /home/worldofn/www/visiads/interface.php`; $visiads_content = join( "\n", @visiads_output ); $time_processing = time() - $time_processing; $visiads_content .= "\n"; } $content =~ s/__VISIADS_ADS__/$visiads_content/; return $content; } sub add_ad_manager { my $content = shift(); my $option = shift(); my $ad_manager_content = ""; my @ad_manager_output = (); if ($option ne '') { #avoid processing for the home page # Process ad manager ads # catch output of PHP code my $time_processing = time(); @ad_manager_output = `php /home/worldofn/www/adClient/interface.php`; $ad_manager_content = join( "\n", @ad_manager_output ); $time_processing = time() - $time_processing; $ad_manager_content .= "\n"; } $content =~ s/X-Powered-By: PHP/5.2.9 Content-type: text/html ###!c:/perl/bin/perl.exe BEGIN { push( @INC, "libs" ); } print "Content-Type: text/html\n\n"; #::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: # Test CPU load use strict; #use warnings; use CGI; use Sys::CpuLoad; my $q = new CGI(); my $skip_cache = $q->param( "skipcache" ); if ( ($ENV{'HTTP_USER_AGENT'} !~ /Googlebot/) && ($ENV{'HTTP_USER_AGENT'} !~ /msnbot/) && ($ENV{'HTTP_USER_AGENT'} !~ /Yahoo\! Slurp/) && ($ENV{'HTTP_USER_AGENT'} !~ /Twiceler/) && ($skip_cache ne 'y') ){ my $min_cpu_load = 2; my $max_cpu_load = 5; my @cpu_load_array = Sys::CpuLoad::load(); # Prevent CPU overloading my $tmp_title = $q->param('title'); $tmp_title =~ s/\-/ /g; if ($cpu_load_array[0] > $max_cpu_load) { print_server_busy_message($tmp_title); } if ($ENV{'HTTP_USER_AGENT'} =~ /(bot[^t]|bot$)/){ if ($cpu_load_array[0] > $min_cpu_load) { print_server_busy_message($tmp_title); } } } #::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: use DBI; use Data::Dumper; use HTML::Entities; use common_libs; use Switch; use PHP::Serialization qw(serialize unserialize); use Time::Local; use POSIX qw(ceil); # Define main variables my $option = $q->param( "option" ); # Debug message #if ($skip_cache ne 'y') { print("Server under maintenance !"); exit(); } #::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: #NOTE: #the public_html directory must have 0751 rights (not 0777) my $worldnewxRootFolder = "/home/worldnew/public_html"; #my $worldnewxRootFolder = "e:/inetpub/wwwroot/worldnewx.com/"; my $worldofnewsRoot = "http://worldofnews.com/index.pl"; my $cache_dir = "/usr/local/cache/won"; #my $cache_dir = "e:/inetpub/wwwroot/worldnewx/cache"; my $config_file_path = "config.xml"; my $template_index = "index.tpl"; my $news_search_link = "http://wssearch.worldnewx.com/ws_search.pl?apikey=worldnewx.com-1277066279"; my $source_list_link = "http://wssearch.worldnewx.com/gapi/index.php?option=exp_slst"; my $category_list_link = "http://wssearch.worldnewx.com/gapi/index.php?option=exp_clst"; my @current_time = localtime(); my $ch = $current_time[ 2 ]; my $cm = $current_time[ 1 ]; my $cs = $current_time[ 0 ]; my $time_in_minutes = $ch * 60 + $cm; my %aArchiveIndex = ( "a" => 1, "b" => 2, "c" => 3, "d" => 4, "e" => 5, "f" => 6, "g" => 7, "h" => 8, "i" => 9, "j" => 10, "k" => 11, "l" => 12, "m" => 13, "n" => 14, "o" => 15, "p" => 16, "q" => 17, "r" => 18, "s" => 19, "t" => 20, "u" => 21, "v" => 22, "w" => 23, "x" => 24, "y" => 25, "z" => 26 ); #::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: #Create and initialize debug object my $DBG = new DEBUG(); $DBG->set_flag( 0 ); #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ my $keyword = $q->param( "keyword" ); my $cat = $q->param( "cat" ); my $bottom_menu_id = $q->param( 'bottom_menu_id' ); my $start_record = $q->param( "s" ); my $news_id = $q->param( "nid" ); $keyword = '' unless defined $keyword; $cat = "Top Stories" unless defined $cat; $option = '' unless defined $option; $bottom_menu_id = '' unless defined $bottom_menu_id; $start_record = 0 unless defined $start_record; $start_record = ( $start_record < 0 ) ? 0 : $start_record; $skip_cache = 'n' unless defined $skip_cache; my $is_first_page = get_first_page_flag( $q ); #Define global script variables for sql queries my $dbh = init_database( $config_file_path ); my $sql; my $sth; my $pps = 18; #pages per sheet #Normalize the time my $step = int( $time_in_minutes / 5 ); my $exact_time = $step * 5; my $show_nav_bar = 0; my $cache_file_name = create_cache_file_name( $cat, $keyword, $news_id, $option, $start_record, $bottom_menu_id ); my $tmp_cache_file_name = ""; #used for hold a temporary unique cache file name #............................................. my $cache_content = ""; my $is_collecting_cache = 'n'; # #Try to get content from cache # my $cache_time = 600; if ( $option eq 'view' ) { $cache_time = 3600 * 24 * 30; visit_news( $news_id ); #$skip_cache = 'y'; } if ( $option eq 'search' ) { $skip_cache = 'y'; } #if ($option eq 'site_map') { $skip_cache = 'y'; } #if ($option eq 'google') { $skip_cache = 'y'; } if ( $skip_cache eq 'n' ) { $DBG->show( "" ); #debug hidden text ( Get From Cache : ) $cache_content = try_to_get_cache( $cache_file_name ); if ( $cache_content ne '' ) { $cache_content = add_comments( $cache_content ); $cache_content = add_visiads( $cache_content, $option ); $cache_content = add_ad_manager( $cache_content, $option ); print $cache_content; $DBG->show( "" ); #debug hidden text ( No ) exit(); } } $DBG->show( "" ); #debug hidden text ( No ) $tmp_cache_file_name = start_collect_cache( $cache_file_name ); $is_collecting_cache = 'y'; ################################################################################ ################################################################################ my @category_array = get_categories_array( $dbh, 1 ); my $wnl_tpl = HTML::Template->new( filename => "templates/$template_index", global_vars => 1 ); $wnl_tpl->param( "first_page_flag" => $is_first_page ); # #Get the image from WorldInPhotos.com # my $WIP_Img = ""; eval { $WIP_Img = get_worldinphotos_image(); $wnl_tpl->param( WIP_Link => $WIP_Img->{ 'images_list' }[ 0 ]{ 'link' } ); $wnl_tpl->param( WIP_Photo => $WIP_Img->{ 'images_list' }[ 0 ]{ 'photo' } ); $wnl_tpl->param( WIP_Title => $WIP_Img->{ 'images_list' }[ 0 ]{ 'title' } ); $wnl_tpl->param( WIP_Category => $WIP_Img->{ 'images_list' }[ 0 ]{ 'category' } ); }; if ( $@ ) { } # #Get the list of channels for World Channels # # - construct the categories arrays for two rows display (right side) my @category_array_l = (); my @category_array_r = (); my $half_way = int( $#category_array / 2 ); for ( my $i = 0 ; $i <= $#category_array ; $i++ ) { if ( $i <= $half_way ) { push( @category_array_l, $category_array[ $i ] ); } else { push( @category_array_r, $category_array[ $i ] ); } } #Assign variables to template $wnl_tpl->param( 'category_array_l' => \@category_array_l ); $wnl_tpl->param( 'category_array_r' => \@category_array_r ); # #Create main menu # my $news_vlist_content = ""; my $ticketnetwork_ads = HTML::Template->new( filename => "templates/ticketnetwork.tpl" ); # $wnl_tpl->param( 'ticketnetwork_ads' => $ticketnetwork_ads->output() ); ########################################################## switch ( $option ) { case 'search' { my $keywords = $q->param( "keywords" ); my $category = $q->param( "category" ); my $source = $q->param( "source" ); my @tmp_news_aray = (); my @news_array; my $nav_bar = ""; if ( $keywords ne '' ) { #Search by keyword @news_array = get_and_unserialize( $news_search_link . "&opt=kwd&nr=$pps&k=$keywords&start=$start_record" ); if ( !$news_array[ 0 ]->{ Error } ) { @tmp_news_aray = @{ $news_array[ 0 ]->{ records } }; $news_vlist_content = create_news_list_content( \@tmp_news_aray ); } #Calculate the number of pages if ( $#tmp_news_aray > -1 ) { $nav_bar = get_nav_bar( $start_record, $pps, $news_array[ 0 ]->{ total_estimated } ); $show_nav_bar = 1; } else { $show_nav_bar = 0; } } elsif ( ( $category ne '' ) || ( $source ne '' ) ) { #Search by category and source @news_array = get_and_unserialize( $news_search_link . "&opt=mix&nr=$pps&c=$category&s=$source&start=$start_record" ); @tmp_news_aray = @{ $news_array[ 0 ]->{ records } }; $news_vlist_content = create_news_list_content( \@tmp_news_aray ); #Calculate the number of pages if ( $#tmp_news_aray > -1 ) { $nav_bar = get_nav_bar( $start_record, $pps, $news_array[ 0 ]->{ total_estimated } ); $show_nav_bar = 1; } else { $show_nav_bar = 0; } } else { #Display advanced search box #Get sources list my @source_name_array = get_and_unserialize( $source_list_link ); #Get categories list my @category_name_array = get_and_unserialize( $category_list_link ); #echo(Dumper(@source_name_array));exit(); #Assign to template my $search_tpl = HTML::Template->new( filename => "templates/search.tpl", global_vars => 1 ); $search_tpl->param( source_name_array => \@{ $source_name_array[ 0 ] } ); $search_tpl->param( category_name_array => \@{ $category_name_array[ 0 ] } ); $news_vlist_content = $search_tpl->output(); $tmp_news_aray[ 0 ]->{ title } = "Advanced Search"; $tmp_news_aray[ 0 ]->{ description } = "WorldOfNews.com Advanced Search"; } $wnl_tpl->param( page_title => "Advanced Search"); $wnl_tpl->param( page_keywords => get_keywords( $tmp_news_aray[ 0 ]->{ description } ) ); $wnl_tpl->param( page_description => get_description( $tmp_news_aray[ 0 ]->{ description } ) ); $wnl_tpl->param( navigation_bar => $nav_bar ); $wnl_tpl->param( show_nav_bar => $show_nav_bar ); $wnl_tpl->param( topstories_content => $news_vlist_content ); } case 'clst' { #Category list #Find out category code my $category_id = CategoryName2Id( $cat ); =debug select (STDOUT); print $news_search_link . "&opt=cat&nr=$pps&c=$category_id&start=$start_record\n"; exit(); =cut my @news_array = get_and_unserialize( $news_search_link . "&opt=cat&nr=$pps&c=$category_id&start=$start_record" ); eval { my @tmp_news_aray = @{ $news_array[ 0 ]->{ records } }; $news_vlist_content = create_news_list_content( \@tmp_news_aray ); #Calculate the number of pages my $nav_bar = ""; if ( $#tmp_news_aray > -1 ) { $nav_bar = get_nav_bar( $start_record, $pps, $news_array[ 0 ]->{ total_estimated } ); $show_nav_bar = 1; } else { $show_nav_bar = 0; } $wnl_tpl->param( navigation_bar => $nav_bar ); }; if ( $@ ) { } $wnl_tpl->param( page_title => "$cat News, World $cat News" ); $wnl_tpl->param( page_keywords => get_keywords( "$cat News, World $cat News" ) ); $wnl_tpl->param( page_description => get_description( "$cat News, World $cat News" ) ); $wnl_tpl->param( topstories_content => $news_vlist_content ); $wnl_tpl->param( show_nav_bar => $show_nav_bar ); } case 'view' { #Item view visit_news( $news_id ); #Display the news my @tmp_arr = get_and_unserialize( $news_search_link . "&opt=arh&permaid=$news_id" ); @tmp_arr = @{ $tmp_arr[ 0 ]->{ records } }; #For option = view we need publication date not and for this we apply the following algorithm # - save the old pubdate my $tmp_pub_date = $tmp_arr[ 0 ]->{ pub_date }; # - process the record my $news_details = adjust_news_object_fields( $tmp_arr[ 0 ], 'n' ); # - process the saved date in the format we need # - restore the date property #echo($tmp_pub_date);exit(); $tmp_arr[ 0 ]->{ pub_date } = decode_mysql_date( $tmp_pub_date ); #Get news by category my $category_id = $news_details->{ cat_id }; my @news_array = get_and_unserialize( $news_search_link . "&opt=cat&nr=6&c=$category_id" ); my @tmp_news_aray = @{ $news_array[ 0 ]->{ records } }; my $aux_topic_content = ""; foreach my $row ( @tmp_news_aray ) { $row = adjust_news_object_fields( $row, 'n' ); my $news_content = HTML::Template->new( filename => "templates/newsheadlines_layout.tpl" ); $news_content->param( 'won_link' => $row->{ won_link } ); $news_content->param( 'title' => $row->{ title } ); $news_content->param( 'source_name' => $row->{ source_name } ); $aux_topic_content .= $news_content->output(); } #Get news by source my $source = $news_details->{ source_name }; @news_array = get_and_unserialize( $news_search_link . "&opt=src&nr=6&s=$source" ); @tmp_news_aray = @{ $news_array[ 0 ]->{ records } }; my $aux_source_content = ""; foreach my $row ( @tmp_news_aray ) { my $news_content = HTML::Template->new( filename => "templates/newsheadlines_layout.tpl" ); $row = adjust_news_object_fields( $row, 'n' ); $news_content->param( 'won_link' => $row->{ won_link } ); $news_content->param( 'title' => $row->{ title } ); $news_content->param( 'source_name' => $row->{ source_name } ); $aux_source_content .= $news_content->output(); } my $newsitem_template = HTML::Template->new( filename => "templates/newsdetails_layout.tpl" ); $newsitem_template->param( id => $news_details->{ permaid } ); $newsitem_template->param( title => $news_details->{ title } ); $newsitem_template->param( description => $news_details->{ description } ); $newsitem_template->param( cname => $news_details->{ cname } ); $newsitem_template->param( enc_category => $news_details->{ enc_category } ); $newsitem_template->param( link => $news_details->{ link } ); $newsitem_template->param( won_link => $news_details->{ won_link } ); $newsitem_template->param( source_name => $news_details->{ source_name } ); $newsitem_template->param( pub_date => $news_details->{ pub_date } ); $newsitem_template->param( aux_topic_content => $aux_topic_content ); $newsitem_template->param( aux_source_content => $aux_source_content ); $wnl_tpl->param( page_title => $news_details->{ title } ); $wnl_tpl->param( page_keywords => get_keywords( $news_details->{ description } ) ); $wnl_tpl->param( page_description => get_description( $news_details->{ description } ) ); $news_vlist_content = $newsitem_template->output(); $wnl_tpl->param( topstories_content => $news_vlist_content ); } case 'site_map' { #construct site map #Get categories list my @category_name_array = get_and_unserialize( $category_list_link ); my @tmp_category_name_array = @{ $category_name_array[ 0 ] }; @category_name_array = (); foreach ( @tmp_category_name_array ) { # echo($_->{name}); $_->{ link } = $_->{ name }; $_->{ link } =~ s/^([\\__]+)//g; $_->{ link } =~ s/( +)/\+/g; push( @category_name_array, $_ ); } my $sitemap_tpl = HTML::Template->new( filename => "templates/site_map.tpl", global_vars => 1 ); $sitemap_tpl->param( tree => \@category_name_array ); $news_vlist_content = $sitemap_tpl->output(); $wnl_tpl->param( page_title => "Site Map" ); $wnl_tpl->param( page_keywords => "WorldOfNews.com Site Map" ); $wnl_tpl->param( page_description => "WorldOfNews.com Site Map" ); $wnl_tpl->param( topstories_content => $news_vlist_content ); =start echo(\@category_name_array); exit(); =cut } case 'rss' { my $category = $q->param( "cat" ); #Find out category code my $category_id = CategoryName2Id( $category ); my @tmp_news_aray = (); my @news_array = (); @news_array = get_and_unserialize( $news_search_link . "&opt=mix&nr=$pps&c=$category_id" ); @news_array = @{ $news_array[ 0 ]->{ records } }; #Workaround to not finish the output here: $wnl_tpl = HTML::Template->new( filename => "templates/rss.tpl" ); foreach ( @news_array ) { #if ( length( $_->{ description } ) > 200 ) { $_->{ description } = substr( $_->{ description }, 0, 200 ) . "..."; } if ( length( $_->{ description } ) > 200 ) { $_->{ description } = get_short_description($_->{ description }); } push( @tmp_news_aray, { 'title' => $_->{ title }, 'won_link' => $_->{ won_link }, 'description' => strip_slashes($_->{ description }), 'source_name' => $_->{ source_name }, 'pub_date' => $_->{ pub_date }, 'img' => $_->{ img }, 'cname' => $_->{ cname } } ); } $wnl_tpl->param( current_content => \@tmp_news_aray ); $wnl_tpl->param( title => $category ); my $clink = $category; $clink =~ s/( +)/\+/g; $wnl_tpl->param( 'link' => "http://www.worldofnews.com/rss/$clink" ); $wnl_tpl->param( 'description' => "$category News, World News, Breaking Stories, News Head Lines, Top Stories, Newspapers, Worldwide News" ); $wnl_tpl->param( 'logo' => 'http://www.worldofnews.com/images/logo.gif' ); $wnl_tpl->param( 'now_date_time' => ( scalar localtime( time() ) ) ); } case 'google' { my $google_tpl = HTML::Template->new( filename => "templates/google.tpl" ); $wnl_tpl->param( page_title => "World News, Breaking Stories, News Head Lines, Top Stories, Newspapers, Worldwide News" ); $wnl_tpl->param( page_keywords => "World News, Breaking Stories, News Head Lines, Top Stories, Newspapers, Worldwide News" ); $wnl_tpl->param( page_description => "World News, Breaking Stories, News Head Lines, Top Stories, Newspapers, Worldwide News" ); $wnl_tpl->param( google_page => 1 ); $wnl_tpl->param( topstories_content => $google_tpl->output() ); } case 'about_us' { my $about_us_tpl = HTML::Template->new( filename => "templates/about_us.tpl" ); $wnl_tpl->param( topstories_content => $about_us_tpl->output() ); $wnl_tpl->param( page_title => "About Us" ); } case 'terms_of_service' { my $tos_tpl = HTML::Template->new( filename => "templates/terms_of_service.tpl" ); $wnl_tpl->param( topstories_content => $tos_tpl->output() ); $wnl_tpl->param( page_title => "Terms of Service" ); } case 'privacy_policy' { my $privacy_policy_tpl = HTML::Template->new( filename => "templates/privacy_policy.tpl" ); $wnl_tpl->param( topstories_content => $privacy_policy_tpl->output() ); $wnl_tpl->param( page_title => "Privacy Policy" ); } case 'contact_us' { my $contact_us_tpl = HTML::Template->new( filename => "templates/contact_us.tpl" ); $wnl_tpl->param( topstories_content => $contact_us_tpl->output() ); $wnl_tpl->param( page_title => "Contact Us" ); } else { #Home page #Get Frontbox content my $frontbox_content .= file_get_contents( "$worldnewxRootFolder/frontbox/feeds/wnl_frontbox.htm" ); #Get Top Stories list my @news_array = get_and_unserialize( $news_search_link . "&opt=cat&nr=$pps&c=2684354584" ); =start select(STDOUT); #print ($news_search_link . "&opt=cat&nr=$pps&c=2684354584");exit(); print Dumper(@news_array);exit(); =cut my @tmp_news_aray = @{ $news_array[ 0 ]->{ records } }; #Calculate the number of pages my $nav_bar = ""; if ( $#tmp_news_aray > -1 ) { $nav_bar = get_nav_bar( $start_record, $pps, $news_array[ 0 ]->{ total_estimated } ); $show_nav_bar = 1; } else { $show_nav_bar = 0; } $wnl_tpl->param( show_nav_bar => $show_nav_bar ); $wnl_tpl->param( navigation_bar => $nav_bar ); $news_vlist_content = create_news_list_content( \@tmp_news_aray ); #Create right section $wnl_tpl->param( 'news_by_cat' => create_right_section( $dbh ) ); $wnl_tpl->param( page_title => $tmp_news_aray[ 0 ]->{ title } ); # $wnl_tpl->param( page_keywords => get_keywords($tmp_news_aray[0]->{description}) ); # $wnl_tpl->param( page_description => get_description($tmp_news_aray[0]->{description}) ); $wnl_tpl->param( page_keywords => "Breaking Stories, News Head Lines, Top Stories, Newspapers, Worldwide News" ); $wnl_tpl->param( page_description => "Breaking Stories, News Head Lines, Top Stories, Newspapers, Worldwide News" ); $wnl_tpl->param( frontbox_content => $frontbox_content ); $wnl_tpl->param( topstories_content => $news_vlist_content ); $wnl_tpl->param( homepage => 1 ); #Create news array for bottom boxes #'Top Stories', 'Business', 'Education', 'Entertainment', 'Health', 'Law', 'Movie', 'Music', 'Sport', 'Technology', 'US', 'World' my @newscateg = ( 'topstories', 'business', 'education', 'entertainment', 'health', 'law', 'movie', 'music', 'sport', 'technology', 'us', 'world' ); foreach my $categ ( @newscateg ) { my $newsbox_tmpl = HTML::Template->new( filename => "$worldnewxRootFolder/newsbox/feeds/" . $categ . "_newsbox.htm" ); $wnl_tpl->param( $categ . "_newsbox" => $newsbox_tmpl->output() ); } } } # Calculate current date for the archive my ($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst)=localtime(time()-86400); $year += 1900; $mon += 1; my $current_date = "$year-$mon-$mday"; $wnl_tpl->param('current_date' => $current_date); my $temporary_content = $wnl_tpl->output; =SEO FIX: Teporary took out # FIX: October 27, 2007. # Updated: 22 Aug 2008 # Reason: SEO optimization (add title on all links) # Remove all 'titles' from links $temporary_content =~ s/]+?)title ?= ?["']?([^<>]+?)(['"]|([> ]))/]+?)title ?= ?["']?([^<>]+?)['" >]/]+?)>([^<>]+?)<\/a>/$2<\/a>/gmi; # @TODO: Add 'alt' to all images =cut print $temporary_content; #print to screen but captured by cache if ( $is_collecting_cache eq 'y' ) { save_to_cache( $tmp_cache_file_name, $cache_file_name ); $temporary_content = add_comments( $temporary_content ); # $temporary_content = add_visiads( $temporary_content, $option ); # $temporary_content = add_ad_manager( $temporary_content, $option ); print $temporary_content; #print to screen } ################################################################################ ################################################################################ #::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: #::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: #::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: sub add_comments { my $content = shift(); my $comments_list = get_comments_list(); $content =~ s/__ALREADY_EXISTING_COMMENTS__/$comments_list/; return $content; } sub add_visiads { my $content = shift(); my $option = shift(); my $visiads_content = ""; my @visiads_output = (); if ($option ne '') { #avoid processing for the home page # Process Visiads.com ads # catch output of PHP code my $time_processing = time(); @visiads_output = `php /home/worldofn/www/visiads/interface.php`; $visiads_content = join( "\n", @visiads_output ); $time_processing = time() - $time_processing; $visiads_content .= "\n"; } $content =~ s/__VISIADS_ADS__/$visiads_content/; return $content; } sub add_ad_manager { my $content = shift(); my $option = shift(); my $ad_manager_content = ""; my @ad_manager_output = (); if ($option ne '') { #avoid processing for the home page # Process ad manager ads # catch output of PHP code my $time_processing = time(); @ad_manager_output = `php /home/worldofn/www/adClient/interface.php`; $ad_manager_content = join( "\n", @ad_manager_output ); $time_processing = time() - $time_processing; $ad_manager_content .= "\n"; } $content =~ s/__AD_MANAGER_ADS__/$ad_manager_content/; return $content; } sub get_and_unserialize { my $url = shift(); my $serialized_news = get( $url ); my @news_array = (); eval { @news_array = unserialize( $serialized_news ); }; if ( $@ ) { print( "\n\n Error: $serialized_news \n\n" ); print Dumper( $@ ); exit(); } return @news_array; } sub get_worldinphotos_image { my $url = "http://www.worldinphotos.com/ws_export/300x250/tags/world.jpg"; return unserialize( get( $url ) ); } #Returns the array for the right section sub create_right_section { my $dbh = shift(); my @special_category_array = ( 268435469, # Business 671088651, # Education 671088644, # Entertainment 1073741831, # Health 1610612742, # Law 1744830518, # Movie News 1744830569, # Music 2550136844, # Sports 2684354563, # Technology 2818572289, # Us 3087007746 # World ); my $return_content = ""; foreach my $category ( @special_category_array ) { my $section_tpl = HTML::Template->new( filename => "templates/news_section.tpl" ); my @tmp_array = get_and_unserialize( $news_search_link . "&opt=cat&nr=2&c=$category" ); my @tmp_data_arr = @{ $tmp_array[ 0 ]->{ records } }; @tmp_array = (); foreach ( @tmp_data_arr ) { $_->{ enc_category } = url_encode( $_->{ cname } ); $_->{ img } = ""; if ( length( $_->{ description } ) > 55 ) { my $break_char_index = index($_->{ description }, '', 55); if ($break_char_index > -1) { $break_char_index += 4; # Also add the length of $_->{ description } = substr( $_->{ description }, 0, $break_char_index ) . "..."; } # $_->{ description } = substr( $_->{ description }, 0, 55 ) . " ..."; } $_->{ description } = strip_slashes($_->{ description }); $_->{ pub_date } = format_pub_date( $_->{ pub_date } ); push( @tmp_array, $_ ); } $section_tpl->param( enc_category_name => $tmp_array[ 0 ]->{ enc_category } ); $section_tpl->param( category_name => $tmp_array[ 0 ]->{ cname } ); $section_tpl->param( news_section => \@tmp_array ); $return_content .= $section_tpl->output(); } return $return_content; } sub get_news_array { my $cat_id = shift(); my @tmp_array = get_and_unserialize( $news_search_link . "&opt=cat&nr=5&c=$cat_id" ); return @{ $tmp_array[ 0 ]->{ records } }; } sub create_news_list_content { my @news_list = @{ shift() }; my $news_vlist_content = ''; if ( $#news_list > -1 ) { foreach my $row ( @news_list ) { $news_vlist_content .= format_story( $row ); } } else { $news_vlist_content .= format_story( 0 ); } return $news_vlist_content; } sub format_story { my $row = shift(); my $news_vlist_content = ''; ################################################### my $news_content = HTML::Template->new( filename => "templates/news_body.tpl" ); if ( $row ) { $row = adjust_news_object_fields( $row ); $news_content->param( 'id' => $row->{ permaid } ); $news_content->param( 'link' => $row->{ link } ); $news_content->param( 'won_link' => $row->{ won_link } ); $news_content->param( 'title' => $row->{ title } ); $news_content->param( 'description' => $row->{ description } ); $news_content->param( 'site_name' => $row->{ source_name } ); $news_content->param( 'pub_date' => $row->{ pub_date } ); $news_content->param( 'topic' => $row->{ cname } ); $news_content->param( 'img' => $row->{ img } ); $news_content->param( 'visits' => $row->{ visits } ); } else { $news_content->param( 'no_records' => 1 ); } $news_vlist_content .= $news_content->output(); #push ( @topstories_array, { 'title' => $rows[2], 'description' => $rows[3]}); return $news_vlist_content; } =start /** * @param object $row * @param character $limit_description_length * * @return object */ =cut sub adjust_news_object_fields { my $row = shift(); my $limit_description_length = shift(); $limit_description_length = 'y' unless defined $limit_description_length; $row->{ cat_id } = int( $row->{ cat_id } ); $row->{ geo_id } = int( $row->{ geo_id } ); $row->{ permaid } = int( $row->{ permaid } ); #$row->{won_link} = "/view-" . $row->{permaid} . ".html"; =start $row->{description} = decode_entities($row->{description}); $row->{description} =~ s/<([^<]+?)>//g; $row->{title} =~ s/<([^<]+?)>//g; =cut if ( ( length( $row->{ description } ) > 200 ) && ( $limit_description_length eq 'y' ) ) { $row->{ description } = get_short_description($row->{ description }); } $row->{ description } = strip_slashes($row->{ description }); if ( ( $row->{ source_name } eq 'aniin.com' ) || ( $row->{ source_name } eq 'IANS.in' ) ) { my $encoded_title = $row->{ title }; $encoded_title =~ s/[^a-zA-Z0-9]/-/g; $encoded_title =~ s/\-(\-+)/-/g; $encoded_title =~ s/^(\-+)//g; $encoded_title =~ s/(\-+)$//g; $row->{ won_link } = "http://www.indiasnews.com/News-" . $row->{ permaid } . "-$encoded_title.html"; $row->{ link } = $row->{ won_link }; } #Trick: if 0 views generate random between 0 and 10; if ( $row->{ votes } eq 0 ) { $row->{ votes } = int( rand( 10 ) ); } $row->{ pub_date } = format_pub_date( $row->{ pub_date } ); $row->{ enc_category } = encode_entities( $row->{ cname } ); return $row; } sub get_short_description{ my $description = shift(); $description = strip_slashes($description); my $break_char_index = index($description, '', 200); if ($break_char_index > -1) { $break_char_index += 4; # Also add the length of }else{ $break_char_index = index($description, ' ', 200); } $description = substr( $description, 0, $break_char_index ) . "..."; return $description; } sub format_pub_date { my $pub_date = shift(); #2008-04-13 21:12:38 => 1210702358 my @date_time = split / /, $pub_date; my ( $year, $month, $day ) = split /\-/, $date_time[ 0 ]; my ( $hour, $minute, $second ) = split /\:/, $date_time[ 1 ]; if ( $day == 0 ) { $day = 1; } =debug select (STDOUT); print "$pub_date \n"; print "$second, $minute, $hour, $day, $month, $year \n\n"; =cut $pub_date = time() - timelocal( $second, $minute, $hour, $day, $month - 1, $year ); my $tmp_time = $pub_date; my ( $s, $mi, $h, $d ); if ( $tmp_time > 60 ) { $mi = int( $tmp_time / 60 ); $s = $tmp_time % 60; if ( $mi > 60 ) { $h = int( $mi / 60 ); $mi = $mi % 60; if ( $h > 24 ) { $d = int( $h / 24 ); $h = $h % 24; } } } else { $mi = $tmp_time; } $pub_date = ''; if ( abs( "$d" ) > 0 ) { $pub_date = $d . " days ago"; } else { if ( $h > 0 ) { $pub_date .= $h . " hours and "; } $pub_date .= $mi . " minutes ago"; } return $pub_date; } sub decode_mysql_date { my $pub_date = shift(); #2008-04-13 21:12:38 my @date_time = split / /, $pub_date; my ( $year, $month, $day ) = split /\-/, $date_time[ 0 ]; my ( $hour, $minute, $second ) = split /\:/, $date_time[ 1 ]; my $ret_val = ""; if ( ( $year > 0 ) && ( $day > 0 ) ) { $pub_date = timelocal( $second, $minute, $hour, $day, $month - 1, $year ); $pub_date = scalar localtime( $pub_date ); $pub_date =~ s/( +)/ /g; my @date_array = split / /, $pub_date; my @time_array = split /:/, $date_array[ 3 ]; $ret_val = sprintf( "%s %s, %s %s:%s", $date_array[ 1 ], $date_array[ 2 ], $date_array[ 4 ], $time_array[ 0 ], $time_array[ 1 ] ); } else { $ret_val = $pub_date; } return $ret_val; } #Creates a database connection and returns databasehandler sub init_database { my $config_file_path = shift(); my $config_xml = XMLin( $config_file_path ); my $db_host = $config_xml->{ parserSettings }{ db_host }; my $db_name = $config_xml->{ parserSettings }{ db_name }; my $db_user = $config_xml->{ parserSettings }{ db_user }; my $db_password = $config_xml->{ parserSettings }{ db_password }; if ( $db_password eq "''" ) { $db_password = ''; } my $dbh = DBI->connect( "dbi:mysql:$db_name:$db_host", "$db_user", "$db_password" ) or die( "Cannot connect to the database" ); return $dbh; } sub create_cache_file_name { my ( $cat, $keyword, $news_id, $option, $start_record, $bottom_menu_id ) = @_; # #Create cache file name # my $cache_file_name = ''; if ( $cat ) { $cache_file_name = $cat; } if ( $keyword ) { $cache_file_name = $keyword; } $cache_file_name .= $news_id . $option . $start_record . $bottom_menu_id; $cache_file_name =~ s/[^a-z0-9A-Z]//g; # #Treate cache # #Split the cache in subdirectories in order to be retreived quickly #In this case will be implemented a three level cache mechanism for ( my $i = 0 ; $i < 3 ; $i++ ) { my $cache_dirLi = substr( $cache_file_name, $i, 1 ); $cache_dir = "$cache_dir/$cache_dirLi"; #$cache_dir is global if ( !( -e "$cache_dir" && -d "$cache_dir" ) ) { mkdir( "$cache_dir" ); chmod 0777, "$cache_dir"; } } $cache_file_name = $cache_dir . "/" . $cache_file_name; return $cache_file_name; } sub try_to_get_cache { my $cache_file_name = shift(); my @cache_stat = stat( "$cache_file_name.ch" ); my $cache_mtime = $cache_stat[ 9 ]; my $cache_size = $cache_stat[ 7 ]; my $current_time = time(); my $return_value = ""; if ( ( !$cache_mtime ) ) { $cache_mtime = 0; open CFH, "> $cache_file_name.ch"; close CFH; $DBG->show( "Closing CFH on checkTheCache function" ); } $DBG->show( "Cache Data \n CacheSize:$cache_size \n CacheModifiedTime:$cache_mtime \n CacheLife:" . ( $current_time - $cache_mtime ) . " \n Keyword:$keyword \n Option:$option " ); if ( ( $cache_size > 1000 ) && ( $cache_mtime > 0 ) && ( $current_time - $cache_mtime < $cache_time ) ) { $return_value = file_get_contents( "$cache_file_name.ch" ); $return_value .= "\n"; $return_value .= "\n"; } else { $return_value = ''; } return $return_value; } sub save_to_cache { my $tmp_cache_file_name = shift(); my $cache_file_name = shift(); if ( $tmp_cache_file_name ne "" ) { close( FH ); $DBG->show( "Closing FH on save_to_cache function" ); chmod 0777, "$tmp_cache_file_name.ch"; select( STDOUT ); my @cacheStat = stat( "$tmp_cache_file_name.ch" ); if ( $cacheStat[ 7 ] > 1000 ) { #stat[7] = filesize if ( unlink "$cache_file_name.ch" ) { $DBG->show( "File $cache_file_name.ch deleted ...\n" ); } else { $DBG->show( "File $cache_file_name.ch can not be deleted ...\n" ); } if ( rename "$tmp_cache_file_name.ch", "$cache_file_name.ch" ) { $DBG->show( "$tmp_cache_file_name.ch renamed to $cache_file_name.ch...\n" ); } else { $DBG->show( "$tmp_cache_file_name.ch can not be renamed to $cache_file_name.ch...\n" ); } } } } #Include a file sub include { my $fileName = shift(); open IFH, "<" . $fileName; while ( ) { print $_; } close( IFH ); $DBG->show( "Closing IFH on include function" ); } #Initiates tho collect the content to be saved into the cache sub start_collect_cache { my $cache_file_name = shift(); #Open cache file handler my $tmp_cache_file_name = $cache_file_name . time(); open FH, "> " . $tmp_cache_file_name . ".ch"; select( FH ); return $tmp_cache_file_name; } #Gets content from a file sub file_get_contents { my $file_name = shift(); my @content_lines = (); open( TMPFH, $file_name ); @content_lines = ; close TMPFH; return join( "\n", @content_lines ); } #Returh the is_homepage glag sub get_first_page_flag { my $q = shift(); my $ret_val = 0; if ( !$q->param( 'cat' ) && ( ( !$q->param( 'option' ) ) || ( $q->param( 'option' ) eq 'specops' ) ) && !$q->param( 'keyword' ) ) { $ret_val = 1; } return $ret_val; } #Visit a news sub visit_news { my $id = shift(); get( "http://wssearch.worldnewx.com/ws_status.pl?apikey=worldnewx.com-1277066279&opt=vis&permaid=$id" ); } #Vote for a news sub vote_news { my $id = shift(); get( "http://wssearch.worldnewx.com/ws_status.pl?apikey=worldnewx.com-1277066279&opt=vot&permaid=$id" ); } sub select_STDOUT { close( FH ); select( STDOUT ); $DBG->show( "Closing FH and selecting STDOUT on select_STDOUT function" ); } sub mysql_query { my $sql = shift(); my $dbh = shift(); my $sth = $dbh->prepare( $sql ); $sth->execute() or die( "Invalid query ($sql) !!!" ); $sth->finish(); } #Returns the categories array sub get_categories_array { my $dbh = shift(); my $clevel = shift(); my $sql = "SELECT * FROM `category`"; if ( $clevel > 0 ) { $sql .= " WHERE `clevel`=$clevel"; } $sql .= " ORDER BY `weight` DESC, `title` ASC"; my $sth = $dbh->prepare( $sql ); $sth->execute() || die( "Could not execute sql !!!" ); my @category_array = (); while ( my $cat_rows = $sth->fetchrow_hashref ) { push( @category_array, { 'id' => $cat_rows->{ 'id' }, 'title' => $cat_rows->{ 'title' }, 'link' => url_encode( $cat_rows->{ 'title' } ) } ); } $sth->finish(); return @category_array; } sub CategoryName2Id { my $category_name = shift(); my $sql = "SELECT `alias` FROM `category` WHERE `title`='$category_name'"; my $sth = $dbh->prepare( $sql ); $sth->execute() || die( "Could not execute sql !!!" ); my $cat_row = $sth->fetchrow_hashref; return ( ( $aArchiveIndex{ lc( substr( $category_name, 0, 1 ) ) } << 27 ) + $cat_row->{ alias } ); } sub url_encode { my ( $string ) = @_; $string =~ s/(\W)/"%" . unpack("H2", $1)/ge; #$string# =~ tr/.//; return $string; } sub url_decode { my ( $string ) = @_; $string =~ tr/+/ /; $string =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack("C", hex($1))/eg; return $string; } sub get_description { my $content = shift(); return strip_slashes(strip_tags($content)); } sub strip_tags{ my $content = shift(); $content =~ s/\<([^>]+?)\>/ /g; $content =~ s/ +/ /g; return $content; } sub strip_slashes{ my $content = shift(); $content =~ s/\\//g; return $content; } sub get_keywords { my $content = shift(); my $commonWordsArray = "able|about|after|again|all|almost|already|also|although|am|an|and|another|any|are|are|around|as|at|based|be|because|been|before|being|between|both|bring|but|by|came|can|com|come|comes|could|did|do|does|doing|done|each|eight|else|etc|even|every|five|for|four|from|get|gets|getting|go|going|got|had|has|have|he|he|her|here|him|himself|his|how|however|href|http|if|in|including|into|is|it|it|its|just|kb|know|like|looks|mailto|make|making|many|may|mb|me|means|might|more|more|most|move|mr|much|must|my|need|needs|never|nice|nine|no|not|now|of|often|oh|ok|on|on|one|only|or|org|other|our|out|over|own|piece|rather|re|really|said|same|say|says|see|seven|several|she|should|since|single|six|so|some|something|still|stuff|such|take|ten|than|that|the|their|them|them|then|there|there|these|they|they|thing|things|this|those|three|through|to|too|took|two|under|up|us|use|used|using|usual|ve|very|via|want|was|way|we|we|well|were|what|when|where|whether|which|while|whilst|who|why|will|with|within|would|yes|yet|you|your"; $content =~ s/\b($commonWordsArray)\b//g; $content =~ s/<([^>]+?)>//g; $content =~ s/(\s+)/,/g; $content =~ s/,(,+)/,/g; return $content; } =start /** * Creates the navigation bar * @param int $start_record, * @param int $pps, * @param int $total_estimated * *@return string */ =cut sub get_nav_bar { my ( $start_record, $pps, $no_of_records ) = @_; my $uri = $ENV{ REQUEST_URI }; #Get $uri like prefix-Title-s00?p1=v1&p2=v2 $uri =~ s/\-s(\d+?)\b//; #Format $uri like prefix-Title?p1=v1&p2=v2 my $request_uri = $uri; my $total_pages = ceil( $no_of_records / $pps ); my $current_page = ceil( $start_record / $pps ); my $navbar_tpl = HTML::Template->new( filename => "templates/nav_bar.tpl" ); #Construct PREV link my $prev_link = $uri; if ( $start_record > 0 ) { my $start = 0; if ( $start_record - $pps >= 0 ) { $start = $start_record - $pps; } $prev_link =~ s/(\?|$)/-s$start$1/; } my $show_prev = 0; if ( $start_record > 0 ) { $show_prev = 1; } $navbar_tpl->param( show_prev => $show_prev ); $navbar_tpl->param( link_prev => $prev_link ); #Construct NEXT link my $next_link = $uri; if ( $start_record < $no_of_records ) { my $start = $no_of_records; if ( $start_record + $pps <= $no_of_records ) { $start = $start_record + $pps; } $next_link =~ s/(\?|$)/-s$start$1/; } my $show_next = 0; if ( $start_record < $no_of_records ) { $show_next = 1; } $navbar_tpl->param( show_next => $show_next ); $navbar_tpl->param( link_next => $next_link ); #return ""; my $tmp_page; my @pages_array = (); my @progress = ( 1000, 100, 10, 5, 4, 3, 2, 1 ); if ( $request_uri eq '/index.pl?skipcache=y') { $request_uri = 'Top+Stories'; =start my $OLD_FH = select(); select (STDOUT); print ""; select ($OLD_FH); =cut } my $page_link = ""; my $page_nr; foreach $step ( @progress ) { $page_link = $request_uri; my $start = 0; if ( $start_record - $step * $pps >= 0 ) { $start = $start_record - $step * $pps; $page_nr = ceil( $start / $pps ) + 1; $page_link =~ s/(\?|$)/-s$start$1/; push( @pages_array, { 'link_number' => $page_link, 'number' => $page_nr, 'selected' => 0 } ); } } $page_nr = ceil( $start_record / $pps ) + 1; push( @pages_array, { 'link_number' => $request_uri, 'number' => $page_nr, 'selected' => 1 } ); @progress = reverse @progress; foreach $step ( @progress ) { $page_link = $request_uri; my $start = 0; if ( $start_record + $step * $pps <= $no_of_records ) { $start = $start_record + $step * $pps; $page_nr = ceil( $start / $pps ) + 1; $page_link =~ s/(\?|$)/-s$start$1/; push( @pages_array, { 'link_number' => $page_link, 'number' => $page_nr, 'selected' => 0 } ); } } $navbar_tpl->param( pages_array => \@pages_array ); return $navbar_tpl->output(); } sub echo { my $OLD_FH = select(); select( STDOUT ); print Dumper( \@_ ); select( $OLD_FH ); } sub get_comments_list { # Get the comments list my $comments_base_url = "http://wssearch.worldnewx.com/ws_comments.pl?apikey=worldofnews.com-1495998270"; my $comments_list_url = $comments_base_url . "&opt=get&id=0&docid=$news_id"; my @tmp_comments_array = get_and_unserialize( $comments_list_url ); @tmp_comments_array = @{ $tmp_comments_array[ 0 ][ 1 ] }; my @comments_array = (); my $iterator = 0; foreach ( @tmp_comments_array ) { if ( $_->{ pending_delete } eq 'n' ) { $_->{ pending_delete } = 0; } #pending delete $_->{ usermail } = ''; #Hide email $_->{ apikey } = ''; #Hide api key $_->{ bg_color } = ( $iterator % 2 == 0 ) ? '#FFFFFF' : '#FFFF99'; #Add background color push( @comments_array, $_ ); $iterator++; } my $comments_list = ""; if ( $#comments_array > -1 ) { my $tpl_comment_list = HTML::Template->new( filename => "templates/comment_body.tpl", global_vars => 1 ); $tpl_comment_list->param( 'comments_array' => \@comments_array ); $comments_list = $tpl_comment_list->output(); } return $comments_list; } sub print_server_busy_message{ my $message = shift(); print "

$message

\n
\n"; print "Server busy! Please try again in a few seconds !"; exit(); } #::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: #::::::::::: CLASS DEBUG ::::::::::::::::::::::::::::::::: #::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: package DEBUG; use Data::Dumper; my $flag = 0; #1 = debug activated my $__START_TIME__; sub new() { $__START_TIME__ = time(); bless {}, shift(); } #Gets the start time of the debug sub get_start_time { return $__START_TIME__; } #Show the debug message according with the flag sub show { my $this = shift(); my $message = shift(); if ( $flag == 1 ) { my $hash = shift(); my $OLD_FH = select(); select( STDOUT ); print Dumper( $message ); select( $OLD_FH ); } } #Sets a value for the flag sub set_flag { my $this = shift(); my $newVal = shift(); $flag = $newVal; } #::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: 1; /$ad_manager_content/; return $content; } sub get_and_unserialize { my $url = shift(); my $serialized_news = get( $url ); my @news_array = (); eval { @news_array = unserialize( $serialized_news ); }; if ( $@ ) { print( "\n\n Error: $serialized_news \n\n" ); print Dumper( $@ ); exit(); } return @news_array; } sub get_worldinphotos_image { my $url = "http://www.worldinphotos.com/ws_export/300x250/tags/world.jpg"; return unserialize( get( $url ) ); } #Returns the array for the right section sub create_right_section { my $dbh = shift(); my @special_category_array = ( 268435469, # Business 671088651, # Education 671088644, # Entertainment 1073741831, # Health 1610612742, # Law 1744830518, # Movie News 1744830569, # Music 2550136844, # Sports 2684354563, # Technology 2818572289, # Us 3087007746 # World ); my $return_content = ""; foreach my $category ( @special_category_array ) { my $section_tpl = HTML::Template->new( filename => "templates/news_section.tpl" ); my @tmp_array = get_and_unserialize( $news_search_link . "&opt=cat&nr=2&c=$category" ); my @tmp_data_arr = @{ $tmp_array[ 0 ]->{ records } }; @tmp_array = (); foreach ( @tmp_data_arr ) { $_->{ enc_category } = url_encode( $_->{ cname } ); $_->{ img } = ""; if ( length( $_->{ description } ) > 55 ) { my $break_char_index = index($_->{ description }, '', 55); if ($break_char_index > -1) { $break_char_index += 4; # Also add the length of $_->{ description } = substr( $_->{ description }, 0, $break_char_index ) . "..."; } # $_->{ description } = substr( $_->{ description }, 0, 55 ) . " ..."; } $_->{ description } = strip_slashes($_->{ description }); $_->{ pub_date } = format_pub_date( $_->{ pub_date } ); push( @tmp_array, $_ ); } $section_tpl->param( enc_category_name => $tmp_array[ 0 ]->{ enc_category } ); $section_tpl->param( category_name => $tmp_array[ 0 ]->{ cname } ); $section_tpl->param( news_section => \@tmp_array ); $return_content .= $section_tpl->output(); } return $return_content; } sub get_news_array { my $cat_id = shift(); my @tmp_array = get_and_unserialize( $news_search_link . "&opt=cat&nr=5&c=$cat_id" ); return @{ $tmp_array[ 0 ]->{ records } }; } sub create_news_list_content { my @news_list = @{ shift() }; my $news_vlist_content = ''; if ( $#news_list > -1 ) { foreach my $row ( @news_list ) { $news_vlist_content .= format_story( $row ); } } else { $news_vlist_content .= format_story( 0 ); } return $news_vlist_content; } sub format_story { my $row = shift(); my $news_vlist_content = ''; ################################################### my $news_content = HTML::Template->new( filename => "templates/news_body.tpl" ); if ( $row ) { $row = adjust_news_object_fields( $row ); $news_content->param( 'id' => $row->{ permaid } ); $news_content->param( 'link' => $row->{ link } ); $news_content->param( 'won_link' => $row->{ won_link } ); $news_content->param( 'title' => $row->{ title } ); $news_content->param( 'description' => $row->{ description } ); $news_content->param( 'site_name' => $row->{ source_name } ); $news_content->param( 'pub_date' => $row->{ pub_date } ); $news_content->param( 'topic' => $row->{ cname } ); $news_content->param( 'img' => $row->{ img } ); $news_content->param( 'visits' => $row->{ visits } ); } else { $news_content->param( 'no_records' => 1 ); } $news_vlist_content .= $news_content->output(); #push ( @topstories_array, { 'title' => $rows[2], 'description' => $rows[3]}); return $news_vlist_content; } =start /** * @param object $row * @param character $limit_description_length * * @return object */ =cut sub adjust_news_object_fields { my $row = shift(); my $limit_description_length = shift(); $limit_description_length = 'y' unless defined $limit_description_length; $row->{ cat_id } = int( $row->{ cat_id } ); $row->{ geo_id } = int( $row->{ geo_id } ); $row->{ permaid } = int( $row->{ permaid } ); #$row->{won_link} = "/view-" . $row->{permaid} . ".html"; =start $row->{description} = decode_entities($row->{description}); $row->{description} =~ s/<([^<]+?)>//g; $row->{title} =~ s/<([^<]+?)>//g; =cut if ( ( length( $row->{ description } ) > 200 ) && ( $limit_description_length eq 'y' ) ) { $row->{ description } = get_short_description($row->{ description }); } $row->{ description } = strip_slashes($row->{ description }); if ( ( $row->{ source_name } eq 'aniin.com' ) || ( $row->{ source_name } eq 'IANS.in' ) ) { my $encoded_title = $row->{ title }; $encoded_title =~ s/[^a-zA-Z0-9]/-/g; $encoded_title =~ s/\-(\-+)/-/g; $encoded_title =~ s/^(\-+)//g; $encoded_title =~ s/(\-+)$//g; $row->{ won_link } = "http://www.indiasnews.com/News-" . $row->{ permaid } . "-$encoded_title.html"; $row->{ link } = $row->{ won_link }; } #Trick: if 0 views generate random between 0 and 10; if ( $row->{ votes } eq 0 ) { $row->{ votes } = int( rand( 10 ) ); } $row->{ pub_date } = format_pub_date( $row->{ pub_date } ); $row->{ enc_category } = encode_entities( $row->{ cname } ); return $row; } sub get_short_description{ my $description = shift(); $description = strip_slashes($description); my $break_char_index = index($description, '', 200); if ($break_char_index > -1) { $break_char_index += 4; # Also add the length of }else{ $break_char_index = index($description, ' ', 200); } $description = substr( $description, 0, $break_char_index ) . "..."; return $description; } sub format_pub_date { my $pub_date = shift(); #2008-04-13 21:12:38 => 1210702358 my @date_time = split / /, $pub_date; my ( $year, $month, $day ) = split /\-/, $date_time[ 0 ]; my ( $hour, $minute, $second ) = split /\:/, $date_time[ 1 ]; if ( $day == 0 ) { $day = 1; } =debug select (STDOUT); print "$pub_date \n"; print "$second, $minute, $hour, $day, $month, $year \n\n"; =cut $pub_date = time() - timelocal( $second, $minute, $hour, $day, $month - 1, $year ); my $tmp_time = $pub_date; my ( $s, $mi, $h, $d ); if ( $tmp_time > 60 ) { $mi = int( $tmp_time / 60 ); $s = $tmp_time % 60; if ( $mi > 60 ) { $h = int( $mi / 60 ); $mi = $mi % 60; if ( $h > 24 ) { $d = int( $h / 24 ); $h = $h % 24; } } } else { $mi = $tmp_time; } $pub_date = ''; if ( abs( "$d" ) > 0 ) { $pub_date = $d . " days ago"; } else { if ( $h > 0 ) { $pub_date .= $h . " hours and "; } $pub_date .= $mi . " minutes ago"; } return $pub_date; } sub decode_mysql_date { my $pub_date = shift(); #2008-04-13 21:12:38 my @date_time = split / /, $pub_date; my ( $year, $month, $day ) = split /\-/, $date_time[ 0 ]; my ( $hour, $minute, $second ) = split /\:/, $date_time[ 1 ]; my $ret_val = ""; if ( ( $year > 0 ) && ( $day > 0 ) ) { $pub_date = timelocal( $second, $minute, $hour, $day, $month - 1, $year ); $pub_date = scalar localtime( $pub_date ); $pub_date =~ s/( +)/ /g; my @date_array = split / /, $pub_date; my @time_array = split /:/, $date_array[ 3 ]; $ret_val = sprintf( "%s %s, %s %s:%s", $date_array[ 1 ], $date_array[ 2 ], $date_array[ 4 ], $time_array[ 0 ], $time_array[ 1 ] ); } else { $ret_val = $pub_date; } return $ret_val; } #Creates a database connection and returns databasehandler sub init_database { my $config_file_path = shift(); my $config_xml = XMLin( $config_file_path ); my $db_host = $config_xml->{ parserSettings }{ db_host }; my $db_name = $config_xml->{ parserSettings }{ db_name }; my $db_user = $config_xml->{ parserSettings }{ db_user }; my $db_password = $config_xml->{ parserSettings }{ db_password }; if ( $db_password eq "''" ) { $db_password = ''; } my $dbh = DBI->connect( "dbi:mysql:$db_name:$db_host", "$db_user", "$db_password" ) or die( "Cannot connect to the database" ); return $dbh; } sub create_cache_file_name { my ( $cat, $keyword, $news_id, $option, $start_record, $bottom_menu_id ) = @_; # #Create cache file name # my $cache_file_name = ''; if ( $cat ) { $cache_file_name = $cat; } if ( $keyword ) { $cache_file_name = $keyword; } $cache_file_name .= $news_id . $option . $start_record . $bottom_menu_id; $cache_file_name =~ s/[^a-z0-9A-Z]//g; # #Treate cache # #Split the cache in subdirectories in order to be retreived quickly #In this case will be implemented a three level cache mechanism for ( my $i = 0 ; $i < 3 ; $i++ ) { my $cache_dirLi = substr( $cache_file_name, $i, 1 ); $cache_dir = "$cache_dir/$cache_dirLi"; #$cache_dir is global if ( !( -e "$cache_dir" && -d "$cache_dir" ) ) { mkdir( "$cache_dir" ); chmod 0777, "$cache_dir"; } } $cache_file_name = $cache_dir . "/" . $cache_file_name; return $cache_file_name; } sub try_to_get_cache { my $cache_file_name = shift(); my @cache_stat = stat( "$cache_file_name.ch" ); my $cache_mtime = $cache_stat[ 9 ]; my $cache_size = $cache_stat[ 7 ]; my $current_time = time(); my $return_value = ""; if ( ( !$cache_mtime ) ) { $cache_mtime = 0; open CFH, "> $cache_file_name.ch"; close CFH; $DBG->show( "Closing CFH on checkTheCache function" ); } $DBG->show( "Cache Data \n CacheSize:$cache_size \n CacheModifiedTime:$cache_mtime \n CacheLife:" . ( $current_time - $cache_mtime ) . " \n Keyword:$keyword \n Option:$option " ); if ( ( $cache_size > 1000 ) && ( $cache_mtime > 0 ) && ( $current_time - $cache_mtime < $cache_time ) ) { $return_value = file_get_contents( "$cache_file_name.ch" ); $return_value .= "\n"; $return_value .= "\n"; } else { $return_value = ''; } return $return_value; } sub save_to_cache { my $tmp_cache_file_name = shift(); my $cache_file_name = shift(); if ( $tmp_cache_file_name ne "" ) { close( FH ); $DBG->show( "Closing FH on save_to_cache function" ); chmod 0777, "$tmp_cache_file_name.ch"; select( STDOUT ); my @cacheStat = stat( "$tmp_cache_file_name.ch" ); if ( $cacheStat[ 7 ] > 1000 ) { #stat[7] = filesize if ( unlink "$cache_file_name.ch" ) { $DBG->show( "File $cache_file_name.ch deleted ...\n" ); } else { $DBG->show( "File $cache_file_name.ch can not be deleted ...\n" ); } if ( rename "$tmp_cache_file_name.ch", "$cache_file_name.ch" ) { $DBG->show( "$tmp_cache_file_name.ch renamed to $cache_file_name.ch...\n" ); } else { $DBG->show( "$tmp_cache_file_name.ch can not be renamed to $cache_file_name.ch...\n" ); } } } } #Include a file sub include { my $fileName = shift(); open IFH, "<" . $fileName; while ( ) { print $_; } close( IFH ); $DBG->show( "Closing IFH on include function" ); } #Initiates tho collect the content to be saved into the cache sub start_collect_cache { my $cache_file_name = shift(); #Open cache file handler my $tmp_cache_file_name = $cache_file_name . time(); open FH, "> " . $tmp_cache_file_name . ".ch"; select( FH ); return $tmp_cache_file_name; } #Gets content from a file sub file_get_contents { my $file_name = shift(); my @content_lines = (); open( TMPFH, $file_name ); @content_lines = ; close TMPFH; return join( "\n", @content_lines ); } #Returh the is_homepage glag sub get_first_page_flag { my $q = shift(); my $ret_val = 0; if ( !$q->param( 'cat' ) && ( ( !$q->param( 'option' ) ) || ( $q->param( 'option' ) eq 'specops' ) ) && !$q->param( 'keyword' ) ) { $ret_val = 1; } return $ret_val; } #Visit a news sub visit_news { my $id = shift(); get( "http://wssearch.worldnewx.com/ws_status.pl?apikey=worldnewx.com-1277066279&opt=vis&permaid=$id" ); } #Vote for a news sub vote_news { my $id = shift(); get( "http://wssearch.worldnewx.com/ws_status.pl?apikey=worldnewx.com-1277066279&opt=vot&permaid=$id" ); } sub select_STDOUT { close( FH ); select( STDOUT ); $DBG->show( "Closing FH and selecting STDOUT on select_STDOUT function" ); } sub mysql_query { my $sql = shift(); my $dbh = shift(); my $sth = $dbh->prepare( $sql ); $sth->execute() or die( "Invalid query ($sql) !!!" ); $sth->finish(); } #Returns the categories array sub get_categories_array { my $dbh = shift(); my $clevel = shift(); my $sql = "SELECT * FROM `category`"; if ( $clevel > 0 ) { $sql .= " WHERE `clevel`=$clevel"; } $sql .= " ORDER BY `weight` DESC, `title` ASC"; my $sth = $dbh->prepare( $sql ); $sth->execute() || die( "Could not execute sql !!!" ); my @category_array = (); while ( my $cat_rows = $sth->fetchrow_hashref ) { push( @category_array, { 'id' => $cat_rows->{ 'id' }, 'title' => $cat_rows->{ 'title' }, 'link' => url_encode( $cat_rows->{ 'title' } ) } ); } $sth->finish(); return @category_array; } sub CategoryName2Id { my $category_name = shift(); my $sql = "SELECT `alias` FROM `category` WHERE `title`='$category_name'"; my $sth = $dbh->prepare( $sql ); $sth->execute() || die( "Could not execute sql !!!" ); my $cat_row = $sth->fetchrow_hashref; return ( ( $aArchiveIndex{ lc( substr( $category_name, 0, 1 ) ) } << 27 ) + $cat_row->{ alias } ); } sub url_encode { my ( $string ) = @_; $string =~ s/(\W)/"%" . unpack("H2", $1)/ge; #$string# =~ tr/.//; return $string; } sub url_decode { my ( $string ) = @_; $string =~ tr/+/ /; $string =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack("C", hex($1))/eg; return $string; } sub get_description { my $content = shift(); return strip_slashes(strip_tags($content)); } sub strip_tags{ my $content = shift(); $content =~ s/\<([^>]+?)\>/ /g; $content =~ s/ +/ /g; return $content; } sub strip_slashes{ my $content = shift(); $content =~ s/\\//g; return $content; } sub get_keywords { my $content = shift(); my $commonWordsArray = "able|about|after|again|all|almost|already|also|although|am|an|and|another|any|are|are|around|as|at|based|be|because|been|before|being|between|both|bring|but|by|came|can|com|come|comes|could|did|do|does|doing|done|each|eight|else|etc|even|every|five|for|four|from|get|gets|getting|go|going|got|had|has|have|he|he|her|here|him|himself|his|how|however|href|http|if|in|including|into|is|it|it|its|just|kb|know|like|looks|mailto|make|making|many|may|mb|me|means|might|more|more|most|move|mr|much|must|my|need|needs|never|nice|nine|no|not|now|of|often|oh|ok|on|on|one|only|or|org|other|our|out|over|own|piece|rather|re|really|said|same|say|says|see|seven|several|she|should|since|single|six|so|some|something|still|stuff|such|take|ten|than|that|the|their|them|them|then|there|there|these|they|they|thing|things|this|those|three|through|to|too|took|two|under|up|us|use|used|using|usual|ve|very|via|want|was|way|we|we|well|were|what|when|where|whether|which|while|whilst|who|why|will|with|within|would|yes|yet|you|your"; $content =~ s/\b($commonWordsArray)\b//g; $content =~ s/<([^>]+?)>//g; $content =~ s/(\s+)/,/g; $content =~ s/,(,+)/,/g; return $content; } =start /** * Creates the navigation bar * @param int $start_record, * @param int $pps, * @param int $total_estimated * *@return string */ =cut sub get_nav_bar { my ( $start_record, $pps, $no_of_records ) = @_; my $uri = $ENV{ REQUEST_URI }; #Get $uri like prefix-Title-s00?p1=v1&p2=v2 $uri =~ s/\-s(\d+?)\b//; #Format $uri like prefix-Title?p1=v1&p2=v2 my $request_uri = $uri; my $total_pages = ceil( $no_of_records / $pps ); my $current_page = ceil( $start_record / $pps ); my $navbar_tpl = HTML::Template->new( filename => "templates/nav_bar.tpl" ); #Construct PREV link my $prev_link = $uri; if ( $start_record > 0 ) { my $start = 0; if ( $start_record - $pps >= 0 ) { $start = $start_record - $pps; } $prev_link =~ s/(\?|$)/-s$start$1/; } my $show_prev = 0; if ( $start_record > 0 ) { $show_prev = 1; } $navbar_tpl->param( show_prev => $show_prev ); $navbar_tpl->param( link_prev => $prev_link ); #Construct NEXT link my $next_link = $uri; if ( $start_record < $no_of_records ) { my $start = $no_of_records; if ( $start_record + $pps <= $no_of_records ) { $start = $start_record + $pps; } $next_link =~ s/(\?|$)/-s$start$1/; } my $show_next = 0; if ( $start_record < $no_of_records ) { $show_next = 1; } $navbar_tpl->param( show_next => $show_next ); $navbar_tpl->param( link_next => $next_link ); #return ""; my $tmp_page; my @pages_array = (); my @progress = ( 1000, 100, 10, 5, 4, 3, 2, 1 ); if ( $request_uri eq '/index.pl?skipcache=y') { $request_uri = 'Top+Stories'; =start my $OLD_FH = select(); select (STDOUT); print ""; select ($OLD_FH); =cut } my $page_link = ""; my $page_nr; foreach $step ( @progress ) { $page_link = $request_uri; my $start = 0; if ( $start_record - $step * $pps >= 0 ) { $start = $start_record - $step * $pps; $page_nr = ceil( $start / $pps ) + 1; $page_link =~ s/(\?|$)/-s$start$1/; push( @pages_array, { 'link_number' => $page_link, 'number' => $page_nr, 'selected' => 0 } ); } } $page_nr = ceil( $start_record / $pps ) + 1; push( @pages_array, { 'link_number' => $request_uri, 'number' => $page_nr, 'selected' => 1 } ); @progress = reverse @progress; foreach $step ( @progress ) { $page_link = $request_uri; my $start = 0; if ( $start_record + $step * $pps <= $no_of_records ) { $start = $start_record + $step * $pps; $page_nr = ceil( $start / $pps ) + 1; $page_link =~ s/(\?|$)/-s$start$1/; push( @pages_array, { 'link_number' => $page_link, 'number' => $page_nr, 'selected' => 0 } ); } } $navbar_tpl->param( pages_array => \@pages_array ); return $navbar_tpl->output(); } sub echo { my $OLD_FH = select(); select( STDOUT ); print Dumper( \@_ ); select( $OLD_FH ); } sub get_comments_list { # Get the comments list my $comments_base_url = "http://wssearch.worldnewx.com/ws_comments.pl?apikey=worldofnews.com-1495998270"; my $comments_list_url = $comments_base_url . "&opt=get&id=0&docid=$news_id"; my @tmp_comments_array = get_and_unserialize( $comments_list_url ); @tmp_comments_array = @{ $tmp_comments_array[ 0 ][ 1 ] }; my @comments_array = (); my $iterator = 0; foreach ( @tmp_comments_array ) { if ( $_->{ pending_delete } eq 'n' ) { $_->{ pending_delete } = 0; } #pending delete $_->{ usermail } = ''; #Hide email $_->{ apikey } = ''; #Hide api key $_->{ bg_color } = ( $iterator % 2 == 0 ) ? '#FFFFFF' : '#FFFF99'; #Add background color push( @comments_array, $_ ); $iterator++; } my $comments_list = ""; if ( $#comments_array > -1 ) { my $tpl_comment_list = HTML::Template->new( filename => "templates/comment_body.tpl", global_vars => 1 ); $tpl_comment_list->param( 'comments_array' => \@comments_array ); $comments_list = $tpl_comment_list->output(); } return $comments_list; } sub print_server_busy_message{ my $message = shift(); print "

$message

\n
\n"; print "Server busy! Please try again in a few seconds !"; exit(); } #::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: #::::::::::: CLASS DEBUG ::::::::::::::::::::::::::::::::: #::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: package DEBUG; use Data::Dumper; my $flag = 0; #1 = debug activated my $__START_TIME__; sub new() { $__START_TIME__ = time(); bless {}, shift(); } #Gets the start time of the debug sub get_start_time { return $__START_TIME__; } #Show the debug message according with the flag sub show { my $this = shift(); my $message = shift(); if ( $flag == 1 ) { my $hash = shift(); my $OLD_FH = select(); select( STDOUT ); print Dumper( $message ); select( $OLD_FH ); } } #Sets a value for the flag sub set_flag { my $this = shift(); my $newVal = shift(); $flag = $newVal; } #::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: 1;
__AD_MANAGER_ADS__

 
US

Lake Placid Race Report...And more!
Jul 28, 2008 07:36
Time sure does pass quickly. Just a week ago, I was navigating my way solo, across the United States. I boarded one plane for Chicago. Then connected to another plane traveling to Vermont. By early evening, I was in Burlington, Vermont.  Leaving the airport in a rented automobile, I always find it thrilling to really have no idea where I am going.  Call it Wanderlust.  And no matter where I was heading, I wasn't getting there very quickly.  With both hands firmly on the wheel, I was cruising along at the maximum speed of 35 mph.  Gravelly, back-country roads, leading me through effervescent green pastures and stoic churches, I found myself mesmerized.  I am on my way to beautiful, dreamy Lake Placid. This will be the scene of my 4th Ironman competition.Arriving to my Upstate New York race site, I wasn't feeling as great as my surroundings.  Joe, my TP Training Partner who opened his majestic home to me, wasn't feeling well either.  He had traveled to Lake Placid from Taiwan.  We were both in horrible shape.  After dinner and a cup of tea yes, tea for me, not margaritas-I must have been sick we headed directly to the store and stocked up on medication.  The moon was full and my sleep was solid.  I rose in the morning feeling nearly 100%.The Pre-Ironman days fly by.  Thursday was grocery shopping and a run and swim, Friday was a bike ride. Saturday was all the stuff you need to do before Ironman.  And in between, it's acclimation and preparation time.  What kind of prep There is Registration and an Athletes Meeting and picking my bike up from its transportation trailer which carried it across the country. There are meals to cook for friends and their family… Preparing "Transition Bags" and prepping my bike for check in. It doesn't matter how many times I have gone through all this IM pre-race rituals before, I am still on edge and question each decision I make.  Wetsuit, goggles, Trisuit. Flexpower, Ibuprofen, Ginseng, Hammer Gels, Cliff Blocks, M & M's and two Peanut Butter and Jelly sandwiches.  Carbo-Gain for my water bottles, extra socks, arm warmers, rain jacket, another pair of socks, sweat bands, sunglasses, cycling gloves, helmet and cycling cleats. An extra rubber band for my hair, headband and extra running shoes, just in case my original pair are too wet from rain.  Bike repair kit-2 tubes, tools, CO2 cartridges.  By Saturday night the night before Ironman! it's time for church. I look forward to exploring new churches of all faiths. Catholic, Presbyterian, Episcopalian, Baptist, Buddhist.  As long as I can pray, I can calm my worries. And as long as I can give thanks and praise, I am at peace. This time, my visit was to a Baptist Church. The singing was delightful.  I sang along and completely surrendered. I felt, simply wonderful! No one ever sleeps the Saturday night before Ironman. I made several phone calls to family and friends, and then watched Bridget Jones Diary on televison until 12:30 in the morning. I didn't need an alarm to wake up on race morning. I quickly darted out of my room at 4:30am. Danville Tom, TP Joe and I arrived for the marking of our bodies, checking our bikes and getting our wetsuits on for the beginning of the race.  We arrived and hour and a half early.  There was no time to spare. I truly miss not having my camera.  This would be the first race EVER, without a camera. However, I knew it would rain and the condensation would damage my coveted camera. More importantly, I knew it would be too dangerous to snap pictures while racing my bike on the slick, rain soaked bike course. I slipped my toes into the sandy beach, marking my normal spot on the Swim Starting Line. This spot is well behind everyone else.  The canon fired and I let all the stronger swimmers go first.  I begin my swim officially 1minute and 15 seconds behind the pack.  Much to my surprise, I caught up with other swimmers quickly. I was hit, scratched, tugged and dunked.  It was a fight in the water. To swim 2.4 miles in Lake Mirror, this requires two laps.  My first lap was 45 minutes.  I exited the beach, ran around the designated Pillars and then jumped back into the water.  My second lap just as aggressive! was 43 minutes.  Total swim time was 1:28 minutes.  As I saw the clock, I screamed and jumped for joy!  I shaved 6 minutes off my normal Ironman swim time! It was a long transition to the bike.  We ran out of the soggy park surrounding the lake, down 2 or 3 blocks to the official Ironman grounds.  It was poring rain as I made it into Transition to grab my bags.  I dashed into a tent to change into my bike gear and exited into muddy, muddy conditions.  I ran for my bike, saddled up and did not return until 56 miles later.  Loop one completed.  Another 56 miles to go! It never, ever stopped raining.  Ever.  There is much to be said about the bike leg of the competition.  But that itself is another blog.  Let's just say, it was a hilly course sprinkled with tough climbs when you least need them.  I felt very strong in the first 56 miles, my training was perfect.  I tired a bit by mile 90.  Not bad, considering I usually begin to fade at mile 80. I lost my Peanut Butter and Jelly sandwich somewhere between mile 56 and 65. Never did I feel it slip out of my rain jacket. This caused me to worry about the possibility of the lack of fuel.  However, I still had M&M's, plenty of gels, Cliff Blocks, Carbo Gain, water and Gatorade.  I should be fine and reminded myself to load up on food ASAP on the run. Total bike time: 7:25. The second lap was 30 minutes slower than the first.  Not what I was hoping for, but still 11 minutes faster than my IM Switzerland bike time. Actually, considering this tough, hilly, rainy Bike course, not too bad of a time for me!  I am a terrible climber. The Marathon. There was a time, when this was once my specialty.  After Winter-injuries, I now know what it's going to take to pull through.  The rain was relentless, but I stripped off my rain jacket.  My arm warmers were soaked, so I took those off too.  I felt by running, if I could keep moving, I would stay warm.  I was wrong. By mile 8, people were pulling out of the race due to hypothermia. I have never seen so many ambulances and medical trucks on a race course before.  We had been enduring wet conditions for over 10 hours now, and the stiffness and numbness of the harsh weather elements were taking its toll. Rewind back to a point on the Bike course, when a fellow rider asked me if I had any Ibuprofen.  She had broken a rib in a crash, but wanted to try and finish.  I knew I would regret handing over my precious "Vitamin I", but it was the Christian thing to do. Fast forward to the Run.  Mile 13. My body was stiff, my fingers numb and my knowledge of weather was telling me, I am becoming hypothermic.  I looked up at the dark clouds and I said, "Dear God, I did the right thing and I handed over my Ibuprofen. I need help now, please do not abandon me". No, I didn't find any Ibuprofen, but I found an abandon soaked garbage bag on the side of the road.  I slipped the bag on over my body.  I ran with the bag from mile 13 to 24, quickly feeling the core of my body warm.  I could flex my fingers again and I could bend my knees. As I approached mile 24, the rain suddenly stopped.  I smiled knowing I would be at the Finish Line in 25 minutes or less. I shed the garbage bag and picked up my speed. Running full speed to the Finish Line, I had no idea what my official time would be.  It was during the second lap of the bike, I had decided to no longer look at my watch, rather concentrate just on finishing the race. As I crossed the Finish Line and saw my time of 14:07, I burst into big alligator tears!  A Personal Best for me!  I shaved 20 minutes off my IM Switzerland time!  Nearly a full hour faster than my first Ironman Canada four years earlier! This latest feat, on a much harder course, in unforgiving weather conditions! As I cried, a man asked me if I was "OK".  I explained yes, and continued to weep.  He asked me again, "Lady are you sure you are ok" I think I startled him as I replied, "Excuse me, I'm having a moment here!"  Yes, it is a little awkward not having anyone dear to me at the Finish Line to share in such a special, precious moment.  Ironman USA was without question, the most difficult challenge of my life.  But I accomplished the six months of training for me.  I finished the race for me.  I needed this journey to see what kind of fighting spirit lives within my soul.  I wanted to feel the pain and I yearned to experience the glory. I learned how to strategize; I learned from my own mistakes and wept with success.  I feel alive! On Iroman Race Day, we are all created equally.  Sure, there are some athletes who are Superman and can fly faster than others.  But this is how I see it. It doesn't matter if you are black, white or brown. It doesn't matter where you are from.  It doesn't matter how educated you are or how much money you earn a year.  You either finish the race, or you don't.  As my fourth Ironman medal was draped around my neck, I felt a "warmness" flush trough my skin. My body tingled. I hope to feel that rush for quite sometime.  PS…Oodles of kudos to my buddy, Tom Glynn #1540, who had a Personal Best, blazing a trail of 11:12:58.  And congratulations to TP Joe Gorfinkle, #1646, with a PB of 12:40!  The East Coast storminess did not dampen the talents of these West Coast Athletes!  



News related by topic - US:
NH city rallies around refugees to banish bedbugs AP - Yahoo
SC gov gambles to 'lay it all out' about affair AP - Yahoo
Lawyers seek freeze on HealthSouth ex-CEO's assets AP - Yahoo
Web support pours out for Iran protesters AP - Yahoo
Video: The Wildcard: Starface - CBSNews
Test Drive: 2010 Mazda3 hatchback punches it up - USAToday


News related by source - CBS5:
Expert On 3 Heart Tests For Women - CBS5
Did A SF Hospice Patient Die Too Soon - CBS5
Iran Accuses U.S. Of Meddling After Disputed Vote - CBS5
Raw Video: Schwarzenegger Talks Budget In Fresno - CBS5
Some Vallejo Employees To Get Raises - CBS5
Schwarzenegger Faces Tough Crowd Over Budget - CBS5



 
casino
News, World News, News Headlines, Top Stories, Breaking News, Globals News at www.worldofnews.com
Indian News, News from India, India News, Indian News Headlines, Indian breaking news, News, World news at www.indiasnews.com
UK News, British News, English News, News from UK, UK headlines, UK top stores, England News, Britain news, world news at www.worldofnews.co.uk
Home | About Us | Get News Feeds | Advertise Here | Terms of Service | Privacy Policy | Contact Us | Site Map