Heiner's SHELLdorado
Links
SHELLdorado - your UNIX shell scripting resource
HomeGood Shell Coding PracticesExample Shell ScriptsShell Scripting LinksShell Scripting Tips+TricksShell Scripting Articles

# Date: 2000-09-01 # Category: WWW, PHP # $Id: scancol.phtml,v 1.5 2010/03/15 22:11:06 heiner Exp $ ##################################################################### # Description: # Prints all categories sorted by "categnum". Categories are # printed only if at least one resource for this category # exists. ##################################################################### # $Log: scancol.phtml,v $ # Revision 1.5 2010/03/15 22:11:06 heiner # PHP5 compatibility # # Revision 1.4 2010-03-15 22:01:24 heiner # PHP5 compatibility # # Revision 1.3 2000-09-24 12:11:28 heiner # Fixed some HTML errors found with "weblint" # # Revision 1.2 2000/09/24 11:41:56 heiner # Remove leading "Shell" from category name # # Revision 1.1 2000/09/24 09:44:51 heiner # Prints a list of categories # ##################################################################### require ('globals.inc.phtml'); $standalone = false; require ('dblib.phtml'); ##################################################################### # Main program ##################################################################### $lid = mysql_connect ($dbhost, $dbuser, $dbpasswd); if ( $lid <= 0 ) { dberror ("could not connect to $dbuser@dbhost", true); exit; } if ( !mysql_select_db ($dbname, $lid) ) { dberror ("could not select database $dbname", true); exit; } if ( $standalone ) { print "\n\n"; } $query = "SELECT cid, title, shortname FROM category" . " WHERE class='RESOURCE' AND enabled='Y'" . " ORDER BY categnum"; $categories = mysql_query ($query, $lid) or dbfatal ("cannot access categories", true); print "\n"; while ( ($categ = mysql_fetch_array ($categories, MYSQL_ASSOC)) ) { for ( $n=key ($categ); $n=key ($categ); next ($categ) ) { $$n = $categ [$n]; } $countres = "SELECT COUNT(resource.rid)" . " FROM resource, link" . " WHERE link.cid=$cid AND link.rid=resource.rid" . " AND enabled='Y'"; #print "DEBUG: ". htmlspecialchars ($countres) ."
\n"; $resources = mysql_query ($countres, $lid); if ( !$resources || mysql_num_rows ($resources) != 1 ) continue; $row = mysql_fetch_row ($resources); if ( $row [0] < 1 ) continue; $title = preg_replace ("/^Shell[[:space:]]*/i", "", $title); print '
'."\n"; } print "
'; print ''; print ''. htmlspecialchars ($title) .''; print ''; print '
\n"; if ( $standalone ) { print "\n\n"; } ?>

# Date: 2000-09-01 # Category: WWW, PHP # $Id: links.phtml,v 1.22 2010/03/15 21:58:02 heiner Exp $ ##################################################################### # Description: # Prints links grouped by category, sorted by rank. # Each entry has the following format: # # urltitle (author[, ...]) - resource description # - url level > 0 # [- url level > 0 ...] ##################################################################### define ("DATEFMT", '%Y-%m-%d %H:%M:%S'); require ('globals.inc.phtml'); empty ($standalone) and $standalone = false; require ('dblib.phtml'); /*******************************************************************/ function printpage () { global $lid, $standalone; #print '\n"; if ( !$standalone ) { print 'The location of this page is' . ' ' . 'http://www.shelldorado.com/links/'."\n"; print '

If a link does not work, or if you know' . ' a new link for this page, please' . ' write me a mail.' . "

\n"; print '

[New] marks resources that were added within' . " the last 30 days
\n"; print '[Update] indicates that the web resource' . ' and/or the SHELLdorado description was' . " modified within the last 30 days

\n"; } ################################################################# $nresources = 0; $nuris = 0; $today = strftime (DATEFMT); $lastmonth = mktime (0, 0, 0, date ('m')-1, date ('d'), date ('Y')); #$lastmonth = mktime (0, 0, 0, 10, 7, 2000); $lastmonth = strftime (DATEFMT, $lastmonth); ################################################################# # Group all links by categories ################################################################# $catquery = "SELECT cid, title, shortname FROM category" . " WHERE class='RESOURCE' AND enabled='Y'" . " ORDER BY categnum"; $categories = mysql_query ($catquery, $lid) or dbfatal ("cannot access categories", true); while ( $category = mysql_fetch_array ($categories, MYSQL_ASSOC) ) { $cid = $category ['cid']; $canchor = $category ['shortname']; $ctitle = $category ['title']; ############################################################# # Get all resources from this category ############################################################# # Needed fields: # rid # originator.firstname/lastname # resource.description # uri.url # uri.description # [uri.level] # [uri.uritype] $resquery = "SELECT DISTINCT resource.rid, resource.title" . " , resource.description" . " , rank, resource.lastchange, resource.created" . " FROM resource, link" . " WHERE link.cid=$cid" . " AND link.rid=resource.rid" . " AND enabled='Y'" . " AND (" . " SELECT COUNT(*)" . " FROM uri" . " WHERE uri.urid = link.urid" . " AND enabled='Y' AND valid='Y') >= 1" . " ORDER BY link.rank DESC"; /* Resource query id */ $resources = mysql_query ($resquery, $lid) or dbfatal ("could not get resources (" . htmlspecialchars ($resquery) .")", true); if ( mysql_num_rows ($resources) < 1 ) continue; ############################################################# # At this point we are sure that at least one resource # exists. Print the category title ############################################################# $hlevel = 2; if ( $standalone ) { print ("$ctitle\n"); } else { print '
' . '' . htmlspecialchars ($ctitle) . '' . 'Top
'."\n"; } print "
    \n"; while ( ($resource=mysql_fetch_array ($resources, MYSQL_ASSOC)) ) { ++$nresources; reset ($resource); while ( list ($n, $val) = each ($resource) ) { #print "DEBUG: n=$n: ". $resource [$n] ."
    \n"; $$n = $val; } $rdesc = $resource ['description']; $rdesc = preg_replace ("/[ \t\r\n]+/", " ", $rdesc); $rtitle = $resource ['title']; $lastchange = timestamp2isodate ($lastchange); $created = timestamp2isodate ($created); #print "DEBUG: today=$today, lastmonth=$lastmonth, lastchange=$lastchange, created=$created
    \n"; $resnew = isodate_newer ($created, $lastmonth); $resupdated = isodate_newer ($lastchange, $lastmonth); ######################################################### # Get all authors of this resource ######################################################### $authorquery = "SELECT firstname, lastname, reltype" . " FROM originator, ownership" . " WHERE rid=$rid" . " AND ownership.pid=originator.pid" . " AND originator.public!='N'"; $authors = mysql_query ($authorquery, $lid); unset ($author); if ( $authors && mysql_num_rows ($authors) > 0 ) { while ( ($row = mysql_fetch_row ($authors)) ) { $firstname = $row [0]; $lastname = $row [1]; $reltype = $row [2]; $name = $firstname; if ( !empty ($name) && !empty ($lastname) ) { $name .= " "; } $name .= $lastname; $author [] = $name; # . "($reltype)"; $ownership [$name] = ucfirst (strtolower ($reltype)); } #print "DEBUG: authors: ".implode("; ",$author). "
    \n"; } ######################################################### # Get the URLs for this resource ######################################################### $uriquery = "SELECT uri.urid, url, description, level" . ", uri.lastchange, reschange" . " FROM uri, link" . " WHERE link.rid=$rid" . " AND link.urid=uri.urid" . " AND link.cid=$cid" . " AND enabled='Y' AND valid='Y'" . " ORDER BY uri.level, link.rank, uritype DESC"; $uris = mysql_query ($uriquery, $lid) or dberror ("QUERY: " . htmlspecialchars ($uriquery) ."", true); if ( $uris && mysql_num_rows ($uris) > 0 ) { $firsturl = 1; $continued = 0; while ( ($uri = mysql_fetch_array ($uris, MYSQL_ASSOC)) ) { ++$nuris; ################################################# # Print one comment for each URI ################################################# $urid = $uri ['urid']; $url = $uri ['url']; $udesc = $uri ['description']; $ulevel = $uri ['level']; $ulastchange = timestamp2isodate ($uri ['lastchange']); $ureschange = timestamp2isodate ($uri ['reschange']); #print "DEBUG: ulastchange=$ulastchange, ureschange=$ureschange
    \n"; $urlupdated = isodate_newer ($ulastchange, $lastmonth); $uresupdated = isodate_newer ($ureschange, $lastmonth); $isnew = $resnew; $isupdated = $resupdated || $urlupdated || $uresupdated; if ( !$firsturl && !$continued ) { print "
      \n"; $continued = 1; } $iref = ""; if ( $firsturl ) { print "
    • "; print "" . htmlspecialchars ($udesc) .""; if ( !empty ($author) ) { print " ("; reset ($author); reset ($ownership); while ( list ($i, $name) = each ($author) ) { if ( $i ) print ", "; $t = $ownership [$name]; print "" . htmlspecialchars ($name) . ""; } print ")"; } if ( !empty ($rdesc) ) { print " - ". htmlspecialchars ($rdesc); } $firsturl = 0; } else { print "
    • " . htmlspecialchars ($udesc) .""; } if ( $isnew ) { print '[New]'; } elseif ( $isupdated ) { print '[Update]'; } print "$iref"; print "\n"; #print "DEBUG: uris: ". implode("\n\t",$uri). "
      \n"; } if ( $continued ) print "
    \n"; } else if ( $standalone ) { print "
  • "; print "no uris for resource $rid "; print "" . htmlspecialchars ($rtitle) ." - " . htmlspecialchars ($rdesc) .""; if ( !empty ($author) ) { print " ("; reset ($author); reset ($ownership); while ( list ($i, $name) = each ($author) ) { if ( $i ) print ", "; $t = $ownership [$name]; print "" . htmlspecialchars ($name) . ""; } print ")"; print ""; } } } print "
\n"; } if ( !$standalone ) { print "

Thanks to Brian Hiles" . " <brian_hiles@rocketmail.com>" . " for providing his extensive link collection.\n"; print '

Last recent update: 2021-09-20

'; } else { print "

$nresources resources, $nuris links

\n"; } } /******************************************************************** * Main program *******************************************************************/ $lid = mysql_connect ($dbhost, $dbuser, $dbpasswd); if ( $lid <= 0 ) { dberror ("could not connect to $dbuser@dbhost", true); exit; } if ( !mysql_select_db ($dbname, $lid) ) { dberror ("could not select database $dbname", true); exit; } if ( $standalone ) { print "\n\n"; } printpage (); if ( $standalone ) { print "\n\n"; } ?>
   
Copyright © 1998-2020 Heiner Steven (heiner.steven@shelldorado.com)