Changeset 438

Show
Ignore:
Timestamp:
11/07/04 00:19:23 (4 years ago)
Author:
hirokai
Message:

fixed occasionally broken flickr thumbs
fixed broken previous mail recip if they have none...
switched to xsltproc from sabcmd...

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/feedmelinks/feedmelinks/_xsl/flickr.xsl

    r429 r438  
    1111        <xsl:output method="xml" indent="yes" omit-xml-declaration="yes" /> 
    1212 
    13 <xsl:template match="/rsp[@stat='ok']"> 
     13<xsl:template match="/rsp[@stat='ok']"><!-- 
    1414 
    1515embedded rest call:  
     
    1919<xsl:text> 
    2020</xsl:text> 
    21  
     21--> 
    2222<xsl:value-of select="sizes/size[@label='Thumbnail']/@source" /></xsl:template> 
    2323 
  • trunk/feedmelinks/feedmelinks/edit-folder.php

    r427 r438  
    9797                $qs = "SELECT userid FROM linksGroups where ID = $id"; 
    9898                $q = mysql_query( $qs ); 
    99                 $numRows = mysql_num_rows($q); 
     99                if( $q ) 
     100                        $numRows = mysql_num_rows($q); 
    100101                if( $numRows ) { 
    101102                        $dbUserId = mysql_result($q,0,"userid"); 
    102103                        if( $dbUserId == $u ) { 
    103                                 $qs = "DELETE from linksGroups where ID = $id"
     104                                $qs = getQuery( "delete_category", $id )
    104105                                $q = mysql_query( $qs ); 
    105106                                if( $q ) {  
     
    146147                                } else { echo "deleting " . getCatName() . " failed! sorry, i suk!"; }  
    147148                        } 
     149                } else { 
     150                        echo "\$q was |$q|<br>"; 
     151                        echo "DEBUG:<br>$qs<br>"; 
     152                        echo "Sorry, can't find a group with ID #$id<br>"; 
    148153                } 
    149154 
  • trunk/feedmelinks/feedmelinks/mailer.php

    r427 r438  
    9797<% 
    9898                } 
    99         } else { 
     99        }  
    100100%> 
    101101 
    102  
    103 <% 
    104         } 
    105 %> 
    106  
  • trunk/feedmelinks/feedmelinks/modules/utils.inc.php

    r437 r438  
    9797        } 
    9898 
    99         # handler: 
    100         function handGetAll($processor,$scheme,$rest) { 
    101                 $rest=substr($rest,1); 
    102                 switch($scheme) { 
    103                         case 'http': 
    104                                 $uri = "http://".$rest; 
    105                                 $ch = curl_init( $uri ); 
    106                                 curl_setopt($ch, CURLOPT_HEADER, 0); 
    107                                 ob_start(); 
    108                                 curl_exec($ch); 
    109                                 curl_close($ch); 
    110                                 $c = ob_get_clean(); 
    111                                 return $c; 
    112                         } 
    113                 break; 
    114         } 
    115  
    11699function get_flickr_thumb( $argPhotoId ) { 
    117         # XML content : 
    118100        $key = "91640f92a17280b1953f02c0b79956bf"; 
    119         $xml='<' . '?' . 'xml version="1.0"?> 
    120                         <page url="www.flickr.com/services/rest/?method=flickr.photos.getSizes&amp;api_key=' . $key . '&amp;photo_id=' . $argPhotoId . '">W3C Recommendation page</page>'; 
    121  
    122         # XSL content : 
    123         $xsl='<' . '?xml version="1.0"?> 
    124         <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> 
    125         <xsl:output method="xml" encoding="UTF-8" omit-xml-declaration="yes"/> 
    126         <xsl:template match="/"> 
    127                  <xsl:value-of select="document(concat(\'http:\',page/@url))/rsp/sizes/size[@label=\'Thumbnail\']/@source"/> 
    128         </xsl:template> 
    129         </xsl:stylesheet>'; 
    130  
    131         $xh = xslt_create(); 
    132         xslt_set_scheme_handlers($xh,array("get_all" => "handGetAll")); 
    133         $out = xslt_process($xh,'arg:/_xml', 'arg:/_xsl',NULL,array("/_xml"=>$xml,"/_xsl"=>$xsl)); 
    134         xslt_free($xh); 
    135         return $out; 
     101        $url = 'www.flickr.com/services/rest/?method=flickr.photos.getSizes&api_key=' . $key . '&photo_id=' . $argPhotoId; 
     102        $lines = xform( "_xsl/flickr.xsl", "http://$url" ); 
     103        if( sizeof( $lines == 1 )) 
     104                return $lines[0]; 
     105        else 
     106                return "/img/spacer.gif"; 
    136107} 
    137108 
     
    484455} 
    485456 
     457function xform( $argXSL, $argXML ) { 
     458        $lines = array(); 
     459        $cmd = get_parser() . " $argXSL \"$argXML\""; 
     460 
     461        $debug = 0; 
     462        if( $debug ) 
     463                echo "<br>$cmd<br>"; 
     464 
     465        exec( "$cmd", $lines ); 
     466 
     467        if( $debug ) { 
     468                echo "\$cmd: $cmd<br>"; 
     469                print "there are " . sizeof( $lines ) . " lines"; 
     470                print_r( $lines ); 
     471                foreach ($lines as $line) { 
     472                        echo "$line<br>"; 
     473                } 
     474        } 
     475 
     476        return $lines; 
     477} 
     478 
    486479function get_xml_cachelist( $argCacheFile ) { 
    487480        chdir( get_root() ); 
     
    502495 
    503496  if( is_file( $argCacheFile ) && is_readable( $argCacheFile ) && is_writeable( $argCacheFile )) { 
    504                 $parser = xslt_create(); 
    505                 $result = xslt_process($parser, $argCacheFile, get_root() . "/_xsl/mailtos.xsl" ); 
    506                 xslt_free($parser); 
    507                 if( $result ) { 
    508                         $items = explode( "\n", $result ); 
     497 
     498                $debug = 0; 
    509499                 
    510                         # need to clean out the junk: 
     500                $lines = xform( get_root() . "/_xsl/mailtos.xsl", $argCacheFile ); 
     501 
     502                if( $debug ) { 
     503                        echo "\$cmd: $cmd<br>"; 
     504                        print "there are " . sizeof( $lines ) . " lines"; 
     505                        print_r( $lines ); 
     506                        foreach ($lines as $line) { 
     507                                echo "$line<br>"; 
     508                        } 
     509                } 
     510 
     511                if( $lines ) { 
    511512                        $t = array(); 
    512                         foreach ($items as $item) { 
    513                                 $item = ltrim( rtrim( chop( $item ))); 
    514                                 if( $item
    515                                         array_push( $t, $item ); 
     513                        foreach ($lines as $line) { 
     514                                $line = ltrim( rtrim( chop( $line ))); 
     515                                if( $line
     516                                        array_push( $t, $line ); 
    516517                        } 
    517                         $items = $t; 
    518                         return $items; 
     518                        $lines = $t; 
     519                        return $lines; 
    519520                } 
    520521        } else { 
     
    583584function get_last_mailto() { 
    584585        $mailtos = get_cachelist( "mailtos" ); 
    585         $tmp = array_keys( $mailtos ); 
    586         return $tmp[0]; 
     586        if( sizeof( $mailtos )) { 
     587                $tmp = array_keys( $mailtos ); 
     588                return $tmp[0]; 
     589        } else { 
     590                ""; 
     591        } 
    587592} 
    588593 
     
    12201225        else 
    12211226                return "hirokai_jm3DataMart"; 
     1227} 
     1228 
     1229function get_parser() { 
     1230        global $env; 
     1231        if( $env == "powerbook" ) 
     1232                return "/sw/bin/xsltproc"; 
     1233        else 
     1234                return "/usr/local/bin/xsltproc"; 
    12221235} 
    12231236 
  • trunk/feedmelinks/feedmelinks/submit-link.php

    r429 r438  
    9999                                                        if( $debug ) 
    100100                                                                echo "<br />"; 
    101                                                         $qs = "INSERT INTO linksCategoriesXRef VALUES( $newLinkID, $catNum );"
     101                                                        $qs = getQuery( "add_new_category_xref", $newLinkID, $catNum )
    102102                                                        if( $debug ) 
    103103                                                                echo "DEBUG: $qs<br />"; 
  • trunk/feedmelinks/feedmelinks/t.php

    r395 r438  
    1111        mysql_selectdb( getDBName() ); 
    1212         
    13         $qs = "INSERT INTO linkMetrics (linkID, date, user, source ) VALUES ( $linkID, NULL, '$u', 'unused' );"; 
    14         #echo "$qs<br />"; 
     13        $qs = getQuery( "track_hit", $linkID, $u ); 
    1514 
    1615        $q = mysql_query( $qs ); 
    1716        conClose( $con_t); 
    18         #echo "q: $q\n"; 
    1917 
    2018        header("Location: " . urldecode( getURLForLink( $linkID )) ); 
    21  
    2219%> 
    2320