TIME() - 1){ // users will get this message if they make requests faster than 1 per second print "
To prevent overloading our server, please lower the rate of your page requests to less than 1 per second."; // try and get the real IP address... if (getenv('HTTP_CLIENT_IP')) { $ip_address = getenv('HTTP_CLIENT_IP'); }elseif (getenv('HTTP_X_FORWARDED_FOR')) { $ip_address = getenv('HTTP_X_FORWARDED_FOR'); }elseif (getenv('HTTP_X_FORWARDED')) { $ip_address = getenv('HTTP_X_FORWARDED'); }elseif (getenv('HTTP_FORWARDED_FOR')) { $ip_address = getenv('HTTP_FORWARDED_FOR'); }elseif (getenv('HTTP_FORWARDED')) { $ip_address = getenv('HTTP_FORWARDED'); }else { $ip_address = $_SERVER['REMOTE_ADDR']; } $REQUEST_LIMIT = 20; include('/var/www/virtual/psoug.org/htdocs/psconfig.php'); $_SESSION['request_count'] = $_SESSION['request_count'] + 1; $req_count = $_SESSION['request_count']; // try to update the offending IP... $throttle_sql = "UPDATE `bw_throttle` SET req_count = (req_count+1), last_req_time = NOW() WHERE req_ip = '$ip_address'"; $throttle_result = mysql_query($throttle_sql); if(mysql_affected_rows() <> 1){ // if the update wasn't successful then the record // doesn't exist, so add the offender to the list if($DIAG=='1'){print 'Adding Offender.....
';} $throttle_sql = "INSERT INTO `bw_throttle` (init_time, last_req_time, req_ip, req_count, delay_time) VALUES (NOW(), NOW(), '$ip_address', '1', '$delay_time')"; $throttle_result = mysql_query($throttle_sql); }else{ // the offender was updated. Check to see if they've hit the limit if($DIAG=='1'){print 'Updated.....
';} $limit_check = "SELECT * FROM bw_throttle WHERE req_ip = '$ip_address'"; $limit_result = mysql_query($limit_check); list($init_time, $last_req_time, $req_ip, $req_count, $delay_time) = mysql_fetch_array($limit_result); if($DIAG=='1'){print "LIMIT COUNT: $req_count
";} if($req_count > $REQUEST_LIMIT){ // add them to the blacklist table, delete from bw_throttle table if($DIAG=='1'){print 'Adding Offender to BLACKLIST table...
';} // get difference between the two in seconds $time_period = ( strtotime($last_req_time) - strtotime($init_time) ); $request_data = "Made $req_count overload requests in $time_period seconds"; if($time_period > 60){ $hours = intval(intval($time_period) / 3600); $hms .= ($padHours) ? str_pad($hours, 2, "0", STR_PAD_LEFT). ':' : $hours. ':'; $minutes = intval(($time_period / 60) % 60); $hms .= str_pad($minutes, 2, "0", STR_PAD_LEFT). ':'; $seconds = intval($time_period % 60); $hms .= str_pad($seconds, 2, "0", STR_PAD_LEFT); $request_data .= "($hms)"; } $bl_sql = "INSERT INTO `ip_blacklist` (`ip_address`, `time_stamp`, `qstring`) VALUES ('$ip_address', NOW(), '$request_data')"; $bl_result = mysql_query($bl_sql); /////////////////////////////////////////// $headers = ''; $to = 'info@psoug.org'; $subject = "DEF User Block Added: $ip_address"; $message = "Oracle Definition Library\nA user block was added:\n\nIP: $ip_address\nRequest Data: $request_data"; $headers = "From: waylon@deltabravo.net\r\n"; $headers .= "Return-Path: waylon@deltabravo.net\r\n"; // send email mail($to,$subject,$message,$headers); /////////////////////////////////////////// // remove from bw_throttle table if($DIAG=='1'){print 'Deleting Offender from bw_throttle table...
';} $remove_sql = "DELETE FROM bw_throttle WHERE req_ip = '$ip_address'"; $remove_result = mysql_query($remove_sql); } } exit; } $_SESSION['last_session_request'] = TIME(); ///////////////////////////////////// // possible include files include('/var/www/virtual/psoug.org/htdocs/psconfig.php'); // include('/var/www/virtual/psoug.org/htdocs/util/sanitize.php'); // include('/var/www/virtual/psoug.org/htdocs/util/pagination.php'); $expand_tag = <<
Want to expand, correct, or add to this information? Please contact us!
EOM; ///////////////////////////////////// $header_code = << EOM; ///////////////////////////////////// // get incoming vars $term = preg_replace("/[^0-9a-zA-Z_-]/i",'', $_REQUEST['term']); $pageURL .= $_SERVER["REQUEST_URI"]; // get just the term with no path or '.htm' $term = strtolower(substr($pageURL, strrpos($pageURL, '/')+1, -4)); //print "T: $term "; // other miscellaneous fixups if($term == 'constraints'){$term = 'constraint';} if($term == 'connect_by'){$term = 'connect';} if($term == 'elsif'){$term = 'if';} if($term == 'endif'){$term = 'if';} if($term == 'create_shared_database_link'){$term = 'create_database_link';} $term_sql = "SELECT * from term_definitions WHERE term_item = '$term'"; $term_result = mysql_query($term_sql); if(mysql_num_rows($term_result) < 1){ // clear the term, skip any further processing, // then re-display the selction box and list $term = ''; }else{ $term_row = mysql_fetch_array($term_result); $term_item = $term_row['term_item']; $term_def = nl2br($term_row['term_def']); $term_title = $term_row['term_title']; $term_links = $term_row['term_links']; // special fixups to replace underscores with a space and convert some terms if($term_item == 'FOREIGN_KEY'){$term_item = preg_replace("|_|", ' ', $term_item);} if($term_item == 'ORDER_BY'){$term_item = preg_replace("|_|", ' ', $term_item);} if($term_item == 'GROUP_BY'){$term_item = preg_replace("|_|", ' ', $term_item);} if($term_item == 'EXECUTE_IMMEDIATE'){$term_item = preg_replace("|_|", ' ', $term_item);} if($term_item == 'CALL_INTERFACE'){$term_item = preg_replace("|_|", ' ', $term_item);} if($term_item == 'START_WITH_CONNECT_BY'){$term_item = preg_replace("|_|", ' ', $term_item);} if($term_item == 'DAY_TO_SECOND'){$term_item = preg_replace("|_|", ' ', $term_item);} if($term_item == 'YEAR_TO_MONTH'){$term_item = preg_replace("|_|", ' ', $term_item);} if($term_item == 'CREATE_INDEX'){$term_item = preg_replace("|_|", ' ', $term_item);} if($term_item == 'CREATE_DATABASE_LINK'){$term_item = preg_replace("|_|", ' ', $term_item);} if($term_item == 'ACCESS_INTO_NULL'){$term_item = preg_replace("|_|", ' ', $term_item);} if($term_item == 'CREATE_INDEX'){$term_item = preg_replace("|_|", ' ', $term_item);} // set meta description $meta_desc = strip_tags(substr($term_def, 0, 150)); // preprocess any '' tags in the definition text - Awesome! //$term_def = preg_replace("|(.+?)|si", "$1", $term_def); // for seo style links $term_def = preg_replace("|(.+?)|si", "$1", $term_def); // special handling - remove line breaks in between tags //$term_def = preg_replace("|(.*?)
(.*?)
|si", str_replace("
", '', $term_def), $term_def); // strip any tags //$term_def = preg_replace("/|<\/NBRK>/si", '', $term_def); // check for the tag $term_def = str_replace('', $expand_tag, $term_def); // strip breaks from zones $term_def = preg_replace_callback('/(.*)<\/NBRK>/msi', create_function('$matches', 'return preg_replace(array("/
/msi","/\n/"),"", $matches[1]);'), $term_def); } // end if term not found // if there is a term, find any possible related snippets in the snippet library if($term != ''){ //$snip_sql = "SELECT sid, name, description FROM plibsnippets WHERE name LIKE '%$term_item%' AND category_id = 4"; $snip_sql = "SELECT sid, name, description FROM plibsnippets WHERE name LIKE '%$term%' AND category_id = 4 LIMIT 25"; $snip_result = mysql_query($snip_sql); $snip_rows = mysql_num_rows($snip_result); if($snip_rows > 0){ //print "Snippets Found"; $snippet_block = '
    '; while($snippet_row = mysql_fetch_array($snip_result)){ $sid = $snippet_row['sid']; $snippet_name = $snippet_row['name']; $snippet_description = $snippet_row['description']; // prep the pretty url from the name $pname = ereg_replace(' ', '-', $snippet_name); $pname = preg_replace("/[^0-9a-zA-Z\_-]/i",'', $pname); $pname = $pname . '_' . $sid; $pname = ereg_replace('__', '-', $pname); $pname = ereg_replace('--', '-', $pname); //$pname = "$preword-$pname"; // dynamically adjust the clipping length of the description // based on the length of the name/title $name_len = strlen($snippet_name); $MAXLENGTH = (100 - $name_len); $CLIPTO = $MAXLENGTH - 5; if(strlen($snippet_description) > $MAXLENGTH){$snippet_description = substr($snippet_description, 0, $CLIPTO) . "... ";} if ($snippet_description != "") { $snippet_description = " - ".$snippet_description; } $snippet_block .= <<$snippet_name$snippet_description EOM; } $snippet_block .= '
'; } // end if $snip_rows }else{ $term_box = <<Type a few characters into the Search box to find Oracle and PL/SQL terms, functions, and keywords:
 

Or, click on a term in the list below: EOM; } if($term_title == ''){$term_title = 'Oracle PL/SQL Syntax & Examples';} ///////////////////////////////////// $titlebar_text = "$term_title"; $page_title = $titlebar_text; $header_bar_text = $titlebar_text; // add index link to $header_bar_text $header_bar_text .= "      [Return To Index]"; ///////////////////////////////////// // optional page bgcolor //$BCOLOR = "bgcolor='#D8D8C4'"; ///////////////////////////////////// // get header include('/var/www/virtual/psoug.org/htdocs/header.php'); print <<  Looking for the original pages? (formerly called "Morgan's Library") You can find them here.
EOM; if($term_item != ''){ $term_item_link = $term_item; // special fixups to replace spaces with underscores and convert some terms if($term_item == 'FOREIGN KEY'){$term_item_link = preg_replace("| |", '_', $term_item);} if($term_item == 'ORDER BY'){$term_item_link = preg_replace("| |", '_', $term_item);} if($term_item == 'GROUP BY'){$term_item_link = preg_replace("| |", '_', $term_item);} if($term_item == 'EXECUTE IMMEDIATE'){$term_item_link = preg_replace("| |", '_', $term_item);} if($term_item == 'CALL INTERFACE'){$term_item_link = preg_replace("| |", '_', $term_item);} if($term_item == 'START WITH CONNECT BY'){$term_item_link = preg_replace("| |", '_', $term_item);} if($term_item == 'DAY TO SECOND'){$term_item_link = preg_replace("| |", '_', $term_item);} if($term_item == 'YEAR TO MONTH'){$term_item_link = preg_replace("| |", '_', $term_item);} if($term_item == 'CREATE INDEX'){$term_item_link = preg_replace("| |", '_', $term_item);} if($term_item == 'ACCESS INTO NULL'){$term_item_link = preg_replace("| |", '_', $term_item);} print <<

Term: $term_item

Definition:
$term_def EOM; if($term_links != ''){ print '


Related Links:
    '; $link_list = explode("\n", $term_links); foreach($link_list as $ref_link){ $ref_link = explode('|', $ref_link); print "
  • $ref_link[1]
  • \n"; } print '
'; } if($snippet_block != ''){ print << Related Code Snippets:
$snippet_block EOM; } }else{ print << 4){$TABLE_WIDTH = '100'; $COLWIDTH = '';} $term_list = "
"; // get list of terms $term_sql = "SELECT term_item, term_title from term_definitions WHERE term_enabled = 'y' ORDER BY term_item ASC"; $term_result = mysql_query($term_sql); // how many terms per column? $term_count = mysql_num_rows($term_result); $terms_per_column = round(($term_count / $COLUMN_COUNT)) + 1; //print "TC: $term_count, TPC: $terms_per_column
"; while($term_row = mysql_fetch_array($term_result)){ $term_item = $term_row['term_item']; $term_title = $term_row['term_title']; $term_list .= "$term_item\n
"; $term_counter++; if($term_counter == $terms_per_column){ $term_list .= "
"; $term_counter = 0; } } if(substr($term_list, -4) == '
'){ $term_list = substr($term_list, 0, -4); } $term_list .= '
'; $term_list = "
$term_list
"; print $term_list; } print << EOM; // get footer include('/var/www/virtual/psoug.org/htdocs/footer.php'); ?>