Yesterday's News Archive

Custom Search

News Finder

Enter topic, city or zip or try our Advanced Search
 
Picture 145 - Nature - Clouds
Picture 145 - Nature - Clouds
Nature - Clouds Photos - Picture 145
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__

 
Technology

Gallery: NASA's Most Amazing Extraterrestrial Vehicles
Jul 27, 2008 13:44
: Image: Courtesy NASANASA's mission is to take humans where they've never been before, so in honor of the agency's 50th anniversary, we take a look through the vehicles NASA's used to carry us into the unknown. This gallery looks through all the eras of NASA from the early glorified missile launches of the pre-NASA 1950s through the Apollo moon missions to the shuttle era and beyond. In the process, we provide you with a brief history of the agency and human progress in space exploration, from the first satellite launches to the Mars Phoenix Lander. Explorer 1Left: With the successful launch of the Juno 1 rocket, the United States entered the Space Age. That rocket, shown here, placed the Explorer 1 satellite into orbit around the Earth in January 1958. Explorer marked an important milestone in the space race between the United States and the USSR, as the Russians had launched the first-ever satellite in October 1957. Explorer's launch actually predated the formation of NASA by a few months: It was carried out by the Army Ballistic Missile Agency, indicating that the United States viewed space both as a frontier and a prospective battlefield. After several months of data transmission, the Explorer's batteries died in May. It hung in orbit until March 1970, when it burned up over the Pacific. : Image: Courtesy NASAAstronaut Alan Shepard became the first American in Space 47 years ago. He flew aboard his Mercury-Redstone 3, named Freedom 7, to make a historic 15-minute suborbital journey May 5, 1961. This image shows Shepard in the craft before launch. After being stuck in the tiny capsule for four hours and suffering through a myriad of delays, Shepard imploredmission control to "fix your little problem and light this candle."Soviet cosmonauts ejected from their vehicles before landing, so Freedom 7 became the first ship to take a human into space and return him all the way to the Earth's surface. But it wasn't easy. Before the craft splash-landed map coordinatesin the Atlantic Ocean off Florida, Shepard was subjected to 11 g's of force.: Image: Courtesy NASAAfter the Freedom 7 briefly entered space, NASA's next step was to put an American into orbit. They accomplished the feat on February 20, 1962 with the Friendship 7, another Mercury spacecraft, propelled into space by the new Atlas rocket. John Glenn circled Earth three times in a flight that lasted a total of 4 hours, 55 minutes, 23 seconds.Left: Test Mercury spacecraft are assembled at Langley Research Center, Virginia.: Image: Courtesy NASAAs a reusable hypersonic craft that flew at the edges of space, the X-15 rocket plane is considered by some to be the most-direct predecessor to the space shuttle, and the bridge between standard jets and spacecraft. Eight test pilots had a chance to fly the craft, including NASA research pilot Bill Dana, pictured here next to X-15 No. 3. He reached a top speed in the plane of almost 4,000 miles per hour and soared 59 miles high.: Image: Courtesy NASAThe most famous space mission in human history marked the first time that human beings had set foot on another celestial body. The Saturn V rocket blasted the astronauts into space July 16, 1969, on their way to the moon. Four days later, the command module circled the moon as the lunar lander brought astronauts Neil Armstrong and Buzz Aldrin to the surface. Stepping onto the moon for the first time, Armstrong delivered his famous line, "That's one small step for man, one giant leap for mankind.": Image: Courtesy NASAThis is a model of the Eagle that landed. The Apollo program's lunar lander remains the only vehicle to carry human beings to the surface of another celestial body and then return them home. Twenty feet tall and 14 feet in diameter, it remains an engineering marvel. Half the module was designed for the descent stage and the other half for takeoff and rendezvous with the orbiting command module. Initially plagued with cost and schedule overruns, it eventually became the most dependable piece of the Apollo infrastructure: Six of these landers made the trip to the moon. : Image: Courtesy NASAThe Apollo lunar roving vehicle was an electric dune buggy built for the moon. One was included in each of the last three manned missions to the moon, Apollo 15 to Apollo 17. Each rover drove more than 15 miles across the lunar surface, ranging several miles from the landing module and reaching a maximum speed of 8 mph. Here, we see Apollo 17 mission commander Eugene Cernan with that mission's rover. For some detailed fantasy fodder, check out NASA's Lunar Rover Operations Handbook -- just in case you're ever kidnapped, sent through a time machine and forced to stand in for Cernan. : Image: Courtesy NASASkylab, America's first experimental space station, was launched in 1973 and soon hosted its first crew, who conducted experiments in solar astronomy, Earth resources and medicine, as well as five student experiments. In total, the lab was occupied for 171 days, with residents logging 42 hours of spacewalks. In 1979, it experienced an unexpectedly early re-entry and fell from the sky over Esperance, Western Australia. "There was this bunch of brightly colored lights, followed by big sonic booms," Stan Thornton, a resident of the town, told Wired.com in 2001. "The sky lit up like a big retail shop." : Image: Courtesy NASA/JPLThe Voyagers, as a duo, were both launched in 1977 and are now the farthest human objects from Earth. After providing the first looks at Jupiter's giant red spot, Voyager 1 is now almost 10 billion miles from Earth and outside the known orbit of any natural solar object, excluding long-period comets. It will be the first human object to reach interstellar space. Voyager 2 is on a similar path.Left: This shot of Neptune is among the last photos that the spacecraft took before heading out of the solar system. : Image: Courtesy NASADesigned to usher in a new era of reusable spacecraft, the various space shuttles have carried out more than 120 missions and have deployed more than 60 satellites, including the groundbreaking Hubble Space Telescope. Sometimes called the most complex machines ever built, they've flown hundreds of millions of miles. However, their successes have been shadowed by the high-profile, lethal endings of the Columbia and Challenger. Three ships, the Atlantis, Endeavour and Discovery pictured will remain in service until 2010, when the shuttles will be retired. They'll be replaced by the next-generation Ares launch vehicles. : Image: Courtesy NASAIn 1997, NASA aimed the Cassini-Huygens spacecraft towards Saturn and waited. Seven years later, Cassini entered Saturn's orbit and has been sending back beautiful images of the planet, its moons and rings ever since. Cassini jettisoned the Huygens probe in December 2004. After orbiting Titan, Huygens landed on that moon in January 2005, sending scientists the most-detailed images of Titan's surface ever seen. Since then, Cassini has continued to image the planetary system. Here, Saturn's pale, icy moon Dione is offset by the gold and blue hues of the planet, in this image taken October 11, 2005. The horizontal stripes near the bottom of the image are Saturn's rings. Cassini was nearly in the same plane as the rings when the image was taken, making them look thin and masking their awesome scale.: Image: Courtesy NASAWhen the international space station is completed, it will be a 900,000-pound, 190-by-146-foot orbiting hub for space science and exploration -- probably the most complicated space endeavor ever undertaken. Assembled in orbit from component modules, it has about 15,000 square feet of living space and has been continuously inhabited since November 2000. It's powered by 240 square feet of solar arrays and features a suite of scientific modules, including NASA's Destiny, which became the agency's first permanent lab since SkyLab when it went into operation in 2001. When all is said and done, the total cost of the ISS could end up running to $100 billion. Given that steep price tag, and with NASA firmly focused on the moon and Mars, the ISS's future looks murky. : Image: Courtesy NASAIn one of the most creative missions in NASA history, the Deep Impact spacecraft actually fired a projectile into the surface of Comet Tempel 1 to learn more about its interior. Even though blasting the comet was the flashiest part of the 2005 mission, further observation by the spacecraft's main imager captured another surprise: the first-ever evidence of water ice on the surface of a comet. In this picture, the "impactor" is located at the bottom of the craft. : Image: Courtesy NASA/JPL/UA/Lockheed MartinOne of NASA's "cheaper, better, faster" missions, the little lander that could completed a perfect touchdown in May of this year near the Martian north pole. In the next month, it will finish a series of tests to assess the suitability for life of the ice-laden Martian dirt. Then, after a mere 90 days on the surface, it will shut down, never to be heard from again. Here, the lander is pictured in prelaunch trials in 2007.: Image: Courtesy NASA/Sean SmithThe model for the next generation of lunar rover isn't a buggy: It's a truck. The "crew mobility chassis" is designed to provide astronauts with maximum mobility, with all of its wheels able to pivot in any direction. Another key aspect of the lunar truck is that it serves as a mobile control station for robots like the K10, seen in the distance of this image snapped during a training exercise.



News related by topic - Technology:
A Day With 400 Tweets Starts With Simplicity - TheNewYorkTimes
Photos: NASA's science, tech showcase - News
The cathedral plus the bazaar: Open source and Apple design envy - News
Debate: Can the Internet handle big breaking news - News
Google thought Michael Jackson traffic was attack - News
Buy-buy Michael Jackson - News


News related by source - WiredNews:
Court Stiffs Veterans Caught in Privacy Breach - WiredNews
Jury Slaps $2 Million Fine on Jammie Thomas - WiredNews
How Science Fiction Writers Can Help, or Hurt, Homeland Security - WiredNews
Facebook, Google Go Persian, Helping Iran's Activists - WiredNews
How-To Wiki: How to Open a Beer Bottle With a Lighter - WiredNews
You Might Be Married to a GeekDad If ... - WiredNews



 
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