function setStat(){
mysql_query('INSERT INTO stat (s_hours, s_day, s_mounth, s_year, s_ip, s_host, s_uri, s_agent, s_reffer) VALUES ("'.date("H").'","'.date("d").'","'.date("m").'","'.date("Y").'","'.$_SERVER['REMOTE_ADDR'].'","'.$_SERVER['HTTP_HOST'].'","'.$_SERVER['REQUEST_URI'].'","'.$_SERVER['HTTP_USER_AGENT'].'","'.$_SERVER['HTTP_REFER'].'")') or die(mysql_error());
}
function box($header, $body, $cssFrame='cBox8', $cssHeader='cBox7', $cssBody='cBox9' ){
$box .= '
| ';
if (is_string($header)){
$box .= '';}
$box .= '
|
';
return $box;
}
class SQLQuery {
var $distinct = null;
var $columns = array();
var $tables = array();
var $where = array();
var $groupBy = array();
var $orderBy = array();
var $ascDesc = 1; // default ASC
var $limitStart = null;
var $limitEnd = null;
var $queryType = 1; // ma to sens czasami prucz selecta przydaje sie insert wpostaci tablicy
var $query;
var $queryResult;
var $dataBaseType = 1; // jeszcze nie uzywane, tylko mysql
var $errorException = 0; // sposob obsługi - jesli zapytanie wykonan sie niepporawnie przekieruj do strony
// oznaczonej jako first_page
function getResult() {
if ($this->checkQuery() == 1) {
$this->rebulidParametrs();
$this->bulidQuery();
return $this->getQueryResult();
} else {
$this->message = 'Zapytanie jest niepoprawne!';
echo $this->getMessage();
return -1;
}
}
function chechIsArrayAndCountIsNot0($array) {
if (is_array($array) && count($array) > 0) {
return 1;
} else {
return -1;
}
}
function checkQuery() {// sprawdz czy wybrano przynajmiej jedno pole i jedna tabele
if ($this->queryType == 1 ) {// jesli select
if (count($this->columns) > 0 && count($this->tables) > 0) {
return 1;
} else {
return -1;
}
} elseif($this->queryType == 2 || $this->queryType == 3) { // insert update
if (count($this->columns) == 2 && $this->chechIsArrayAndCountIsNot0($this->columns[0]) == 1 && $this->chechIsArrayAndCountIsNot0($this->columns[1]) == 1 && $this->chechIsArrayAndCountIsNot0($this->tables) == 1) {
return 1;
} else {
return -1;
}
} elseif($this->queryType == 4) { // delete
if (count($this->tables) > 0 && count($this->where) > 0) {
return 1;
} else {
return -1;
}
} else {
$this->message = 'Nie można sprawdzić składni dla tego typu zapytania';
echo $this->getMessage();
return -1;
}
}
function getVarName($parametrID)
{
if ($parametrID == 1) {
return 'columns';
} elseif ($parametrID == 2) {
return 'tables';
} elseif ($parametrID == 3) {
return 'where';
} else {
die('niezdefionowany var');
}
}
function addParametr($parametr, $parametrID)
{
$parametrName = $this->getVarName($parametrID);
if (is_array($this->$parametrName))
{
if (is_array($parametr))
{
$this->$parametrName = array_merge($this->$parametrName, $parametr);
} else {
array_push($this->$parametrName, $parametr);
}
} else {
$this->toVarName = $parametr;
}
}
function removeParametr($parametr, $parametrID) {
$parametrName = $this->getVarName($parametrID);
if (is_array($this->$parametrName)) {
if (class_exists('Ont')) {
$ont = new Ont();
$ont->array = $this->$parametrName;
$ont->findAndDestroy($parametr);
$ont->ResetKeys();
$this->$parametrName = $ont->getArray();
} else {
$this->message = 'CLASS';
echo $this->getMessage();
}
} else {
$this->$parametrName = $parametr; // podmien parametr na podany
}
}
function rebulidParametrs() {
if ($this->distinct == 1) {
$this->distinct = ' DISTINCT ';
}
if (count($this->orderBy) > 0) {
$this->orderBy = ' ORDER BY '.implode(',', $this->orderBy);
} else {
if (count($this->columns) > 1)
{
$this->orderBy = ' ORDER BY '.$this->columns[1];
} else {
$this->orderBy = null;
}
}
if (is_array($this->columns) && !is_array($this->columns[0]) ) {
$this->columns = implode(',', $this->columns );
} elseif (is_array($this->columns) && is_array($this->columns[0] ) ) {
$this->columns[1] = $this->dc($this->columns[1]);
if ($this->queryType == 2)
{
$this->columns = array(implode(',', $this->columns[0] ), implode(',', $this->columns[1]));
} else {
$newColumn = array();
for($i = 0; $i < count($this->columns[0]); $i++) {
array_push($newColumn, $this->columns[0][$i].'='.$this->columns[1][$i]);
}
$this->columns = implode(',',$newColumn);
print_r($newColumn);
unset($newColumn);
}
} else {
}
$this->tables = implode(',',$this->tables);
if (count($this->where) > 0)
{
$this->where = ' WHERE '.implode(' AND ', $this->where);
} else {
$this->where = null;
}
if (count ($this->groupBy) > 0) {
$this->orderBy = ' GROUP BY '.implode(',', $this->orderBy);
} else {
$this->groupBy = null;
}
if ($this->orderBy != null)
{
if ($this->ascDesc == 1) {
$this->ascDesc = ' ASC ';
} else {
$this->ascDesc = ' DESC ';
}
}
}
function bulidQuery() {
if ($this->queryType == 1 ) {
// . $this->groupBy. $this->orderBy . $this->ascDesc .' LIMIT '. $this->limitStart . $this->limitEnd
$this->query = 'SELECT ' .$this->distinct. $this->columns.' FROM '. $this->tables .$this->where ;
} elseif ($this->queryType == 2 ) {
$this->query = 'INSERT INTO ' . $this->tables . ' (' . $this->columns[0] . ') VALUES (' . $this->columns[1] . ')';
} elseif ($this->queryType == 3 ) {
$this->query = 'UPDATE ' . $this->tables . ' SET ' . $this->columns . ' ' . $this->where;
} else {
die('nieznany rodzaj zapytania :)');
}
}
function getQuery() {
return $this->query;
}
function printQuery() {
echo $this->query;
}
function dc($array) {
for($i = 0; $i < count($array); $i++) {
$array[$i] = '\''.$array[$i].'\'';
}
return $array;
}
// funkcja nie bazuje na zadnych polach
function getQueryResult()
{
$result = mysql_query($this->query) or die(mysql_error().''.$this->query);
$array = array();
while($row=mysql_fetch_row($result))
{
array_push($array, $row);
}
return $array;
}
}
class Ont
{
var $array;
function findAndDestroy($element) {
$i = array_search($element, $this->array);
if (is_numeric($i)) {
unset($this->array[$i]);
} else {
return -1;
}
}
function ResetKeys() {
$new_array = array();
$i = 0;
while (list($key, $val) = each($this->array)) {
$new_array[$i++] = $val;
}
$this->array = $new_array;
}
function getArray()
{
return $this->array;
}
}
function getMonthByDay($day,$months){
$d = explode('_',$day);
//print_r($);
for($i=0;$inewSource = $this->source;
foreach ($this->replacedArray as $key => $value) {
$this->newSource = eregi_replace($key, $value, $this->newSource);
// newSource = jesli operacja wykonywana jest w petli konieczne jedst
// stworzenie w tej klasie nowej zmiennnej, poniewaz $source jest nadpisywane :/
}
}
function getSource() {
return $this->newSource;
}
}
function n2n($n1, $n2){
$n2++;
if ($n1 > $n2){
for($i=1; $i<$n2; $i++){
if($i != 1){
$n .=',';}
$n .= $i; }
$n .=',';
$n2 = 365;}
for($i=$n1; $i<$n2; $i++){
if ($i != $n1){
$n .=',';}
$n.=$i;}
return $n;}
function chr4sqlQuery($string){
$chr = array(
array('ł', '%'),
array('Ł','%'),
array('ś','%'),
array('Ś','%'),
array('Ę','%'),
array('ę','%'),
array('ą','%'),
array('Ę','%'),
array('ć','%'),
array('Ć','%'),
array('ń','%'),
array('Ń','%'),
array('ż','%'),
array('Ż','%'),
//array('?', '_'),
);
for($i = 0; $i < count($chr); $i++)
{
$string = ereg_replace($chr[$i][0], $chr[$i][1], $string);
}
return strtolower($string);
}
function DelPolishChr($string){
$chr = array(
array(' ', '_'),
array(',',''),
array('±','a'),
array('ˇ','a'),
array('ę','e'),
array('Ę','e'),
array('¶','s'),
array('¦','s'),
array('ć','c'),
array('Ć','c'),
array('ń','n'),
array('Ń','n'),
array('ż','z'),
array('Ż','z'),
array('Ľ','z'),
array('¬','z'),
array('ł','l'),
array('Ł','l'),
array('ó','o'),
array('Ó','o'),
array('!', ''),
array('"','')
//array('?', '_'),
);
for($i = 0; $i < count($chr); $i++)
{
$string = ereg_replace($chr[$i][0], $chr[$i][1], $string);
}
return strtolower($string);
}
function getProjects($projectID){
if($projectID != '' && $projectID != null && is_numeric($projectID)) {
$where = 'WHERE p_id='.$projectID;
} else {
$where = 'LIMIT 1';
}
return SQL2array('SELECT p_id, p_name, p_title, p_descryption, p_keywords,p_url FROM fenix_project '.$where);
}
function SQL2array($query) {
$result=mysql_query($query);
if (!$result ){
echo $query .' '. mysql_error();}
$array = array();
while($row=mysql_fetch_row($result)){
for($i=0;$i',ereg_replace('„','"',win2iso($row[$i])));
}
array_push($array, $row);}
return $array;
}
function iso2win($string){
return strtr($string, "\xA1\xA6\xAC\xB1\xB6\xBC",
"\xA5\x8C\x8F\xB9\x9C\x9F");
}
function win2iso($string){
return strtr($string, "\xA5\x8C\x8F\xB9\x9C\x9F",
"\xA1\xA6\xAC\xB1\xB6\xBC");
}
function getRandElement($array){
$array_r = array_rand($array);
return $array[$array_r];
}
function getUrlSource($url){
$source = @implode(null,@file($url));
// echo $source;
if($source) {
return $source;
} else {
return -1;
}
}
/* pobierz zmodyfikowane zrodlo wynikow wyszukania */
function getModUrlSource($url){
// echo tagMOD(getUrlSource($url));
return tagMOD(getUrlSource($url));
}
function tagMOD($source) {
/* usun bold slow kluczowych w wynikach wyszukania */
if(!strpos($source, 'http://www.altavista.com/'))
{
$source = ereg_replace('', '', $source); // Yahoo
}
$source = strip_tags($source, '');
$source = ereg_replace('','',$source);
$source = ereg_replace('', '', $source);
$source = ereg_replace('URL: ', '', $source); // Szukacz
//echo $source;
/*ujednolicenie tagow zawierajacych url'e */
//$source = ereg_replace('', '', $source); // yahoo
//$source = ereg_replace('- ', '', $source); // Yahoo
//$source = ereg_replace('', '', $source);
$source = ereg_replace('');
}
function getCategory($source){
preg_match_all("/(a class=\"male\" href=\"index.php\?kat=)([^>]*)(&pod=)([^>]*)(\")/",$source, $out);
//print_r($out);
return array($out[2],$out[4]);
}
function getUrls($url) {
preg_match_all("/(]*>)([^>]*)(<\/link>)/",getModUrlSource($url), $out);
return unsetFailUrl($out[2]);
}
function unsetFailUrl($array){
$newArray = array();
for($i=0;$isource = $rowHTML;
$parser->replacedArray = $sql[$i];
$parser->parseSource();
$resource .= $parser->getSource();
}
return $resource;
}
function sendFriend(){
if(isset($_POST['send_link'])){
if($_POST['from'] == '' || $_POST['from'] = ' '){
$_POST['from'] = 'anonim';}
if(@mail($_POST['to'], $_POST['from']. ' wysłał/a Ci wiadomość z serwisu '.$_SERVER['HTTP_HOST'],$_POST['from'].' przesyła Ci link '.$_SERVER['HTTP_HOST'].''.$_SERVER['REQUEST_URI'])){
return '';
} else {
return '