hp require_once 'db.mysql.class.php'; $garrayTopics = array(); define("DBCOMMON", "termpapers9"); define("DBLCOMMON", "add_links"); define ( 'SITE_ACADEMONXML', 'http://www.xmlen.academon.com' ); define ( 'SITE_ACADEMONXML_SOURCE', 'http://www.xmlse.academon.com' ); define ( 'SITE_ACADEMONXML_CH', 'http://www.xmlce.academon.com' ); function getDB($cdconnect){ # ------------------------------------------------------------------------- # - get db name from common termpapers db $oDB = & new db_mysql('', '', '', $cdconnect); return $oDB; } function getGroup($cdomain){ # ------------------------------------------------------------------------- # - get db name from common termpapers db $db = getDB(DBCOMMON); $grow = ''; $sql = "Select * from domains_group tg, termpapers_sites ts, termpapers_groups tsg where tg.siteID = ts.siteID and tsg.groupID = tg.groupID and ts.siteName = '". $cdomain. "'"; $users = $db->query($sql) or RedirectToPageNotFound(); while ($row=$db->fetch_array($users)) { $grow =$row['dbName']; } if ($grow==''){ RedirectToPageNotFound(); } $db->close(); return $grow; } function get_tcount($table_name, $db, $dbTable, $where_clause){ # ------------------------------------------------------------------------- # - read data from db $i = 0; $gTopics = array(); $dDB = getDB(DBCOMMON); if ($where_clause==''){ $sql = "Select count(*) from ". $table_name ; } else { $sql = "Select count(*) from ".$table_name. " tn, termpapers_sites ts where tn.siteID = ts.siteID and ts.siteName = '". $where_clause. "' order by tn.".$dbTable. " ASC"; } $users = $db->query($sql) or RedirectToPageNotFound(); while ($row=$db->fetch_array($users)) { $gnumrow =$row['count(*)']; } return $gnumrow; } function read_file($files, $numSite){ # ------------------------------------------------------------------------- # - add data to db //$oDB = new linksDB; $oDB = getDB(DBCOMMON); $table_name= 'abortiontermpapers'; $sql1 = 'Select * from '. $table_name; //print $sql1; $table_name= 'a-bookreport.com'; $numfwords = $oDB->query($sql1); //print $numgwords; //$results = 0; $gTopics = file($files); //print_r($gTopics); for ($i=0; $iquery($sql1)) { //$numfwords = $oDB->query($sql1); //while( $myrow =$oDB->fetch_assoc()){ //for ($key = 0; $key < $numfwords; $key++){ //$myrow =$oDB->fetch_assoc() //print 'test'. str_replace( "'", "\'", $myrow['txtResult']); //if (str_replace( "'", "\'", $myrow['txtResult'])== ''){ //}else{ $sql = "INSERT INTO `termpapers_results` ( `numResult` , `txtResult`, `siteID` ) VALUES (NULL ,'". str_replace( "'", "\'", str_replace( '"', '\"', $gTopics[$i])). "', ". $numSite. ")"; //print $sql; $results = $oDB->query($sql); //} //} } return $results; } function read_file_links($files, $numSite){ # ------------------------------------------------------------------------- # - add data to links table //$oDB = new acdDB; $oDB = getDB(DBCOMMON); $gTopics = file($files); for ($i=0; $iquery($sql); //$results = $oDB2->execute($sql); } return $results; } function get_topics($table_name, $oDB, $dbTable, $where_clause, $gstart, $gperpage, $gincr, $gmax){ # ------------------------------------------------------------------------- # - read data from db $i = 0; $gTopics = array(); $r=0; $m = 0; $gTo = ($gstart + $gperpage)*($gincr); if ($where_clause==''){ $sql = "Select * from ". $table_name; } else { $sql = "Select * from ".$table_name. " tn, termpapers_sites ts where tn.siteID = ts.siteID and ts.siteName = '". $where_clause. "' order by tn.".$dbTable. " ASC LIMIT ". $gstart. " , ".$gTo; } $numfwords = $oDB->query($sql); if ($oDB->query($sql)) { $numfwords = $oDB->query($sql); while( $myrow =$oDB->fetch_array($numfwords)){ if (strlen($myrow[$dbTable])!=1){ $r = $m % ($gincr); if ($r == 0) { $gTopics[$i] = $myrow[$dbTable]; $i = $i + 1; } } $m = $m+1; } } return $gTopics; } ///////////////////////////////////////////////// ////error handling //error_reporting(0); ////user defined error handling function /*function userErrorHandler($errno, $errmsg, $filename, $linenum, $vars){ # ------------------------------------------------------------------------- # - error traping $dt = date("Y-m-d H:i:s (T)"); $errortype = array( E_ERROR => 'Error', E_WARNING => 'Warning', E_PARS => 'Parsing Error', E_NOTICE => 'Notice', E_CORE_ERROR => 'Core Error', E_CORE_WARNING => 'Core Warning', E_COMPILE_ERROR => 'Compile Error', E_COMPILE_WARNING => 'Compile Warning', E_USER_ERROR => 'User Error', E_USER_WARNING => 'User Warning', E_USER_NOTICE => 'User Notice', E_STRICT => 'Runtime Notice', E_RECOVERABLE_ERROR => 'Catchable Fatal Error' ); $user_errors = array(E_USER-ERROR, E_USER_WARNING, E_USER_NOTICE); $err = "\n"; $err .= "\t". $dt . "\n"; $err .= "\t". $errno . "\n"; $err .= "\t". $errortype[$errno] . "\n"; $err .= "\t". $errmsg . "\n"; $err .= "\t". $filename . "\n"; $err .= "\t". $linenum . "\n"; if (in_array($errno, $user_errors)){ $err .= "\t". wddx_serialize_value($vars, 'Variables') . "\n"; } $err .= "\n\n"; echo $err; error_log($err, 3, "C:/Server/xampp/htdocs/docs/dev.abortiontermpapers/logs/error.log"); if ($errno == E_USER_ERROR) { //mail ("test@example.com", "Critical User Error", $err); } } $old_error_handler = set_error_handler("userErrorHandler");*/ //////////////////////////////////////////////////////////////////////////////////////////////// function to_dash($sz){ # ------------------------------------------------------------------------- # - Replace $sz = preg_replace( '/\W+/', '-', strtolower(trim($sz)) ); //$sz = preg_replace( '/\[^a-zA-Z0-9]+/', '-', $sz ); return $sz; } function clean_text($sz) { # ------------------------------------------------------------------------- # - Replace $sz = strtolower(str_replace( '"', '', $sz )); $sz = strtolower(str_replace( '�', '', $sz )); $sz = strtolower(str_replace( '�', '', $sz )); $sz = strtolower(str_replace( ':', '', $sz )); $sz = strtolower(str_replace( ' ', '-', $sz )); $sz = strtolower(str_replace( "�", '-', $sz )); $sz = strtolower(str_replace( "'", '-', $sz )); $sz = strtolower(str_replace( ",", ' ', $sz )); $sz = strtolower(str_replace( "/", '-', $sz )); $sz = strtolower(str_replace( ".", '-', $sz )); $sz = strtolower(str_replace( "&", '-', $sz )); $sz = strtolower(str_replace( "?", '', $sz )); $sz = strtolower(str_replace( ";", '', $sz )); return $sz; } function _getPaperTerm ($szKeyTitle, $tlString){ # ------------------------------------------------------------------------- # - print text return $tlString; } function printLinks($linksFile, $lcount, $llength) { # ------------------------------------------------------------------------- # - Read from DB appropriate table with links and print it rendomly $head_expl = explode( ".",$_SERVER["HTTP_HOST"]); $cdomain = $head_expl[1].'.'.$head_expl[2]; //$oDB = getDB(getGroup($cdomain)); $oDBcom = getDB(DBCOMMON); $gpermLinks = array(); $garrayLinks = array(); $strReturn = ''; $sql = "Select * from permanent_links" ; if ($oDBcom->query($sql)) { $numfwords = $oDBcom->query($sql); while( $myrow =$oDBcom->fetch_array($numfwords)){ $strReturn .= ''.$myrow['txtLinks'].'
'; } } $sqlp = "Select * from termpapers_links_permanent" ; if ($oDBcom->query($sqlp)) { $numfwordsp = $oDBcom->query($sqlp); $i = 0; while( $myrowp =$oDBcom->fetch_array($numfwordsp)){ $garrayLinks[$i][0]= $myrowp['txtLinks']; $garrayLinks[$i][1]= $myrowp['linkurl']; $i = $i + 1; } } //$garrayLinks = get_topics("termpapers_links_permanent", $oDBcom, 'txtLinks', $linksFile, 1, 100,1,$lcount); //print_r($garrayLinks); shuffle($garrayLinks); $subject = ''; $pos = 0; $linksPrint = ''; $linksURL = ''; //add one array to another //$result = array_merge_recursive($gpermLinks, $garrayLinks); $result = $garrayLinks; $strReturn .= '
'; for ($key = 0; $key < $lcount ; $key++){ $subject = $result[$key][0]; $pos = strpos($subject, '.'); $linksPrint = substr( $subject, 0, $pos); //$chars[0]; $strURL_length = check_len_links($subject, 15); //if ($strURL_length == ''){ $linksPrint = $subject; //} else{ //$linksPrint = substr( $subject, 0, $llength); ////$linksPrint = $linksPrint. '...'; //} $linksURL = $result[$key][1]; //$chars[1]; $strReturn .= ''.$linksPrint.'
'; } $strReturn .= '
'; $oDBcom->close(); return $strReturn; }function _getTitle($strT, $pcount, $titleN){ # ------------------------------------------------------------------------- # - Print titles $strReturn = str_replace( 'var1', $pcount, $strT ); $strReturn = str_replace( 'var2', $titleN, $strReturn ); $strReturn = preg_replace('/\s\s+/', ' ', trim($strReturn)); return $strReturn; } function _getItems($gaTopics, $pNum, $cFound, $rPerPage, $gdomain, $gincr){ # ------------------------------------------------------------------------- # - Print items //$oDB = new acdDB(); $oDB = getDB(getGroup($gdomain)); $arrayItems = array(); $topicsPagefrom = 0; //$gaTopics; //$pNum*$rPerPage; $topicsPageto = 0; //$gaTopics + $rPerPage; //($pNum+1)*$rPerPage; $strMatch = ''; $strItems = ''; $subject = ''; $pattern = ''; $garrayTopicsPrint = ''; $arrayItems = get_topics('termpapers_results', $oDB, 'txtResult', $gdomain, $gaTopics, $rPerPage, $gincr, $cFound); for ($key = 0; $key < $rPerPage; $key++){ $subject = $arrayItems[$key]; $pattern = '/^'.$strMatch. '$/'; $garrayTopicsPrint=trim(ucwords($arrayItems[$key])); //if (preg_match($pattern, $subject, $matches, PREG_OFFSET_CAPTURE)){ //$printkey = $printkey + 1; //} else { if (($key == count($arrayItems)-1) && (!$key == ($topicsPageto-1))){ $printkey = $printkey + 1; } else { $printkey = 0; } //} $garrayTopicsPrintA = strtolower(str_replace( '"', '', $arrayItems[$key] )); $garrayTopicsPrintA = to_dash(clean_text( $garrayTopicsPrintA )); if (($printkey == 0) || ($printkey == $topicsPageto-1)){ $strItems .= ''.$garrayTopicsPrint.'
'; } else { $strItems .= ''.$garrayTopicsPrint.'
'; } $strMatch = $arrayItems[$key]; } $oDB->close(); return $strItems; } function _getNext($cFound, $rPerPage, $pageN, $pageCat){ # ------------------------------------------------------------------------- # $maxPage = $cFound/$rPerPage; $strNext = ''; $page = 0; $prev = ''; $navPage = ''; $pself = ''; $nself = ''; if (!isset($pageN)) { $pageN = 1; $self= $rPage; } else { $self= ($pageN *$rPerPage); } if ($pageN > 0){ $page = $pageN - 1; $self= ($page * $rPerPage); $prev = ' <<[Prev] '; $nself = $page; $self= ($page); } else{ $prev = ' '; // we're on page one, don't print previous link $nself = ''; } if (($pageN < $maxPage-1)&&($pageN > 0)){ $page = $pageN + 1; $self = $page *$rPerPage; $next = '[Next]>> '; } else{ $next = ' '; // we're on the last page, don't print next link } for ($key = 0; $key < $maxPage; $key++){ if ($key == ($pageN)){ $navPage= $navPage. ''. ($key +1).' '; } else { $pself = $key *$rPerPage; if ($pageCat!=''){ $pself = 'cat/'.$pageCat.'/'.($key *$rPerPage); } $navPage= $navPage. ''. ($key +1).' '; } } $strNext .= $prev . $navPage. $next. "

"; return $strNext; } function _getMorePapers($gaTopics, $mpaper){ # ------------------------------------------------------------------------- # - Print papers that can match any word from current papper name //$oDB = new acdDB(); //$numDB = new acdDB(); $head_expl = explode( ".",$_SERVER["HTTP_HOST"]); $cdomain = $head_expl[1].'.'.$head_expl[2]; $oDB = getDB(getGroup($cdomain)); //$numDB = getDB(getGroup($cdomain)); $ga_site_name = ''; $ga_topic_rendom=array(); $sql = "select * from termpapers_sites"; if ($oDB->query($sql)) { $numfwords = $oDB->query($sql); while( $myrow =$oDB->fetch_array($numfwords)){ $tables[]= $myrow['siteName']; } } $i=0; $pos1 = strpos($gaTopics, '.'); $gaTopics = substr($gaTopics, 0, $pos1); //print($gaTopics); shuffle($tables); for ($key = 0; $key < $mpaper; $key++){ if ($tables[$key]!= $gaTopics){ $sql = "select * from termpapers_results tr, termpapers_sites ts where tr.siteID=ts.siteID and ts.siteName = '". $tables[$key]. "'"; if ($oDB->query($sql)) { $numfwords = $oDB->query($sql); while( $myrow =$oDB->fetch_array($numfwords)){ $ga_topic_rendom[]= $myrow['txtResult']; $ga_site_name= $myrow['siteName']; } } $num = Rand (1,count($ga_topic_rendom)); $garrayTopicsPrint = ''; $garrayTopicsPrintA = ''; if (!preg_match('/([A-Za-z0-9]+\.)+/i',$ga_site_name)){ $ga_site_name = $ga_site_name. '.com'; //only for now hardcoding }else{ $ga_site_name = $ga_site_name; } $garrayTopicsPrint=$ga_topic_rendom[$num]; //$myrow['txtResult']; $garrayTopicsPrintA = strtolower(str_replace( '"', '', $garrayTopicsPrint )); $garrayTopicsPrintA = clean_text( $garrayTopicsPrintA ); $strMore .= ''.ucwords($garrayTopicsPrint).'
'; } // $oDB->query($sql) } //for $oDB->close(); return $strMore; } function _getCategories($gaDomain, $strAdd){ # ------------------------------------------------------------------------- # - For each site take Categories //$oDB = new acdDB(); $oDB = getDB(getGroup($gaDomain)); $sql = "select * from site_categories tr, categories tc, termpapers_sites ts where tr.categoriesID=tc.categoriesID and tr.siteID=ts.siteID and ts.siteName = '". $gaDomain. "'"; if ($oDB->query($sql)) { $numfwords = $oDB->query($sql); while( $myrow =$oDB->fetch_array($numfwords)){ $strCateg .= $strAdd. ''.ucwords($myrow['categoriesName']).'
'; } // while } //if $oDB->close(); return $strCateg; } function _getTemplate($gaDomainName){ # ------------------------------------------------------------------------- # - For each site take Template $name = getGroup($gaDomainName); $db = getDB($name); $grow = ''; $sql = "SELECT * FROM termpapers_templates tt, site_templates st, termpapers_sites ts WHERE tt.templateID = st.templateID AND ts.siteID = st.siteID AND ts.siteName = '$gaDomainName'"; //print $sql; $users = $db->query($sql) or RedirectToPageNotFound(); while ($row=$db->fetch_array($users)) { $strTemplate =$row['templateName']; } if ($strTemplate==''){ RedirectToPageNotFound(); } $db->close(); return $strTemplate; } /** * Redirect to another page (code 302) * Clean buffer and send Location header * Duplicate with JavaScript in the case headers did not work * @param string $Url Redirect URL * @return bool True always * @access public */ function Redirect( $Url='/', $DebugIfDevelopment=true ) { # --------------------------------------------------------------------------- if ( !preg_match( '/^https?:/', $Url ) ) { $Url = 'http://' . $_SERVER["HTTP_HOST"] . $Url; } if ( !headers_sent() ) { while (@ob_end_clean()); header( 'Location: ' . $Url ); header( 'Content-Type: text/plain' ); header( 'Connection: close' ); } else { } exit(); return true; } /** * Shortcut: redirect to 404 page * @return bool From Redirect * @access public */ function RedirectToPageNotFound() { # --------------------------------------------------------------------------- return Redirect( 'http://' . $_SERVER["HTTP_HOST"] . '/page-not-found.htm' ); } /** * Shortcut: redirect to error * @return bool From Redirect * @access public */ function RedirectToErrorPage() { # --------------------------------------------------------------------------- return Redirect( 'http://' . $_SERVER["HTTP_HOST"] . '/internal_error.htm' ); } function TriggerError( $Msg = '', $error_type = E_USER_WARNING ) { # --------------------------------------------------------------------------- #trigger_error( $Msg, $error_type ); #trigger_error( $Msg . "\n" . print_r( debug_backtrace(), true), $error_type ); $hBackTrace = debug_backtrace(); error_log( 'Termpaper|' . $Msg . '|' . serialize( $hBackTrace ) ); return true; } function read_cat($numCat){ # ------------------------------------------------------------------------- # - add data to links table //$oDB = new acdDB(); $head_expl = explode( ".",$_SERVER["HTTP_HOST"]); $cdomain = $head_expl[1].'.'.$head_expl[2]; $oDB = getDB(getGroup($cdomain)); $sql = "Select * from categories where categoriesID = ". $numCat; if ($oDB->query($sql)) { $numfwords = $oDB->query($sql); while( $myrow =$oDB->fetch_array($numfwords)){ $results = $myrow['categoriesName']; } // while } //if $oDB->close(); return $results; } function getLGroup($cdomain){ # ------------------------------------------------------------------------- # - get db name from common termpapers db $db = getDB(DBLCOMMON); $grow = ''; $sql = "Select * from domains_group tg, termpapers_sites ts, termpapers_groups tsg where tg.siteID = ts.siteID and tsg.groupID = tg.groupID and ts.siteName = '". $cdomain. "'"; $users = $db->query($sql) or RedirectToPageNotFound(); while ($row=$db->fetch_array($users)) { $grow =$row['dbName']; } if ($grow==''){ RedirectToPageNotFound(); } $db->close(); return $grow; } function check_len_links($strRecord, $int_length){ # ------------------------------------------------------------------------- # - check for length of the string $flat1 = ''; if (strlen($strRecord) > $int_length) { $flat1 = substr($strRecord, 0, strlen($strlen2)/2). ' ...'; } return $flat1; } function check_len($strRecord){ # ------------------------------------------------------------------------- # - check for length of the string $array2 = explode( " ",$strRecord); //print_r($array1); $flat1 = ""; foreach ($array2 as $strlen2) { //print $strlen2; if (strlen($strlen2) > 50) { $strlen_walk2 = substr($strlen2, 0, strlen($strlen2)/2). ' '. substr($strlen2, strlen($strlen2)/2 ); $flat1 = $flat1. " ". $strlen_walk2; print $flat1; } else { $flat1 = $flat1. " ". $strlen2; } } return $flat1; } function readFileInAcademon($strText){ # ------------------------------------------------------------------------- # - read from Academon site $strText = str_replace( '_', '-', $strText ); $strText = str_replace( ' ', '-', $strText ); $strText = strtolower($strText); $head_expl = explode( ".",urlencode($_SERVER["HTTP_HOST"])); $strDomain = $head_expl[1].'.'.$head_expl[2]; //$request = 'http://www.academonxml.tiv.net/ch/search_php_eval.php?keyw='. $strText ; $request = SITE_ACADEMONXML_CH. '/php/pagegen.php?ip='. urlencode($_SERVER['REMOTE_ADDR']).'&domain='.$strDomain.'&uagent=' . urlencode($_SERVER['HTTP_USER_AGENT']) . '&t=search_php_eval&q='. urlencode($strText) ; $cache_fullpath = 'xml/academonxml'.$strText.'.php'; $cache_timeout = 7200; $hAcdSearch = request_cache($request, $cache_fullpath, $cache_timeout); $hAcdSearch = @unserialize($hAcdSearch); return $hAcdSearch; } function readFileIn($strText){ # ------------------------------------------------------------------------- # - read from term-paper site $strText = str_replace( '_', '-', $strText ); $strText = str_replace( ' ', '-', $strText ); $strText = strtolower($strText); $head_expl = explode( ".",$_SERVER["HTTP_HOST"]); $strDomain = $head_expl[1].'.'.$head_expl[2]; $request = SITE_ACADEMONXML_SOURCE. '/php/pagegen.php?ip='. urlencode($_SERVER['REMOTE_ADDR']).'&domain='.$strDomain.'&uagent=' . urlencode($_SERVER['HTTP_USER_AGENT']) . '&t=search_php_eval&q='. urlencode($strText) ; $cache_fullpath = 'xmlterm/academonxml'.$strText.'.php'; $cache_timeout = 7200; $hAcdSearch = request_cache($request, $cache_fullpath, $cache_timeout); $hAcdSearch = @unserialize($hAcdSearch); return $hAcdSearch; } function readFiletoXML($strText){ # ------------------------------------------------------------------------- # - read from Academon $strText = str_replace( '_', '-', $strText ); $strText = str_replace( ' ', '-', $strText ); $strText = strtolower($strText); $head_expl = explode( ".",$_SERVER["HTTP_HOST"]); $strDomain = $head_expl[1].'.'.$head_expl[2]; $request = SITE_ACADEMONXML. '/php/pagegen.php?ip='. urlencode($_SERVER['REMOTE_ADDR']).'&domain='.$strDomain.'&uagent=' . urlencode($_SERVER['HTTP_USER_AGENT']) . '&t=search_php_eval&q='. urlencode($strText) ; $cache_fullpath = 'xmltv/academonxml'.$strText.'.php'; $cache_timeout = 7200; $hAcdSearch = request_cache($request, $cache_fullpath, $cache_timeout); $hAcdSearch = @unserialize($hAcdSearch); return $hAcdSearch; } function request_cache($url, $dest_file, $timeout) { if (!file_exists($dest_file) || filemtime($dest_file) < (time()-$timeout)) { $ch = curl_init(); $timeout = 5; // set to zero for no timeout curl_setopt ($ch, CURLOPT_URL, $url); curl_setopt ($ch, CURLOPT_RETURNTRANSFER, 1); curl_setopt ($ch, CURLOPT_CONNECTTIMEOUT, $timeout); $data = curl_exec($ch); curl_close($ch); //$fp = fopen($dest_file,"w"); //fwrite($fp, $data); //fclose($fp); return $data; } else { $fh = fopen($dest_file, 'r'); $theData = fread($fh, filesize($dest_file)); fclose($fh); return $theData; } } function buildstrAcademon($strKey, $strSearch, $maxList, $boxWidth, $border){ # ------------------------------------------------------------------------- # - build the box of advertising $sCount = 0; $strAcademon = ''; $strAcademon .= '
'; foreach ( $strSearch as $Related ) { if ($sCount < $maxList){ $strAcademon = $strAcademon.''. $Related['ITM_TTL'] .'
'; if ( !empty( $Related['ITM_DESCR'] ) ){$strAcademon = $strAcademon. htmlspecialchars( $Related['ITM_DESCR'] ) . ' -- '; } $strAcademon =$strAcademon . ''; if ( !empty( $Related['ITM_NWRD'] ) ) { $strAcademon =$strAcademon . number_format( $Related['ITM_NWRD'] ) . ' words; '; } if ( !empty( $Related['ITM_NSRC'] ) ) { $strAcademon =$strAcademon . number_format( $Related['ITM_NSRC'] ) . ' sources; '; } if ( !empty( $Related['ITM_FORMAT'] ) ) { $strAcademon =$strAcademon . $Related['ITM_FORMAT']; } $strAcademon =$strAcademon . '
'; $strAcademon .= ' www.termpapers2000.com'; $strAcademon .= '

'; } $sCount=$sCount+1; } //foreach $strAcademon .= '
'; return $strAcademon; } function cleanRT($sz) { # ------------------------------------------------------------------------- # - Replace $sz = strtolower(str_replace( '"', ' ', $sz )); $sz = strtolower(str_replace( '”', ' ', $sz )); $sz = strtolower(str_replace( '“', ' ', $sz )); return $sz; } ?>
Fatal error: Call to undefined function getGroup() in /home/content/m/a/x/maxtermp/html/varlib.php on line 8