'; // Google links $googlelinks = ' '; // connect to database $connection=@mysql_connect( $dbhost, $username, $password ) or die( "Not able to connect server" ); @mysql_select_db( $database, $connection ) or die( "Not able to open database" ); class getItem { var $data; function getItem( $id ) { $sql="SELECT * FROM items WHERE ID = ".$id; $result=mysql_query( $sql ); $this->data=mysql_fetch_array( $result ); } function getParent() { return $this->data['parent']; } function getPosition() { return $this->data['position']; } function getMenuTitle() { return $this->data['menu_title']; } function getItemTitle() { return $this->data['item_title']; } function getContent() { return $this->data['content']; } function getUrl() { return $this->data['url']; } function getKeywords() { return $this->data['keywords']; } } class getMenu { // id / parent / position / item / title var $data; var $menuitems; function getMenu() { $sql="SELECT * FROM items WHERE parent = 0 ORDER BY position"; $result=mysql_query( $sql ); $count = 1; if ( $result && mysql_num_rows( $result )>0 ) { $count = 0; while( $row=mysql_fetch_array( $result )) { $this->data[]=$row; $count++; } } $this->menuitems = $count; } function getMenuItems() { return $this->menuitems; } function getId( $id ) { return $this->data[ $id ]['id']; } function getParent( $id ) { return $this->data[ $id ]['parent']; } function getPosition( $id ) { return $this->data[ $id ]['position']; } function getTitle( $id ) { return $this->data[ $id ]['menu_title']; } function getUrl($id ) { return $this->data[ $id ]['url']; } } class getSubMenu { // id / parent / position / item / title var $data; var $menuitems; function getSubMenu($id) { $sql="SELECT * FROM items WHERE parent = ".$id." ORDER BY position"; $result=mysql_query( $sql ); $count = 1; if ( $result && mysql_num_rows( $result )>0 ) { $count = 0; while( $row=mysql_fetch_array( $result )) { $this->data[]=$row; $count++; } } $this->menuitems = $count-1; } function getMenuItems() { return $this->menuitems; } function getId( $id ) { return $this->data[ $id ]['id']; } function getPosition( $id ) { return $this->data[ $id ]['position']; } function getTitle( $id ) { return $this->data[ $id ]['menu_title']; } function getUrl( $id ) { return $this->data[ $id ]['url']; } } function getnews_security() { $sql = "SELECT * FROM security_news WHERE 1 ORDER BY time_stamp LIMIT 7"; $result = mysql_query($sql); $news_block = ''; if ( $result && mysql_num_rows( $result )>0 ) { while( $row=mysql_fetch_array( $result )) { $news_block = $news_block.''.$row['title']."

"; } } $news_block = $news_block.""; return $news_block; } function getnews_field() { $sql = "SELECT * FROM field_news WHERE 1 ORDER BY time_stamp LIMIT 6"; $result = mysql_query($sql); $news_block = ''; if ( $result && mysql_num_rows( $result )>0 ) { while( $row=mysql_fetch_array( $result )) { $news_block = $news_block.''.$row['title']."

"; } } $news_block = $news_block.""; return $news_block; } // ********************************************************************************************************************** // inc hit counter of day of specific record day of al records (d(0-6)) function inc_hitcount($id, $day) { $id = mysql_real_escape_string( $id ); $sql = "UPDATE items SET d".$day."=d".$day."+1 WHERE id = ".$id; $result = mysql_query($sql); } // ********************************************************************************************************************** // display top 5 records function disp_top5() { $sql = "SELECT * FROM items WHERE id < 1000"; $result = mysql_query($sql); echo mysql_error().'
'; $count = 0; if ( $result && mysql_num_rows( $result )>0 ) { while( $row=mysql_fetch_array( $result )) { $hits[$count]['hits'] = $row['d0']+$row['d1']+$row['d2']+$row['d3']+$row['d4']+$row['d5']+$row['d6']; $hits[$count]['id'] = $row['id']; $count++; } $top5array['0']['value']=0; $top5array['1']['value']=0; $top5array['2']['value']=0; $top5array['3']['value']=0; $top5array['4']['value']=0; $top5count=0; while ($top5count != 5) { for ($i = 0; $i < $count; $i++) { if ($top5array[$top5count]['value'] <= $hits[$i]['hits']) { $top5array[$top5count]['value'] = $hits[$i]['hits']; $top5array[$top5count]['id'] = $hits[$i]['id']; $temp = $i; } } $hits[$temp]['hits'] = -1; $top5count++; } $top5count=0; $text = ''; while ($top5count != 5) { $sql = "SELECT * FROM items WHERE id =".$top5array[$top5count]['id']; $result=mysql_query( $sql ); $row=mysql_fetch_array( $result ); $output=strip_tags($row['content']); $string2=wordwrap( $output, 100, '[%%]' ); $string3=substr( $string2, 0, strpos( $string2, '[%%]' )); $text = $text.' '.$row['item_title'].' '.$string3.'
more....'; $top5count++; } } return $text; } // ***************************************************************************************************************** // ***************************************************************************************************************** // main $action=$_REQUEST['action']; if ($action == 'disp' ) // 301 Moved Permanently { $nr= mysql_real_escape_string( $_REQUEST['nr'] ); $item = new getItem( $nr ); $url = '/'.$nr.'/'.$item->getUrl().'.html'; header(".html/1.0 301 Moved Permanently"); header( "Location: ".$url ); die(); } if ( $_REQUEST['html']=="true" ) { $parts=explode( "/", $_REQUEST['uri']); $itemid = $parts[0]; } else { if ($action != 'disp' ) { $itemid = 1000; } } $itemid = mysql_real_escape_string( $itemid ); $item = new getItem( $itemid ); $position = $item->getPosition(); $parent = $item->getParent(); $menu = new getMenu(); $menuitems = $menu->getMenuItems(); $count = 0; $menu_field = ''; while ( $count < ($menuitems) ) { $menupos = $count+1; // to determine if position is in main or sub menu (parent = 0 -> main menu if ( ( (($parent==0)) and ($count==($position-1) ) ) or ( ($parent!=0) and ($count==$parent-1) ) ) { // Selected main menu option $menu_field = $menu_field.' '; // if item is main menu item use position to get sub menu else use parent to get sub menu if ( $parent==0 ) { $submenu = new getSubMenu( $position ); } else { $submenu = new getSubMenu( $parent ); } $submenuitems = $submenu->getMenuItems(); $count2 = 0; if ($submenuitems>-1) { while ( $count2 <= $submenuitems) { if ( $count2==($position-1) ) { // selected submenu item $menu_field = $menu_field.' '; } else { // unselected submenu item $menu_field = $menu_field.' '; } $count2++; } } } else { // unselected main menu item $menu_field = $menu_field.' '; } if ($count==0)// place google links only first cycle { $menu_field = $menu_field.''; } $count++; } $menu_field = $menu_field.'
 
 
 
'.$googlelinks.'
 
'; $title = $item->getItemTitle(); if(is_numeric($parts[0]) || $itemid == 1000 ) { // ***************************************************************************************** // reset view counter for actual day for all FAQ records $sql = "SELECT * FROM settings WHERE 1"; $result=mysql_query( $sql ); $row=mysql_fetch_array( $result ); $actual_date = date( "Y")."-".date( "m")."-".date( "d"); $day = date("w"); if ( $row["last_reset"] != $actual_date) { $sql = "UPDATE items SET d".$day."='' where 1"; $result = mysql_query($sql); $sql = "UPDATE settings SET last_reset='".$actual_date."' where 1"; $result = mysql_query($sql); echo 'day: '.$day.'status: '.$result; } // ***************************************************************************************** inc_hitcount($parts[0], $day); // Main field $main_field = ' '; if ( $itemid == 1000 ) { $main_field = $main_field.disp_top5(); } $main_field = $main_field.'

'.$item->getItemTitle().'

'.$item->getContent().'
'; $keywords = $item->getKeywords(); } else { switch ($parts[1]) { case 'vulnerabilities': $sql = "SELECT * FROM security_news WHERE 1 ORDER BY time_stamp"; $result=mysql_query( $sql ); $text = ''; if ( $result && mysql_num_rows( $result )>0 ) { while( $row=mysql_fetch_array( $result )) { $text = $text.' '; } } $text = $text.'
'.$row['title'].'
'.$row['description'].'...
 
source: Cisco Systems, Inc.
'; $main_field = $text; $keywords = 'vulnerabilities, security, news'; break; case 'field_notices': $sql = "SELECT * FROM field_news WHERE 1 ORDER BY time_stamp"; $result=mysql_query( $sql ); $text = ''; if ( $result && mysql_num_rows( $result )>0 ) { while( $row=mysql_fetch_array( $result )) { $text = $text.' '; } } $text = $text.'
'.$row['title'].'
'.$row['description'].'...
 
source: Cisco Systems, Inc.
'; $main_field = $text; $keywords = 'field notices, news'; break; } } // News field $news_security = getnews_security(); $news_field = getnews_field(); // close database mysql_close($connection); include("layout.php");