init(); } /** *inicjalizuje sesje */ function init() { $this->id = 0; $this->login = ''; $this->email = ''; $this->password='' ; $this->group_id='' ; $this->admin=0 ; // $this->administrator = false; // $this->superadmin = false; //session_unregister("sess"); unset($_SESSION['sess']); session_destroy(); } /** *loguje uzytkownika * *wyszukuje uzytkownika o podanym logini i hasle w bazie *jesli znajdzie, przypisuje jego parametery do odpowiednich pol * *@param string login uzytkownika *@param string haslo uzytkownika *@param string adres, na ktory nastepuje przekierowanie */ function zaloguj($login, $haslo, $url = '') { global $uzytkownicy; global $CAdmins,$CUsersAction; global $db2; $db2->query("SELECT ".$uzytkownicy->tablePrefix."id,".$uzytkownicy->tablePrefix."password,".$uzytkownicy->tablePrefix."group_id,".$uzytkownicy->tablePrefix."email FROM `".$uzytkownicy->tableName."` WHERE ".$uzytkownicy->tablePrefix."login = '" . $login . "' AND ".$uzytkownicy->tablePrefix."password = '" . hash_make($haslo) . "'"); if ($db2->nextRecord()) { // sprawdzenie czy aktywował konto if(!($CUsersAction->istniejePoleOWartosci('user_id',$db2->f($uzytkownicy->tablePrefix.'id')))) { $db2->query("SELECT ".$uzytkownicy->tablePrefix."id,".$uzytkownicy->tablePrefix."password,".$uzytkownicy->tablePrefix."group_id,".$uzytkownicy->tablePrefix."email FROM `".$uzytkownicy->tableName."` WHERE ".$uzytkownicy->tablePrefix."login = '" . $login . "' AND ".$uzytkownicy->tablePrefix."password = '" . hash_make($haslo) . "'"); if ($db2->nextRecord()) { $this->login = $login; // zwykle logowanie $this->id = $db2->f($uzytkownicy->tablePrefix.'id'); //rola 1 admin // 2 cześciwoy admin if($rCAdmins=($CAdmins->istniejePoleOWartosci('user_id',$db2->f($uzytkownicy->tablePrefix.'id')))) $this->admin=$rCAdmins->get_role(); else $this->admin =0; $this->group_id = $db2->f($uzytkownicy->tablePrefix.'group_id'); $this->email = $db2->f($uzytkownicy->tablePrefix.'email'); $this->password = $db2->f($uzytkownicy->tablePrefix.'password'); $uzytkownicy->update($db2->f($uzytkownicy->tablePrefix.'id'),array('lastlogin_time'=>date('Y-m-d H:i:s'))); // $this->administrator = $db->f('u_administrator') == "T"?true:false; // $this->superadmin = $db->f('u_administrator') == "S"?true:false; // $this->haslo = $db->f('u_haslo') ; // if($this->superadmin) // $this->administrator = true ; redirect($url); return true; } } } return false; } /** *wylogowuje uzytkownika * *czysci wszystkie pola * *@param string nie wykorzystywane, domyslnie puste */ function wyloguj() { $this->init(); redirect('http://' . $_SERVER["HTTP_HOST"]); } /** *sprawdza czy dany uzytkownik jest uprawniony do ogladania danej strony * *@param string adres, na ktory nastepuje przekierowanie *@return boolean true jesli uzytkownij jest uprawniony do ogladania danej strony */ function uprawniony($url = '',$onlyadmin=true) { if ($this->zalogowany()) { if($onlyadmin) { if($this->admin==1) return true; } else { if($this->admin==1 or $this->admin==2) return true; } } redirect('http://' . $_SERVER["HTTP_HOST"] . '/login.php?redir=' . urlencode($url)); /* if ($this->administrator) return true; elseif($url != '') redirect('http://' . $_SERVER["HTTP_HOST"] . '/login.php?redir=' . urlencode($url)); */ } /** *sprawdza czy uzytkownik jest superuprawniony * *@param string adres, na ktory nastepuje przekierowanie *@return boolean true - jesli uzytkownik jest superuprawniony do ogladania danej strony */ function superuprawniony($url = '') { if ($this->superadmin) return true; elseif($url != '') redirect('http://' . $_SERVER["HTTP_HOST"] . '/login.php?redir=' . urlencode($url)); } /** *sprawdza czy uzytkownik ma dostep do strony (zwykly user) * *@return boolean true jesli ma dostep */ function dostepnosc($url = '') { if ($this->login!='') return true; elseif($url != '') redirect('http://' . $_SERVER["HTTP_HOST"] . '/login.php?redir=' . urlencode($url)); } /** *sprawdza czy uzytkownik jest zalogowany * *@return boolean true jesli zalogowany, false - jesli nie zalogowany */ function zalogowany() { if ($this->login!='') return true; else return false; } function zmien_haslo($stare, $nowe, $powtorka) { global $uzytkownicy; if ($nowe == $powtorka && hash_make($stare) == $this->password) { global $db2; $db2->query("UPDATE ".$uzytkownicy->tableName." SET ".$uzytkownicy->tablePrefix."password = '".hash_make($nowe)."' WHERE ".$uzytkownicy->tablePrefix."id = ".$this->id); $this->password=hash_make($nowe); return TRUE; } else return FALSE; } } ?> query('SHOW TABLES FROM administracja'); while($db->nextRecord()) { if(tablePrefix($db->f('Tables_in_administracja')) == $fieldTablePrefix) { $table = $db->f('Tables_in_administracja'); break; } } return $table; } /** *zwraca maksymalna dlugosc pola * *@param string nazwa pola *@param string nazwa tabeli *@return int dlugosc pola */ function poleMaxlength($field,$table = 'brakuje prefiksu tabeli w nazwie pola') { $db = new DBLocalMySql; if($table == 'brakuje prefiksu tabeli w nazwie pola') { $fieldTablePrefix = substr($field, 0, strpos($field, '_')); $db->query('SHOW TABLES FROM administracja'); while($db->nextRecord()) { if(tablePrefix($db->f('Tables_in_administracja')) == $fieldTablePrefix) { $table = $db->f('Tables_in_administracja'); break; } } if($table == 'brakuje prefiksu tabeli w nazwie pola') $table = 'brakuje prefiksu tabeli w nazwie pola \'' . $field . '\''; } $db->query('SHOW FIELDS FROM ' . $table); while($db->nextRecord()) { if($db->f('Field') == $field) { $type = $db->f('Type'); break; } } if($type == 'text') return 8192; $start = strpos($type, '(') + 1; $size = substr($type, $start, strrpos($type, ')') - $start); if(is_numeric($size)) return $size; else { $n = explode(',', $size); if(is_numeric($n[0]) && is_numeric($n[1])) return $n[0] + $n[1] + 1; } return 64; } // operacje na zmiennych konfiguracyjnych /** *pobiera wartosc podanej zmiennej * *@param string nazwa pola *@return string wartosc pola lub "nieustawiona" */ function getZmienna($nazwa) { $db = new DBLocalMySql; $db->query('SELECT wartosc FROM ustawienia WHERE nazwa=\'' . $nazwa . '\''); if($db->nextRecord()) return $db->f('wartosc'); return $nieustawiona; } /** *ustawia pole o podanej nazwie * *@param string nazwa pola *@param string nowa wartosc pola */ function setZmienna($nazwa, $wartosc) { $db = new DBLocalMySql; $db->query('SELECT wartosc FROM ustawienia WHERE nazwa=\'' . $nazwa . '\''); if($db->nextRecord()) $db->query('UPDATE ustawienia SET wartosc = \'' . $wartosc . '\' WHERE nazwa = \'' . $nazwa . '\''); else $db->query('INSERT INTO ustawienia(nazwa, wartosc) VALUES (\'' . $nazwa . '\',\'' . $wartosc . '\')'); } /** *czysci pole o podanej nazwie * *@param string nazwa pola */ function unsetZmienna($nazwa) { $db = new DBLocalMySql; $db->query('DELETE FROM ustawienia WHERE nazwa=\'' . $nazwa . '\''); } /** *pobiera rozszerzenie pliku z podanej nazwy pliku * *@param string nazwa pliku *@return string rozszerzenie pliku */ function ExtractFileExt($filename) { $pos = strrpos($filename, '.'); return strtolower(substr($filename, $pos + 1, strlen($filename) - $pos)); } /** *buduje menu na zapleczu * *@param array menu *@param string wybrane *@return string kod html */ function menu($menu, $sel) { $ams = explode(',', $sel); global $_ARGS; ksort($menu); $html = ''; $html .= ''; unset($prefixes); return $html; } /** * zwraca ades bazowy * *@return string adres */ function myurlbase() { /** *@global string $HTTP_SERVER_VARS */ global $HTTP_SERVER_VARS; /** *@global string $HTTPS */ global $HTTPS; $port = $HTTP_SERVER_VARS['SERVER_PORT']; $scheme = 'http'; $defPort = 80; if (isset($HTTPS) && ($HTTPS == 'on')) { $scheme = 'https'; $defPort = 443; } if ($port == $defPort) $optPort = ''; else $optPort = ':' . $port; $urlbase = $scheme . '://' . $HTTP_SERVER_VARS['HTTP_HOST'] . $optPort; return $urlbase; } /** *przekierowuje pod podany adres * *@param string adres */ function redirect2($msg="", $url="") { $action = ''; echo $action; } function redirect($to) { /** *@global array */ global $HTTP_SERVER_VARS; /** *@global array */ global $_WLIB; if (!eregi('(^http://)|(^https://)|(^ftp://)', $to)) { if ($to{0} != '/') { $scriptname = $HTTP_SERVER_VARS['PHP_SELF']; if (($scriptname{strlen($scriptname) - 1} == '/') || ($scriptname{strlen($scriptname) - 1} == '\\')) $scriptname .= 'index.html'; $dir = dirname($scriptname); if ((strlen($dir) == 0) || (($dir{strlen($dir) - 1} != '/') && ($dir{strlen($dir) - 1} != '\\'))) $dir .= '/'; $to = $dir . $to; $to = str_replace('\\', '/', $to); } $to = myurlbase() . $to; } header("Location:" . $to); pageClose(); exit; } /** * Funkcja skalujaca obrazek. Skalowanie zachowuje oryginalne proporcje. * Jesli obrazek po przeskalowaniu jest mniejszy niz nowe wymiary, zostaje on * w takim rozmiarze zapisany. * @param string zrodlo obrazka * @param string docelowa sciezka i nazwa zmienionego obrazka * @param int nowa szerokosc * @param int nowa wysokosc */ function resize_img_nofill($src_name,$dst_name,$width,$height=0,$orl_name=null) { global $old_gd; if(is_null($orl_name)) $type = strtolower(substr(strrchr($src_name,"."),1)); else $type = strtolower(substr(strrchr($orl_name,"."),1)); if($type == "jpg" || $type == "jpeg") { $src = imagecreatefromjpeg($src_name); } else if($type == "png") { $src = imagecreatefrompng($src_name); } else if($type == "gif") { $src = imagecreatefromgif($src_name); } else { echo "resize_img('$src_name', '$dst_name', $width, $height) supports only jpg, gif and 8-bit png images!!!
Check file extension.
"; return; } $s_width = imagesx($src); $s_height = imagesy($src); if($height==0) { $ratio=$s_width / $s_height; $height=$width / $ratio; } if($s_width*$height > $width*$s_height) { $d_width = $width; $d_height = $s_height*$d_width/$s_width; } else { $d_height = $height; $d_width = $s_width*$d_height/$s_height; } $white = imagecolorallocate($dst,255,255,255); if($type == "jpg" || $type == "jpeg") { if($old_gd) $dst = imagecreate($d_width,$d_height); else $dst = imagecreatetruecolor($d_width,$d_height); imagefilledrectangle($dst,0,0,$d_width,$d_height,$white); } else if($type == "png") { $dst = imagecreate($d_width,$d_height); imagefilledrectangle($dst,0,0,$d_width,$d_height); } else if($type == "gif") { $dst = imagecreate($d_width,$d_height); imagefilledrectangle($dst,0,0,$d_width,$d_height); } //$white = imagecolorallocate($dst,255,255,255); //imagefilledrectangle($dst,0,0,$d_width,$d_height,$white); if($old_gd) imagecopyresized($dst,$src,0,0,0,0,$d_width,$d_height,$s_width,$s_height); else imagecopyresampled($dst,$src,0,0,0,0,$d_width,$d_height,$s_width,$s_height); if($type == "jpg" || $type == "jpeg") imagejpeg($dst,$dst_name); else if($type == "png") imagepng($dst,$dst_name); else if($type == "gif") imagegif($dst,$dst_name); } function resize_img_fill($src_name,$dst_name,$width,$height=null,$orl_name=null,$colors=null) { global $old_gd; if(is_null($orl_name)) $type = strtolower(substr(strrchr($src_name,"."),1)); else $type = strtolower(substr(strrchr($orl_name,"."),1)); if($type == "jpg" || $type == "jpeg") { $src = imagecreatefromjpeg($src_name); $s_width = imagesx($src); $s_height = imagesy($src); if($height==null) { if($s_width>$width){ $ratio=$s_width / $s_height; $height=$width / $ratio; } else { $width = $s_width; $height = $s_height; } } if($old_gd) $dst = imagecreate($width,$height); else $dst = imagecreatetruecolor($width,$height); } else if($type == "png") { $src = imagecreatefrompng($src_name); $s_width = imagesx($src); $s_height = imagesy($src); if($height==null) { if($s_width>$width){ $ratio=$s_width / $s_height; $height=$width / $ratio; } else { $width = $s_width; $height = $s_height; } } $dst = imagecreate($width,$height); } else if($type == "gif") { $src = imagecreatefromgif($src_name); $s_width = imagesx($src); $s_height = imagesy($src); if($height==null) { if($s_width>$width){ $ratio=$s_width / $s_height; $height=$width / $ratio; } else { $width = $s_width; $height = $s_height; } } $dst = imagecreate($width,$height); } else { throw new Exception("resize_img_fill('$src_name', '$dst_name', $width, $height) supports only jpg, gif and 8-bit png images!!!
Check file extension.
".$type); return false; } if(count($colors)==3) $white = imagecolorallocate($dst,$colors[0],$colors[1],$colors[2]); else $white = imagecolorallocate($dst,250,251,255); imagecolortransparent($dst, $white); imagefilledrectangle($dst,0,0,$width,$height,$white); if($s_width*$height > $width*$s_height) { $d_width = $width; $d_height = $s_height*$d_width/$s_width; } else { $d_height = $height; $d_width = $s_width*$d_height/$s_height; } if($old_gd) imagecopyresized($dst,$src,($width-$d_width)/2,($height-$d_height)/2,0,0,$d_width,$d_height,$s_width,$s_height); else imagecopyresampled($dst,$src,($width-$d_width)/2,($height-$d_height)/2,0,0,$d_width,$d_height,$s_width,$s_height); // dbg_error($dst_name); if($type == "jpg" || $type == "jpeg") imagejpeg($dst,$dst_name,95); else if($type == "png") imagepng($dst,$dst_name); else if($type == "gif") imagegif($dst,$dst_name); imagedestroy($dst); imagedestroy($src); return true; } /** * Tworzy podglada * * @param string nazwa pliku zrodlowa * @param string nazwa pliku docelowa */ function makePreview ($fileSource, $filePreview, $width, $height) { define("PREVIEW_WIDTH", $width); define("PREVIEW_HEIGHT", $height); $imgPreview = imagecreatetruecolor(PREVIEW_WIDTH, PREVIEW_HEIGHT ); $imgSource = imagecreatefromjpeg($fileSource); $widthSource = imagesx($imgSource); $heightSource = imagesy($imgSource); $ratioSource = $widthSource / $heightSource ; $ratioPreview = PREVIEW_WIDTH / PREVIEW_HEIGHT; if($ratioPreview >= 1) { if($ratioSource < $ratioPreview) { $newWidthSource = PREVIEW_WIDTH; $newHeightSource = $heightSource * (PREVIEW_WIDTH / $widthSource); $bigWidthPreview = $widthSource; $bigHeightPreview = PREVIEW_HEIGHT * ($widthSource / PREVIEW_WIDTH); } else { $newWidthSource = $widthSource * (PREVIEW_HEIGHT / $heightSource); $newHeightSource = PREVIEW_HEIGHT; $bigWidthPreview = PREVIEW_WIDTH * ($heightSource / PREVIEW_HEIGHT ); $bigHeightPreview = $heightSource; } imagecopyresampled ( $imgPreview, $imgSource, 0, 0, ($widthSource - $bigWidthPreview)/2, ($heightSource - $bigHeightPreview)/2, $newWidthSource, $newHeightSource, $widthSource, $heightSource ); } imagejpeg($imgPreview, $filePreview,90); chmod($filePreview, 0775) ; } function trimTitle($str, $maxLenght = 26) { $strLen = strlen($str) ; if($strLen > $maxLenght) { return substr($str, 0, $maxLenght-3) . '...' ; } return $str ; } function ClearLink($link) { $link = strip_tags($link) ; $link = str_replace(" ", "_", $link) ; $link = str_replace(".", ",", $link) ; // characters to delete $expression = Array('-', '$', '%', '&', '/', '\\', '@') ; $link = str_replace( $expression, "", $link) ; $link = strtr($link,"ąćęłńśźżĄĆĘŁŃŚŹŻóÓ","acelnszzACELNSZZoO") ; return $link ; } function nbps($string){ $patterns =array('/\s+w\s+/','/\s+a\s+/','/\s+z\s+/','/\s+i\s+/','/\s+w\s+/','/\s+A\s+/','/\s+I\s+/','/\s+Z\s+/','/\s+o\s+/','/\s+u\s+/','/\s+-\s+/','/ w\s+/','/ a\s+/','/ z\s+/','/ i\s+/','/ w\s+/','/ A\s+/','/ I\s+/','/ Z\s+/','/ o\s+/','/ u\s+/','/ -\s+/'); $replacers =array(' w ',' a ',' z ',' i ',' w ',' A ',' I ',' Z ',' o ',' u ',' - ',' w ',' a ',' z ',' i ',' w ',' A ',' I ',' Z ',' o ',' u ',' - '); return preg_replace($patterns,$replacers,$string); } function CutString($do,$string) { $text = ''; $textA=explode(' ', $string); $space=''; for ($n=0; $n<$do; $n++) { $text.=$space.$textA[$n]; $space=' '; } $text .= " (...)"; return $text; } function is_date($field) { return preg_match("/^[0-9]{2}\/[0-9]{2}\/[0-9]{4}$/",$field); } function is_date_correct( $sDate, $sFormat = 'ymd', $sSep = '-' ){ $f['y'] = 4; $f['m'] = 2; $f['d'] = 2; if( ereg( "([0-9]{".$f[$sFormat[0]]."})".$sSep."([0-9]{".$f[$sFormat[1]]."})".$sSep."([0-9]{".$f[$sFormat[2]]."})", $sDate ) ){ $y = strpos( $sFormat, 'y' ); $m = strpos( $sFormat, 'm' ); $d = strpos( $sFormat, 'd' ); $aDates = explode( $sSep, $sDate ); return checkdate( $aDates[$m], $aDates[$d], $aDates[$y] ); } else return false; } function date_map($sDate,$sFormat = 'ymd',$sSep='-') { $month=array('','stycznia','lutego','marca','kwietnia','maja','czerwca','lipca','sierpnia','września','października','listopada','grudnia'); if(is_date_correct($sDate)) { $y = strpos( $sFormat, 'y' ); $m = strpos( $sFormat, 'm' ); $d = strpos( $sFormat, 'd' ); $aDates = explode( $sSep, $sDate ); return intval($aDates[$d]).' '.$month[intval($aDates[$m])].' '.intval($aDates[$y]); } else return $sDate; } /** * Tworzy podglada * * @param string nazwa pliku zrodlowa * @param string nazwa pliku docelowa */ function makePreview2 ($fileSource, $filePreview, $type) { define("PREVIEW_WIDTH", 145); define("PREVIEW_HEIGHT", 109); //echo "

source in: " . $fileSource . "
"; //echo "save in: " . $filePreview . "
"; $imgPreview = imagecreatetruecolor(PREVIEW_WIDTH, PREVIEW_HEIGHT ); $imageType = checkFileMime($fileSource) ; //$imgSource = imagecreatefromjpeg($fileSource); if($imageType == "image/jpg" || $imageType == "image/jpeg" ) $imgSource = imagecreatefromjpeg($fileSource); else if($imageType == "image/png") $imgSource = imagecreatefrompng($fileSource); else if($imageType == "image/gif") $imgSource = imagecreatefromgif($fileSource); else { echo "resize_img('$src_name', '$dst_name', $width, $height) supports only jpg, gif and 8-bit png images!!!
"; return; } $widthSource = imagesx($imgSource); $heightSource = imagesy($imgSource); $ratioSource = $widthSource / $heightSource ; $ratioPreview = PREVIEW_WIDTH / PREVIEW_HEIGHT; if($ratioPreview > 1) { if($ratioSource < $ratioPreview) { $newWidthSource = PREVIEW_WIDTH; $newHeightSource = $heightSource * (PREVIEW_WIDTH / $widthSource); $bigWidthPreview = $widthSource; $bigHeightPreview = PREVIEW_HEIGHT * ($widthSource / PREVIEW_WIDTH); } else { $newWidthSource = $widthSource * (PREVIEW_HEIGHT / $heightSource); $newHeightSource = PREVIEW_HEIGHT; $bigWidthPreview = PREVIEW_WIDTH * ($heightSource / PREVIEW_HEIGHT ); $bigHeightPreview = $heightSource; } } imagecopyresampled ( $imgPreview, $imgSource, 0, 0, ($widthSource - $bigWidthPreview)/2, ($heightSource - $bigHeightPreview)/2, $newWidthSource, $newHeightSource, $widthSource, $heightSource ); global $Dirs; switch($type) { case "o": $imgIco = imagecreatefromgif("img/litereczki/o.gif"); break; case "m": $imgIco = imagecreatefromgif("img/litereczki/m.gif"); break; case "f": $imgIco = imagecreatefromgif("img/litereczki/f.gif"); break; default: $imgIco = imagecreatefromgif("img/litereczki/t.gif"); } imagecopy( $imgPreview, $imgIco, 5, PREVIEW_HEIGHT-20, 0, 0, imagesx($imgIco), imagesy($imgIco)); imagejpeg($imgPreview, $filePreview,90); } function checkFileMime($fileName) { if(!extension_loaded('fileinfo')) { dl('fileinfo.' . PHP_SHLIB_SUFFIX); } if(!extension_loaded('fileinfo')) { die("fileinfo extension is not avaliable, please compile it.\n"); } $res = finfo_open(FILEINFO_MIME); return finfo_file($res, $fileName) ; } function checkFileMimeWork($fileName) { if(!extension_loaded('fileinfo')) { dl('fileinfo.' . PHP_SHLIB_SUFFIX); } if(!extension_loaded('fileinfo')) { die("fileinfo extension is not avaliable, please compile it.\n"); } // $res = finfo_open(FILEINFO_MIME); // return finfo_file($res, $fileName) ; $res=getimagesize($fileName); return $res['mime']; } function smarty_modifier_polish_month($month) { $polish_month=array('stycznia','lutego','marca','kwietnia','maja','czerwca','lipca','sierpnia','września','października','listopada','grudnia'); if(intval($month)>=1 && intval($month)<=12) return $polish_month[intval($month)-1]; else return $month; } function smarty_modifier_polish_week($week) { $polish_week=array('poniedziałek','wtorek','środa','czwartek','piątek','sobota','niedziela'); if(intval($week)>=1 && intval($week)<=7) return $polish_week[intval($week)-1]; else return $week; } function makeSign ($imgSource,$signSource=null) { $widthSource = imagesx($imgSource); $heightSource = imagesy($imgSource); $imgPreview = imagecreatetruecolor($widthSource, $heightSource ); imagecopyresampled ( $imgPreview, $imgSource, 0, 0, 0, 0, $widthSource, $heightSource, $widthSource, $heightSource ); if(!is_null($signSource) and file_exists($signSource)) { $imageType = checkFileMimeWork($signSource) ; switch($imageType) { case 'image/jpg' : case 'image/jpeg' : $imgIco=imagecreatefromjpeg($signSource); break; case 'image/gif' : $imgIco=imagecreatefromgif($signSource); break; case 'image/png' : $imgIco=imagecreatefrompng($signSource); break; } @imagecopy( $imgPreview, $imgIco, (($widthSource/2)-(imagesx($imgIco)/2)), ($heightSource/2-imagesy($imgIco)/2), 0, 0, imagesx($imgIco), imagesy($imgIco)); } imagejpeg($imgPreview); imagedestroy($imgPreview); } * Ustawia takze zawartosc koszyka * * @author Sparta Software */ function init_smarty(){ $sDocRoot = $_SERVER['DOCUMENT_ROOT']."/"; ini_set('include_path',ini_get('include_path').":".$sDocRoot."inc/smarty"); global $Smarty; $Smarty= new Smarty(); $Smarty->template_dir = $sDocRoot.'templates/'; $Smarty->compile_dir = $sDocRoot.'templates_c/'; $Smarty->config_dir = $sDocRoot.'configs/'; $Smarty->cache_dir = $sDocRoot.'cache/'; // $Smarty->caching = $configfile['template']['caching']; $Smarty->compile_check = true; $Smarty->force_compile = true; $Smarty->debugging_ctrl="URL"; $Smarty->register_modifier('polish_month','smarty_modifier_polish_month'); $Smarty->register_modifier('polish_week','smarty_modifier_polish_week'); $Smarty->register_modifier('clean_url','smarty_modifier_clean_url'); $Smarty->register_modifier('date_map','smarty_modifier_date_map'); $Smarty->register_modifier('ss', 'stripslashes'); } init_smarty(); function pageOpen2($onlyadmin=true) { /** *@global object obiekt klasy Sesja */ include_once('functions.php'); global $sess, $Ustawienia,$Dirswz; /** *@global object obiekt klasy Koszyk */ if (!isset($_SESSION['sess'])) { $sess = new Sesja(); $_SESSION['sess'] = $sess; } if (!isset($sess)) $sess = new Sesja(); $sess = $_SESSION['sess']; global $Smarty; $Smarty->assign('Dirswz',$Dirswz); if(isset($_GET['menu_sel'])) $Smarty->assign('menu_sel',$_GET['menu_sel']); if($onlyadmin) $sess->uprawniony($_SERVER['PHP_SELF']."?".$_SERVER['QUERY_STRING']); else $sess->uprawniony($_SERVER['PHP_SELF']."?".$_SERVER['QUERY_STRING'],false); } function pageOpen() { /** *@global object obiekt klasy Sesja */ include_once('functions.php'); global $sess, $Ustawienia,$Dirswz; /** *@global object obiekt klasy Koszyk */ if (!isset($_SESSION['sess'])) { $sess = new Sesja(); $_SESSION['sess'] = $sess; } if (!isset($sess)) { $sess = new Sesja(); $sess = $_SESSION['sess']; } global $Smarty; $Smarty->assign('Dirswz',$Dirswz); if($_GET['searchtext']) $Smarty->assign('searchtext',htmlspecialchars(strip_tags($_GET['searchtext']))); $Smarty->assign('sid2', md5(uniqid(time()))); $Smarty->assign('Dirswz',$Dirswz); } /** * Funkcja zamykajaca strone, robi nic * * @author Sparta Software */ function pageClose() { // var_dump($_SESSION['sess']); } /** * Funkcja budujaca naglowek strony na zapleczu * * @author Sparta Software *@param string tytul strony *@param string slowa kluczowe *@param string opis *@param string jezyk *@param string kodowanie *@param string adres pliku .css *@param string adres pliku .js *@param string cachowanie *@param string odswiezanie */ function zHeader($title = '', $keywords = '', $description = '', $lang = '', $charset = 'utf-8', $css = '../style/style.css', $js = '../js/scripts.js', $nocache = '', $refresh = '') { /** *@global array menu */ global $menu; // global $Ustawienia; /** *@global array wybrane elementy */ global $menuSel; /** *@global array tablica argumentow */ global $Smarty; global $sess; $Smarty->assign('title', $title); $Smarty->assign('author', 'Sparta Software ; www.sparta.net.pl'); $Smarty->assign('copyright','XXWIEK'); $Smarty->assign('charset',$charset); if($sess->admin==2) { global $menu2; $menu=$menu2; } $Smarty->assign('menu', menu($menu, $_GET['menu_sel'])); header('Expires: Mon, 26 Jul 1997 05:00:00 GMT'); // Date in the past header('Last-Modified: ' . gmdate("D, d M Y H:i:s") . ' GMT'); // always modified header('Cache-Control: no-store, no-cache, must-revalidate'); // HTTP/1.1 header('Cache-Control: post-check=0, pre-check=0', false); header('Pragma: no-cache'); // HTTP/1.0 $Smarty->display( 'zaplecze/zHeader.thtml'); } /** * Funkcja budujaca stopke na zapleczu * * @author Sparta Software */ function zFooter() { global $Smarty; $Smarty->display( 'zaplecze/zFooter.thtml'); } /** * Funkcja buduje naglowek strony * * Funckja tworzy cala sekcje head w naglowku strony wykorzystujac szablon header.thtml
* W szablonie otwierana jest sekcja body! * * @param title string tytul strony * @param keywords string slowa kluczowe * @param description string opis strony * @param lang string jezyk * @param charset string kodowanie strony * @param nocache bool zezwalanie na cache'owanie * @param refresh string odswiezanie strony ew. redirect na inna * @author Sparta Software (Krzysztof Maranowski) */ function sHeader($title = '', $keywords = '', $description = '', $lang = '', $charset = 'utf-8', $nocache = '', $refresh = '',$template='') { /** *@global object obiekt klasy Sesja */ global $sess; global $uzytkownicy; /** *@global object obiekt klasy Koszyk */ global $forum; global $CSecureimg; /** *@global array menu */ /** *@global object obiekt klasy Ustawienia */ global $Ustawienia; /** *@global array tablica argumentow */ global $Smarty; /** *@global obiekt klasy Newsletter */ global $CNewsletter; if($keywords) $Smarty->assign('keywords', $keywords); else $Smarty->assign('keywords', $Ustawienia->keywords()); if($description) $Smarty->assign('description', $description); else $Smarty->assign('description',$Ustawienia->description()); $Smarty->assign('lang', 'pl'); $Smarty->assign('title', $title); $Smarty->assign('author', 'Sparta Software ; www.sparta.net.pl'); $Smarty->assign('copyright','XXWIEK'); $Smarty->assign('charset',$charset); if ($nocache) { header('Expires: Mon, 26 Jul 1997 05:00:00 GMT'); // Date in the past header('Last-Modified: ' . gmdate("D, d M Y H:i:s") . ' GMT'); // always modified header('Cache-Control: no-store, no-cache, must-revalidate'); // HTTP/1.1 header('Cache-Control: post-check=0, pre-check=0', false); header('Pragma: no-cache'); // HTTP/1.0 $Smarty->assign('nocache', 'nocache'); } $page = str_replace("/","",$_SERVER['SCRIPT_NAME']); $redir = $page ; $action = $_POST['action'] ; if($action == 'login') { $login = $_POST['loginName'] ; $passwd = $_POST['loginPasswd'] ; $redir = $_GET['redir'] ; // login functionality if( $login && $passwd ) { if( !$sess->zaloguj($login, $passwd, $redir) ) { $Smarty->assign('message', "Błędnie wprowadzony login lub hasło" ); // $Smarty->append('tresc', "Błędnie wprowadzony login lub hasło" ); $Smarty->append('javascript','showlogin();'); } } else { $Smarty->assign('message', "Podaj login i hasło" ); // $Smarty->append('tresc', "Podaj login i hasło" ); $Smarty->append('javascript','showlogin();'); } } else if($action == 'logout') { $sess->wyloguj() ; } if($sess->zalogowany()) { $Smarty->assign('logged','true'); $Smarty->assign('login',$sess->login); } if($action == 'addnewsletter') { if($CSecureimg->check($_POST['captcha_code']) != true) $Smarty->assign('message', "Niepoprawny kod!
"); else { if($CNewsletter->addNewsletter($_POST['email'])) $Smarty->assign('message', "Email został dodany"); else $Smarty->assign('message', "Email nie został dodany."); } } if(isset($_GET['dzien_akt']) and is_date_correct($_GET['dzien_akt'])) { $Pdata = explode("-", $_GET['dzien_akt']); $Pdecade = substr($Pdata[0], 2,2); $Pyear = $Pdecade; $Pmonth = $Pdata[1]; $Pmonth = $Pmonth * 1; $Pday = $Pdata[2]; $Pday = $Pday * 1; if($Pdecade == "00") { $Pdecade = "99"; } if($Pyear == "00") { $Pyear = "100"; } $Pd = floor(($Pdecade - 1) / 10); $Py = (($Pyear % 10) - 1); if($Py == -1) { $Py = 9; } $Pm = $Pmonth - 1; $Pdd= $Pday - 1; $PDATE = "/flash/os.swf?Pd=".$Pd."&Py=".$Py."&Pm=".$Pm."&Pdd=".$Pdd.""; }else{ $PDATE = "/flash/os.swf"; } global $CFooter; $Smarty->assign('projectsImg', $CFooter->pozycje(NULL, "projekt", NULL, TRUE)); $Smarty->assign('projectsTxt', $CFooter->pozycje(NULL, "projekt", NULL, FALSE)); $Smarty->assign('presentations', $CFooter->pozycje(NULL, "prezentacja", NULL, FALSE)); $Smarty->assign('projectsSpo', $CFooter->pozycje(NULL, "sponsor", NULL, TRUE)); //wyciąganie tagów dla ktorych jest najwięcej mediów i artykułów global $db,$CTags; $tags=array(); $db->query('select *,tag_id, sum(ile) as '.$CTags->tablePrefix.'ilosc from (SELECT tm_t_id as tag_id,count(tm_t_id) as ile FROM tags_multimedia t left JOIN multimedia on tm_m_id=m_id where m_active = "T" group by tm_t_id union SELECT ta_t_id as tag_id, count(ta_t_id) as ile FROM tags_articles t left JOIN articles on ta_a_id=a_id where a_active = "T" group by ta_t_id UNION SELECT tw_t_id as tag_id, count( tw_t_id ) as ile FROM tags_wydarzenia t left JOIN wydarzenia on tw_w_id=w_id where w_active = "T" GROUP BY tw_t_id UNION SELECT tf_t_id as tag_id, count( tf_t_id ) as ile FROM tags_forum t left JOIN forum_post on tf_t_id=p_id where p_active = "T" GROUP BY tf_t_id) as tab left join '.$CTags->tableName.' on '.$CTags->tablePrefix.'id=tag_id where t_id is not null and t_name is not null group by tag_id order by '.$CTags->tablePrefix.'ilosc desc limit 0,16'); while($db->nextRecord()) $tags[] = new CRecord($db->allFields(),$CTags->tablePrefix); $Smarty->assign('tags', $tags); $Smarty->assign('PreloadDate', $PDATE); if($template) $Smarty->display($template); else $Smarty->display('header.thtml'); } /** * Funkcja tworzaca stopke strony * * Funckja tworzy stopke strony wykorzystujac szablon footer.thtml
* W szablonie zamykana jest sekcja body i html! * * @author Sparta Software */ function sFooter() { /** *@global array tablica argumentow */ global $Smarty; global $Ustawienia; global $ForumCategory; $Smarty->assign('lt',$Ustawienia->lt()); $Smarty->assign('rt',$Ustawienia->rt()); $Smarty->assign('lb',$Ustawienia->lb()); $Smarty->assign('rb',$Ustawienia->rb()); //if(eregi("mamzdrowedziecko.pl",$_SERVER["HTTP_HOST"])) //$args['GOOGLE']['jest'] = "ok"; $Smarty->display('footer.thtml'); } ?> '; } } /** *stop stopera * *@param string komentarz *@param string sekcja *@param boolean */ function dbgStoperStop($comment = '', $section = 'global', $silent = 0) { global $dbgStoper; $t = microtime(); $t = explode(' ', $t); $t = $t[0] + $t[1]; if($dbgStoper[$section]['working']) { $delta = $t - $dbgStoper[$section]['last_value']; $dbgStoper[$section]['acc'] += $delta; if(!$silent) echo 'stoper'. ($section) . ' this: ' . sprintf("%.6f", $delta) . ' all: ' . sprintf("%.6f", $dbgStoper[$section]['acc']) . ' - ' . $comment .'
'; $dbgStoper[$section]['working'] = 0; } } /** *pokazanie stopera * *@param string komentarz *@param string sekcja */ function dbgStoperShow($comment = '', $section = 'global') { global $dbgStoper; echo '### stoper($section) all: ' . sprintf("%.6f", $dbgStoper[$section]['acc']) . ' - ' . $comment . '
'; } /** * *@param string komentarz *@param string sekcja */ function dbgTime($comment = '', $section = 'global') { /** *przetrzymuje wartosci pobieranych czasow * *@global array */ global $dbgTimeValue; $t = microtime(); $t = explode(' ', $t); if(!isset($dbgTimeValue[$section])) { echo 'timer ' . ($section) . 'starting
'; $dbgTimeValue[$section]['last_value'] = $t[0] + $t[1]; $dbgTimeValue[$section]['start'] = $t[0] + $t[1]; } else { echo 'timer' . ($section) . 'read: ' . sprintf("%.6f", $t[0] + $t[1] - $dbgTimeValue[$section]['start']) . ' delta: ' . sprintf("%.6f", $t[0] + $t[1] - $dbgTimeValue[$section]['last_value']) . ' - ' . $comment . '
'; $dbgTimeValue[$section]['last_value'] = $t[0] + $t[1]; } } /** *wyswietlenie parametru var w postaci czytelnej * *@param array tablica do wyswietlenia */ function dbgShow($var) { echo '
';
    print_r($var);
    echo '
'; } /** *wyswietlenie parametru var jako bledu w postaci czytelnej * *@param array tablica do wyswietlenia */ function dbgError($var) { echo '

'; print_r($var); echo '

'; } ?> bo = "X----".uniqid(rand()); $this->zalaczniki = ""; } function get_mime($ext) { $mime = array ( "mdf" => "application/access", "xls" => "application/excel", "pfr" => "application/font-tdpfr", "spl" => "application/futuresplash", "hep" => "application/hep", "wks" => "application/lotus-123", "hqx" => "application/mac-binhex40", "cpt" => "application/mac-compactpro", "ppt" => "application/powerpoint", "doc" => "application/msword", "bin" => "application/octet-stream", "dms" => "application/octet-stream", "lha" => "application/octet-stream", "lzh" => "application/octet-stream", "exe" => "application/octet-stream", "class" => "application/octet-stream", "oda" => "application/oda", "pm5" => "application/pagemaker", "pt5" => "application/pagemaker", "pm" => "application/pagemaker", "pdf" => "application/pdf", "ai" => "application/postscript", "eps" => "application/postscript", "ps" => "application/postscript", "rtf" => "application/rtf", "smi" => "application/smil", "smil" => "application/smil", "sml" => "application/smil", "tbk" => "application/toolbook", "wp" => "application/wordperfect", "wp5" => "application/wordperfect5.1", "wp6" => "application/wordperfect6.1", "wpd" => "application/wordperfectd", "bcpio" => "application/x-bcpio", "vcd" => "application/x-cdlink", "cpio" => "application/x-cpio", "csh" => "application/x-csh", "dcr" => "application/x-director", "dir" => "application/x-director", "dxr" => "application/x-director", "dvi" => "application/x-dvi", "gtar" => "application/x-gtar", "hdf" => "application/x-hdf", "ica" => "application/x-ica", "js" => "application/x-javascript", "skp" => "application/x-koan", "skd" => "application/x-koan", "skt" => "application/x-koan", "skm" => "application/x-koan", "latex" => "application/x-latex", "mif" => "application/x-mif", "nc" => "application/x-netcdf", "cdf" => "application/x-netcdf", "sh" => "application/x-sh", "shar" => "application/x-shar", "swf" => "application/x-shockwave-flash", "sav" => "application/x-spss", "spp" => "application/x-spss", "sbs" => "application/x-spss", "sps" => "application/x-spss", "spo" => "application/x-spss", "sit" => "application/x-stuffit", "sv4cpio" => "application/x-sv4cpio", "sv4crc" => "application/x-sv4crc", "tar" => "application/x-tar", "tcl" => "application/x-tcl", "tex" => "application/x-tex", "texinfo" => "application/x-texinfo", "texi" => "application/x-texinfo", "man" => "application/x-troff-man", "me" => "application/x-troff-me", "ms" => "application/x-troff-ms", "t" => "application/x-troff", "tr" => "application/x-troff", "roff" => "application/x-troff", "ustar" => "application/x-ustar", "src" => "application/x-wais-source", "zip" => "application/zip", "au" => "audio/basic", "snd" => "audio/basic", "mid" => "audio/x-midi", "midi" => "audio/midi", "kar" => "audio/midi", "mp2" => "audio/x-mpeg", "mpa" => "audio/mpeg", "mpg" => "video/mpeg", "mpga" => "audio/mpeg", "mp3" => "audio/x-mpegurl", "aif" => "audio/x-aiff", "aiff" => "audio/x-aiff", "aifc" => "audio/x-aiff", "rpm" => "audio/x-pn-realaudio", "ra" => "audio/x-realaudio", "ram" => "audio/x-pn-realaudio", "rm" => "audio/x-pn-realaudio", "wav" => "audio/x-wav", "gif" => "image/gif", "ief" => "image/ief", "jpeg" => "image/jpeg", "jpg" => "image/jpeg", "jpe" => "image/jpeg", "png" => "image/png", "tiff" => "image/tiff", "tif" => "image/tiff", "ras" => "image/x-cmu-raster", "pnm" => "image/x-portable-anymap", "pbm" => "image/x-portable-bitmap", "pgm" => "image/x-portable-graymap", "ppm" => "image/x-portable-pixmap", "rgb" => "image/x-rgb", "xbm" => "image/x-xbitmap", "xpm" => "image/x-xpixmap", "xwd" => "image/x-xwindowdump", "igs" => "model/iges", "iges" => "model/iges", "msh" => "model/mesh", "mesh" => "model/mesh", "silo" => "model/mesh", "wrl" => "model/vrml", "vrml" => "model/vrml", "css" => "text/css", "html" => "text/html", "htm" => "text/html", "txt" => "text/plain", "rtx" => "text/richtext", "tsv" => "text/tab-separated-values", "etx" => "text/x-setext", "sgml" => "text/x-sgml", "sgm" => "text/x-sgml", "xml" => "text/xml", "dtd" => "text/xml", "mpeg" => "video/mpeg", "mpe" => "video/mpeg", "qt" => "video/quicktime", "mov" => "video/quicktime", "asf" => "video/x-ms-asf", "asx" => "video/x-ms-asf", "avi" => "video/x-msvideo", "movie" => "video/x-sgi-movie", "nieznny" => "applica/octet-stre" ); if ($mime[strtolower($ext)] == "") return "application/".strtolower($ext); else return $mime[strtolower($ext)]; } function dodaj_zalacznik($tmpfile,$name,$ext) { $fd = @fopen($tmpfile,'r'); if(!$fd) return(''); $bin = fread($fd,filesize($tmpfile)); fclose($fd); $att = "Content-Type: ".$this->get_mime($ext).'; name="'.$name.'";'."\n"; $att .= "Content-Transfer-Encoding: base64\n"; $att .= "Content-Disposition: attachment\n"; $att .= "Content-ID: <".$name.">"; // src="cid:$name" $att .= "\n"; $att .= base64_encode($bin)."\n"; $att .= "--".$this->bo."\n"; $this->zalaczniki .= $att; } function dodaj_zalacznik2($tmpfile,$name,$ext) { $fd = fopen($tmpfile,'r'); if(!$fd) return (''); $bin = fread($fd,filesize($tmpfile)); fclose($fd); $att = "Content-Type: ".$this->get_mime($ext).'; name="'.$name.'";'."\n"; $att .= "Content-Transfer-Encoding: base64\n"; $att .= "Content-Disposition: attachment; filename=".$name."\n\n"; //$att .= "Content-Disposition: attachment\n"; //$att .= "Content-Transfer-Encoding: base64\n"; //$att .= "Content-ID: <".$name.">"; // src="cid:$name" //$att .= "\n"; //$att .= $bin."\n"; $att .= chunk_split(base64_encode($bin)."\n"); //$att .= "--".$this->bo."\n"; //$att .= "Content-Type: multipart/alternative\n"; $this->zalaczniki .= $att; } function NowaWiadomosc($nadawca, $temat, $tresc) { $this->adresat = $adresat; $this->nadawca = $nadawca; $this->temat = $temat; $this->tresc = $tresc; $this->ustawione = true; $this->bo = "X----".uniqid(rand()); } function Wyslij() { global $Ustawienia; $naglowek = "
"; $stopka = "
"; $this->tresc = $naglowek.$this->tresc.$stopka; $naglowek = "From: ".$this->nadawca."\n"; $naglowek.="MIME-Version: 1.0\n"; $naglowek.="Content-Type: multipart/mixed; boundary=".$this->bo." \n"; $naglowek.="Content-Transfer-Encoding: 7bit\n"; $naglowek.= "Reply-To: ".$this->nadawca."\n\n"; $wiadomosc = "This is a MIME Encoded Message\n\n"; $wiadomosc .= "--".$this->bo."\n"; $wiadomosc .= "MIME-Version: 1.0\n"; $wiadomosc .= "Content-Type: text/html; charset=iso-8859-2\n"; $wiadomosc .= "Content-Transfer-Encoding: 7bit\n\n"; $wiadomosc .= $this->tresc."\n\n"; $wiadomosc .= "--".$this->bo."\n"; $wiadomosc .= $this->zalaczniki; //print nl2br($naglowek.$wiadomosc); die; return mail($this->adresat, $this->temat, $wiadomosc, $naglowek ); } function WyslijNaAdres($adresat){ $this->adresat = $adresat; $this->Wyslij(); } function WyslijDoWszystkichKlientow() { global $uzytkownicy; $kli = $uzytkownicy->wszyscyDoRozsylania(); foreach( $kli as $obj ) $this->WyslijDoKlienta( $obj->get_id() ); } function WyslijDoKlienta($k_id) { //if( !$this->ustawione ) return 0; global $uzytkownicy; $kli = $uzytkownicy->klient($k_id); $this->adresat = $kli->get_email(); return $this->Wyslij(); } } $Mail = new CMail; class CMail2 { var $adresat; var $nadawca; var $tresc; var $temat; var $adres_zwrotny; var $ustawione; var $return_path; var $zalaczniki; var $obrazki; var $bo; var $bo1; function CMail2() { $this->bo = "X----".uniqid(rand()); $this->bo1 = "X----".uniqid(rand()); $this->zalaczniki = ""; $this->obrazki = ""; } function get_mime($ext) { $mime = array ( "mdf" => "application/access", "xls" => "application/excel", "pfr" => "application/font-tdpfr", "spl" => "application/futuresplash", "hep" => "application/hep", "wks" => "application/lotus-123", "hqx" => "application/mac-binhex40", "cpt" => "application/mac-compactpro", "ppt" => "application/powerpoint", "doc" => "application/msword", "bin" => "application/octet-stream", "dms" => "application/octet-stream", "lha" => "application/octet-stream", "lzh" => "application/octet-stream", "exe" => "application/octet-stream", "class" => "application/octet-stream", "oda" => "application/oda", "pm5" => "application/pagemaker", "pt5" => "application/pagemaker", "pm" => "application/pagemaker", "pdf" => "application/pdf", "ai" => "application/postscript", "eps" => "application/postscript", "ps" => "application/postscript", "rtf" => "application/rtf", "smi" => "application/smil", "smil" => "application/smil", "sml" => "application/smil", "tbk" => "application/toolbook", "wp" => "application/wordperfect", "wp5" => "application/wordperfect5.1", "wp6" => "application/wordperfect6.1", "wpd" => "application/wordperfectd", "bcpio" => "application/x-bcpio", "vcd" => "application/x-cdlink", "cpio" => "application/x-cpio", "csh" => "application/x-csh", "dcr" => "application/x-director", "dir" => "application/x-director", "dxr" => "application/x-director", "dvi" => "application/x-dvi", "gtar" => "application/x-gtar", "hdf" => "application/x-hdf", "ica" => "application/x-ica", "js" => "application/x-javascript", "skp" => "application/x-koan", "skd" => "application/x-koan", "skt" => "application/x-koan", "skm" => "application/x-koan", "latex" => "application/x-latex", "mif" => "application/x-mif", "nc" => "application/x-netcdf", "cdf" => "application/x-netcdf", "sh" => "application/x-sh", "shar" => "application/x-shar", "swf" => "application/x-shockwave-flash", "sav" => "application/x-spss", "spp" => "application/x-spss", "sbs" => "application/x-spss", "sps" => "application/x-spss", "spo" => "application/x-spss", "sit" => "application/x-stuffit", "sv4cpio" => "application/x-sv4cpio", "sv4crc" => "application/x-sv4crc", "tar" => "application/x-tar", "tcl" => "application/x-tcl", "tex" => "application/x-tex", "texinfo" => "application/x-texinfo", "texi" => "application/x-texinfo", "man" => "application/x-troff-man", "me" => "application/x-troff-me", "ms" => "application/x-troff-ms", "t" => "application/x-troff", "tr" => "application/x-troff", "roff" => "application/x-troff", "ustar" => "application/x-ustar", "src" => "application/x-wais-source", "zip" => "application/zip", "au" => "audio/basic", "snd" => "audio/basic", "mid" => "audio/x-midi", "midi" => "audio/midi", "kar" => "audio/midi", "mp2" => "audio/x-mpeg", "mpa" => "audio/mpeg", "mpg" => "video/mpeg", "mpga" => "audio/mpeg", "mp3" => "audio/x-mpegurl", "aif" => "audio/x-aiff", "aiff" => "audio/x-aiff", "aifc" => "audio/x-aiff", "rpm" => "audio/x-pn-realaudio", "ra" => "audio/x-realaudio", "ram" => "audio/x-pn-realaudio", "rm" => "audio/x-pn-realaudio", "wav" => "audio/x-wav", "gif" => "image/gif", "ief" => "image/ief", "jpeg" => "image/jpeg", "jpg" => "image/jpeg", "jpe" => "image/jpeg", "png" => "image/png", "tiff" => "image/tiff", "tif" => "image/tiff", "ras" => "image/x-cmu-raster", "pnm" => "image/x-portable-anymap", "pbm" => "image/x-portable-bitmap", "pgm" => "image/x-portable-graymap", "ppm" => "image/x-portable-pixmap", "rgb" => "image/x-rgb", "xbm" => "image/x-xbitmap", "xpm" => "image/x-xpixmap", "xwd" => "image/x-xwindowdump", "igs" => "model/iges", "iges" => "model/iges", "msh" => "model/mesh", "mesh" => "model/mesh", "silo" => "model/mesh", "wrl" => "model/vrml", "vrml" => "model/vrml", "css" => "text/css", "html" => "text/html", "htm" => "text/html", "txt" => "text/plain", "rtx" => "text/richtext", "tsv" => "text/tab-separated-values", "etx" => "text/x-setext", "sgml" => "text/x-sgml", "sgm" => "text/x-sgml", "xml" => "text/xml", "dtd" => "text/xml", "mpeg" => "video/mpeg", "mpe" => "video/mpeg", "qt" => "video/quicktime", "mov" => "video/quicktime", "asf" => "video/x-ms-asf", "asx" => "video/x-ms-asf", "avi" => "video/x-msvideo", "movie" => "video/x-sgi-movie", "nieznny" => "applica/octet-stre" ); if ($mime[strtolower($ext)] == "") return "application/".strtolower($ext); else return $mime[strtolower($ext)]; } function dodaj_zalacznik($tmpfile,$name,$ext) { $fd = fopen($tmpfile,'r'); if(!$fd) return (''); $bin = fread($fd,filesize($tmpfile)); fclose($fd); $att = "Content-Type: ".$this->get_mime($ext).'; name="'.$name.'";'."\n"; $att .= "Content-Transfer-Encoding: base64\n"; $att .= "Content-Disposition: attachment; filename=".$name."\n\n"; //$att .= "Content-Disposition: attachment\n"; //$att .= "Content-Transfer-Encoding: base64\n"; //$att .= "Content-ID: <".$name.">"; // src="cid:$name" //$att .= "\n"; //$att .= $bin."\n"; $att .= chunk_split(base64_encode($bin)."\n"); $att .= "--".$this->bo."\n"; //$att .= "--".$this->bo."\n"; //$att .= "Content-Type: multipart/alternative\n"; $this->zalaczniki .= $att; } function dodaj_obrazek($tmpfile,$name,$ext) { $fd = fopen($tmpfile,'r'); if(!$fd) return (''); $bin = fread($fd,filesize($tmpfile)); fclose($fd); $att = "Content-Type: ".$this->get_mime($ext).";\n"; $att .= "Content-ID: <".$name.">\n"; $att .= "Content-Transfer-Encoding: base64\n\n"; // $att .= "Content-Disposition: attachment; filename=".$tmpfile."\n\n"; //$att .= "Content-Disposition: attachment\n"; //$att .= "Content-Transfer-Encoding: base64\n"; // src="cid:$name" //$att .= "\n"; //$att .= $bin."\n"; $att .= chunk_split(base64_encode($bin)); $att .= "\n--".$this->bo1."--\n"; //$att .= "\n"; //$att .= "--".$this->bo."\n"; //$att .= "Content-Type: multipart/alternative\n"; $this->obrazki .= $att; } function NowaWiadomosc($nadawca, $temat, $tresc) { $this->adresat = $adresat; $this->nadawca = $nadawca; $this->temat = $temat; $this->tresc = $tresc; $this->ustawione = true; $this->bo = "X----".uniqid(rand()); } function Wyslij() { global $Ustawienia; $naglowek = ""; $stopka = ""; $this->tresc = $naglowek.$this->tresc.$stopka; $naglowek = "From: ".$this->nadawca."\n"; $naglowek.= "MIME-Version: 1.0\n"; $naglowek.= "Content-Type: multipart/mixed; boundary=\"".$this->bo."\" \n"; $naglowek.= "Content-Transfer-Encoding: 7bit\n"; $naglowek.= "Reply-To: ".$this->nadawca."\n"; //$naglowek.= "X-Mailer: PHP\n"; $naglowek .= "Sender: ".$this->nadawca."\n\n"; $wiadomosc = "This is a MIME Encoded Message\n"; $wiadomosc .= "--".$this->bo."\n"; $wiadomosc .="Content-Type: multipart/related; boundary=\"".$this->bo1."\" \n\n"; $wiadomosc .= "--".$this->bo1."\n"; $wiadomosc .= "Content-Type: text/html; charset=iso-8859-2\n"; $wiadomosc .= "Content-Transfer-Encoding: 7bit\n\n"; $wiadomosc .= $this->tresc."\n\n"; $wiadomosc .= "--".$this->bo1."\n"; $wiadomosc .= $this->obrazki; //$wiadomosc .= "--".$this->bo."\n"; //$wiadomosc .= $this->zalaczniki; $wiadomosc .= "--".$this->bo."--\n"; return mail($this->adresat, $this->temat, $wiadomosc, $naglowek ); } function WyslijNaAdres($adresat){ $this->adresat = $adresat; $this->Wyslij(); } } $Mail2 = new CMail2; ?> className) ; } } //////////////////////////////////////////////////////////////////////////// // CategoryNode - DEFINE ONE MENU ITEM / NODE //////////////////////////////////////////////////////////////////////////// class CategoryNode { function CategoryNode($cat) { $this->category = $cat ; } public $Kategorie ; public $hasChild ; public $childArray = Array() ; } //////////////////////////////////////////////////////////////////////////// // SuperMenu - DEFINE ONE COMPLETE MENU //////////////////////////////////////////////////////////////////////////// // WARNING! To work it needs DBAccees.php and CTable etc. // This class operate only on database, creates menuNode and more and more class SuperMenuDB extends CTable { protected $className = "SuperMenuDB" ; public function toString() { echo("Instance of: " . $this->className) ; } // contain all 0 level nodes public $rootNode ; // represent string that contains HTML list. It's used by CreateList function private $listString ; ////////// constructor ///////// function SuperMenuDB() { $this->tableName = "kategorie_produktow"; $this->tablePrefix = "kp" ; /* $this->table_name = "kategorie_produktow"; $this->table_prefix = "kp"; $this->record_class = "CKategoria";*/ } // help function. Read one category with parentId and write it to array // prevent killing the server private $prevent = 0; private function ReadOneCategoryDB($parentId, &$childArray, &$hasChild ) { // save mechanizm if($this->prevent++ > 1000) { echo "recursive linite riched. Now script shall die..." ; die() ; } // 999999 - bezKategorii category $Cat = $this->wybierz("where kp_kp_id=$parentId and kp_id<> 999999 order by kp_pozycja ASC, kp_nazwa ASC"); $count = 0 ; $menuArray ; foreach($Cat as $index => $value) { $catNode = new CategoryNode($value) ; $tempChildArray; $temphasChild ; $id = $catNode->category->get_id() ; $this->ReadOneCategoryDB($catNode->category->get_id(), $tempChildArray, $temphasChild ) ; $catNode->childArray = $tempChildArray ; $catNode->hasChild = $temphasChild ; $menuArray[$index] = $catNode ; $count++ ; } if($count > 0) { $childArray = $menuArray ; $hasChild = true ; } else { $childArray = null ; $hasChild = false ; } } // read menu from database and fill menuArray. // param1: what category should be root, deafatul 0 protected function ReadFromDB($k_id = 0) { $this->rootNode = new CategoryNode($k_id) ; global $Kategorie ; $cat = $Kategorie->getCategory($k_id) ; $tempChildArray; $temphasChild ; $this->ReadOneCategoryDB($k_id, $tempChildArray, $temphasChild ) ; $this->rootNode->childArray = $tempChildArray; $this->rootNode->hasChild = $temphasChild ; return $menuArray; } } //////////////////////////////////////////////////////////////////////////// // SuperMenuZaplecze - DEFINE ONE COMPLETE0 HTML MENU - TREE //////////////////////////////////////////////////////////////////////////// // This menu is designeg for zaplecze and has tree form // for proper work it needs js function tree() somewhere in document // before call CreateList() following property should be filled: // itemLink: link text for zmie // linkClass: class for "zmie" span // nodeClass: class for
  • nodes // leafClass: class for
  • leaf nodes class SuperMenuZaplecze extends SuperMenuDB { // write ul list public $itemLink, $linkClass, $nodeClass, $leafClass ; public function CreateList() { $this->ReadFromDB(-1) ; $this->listString = "" ; $this->WriteOneNode($this->rootNode->childArray, "id=\"tree0\"" ) ; return $this->listString ; } // write one