CMOD - Script

SasserVirus

Gesperrt
Huhu! Ich mal wieder

Ich hab ein Script, mit dem man smilies hochladen kann! Diese werden auch hochgeladen, nur muss ich immer jeden einzelnen Smiley die Rechte 666 geben, sonst werden diese nicht angezeigt!

Gibt es ne Möglichkeit automatisch allen in diesem Ordner liegenden Dateien diese Recht zu geben (z.B. per Script)? :confused:

Danke schonmal
 
Danke schonmal, aber wie bastele ich da nun mein uploadscript so um, dass dann immer das angelegte userphoto mit den Rechten 666 versehen wird?

Hier mein Script upload:

PHP:
<?PHP
/* This is a photo upload page. */

/* Read userdata from database */
$user=NEW user();
$user->readUser($session,$profile_user_id);
/* Prepare nickname */
common::doHtmlEntities($user->login);
/* Current user */
$current_user=NEW user();
$current_user->readUser($session,$session->user_id);

IF($session->user_id==$profile_user_id||$current_user->level&8){
  IF($submitted){
    $errortext='';
    IF($photo[error]){
      // No files uploaded
      $errortext=$lng["noimageselected"];
    }ELSE{
      // Check file size.
      IF($photo['size']>$session->config->max_photo_size){
        // Uploaded file is too large
        $errortext=STR_REPLACE('{SIZE}', $session->config->max_photo_size, $lng['filesizetoobig']);
      }ELSE{
        // Store file
        $tmp_name=MD5($session_id.MICROTIME().RAND(-TIME(), TIME()));
        $tmp_fullname=IMAGEPATH.'/userphotos/'.$tmp_name;
        MOVE_UPLOADED_FILE($photo['tmp_name'], $tmp_fullname);
        // Check file mime type
        $type_ok=FALSE;
        $allowed_types=ARRAY('jpg'  =>  '.jpg',
                             'jpeg' =>  '.jpeg',
                             'gif'  =>  '.gif',
                             'ief'  =>  '.ief',
                             'png'  =>  '.png',
                             'tiff' =>  '.tiff',
                             'bmp'  =>  '.bmp',
                             'wbmp' =>  '.wbmp');
        IF(FUNCTION_EXISTS('getimagesize')){
          $imgdata=GETIMAGESIZE($tmp_fullname);
          IF(EMPTY($imgdata) || EMPTY($imgdata['mime'])){
            $imgdata=NULL;
          }
        }ELSE{
          $imgdata=NULL;
        }
        FOREACH($allowed_types AS $chk_type=>$extension){
          IF(!EMPTY($imgdata)){
            $type_ok=   !EMPTY($imgdata[0])
                     && !EMPTY($imgdata[1])
                     && FALSE!==STRPOS(STRTOLOWER($imgdata['mime']), $chk_type);
          }ELSE{
            $type_ok=FALSE!==STRPOS(STRTOLOWER($photo['type']), $chk_type);
          }
          IF($type_ok){
            RENAME($tmp_fullname, $tmp_fullname.$extension);
            $tmp_name.=$extension;
            BREAK;
          }
        }
        IF(!$type_ok){
          // File is not an image or has non-supported format
          $errortext=$lng['notanimage'];
          UNLINK($tmp_fullname);
        }ELSE{
          // Image is OK
          // Delete old image
          if ($user->photo!='' && $user->photo!='nophoto.jpg') {
            UNLINK(IMAGEPATH.'/userphotos/'.$user->photo);
          }
          // Update user's profile
          $user->updateUser($session, $profile_user_id, 'photo = "'.$tmp_name.'"');
          // Show user's profile
          HEADER("Location: main.php?include=$back&profile_user_id=$profile_user_id&session_id=$session_id");
          DIE();
        }
      }
    }
  }
  REQUIRE(TEMPLATEPATH."/photo_upload.tpl.php");
}

?>
 
Nachdem du die Datei verschoben hast also so:

PHP:
MOVE_UPLOADED_FILE($photo['tmp_name'], $tmp_fullname);
chmod($tmp_fullname, 666);
 
Kannst du mir noch kurz die Stelle zeigen? Fange grade erst mit PHP an. Muss diese Prozedur noch auf andere Dateien dann noch anwenden!

Danke :)
 
Das MOVE_UPLOADED_FILE($photo['tmp_name'], $tmp_fullname); stammte aus deinem gepostetem File.. eins zu eins.

noch mehr zeilen darüber sind die hier:
PHP:
        // Uploaded file is too large
        $errortext=STR_REPLACE('{SIZE}', $session->config->max_photo_size, $lng['filesizetoobig']);
      }ELSE{
        // Store file
        $tmp_name=MD5($session_id.MICROTIME().RAND(-TIME(), TIME()));
        $tmp_fullname=IMAGEPATH.'/userphotos/'.$tmp_name;
        MOVE_UPLOADED_FILE($photo['tmp_name'], $tmp_fullname);
        chmod($tmp_fullname, 666);
 
Gut danke schonmal, aber irgendwie gibt der nicht die Rechte 666

Also mein Code sieht jetzt so aus;

PHP:
<?PHP
/* This is a photo upload page. */

/* Read userdata from database */
$user=NEW user();
$user->readUser($session,$profile_user_id);
/* Prepare nickname */
common::doHtmlEntities($user->login);
/* Current user */
$current_user=NEW user();
$current_user->readUser($session,$session->user_id);

IF($session->user_id==$profile_user_id||$current_user->level&8){
  IF($submitted){
    $errortext='';
    IF($photo[error]){
      // No files uploaded
      $errortext=$lng["noimageselected"];
    }ELSE{
      // Check file size.
      IF($photo['size']>$session->config->max_photo_size){
        // Uploaded file is too large
        $errortext=STR_REPLACE('{SIZE}', $session->config->max_photo_size, $lng['filesizetoobig']);
      }ELSE{
        // Store file
        $tmp_name=MD5($session_id.MICROTIME().RAND(-TIME(), TIME()));
        $tmp_fullname=IMAGEPATH.'/userphotos/'.$tmp_name;
        MOVE_UPLOADED_FILE($photo['tmp_name'], $tmp_fullname);
        chmod($tmp_fullname, 666);
        // Check file mime type
        $type_ok=FALSE;
        $allowed_types=ARRAY('jpg'  =>  '.jpg',
                             'jpeg' =>  '.jpeg',
                             'gif'  =>  '.gif',
                             'ief'  =>  '.ief',
                             'png'  =>  '.png',
                             'tiff' =>  '.tiff',
                             'bmp'  =>  '.bmp',
                             'wbmp' =>  '.wbmp');
        IF(FUNCTION_EXISTS('getimagesize')){
          $imgdata=GETIMAGESIZE($tmp_fullname);
          IF(EMPTY($imgdata) || EMPTY($imgdata['mime'])){
            $imgdata=NULL;
          }
        }ELSE{
          $imgdata=NULL;
        }
        FOREACH($allowed_types AS $chk_type=>$extension){
          IF(!EMPTY($imgdata)){
            $type_ok=   !EMPTY($imgdata[0])
                     && !EMPTY($imgdata[1])
                     && FALSE!==STRPOS(STRTOLOWER($imgdata['mime']), $chk_type);
          }ELSE{
            $type_ok=FALSE!==STRPOS(STRTOLOWER($photo['type']), $chk_type);
          }
          IF($type_ok){
            RENAME($tmp_fullname, $tmp_fullname.$extension);
            $tmp_name.=$extension;
            BREAK;
          }
        }
        IF(!$type_ok){
          // File is not an image or has non-supported format
          $errortext=$lng['notanimage'];
          UNLINK($tmp_fullname);
        }ELSE{
          // Image is OK
          // Delete old image
          if ($user->photo!='' && $user->photo!='nophoto.jpg') {
            UNLINK(IMAGEPATH.'/userphotos/'.$user->photo);
          }
          // Update user's profile
          $user->updateUser($session, $profile_user_id, 'photo = "'.$tmp_name.'"');
          // Show user's profile
          HEADER("Location: main.php?include=$back&profile_user_id=$profile_user_id&session_id=$session_id");
          DIE();
        }
      }
    }
  }
  REQUIRE(TEMPLATEPATH."/photo_upload.tpl.php");
}

?>
 
Zurück