Advertisement
hejmus

Untitled

Mar 7th, 2014
79
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 30.99 KB | None | 0 0
  1. <?php
  2. session_start();
  3.  
  4.  
  5. $error = 0;
  6. $info = 0;
  7.  
  8. $blad_pomocniczy = 0;
  9. $mod = array();
  10. $akcje= array();
  11. $akcje_db = array();
  12. $moduly = array(
  13.                
  14.                
  15.         'news'    => array( 'path' => 'news.php',
  16.                                                         'activ' =>1),
  17.                                                        
  18.         'gallery' => array( 'path' => 'gallery.php',
  19.                                                         'activ' =>1),
  20.                                                        
  21.         'content' => array( 'path' => 'content.php',
  22.                                                         'activ' =>1)                                                       
  23.                                  
  24.                                  
  25.                 );
  26.  
  27.  
  28.  
  29.  
  30. require_once('phpClasses/impl.php');
  31. require_once 'phpClasses/modules/login.php';
  32.  
  33.  
  34.     function dbuj($el) #czyli przygotuj do bazy danych itp
  35.     {
  36.       return mb_strtolower(strip_tags(trim($el)), 'UTF-8');
  37.     }
  38.     function urluj($sm)
  39.     {
  40.      
  41.         # CONTENT
  42.         $w = ContentPeer::doSelect(new Criteria());
  43.         foreach($w as $k)
  44.         {
  45.             if(strlen(trim($k->getUrl())) == 0)
  46.               $nazwa = $k->getName();
  47.             else
  48.               $nazwa = $k->getUrl();
  49.             $tab_C[$k->getIdcontent()] = string2filename($nazwa);
  50.            
  51.         }
  52.        
  53.         $sm->assign('content', $tab_C);
  54.        
  55.         # Photos
  56.         $w = PhotcatPeer::doSelect(new Criteria());
  57.         foreach($w as $k)
  58.         {
  59.  
  60.             $nazwa = $k->getName();
  61.             $tab_P[$k->getIdphotcat()] = string2filename($nazwa);
  62.            
  63.         }
  64.        
  65.         $sm->assign('photo', $tab_P);
  66.        
  67.        
  68.         $w = NewsPeer::doSelect(new Criteria());
  69.         foreach($w as $k)
  70.         {
  71.  
  72.             $nazwa = $k->getTitle();
  73.             $tab_N[$k->getIdnews()] = string2filename($nazwa);
  74.            
  75.         }
  76.        
  77.         $sm->assign('news', $tab_N);       
  78.        
  79.                
  80.        
  81.         $s1 = $sm->fetch('htaccess.tpl');
  82.         file_put_contents('../.htaccess', $s1);
  83.        
  84.         $s2 = $sm->fetch('filtr.tpl');
  85.         file_put_contents('../filtr.log', $s2);
  86.     }
  87.    
  88.    
  89.    
  90.    
  91.                function usun_f($id)
  92.                    {
  93.                      $tab = array(".jpg", ".gif", ".png");
  94.                      foreach($tab as $k)
  95.                      {
  96.                        if(file_exists('../galeria/d/'.$id.$k))
  97.                        {
  98.                          //chmod('../galeria/d/'.$id.$k, 0777);
  99.                          unlink('../galeria/d/'.$id.$k);
  100.                          //chmod('../galeria/m/'.$id.$k, 0777);
  101.                          unlink('../galeria/m/'.$id.$k);   
  102.                        }
  103.                      }
  104.                    }
  105.                    
  106.                    function spr_sciezke($id)
  107.                    {
  108.                        if(file_exists('../galeria/loga/'.$id.'.jpg'))
  109.                        {
  110.                          $sciezka = $id.'.jpg';                  
  111.                          
  112.                        }
  113.                        else if(file_exists('../galeria/loga/'.$id.'.gif'))
  114.                        {
  115.                           $sciezka = $id.'.gif';
  116.                        }
  117.                        else if(file_exists('../galeria/loga/'.$id.'.png'))
  118.                        {
  119.                          $sciezka = $id.'.png';
  120.                        }
  121.                        
  122.                        return $sciezka;
  123.                    }
  124.                    
  125.                  function OrderNo()
  126.                  {
  127.                       $cx = new Criteria();
  128.                       $cx->addDescendingOrderByColumn(CatContentPeer::ORDER_NO);
  129.                       $cx->setLimit(1);
  130.                      
  131.                       $wx = CatContentPeer::doSelect($cx);
  132.                      
  133.                       if(count($wx) == 0)
  134.                         $order_no = 1;
  135.                       else
  136.                         $order_no = $wx[0]->getOrderNo() + 1;
  137.                        
  138.                       return $order_no;
  139.                  }  
  140.  
  141.  
  142. foreach($moduly as $k=>$v)
  143. {
  144.  
  145.    if($v['activ'] == 1)
  146.    {
  147.       $mod[] = $k;
  148.       require_once 'phpClasses/modules/'.$v['path'];
  149.    }
  150.    
  151.      
  152. }
  153. //require_once('phpClasses/modules/login.php');
  154.  
  155. if($action == 2)
  156. {
  157.  
  158.     $action = 3; // strona bledu w standardzie
  159.      
  160.     if(count($_GET) == 0)
  161.     $action = 4;
  162.  
  163.  
  164.     $akcje[] = 11; # news
  165.     $akcje[] = 21; #
  166.     $akcje[] = 61; #
  167.    
  168.     $akcje[] = 12; # photos
  169.     $akcje[] = 22; #
  170.    $akcje[] = 32; #
  171.     $akcje[] = 42; #
  172.    
  173.     $akcje[] = 13; # content *
  174.     $akcje[] = 23; #  *
  175.     $akcje[] = 43; #   
  176.     $akcje[] = 173; # dod. kategorii
  177.     $akcje[] = 193; # dod. str. do kategorii
  178.     $akcje[] = 213; # ustaw kolejnosc
  179.    
  180.     $akcje[] = 14; #LOGA
  181.    
  182.  
  183.     #################
  184.    
  185.     $akcje_db[] = 41; # news
  186.     $akcje_db[] = 51; #
  187.     $akcje_db[] = 71; #
  188.    
  189.     $akcje_db[] = 32; # photos
  190.     $akcje_db[] = 52;
  191.     $akcje_db[] = 62;  
  192.     $akcje_db[] = 72;
  193.     $akcje_db[] = 82;
  194.     $akcje_db[] = 92;
  195.     $akcje_db[] = 102;
  196.    
  197.     $akcje_db[] = 33; # content *
  198.     $akcje_db[] = 53;
  199.     $akcje_db[] = 63;
  200.     $akcje_db[] = 73;  
  201.     $akcje_db[] = 183; # dod. nowej kategorii  
  202.     $akcje_db[] = 203; # dod. nowej str. do kategorii  
  203.     $akcje_db[] = 663; 
  204.     $akcje_db[] = 223; 
  205.    
  206.     $akcje_db[] = 24;
  207.     $akcje_db[] = 34;
  208.  
  209.    
  210.    
  211.     if (                                                   //
  212.         isset($_GET['id']) &&                              //  zaawansowana walidacja zmiennych
  213.         str_ievpi($_GET['id']) &&                          //  w celu ochrony przed manipulacja.
  214.         in_array($_GET['id'], $akcje_db)                   //
  215.        )                                                   //
  216.     {
  217.     switch($_GET['id'])
  218.     {
  219.        case 41:
  220.        
  221.        if($_POST['id'] != "" && $_POST['dzien'] != "" && $_POST['rok'] != "" && $_POST['miesiac'] != ""
  222.           &&  $_POST['title'] != "" && $_POST['content'] != "")
  223.        {
  224.        
  225.       /*   if(preg_match('/^[0-3][0-9]$/i', $_POST['dzien']) == false)
  226.            $blad_pomocniczy++;
  227.           else
  228.           {
  229.             if($_POST['dzien']<32 && $_POST['dzien']>0) {} else $blad_pomocniczy++;
  230.           }
  231.            
  232.          if(preg_match(' /^[0-1][0-9]$/i', $_POST['miesiac']) == false)
  233.            $blad_pomocniczy++;         
  234.           else
  235.           {
  236.             if($_POST['miesiac']<13 && $_POST['miesiac']>0) {} else $blad_pomocniczy++;
  237.           }        
  238.          if(preg_match('/^2[0-9]{3}$/i', $_POST['rok']) == false)
  239.            $blad_pomocniczy++;         
  240.  
  241.                  
  242.          if($blad_pomocniczy == 0)
  243.          {
  244.          */
  245.              $obj = new Aktualnosci();
  246.              if(!$obj->upgrAktualnosc($_POST['id'], $_POST['dzien'], $_POST['miesiac'], $_POST['rok'],
  247.                  trim($_POST['title']), $_POST['content'])) {
  248.               $error++;
  249.               $errM = 4;
  250.              
  251.              
  252.               }
  253.               else
  254.               {
  255.                  //urluj($s);  
  256.                  $info = 12;
  257.                  $_GET['id'] = '11';
  258.               }
  259.          /* }
  260.           else {
  261.             $s->assign('e_data', true);
  262.             $s->assign('valid_e', true);
  263.           } */
  264.                
  265.        }
  266.        else
  267.        {
  268.          if(trim($_POST['title']) == "")
  269.          {
  270.            $s->assign('e_title', true);
  271.          }
  272.          if(trim($_POST['dzien']) == "" || trim($_POST['miesiac']) == "" || trim($_POST['rok']) == "")
  273.          {
  274.            $s->assign('e_data', true);
  275.          }
  276.          if(trim($_POST['content']) == "")
  277.          {
  278.            $s->assign('e_content', true);
  279.          }               
  280.          
  281.          $s->assign('valid_e', true);
  282.          
  283.          $s->assign('id', $_POST['id']);
  284.          $s->assign('date2', $_POST['date2']);
  285.          $s->assign('title2', $_POST['title2']);
  286.          $s->assign('content2', $_POST['content2']);
  287.          
  288.  
  289.          $s->assign('title', $_POST['title']);
  290.          $s->assign('content', $_POST['content']);
  291.          
  292.          $s->assign('data', data());
  293.          $s->assign('powtorz', true);
  294.          $s->assign('dzien', $_POST['dzien']);
  295.          $s->assign('miesiac', $_POST['miesiac']);
  296.          $s->assign('rok', $_POST['rok']);  
  297.          
  298.          $action =  '21';
  299.          $s->assign('id', $_POST['id']);
  300.          
  301.          
  302.        }
  303.        
  304.        
  305.        
  306.        
  307.        
  308.  
  309.        break;
  310.        case 51:
  311.         if($_POST['id'] != "")
  312.         {
  313.           $obj = new Aktualnosci();
  314.           if(!$obj->delAkt($_POST['id'])){
  315.               $error++;
  316.               $errM = 5;
  317.              
  318.           }
  319.           else
  320.           {
  321.           //urluj($s); 
  322.           $_GET['id'] = '11';
  323.           }  
  324.         }
  325.        
  326.        
  327.        break;
  328.        case 71:
  329.      
  330.        if($_POST['dzien'] != "" && $_POST['rok'] != "" && $_POST['miesiac'] != ""
  331.           &&  $_POST['title'] != "" && $_POST['content'] != "")
  332.        {
  333.        
  334.         /* if(preg_match('/^[0-3][0-9]$/i', $_POST['dzien']) == false)
  335.            $blad_pomocniczy++;
  336.           else
  337.           {
  338.             if($_POST['dzien']<32 && $_POST['dzien']>0) {} else $blad_pomocniczy++;
  339.           }
  340.            
  341.          if(preg_match(' /^[0-1][0-9]$/i', $_POST['miesiac']) == false)
  342.            $blad_pomocniczy++;         
  343.           else
  344.           {
  345.             if($_POST['miesiac']<13 && $_POST['miesiac']>0) {} else $blad_pomocniczy++;
  346.           }        
  347.          if(preg_match('/^2[0-9]{3}$/i', $_POST['rok']) == false)
  348.             $blad_pomocniczy++;        
  349.  
  350.                
  351.          if($blad_pomocniczy == 0)
  352.          {
  353.         */
  354.          
  355.              $obj = new Aktualnosci();
  356.              if(!$obj->saveAktualnosc($_POST['dzien'], $_POST['miesiac'], $_POST['rok'],
  357.                  trim($_POST['title']), $_POST['content'])) {
  358.               $error++;
  359.               $errM = 4;
  360.              
  361.               }else {
  362.                    //urluj($s);
  363.                 }
  364.              
  365.              
  366.         /*  }
  367.           else {
  368.            
  369.             $s->assign('e_data', true);
  370.             $s->assign('valid_e', true);
  371.           }*/
  372.                
  373.        }
  374.        else
  375.        {
  376.          if(trim($_POST['title']) == "")
  377.          {
  378.            $s->assign('e_title', true);
  379.          }
  380.          if(trim($_POST['dzien']) == "" || trim($_POST['miesiac']) == "" || trim($_POST['rok']) == "")
  381.          {
  382.            $s->assign('e_data', true);
  383.          }
  384.          if(trim($_POST['content']) == "")
  385.          {
  386.            $s->assign('e_content', true);
  387.          }               
  388.          $blad_pomocniczy+=1;
  389.          $s->assign('valid_e', true);
  390.        }
  391.        
  392.        if( $blad_pomocniczy >0)
  393.        {
  394.         $action = '61';
  395.        
  396.          $s->assign('date', $_POST['date']);
  397.          $s->assign('title', $_POST['title']);
  398.          $s->assign('content', $_POST['content']);
  399.          
  400.          $s->assign('data', data());
  401.          $s->assign('powtorz', true);
  402.          $s->assign('dzien', $_POST['dzien']);
  403.          $s->assign('miesiac', $_POST['miesiac']);
  404.          $s->assign('rok', $_POST['rok']);     
  405.        
  406.        }
  407.        else
  408.         $info = 13;
  409.         $_GET['id'] = '11';
  410.        
  411.        break;  
  412.        case 32:
  413.         if(count($_POST) == 1)
  414.         {
  415.           if(strlen($_POST['cat_name']) >0 && strlen($_POST['cat_name']) < 151)
  416.           {
  417.              $nazwa_cat = trim($_POST['cat_name']);
  418.              
  419.              $c = new Criteria();
  420.              $c->setIgnoreCase(true);
  421.              $c->add(PhotcatPeer::NAME, $nazwa_cat);
  422.              
  423.              $w = PhotcatPeer::doSelect($c);
  424.              if(count($w) == 0)
  425.              {
  426.                try
  427.                {
  428.                    $obj = new Photcat();
  429.                    $obj->setName(strip_tags(trim($nazwa_cat)));
  430.                    $obj->save();
  431.                    
  432.                    //urluj($s);
  433.                    
  434.                    $info = 4;
  435.                    $_GET['id'] = '12';
  436.                }
  437.                catch (PropelException $e)
  438.                {  
  439.                  $errM = 6;
  440.                  $action = 22;
  441.                }
  442.                
  443.              }
  444.              else
  445.              {
  446.                $errM = 7;
  447.                $s->assign('repeat', $_POST['cat_name']);
  448.                $_GET['id'] = '22';
  449.              }
  450.              
  451.           }
  452.           else{
  453.            
  454.             $errM = 8;
  455.            
  456.             $_GET['id'] = '22';
  457.             }
  458.         }
  459.        break;
  460.        case 52:
  461.         if(count($_POST) == 2)
  462.         {
  463.           if(strlen($_POST['cat_name']) >0 && strlen($_POST['cat_name']) < 151)
  464.           {
  465.              $nazwa_cat = trim($_POST['cat_name']);
  466.              
  467.              $c = new Criteria();
  468.              $c->setIgnoreCase(true);
  469.              $c->add(PhotcatPeer::NAME, $nazwa_cat);
  470.              
  471.              $w = PhotcatPeer::doSelect($c);
  472.              if(count($w) == 0 )
  473.              {
  474.                try
  475.                {
  476.                    $obj = PhotcatPeer::retrieveByPK($_POST['id']);
  477.                    $obj->setName(strip_tags(trim($nazwa_cat)));
  478.                    $obj->save();
  479.                    
  480.                
  481.                      //urluj($s);
  482.                    $info = 3;
  483.                    $_GET['id'] = '42';
  484.                    $_GET['id2'] = $_POST['id'];
  485.                }
  486.                catch (PropelException $e)
  487.                {  
  488.                  $errM = 6;
  489.                   $_GET['id'] = '42';
  490.                   $_GET['id2'] = $_POST['id'];
  491.                }
  492.                
  493.              }
  494.              else
  495.              {
  496.                $errM = 7;
  497.                
  498.                 $_GET['id'] = '42';
  499.                 $_GET['id2'] = $_POST['id'];   
  500.              }
  501.              
  502.           }
  503.           else{
  504.            
  505.             $errM = 8;
  506.            
  507.              $_GET['id'] = '42';
  508.              $_GET['id2'] = $_POST['id'];
  509.             }
  510.         }
  511.         break;   
  512.         case 62:
  513.         $uploaddir = 'tmp/';
  514.  
  515.             if($_FILES['plik1']['error'] == UPLOAD_ERR_OK){
  516.              
  517.              /* */
  518.            
  519.               $new_name = $uploaddir.$_FILES['plik1']['name'];
  520.               $temp_name = $_FILES['plik1']['tmp_name'];
  521.               if(move_uploaded_file($temp_name, $new_name)){
  522.              
  523.               $galeria = new Galeria($new_name, $_POST['id']);
  524.               $blad = $galeria->resize_image($new_name, 150, 'm');
  525.               if($blad)
  526.               {
  527.                 $errM = $blad;
  528.               }
  529.               else
  530.               {
  531.                 $blad = $galeria->resize_image($new_name, 800, 'd');
  532.                   if($blad)
  533.                   {
  534.                     $errM = $blad;                 
  535.                   }              
  536.                   $info = 1;
  537.               }
  538.               chmod($new_name, 0777);
  539.               unlink($new_name);
  540.              
  541.              
  542.              
  543.                 $_GET['id']= '42';
  544.                 $_GET['id2']= $_POST['id'];
  545.                
  546.                
  547.               }
  548.               else{
  549.                 $errM = 13;
  550.                 $_GET['id']= '42';
  551.                 $_GET['id2']= $_POST['id'];
  552.               }
  553.             }
  554.             else{
  555.              
  556.               switch($_FILES['plik1']['error']){
  557.                 case UPLOAD_ERR_INI_SIZE  :
  558.                 case UPLOAD_ERR_FORM_SIZE :
  559.                   $errM = 9;
  560.                   break;
  561.                 case UPLOAD_ERR_PARTIAL :
  562.                   $errM = 10;
  563.                   break;
  564.                 case UPLOAD_ERR_NO_FILE :
  565.                  $errM = 11;
  566.                   break;
  567.                 default :
  568.                  $errM = 12;
  569.                  
  570.                  
  571.          
  572.                  
  573.               }
  574.              
  575.                 $_GET['id']= '42';
  576.                 $_GET['id2']= $_POST['id'];    
  577.             }
  578.         break;
  579.         case 72:
  580.           if(count($_GET) == 3)
  581.           {
  582.          
  583.                 $w = PhotoPeer::retrieveByPK($_GET['id3']);
  584.                 PhotoPeer::doDelete($w);
  585.                
  586.                 usun_f($_GET['id3']);
  587.                                        
  588.                 $info = 2;
  589.                 $_GET['id']= '42';
  590.                 $_GET['id2']= $_GET['id2'];                    
  591.           }
  592.         break;
  593.         case 82:
  594.           if(count($_GET) == 2)
  595.           {
  596.                 $c = new Criteria();
  597.                 $c->add(PhotoPeer::IDPHOTCAT, $_GET['id2']);
  598.                
  599.                 $w = PhotoPeer::doSelect($c);
  600.                 foreach($w as $k)
  601.                 {
  602.                     $id = $k->getIdphoto();
  603.                     PhotoPeer::doDelete($k);
  604.                    
  605.                     usun_f($id);
  606.                    
  607.                 }                          
  608.                 $info = 5;
  609.                 $_GET['id']= '42';
  610.                 $_GET['id2']= $_GET['id2'];                
  611.           }
  612.         break;
  613.         case 92:
  614.         if(count($_GET) == 2)
  615.         {
  616.                 $c = new Criteria();
  617.                 $c->add(PhotoPeer::IDPHOTCAT, $_GET['id2']);
  618.                
  619.                 $w = PhotoPeer::doSelect($c);
  620.                 foreach($w as $k)
  621.                 {
  622.                     $id = $k->getIdphoto();
  623.                     PhotoPeer::doDelete($k);
  624.                    
  625.                     usun_f($id);
  626.                 }
  627.                
  628.                 $w2 = PhotcatPeer::retrieveByPK($_GET['id2']);
  629.                 PhotcatPeer::doDelete($w2);
  630.                
  631.                 //urluj($s);   
  632.                 $info = 6;
  633.                 $_GET['id']= '12';
  634.                 $_GET['id2']= $_GET['id2'];                
  635.         }      
  636.         break;
  637.         case 102:
  638.           if(count($_GET) == 1)
  639.           {
  640.                
  641.                 $w = PhotoPeer::doSelect(new Criteria());
  642.                 foreach($w as $k)
  643.                 {
  644.                     $id = $k->getIdphoto();
  645.                     PhotoPeer::doDelete($k);
  646.                    
  647.                     usun_f($id);
  648.                    
  649.                                        
  650.                 }
  651.                
  652.                 $w2 = PhotcatPeer::doSelect(new Criteria());
  653.                 foreach($w2 as $k2)
  654.                  PhotcatPeer::doDelete($k2);
  655.  
  656.                 //urluj($s);   
  657.                 $info = 7;
  658.                 $_GET['id']= '12';
  659.                 $_GET['id2']= $_GET['id2'];                      
  660.           }    
  661.         break;
  662.         case 33:
  663.           if(count($_GET) == 1 && count($_POST) == 3)
  664.           {
  665.             if( strlen(trim($_POST['menu'])) > 0 && strlen(trim($_POST['content'])) > 0 )
  666.             {
  667.                 $c = new Criteria();
  668.                 $c->setIgnoreCase(true);
  669.                 $c->add(CatContentPeer::NAME, $_POST['menu']);
  670.                
  671.                 $w = CatContentPeer::doSelect($c);
  672.                 if(count($w) == 0)
  673.                 {
  674.                
  675.                   #
  676.                   # analiza czy URL zostal wpisany jak tak to spr. czy nie istnieje
  677.                   # sprawdzanie w tabeli content
  678.                   # URL musi byc unikalny na cala aplikacje
  679.                   if(strlen(trim($_POST['url'])) >0)
  680.                   {
  681.                     $c = new Criteria();
  682.                     $c->setIgnoreCase(true);
  683.                     $c->add(ContentPeer::URL, $_POST['url']);
  684.                    
  685.                     $w = ContentPeer::doSelect($c);
  686.                     if(count($w) > 0)
  687.                      $errM = 17;
  688.                     else
  689.                      $url = $_POST['url'];
  690.                   }
  691.                   else
  692.                   {
  693.                     $url = $_POST['menu'];
  694.                   }
  695.                  
  696.                  
  697.                  
  698.                   if($errM == null)
  699.                   {
  700.                     $obj = new CatContent();
  701.                     $obj->setName(strip_tags(trim($_POST['menu'])));
  702.                     //$obj->setUrl(mb_strtolower(trim($_POST['url']), 'UTF-8'));
  703.                     //$obj->setContent(trim($_POST['content']));
  704.                    
  705.                     # ustawienie order_no
  706.                       $order_no = OrderNo();
  707.                    
  708.                     #..
  709.                     $obj->setOrderNo($order_no);
  710.                     $obj->setTree(0);                  
  711.                     $obj->save();
  712.                    
  713.                     #ZAPIS DO CONTENT
  714.                    
  715.                     $obj2 = new Content();
  716.                     $obj2->setIdcat($obj->getId());
  717.                     $obj2->setName(strip_tags(trim($_POST['menu'])));
  718.                     $obj2->setContent($_POST['content']);
  719.                     $obj2->setUrl(strip_tags(mb_strtolower(trim($_POST['url']), 'UTF-8')));
  720.                     $obj2->save();
  721.                    
  722.                     $info = 8; 
  723.                     //urluj($s);             
  724.                     $_GET['id'] = '13';
  725.                   }
  726.                   else
  727.                   {
  728.                    $_GET['id'] = '23';
  729.                    $s->assign('menu', $_POST['menu']);
  730.                    $s->assign('url', $_POST['url']);
  731.                    $s->assign('content', $_POST['content']);                 
  732.                   }
  733.                  
  734.                    
  735.  
  736.                 }
  737.                 else
  738.                 {
  739.                    $errM = 16;
  740.                    $_GET['id'] = '23';
  741.                    $s->assign('menu', $_POST['menu']);
  742.                    $s->assign('url', $_POST['url']);
  743.                    $s->assign('content', $_POST['content']);
  744.                 }
  745.          
  746.             }
  747.             else
  748.             {
  749.               $errM = 15;
  750.               $_GET['id'] = '23';
  751.               $s->assign('menu', $_POST['menu']);
  752.               $s->assign('url', $_POST['url']);
  753.               $s->assign('content', $_POST['content']);          
  754.             }
  755.           }
  756.         break;
  757.         case 53:
  758.           if(count($_GET) == 2 && count($_POST) == 3)
  759.           {
  760.             if( strlen(trim($_POST['menu'])) > 0 && strlen(trim($_POST['content'])) > 0 )
  761.             {
  762.                 $c = new Criteria();
  763.                 $c->setIgnoreCase(true);
  764.                 $c->add(ContentPeer::NAME, strip_tags(trim($_POST['menu'])));
  765.                
  766.                 $w = ContentPeer::doSelect($c);
  767.                 if(count($w) == 0 || (count($w) > 0
  768.                 && mb_strtolower(trim($w[0]->getIdcontent())) == mb_strtolower(trim($_GET['id2']),'UTF-8')))
  769.                 {
  770.                   if(strlen(trim($_POST['url'])) >0)
  771.                   {
  772.                     $c = new Criteria();
  773.                     $c->setIgnoreCase(true);
  774.                     $c->add(ContentPeer::URL, $_POST['url']);
  775.                    
  776.                     $w = ContentPeer::doSelect($c);
  777.                     if(count($w) > 0 &&  $w[0]->getIdcontent() != $_GET['id2'])
  778.                      $errM = 17;
  779.                     else
  780.                      $url = $_POST['url'];
  781.                   }
  782.                   else
  783.                   {
  784.                     $url = $_POST['menu'];
  785.                   }
  786.                  
  787.                   if($errM == null)
  788.                   {
  789.                     $obj = ContentPeer::retrieveByPK($_GET['id2']);
  790.                     $obj->setName(strip_tags(trim($_POST['menu'])));
  791.                     $obj->setUrl(dbuj($_POST['url']));
  792.                     $obj->setContent(trim($_POST['content']));
  793.                    
  794.                     $obj->save();
  795.                     //urluj($s);
  796.                     $info = 9;               
  797.                     $_GET['id'] = '13';
  798.                   }
  799.                   else
  800.                   {
  801.                  
  802.                    $action = '43';
  803.                    $s->assign('menu', $_POST['menu']);
  804.                    $s->assign('url', $_POST['url']);
  805.                    $s->assign('content', $_POST['content']);
  806.                    
  807.                    $s->assign('id', $_GET['id2']);               
  808.                   }
  809.                  
  810.                    
  811.  
  812.                 }
  813.                 else
  814.                 {
  815.                    $errM = 16;
  816.                    $action = '43';
  817.                    $s->assign('menu', $_POST['menu']);
  818.                    $s->assign('url', $_POST['url']);
  819.                    $s->assign('content', $_POST['content']);
  820.                    $s->assign('id', $_GET['id2']); 
  821.                 }
  822.          
  823.             }
  824.             else
  825.             {
  826.               $errM = 15;
  827.               $action = '43';
  828.               $s->assign('menu', $_POST['menu']);
  829.               $s->assign('url', $_POST['url']);
  830.               $s->assign('content', $_POST['content']);
  831.               $s->assign('id', $_GET['id2']);            
  832.             }
  833.           }
  834.         break;
  835.         case 63:
  836.           if(count($_GET) ==2)
  837.           {
  838.             $tak = 0; // narazie nie kasujemy calej kategorii
  839.            
  840.             $w = ContentPeer::retrieveByPK($_GET['id2']);
  841.             $kat = $w->getIdcat();
  842.               $c = new Criteria();
  843.               $c->add(ContentPeer::IDCAT, $kat);
  844.              
  845.               $wx = ContentPeer::doSelect($c);
  846.               if(count($wx) == 1) #deletuj cala kategorie
  847.               {
  848.                  $dow = CatContentPeer::retrieveByPK($kat);
  849.                  if($dow->getTree() == 0)
  850.                  $tak = 1;
  851.               }
  852.              
  853.            
  854.             ContentPeer::doDelete($w);
  855.            
  856.             if($tak == 1)
  857.             {
  858.                $doKasacji = CatContentPeer::retrieveByPK($kat);
  859.                CatContentPeer::doDelete($doKasacji);
  860.             }
  861.            
  862.            
  863.             //urluj($s);   
  864.             $_GET['id'] = '13';
  865.             $info = 10;
  866.           }
  867.         break;
  868.         case 663:
  869.         if(count($_GET) == 2)
  870.         {
  871.        
  872.        
  873.            $c = new Criteria();
  874.            $c->add(ContentPeer::IDCAT, $_GET['id2']);
  875.            
  876.            $w = ContentPeer::doSelect($c);
  877.            foreach($w as $k)  
  878.              ContentPeer::doDelete($k);
  879.              
  880.            $c2 = new Criteria();
  881.            $c2->add(CatContentPeer::ID, $_GET['id2']);
  882.            
  883.            $w2 = CatContentPeer::doSelect($c2);
  884.            foreach($w2 as $k2)  
  885.              CatContentPeer::doDelete($k2);          
  886.         //urluj($s);   
  887.             $_GET['id'] = '13';
  888.             $info = 16;
  889.         }      
  890.         break;
  891.         case 73:
  892.           if(count($_GET) ==1)
  893.           {
  894.             $w = ContentPeer::doSelect(new Criteria());
  895.             foreach($w as $k)
  896.              ContentPeer::doDelete($k);
  897.              
  898.             $w = CatContentPeer::doSelect(new Criteria());
  899.             foreach($w as $k)
  900.              CatContentPeer::doDelete($k);
  901.            
  902.             //urluj($s);   
  903.             $_GET['id'] = '13';
  904.             $info = 11;
  905.           }
  906.         break; 
  907.         case 183:
  908.           if(count($_POST) == 1 && count($_GET) == 1)
  909.           {
  910.             $c = new Criteria();
  911.             $c->setIgnoreCase(true);
  912.             $c->add(CatContentPeer::NAME, dbuj($_POST['name']));
  913.            
  914.             $w = CatContentPeer::doSelect($c);
  915.             if(count($w) == 0)
  916.             {
  917.                $obj = new CatContent();
  918.                $obj->setName(dbuj($_POST['name']));
  919.                $obj->setTree(1);
  920.                $obj->setOrderNo(OrderNo());
  921.                $obj->save();
  922.                
  923.                $info = 14;
  924.                $_GET['id'] = '13';
  925.                
  926.             }
  927.             else
  928.             {
  929.                $errM = 18;
  930.                $s->assign('repeat', $_POST['name']);
  931.                $_GET['id'] = '173';
  932.             }  
  933.           }
  934.         break; 
  935.         case 203:
  936.         if(count($_GET) == 1 && count($_POST) ==4)
  937.         {
  938.           $catId = $_POST['kategoria'];
  939.           $url = dbuj($_POST['url']);
  940.           $c = new Criteria();
  941.           $c->setIgnoreCase(true);
  942.          // $c->add(ContentPeer::IDCAT, $catId);
  943.           $c->add(ContentPeer::NAME, strip_tags(trim($_POST['menu'])) );
  944.          
  945.           $w = ContentPeer::doSelect($c);
  946.           if(count($w) == 0)
  947.           {
  948.             if(strlen($url) > 0)
  949.             {
  950.                  $c2 = new Criteria();
  951.                  $c2->setIgnoreCase(true);
  952.                  $c2->add(ContentPeer::URL, $url);
  953.                  
  954.                  $w2 = ContentPeer::doSelect($c2);
  955.              }
  956.              else
  957.                $w2 = null;
  958.              if(count($w2)==0)
  959.              {
  960.                  
  961.                  $obj = new Content();
  962.                  $obj->setIdcat($catId);
  963.                  $obj->setName(strip_tags(trim($_POST['menu'])));
  964.                  $obj->setContent($_POST['content']);
  965.                  $obj->setUrl($url);
  966.                  
  967.                  $obj->save();
  968.                  //urluj($s);  
  969.                  
  970.                  
  971.                  $info = 15;
  972.                  $_GET['id'] = '13';
  973.              }
  974.              else{
  975.              
  976.              $s->assign('kategoria', $catId);
  977.              $s->assign('menu', $_POST['menu']);
  978.              $s->assign('url', $_POST['url']);
  979.              $s->assign('content', $_POST['content']);               
  980.                  
  981.                  
  982.                  $errM = 20;
  983.                  $_GET['id'] = '193';
  984.              }
  985.           }
  986.           else
  987.           {
  988.              
  989.              $s->assign('kategoria', $catId);
  990.              $s->assign('menu', $_POST['menu']);
  991.              $s->assign('url', $_POST['url']);
  992.              $s->assign('content', $_POST['content']);
  993.              
  994.              $errM = 16;
  995.              $_GET['id'] = '193';
  996.           }      
  997.         }
  998.         break;
  999.         case 223:
  1000.           foreach($_POST as $k=>$v)
  1001.           {
  1002.              $obj = CatContentPeer::retrieveByPK($k);
  1003.              $obj->setOrderNo($v);
  1004.              $obj->save();
  1005.              
  1006.            
  1007.              
  1008.           }
  1009.           $info =        17;   
  1010.           $_GET['id'] = '13';  
  1011.         break;
  1012.         case 24:
  1013.         $uploaddir = 'tmp/';
  1014.  
  1015.             if($_FILES['plik1']['error'] == UPLOAD_ERR_OK){
  1016.              
  1017.              /* */
  1018.              
  1019.              $new_name = $uploaddir.$_FILES['plik1']['name'];
  1020.               $temp_name = $_FILES['plik1']['tmp_name'];
  1021.               if(move_uploaded_file($temp_name, $new_name)){
  1022.              
  1023.               $galeria = new Galeria2($_POST['opis'], $_POST['link']);
  1024.              
  1025.               $blad = $galeria->resize_image($new_name, 80, 'm');
  1026.              
  1027.  
  1028.               chmod($new_name, 0777);
  1029.               unlink($new_name);
  1030.              
  1031.              
  1032.                 $info = 18;
  1033.                 $_GET['id']= '14';
  1034.                
  1035.                
  1036.                
  1037.               }
  1038.               else{
  1039.                 $errM = 13;
  1040.                 $_GET['id']= '14';
  1041.                
  1042.               }
  1043.             }
  1044.             else{
  1045.              
  1046.               switch($_FILES['plik1']['error']){
  1047.                 case UPLOAD_ERR_INI_SIZE  :
  1048.                 case UPLOAD_ERR_FORM_SIZE :
  1049.                   $errM = 9;
  1050.                   break;
  1051.                 case UPLOAD_ERR_PARTIAL :
  1052.                   $errM = 10;
  1053.                   break;
  1054.                 case UPLOAD_ERR_NO_FILE :
  1055.                  $errM = 11;
  1056.                   break;
  1057.                 default :
  1058.                  $errM = 12;
  1059.                  
  1060.                  
  1061.          
  1062.                  
  1063.               }
  1064.              
  1065.                 $_GET['id']= '14';
  1066.                
  1067.             }
  1068.         break; 
  1069.         case 34:
  1070.           if(count($_GET) == 2)
  1071.           {
  1072.            
  1073.             $w = LogaPeer::retrieveByPK($_GET['id2']);
  1074.             $path = '../galeria/loga/'.spr_sciezke($w->getId());
  1075.             LogaPeer::doDelete($w);
  1076.              
  1077.              chmod($path, 0777);
  1078.              unlink($path);
  1079.          
  1080.             $info = 19;
  1081.             $_GET['id'] = '14';
  1082.           }    
  1083.         break; 
  1084.          
  1085.    
  1086.     } // switch
  1087.     } //if  
  1088.    
  1089.     if (                                                   //
  1090.         isset($_GET['id']) &&                              //  zaawansowana walidacja zmiennych
  1091.         str_ievpi($_GET['id']) &&                          //  w celu ochrony przed manipulacja.
  1092.         in_array($_GET['id'], $akcje)                      //
  1093.        )                                                   //
  1094.     {
  1095.     switch($_GET['id'])
  1096.     {
  1097.        case 11:
  1098.          $obj = new Aktualnosci();
  1099.          
  1100.          $s->assign('news', $obj->getAktualnosci());
  1101.          $action = $_GET['id'];
  1102.        break;
  1103.        case 21:
  1104.          $obj = new Aktualnosci();
  1105.          $tab = $obj->getAktualnosc($_GET['id2'],1);
  1106.          
  1107.          $s->assign('id', $tab['id']);
  1108.          $s->assign('date2', $tab['date']);
  1109.          $s->assign('title2', $tab['title']);
  1110.          $s->assign('content2', stripslashes($tab['content']));
  1111.          
  1112.          $s->assign('date', $tab['date']);
  1113.          $s->assign('title', $tab['title']);
  1114.          $s->assign('content', stripslashes($tab['content']));       
  1115.          
  1116.          $s->assign('data', data());
  1117.          $s->assign('dzien', $tab['dzien']);
  1118.          $s->assign('miesiac', $tab['miesiac']);
  1119.          $s->assign('rok', $tab['rok']);
  1120.          $action = $_GET['id'];
  1121.        break;
  1122.        case 61:
  1123.          
  1124.          $s->assign('data', data());
  1125.          
  1126.          $action = $_GET['id'];
  1127.        
  1128.        break;
  1129.        case 12:
  1130.          
  1131.          $w = PhotcatPeer::doSelect(new Criteria());
  1132.          $s->assign('kategorie', $w);      
  1133.        
  1134.          $action = $_GET['id'];
  1135.        break;
  1136.        case 22:
  1137.          $action = $_GET['id'];
  1138.        break;    
  1139.        case 42:
  1140.          $w = PhotcatPeer::retrieveByPK($_GET['id2']);
  1141.          $s->assign('kat', $w);
  1142.          
  1143.          $c = new Criteria();
  1144.          $c->add(PhotoPeer::IDPHOTCAT, $_GET['id2']);
  1145.          
  1146.          $w2 = PhotoPeer::doSelect($c);
  1147.          $zdj = array();
  1148.          $i=0;
  1149.          foreach($w2 as $k)
  1150.          {
  1151.            
  1152.            $n = $k->getIdphoto();
  1153.            if(file_exists('../galeria/d/'.$n.'.jpg'))
  1154.            {
  1155.              $zdj[$i]['n'] = $n.'.jpg';
  1156.              $zdj[$i]['id'] = $k->getIdphoto();
  1157.              $i+=1;
  1158.            }
  1159.            else if(file_exists('../galeria/d/'.$n.'.gif'))
  1160.            {
  1161.              $zdj[$i]['n'] = $n.'.gif';
  1162.              $zdj[$i]['id'] = $k->getIdphoto();
  1163.              $i+=1;
  1164.            }
  1165.            else if(file_exists('../galeria/d/'.$n.'.png'))
  1166.            {
  1167.              $zdj[$i]['n'] = $n.'.png';
  1168.              $zdj[$i]['id'] = $k->getIdphoto();
  1169.              $i+=1;
  1170.            }
  1171.        
  1172.                  
  1173.          }
  1174.          
  1175.  
  1176.          $s->assign('zdj', $zdj);
  1177.          
  1178.          $action = $_GET['id'];
  1179.        break;
  1180.        case 13:
  1181.          $c = new Criteria();
  1182.          $c->addAscendingOrderByColumn(CatContentPeer::ORDER_NO);
  1183.          
  1184.          $w = CatContentPeer::doSelect($c);
  1185.          $tab = array();
  1186.          $i = 0;
  1187.          foreach($w as $k)
  1188.          {
  1189.                if($k->getTree() == 0)
  1190.                {
  1191.                $c2 = new Criteria();
  1192.                $c2->add(ContentPeer::IDCAT, $k->getId());
  1193.                
  1194.                $w2 = ContentPeer::doSelect($c2);
  1195.                
  1196.                    $tab[$i]['tree'] = 0;
  1197.                    $tab[$i]['idcontent'] = $w2[0]->getIdcontent();
  1198.                    $tab[$i]['idcat'] = $w2[0]->getIdcat();
  1199.                    $tab[$i]['name'] = $w2[0]->getName();
  1200.                    $tab[$i]['content'] = $w2[0]->getContent();
  1201.                    $tab[$i]['url'] = $w2[0]->getUrl();
  1202.                }
  1203.                else if($k->getTree() == 1)
  1204.                {
  1205.                $c2 = new Criteria();
  1206.                $c2->add(ContentPeer::IDCAT, $k->getId());
  1207.                
  1208.                $w2 = ContentPeer::doSelect($c2);
  1209.  
  1210.                    $tab[$i]['name'] = $k->getName();
  1211.                    $tab[$i]['tree'] = 1;
  1212.                    $tab[$i]['id'] = $k->getId();
  1213.                    $ii = 0;
  1214.                    if(count($w2) > 0)
  1215.                   {
  1216.                    foreach($w2 as $k2)
  1217.                    {
  1218.                        
  1219.                        $tab[$i]['pod'][$ii]['idcontent'] = $k2->getIdcontent();
  1220.                        $tab[$i]['pod'][$ii]['idcat'] = $k2->getIdcat();
  1221.                        $tab[$i]['pod'][$ii]['name'] = $k2->getName();
  1222.                        $tab[$i]['pod'][$ii]['content'] = $k2->getContent();
  1223.                        $tab[$i]['pod'][$ii]['url'] = $k2->getUrl();    
  1224.                        $ii+=1;      
  1225.                    }
  1226.  
  1227.                 }  else {
  1228.                      $tab[$i]['bez'] = '1';   # brak podstron
  1229.                    }//if
  1230.                }//else
  1231.                else if($k->getTree() == 2)
  1232.                {
  1233.                  $tab[$i]['tree'] = 2;
  1234.                  $tab[$i]['name'] = $k->getName();               
  1235.                }
  1236.            $i+=1;
  1237.          }
  1238.          
  1239.      
  1240.          $s->assign('tree', $tab);
  1241.          $action = $_GET['id'];
  1242.        
  1243.          /*$strony = ContentPeer::doSelect(new Criteria());
  1244.          $s->assign('str', $strony);
  1245.          $action = $_GET['id'];  */  
  1246.        break;
  1247.        case 23:
  1248.          $action = $_GET['id'];
  1249.        break;
  1250.        case 43:
  1251.          $w = ContentPeer::retrieveByPK($_GET['id2']);
  1252.          
  1253.          $s->assign('menu', stripslashes($w->getName()));
  1254.          $s->assign('url', stripslashes($w->getUrl()));
  1255.          $s->assign('content', stripslashes($w->getContent()));              
  1256.          $s->assign('id', $_GET['id2']);
  1257.          
  1258.          $action = $_GET['id'];
  1259.        break;
  1260.        case 173:
  1261.          $action = $_GET['id'];
  1262.        break;
  1263.        case 193:
  1264.         $c = new Criteria();
  1265.         $c->add(CatContentPeer::TREE, 1);
  1266.         $c->addAscendingOrderByColumn(CatContentPeer::NAME);
  1267.        
  1268.         $w = CatContentPeer::doSelect($c);
  1269.        
  1270.         $s->assign('select', $w);  
  1271.        
  1272.         $action = $_GET['id'];
  1273.        break;
  1274.        case 213:
  1275.          $c = new Criteria();
  1276.          $c->addAscendingOrderByColumn(CatContentPeer::ORDER_NO);
  1277.          
  1278.          $w = CatContentPeer::doSelect($c);
  1279.          $tab = array();
  1280.          $i = 0;
  1281.          foreach($w as $k)
  1282.          {
  1283.                if($k->getTree() == 0)
  1284.                {
  1285.                $c2 = new Criteria();
  1286.                $c2->add(ContentPeer::IDCAT, $k->getId());
  1287.                
  1288.                $w2 = ContentPeer::doSelect($c2);
  1289.                    $tab[$i]['order_no'] = $k->getOrderNo();
  1290.                    $tab[$i]['tree'] = 0;
  1291.                    $tab[$i]['idcontent'] = $w2[0]->getIdcontent();
  1292.                    $tab[$i]['idcat'] = $w2[0]->getIdcat();
  1293.                    $tab[$i]['name'] = $w2[0]->getName();
  1294.                    $tab[$i]['content'] = $w2[0]->getContent();
  1295.                    $tab[$i]['url'] = $w2[0]->getUrl();
  1296.                    $tab[$i]['id'] = $w2[0]->getIdcat();
  1297.                }
  1298.                else if($k->getTree() == 1)
  1299.                {
  1300.                $c2 = new Criteria();
  1301.                $c2->add(ContentPeer::IDCAT, $k->getId());
  1302.                
  1303.                $w2 = ContentPeer::doSelect($c2);
  1304.  
  1305.                    $tab[$i]['name'] = $k->getName();
  1306.                    $tab[$i]['tree'] = 1;
  1307.                    $tab[$i]['id'] = $k->getId();
  1308.                    $tab[$i]['order_no'] = $k->getOrderNo();
  1309.                    $ii = 0;
  1310.                    if(count($w2) > 0)
  1311.                   {
  1312.                    foreach($w2 as $k2)
  1313.                    {
  1314.                        
  1315.                        $tab[$i]['pod'][$ii]['idcontent'] = $k2->getIdcontent();
  1316.                        $tab[$i]['pod'][$ii]['idcat'] = $k2->getIdcat();
  1317.                        $tab[$i]['pod'][$ii]['name'] = $k2->getName();
  1318.                        $tab[$i]['pod'][$ii]['content'] = $k2->getContent();
  1319.                        $tab[$i]['pod'][$ii]['url'] = $k2->getUrl();    
  1320.                        $ii+=1;      
  1321.                    }
  1322.  
  1323.                 }  else {
  1324.                      $tab[$i]['bez'] = '1';   # brak podstron
  1325.                    }//if
  1326.                }//else
  1327.                            else if($k->getTree() == 2)
  1328.                {
  1329.                  $tab[$i]['tree'] = 2;
  1330.                  $tab[$i]['name'] = $k->getName();
  1331.                  $tab[$i]['order_no'] = $k->getOrderNo();
  1332.                  $tab[$i]['id'] = $k->getId();               
  1333.                }
  1334.            $i+=1;
  1335.          }
  1336.          
  1337.      
  1338.          $s->assign('tree', $tab);
  1339.          $action = $_GET['id'];
  1340.        
  1341.          /*$strony = ContentPeer::doSelect(new Criteria());
  1342.          $s->assign('str', $strony);
  1343.          $action = $_GET['id'];  */  
  1344.        break;    
  1345.        
  1346.        
  1347.        case 14:
  1348.          $w = LogaPeer::doSelect(new Criteria());
  1349.          $i=0;
  1350.          foreach($w as $k)
  1351.          {
  1352.            $tab[$i]['id'] = $k->getId();
  1353.          //  if(strlen(trim($k->getLink())) > 0)
  1354.             $l = $k->getLink();
  1355.             if(!preg_match('/http:\/\//', $l))
  1356.                  $tab[$i]['link'] = 'http://'.$l;
  1357.              else
  1358.                 $tab[$i]['link'] = $l;
  1359.                
  1360.            
  1361.            $tab[$i]['opis'] = $k->getOpis();
  1362.            $tab[$i]['path'] = spr_sciezke($tab[$i]['id']);
  1363.            $i+=1;
  1364.          }  
  1365.          $s->assign('loga', $tab);
  1366.          $action = $_GET['id'];
  1367.        break;  
  1368.  
  1369.        
  1370.     } // switch
  1371.     } //if     
  1372.    
  1373.    
  1374.    
  1375.    
  1376. // dynamiczne menu 
  1377.  
  1378.  
  1379. $s->assign('mod', $mod);   
  1380. }
  1381.  
  1382.  
  1383.  
  1384.  
  1385. $s->assign('errM', $messages[$errM]);
  1386. $s->assign('info', $messages2[$info]);
  1387. if($error>0)
  1388.   $action = 999;
  1389. $s->assign('action', $action);
  1390. $s->display('admin.tpl');
  1391.  
  1392. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement