#!/usr/bin/perl -w ; ############################################################################## ############################################################################## use POSIX; use DBI; use strict ; #DEBUG my $want_elog = 0; sub page1() ; sub page2() ; sub page3() ; sub page4() ; sub page5() ; sub page5a() ; sub page6() ; sub page7() ; sub story() ; sub dispcat() ; sub pageAP() ; sub googAd($) ; sub get_cats($$$) ; sub make_m3u($$) ; my $filename = "template.html" ; my $oururl = "" ; my $formdata ; my $datasize ; my $elog = "" ; my $thistag ; my %args ; my $dbh ; my $dsn ; my $sth ; my $rv ; my $max_rows ; my @row ; my @rank ; my $query ; my @boxes ; my $bx = 0; ##index into boxes my $photo_links = "" ; ## setup a fake database my %catData ; ## length of intro in milliseconds $catData{'90000.0100'}[0] = 7000; $catData{'90000.0200'}[0] = 8000; $catData{'90000.0300'}[0] = 6000; $catData{'90000.0400'}[0] = 5000; $catData{'90000.0500'}[0] = 6000; $catData{'90000.0600'}[0] = 5000; $catData{'90000.0700'}[0] = 7000; $catData{'90000.0800'}[0] = 6000; $catData{'90000.0900'}[0] = 7000; $catData{'90000.1000'}[0] = 7000; my @btext = ( ["", "\"Vonage", 0, 60 ] , ["", "\"\"", 0, 60 ], ["", "\"\"", 0, 60 ] , ["", "\"Get", 0, 60 ] , ["", "\"\"", 0, 60 ] , ["", "\"\$10", 0, 60 ] , ["", "\"What's", 0, 60 ] , ["", "\"\"", 0, 60 ] ) ; my $request_method = $ENV{'REQUEST_METHOD'} ; if ($request_method eq "GET") { $formdata = $ENV{'QUERY_STRING'} ; $elog .= "GET request $formdata
\n" ; } elsif ($request_method eq "POST") { $datasize = $ENV{'CONTENT_LENGTH'}; $elog .= "POST content length is $datasize
\n" ; read (STDIN, $formdata, $datasize); } else { $formdata = "" ; $datasize = length($formdata) ; } my $path_info = $ENV{'PATH_INFO'} ; my $path_translated = $ENV{'PATH_TRANSLATED'} ; ## $elog .= "PATH_INFO $path_info PATH_TRANSLATED $path_translated
\n" ; my $script_name = $ENV{'SCRIPT_NAME'} ; $elog .= "SCRIPT_NAME $script_name
\n" ; my $server_name = $ENV{'SERVER_NAME'} ; $elog .= "SERVER_NAME $server_name
\n" ; $server_name = "$server_name$script_name" ; $server_name =~ s/\/index.pl// ; $elog .= "SERVER_NAME $server_name
\n" ; ##print ( "$formdata
\n"); $elog .= "FORMDATA $formdata
\n"; foreach $thistag ( split ( "&", $formdata ) ) { my $sstag = $thistag ; $thistag =~ s/[\n|\r]//g ; ## $elog .= "THISTAG1 is $thistag
\n" ; $thistag =~ s/\+/ /go ; ## $elog .= "THISTAG2 is $thistag
\n" ; $thistag =~ s/%([\dA-Fa-f][\dA-Fa-f])/pack ("C", hex ($1))/eg; ## $elog .= "THISTAG3 is $thistag
\n" ; $thistag =~ s/[\n|\r]//g ; ## $elog .= "THISTAG4 is $thistag
\n" ; my (@ts) = split "=", $thistag; ## $t2 =~ s/^\s+// ; ## $t2 =~ s/\s+$// ; my $t1 = $ts[0] ; my $t2 = $ts[1] ; for (my $i=2; $i<=$#ts; $i++) { $t2 .= "=" . $ts[$i] ; } $args{$t1} = $t2 ; if (defined $t2) { $elog .= "TAGS $t1 is $t2
\n" ; } else { $elog .= "TAGS $t1 is blank
\n" ; } $boxes[$bx++] = $1 if ($t1 =~ /box(.*)/) ; } for (my $i=0; $i<$bx; $i++) { $elog .= sprintf "BOXES $i $boxes[$i]
\n" ; } my $yb ; my $intro ; my $outro ; my $usecats ; my $header_gif ; if (0 && $server_name =~ m!/yb/!) { $yb = 1 ; $intro = "TI" ; $outro = "TO" ; $usecats = "tree='50000.4' OR tree='51000' OR tree='54000' or tree='53000'" ; $header_gif = "ap.taldia.com/b_header.gif" ; } else { $yb = 0 ; $intro = "90000.0.I" ; $outro = "90000.0.O" ; $usecats = ("tree like '90000%'") ; $header_gif = "affiliate_header.gif" ; } my ($sec, $min, $hour, $mday, $mon, $year, $wday, $yday, $isdst) = localtime ; my $sec_in_day = (($hour * 60) + $min) * 60 + $sec ; if (!defined $args{page}) { $args{page} = 1 ; } elsif ($args{page} =~ /Returning/ ) { $args{page} = 6 ; } elsif ($args{page} =~ /Back to Audio/ ) { $args{page} = 1 ; } if (defined $args{story} ) { $args{page} = 8 ; $elog .= "PAGE 8
\n" ; } if (defined $args{c}) { $args{page} = 9 ; $elog .= "PAGE 9
\n" ; } my $page = $args{page} ; ## $page = 4 if (!defined $args{story}) ; print "Content-type: text/html \n"; print "Expires: 0 \n"; print "\n"; open FILE, $filename || die "could not open $filename $!" ; while () { print $_ ; last if //i ; } print "<h1><b>MISSING TITLE</b></h1>\n" unless /title/i ; my $init_logo = 'blank' ; $init_logo = 'tri_city_300' ; if ($page == 3 || $page==2 || $page==4) { $elog .= "SKIPPING<br>" ; goto SKIPPER ; } while (<FILE>) { last if /^\s*----/ ; print $_ ; } print "<FRODO LIVES<br>\n" ; print "<!-- start taldia insert -->\n" ; #888888 print "" . "<script type=text/javascript>\n" . "var tboxes=0;\n" . "var boxes = new Array;\n" . "function make_cbox(tree,checked){\n" . " boxes[tboxes]= tree ;\n" # . " document.write(\"<span class='cathead'>\");\n" . " document.write(\"<input type='checkbox' \"+checked+\" " . " name='box\" +tboxes+ \"'> \");\n" . " tboxes++;\n" . "}\n" . "function make_chead(server,tree,cat){\n" . " document.write('<a href=\"//'+server+'?c='" . "+tree+'\">'+cat+'</a>');\n" . "}\n" . "function checkall() {\n" . " for (var i=0; i<tboxes; i++) {\n" . " var thebox = eval('document.theform.box'+i);\n" . " thebox.checked = true;\n" . " }\n" . "}\n" . "function clearall() {\n" . " for (var i=0; i<tboxes; i++) {\n" . " var thebox = eval('document.theform.box'+i);\n" . " thebox.checked = false;\n" . " }\n" . "}\n" ; print "" . "function popper(page){\n" . " var url = \"http://$server_name$script_name?page=\"+page;\n" . " var wn = \"wmpplayer\" ;\n" . " if (page == 3) {wn = \"qplayer\";}\n" . " if (page == 4) {wn = \"dlnow\";}\n" . " for (var i=0; i<tboxes; i++) {" . " var thebox = eval('document.theform.box'+i);\n" . " if (thebox.checked){\n" # . " if (h) { url += '&' ; h=1;}\n" . " url += '&box' + boxes[i] + '=true';\n" . " }\n" . "}\n" # ." url += '\"' ;" # ." alert(wn);\n" ## the following seem to not work in IE . "var inw = window.innerWidth ;\n" . "var inh = window.innerHeight ;\n" . "var otw = window.outerWidth ;\n" . "var oth = window.outerWidth ;\n" # . "alert(inw+' '+inh+' '+otw+' '+oth);\n" . "var thex = (inw-320)/2;\n" . "var they = (inh-500)/2;\n" . "wnx = (window.open(url,wn," # . "'wmpplayer'," . "'toolbar=no,location=no,status=no,directories=no,menubar=no," . "scrolling=auto,scrollbars=auto,width=320,height=500," . "resizable=yes,screenX=200,screenY=100,top=100,left=200'));\n" . "wnx.moveTo(200,100);\n" . "}\n" . "</script>\n" ; my $styles = "<!-- start taldia insert -->\n" . "<style type=\"text/css\">\n\n" # . "<!--\n" . ".cathead {" . "font-size:16px;" . "font-family:Arial;" . "width:100%;" . "color:#a00000;\n" . "text-align:left;" . "font-weight:bold;" . "margin-top:3px;" . "padding-top:3px;" . "}\n\n" . ".cathead a {" . "font-size:16px;" . "color:#a00000;" . "margin-top:0px;" . "padding-top:0px;" . "margin-bottom:0px;" . "padding-bottom:0px;" . "}\n" . ".cathead a:link " . "{" . "text-decoration:underline;" . "color:#a00000;" . "}\n" . ".cathead a:hover " . "{" . "color:#a00000;\n" . "text-decoration:underline;" . "}\n" . ".cathead a:visited " . "{" . "text-decoration:underline;" . "}\n" . ".subline {" . "font-size:12px;" . "font-family:Arial;" . "color:#a00000;\n" . "text-align:left;" . "text-valign:bottom;" . "font-weight:normal;" . "margin-top:0px;" . "padding-top:0px;" . "margin-bottom:0px;" . "padding-bottom:0px;" . "}\n\n" . ".subline a {\n" . "color:#a00000;" . "font-size:12px;" . "font-family:Arial;" . "text-weight:normal;" . "margin-top:0px;" . "padding-top:0px;" . "margin-bottom:0px;" . "padding-bottom:0px;" . "text-decoration:none;" . "}\n" . ".subline a:hover " . "{" . "text-decoration:underline;" # . "text-weight:normal;" # . "color:#000000;" . "}\n" . ".catc {" . "font-size:12px;" . "font-family:Arial;" . "color:black;\n" . "text-align:left;" . "text-valign:bottom;" # . "font-weight:bold;" . "margin-top:25px;" . "padding-top:0px;" . "margin-bottom:0px;" . "padding-bottom:0px;" . "}\n\n" . ".catc a {\n" . "font-size:14px;" . "color:#a00000;" . "font-weight:bold;" . "margin-top:0px;" . "padding-top:25px;" . "margin-bottom:0px;" . "padding-bottom:0px;" . "}\n" . ".catc a:link " . "{" . "text-decoration:none;" . "}\n" . ".catc a:hover " . "{" . "text-decoration:underline;" . "}\n" . ".catc a:visited " . "{" . "text-decoration:underline;" . "}\n" # . "-->\n " . "</style>\n" . "<!-- end taldia insert -->\n" ; ## if this is tch convert reds to blue in style $styles =~ s/#a00000/#000080/g if $server_name =~ /^tch/ ; print "$styles" . "<form name='theform' " . "action=\"//$server_name/index.pl\" method=\"post\">\n" . "<table width=\"600\" border=\"0\" " . "cellpadding=\"0\" cellspacing=\"0\">\n" . "<tr><td width=600 colspan=\"0\" align='center'>\n" ; googAd(0) ; print "" . "<p><p>\n" . "</td></tr>\n" . "<tr align='center'>\n" . "<td colspan=\"2\"><img src=\"$header_gif\" alt=\"header\" " . "width=\"402\" height=\"120\"></td>\n" . " </tr>\n" . " <tr><td>\n" # . "<td width=\"50\" valign=\"top\"><img src=\"//ap.taldia.com/line.gif\" alt=\"\" " # . "width=\"47\" height=\"43\"></td>\n" # . " <td width=\"352\" rowspan=\"2\" align=\"justify\" valign=\"top\"><p><span style=\"line-height:20px;align:center;\"><br>\n" # . " </span>\n" ; if (0) { if (defined $args{checkall}) { $page = 4 ; } elsif (defined $args{update} && $args{update} =~ /download/i ) { $page = 5 ; } elsif (defined $args{update} && $args{update} =~ /Listen/i ) { $page = 6 ; } } # print "PAGE is $page<br>\n" ; SKIPPER: ; page1() if ($page == 1) ; page2() if ($page == 2) ; ##wmp popup page3() if ($page == 3) ; ##quicktime popup page4() if ($page == 4) ; ##download popup page5() if ($page == 5) ; page6() if ($page == 6) ; page4() if ($page == 7) ; story() if ($page == 8) ; dispcat() if ($page == 9) ; goto SKIPPER_AGAIN if $page==3 || $page==2 || $page==4; print "<tr><td> </td></tr>\n" . "<tr><td colspan=\"2\" align='center'>\n" ; googAd(1) ; print "" . "<tr><td> </td></tr>\n" . "</td></tr>\n" . " </table>\n" . "</form>\n" . "<!-- end taldia insert -->\n" ; while (<FILE>) { last if m!</body>!i ; print $_ ; } SKIPPER_AGAIN : ; ## DEBUG if ($want_elog) { print "</center>\n" ; print $elog ; } print "</body>\n</html>\n" ; exit(0) ; sub page1() { print "" ## " <strong>Hello:</strong></p>\n" # "<ul>" # . "<li>Click the " # . "<img src=\"//images.taldia.com/speaker.gif\" alt=\"\">" # . " speaker to listen to audio summary." # . "<li>Check boxes of your favorite categories." # . "<li>Click  <b>LISTEN NOW</b> or  <b>DOWNLOAD</b>.<br>" # . "</ul><p>\n" #. "Click on  " #. "<img src=\"rss.gif\" width=\"36\" height=\"14\">" #. "<img src=\"xml-podcast.gif\" width=\"80\" height=\"15\">" #. "  for category RSS feed. " . "</td></tr>" # . "<tr><td> </td></tr>\n" # . "<tr><td> </td></tr>\n" ; the_buttons() ; print "" ## . "<tr><td>" . "<tr><td colspan=\"0\"><hr></td></tr>\n" # . "<tr><td height=\"43\" colspan=\"2\" " # . "background=\"//ap.taldia.com/wide_horiz1.gif\"> " # . "</td></tr>\n" ; # print "<tr><td valign=\"bottom\"> </td></tr>\n" ; get_cats(0, 1, 1) ; # print "<tr><td valign=\"bottom\"> </td></tr>\n" ; print "<tr><td colspan=\"0\"><hr></td></tr>\n" ; # "<tr><td height=\"30\" colspan=\"2\" " # . "background=\"//ap.taldia.com/wide_horiz2.gif\">" # . "</td></tr>\n" ; print "<tr><td> </td></tr>\n" ; the_buttons() ; ##TODO should next line be here? # print "</td>\n" ; } sub page1x() { print "San Jose Mercury News is now providing daily audio news summaries. " . "With just a few simple steps, you can create " . "a personalized playlist that will be delivered " . "to your computer automatically every day... " . "best of all, the subscription is <b>FREE</b>. " . "Click on the button below to begin." . "<form action=\"index.pl\" method=\"post\">\n" . "<input type=\"hidden\" name=\"page\" value=\"2\">\n" . "<input name=\"subscribe\" type=\"submit\" id=\"subscribe\" " . "value=\"Subscribe Now!\">\n</form><p>\n" . "<hr>" . "<b>Using the options below you can:</b><p>" . "<p>1. <b>Listen</b> to summaries of the articles " . "by clicking on the speaker.<p>" . "2. Click on  " . "<img src=\"rss.gif\" width=\"36\" height=\"14\">" . "  for category RSS feed. " . "<p>3. <strong>Read</strong> " . "the entire article by clicking on the headline. " . "</p>\n" . "</td></tr>\n" . "<tr><td> </td></tr>\n" . "<tr><td height=\"43\" colspan=\"1\" background=\"//images.taldia.com/wide_horiz1.gif\"> " . "</td></tr>\n" ; # print "<tr><td valign=\"bottom\"> </td></tr>\n" ; get_cats(0, 0, 0) ; print "<tr><td height=\"30\" colspan=\"2\" background=\"//images.taldia.com/wide_horiz2.gif\"> " . "</td></tr>\n" ; } sub page2x() { print " <strong>SIGN UP</strong></p>\n" . " <p>Please fill in the information below to have your playlist " . " delivered daily. </p>\n" . " <p class=\"breadcrumb\">Note: username and password must contain both letters and numbers </p></td>\n" . "</tr>\n" . "<tr>\n" . "<td valign=\"bottom\"> </td>\n" . "\n" . "</tr>\n" . "<tr>\n" . "<td height=\"43\" colspan=\"2\" valign=\"bottom\" background=\"horiz.gif\"> </td>\n" . "</tr>\n" . "<tr>\n" . "<td> </td>\n" . "<td><table width=\"100%\" border=\"0\" cellspacing=\"0\" cellpadding=\"0\">\n" . " \n" . "<tr>\n" . "<td width=\"24%\">Username:</td>\n" . "\n" . "<td width=\"76%\">\n" . "<input type=\"text\" name=\"textfield\" class=\"fullrailformelement\">\n" . "(min 6 characters) \n" . "</td>\n" . "</tr>\n" . "<tr>\n" . "<td>Password:</td>\n" . "<td><input type=\"password\" name=\"textfield2\" class=\"fullrailformelement\">\n" . "(min 5 characters) </td>\n" . "\n" . "</tr>\n" . "<tr>\n" . "<td> </td>\n" . "<td> </td>\n" . "</tr>\n" . "<tr>\n" . "<td>First Name: </td>\n" . "<td><input type=\"text\" name=\"textfield3\" class=\"fullrailformelement\"></td>\n" . "\n" . "</tr>\n" . "<tr>\n" . "<td>Zip Code: </td>\n" . "<td><input type=\"text\" name=\"textfield3a\" class=\"fullrailformelement\"></td>\n" . "\n" . "</tr>\n" . "<tr>\n" . "<td>Gender:</td>\n" . "<td>\n" . "<select name=\"select\" class=\"fullrailformelement\">\n" . "<option>Male</option>\n" . "<option>Female</option>\n" . "</select>\n" . "</td></tr>\n" . "<tr>\n" . "<td>Age: </td>\n" . "<td><input type=\"text\" name=\"textfieldage\" " . "class=\"fullrailformelement\" maxlength=\"3\"></td>\n" . "</tr>\n" . "<tr><td> </td><td> </td></tr>\n" . "<tr><td>Download days of week</td><td>\n" ; my $thedays = "SunMonTueWedThuFriSatSun" ; for (my $i=0; $i<7; $i++) { my $day_str = substr($thedays, $i*3, 3) ; print "<input type=checkbox name=\"day$i\" " . "value=\"$day_str\">\n" . "$day_str" ; print "<br>" if ($i == 3) ; print "   " if ($i == 5) ; } print "</td></tr>\n" ; print "<tr><td>Download Time</td><td>\n" . "<select name=\"phour\" class=\"textbox2\">\n" ; my $thour = 12 ; my $thourx = 0 ; my $tmins = 0 ; my @ampm = ("am", "pm") ; my $filler = "" ; my $tenable = 27 ; for (my $i=0; $i<96; $i++) { my $minstr = sprintf "%02i", $tmins ; my $selectit = ($i == $tenable) ? "selected" : "" ; $filler = ($thour > 9) ? "" : "  " ; print "<option $selectit, value=\"$i\">$filler$thour:$minstr " . "$ampm[$thourx]</option>" ; $tmins += 15 ; if ($tmins >= 60) { $tmins = 0 ; $thour = 1 if (++$thour >= 13) ; $thourx ^= 1 if ($thour == 12 && !$tmins) ; } print "\n" if (($i %4) == 3) ; } print "</select></font></td></tr>\n" ; print " <tr>\n" . " <td> </td>\n" . " <td> </td>\n" . " </tr>\n" . " <tr>\n" . " <td>Email Address: </td>\n" . "\n" . " <td><input type=\"text\" name=\"textfield5\" class=\"fullrailformelement\"></td>\n" . " </tr>\n" . " <tr>\n" . " <td>Confirm Email: </td>\n" . " <td><input type=\"text\" name=\"textfield6\" class=\"fullrailformelement\"></td>\n" . " </tr>\n" . " <tr>\n" . " <td> </td>\n" . "\n" . " <td>\n" . " <br>\n" . " <form action=\"$server_name\" method=\"post\">" . "<input type=\"hidden\" name=\"page\" value=\"3\">\n" . "<input type=\"submit\" name=\"Submit\" value=\"Next\"></form>\n" . " </td>\n" . " </tr>\n" . " </table></td>\n" . " </tr>\n" ; print "<tr><td height=\"30\" colspan=\"2\" background=\"horiz2.gif\"> " . "</td></tr>\n" ; } sub popup($$) { my $have_player = shift ; my $player = shift ; print "</head>\n" . "<body bgcolor='#ffffff' marginwidth=0 marginheight=0>" ; my $error_msg = "" ; my $m3u_url ; ##set up the playlist get_cats(1, 0, 0) ; if ( $oururl eq "") { $error_msg = "" . "<div style='font-size:16px;font-weight:normal;" . "margin-top:20px;margin-right:20px;margin-left:20px;" . "text-valign:middle;text-align:center;'>\n" . "<b>You did not select any content</b><p>" . "Please select your favorite category(s) or click on the " . "CHECK ALL button.<p>\n" . "Then, click PLAY AUDIO or DOWNLOAD.<p>\n" . "<img name='pic' src='//ap.taldia.com/$init_logo.jpg' \n" . "alt='300*250 picture' " . "</div>\n" ; print $error_msg ; return ; } ## oururl has all the category intro's, ads, stories, etc ## photo_links has the photos to display for everything #now put the main taldia (or replacement) intro and outro on it #and insert alaska "sponsor" ad $oururl = "$intro" . "_AD50001" . "$oururl" . "_$outro" ; $photo_links = "" ## TI is 5 seconds but give it 4 seconds extra to start up . "np(0,'ti/alaska_sponsor',10000,'');\n" . "np(0,'ti/alaska_sponsor',13500,'');\n" . "$photo_links" . "np(0,'$init_logo',1000,'');\n" ; $m3u_url = "http:" . make_m3u($oururl, 0) ; my $mp3_url = # "//users.taldia.com:81/mp?001-$sec_in_day" . "//audio.taldia.com:80/mp?001-$sec_in_day" . # "_$intro" . "_$oururl" . "_$outro.mp3" ; "_$oururl" . ".mp3" ; $photo_links = "np(0,'$init_logo',10,'');\n" . $photo_links ; $photo_links = "" if (!$have_player) ; print "" . "<script type='text/JavaScript'>\n" . "var pnames = new Array;\n" . "var ptime = new Array;\n" . "var ptype = new Array;\n" . "var phead = new Array;\n" . "var nt = 0;\n" . "var nn = 0;\n" . "function np(type,tag,t,head){\n" # . " if (type){\n" . " ptype[nt] = type;\n" . " pnames[nt] = tag;\n" . " ptime[nt] = t;\n" . " phead[nt++] = head;\n" # . " }\n" . " }\n" # . "np(0, 'small-taldia-logo',10,'');\n" # . "np(0, 'ti/alaska_sponsor',9000,'alaska airlines');\n" . "$photo_links" # . "np(0, 'small-taldia-logo',1000,'taldia');\n" # . "alert('it is '+nt);\n" ## this should preload the images but not wait for them . "if (document.images){\n" . " }\n" # . "document.title = 'Your News, Your Way';\n" . "function dp(){\n" . " if (nn >= nt) return;\n" # . " if (nn >= nt) nn = 0 ;\n" . " var loc = '//taldia.com/photos300/';\n" . " if (ptype[nn] == 0) loc = '//ap.taldia.com/';\n" . " var url = loc +pnames[nn] + '.jpg';\n" # . " alert(url);\n" #. " document.write(url+'<br>');\n" . " document.pic.src = eval(\"url\");\n" . " var tx = phead[nn] ;\n" # . " alert(tx);\n" # . " document.what.write(tx);\n" # . " document.getElementById(\"what\").innerText = 'toads' ;\n" # . " document.what.write = 'toads' ;\n" # . " document.getElementById(\"what\").writeln = 'toads' ;\n" # . " document.all(\"what\").innerText = 'toads' ;\n" # . " document.what.write('toads');\n" ## document.all path is taken with IE and worked once . " if (document.all)\n" . " document.all('what').innerHTML = tx;\n" ## assume netscape 6+ . " else\n" . " document.getElementById(\"what\").innerHTML = tx ;\n" ## the following *probably* works for NS 4 # . " else if (document.layers){\n" # . " alert('layers') ;\n" # . " document.layers['what'].document.open() ;\n" # . " document.layers['what'].document.write('toads');\n" # . " document.layers['what'].document.close() ;\n" # . " }\n" . " var dlx = nn != 0 ? ptime[nn] : 30 ;\n" . " setTimeout('dp()', dlx);\n" . " nn++;\n" . " }\n" . "</script>\n" ; ## make sure the mp3 URL is not too long my $pos = length($mp3_url) ; my $maxl = 1023 - 20; if ($pos > $maxl) { ## get last file name $pos = rindex($mp3_url, "_") ; my $tstring = substr($mp3_url, $pos) ; $maxl -= length($tstring) ; ##print STDERR "ENDER $tstring\n" ; while ( ($pos = rindex($mp3_url, "_", $pos)) >= $maxl ) { $pos--; } ##print STDERR "ENDERx pos is $pos\n" ; $mp3_url = substr($mp3_url, 0, $pos) . $tstring ; } # $m3u_url = "http://ap.taldia.com/tmp/audio.30497.m3u" ; print "" . "<table align='center' width=300 " . "border=0 cellpadding=0 cellspacing=0>\n" . "<tr align='center' valign='middle'>\n" . "<td height=70 bgcolor='#ffffff'>\n" . "<img src='//$server_name/topbanner.jpg' " . "alt='300*70 AFFILIATE BANNER' " . "width=300 height=70>\n" . "</td></tr>\n" . "<tr><td height=250 bgcolor='#ffffff' width=300 " . "align='center' valign='middle'>\n" . "<img name='pic' src='//ap.taldia.com/$init_logo.jpg' \n" . "alt='' " . ">\n" # . "$error_msg\n" . "</td></tr>\n" ## data cell for the article/ad identifier . "<tr><td height=13 width=300 bgcolor='#ffffff' align='center'>\n" ## the following div id=what line works in IE and NS 6+ #. "<div id='what' width=300 height=10 align=center>frogs</div>\n" ## the following lines might work for NS 4 #. "<div id='what' width=300 height=30 ' \n" #. "style='position:absolute;'></div>\n" # ## the following div with style info . "<div id='what' width=300 height=13 align=center " . "style='font-size:13px;font-weight:normal;" . "font-family:arial;" . "text-valign:middle;text-align:center;'" . "></div>\n" ; ## discover how high to make the td element my $tdString ; if ($player =~ /(height\=\d+)/) { $tdString = "<tr><td $1 bgcolor='#ffffff'>" ; } else { $tdString = "<tr><td height=64 bgcolor='#ffffff'>" ; } ##put the m3u url into the player string $player =~ s/#m3u_url/$m3u_url/g ; $player =~ s/#mp3_url/$mp3_url/g ; #and now put the player onto the page print "$tdString\n$player" ; ## if $have_player; print "" . "</td></tr>\n" # . "<tr><td height=13 bgcolor='#ffffff' " # . "style='font-size:13px;font-weight:normal;" # . "font-family:arial;" # . "text-valign:middle;text-align:center;'>" # . "<a href='#download_summary'>\n" # . "Click Here for Summary of This Download</a>\n " # . "</td></tr>\n" . "<tr><td height=70 bgcolor='#ffffff'>" . "<img src='//ap.taldia.com/bottombanner.jpg' " . "alt='300*70 AREA for links' " . "width=300 height=70>\n" . "</td></tr>\n" . "</table>\n" . "<script language='JavaScript1.2'>dp();</script>\n" ; } ## popup ############################################################################## ############################################################################## sub page2() { my $pstring = "" . '<OBJECT ID="Player" height=44 width="300" ' . 'CLASSID="CLSID:6BF52A52-394A-11d3-B153-00C04F79FAA6" ' . 'VIEWASTEXT type="application/x-oleobject">' . '<param name="uimode" value="full">' . '<param name="autostart" value="true">' . "<param name='url' value='#m3u_url'>" . '<param name="filename" value="$m3u_url">' . '<param name="ShowAudioControls" value="1">' . '<param name="ShowStatusBar" value="0">' . "<param name='ShowTracker' value='1'>\n" . '<EMBED type="application/x-mplayer2" ' . 'pluginspage="http://microsoft.com/windowsmedia/download/" ' . 'ID="Player" name="Player" ' . 'videoborder3d="1" width="300" height="44" ' . "src='#m3u_url' " . 'autostart="1" type="application/x-oleobject" ' . 'ShowAudioControls="1" ShowStatusBar="0" ShowTracker="1">' . "</EMBED>\n" . "</OBJECT>\n" ; popup(1, $pstring) ; } ############################################################################## ############################################################################## sub page3() { my $pstring = "" . '<OBJECT classid="clsid:02BF25D5-8C17-4B23-BC80-D3488ABDDC6B"' . 'width="300" height=30 ' . 'codebase="http://www.apple.com/qtactivex/qtplugin.cab">' #. 'width="400" height="328" codebase="http://www.apple.com/qtactivex/qtplugin.cab">' # . '<PARAM name="SRC" value="reference.txt.mov">' . "<PARAM name=\"SRC\" value=\"#m3u_url\">" . '<param name="type" value="audio/mpeg"' . '<param name="target" value="QuickTimePlayer"' . '<PARAM name="AUTOPLAY" value="true">' . '<PARAM name="CONTROLLER" value="true">' . '<PARAM name="LOOP" value="false">' # . '<PARAM name="QTSRCDONTUSEBROWSER" value="true">' # . '<EMBED src="reference.txt.mov"' . "<EMBED src=\"#m3u_url\"" . ' target="QuickTimePlayer"' . ' type="audio/mpeg"' . ' pluginspage="http://www.apple.com/quicktime/download/"' . ' height=30 width=300"" autoplay="true"' #. ' height="328" width="400" autoplay="true"' . ' loop="false" controller="true">' . '</EMBED>' . '</OBJECT>' ; popup(1, $pstring) ; } sub page4() { my $pstring = "" . "<script language='javascript'>\n" # . "window.location.href ='#mp3_url'\n" . "</script>\n" . "<table align='center'><tr>\n" . "<td bgcolor=\"#f0f0f0\" align=\"center\">" . "<a href=\"#mp3_url\">" . "<font size=\"+1\">Click to start Download</font></a>" . "</td></tr></table>\n" # </td><td width=\"30%\" </td></tr>\n" ; popup(0, "$pstring") ; } sub page3x() { print "<strong>Automatic Daily Downloads</strong></p>\n" . "To receive your playlist automatically, " . "use your favorite RSS reader " . "(My Yahoo, iTunes, iPodder... etc.) " . "or download our custom software " . "<a href=\"#\">here</a>.<p> " . "<form action=\"index.pl\" method=\"post\">\n" . "<input type=\"hidden\" name=\"page\" value=\"4\">\n" . "<input name=\"subscribe\" type=\"submit\" " . "value=\"Next\">\n" . "</form></p>\n" . "</td>\n" ; } if (0) { print "" . "<button name=\"update\" type=\"button\" " . "value=\"" . "<A HREF=\"javascript:" . "javascript:" . "void(window.open('http://ap.taldia.com/?page=3'," . "'wmpplayer'," . "'toolbar=no,location=no,status=no,directories=no,menubar=no," . "scrolling=auto,scrollbars=auto,width=320,height=500," . "resizable=yes'));\">\n" . "<IMG SRC=\"http://ap.taldia.com/button_PlayAudioWindows.gif\" " . "ALT=\"Play Windows Media\" BORDER=0 width=121 height=36></a>" . "\n" . "       \n" ; } sub the_buttons() { print "" . "<tr><td><table width=600 border=0 cellspacing=0 cellpadding=0>\n" . "<tr>" . "<td>" . "<A HREF=\"javascript:checkall();\">\n" . " <IMG SRC=\"http://ap.taldia.com/checkall.gif\"\n" . " ALT=\"Check All\" BORDER=0 width=119 height=37></a>" . "</td>\n" . "<td><A HREF=\"javascript:clearall();\">\n" . " <IMG SRC=\"http://ap.taldia.com/clearall.gif\"\n" . " ALT=\"Clear All\" BORDER=0 width=119 height=37></a>" . "</td>\n" # . "<input type='button' onClick='checkall()' " # . "value=\"CheckAll\"><br>\n" # . "<input type='button' onClick='clearall()' " # . "value=\"ClearAll\"></td><td colspan=10 valign='bottom'>\n" # . "       \n" # . "<button name=\"update\" type=\"button\" " # . "value=\"" ; print "" . "<td><A HREF=\"javascript:popper(2);\">\n" . " <IMG SRC=\"http://ap.taldia.com/playwindows.gif\"\n" . " ALT=\"Play Windows Media\" BORDER=0 width=119 height=37></a>" . "</td>\n" # . "\n" # . "       \n" . "<td><A HREF=\"javascript:popper(3);\">\n" . " <IMG SRC=\"http://ap.taldia.com/playquicktime.gif\"\n" . " ALT=\"Play Quick Time\" BORDER=0 width=119 height=37></a>" . "</td>\n" # . "\n" # . "       \n" . "<td><A HREF=\"javascript:popper(4);\">\n" . " <IMG SRC=\"http://ap.taldia.com/download.gif\"\n" . " ALT=\"Download mp3\" BORDER=0 width=119 height=37></a>" # . "<input type='button' onClick='popper(4)' " # . "value=\"download\">\n" ## . "<input name=\"update\" type=\"submit\" " ## . "value=\"Download\">\n" # . "<input name=\"update\" type=\"submit\" " # . "value=\"Listen Now\">\n" ; print "" . "</td></tr>\n" . "</table></td></tr>\n" ; } sub insert_sponsors() { print "<tr><td colspan=\"2\">\n" ; start_sql() ; for (my $i=0; $i<$bx; $i++) { $query = "SELECT " . "cat " . "FROM cats " ####DEBUG . "WHERE tree like '$boxes[$i]'" ; $elog .= "$query\n" ; $sth = $dbh->prepare($query) ; $rv = $sth->execute ; if (!defined $rv) { die "mysql error -- SELECT failed\n" . "$query\n" ; exit(0) ; } $max_rows = $sth->rows ; #print "cat 0 maxrows is $max_rows $query\n" ; next unless ($max_rows) ; @row = $sth->fetchrow_array ; $args{cat} = $row[0] ; my $thiscat = $args{cat} ; $thiscat =~ s/AP Top News/Top News/ ; $thiscat =~ s/AP TOP // ; $thiscat = "Playlist" ; print "<p> <p>\n" if ($i) ; print "<center><b>$thiscat sponsored by:</b><br>\n" ; googAd($i+2); print "</center><p>\n" ; ##do just one last ; } ## each category $sth->finish ; print "</td></tr>\n" ; print "<tr><td> </td></tr>\n" ; print "<tr><td> </td></tr>\n" ; } sub page5() { # print # #"<table width=\"100%\"><tr><td>" # " <strong>Playlist Options page5</strong><p>\n" # . "Displayed below are several playlist options that publishers can " # . "choose from.<p>" # . "</td></tr>\n" # . "<tr><td colspan=\"2\"> </td></tr>\n" # . "<tr><td height=\"43\" colspan=\"2\" background=\"horiz.gif\"> " # . "</td></tr>\n" # ; get_cats(1, 0, 0) ; if ( $oururl eq "") { print "<tr><td colspan=\"2\"><center><font size=\"+1\">" . "<b>You did not select any content</b></center></font></td></tr>"; print "<tr><td> </td></tr>\n" ; goto ENDOFWORLD ; } $oururl =~ s/^_// ; my $m3u_url = make_m3u($oururl, 0) ; my $mp3_url = # "//users.taldia.com:81/mp?001-$sec_in_day" . "//audio.taldia.com:80/mp?001-$sec_in_day" . "_$intro" . "_$oururl" . "_$outro.mp3" ; print "<tr><td colspan=\"2\"><table width=\"100%\">" ; my $title = "Top story in each category" ; if (0) { print "<tr><td><strong>Option 1</strong></td>\n" ; print "<td colspan=\"2\">" . "<img src=\"rss.gif\" border=\"0\" id=\"hotspot\" name=\"hotspot\">" # . "</span>\n" . " <span id=\"toggle\" name=\"toggle\" class=\"toggle\">" # . "<br>RSS link for $title is<br>" . "<br>http://podcasts.taldia.com/pods/MNdemozs.xml</span></td></tr>" . "<tr><td colspan=\"3\">Click on RSS button to display " . "RSS feed for top story in each category." . "</td></tr>\n" ; print "<tr><td> </td></tr>\n" ; } if (0) { print "<tr><td><strong>Option 2</strong></td><td>\n" ; speak_out($mp3_url, "</td></tr><tr><td colspan=\"3\">" . "Play the created playlist using one large mp3 file with " . "the embedded flash player, without advertising", "", 1) ; print "</td></tr>\n" ; print "<tr><td> </td></tr>\n" ; } if (0) { print "<tr><td>Click the play button below in the Media Player to listen " . "using this interface." . "<p></td></tr>\n" . "<tr><td align=\"center\">\n" . "<OBJECT ID=\"MediaPlayer\" WIDTH=\"233\" HEIGHT=\"42\"\n" . "CLASSID=\"CLSID:22D6F312-B0F6-11D0-94AB-0080C74C7E95\" " . "STANDBY=\"Loading Windows Media Player components...\" " . "TYPE=\"application/x-oleobject\">\n" . "<PARAM NAME=\"FileName\" \n " . "VALUE=\"$mp3_url\">\n" . "<param name=\"autoplay\" value=\"false\">\n" . "<param name=\"autostart\" value=\"false\">\n" . "<param name=\"controller\" value=\"true\">\n" . "<EMBED TYPE=\"application/x-mplayer2\"\n" . " NAME=\"MediaPlayer\"\n" . " SRC=\"$mp3_url\"\n" . " autoplay=\"false\"\n" . " autostart=\"false\"\n" . " WIDTH=\"233\"\n" . " HEIGHT=\"42\">\n" . "</EMBED>\n" . "</OBJECT>\n" . "</td></tr>\n" . "<tr><td> </td></tr>\n" ; } if (0) { print ## . "<td width=\"10%%\"></td>\n" ## . "<td bgcolor=\"#deb825\" width=\"30%%\" align=\"center\">" "<tr><td width=\"20%\">\n" . "<strong>Option 3</strong></td>" . "<td bgcolor=\"#f8f8f8\" width=\"20%\" align=\"center\">" . "<a href=\"$m3u_url\">\n" . "Play Now</a></td><td width=\"58%\"> </td></tr>\n" . "<tr><td colspan=\"3\">" . "Playlist with separate tracks for each category " . "without advertising<p></td></tr>\n" # . "<tr><td bgcolor=\"#c0c0c0\" width=\"30%%\" align=\"center\">" # . "<a href=\"$m3u_url\">\n" #. "Play Now</a></td></tr>\n" # . "Listen to playlist with your OS or browser configured " # . "external default media player<br> (M3U/headlines for each file in audio player)</a></td></tr>\n" # . "<tr><td> </td></tr>\n" . "<tr><td> </td></tr>\n" . "<tr><td width=\"20%\">\n" . "<strong>Option 4</strong></td>" . "<td bgcolor=\"#f8f8f8\" width=\"20%\" align=\"center\">" . "<a href=\"$mp3_url\">" . "Play Now</a></td><td width=\"58%\"> </td></tr>\n" . "<tr><td colspan=\"3\">Playlist with one large mp3 file " . "without advertising<p></td></tr>\n" # . "Listen to playlist with your OS or browser configured " # . "external default media player (One large MP3)" . " </a></td></tr>\n" # . "<tr><td> </td></tr>\n" # . "<tr><td> </td></tr>\n" . "<tr><td>\n" # . "The links below have the same content except that they have " # . "a sponsorship note included in the playlists." ; print "</td></tr>\n" ; } ## old non-sponsered links ## change to link with the adds ## $mp3_url =~ s/10000\.I/10000.I.ad/ ; ## $mp3_url =~ s/10000\.O/10000.O.ad/ ; $m3u_url = make_m3u($oururl, 1) ; ## make sure the mp3 URL is not too long my $pos = length($mp3_url) ; my $maxl = 1023 - 20; if ($pos > $maxl) { ## get last file name $pos = rindex($mp3_url, "_") ; my $tstring = substr($mp3_url, $pos) ; $maxl -= length($tstring) ; ##print STDERR "ENDER $tstring\n" ; while ( ($pos = rindex($mp3_url, "_", $pos)) >= $maxl ) { $pos--; } ##print STDERR "ENDERx pos is $pos\n" ; $mp3_url = substr($mp3_url, 0, $pos) . $tstring ; } if (0) { print "<tr><td><strong>Option 2</strong></td><td>\n" ; speak_out($mp3_url, "</td></tr><tr><td colspan=\"3\">" . "Click on the speaker and listen to the created playlist " . " (one file including advertising and sponsorship) " . "using the embedded flash player " # . "one large mp3 file with " , "", 1) ; print "</td></tr>\n" ; } if (0) { print "<tr><td> </td></tr>\n" . "<tr><td width=\"20%\">\n" . "<strong>Option 3</strong></td>" . "<td bgcolor=\"#f8f8f8\" width=\"20%\" align=\"center\">" . "<a href=\"$m3u_url\">\n" . "Play Now</a></td><td width=\"58%\"> </td></tr>\n" . "<tr><td colspan=\"3\">" . "Click on \"Play Now\" and listen to the created playlist " . "(separate tracks including advertising and sponsorship) " . "using your default media player. " . "</td></tr>\n" ; } ## the only one left if (!$yb) { $mp3_url =~ s!/mp!/apnews! ; } print "" . "<tr><td width=\"30%\">\n" # . "<strong>Option 4</strong></td>" . " </td>" . "<td bgcolor=\"#f8f8f8\" align=\"center\">" . "<a href=\"$mp3_url\">" . "<font size=\"+1\">Download Now</font></a></td><td width=\"30%\" </td></tr>\n" . "<tr><td> </td></tr>\n" . "<tr><td colspan=\"3\" align=\"center\">" . "Click \"Download Now\" to have a mp3 playlist " # . "(one mp3 file including advertising and sponsorship) " . "sent to your default media player." . "<p></td></tr>\n" # . "Listen to playlist with your OS or browser configured " # . "external default media player (One large MP3)" . "</a></td></tr>\n" # . "<tr><td> </td></tr>\n" # . "<tr><td> </td></tr>\n" ; print "</table></td></tr>\n" ; ## around media player ENDOFWORLD: ; print "" # "<tr><td height=\"30\" colspan=\"2\" background=\"horiz2.gif\"> " # . "</td></tr>\n" . "<tr><td> </td><td align=\"center\">" ; insert_sponsors() ; print "" . "<tr><td align=\"center\" colspan=\"2\">\n" . "<form method=\"post\">\n" ; for (my $i=0; $i<$bx; $i++) { my $tag = "box" . $boxes[$i] ; print "<input type=\"hidden\" name=\"$tag\" value=\"1\">\n" ; } print # "<input type=\"hidden\" name=\"page\" value=\"4\">\n" "<input name=\"page\" type=\"submit\" " . "value=\"Back to Audio News Page\"><p>\n" ## . "<input name=\"page\" type=\"submit\" " ## . "value=\"Returning User Page\">\n" . "</form></p>\n" ; # print "</table>\n" ; ##around mid section } ## page 5 sub page6() { ## print #"<table width=\"100%\"><tr><td>" ## " <strong>Playlist Options</strong><p>\n" ## . "Displayed below are several playlist options that publishers can " ## . "choose from.<p>" ## . "</td></tr>\n" ## . "<tr><td colspan=\"2\"> </td></tr>\n" ## . "<tr><td height=\"43\" colspan=\"2\" background=\"horiz.gif\"> " ## . "</td></tr>\n" ## ; get_cats(1, 0, 0) ; if ( $oururl eq "") { print "<tr><td colspan=\"2\"><center><font size=\"+1\">" . "<b>You did not select any content</b></center></font></td></tr>"; print "<tr><td> </td></tr>\n" ; goto ENDOFWORLD ; } $oururl =~ s/^_// ; my $m3u_url = make_m3u($oururl, 0) ; my $mp3_url = # "//users.taldia.com:81/mp?001-$sec_in_day" . "//audio.taldia.com:80/mp?001-$sec_in_day" . "_$intro" . "_$oururl" . "_$outro.mp3" ; print "<tr><td colspan=\"2\"><table width=\"100%\">" ; my $title = "Top story in each category" ; my $usethis = "http:$m3u_url" ; ##print "<p>$usethis\n" ; if (10) { print "<tr><td align=\"center\">Media Player will start automatically<p> " # . "using this interface." . "<p></td></tr>\n" . "<tr><td align=\"center\">\n" . "<OBJECT ID=\"MediaPlayer\" WIDTH=\"233\" HEIGHT=\"42\"\n" . "CLASSID=\"CLSID:22D6F312-B0F6-11D0-94AB-0080C74C7E95\" " . "STANDBY=\"Loading Windows Media Player components...\" " . "TYPE=\"application/x-oleobject\">\n" . "<PARAM NAME=\"FileName\" VALUE=\"$usethis\">\n" . "<param name=\"autoplay\" value=\"true\">\n" . "<param name=\"autostart\" value=\"true\">\n" . "<param name=\"controller\" value=\"true\">\n" . "<EMBED TYPE=\"application/x-mplayer2\"\n" . " NAME=\"MediaPlayer\"\n" . " SRC=\"$usethis\"\n" . " autoplay=\"true\"\n" . " autostart=\"true\"\n" . " WIDTH=\"233\"\n" . " HEIGHT=\"42\">\n" . "</EMBED>\n" . "</OBJECT>\n" . "</td></tr>\n" . "<tr><td> </td></tr>\n" ; } if (0) { print "<tr><td align=\"center\">\n" . "<!-- BEGIN GENERIC ALL BROWSER FRIENDLY HTML FOR WINDOWS MEDIA PLAYER --> " . "" . "<object id=\"MediaPlayer1\" width=180 height=200 " . " classid=\"CLSID:22D6F312-B0F6-11D0-94AB-0080C74C7E95\"" . " codebase=\"http://activex.microsoft.com/activex/controls/mplayer/en/nsmp2inf.cab#Version=5,1,52,701\"" . " standby=\"Loading Microsoft® Windows® Media Player components...\" " . " type=\"application/x-oleobject\" align=\"middle\">" . " <param name=\"FileName\" value=\"$usethis\">" . " <param name=\"ShowStatusBar\" value=\"True\">" . " <param name=\"DefaultFrame\" value=\"mainFrame\">" . " <embed type=\"application/x-mplayer2\" " . " pluginspage = \"http://www.microsoft.com/Windows/MediaPlayer/\"" . " src=\"$usethis\" align=\"middle\"" . " width=176" . " height=144" . " defaultframe=\"rightFrame\"" . " showstatusbar=true>" . " </embed> " . " </object> <!-- END GENERIC ALL BROWSER FRIENDLY HTML FOR WINDOWS MEDIA PLAYER --><br>" . " <a href=\"Server/file\"><font size=\"2\">Click " . " here for standalone player</font></a><br>" . " " . " <a href=\"http://www.microsoft.com/windows/windowsmedia/en/default.asp\"><font size=\"1\">Download Windows Media Player Here</font></a></p>" . "</td></tr>\n" . "<tr><td> </td></tr>\n" ; } ## change to link with the adds ## $mp3_url =~ s/10000\.I/10000.I.ad/ ; ## $mp3_url =~ s/10000\.O/10000.O.ad/ ; $m3u_url = make_m3u($oururl, 1) ; print "</table></td></tr>\n" ; ## around media player insert_sponsors() ; ENDOFWORLD: ; print ## "<tr><td height=\"30\" colspan=\"2\" background=\"horiz2.gif\"> " ## . "</td></tr>\n" # "<tr><td> </td><td align=\"center\">" "<tr><td align=\"center\" colspan=\"2\">\n" . "<form method=\"post\">\n" ; for (my $i=0; $i<$bx; $i++) { my $tag = "box" . $boxes[$i] ; print "<input type=\"hidden\" name=\"$tag\" value=\"1\">\n" ; } print # "<input type=\"hidden\" name=\"page\" value=\"4\">\n" "<input name=\"page\" type=\"submit\" " . "value=\"Back to Audio News Page\"><p>\n" ## . "<input name=\"page\" type=\"submit\" " ## . "value=\"Returning User Page\">\n" . "</form></p>\n" ; # print "</table>\n" ; ##around mid section } sub page6x() { print " <strong>Welcome back user</strong></p>\n" . "To modify your playlist, put a checkmark next to the<br> " . "categories you would like " . "to include, then click the update button.<p>" . "<hr>" . "<b>Using the options below you can:</b><p>" . "<p>1. <b>Listen</b> to summaries of the articles " . "by clicking on the speaker.<p>" . "2. Click on  " . "<img src=\"rss.gif\" width=\"36\" height=\"14\">" . "  for category RSS feed. " . "<p>3. <strong>Read</strong> " . "the entire article by clicking on the headline. " . "</p>\n" . "</td></tr>\n" . "<tr><td> </td></tr>\n" . "<form method=\"post\">" . "<tr><td height=\"43\" colspan=\"2\" background=\"horiz.gif\"> " . "</td></tr>\n" ; # print "<tr><td valign=\"bottom\"> </td></tr>\n" ; get_cats(0, 1, 0) ; # print "<tr><td valign=\"bottom\"> </td></tr>\n" ; print "<tr><td height=\"30\" colspan=\"2\" background=\"horiz2.gif\"> " . "</td></tr>\n" ; print "<tr><td> </td><td align=\"center\">" ; for (my $i=0; 00 && $i<10; $i++) { my $tag = "box$i" ; next if (!defined $args{$tag} ) ; print "<input type=\"hidden\" name=\"$tag\" value=\"1\">\n" ; } print "<input type=\"hidden\" name=\"page\" value=\"7\">\n" . "<input name=\"update\" type=\"submit\" id=\"update\" " . "value=\"Update\">\n" . "</td></tr>\n" . "</form>\n" ; #print "</table>\n" ; ##around mid section } sub page7() { get_cats(1, 0, 0) ; if ($oururl eq "") { print "You have not selected any content<br></td></tr>"; print "<tr><td> </td></tr>\n" ; goto ENDOFPAGE7 ; } $oururl =~ s/^_// ; my $m3u_url = make_m3u($oururl, 1) ; print " <strong>Listen to your updated playlist</strong></p>\n" # . "</td></tr>\n" # . "<tr><td>\n" . "<p>Now listen to your new playlist by " . "<a href=\"$m3u_url\">" . "<strong>clicking here</strong></a>.<p>\n" . "</td></tr>\n" . "<tr><td> </td></tr>\n" ; ENDOFPAGE7: ; print "<tr><td> </td><td align=\"left\">" . "<form method=\"post\" action=\"//mercurynews.com\">\n" . "<input name=\"update\" type=\"submit\" " . "value=\"Mercury News Home\">\n</form></p>\n" # . "</td></tr>\n" ; ; } sub story() { my $article = $args{story} ; if (00 && $oururl eq "") { print "You have not selected any content<br></td></tr>"; print "<tr><td> </td></tr>\n" ; goto ENDOFPAGE7 ; } my ($headline, $the_url, $textp, $image_url, $summary, $arrival_time) = get_headline($article) ; $textp =~ s/\<P>/<p>/g ; ## 10-apr-06 fix glitch in database $textp =~ s!</p>\s*,\s*<p>!</p><p>!iogs ; $textp =~ s!\s*,\s*$!!iogs ; $textp =~ s!^\s*,\s*!!iogs ; my @pieces = split "<p>", $textp ; print "<span style=\"font-size:16px;font-family:arial;font-weight:bold;\">\n" . "$headline</span><br>\n" . "<span style=\"font-size:10px;font-family:arial;\">$arrival_time US/Eastern</span>\n" . "<p>\n" ; ## " the story should be $article<br>\n" ## . "$textp\n" my $i ; print "<span style=\"font-size:12px;font-family:arial;\">\n" ; for ($i=0; $i<3 && $i<=$#pieces; $i++) { print "$pieces[$i]<p>\n" ; } ## 10-apr-06 no images in database 17-apr put back if ($image_url ne "") { if ( $image_url =~ m!ap.org/(.*?)\@! ) { $image_url = $1 ; } $image_url = "http://taldia.com/photos200/$image_url.jpg" ; my $link_url = $image_url ; $link_url =~ s/photos200/photos/ ; # print "<img src=\"$image_url\" " # . "style=\"float:right;padding:0 0 4px 4px;\">\n" ; print "" . " <a href=\"$link_url\"><img src=\"$image_url\"" . "style=\"float:right;padding:0 0 4px 4px;border:0;\">\n" . "</a>\n" ; # print # "<span style=\"float: left;padding: 5px 5px 5px 0px; " # . "margin: 5px 5px 5px 0px;\">\n" # . "<img src=\"$image_url\" alt=\"missing\" border=\"0\">\n" # . "</span>\n" # ; } for (; $i<=$#pieces; $i++) { print "$pieces[$i]<p>\n" ; } print "</span></td></tr>\n" . "<tr><td> </td></tr>\n" ; print "<tr><td> </td></tr>\n" . "<tr><td align=\"center\" colspan=\"2\">" ; for (my $i=0; $i<$bx; $i++) { my $tag = "box" . $boxes[$i] ; print "<input type=\"hidden\" name=\"$tag\" value=\"1\">\n" ; } print "" . "<input name=\"update\" type=\"submit\" " . "value=\"Return to Main Page\">\n" ; } sub dispcat() { my $thecat = $args{c} ; my @headlines ; my $nhead = 0 ; my $link = 0 ; start_sql() ; $query = "SELECT " . "tree, " . "cat, " . "ybcat, " . "rank, " . "type, " . "rrdbcat, " . "prem " . "FROM cats " ####DEBUG . "WHERE tree ='$thecat'" ; $elog .= "$query\n" ; $sth = $dbh->prepare($query) ; $rv = $sth->execute ; if (!defined $rv) { die "mysql error -- SELECT failed\n" . "$query\n" ; exit(0) ; } $max_rows = $sth->rows ; #print "cat 0 maxrows is $max_rows $query\n" ; for (my $i=0; $i<$max_rows; $i++) { @row = $sth->fetchrow_array ; $args{tree}[$i] = $row[0] ; $args{cat}[$i] = $row[1] ; $args{ybcat}[$i] = $row[2] ; $args{rankx}[$i] = $row[3] ; $args{type}[$i] = $row[4] ; $args{rrdbcat}[$i] = $row[5] ; $args{prem}[$i] = $row[6] ; } $sth->finish ; my $adstr = "AD50000" ; for (my $i=0; $i<$max_rows; $i++) { @rank = split / /, $args{rankx}[$i] ; my $temp = $rank[0] ; next if (!defined $temp || $temp eq "") ; #print "article is $temp\n" ; my ($article, $junk) = split '/', $temp ; #print "article is $article\n" ; my $want_url = 0 ; if (! $want_url) { if (0) { print "<tr>\n" . "<td height=\"43\" colspan=\"2\" valign=\"bottom\"> " . "<span> " ; } my $title = $args{cat}[$i] ; $title =~ s/SJMN // ; $title =~ s/AP Top News/Top News/ ; $title =~ s/AP Top// ; if ($link) { print "<span class=\"catc\">" . "<a href=\"//$server_name/index.pl?c=$args{tree}[$i]\">$title</a>" . "</span>\n" ; } else { print "<span style=\"" . "font-size:16px;font-weight:bold;" . "font-family:Arial;" . "text-valign:top;" . "text-align:left;" # . "margin-top:0px;padding-top:0px;border-top:0px;" . "margin-left:5px;\">\n" . "$title " . "</span>\n" ; } # print ## . "<img src=\"rss.gif\" border=\"0\" id=\"hotspot\" name=\"hotspot\">" ## . "</span>\n" ## . " <span id=\"toggle\" name=\"toggle\" class=\"toggle\">" ## . "<br>RSS link for $title is<br>" ## . "http://podcasts.taldia.com/pods/$args{tree}[$i]as.xml</span></td>" ## . "<img src=\"rss.gif\"></span></td>\n" #. "<img src=\"xml-podcast.gif\"></span></td>\n" #. "$args{cat}[$i] $args{tree}[$i]</span></td>\n" # "</span></td></tr>\n" # ; #0 print "</td></tr>\n" ; #0 print "<tr><td> </td>\n<td>" ; } my $num_articles = 0 ; for (my $j=0; $j<$#rank; $j++) { last if ($num_articles >= 5 ) ; my ($t1, $t2) = split "/", $rank[$j] ; #print $rank[$j] ; #88888888 my ($headline, $url, $textp, $image_url, $summary) = get_headline($t1) ; #my ($headline, $url) = ("headline", "url") ; ##print "$t1 $headline $url<br>\n" ; for (my $hx=0; $hx<$nhead; $hx++) { goto BAIL if ($headline eq $headlines[$hx]) ; } $headlines[$nhead++] = $headline ; $num_articles++ ; # print "<div style=\"" # . "margin-top:25px;font-size:14px;font-weight:bold;\">\n" print "<div class='catc'>\n" . "<a href=\"//$server_name/index.pl?story=$t1\">$headline</a><br>\n" ; if ($image_url ne "") { if ( $image_url =~ m!ap.org/(.*?)\@! ) { $image_url = $1 ; } $image_url = "http://taldia.com/photost/$image_url.jpg" ; my $link_url = $image_url ; $link_url =~ s/photost/photos/ ; # print "<img src=\"$image_url\" " # . "style=\"float:right;padding:0 0 4px 4px;\">\n" ; print "" . " <a href=\"$link_url\"><img src=\"$image_url\" " . "style=\"float:right;padding:0 0 4px 4px;border:0;\">\n" . "</a>\n" ; } $summary =~ s/<text>/<p>/gi ; $summary =~ s/<\/text>//gi ; print "$summary\n" ; print "</div>\n" ; BAIL: ; } print "</td></tr>\n" if (! $want_url) ; } ## put it in, put it out. mark wants it in # $oururl =~ s/_bmp$// ; print "<tr><td> </td></tr>\n" . "<tr><td> </td></tr>\n" . "<tr><td align=\"center\" colspan=\"2\">" ; for (my $i=0; $i<$bx; $i++) { my $tag = "box" . $boxes[$i] ; print "<input type=\"hidden\" name=\"$tag\" value=\"1\">\n" ; } print "" ## . "<form method=\"post\" action=\"//ap.taldia.com\">\n" . "<input name=\"update\" type=\"submit\" " . "value=\"Return to Main Page\">\n" # . "</td></tr>\n" ; ; } ##dispcat sub googAd($) { my $ix = shift ; if ($ix > $#btext) { $ix = $ix % ($#btext-1) + 2 ; } ##print "BTEXT $#btext\n" ; my ($url, $image) = $btext[$ix] ; ##print "$url\n$image\n" ; print "$btext[$ix][0]\n$btext[$ix][1]\n" ; return ; print "<script type=\"text/javascript\">\n" ## . " <!--\n" . "google_ad_client = \"pub-6731390347816831\";\n" . "google_ad_width = 468;\n" . "google_ad_height = 60;\n" . "google_ad_format = \"468x60ads_al_s\";\n" . "google_ad_channel =\"\";\n" ## . "-->\n . "</script>\n" . "<script type=\"text/javascript\"\n" . " src=\"http://pagead2.googlesyndication.com/pagead/show_ads.js\">\n" . "</script>\n" ; } sub pageAP() { print " <strong>AP USER</strong></p>\n" . "Create your personalized playlist by putting a checkmark " . "next to the " . "categories you would like include.<p>" #. "Click on  " #. "<img src=\"rss.gif\" width=\"36\" height=\"14\">" #. "<img src=\"xml-podcast.gif\" width=\"80\" height=\"15\">" #. "  for category RSS feed. " . "</td></tr>" . "<tr><td> </td></tr>\n" . "<tr><td>" . "<form action=\"index.pl\" method=\"post\">\n" . "<tr><td height=\"43\" colspan=\"2\" background=\"horiz.gif\"> " . "</td></tr>\n" ; # print "<tr><td valign=\"bottom\"> </td></tr>\n" ; get_cats(0, 1, 0) ; # print "<tr><td valign=\"bottom\"> </td></tr>\n" ; print "<tr><td height=\"30\" colspan=\"2\" background=\"horiz2.gif\"> " . "</td></tr>\n" ; print "<tr><td> </td><td align=\"center\">" . "<input type=\"hidden\" name=\"page\" value=\"5\">\n" . "<input name=\"update\" type=\"submit\" id=\"update\" " . "value=\"Listen to Playlist\">\n</form></p>\n" ; ##TODO should next line be here? # print "</td>\n" ; } sub make_m3u($$) { my $oururl = shift ; my $do_ads = shift ; ## no ads for now $do_ads = 0 ; ##create a m3u filename my $mypid = $$ ; my $m3u_url ; if ($do_ads) { $m3u_url = "tmp/audio.$mypid.ad.m3u" ; } else { $m3u_url = "tmp/audio.$mypid.m3u" ; } ##get local address of file and open it my $tm3u = "/pages/x-taldia/ap/$m3u_url" ; open (M3U, "> $tm3u") || die "could not open $tm3u $!" ; my $track = 0 ; my $m3uline = "" ; my @tags = split /_/, $oururl ; for (my $j=0; $j<=$#tags; $j++) { if ( ( length($m3uline) > 200 && ($tags[$j] =! /bmp/)) || ( length($m3uline) > 80 && ($tags[$j] =~ /\.I/)) || (!length($m3uline))) { if (length($m3uline)) { print M3U "$m3uline.mp3\n" ; $m3uline = "" ; } $track++ ; my $track_str = sprintf "%03i", $track ; $m3uline = "http://audio.taldia.com:80/mp?$track_str-$yday" ; } $m3uline .= "_$tags[$j]" ; } print M3U "$m3uline.mp3\n" ; close M3U || die "error closing $m3u_url $!" ; ## get network address of the m3ufile $m3u_url = "//ap.taldia.com/$m3u_url" ; return $m3u_url ; } my $started = 0 ; sub start_sql() { return if $started ; $started++ ; $dsn = "DBI:mysql:taldia" ; ## next line needs user and password $dbh = DBI->connect($dsn, "root", "frog", ## "", { RaiseError => 1, AutoCommit => 0 } ) or die " could not connect to sql database" ; } ############################################################################## # # returns the created string # ############################################################################## sub speak_out($$$$) { my $article = shift ; my $headline = shift ; my $url = shift ; my $type = shift ; my $string = "" ; my $host ; if ($type) { $host = $article ; } else { $host = "//taldia.com/clips/$article.mp3" ; } $string .= "" . "<span class='subline'>\n" . "<object classid=\"clsid:D27CDB6E-AE6D-11cf-96B8-444553540000\"\n" . "codebase=\"http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,19,0\"\n " . "width=\"23\" height=\"20\" id=\"speaker_R\" align=\"middle\"/>\n" . " <param name=\"allowScriptAccess\" value=\"sameDomain\"/>\n" . " <param name=\"movie\" value=\"//images.taldia.com/speaker_R.swf\"/>\n" . " <param name=\"quality\" value=\"high\"/>\n" . " <param name=\"wmode\" value=\"transparent\"/>\n" . " <param name=\"FlashVars\" " . " value=\"&soundfile=$host\"/>\n" # . " <param name=\"bgcolor\" value=\"%s\" />"NL . " <embed src=\"//images.taldia.com/speaker_R.swf\" quality=\"high\"\n" . " FlashVars=\"&soundfile=$host\"\n" . " pluginspage=\"http://www.macromedia.com/go/getflashplayer\"\n" . " type=\"application/x-shockwave-flash\"\n" . " width=\"23\" height=\"20\" name=\"speaker_R\">\n" . " </embed>\n" . "</object>" # . "<span>\n" ; ##<span class=\"359200618-06122005\">\n" ; # $headline = substr($headline, 0, 35) ; if ($url ne "") { $string .= "<a href=\"//$server_name/index.pl?story=$article\">$headline</a></span>\n" ; } else { $string .= $headline ; } # www.mercurynews.com/mld/mercurynews/sports/soccer/13339105.htm"> # Babysitter jailed in death of toddler finding support</a></span> return $string ; } sub get_headline($) { my $id = shift ; my $headline ; my $the_url ; my $sth ; my $rv ; my $rows ; my $max_rows ; my $textp ; my $image_url ; my $summary ; my $arrival_time ; my $playtime ; start_sql() ; $query = "SELECT " . "headline, url, textp, " . "image_url, summary, arrival_time, " . "playtime " . "FROM news " . "WHERE id='$id'" ; $elog .= "$query<br>\n" ; $sth = $dbh->prepare($query) ; $rv = $sth->execute ; if (!defined $rv) { die "mysql error -- SELECT failed\n" . "$query\n" } $max_rows = $sth->rows ; #print "cat 0 maxrows is $max_rows $query\n" ; if ($max_rows >= 1) { @row = $sth->fetchrow_array ; $headline = $row[0] ; $the_url = $row[1] ; $textp = $row[2] ; $image_url = $row[3] ; $summary = $row[4] ; $arrival_time = $row[5] ; $playtime = $row[6] ; } $sth->finish ; $arrival_time = "" unless (defined $arrival_time) ; return ($headline, $the_url, $textp, $image_url, $summary, $arrival_time, $playtime) ; } ########################################################################### ########################################################################### ## fake that there might be an ad server ## this will just switch back and forth from alaska to jiffylube my $adName ; my $adPhoto ; my $adTime ; my $adHead ; sub AdSetup() { if ($adName eq "AD50000") ## check if now jiffylube { $adName = "AD50001" ; $adPhoto = 'alaska' ; $adTime = 13500 ; $adHead = "Alaska Airlines" ; } else { $adName = "AD50000" ; $adPhoto = 'jiffylube' ; $adTime = 13500 ; $adHead = "Jiffylube" ; } } ############################################################################## ############################################################################## ## getcats # this routine is used for two things # 1) to create speaker & headline links # 2) to create a url for what to put in the playlist # # want_url set if url with mp3 files is wanted # want_boxes set if checkboxes on category headings are wanted # link set if category title is link to a summary page sub get_cats($$$) { my $want_url = shift ; my $want_boxes = shift ; my $link = shift ; my $add_to_url ; my @headlines ; my $nhead = 0 ; $photo_links = "" ; start_sql() ; $query = "SELECT " . "tree, " . "cat, " . "ybcat, " . "rank, " . "type, " . "rrdbcat, " . "prem " . "FROM cats " ####DEBUG # . "WHERE tree like '90000%'" . "WHERE $usecats" ; $elog .= "$query\n" ; $sth = $dbh->prepare($query) ; $rv = $sth->execute ; if (!defined $rv) { die "mysql error -- SELECT failed\n" . "$query\n" ; exit(0) ; } $max_rows = $sth->rows ; #print "cat 0 maxrows is $max_rows $query\n" ; for (my $i=0; $i<$max_rows; $i++) { @row = $sth->fetchrow_array ; $args{tree}[$i] = $row[0] ; $args{cat}[$i] = $row[1] ; $args{ybcat}[$i] = $row[2] ; $args{rankx}[$i] = $row[3] ; $args{type}[$i] = $row[4] ; $args{rrdbcat}[$i] = $row[5] ; $args{prem}[$i] = $row[6] ; } $sth->finish ; ## set jiffylube, but it will immediately be switched below $adName = "AD5000" ; my ($col, $col1, $col2) ; $col = $col = $col2 = "" ; my $flip_flop = 0 ; ## == 0 when building column two for (my $i=0; $i<$max_rows; $i++) { @rank = split / /, $args{rankx}[$i] ; my $temp = $rank[0] ; next if (!defined $temp || $temp eq "") ; next if ( $args{tree}[$i] =~ /\.0$/ ) ; ## AP General not wanted next if ( $args{tree}[$i] =~ /90000\.2000/ ) ; ## AP US News missing VO #next if ( $args{tree}[$i] =~ /90000\.0700/ ) ; ## AP Politics has bad VO volume #next if ( $args{tree}[$i] =~ /90000\.0900/ ) ; #print "article is $temp\n" ; my ($article, $junk) = split '/', $temp ; #print "article is $article\n" ; #$elog .= "NEWCAT $args{tree}[$i]<br>\n" ; if ($flip_flop) { $flip_flop = 0 ; $col1 = $col ; $col = $col2 ; } else { $flip_flop = 1 ; $col2 = $col ; $col = $col1 ; } my $title = $args{cat}[$i] ; $title =~ s/SJMN // ; $title =~ s/^AP Top News/Top News/ ; $title =~ s/^AP Top // ; # $title =~ s/^AP // ; my $checked = "" ; $add_to_url = 0 ; my $tbox = "box" . $args{tree}[$i] ; my $filler ; my $fillerTime ; ##print STDERR "BOX is $tbox\n" ; if (defined $args{$tbox}) { $checked = "checked" ; $oururl .= "_$args{tree}[$i].I" ; $add_to_url++ ; AdSetup() ; ## display the ad during the intro #$photo_links .= "np(0,'$adPhoto',6000,'$adHead');\n" ; ## display the intro pic during the intro my $tv = $args{tree}[$i] ; $filler = "ti/$tv" ; $photo_links .= "np(0," . "'$filler'," . "$catData{$tv}[0],'$title');\n" ; } # $col .= "<tr><td colspan=10><hr></td></tr>\n" if ($col ne "") ; if (00 && $col ne "") { $col .= "" . "<tr align='center' bgcolor='#808080'>" . "<td colspan=10 height='1px'> </td>\n" . "</tr>\n" ; } if (! $want_url) { $col .= "" . "<tr>\n" . "<td height='30' colspan='2' class='cathead'>\n" # . "<span class=\"cathead\">\n" . "<script>\n" ; if ($want_boxes) { #print "<input type=\"checkbox\" name=\"remember\" checked>\n" ; $col .= "" # . "<input type=\"checkbox\" " # . "name=\"box$args{tree}[$i]\" $checked>\n" ; . "make_cbox('$args{tree}[$i]','$checked');\n" ; } if ($link) { #888888 $col .= "" # . "<a href=\"//$server_name/index.pl?c=$args{tree}[$i]\">$title</a>" ; . "make_chead('$server_name','$args{tree}[$i]','$title');\n" ; } else { $col .= "$title " ; } $col .= "</script>\n" ; $col .= "" ## . "<img src=\"rss.gif\" border=\"0\" id=\"hotspot\" name=\"hotspot\">" ## . "</span>\n" ## . " <span id=\"toggle\" name=\"toggle\" class=\"toggle\">" ## . "<br>RSS link for $title is<br>" ## . "http://podcasts.taldia.com/pods/$args{tree}[$i]as.xml</span></td>" ## . "<img src=\"rss.gif\"></span></td>\n" #. "<img src=\"xml-podcast.gif\"></span></td>\n" #. "$args{cat}[$i] $args{tree}[$i]</span></td>\n" # . "</span>\n" . "</td></tr>\n" ; $col .= "<tr><td> </td><td width=295>\n" ; } my $num_articles = 0 ; my $articlesWanted = 5; for (my $j=0; $j<$#rank; $j++) { last if ($num_articles >= $articlesWanted); #$elog .= "URL $num_articles $oururl<br>\n"; my ($t1, $t2) = split "/", $rank[$j] ; #print $rank[$j] ; my ($headline, $url, $textp, $image_url, $sum, $art, $playtime) = get_headline($t1) ; ##ignore articles with headlines that are too long next if (length($headline) >60) ; for (my $hx=0; $hx<$nhead; $hx++) { goto BAIL if ($headline eq $headlines[$hx]) ; } $headlines[$nhead++] = $headline ; $num_articles++ ; #$headline .= "++" . length($headline) ; if ($want_url) { if ($add_to_url) { ## add the story to the url $oururl .= "_$t1"; $playtime = $playtime * 1000 + 500; if ($image_url ne "") { ## if there is a picture use it $photo_links .= "np(1,'$image_url',$playtime,'$headline');\n" ; } else { $photo_links .= ## if no picture use the ad # "np(0,'$adPhoto',$playtime,'$headline');\n" ; ## if no picture use the sponsor sorry "np(0,'ti/alaska_sorry',$playtime,'$headline');\n" ; } if ($num_articles < $articlesWanted) { #insert bumper $oururl .= "_bmp" ; ## display the ad during the bumper #$photo_links .= "np(0,'$adPhoto',4400,'bmp');\n" ; ## display the blank during the bumper $filler = 'blank' ; $photo_links .= "np(0,'$filler',2400,'');\n" ; } ## insert ad after first story #if ($j == 0) ## insert ad after second story unless there are just two if ( ($num_articles == 1 && $#rank == 1) ||($num_articles == 2 && $#rank > 1) ) { $oururl .= "_$adName" ; #$photo_links.="np(0,'$adPhoto',$adTime,'$adHead');\n"; $photo_links .= "np(0,'$adPhoto',$adTime,'');\n" ; } } } else ## !$want_url so build text { ## 10-apr-06 make url non-empty $url = "x" ; $col .= speak_out($t1, $headline, $url, 0) ; $col .= "<br>\n" ; } BAIL: ; } $col .= "</td></tr>\n" if (! $want_url) ; ## some delay for end of category if (00 && $add_to_url) { $photo_links .= "np(0,'alaska',5000);\n" ; } } if ($flip_flop) { $col1 = $col ; } else { $col2 = $col ; } return if ($want_url) ; print "" # . "<tr><td colspan=2 bgcolor='#202020'>" . "<tr><td colspan=2>" #print "<span bgcolor=\"#808080\">\n" ; . " <table border=0 cellspacing=0 cellpadding=0><tr>\n" . "<!-- start of column one -->\n" . "<td width=\"300\" valign=\"top\">\n" # . "<table bgcolor='#8080999980' border=0 cellspacing=0 cellpadding=0>\n" . "<table border=0 cellspacing=0 cellpadding=0>\n" #. "<tr><td>$col1</td></tr>\n" . "$col1\n" . "</table></td>\n" . "<!-- start of column two -->\n" . "<td width=\"300\" valign=\"top\">" # . "<table bgcolor='#707070' border=0 cellspacing=0 cellpadding=0>\n" . "<table border=0 cellspacing=0 cellpadding=0>\n" #. "<tr><td>$col2</td></tr>\n" . "$col2\n" . "</table></td></tr>\n" . "</table>\n" . "<!--end of column two-->\n" . "</td></tr>\n" ; ## put it in, put it out. mark wants it in # $oururl =~ s/_bmp$// ; } __END__ ############################################################################## ## ## pods.pl ## create the podcast files ## ############################################################################# use POSIX; use DBI; use strict ; my $dir = "/pages/x-taldia/pods/" ; my $all_pods = "index.html" ; sub head($$$$) ; sub one_item($$$$) ; sub foot() ; sub start_sql() ; sub one_cat() ; my $dbh ; my $dsn ; my $sth ; my $rv ; my $max_rows ; my @row ; my %args ; my @rank ; my $query ; my $elog = "" ; my $pod_string = "" ; my $psd_string = "" ; my $page_string = "" ; my $we_string = "" ; my $hl_string = "" ; my $hs_string = "" ; my $request_method = $ENV{'REQUEST_METHOD'} ; $elog .= "REQUEST METH $request_method<br>\n" ; if ($request_method eq "GET") { $formdata = $ENV{'QUERY_STRING'} ; $elog .= "GET content $formdata<br>\n" ; } elsif ($request_method eq "POST") { $datasize = $ENV{'CONTENT_LENGTH'}; $elog .= "POST content length is $datasize<br>\n" ; read (STDIN, $formdata, $datasize); } else { $formdata = "" ; $datasize = length($formdata) ; } ##print ( "$formdata <br>\n"); $elog .= "FORMDATA $formdata <br>\n"; foreach $thistag ( split ( "&", $formdata ) ) { my $sstag = $thistag ; $thistag =~ s/[\n|\r]//g ; $elog .= "THISTAG1 is $thistag<br>\n" ; $thistag =~ s/\+/ /go ; $elog .= "THISTAG2 is $thistag<br>\n" ; $thistag =~ s/%([\dA-Fa-f][\dA-Fa-f])/pack ("C", hex ($1))/eg; $elog .= "THISTAG3 is $thistag<br>\n" ; $thistag =~ s/[\n|\r]//g ; $elog .= "THISTAG4 is $thistag<br>\n" ; my (@ts) = split "=", $thistag; ## $t2 =~ s/^\s+// ; ## $t2 =~ s/\s+$// ; my $t1 = $ts[0] ; my $t2 = $ts[1] ; for (my $i=2; $i<=$#ts; $i++) { $t2 .= "=" . $ts[$i] ; } $args{$t1} = $t2 ; if (defined $t2) { $elog .= "TAGS $t1 is $t2<br>\n" ; } else { $elog .= "TAGS $t1 is blank<br>\n" ; } } one_cat() if (defined($args{pcast}) ; exit(0); $page_string .= "<html><head></head><body>\n" ; $we_string .= "<center><table border=\"2\">\n" ; $we_string .= "<tr><th>City</th><th>WeekEnd Minute</th></tr>\n" ; $hl_string .= "<center><table border=\"2\">\n" ; $hl_string .= "<tr><th colspan=\"2\">Multiple Links</th></tr>\n" ; $hl_string .= "<tr><th>Headlines</th><th>Link</th></tr>\n" ; $hs_string .= "<center><table border=\"2\">\n" ; $hs_string .= "<tr><th colspan=\"2\">Single Link</th></tr>\n" ; $hs_string .= "<tr><th>Headlines</th><th>Link</th></tr>\n" ; my ($sec, $min, $hour, $mday, $mon, $year, $wday, $yday, $isdst) = localtime ; # . " <pubDate> Thu, 16 Jun 2005 5:00:00 PST </pubDate>\n" my $days = "SunMonTueWedThuFriSat" ; my $months = "JanFebMarAprMayJunJulAugSepOctNovDec" ; my $theday = substr($days, $wday*3, 3) ; my $themonth = substr($months, $mon*3, 3) ; $year += 1900 ; my $today = sprintf "%3s, %02i %3s %4i %02i:%02i:%02i PST", $theday, $mday, $themonth, $year, $hour, $min, $sec ; #print "$today\n" ; ## exit(0) ; start_sql() ; $query = "SELECT " . "tree, " . "cat, " . "ybcat, " . "rank, " . "type, " . "rrdbcat, " . "prem " . "FROM cats " . "WHERE tree like '57000%'" ; $elog .= "$query\n" ; $sth = $dbh->prepare($query) ; $rv = $sth->execute ; if (!defined $rv) { die "mysql error -- SELECT failed\n" . "$query\n" ; exit(0) ; } $max_rows = $sth->rows ; #print "cat 0 maxrows is $max_rows $query\n" ; for (my $i=0; $i<$max_rows; $i++) { @row = $sth->fetchrow_array ; $args{tree} = $row[0] ; $args{cat} = $row[1] ; $args{ybcat} = $row[2] ; @rank = split / /, $row[3] ; $args{type} = $row[4] ; $args{rrdbcat} = $row[5] ; $args{prem} = $row[6] ; my $temp = $rank[0] ; next if (!defined $temp || $temp eq ""); #print "article is $temp\n" ; my ($article, $junk) = split '/', $temp ; #print "article is $article\n" ; my $city = $args{cat} ; my $city_lc = lc $city ; $city_lc =~ s/ /./g ; $city_lc =~ s#/#_#g ; ## $we_string .= "<tr><td>$args{cat}</td>\n\t<td>" my $image = "$args{tree}.jpg" ; $we_string .= "<tr><td><center><img " . "src=\"http://images.taldia.com/$image\" " . "alt=\"$args{cat}\"></center>" . "</td>\n\t<td>" . "<a href=\"//taldia.com/pods/$city_lc.xml\">" . "$city" . "</td>\n</tr>\n" ; $pod_string = "" ; head("Taldia Podcasts", $today, $year, $image) ; one_item($args{cat}, "$args{cat} Weekend Highlight", $today, $article) ; foot() ; my $filename = "$dir$city_lc.xml" ; open (FILE, "> $filename") || die "could not open $filename $!" ; print FILE $pod_string ; close FILE || die "error closing $filename $!" ; ##last ; } $rv = $sth->finish ; $we_string .= "</table>\n" ; ########################################################################## # # now do the headlines # $query = "SELECT " . "type, " . "links " . "FROM links " ; $elog .= "$query\n" ; $sth = $dbh->prepare($query) ; $rv = $sth->execute ; if (!defined $rv) { die "mysql error -- SELECT links failed\n" . "$query\n" ; exit(0) ; } $max_rows = $sth->rows ; #print "cat 0 maxrows is $max_rows $query\n" ; for (my $i=0; $i<$max_rows; $i++) { @row = $sth->fetchrow_array ; my $type = $row[0] ; my @links = split /\n/, $row[1] ; my $set ; my $flink ; if ($type == 1) { $set = "Latest Headlines" ; $flink = "latest" ; } elsif ($type == 2) { $set = "Top Tech Stories" ; $flink = "tech" ; } elsif ($type == 3) { $set = "See Also" ; $flink = "seealso" ; } else { next ; } $flink .= ".xml" ; $hl_string .= "<tr><td>$set</td>\n\t<td>" . "<a href=\"//taldia.com/pods/$flink\">" . "$set" . "</td>\n</tr>\n" ; $pod_string = "" ; my $flink_sing = $flink ; $flink_sing =~ s/.xml/s.xml/ ; $hs_string .= "<tr><td>$set</td>\n\t<td>" . "<a href=\"//taldia.com/pods/$flink_sing\">" . "$set Single" . "</td>\n</tr>\n" ; $psd_string = "" ; ## multiple links first head("Taldia Podcasts", $today, $year, "") ; for (my $j=0; $j<=$#links; $j+=2) { my $article = $links[$j] ; my $hl = $links[$j+1] ; one_item("Taldia News", "$hl", $today, $article) ; $psd_string .= "_$article" ; } foot() ; my $filename = "$dir$flink" ; open (FILE, "> $filename") || die "could not open $filename $!" ; print FILE $pod_string ; close FILE || die "error closing $filename $!" ; $pod_string = "" ; head("Taldia Podcasts", $today, $year, "") ; $psd_string =~ s/^_// ; one_item("Taldia News", "Single Clip", $today, $psd_string) ; foot() ; $filename = "$dir$flink_sing" ; open (FILE, "> $filename") || die "could not open $filename $!" ; print FILE $pod_string ; close FILE || die "error closing $filename $!" ; } $rv = $sth->finish ; $hl_string .= "</table>\n" ; $hs_string .= "</table>\n" ; $page_string .= "<table>\n<tr><td>\n" ; $page_string .= $we_string ; $page_string .= "</td><td valign=\"top\">" ; $page_string .= $hl_string ; $page_string .= "<p><p><p>\n" ; $page_string .= $hs_string ; $page_string .= "</td></tr>" ; $page_string .= "</table>\n</body></html>\n" ; # print $pod_string ; $all_pods = $dir . $all_pods ; open (FILE, "> $all_pods") || die "could not open $all_pods $!" ; print FILE $page_string ; close FILE || die "error closing $all_pods $!" ; exit(0) ; sub head($$$$) { my $description = shift ; my $today = shift ; my $year = shift ; my $image = shift ; $pod_string .= sprintf ( # "\n\n" "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n" . "<rss version=\"2.0\" xmlns:itunes=\"http://www.itunes.com/DTDs/Podcast-1.0.dtd\" xmlns:media=\"http://search.yahoo.com/mrss/\">\n" . "\n" . "<channel>\n" ## . "<title> Title of your site \n" . "Taldia.com\n" ## . " A description of your podcast show \n" . "$description \n" ## . "Your Name \n" . "taldia.com\n" # . " http://www.yourserver.com/YourPodcastHomepage/ \n" . " http://podcasts.taldia.com/pods/ \n" ) ; if ($image ne "") { $pod_string .= sprintf ( # "\n" "\n" ) ; } $pod_string .= sprintf ( # . " Sun, 09 Oct 2005 21:00:00 PST \n" "$today\n" . "en-us\n" # . " Copyright Year Your_Name \n" . "Copyright $year Taldia Inc.\n" . "\n" ) ; } sub one_item($$$$) { my $title = shift ; my $description = shift ; my $today = shift ; my $article = shift ; $pod_string .= sprintf ( "\n" # . " This is just a test \n" . " $title\n" # . " A description of your podcast episode \n" . " $description \n" # . " Your Name \n" . " Taldia Inc. \n" # . " Thu, 16 Jun 2005 5:00:00 PST \n" . " $today\n" # . " \n" . " \n" ) ; } sub foot() { $pod_string .= sprintf ( "\n" . "\n\n\n" ) ; } my $started = 0 ; sub start_sql() { return if $started ; $started++ ; $dsn = "DBI:mysql:taldia" ; ## next line needs user and password $dbh = DBI->connect($dsn, "root", "frog", ## "", { RaiseError => 1, AutoCommit => 0 } ) or die " could not connect to sql database" ; } sub one-cat() { start_sql() ; $query = "SELECT " . "tree, " . "cat, " . "ybcat, " . "rank, " . "type, " . "rrdbcat, " . "prem " . "FROM cats " . "WHERE tree like '$arg{pcast}%'" ; $elog .= "$query\n" ; $sth = $dbh->prepare($query) ; $rv = $sth->execute ; if (!defined $rv) { die "mysql error -- SELECT failed\n" . "$query\n" ; exit(0) ; } $max_rows = $sth->rows ; #print "cat 0 maxrows is $max_rows $query\n" ; for (my $i=0; $i<$max_rows; $i++) { @row = $sth->fetchrow_array ; $args{tree} = $row[0] ; $args{cat} = $row[1] ; $args{ybcat} = $row[2] ; @rank = split / /, $row[3] ; $args{type} = $row[4] ; $args{rrdbcat} = $row[5] ; $args{prem} = $row[6] ; my $temp = $rank[0] ; print "Content-type: text/html \n"; print "Expires: 0 \n"; print "\n"; print "\n\n" . '' . "taldia forced category entry \n" ; ## print '' ; print '' ; print "

 

 \n" ; if ($error ne "") { print "$error was incorrect. please reenter it
\n" ; } if ($xerror ne "") { print "$xerror please reenter it
\n" ; } print "

\n " ; print '\n"; print "\n" ; print "\n" ; print "\n" ; print "\n" ; print "\n" ; print "
Category tree value
" . " " . "
" . "" . "
\n" ; } __END__ #!/usr/bin/perl -w ############################################################################# ## ## process to edit the data in a database cat record ## ## 04-dec-05 ## copy from buildad.pl to start ## ## 06-nov-05 ## start ## ############################################################################## use POSIX; use DBI; use strict ; my $datasize ; my $formdata ; my $thistag ; sub start_sql() ; sub FixQuote($) ; sub get_playtime($) ; my $dsn ; my $dbh ; my $sth ; my $rv ; my $max_rows ; my @row ; my $query ; my %args; my %pwd ; my $elog = "" ; my $request_method = $ENV{'REQUEST_METHOD'} ; if ($request_method eq "GET") { $formdata = $ENV{'QUERY_STRING'} ; } elsif ($request_method eq "POST") { $datasize = $ENV{'CONTENT_LENGTH'}; $elog .= "POST content length is $datasize
\n" ; read (STDIN, $formdata, $datasize); } else { $formdata = "" ; $datasize = length($formdata) ; } ##print ( "$formdata
\n"); $elog .= "FORMDATA $formdata
\n"; foreach $thistag ( split ( "&", $formdata ) ) { my $sstag = $thistag ; $thistag =~ s/[\n|\r]//g ; $elog .= "THISTAG1 is $thistag
\n" ; $thistag =~ s/\+/ /go ; $elog .= "THISTAG2 is $thistag
\n" ; $thistag =~ s/%([\dA-Fa-f][\dA-Fa-f])/pack ("C", hex ($1))/eg; $elog .= "THISTAG3 is $thistag
\n" ; $thistag =~ s/[\n|\r]//g ; $elog .= "THISTAG4 is $thistag
\n" ; my (@ts) = split "=", $thistag; ## $t2 =~ s/^\s+// ; ## $t2 =~ s/\s+$// ; my $t1 = $ts[0] ; my $t2 = $ts[1] ; for (my $i=2; $i<=$#ts; $i++) { $t2 .= "=" . $ts[$i] ; } $args{$t1} = $t2 ; if (defined $t2) { $elog .= "TAGS $t1 is $t2
\n" ; } else { $elog .= "TAGS $t1 is blank
\n" ; } } if (0) { print STDERR "ATTEMPTED LOGIN#1 $args{username} $args{password}\n" ; print STDERR "ATTEMPTED LOGIN#2 frodo is $pwd{frodo}\n" ; print STDERR "ATTEMPTED LOGIN#3 frodo is $pwd{$args{username}}\n" ; print STDERR " ($pwd{$args{username}} ne $args{password})\n" ; } my $error = "" ; my $xerror = "" ; if ( defined $args{tree} && $args{tree} ne "" && defined $args{read_data} && $args{read_data} ne "" ) { start_sql() ; $query = "SELECT " . "tree, " . "cat, " . "ybcat, " . "rank, " . "type, " . "rrdbcat, " . "prem " . "FROM cats " . "WHERE tree='$args{tree}'" ; $elog .= "$query\n" ; $sth = $dbh->prepare($query) ; $rv = $sth->execute ; if (!defined $rv) { die "mysql error -- SELECT failed\n" . "$query\n" } $max_rows = $sth->rows ; #print "cat 0 maxrows is $max_rows $query\n" ; if ($max_rows >= 1) { @row = $sth->fetchrow_array ; $args{tree} = $row[0] ; $args{cat} = $row[1] ; $args{ybcat} = $row[2] ; $args{rank} = $row[3] ; $args{type} = $row[4] ; $args{rrdbcat} = $row[5] ; $args{prem} = $row[6] ; } else { ## $args{tree} = "" ; $args{cat} = "" ; $args{ybcat} = "" ; $args{rank} = "" ; $args{type} = "0" ; $args{rrdbcat} = "" ; $args{prem} = "" ; } $sth->finish ; } elsif ( defined $args{update} && $args{update} ne "") { if (!(defined $args{tree}) || $args{tree} eq "") { $error = "tree value" } ## $xerror = "Ad name must be of the form ADnnnnn" ## unless $args{tree} =~ /^AD\d\d\d\d\d$/ ; $error = "category" if (!(defined $args{cat}) || $args{cat} eq "") ; $error = "prem" if (!(defined $args{prem}) || $args{prem} eq "") ; $error = "type" if (!(defined $args{type}) || $args{type} eq "") ; ## $error = "rank" ## if (!(defined $args{rank}) || $args{rank} eq "") ; $args{rank} = ' ' if (!(defined $args{rank}) || $args{rank} eq "") ; my @theranks = split " ", $args{rank} ; print STDERR "rank has $#theranks entries\n" ; for (my $ii=0; $ii<=$#theranks; $ii++) { my ($id, $playtime) = split "/", $theranks[$ii] ; if (!defined $playtime || $playtime < 10) { $playtime = get_playtime($id) ; $playtime = 30 if (!defined $playtime || $playtime < 2) ; } $theranks[$ii] = "$id/$playtime" ; } $args{rank} = join " ", @theranks ; $args{rank} .= " " ; if ($error eq "" and $xerror eq "") { start_sql() ; my $ttree = $args{tree} ; FixQuote($ttree) ; my $tcat = $args{cat} ; FixQuote($tcat) ; my $tybcat = $args{ybcat} ; FixQuote($tybcat) ; my $trank = $args{rank} ; FixQuote($trank) ; my $ttype = $args{type} ; FixQuote($ttype) ; my $trrdbcat = $args{rrdbcat} ; FixQuote($trrdbcat) ; my $tprem = $args{prem} ; FixQuote($tprem) ; $query = "REPLACE cats SET " . "tree=$ttree, " . "cat=$tcat, " . "ybcat=$tybcat, " . "rank=$trank, " . "type=$ttype, " . "rrdbcat=$trrdbcat, " . "prem=$tprem " ; $elog .= "$query\n" ; $sth = $dbh->prepare($query) ; $rv = $sth->execute ; if (!defined $rv) { die "mysql error -- $query\n" ; die "cant do replace in cats $DBI::errstr" ; } } } else { $xerror = "unknown call" ; } $args{tree} = "999999999" if (!(defined($args{tree}))) ; $args{tree} = "999999999" if ($args{tree} eq "") ; $args{cat} = "TALDIA is great" if (!(defined($args{cat}))) ; $args{cat} = "TALDIA is great" if ($args{cat} eq "") ; $args{prem} = "prem_content_class" if (!(defined($args{prem}))) ; ## $args{prem} = "prem_content_class" if ($args{prem} eq "") ; $args{rank} = " " if (!(defined($args{rank}))) ; $args{rank} = " " if ($args{rank} eq "") ; $args{ybcat} = "demo ". $args{cat} if (!(defined($args{ybcat})) || ($args{ybcat} eq "") ) ; $args{rrdbcat} = -1 if (!(defined($args{rrdbcat})) || ($args{rrdbcat} eq "") ) ; $args{type} = 0 if (!(defined($args{type})) || ($args{type} eq "") ) ; if (1) { print "Content-type: text/html \n"; print "Expires: 0 \n"; print "\n"; print "\n\n" . '' . "taldia forced category entry \n" ; ## print '' ; print '' ; print "

 

 \n" ; if ($error ne "") { print "$error was incorrect. please reenter it
\n" ; } if ($xerror ne "") { print "$xerror please reenter it
\n" ; } print "

\n " ; print '\n"; print "\n" ; print "\n" ; print "\n" ; print "\n" ; print "\n" ; print "\n" ; print "\n" ; print "\n" ; print "\n" ; print "\n" ; print "\n" ; ## "\n" print "\n" ; print "\n" ; print "\n" ; print "\n" ; print "\n" ; print "\n" ; print "\n" ; print "
Category tree value
" . " " . "
" . "" . "
Category (cat)
" . " " . "
Category (ybcat)
" . " " . "
Category (rrdbcat)
" . " " . "
Prem
" . "
Type
" . "
Rank
" . "
" . "" . "
\n
\n" ; print "$elog\n" ; print "\n\n" ; exit(0) ; } my $started = 0 ; sub start_sql() { return if $started ; $started++ ; $dsn = "DBI:mysql:taldia" ; ## next line needs user and password $dbh = DBI->connect($dsn, "root", "frog", ## "", { RaiseError => 1, AutoCommit => 0 } ) or die " could not connect to sql database" ; } sub get_playtime($) { my $id = shift ; my $playtime = 0 ; start_sql() ; $query = "SELECT " . "playtime " . "FROM news " . "WHERE id='$id'" ; $elog .= "$query
\n" ; $sth = $dbh->prepare($query) ; $rv = $sth->execute ; if (!defined $rv) { die "mysql error -- SELECT failed\n" . "$query\n" } $max_rows = $sth->rows ; #print "cat 0 maxrows is $max_rows $query\n" ; if ($max_rows >= 1) { @row = $sth->fetchrow_array ; $playtime = $row[0] ; $elog .= "playtime is $playtime
\n" ; } $sth->finish ; return $playtime ; } sub FixQuote($) { $_[0] =~ s/\\\'/'/g; $_[0] =~ s/^'//; $_[0] =~ s/'$//; # @_[0] =~ s/\\\\/\/g; $_[0] = $dbh->quote($_[0]); } __DATA__ Mercury News Page 2 MercuryNews.com : Bay Area news, technology, jobs, cars & real estate
Subscriber Services
Subscriber Services
Weather
Complete Forecast
Search  Recent News  Archives  Web   for    
News
  •  Education
  •  Obituaries
  •  Health / Science
Opinion
  •  Columnists
Business
  •  Technology
Life & Style
  •  Travel

PARTNERS

Win movie tickets
Win passes to see 'Last Holiday,' starring Queen Latifah and LL Cool J, on Jan. 10 in San Jose.
» Enter here to win tickets
Warriors Holiday Hoops Grand Prize Giveaway
Win tickets to four Warriors home games, an exclusively designed Baron Davis t-shirt and a Baron Davis poster.
» Click here to enter the contest
Win a satellite radio
Enter today to win a satellite radio from Hartzhiem Dodge!
» Click here to enter contest
Sharks Family Pack
Save $34 on four hot dogs, sodas, pretzels and tickets to the Sharks vs. St. Louis Blues game on Friday, Dec. 23.
» Sink your teeth into savings!

E-mail Alerts !
Featured Advertisers:
 •  Fry's
 •  Gold's Gym
 •  Macy's
 •  Click to see all ads

 


SIGN UP

Enter your information in the form below to sign up to access our audio and podcast news subscriber services.

 
 
 
Username: (min 6 characters)
Password: (min 5 characters)
   
First Name:
Gender:
   
Email Address:
Confirm Email:
 
 




Bay Area Top Jobs


    Financial Markets