"; ///////////////////////////////////// /////////////////////////////////////// if($sid == ''){ include_once("header.php"); print <<
You must specify a snippet to view.  



EOM; include_once("footer.php"); exit; } /////////////////////////////////////// ///////////////////////////////////// // get snippet data $snippet_query = "SELECT * FROM plibsnippets, plibcategories WHERE sid='$sid' AND plibcategories.cid = plibsnippets.category_id"; $snippet_result = mysql_query($snippet_query ); $snippet_row = mysql_fetch_array($snippet_result); $category_name = $snippet_row['category_name']; $snippet_name = $snippet_row['name']; $snippet_description = nl2br($snippet_row['description']); $snippet_comment = nl2br($snippet_row['comment']); $snippet_language = $snippet_row['language']; $highlight_mode = $snippet_row['highlight_mode']; $last_modified = $snippet_row['last_modified']; $category_id = $snippet_row['category_id']; $page_id = $snippet_row['page_id']; $search_keys = $snippet_row['search_keys']; $snippet_code = $snippet_row['snippet']; // Check for magic quotes, if it's on, do stripslashes $magic_quotes_gpc = (bool) ini_get('magic_quotes_gpc'); if ($magic_quotes_gpc) { $snippet_name = stripslashes($snippet_name); $snippet_description = stripslashes($snippet_description); $snippet_comment = stripslashes($snippet_comment); $snippet_language = stripslashes($snippet_language); } $meta_description = substr($snippet_description, 0, 100); $titlebar_text = ereg_replace('_', ' ', "$category_name: $snippet_name - $meta_description"); $header_bar_text = "$category_name: $snippet_name"; $meta_desc = ereg_replace('_', ' ', $snippet_name) . " - $meta_description"; // format actual link URL $snippet_link_name = preg_replace("/[^0-9a-z ]/i",'', $snippet_name); $snippet_link_name = ereg_replace(' ', '-', $snippet_link_name) . '_' . $sid . '.htm'; // format the visible link text $snippet_name_trail = $snippet_name; $category_link_trail = "/browse.htm?cid=$category_id"; $snippet_language_UPPER = strtoupper($snippet_language); $highlight_mode_UPPER = strtoupper($highlight_mode); // make HR last modified date $last_modified_HR = date('F dS, Y', strtotime($last_modified)); if($snippet_comment ==''){$snippet_comment = '(none)';} ///////////////////////////////////// if($category_id=='1'){$preword = 'PL-SQL-Code';} if($category_id=='2'){$preword = 'PHP';} if($category_id=='3'){$preword = 'Javascript';} if($category_id=='4'){$preword = 'Oracle-PL-SQL';} if($category_id=='5'){$preword = 'mySQL';} if($category_id=='6'){$preword = 'Perl';} ///////////////////////////////////// /////////////////////////////////////// // if logged, make an Admin link... if ($_SESSION['isloggedin'] != '' && $_SESSION['isloggedin'] == $glbl_hash) { $admin_link = << EOM; } /////////////////////////////////////// ///////////////////////////////////// // get snippets linked by search keys $SEARCHKEYLIMIT = 30; // find any matching title elements if($search_keys != ''){ $key_list = explode('|', $search_keys); if(count($key_list) > 1){ // format the list of search terms foreach($key_list as $search_term){ $search_blob .= "'%$search_term%' OR name LIKE "; } // remove last 'OR name LIKE' $search_keys = substr($search_blob, 0, -13); }else{ $search_keys = "'%" . $search_keys . "%'"; } $squery = "SELECT sid, name FROM plibsnippets WHERE sid <> '$sid' AND category_id = '$category_id' AND search_keys LIKE $search_keys ORDER BY sid DESC LIMIT $SEARCHKEYLIMIT;"; $squery_result = mysql_query($squery); if(mysql_num_rows($squery_result) > 0){ // build the list... while($link_row = mysql_fetch_array($squery_result)){ $link_name = $link_row['name']; $link_sid = $link_row['sid']; // prep the pretty URL $linkurl = ereg_replace(' ', '-', $link_name); $linkurl = preg_replace("/[^0-9a-zA-Z\_-]/i",'', $linkurl); $linkurl = $linkurl . '_' . $link_sid . '.htm'; $linkurl = ereg_replace('__', '-', $linkurl); if(strlen($link_name) > 39){$link_name = substr($link_name, 0, 38) . '...';} $linkblob .= "» $link_name
\n"; } $linkblob = "Also see:
$linkblob"; } } ///////////////////////////////////// ///////////////////////////////////// // build the next/last buttons $next_query = "SELECT sid, name FROM plibsnippets WHERE category_id = '$category_id' AND sid > '$sid' ORDER BY sid ASC LIMIT 1"; $next_result = mysql_query($next_query); $next_row = mysql_fetch_array($next_result); $nextsid = $next_row['sid']; $nextname = $next_row['name']; // prep the pretty url from the name $nexturl = ereg_replace(' ', '-', $nextname); $nexturl = preg_replace("/[^0-9a-zA-Z\_-]/i",'', $nexturl); $nexturl = $nexturl . '_' . $nextsid . '.htm'; $nexturl = ereg_replace('__', '-', $nexturl); $nexturl = preg_replace( '(-+)', '-', $nexturl ); // add category name to front of URL $nexturl = "$preword-$nexturl"; // if no "next" snippet, set the suppress flag if($nexturl == '_.htm'){$suppress_next = '1';} $prev_query = "SELECT sid, name FROM plibsnippets WHERE category_id = '$category_id' AND sid < '$sid' ORDER BY sid DESC LIMIT 1"; $prev_result = mysql_query($prev_query); $prev_row = mysql_fetch_array($prev_result); $prevsid = $prev_row['sid']; $prevname = $prev_row['name']; // prep the pretty url from the name $prevurl = ereg_replace(' ', '-', $prevname); $prevurl = preg_replace("/[^0-9a-zA-Z\_-]/i",'', $prevurl); $prevurl = $prevurl . '_' . $prevsid . '.htm'; $prevurl = ereg_replace('__', '-', $prevurl); $prevurl = preg_replace( '(-+)', '-', $prevurl ); // add category name to front of URL $prevurl = "$preword-$prevurl"; // if no "prev" snippet, set the suppress flag if($prevurl == '_.htm'){$suppress_prev = '1';} ///////////////////////////////////// ///////////////////////////////////// // highlight snippet code with geSHi $source = $snippet_code; $language = $highlight_mode; $path = '/var/www/virtual/psoug.org/htdocs/util/geshi/geshi/'; $geshi = new GeSHi($source, $language, $path); $geshi->set_header_type(GESHI_HEADER_PRE); $geshi->set_overall_style('background: #fefefe;', 'background: #e8e8e8;'); $geshi->set_line_style('background: #fefefe;', 'background: #e8e8e8;', true); $geshi->set_case_keywords(GESHI_CAPS_UPPER); $highlight_code = $geshi->parse_code(); ///////////////////////////////////// // share links block /* // get the snippet title $ptitle = $snippet_link_name; $ptitle = urlencode($ptitle); // get the full path string $pageurl = "http://psoug.org" . $_SERVER["REQUEST_URI"] . ".html"; $link_block = << Share this snippet: del.icio.us digg Reddit Furl Fark TailRank Ma.gnolia NewsVine Simpy Spurl EOM; */ ///////////////////////////////////// ///////////////////////////////////// // optional page bgcolor //$BCOLOR = "bgcolor='#D8D8C4'"; ///////////////////////////////////// // get header include('header.php'); print <<
Category: >> $category_name >> $snippet_name_trail Bookmark and Share

"; }else{ print ' '; } print << EOM; if($suppress_next != '1'){ print "next >>"; }else{ print ' '; } print <<
EOM; if($suppress_prev != '1'){ print "<< last

Snippet Name: $snippet_name

Description: $snippet_description

$linkblob

Comment: $snippet_comment

Language: $snippet_language_UPPER
Highlight Mode: $highlight_mode_UPPER
Last Modified: $last_modified_HR $admin_link

$highlight_code


Free
Oracle Magazine
Subscriptions
and Oracle White Papers


SQL University.net courses meet the most demanding needs of the business world for advanced education in a cost-effective manner. SQL University.net courses are available immediately for IT professionals and can be taken without disruption of your workplace schedule or processes.

Compared to traditional travel-based training, SQL University.net saves time and valuable corporate resources, allowing companies to do more with less. That's our mission, and that's what we deliver.

Click here to find out more
EOM; // get footer include('footer.php'); ?>