jablonka.czprosek.czf

is

Subversion Repositories:
[/] [trunk/] [html/] [fce.php] - Rev 8 Go to most recent revision

Compare with Previous - Blame - Download


<?
include ("config.php");

function datum2sql ($datum) {
$vara = explode(".",$datum);
return $vara[2]."-".$vara[1]."-".$vara[0];
}

function sql2datum ($datum) {
$vara = explode("-",$datum);
return @$vara[2].".".@$vara[1].".".@$vara[0];
}

function logging ($message) {

#$islogdir="/home/demois/html/logs/";
include ("config.php");
$myFile = $islogdir."/db.log";
$fh = fopen($myFile, 'a') or die("Can't open file $myFile");
$stringData = date("d.m.Y H:i:s ").$_SERVER['PHP_AUTH_USER']." ".$_SERVER["REMOTE_ADDR"]." ".$_SERVER["SCRIPT_FILENAME"]." ";
fwrite($fh, $stringData);
$stringData = "$message\n";
fwrite($fh, $stringData);
fclose($fh);

return "OK";
}

function fid_to_name ($flat, $flatid) {
$name=MySQL_Query("SELECT name  FROM allusers WHERE flat='$flat' AND flatid='$flatid'");
$name=MySQL_Fetch_Array($name);
return $name["name"];
}

function get_transactions ($fp) {
 if ($fp) {
    $message="";
    while (($s =fgets($fp))) {
      $message=$message.$s;
    }
    fclose($fp);
  }
#useknuti zacatku
  $message=stristr($message, "<TABLE BORDER=\"1\" CELLPADDING=\"2\" CELLSPACING=\"0\" WIDTH=\"100%\" BGCOLOR=\"#FFFFFF\">");
  $message=stristr($message, "</tr>");
  $message=stristr($message, "<tr>");
#useknuti konce
  $konec=strpos($message,"<TD ALIGN=\"center\" VALIGN=\"TOP\" COLSPAN=\"5\">");
  $message=substr($message,0,$konec-5);

return $message;
}

function id_to_flat ($id) {
$name=MySQL_Query("SELECT flat FROM allusers WHERE id='$id'");
$name=MySQL_Fetch_Array($name);
return $name["flat"];
}

function id_to_vs ($id) {
$name=MySQL_Query("SELECT vs FROM cleni WHERE id='$id'");
$name=MySQL_Fetch_Array($name);
return $name["vs"];
}

function id_to_name ($id) {
$name=MySQL_Query("SELECT * FROM cleni WHERE id='$id'");
$name=MySQL_Fetch_Array($name);
return $name["jmeno"]." ".$name["prijmeni"];
}

function id_to_ucet ($id) {
$ucet=MySQL_Query("SELECT * FROM finance WHERE id='$id'");
$ucet=MySQL_Fetch_Array($ucet);
return sql2datum($ucet["datum"])." ".$ucet["hodnota"]." ".substr($ucet["komentar"],0,30);
}

function id_to_type($id){
$type=MySQL_Query("SELECT type FROM poplatky WHERE id='$id'");
$type=MySQL_Fetch_Array($type);
return $type["type"];
}

function id_to_platba($id){
$type=MySQL_Query("SELECT nazev FROM platby WHERE id='$id'");
$type=MySQL_Fetch_Array($type);
return $type["nazev"];
}

function id_to_dodavatel($id){
$type=MySQL_Query("SELECT nazev FROM dodavatele WHERE id='$id'");
$type=MySQL_Fetch_Array($type);
return $type["nazev"];
}

function id_to_pokladna($id){
$type=MySQL_Query("SELECT nazev FROM pokladny WHERE id='$id'");
$type=MySQL_Fetch_Array($type);
return $type["nazev"];
}

function id_to_prenos05($id){
$type=MySQL_Query("SELECT hodnota FROM finance WHERE clen='$id' AND platba=7 AND YEAR(datum) = 2006");
$type=MySQL_Fetch_Array($type);
return $type["hodnota"];
}

function id_to_prenos06($id){
$type=MySQL_Query("SELECT hodnota FROM finance WHERE clen='$id' AND platba=7 AND YEAR(datum) = 2007");
$type=MySQL_Fetch_Array($type);
return $type["hodnota"];
}

function id_to_prenos07($id){
$type=MySQL_Query("SELECT hodnota FROM finance WHERE clen='$id' AND platba=7 AND YEAR(datum) = 2008");
$type=MySQL_Fetch_Array($type);
return $type["hodnota"];
}

function id_to_prenos($id, $rok){
$type=MySQL_Query("SELECT hodnota FROM finance WHERE clen='$id' AND platba=7 AND YEAR(datum) = '$rok'");
$type=MySQL_Fetch_Array($type);
return $type["hodnota"];
}

function id_to_sleva($id,$rok){
$type=MySQL_Query("SELECT * FROM ukony WHERE clen='$id' AND udalost IN (5,6) ORDER BY datum,udalost");
$cnt=0;
$count=MySQL_Num_Rows($type);
$od=strtotime($rok."-01-01");
$do=strtotime($rok."-12-31");
$zacatek=0;
$konec=0;
$merime=False;
$celkem=0;
while($radek=MySQL_Fetch_Array($type))
  {
    $cnt=$cnt+1;
    if (($radek["udalost"] == 5) AND ! $merime AND $radek["datum"])
    { $cnt=10;
      $merime=True;
      $zacatek=strtotime($radek["datum"]);
    }
    if (($radek["udalost"] == 6) AND  $merime AND $radek["datum"])
    { $cnt=12;
      $merime=False;
      $konec=strtotime($radek["datum"]);
      #uzavreli jsme interval a jdeme tedy zjistit jestli lezi v nasem roce
      if (($zacatek < $do) AND ($konec>$od))
      { #pokud je zacatek pred zacatkem roku tak merime od zacatku roku
        if ($zacatek<$od) $zacatek=$od;
        #pokud je konec po konci roku tak merime jen do konce roku 
        if ($konec>$do) $konec=$do;
        #a konecne ziskame rozdil a pricteme do celkove doby kdy clen napaji switch
        $celkem += $konec-$zacatek;
      }            
    }
  }
#    return (strtotime($do)-strtotime($od));
#zbyva otestovat jestli stale nemerime a pripadne vycislit dobu
#uzavreli jsme interval a jdeme tedy zjistit jestli zacatek lezi v nasem roce
      if (($zacatek < $do) AND $merime)
      { #pokud je zacatek pred zacatkem roku tak merime od zacatku roku
        if ($zacatek<$od) $zacatek=$od;
        $konec=$do;
        #a konecne ziskame rozdil a pricteme do celkove doby kdy clen napaji switch
        $celkem = $konec-$zacatek;
      }
    return $celkem;
}

function id_to_delkazarok($id,$rok,$zac,$kon){
#udalost musi byt razeny sestupne DESC aby vsechny konce v dany den byly (8) pred zacatky (7)
$type=MySQL_Query("SELECT * FROM ukony WHERE clen='$id' AND udalost IN ('$zac','$kon') ORDER BY datum ASC,udalost DESC");
$od=strtotime($rok."-01-01");
$do=strtotime($rok."-12-31");
$zacatek=0;
$konec=0;
$merime=False;
$celkem=0;
while($radek=MySQL_Fetch_Array($type))
  {
    if (($radek["udalost"] == $zac) AND ! $merime AND $radek["datum"])
    { $merime=True;
      $zacatek=strtotime($radek["datum"]);
    }
    if (($radek["udalost"] == $kon) AND  $merime AND $radek["datum"])
    { $merime=False;
      $konec=strtotime($radek["datum"]);
      #uzavreli jsme interval a jdeme tedy zjistit jestli lezi v nasem roce
      if (($zacatek < $do) AND ($konec>$od))
      { #pokud je zacatek pred zacatkem roku tak merime od zacatku roku
        if ($zacatek<$od) $zacatek=$od;
        #pokud je konec po konci roku tak merime jen do konce roku 
        if ($konec>$do) $konec=$do;
        #a konecne ziskame rozdil a pricteme do celkove doby
        $celkem += $konec-$zacatek;
      }
    }
  }
#zbyva otestovat jestli stale nemerime a pripadne vycislit dobu
#uzavreli jsme interval a jdeme tedy zjistit jestli zacatek lezi v nasem roce
      if (($zacatek < $do) AND $merime)
      { #pokud je zacatek pred zacatkem roku tak merime od zacatku roku
        if ($zacatek<$od) $zacatek=$od;
        $konec=$do;
        #a konecne ziskame rozdil a pricteme do celkove doby
        $celkem += $konec-$zacatek;
      }
    return $celkem;
}

function id_to_delkakonektivity($id,$rok){
#udalost musi byt razeny sestupne DESC aby vsechny konce v dany den byly (8) pred zacatky (7)
$type=MySQL_Query("SELECT * FROM ukony WHERE clen='$id' AND udalost IN (7,8) ORDER BY datum ASC,udalost DESC");
$od=strtotime($rok."-01-01");
$do=strtotime($rok."-12-31");
$zacatek=0;
$konec=0;
$merime=False;
$celkem=0;
while($radek=MySQL_Fetch_Array($type))
  {
    if (($radek["udalost"] == 7) AND ! $merime AND $radek["datum"])
    { $merime=True;
      $zacatek=strtotime($radek["datum"]);
    }
    if (($radek["udalost"] == 8) AND  $merime AND $radek["datum"])
    { $merime=False;
      $konec=strtotime($radek["datum"]);
      #uzavreli jsme interval a jdeme tedy zjistit jestli lezi v nasem roce
      if (($zacatek < $do) AND ($konec>$od))
      { #pokud je zacatek pred zacatkem roku tak merime od zacatku roku
        if ($zacatek<$od) $zacatek=$od;
        #pokud je konec po konci roku tak merime jen do konce roku 
        if ($konec>$do) $konec=$do;
        #a konecne ziskame rozdil a pricteme do celkove doby
        $celkem += $konec-$zacatek;
      }
    }
  }
#zbyva otestovat jestli stale nemerime a pripadne vycislit dobu
#uzavreli jsme interval a jdeme tedy zjistit jestli zacatek lezi v nasem roce
      if (($zacatek < $do) AND $merime)
      { #pokud je zacatek pred zacatkem roku tak merime od zacatku roku
        if ($zacatek<$od) $zacatek=$od;
        $konec=$do;
        #a konecne ziskame rozdil a pricteme do celkove doby
        $celkem += $konec-$zacatek;
      }
    return $celkem;
}


function id_to_delkaspotreby($id,$rok){
$type=MySQL_Query("SELECT * FROM ukony WHERE majetek='$id' AND udalost IN (17,18) ORDER BY datum,udalost");
$cnt=0;
$count=MySQL_Num_Rows($type);
if($rok=="vsechno")
{   $od=0;
    $do=strtotime(date("Y")."-12-31");
} else {
    $od=strtotime($rok."-01-01");
    $do=strtotime($rok."-12-31");
}
$zacatek=0;
$konec=0;
$merime=False;
$celkem=0;
while($radek=MySQL_Fetch_Array($type))
  {
    $cnt=$cnt+1;
    if (($radek["udalost"] == 17) AND ! $merime AND $radek["datum"])
    { $cnt=10;
      $merime=True;
      $zacatek=strtotime($radek["datum"]);
    }
    if (($radek["udalost"] == 18) AND  $merime AND $radek["datum"])
    { $cnt=12;
      $merime=False;
      $konec=strtotime($radek["datum"]);
      #uzavreli jsme interval a jdeme tedy zjistit jestli lezi v nasem roce
      if (($zacatek < $do) AND ($konec>$od))
      { #pokud je zacatek pred zacatkem roku tak merime od zacatku roku
        if ($zacatek<$od) $zacatek=$od;
        #pokud je konec po konci roku tak merime jen do konce roku 
        if ($konec>$do) $konec=$do;
        #a konecne ziskame rozdil a pricteme do celkove doby kdy clen napaji switch
        $celkem += $konec-$zacatek;
      }            
    }
  }
#    return (strtotime($do)-strtotime($od));
#zbyva otestovat jestli stale nemerime a pripadne vycislit dobu
#uzavreli jsme interval a jdeme tedy zjistit jestli zacatek lezi v nasem roce
      if (($zacatek < $do) AND $merime)
      { #pokud je zacatek pred zacatkem roku tak merime od zacatku roku
        if ($zacatek<$od) $zacatek=$od;
        $konec=$do;
        #a konecne ziskame rozdil a pricteme do celkove doby kdy clen napaji switch
        $celkem = $konec-$zacatek;
      }
    return $celkem;
}

function id_to_ipecko($id){
$type=MySQL_Query("SELECT ip FROM ipecka WHERE id='$id'");
$type=MySQL_Fetch_Array($type);
return $type["ip"];
}

function id_to_udalost($id){
$type=MySQL_Query("SELECT nazev FROM udalosti WHERE id='$id'");
$type=MySQL_Fetch_Array($type);
return $type["nazev"];
}

function id_to_zarizeni($id){
$type=MySQL_Query("SELECT nazev FROM zarizeni WHERE id='$id'");
$type=MySQL_Fetch_Array($type);
return $type["nazev"];
}

function id_to_spotreba($id){
$type=MySQL_Query("SELECT spotreba FROM 
majetek WHERE id='$id'");
$type=MySQL_Fetch_Array($type);
return $type["spotreba"];
}

function clen_to_ipecko($clen){
$type=MySQL_Query("SELECT id FROM ipecka WHERE clen='$clen'");
$type=MySQL_Fetch_Array($type);

return $type["id"];
}

function clen_to_ipecka($clen){
  $type=MySQL_Query("SELECT id,ip FROM ipecka WHERE clen='$clen'");
  while ($ipecko=MySQL_Fetch_Array($type)) {
    $ipecka[$ipecko["id"]]=$ipecko["ip"];
  }
return $ipecka;
}

function last_ip_action($id){
$type=MySQL_Query("SELECT udalost FROM ukony WHERE predmet='$id' ORDER BY datum DESC");
$type=MySQL_Fetch_Array($type);
return $type["udalost"];
}

function id_to_ukon($id){
$type=MySQL_Query("SELECT * FROM ukony WHERE id='$id' ORDER BY datum DESC");
$type=MySQL_Fetch_Array($type);
return sql2datum($type["datum"])." ".id_to_udalost($type["udalost"])." ".id_to_adresa($type["adresa"]);
}

function clen_to_adresa($clen){
$type=MySQL_Query("SELECT id FROM adresy WHERE clen='$clen'");
$type=MySQL_Fetch_Array($type);
return $type["id"];
}

function id_to_byt($id){
$type=MySQL_Query("SELECT byt FROM adresy WHERE id='$id'");
$type=MySQL_Fetch_Array($type);
return $type["byt"];
}

function id_to_ulice($id){
$type=MySQL_Query("SELECT ulice FROM adresy WHERE id='$id'");
$type=MySQL_Fetch_Array($type);
return $type["ulice"];
}

function id_to_cp($id){
$type=MySQL_Query("SELECT cp FROM adresy WHERE id='$id'");
$type=MySQL_Fetch_Array($type);
return $type["cp"];
}

function id_to_email($id){
$type=MySQL_Query("SELECT email FROM cleni WHERE id='$id'");
$type=MySQL_Fetch_Array($type);
return $type["email"];
}

function id_to_adresa($id){
$type=MySQL_Query("SELECT * FROM adresy WHERE id='$id'");
$type=MySQL_Fetch_Array($type);
if ($type["byt"]) return $type["ulice"]." ".$type["cp"]." byt ".$type["byt"];
return $type["ulice"]." ".$type["cp"];
}

function id_to_finance($id){
$type=MySQL_Query("SELECT * FROM finance WHERE id='$id'");
$type=MySQL_Fetch_Array($type);
return id_to_platba($type["platba"])." ".$type["hodnota"];
}

function id_to_majetek($id){
$type=MySQL_Query("SELECT * FROM majetek WHERE id='$id'");
$type=MySQL_Fetch_Array($type);
return id_to_zarizeni($type["zarizeni"])." ".$type["scislo"]." ".$type["mac"]." ".$type["komentar"];
}

function id_to_objekt($id){
$type=MySQL_Query("SELECT * FROM objekty WHERE id='$id'");
$type=MySQL_Fetch_Array($type);
return $type["nazev"]." ".$type["komentar"];
}

function type_count(){
$type=MySQL_Query("SELECT * FROM poplatky");
$type=MySQL_Num_Rows($type);
return $type;
}

function flat_to_address($flat){
if ($flat>999 || $flat==0) return "";
$patro=10;
$vchod=420;
while($flat>33)
{
$flat-=33;
$vchod--;
}
while($flat>3)
{
$flat-=3;
$patro--;
}
if($vchod==408)$vchod=713;
if($vchod==407)$vchod=714;

return $vchod.' - '.$patro;
}

/** Kontrola e-mailové adresy
* @param string $email e-mailová adresa
* @return bool syntaktická správnost adresy
* @copyright Jakub Vrána, http://php.vrana.cz
*/
function check_email($email)
{
    $atom = '[-a-z0-9!#$%&\'*+/=?^_`{|}~]'; // znaky tvořící uživatelské jméno
    $domain = '[a-z0-9]([-a-z0-9]{0,61}[a-z0-9])'; // jedna komponenta domény
    return eregi("^$atom+(\\.$atom+)*@($domain?\\.)+$domain\$", $email);
}


function getweb($URL){

//Giving the String URL as argument it returns all webpage as a String to you
$allPage = "";

if($URL == null){ //Checking provided URL
echo("<b><font color=\"red\">Please specify a URL to get data from </font></b>");
}

$fp= fopen($URL, 'r'); //Opening Connection

if ( !$fp ) { // Check connection
echo("<b><font color=\"red\">Connection Failed</font></b>");
}
else{
$num=0;
while ( !feof($fp) ){
$pageText[$num] = fread($fp,1024);// read WebPage
$num++;
}
//endwhile;
}

$arrayLen=count($pageText);
for($i=0; $i<$arrayLen; $i++){
$allPage=$allPage.$pageText[$i];
}
fclose($fp);
return $allPage;
}

?>

Powered by WebSVN 2.2.1