Witaj Gościu! ( Zaloguj | Rejestruj )

Forum PHP.pl

 
Reply to this topicStart new topic
> [PHP] Skypt do zmiany atrybutow
Aragon
post 2.08.2009, 00:38:36
Post #1





Grupa: Zarejestrowani
Postów: 3
Pomógł: 0
Dołączył: 2.08.2009

Ostrzeżenie: (0%)
-----


witam , mam skrypt żeby zmieniać atrybuty, bo przez total comandera sie nie da :
  1. <?php
  2. $id = $_GET['id'];
  3.  
  4. $_ok='nic nie wybrałeś: ?id=644';
  5. if (isset($id) AND $id!=="" AND is_numeric($id))
  6. {
  7.    $path = '.';
  8.    
  9.    $Dir = opendir ($path);
  10.    $i = 0;
  11.    while ( $file = readdir( $Dir ) )
  12.    {
  13.        //checks that file is an image
  14.        $file_type = strrchr( $file, "." );
  15.        $is_image = eregi( "txt|php|xml",$file_type );
  16.        
  17.        if ( $file != '.' && $file != '..' && $is_image && $file!=='_chmod.php')
  18.        {
  19.            if ($id == 644) {
  20.            
  21.                if(chmod($file, 0644))$_ok ='zapisano uprawnienia: '.$id;
  22.                else $_ok =' nieustawiono uprawnień';
  23.            
  24.                $i++;
  25.                echo "<li>$i. $file = $_ok";
  26.            }
  27.            else if ($id == 666) {
  28.            
  29.                if(chmod($file, 0666))$_ok ='zapisano uprawnienia: '.$id;
  30.                else $_ok =' nieustawiono uprawnień';
  31.            
  32.                $i++;
  33.                echo "<li>$i. $file = $_ok";
  34.            }
  35.        }
  36.    }
  37.    closedir ($Dir);
  38. }    
  39. else echo $_ok;
  40.  
  41. ?>



Ale jest jeden problem, bo ten skypt zmiania tylko pliki php txt, a ja musze zeby folderu zmienilo atrybuty , chodzi mi tylko o folder o nazwie mod_jsn_imageshow_pro , zeby tylko to wykrylo i zmienilo argumenty

tu jest ten skypt na mojej stronie : i jak widac zmiania tylko ten jeden plik :
http://www.iphoneworld.pl/modules/delete.php?id=0666

Bardzo prosze o pomoc bo juz kturac godzine mecze sie nad zmiana atrybutów tego folderu
Go to the top of the page
+Quote Post
Pawel_W
post 2.08.2009, 09:38:14
Post #2





Grupa: Zarejestrowani
Postów: 1 675
Pomógł: 286
Dołączył: 15.06.2009
Skąd: Wieliczka

Ostrzeżenie: (0%)
-----


  1. <?php
  2. if ($id == 644) {
  3.          
  4.               if(chmod($file, 0644))$_ok ='zapisano uprawnienia: '.$id;
  5.               else $_ok =' nieustawiono uprawnień';
  6.          
  7.               $i++;
  8.               echo "<li>$i. $file = $_ok";
  9.           }
  10.           else if ($id == 666) {
  11.          
  12.               if(chmod($file, 0666))$_ok ='zapisano uprawnienia: '.$id;
  13.               else $_ok =' nieustawiono uprawnień';
  14.          
  15.               $i++;
  16.               echo "<li>$i. $file = $_ok";
  17.           }
  18. ?>

zamien na
  1. <?php
  2. if(chmod($file, 0.$id))$_ok ='zapisano uprawnienia: '.$id;
  3.               else $_ok =' nieustawiono uprawnień';
  4.          
  5.               $i++;
  6.               echo "<li>$i. $file = $_ok";
  7. ?>

będzie krócej, a żeby zmieniało ci chmod folderu to zrób to tak:
  1. <?php
  2. $id = $_GET['id'];
  3.  
  4. $_ok='nic nie wybrałeś: ?id=644';
  5. if (isset($id) AND $id!=="" AND is_numeric($id))
  6. {
  7.   $path = '.';
  8.  
  9.   $Dir = opendir ($path);
  10.   $i = 0;
  11.   while ( $file = readdir( $Dir ) )
  12.   {
  13.       //checks that file is an image
  14.       $file_type = strrchr( $file, "." );
  15.       $is_image = eregi( "txt|php|xml",$file_type );
  16.      
  17.       if ( $file != '.' && $file != '..' && $is_image && $file!=='_chmod.php')
  18.       {
  19.               if(chmod($file, 0.$id))$_ok ='zapisano uprawnienia: '.$id;
  20.               else $_ok =' nieustawiono uprawnień';
  21.          
  22.               $i++;
  23.               echo "<li>$i. $file = $_ok";
  24.       }
  25. else if(filetype($file) == 'dir')
  26. {
  27.               if(chmod($file, 0.$id))$_ok ='zapisano uprawnienia: '.$id;
  28.               else $_ok =' nieustawiono uprawnień';
  29.          
  30.               $i++;
  31.               echo "<li>$i. $file = $_ok";
  32. }
  33.   }
  34.   closedir ($Dir);
  35. }    
  36. else echo $_ok;
  37.  
  38. ?>
Go to the top of the page
+Quote Post
lukada
post 2.08.2009, 09:56:41
Post #3





Grupa: Zarejestrowani
Postów: 38
Pomógł: 2
Dołączył: 4.02.2009

Ostrzeżenie: (0%)
-----


A przypadkiem to:

  1. <?php
  2. while ( $file = readdir( $Dir ) )
  3. ?>

nie powinno zapisywać się tak:

  1. <?php
  2. while ( false !== ( $file = readdir( $Dir ) ) )
  3. ?>

?

Bo co, gdy plik będzie się nazywał "0", "null" lub "false"? winksmiley.jpg

Ten post edytował lukada 2.08.2009, 09:56:53
Go to the top of the page
+Quote Post
Pawel_W
post 2.08.2009, 11:02:19
Post #4





Grupa: Zarejestrowani
Postów: 1 675
Pomógł: 286
Dołączył: 15.06.2009
Skąd: Wieliczka

Ostrzeżenie: (0%)
-----


plik ma rozszerzenie...
Go to the top of the page
+Quote Post
Aragon
post 2.08.2009, 12:25:15
Post #5





Grupa: Zarejestrowani
Postów: 3
Pomógł: 0
Dołączył: 2.08.2009

Ostrzeżenie: (0%)
-----


ten kod nie dziala pisze ze blad jest w 20 linijce
Go to the top of the page
+Quote Post
marian2299
post 2.08.2009, 13:19:57
Post #6





Grupa: Zarejestrowani
Postów: 272
Pomógł: 9
Dołączył: 6.06.2009

Ostrzeżenie: (0%)
-----


Mynconcy jesteś haha.gif. Napisz jaki błąd, a poza tym:
Cytat(Aragon)
pisze ze blad jest w 20 linijce

Kto pisze ?


--------------------
film edit student
Go to the top of the page
+Quote Post
Pawel_W
post 2.08.2009, 20:03:50
Post #7





Grupa: Zarejestrowani
Postów: 1 675
Pomógł: 286
Dołączył: 15.06.2009
Skąd: Wieliczka

Ostrzeżenie: (0%)
-----


zmień filetype($file) na filetype($path.$file)
Go to the top of the page
+Quote Post
Aragon
post 5.08.2009, 00:50:59
Post #8





Grupa: Zarejestrowani
Postów: 3
Pomógł: 0
Dołączył: 2.08.2009

Ostrzeżenie: (0%)
-----


http://www.iphoneworld.pl/templates/delete.php

Parse error: syntax error, unexpected T_VARIABLE in /home/iphoneworl/domains/iphoneworld.pl/public_html/templates/delete.php on line 20
Go to the top of the page
+Quote Post

Reply to this topicStart new topic
1 Użytkowników czyta ten temat (1 Gości i 0 Anonimowych użytkowników)
0 Zarejestrowanych:

 



RSS Wersja Lo-Fi Aktualny czas: 28.07.2025 - 04:26