ip = getenv("HTTP_CLIENT_IP"); elseif (getenv("HTTP_X_FORWARDED_FOR") && strcasecmp(getenv("HTTP_X_FORWARDED_FOR"), "unknown")) $this->ip = getenv("HTTP_X_FORWARDED_FOR"); elseif (getenv("REMOTE_ADDR") && strcasecmp(getenv("REMOTE_ADDR"), "unknown")) $this->ip = getenv("REMOTE_ADDR"); elseif (!empty($_SERVER['REMOTE_ADDR']) && strcasecmp($_SERVER['REMOTE_ADDR'], "unknown")) $this->ip = $_SERVER['REMOTE_ADDR']; else $this->ip = "unknown"; return $this->ip; } function getbuttons($path,$aph='',$img='') { $txt="
\"VK\" \"Facebook\" \"Twitter\" \"Twitter\" \"Twitter\" \"Print\"
"; return $txt; } function getauthor($avtor,$is_photo='N'){ $query = "SELECT path,NameEng,SurNameEng,picture FROM aph_avtor WHERE avtor='$avtor'"; $result = $this->get_link()->query($query); while($row = $result->fetch_array()) { $avtor_name=$row['NameEng']." ".$row['SurNameEng']; if ($is_photo=='Y') { $text.="\"$avtor_name\""; }; $text.="$avtor_name"; } $result->close(); return $text; } function getquotes($aph,$avtor=0) { $pr_users=0; $pr=0; $query = "SELECT *,DATE_FORMAT(data,'%m/%d/%Y %T') AS date_pub FROM allmyquotes WHERE id='$aph'"; $result = $this->get_link()->query($query); while($qrow = $result->fetch_array()) { $img=""; $out=""; $quotes=trim($qrow['quotes']); $id_avtor=$qrow['avtor_aphorism']; $date=$qrow['date_pub']; $path=$qrow['path']; $path_full="http://www.allmyquotes.com/quotes/".$path.".html"; $quote=stripslashes(htmlspecialchars_decode($qrow['quotes'])); $Otexts="".stripslashes(htmlspecialchars_decode($qrow['quotes'])).""; //$buttons=$this->getbuttons($path_full,$Otexts,$img); $squery = "SELECT avtor,path,NameEng,SurNameEng,picture FROM aph_avtor WHERE avtor='$id_avtor'"; $sresult = $this->get_link()->query($squery); while($srow = $sresult->fetch_array()) { $avtor_path=$srow['path']; $avtor=$srow['avtor']; $avtor_name=$srow['NameEng']." ".$srow['SurNameEng']; $out.="\"$avtor_name\""; }; $sresult->close(); /* $squery = "SELECT * FROM allmyquotes_counter WHERE nomber='$aph'"; $sresult = $this->get_link()->query($squery); while($srow = $sresult->fetch_array()) { $visitors=$srow['pr3']; $pr3=$srow['pr3']; }; $sresult->close(); $squery = "SELECT pr_users FROM allmyquotes_vote_users WHERE id_aphorism='$aph'"; $sresult = $this->get_link()->query($squery); while($srow = $sresult->fetch_array()) { $pr_users=$srow['pr_users']; }; $sresult->close(); */ // $out ="\n$Otexts $author [".$qrow['date_pub']."] { $visitors "; // $out.=" } "; // $out.="\n
".$this->getbuttons($path_full,$quotes)."
"; $out.="$quote /$avtor_name/ [$date]"; $out.="\n
".$this->getbuttons($path_full,$quotes)."
"; $out.="More"; $out="

$out

"; }; $result->close(); return $out."

\n"; } function getquotes_unregister($aph,$avtor=0) { return $this->getquotes($aph,$avtor); } function check_forsearch_string($path) { $path=trim(mb_strtolower($path)); $path=strip_tags($path,'
'); $path=strip_tags($path,'
'); $path=strip_tags($path,''); $path=strip_tags($path,'
'); $path=strip_tags($path,'
'); $path=str_replace(""", " ", $path); $path=str_replace("'", " ", $path); $path=str_replace("`", " ", $path); $path=str_replace("-", " ", $path); $path=str_replace("(", " ", $path); $path=str_replace(")", " ", $path); $path=str_replace("\'", " ", $path); $path=str_replace(";", " ", $path); $path=str_replace(":", " ", $path); $path=str_replace("{", " ", $path); $path=str_replace("}", " ", $path); $path=str_replace("?", " ", $path); $path=str_replace(":", " ", $path); $path=str_replace(",", " ", $path); $path=str_replace("[", " ", $path); $path=str_replace("\\", " ", $path); $path=str_replace("]", " ", $path); $path=str_replace("\"", "", $path); $path=str_replace("'", "", $path); $path=preg_replace('/[^À-ßà-ÿa-zA-Z0-9 -]/', '', $path); $path = preg_replace('/\s\s+/', ' ',$path); return $path; } function path_to_dir($path) { $path=str_replace(" ", "-", $path); $path=str_replace("(", "", $path); $path=str_replace(")", "", $path); $path=str_replace("\'", "", $path); $path=str_replace(";", "", $path); $path=str_replace(":", "", $path); $path=str_replace("{", "", $path); $path=str_replace("}", "", $path); $path=str_replace("?", "", $path); $path=str_replace(":", "", $path); $path=str_replace(",", "", $path); $path=str_replace("[", "", $path); $path=str_replace("\\", "", $path); $path=str_replace("]", "", $path); $path=str_replace("?", "", $path); $path=str_replace("\"", "", $path); $path=trim(strtolower($path)); $RemoveChars = array( "([\40])" , "([^a-zA-Z0-9-])", "(-{2,})" ); return preg_replace($RemoveChars, $ReplaceWith, $path); } function getpathforaphorism($base='aphorism',$len=10) { $path = ""; $yes = ""; echo $len; for ($i=0;$i<10;$i++) { $path=$this->GetRandomString($len); $aSQL = "SELECT path FROM $base WHERE path='$path' LIMIT 1"; $aQResult = mysql_query($aSQL); if (mysql_error()) { print(mysql_error()); } while ($arow = mysql_fetch_array($aQResult)): $yes = $arow['path']; endwhile; if (empty($yes) == true) { break; } if (empty($yes) <> true) { $path=$this->GetRandomString($len); $yes=""; } }; return $path; } // RANDOM KEY GENERATOR function GetRandomString($length) { //$keychars = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789"; $keychars = "abcdefghijklmnopqrstuvwxyz0123456789"; $randkey = ""; $max=strlen($keychars)-1; for ($i=0;$i<$length;$i++) { $randkey .= substr($keychars, rand(0, $max), 1); } return $randkey; } function check_search_string($name) { $name_test=htmlspecialchars(strip_tags(addslashes(trim($name)))); // $name_test=str_replace("_", "", $name_test); $name_test=str_replace("\"", "\'", $name_test); $name_test=str_replace("<", "", $name_test); $name_test=str_replace(">", "", $name_test); $name_test=str_replace("information_schema", "", $name_test); $name_test=str_replace("tables", "", $name_test); $name_test=str_replace("select", "", $name_test); $name_test=str_replace("update", "", $name_test); $name_test=str_replace("insert", "", $name_test); $name_test=str_replace("SELECT", "", $name_test); $name_test=str_replace("http", "", $name_test); $name_test=str_replace("%", "", $name_test); // $name_test=str_ireplace("%","", $name_test); return $name_test; } } ?>