Ocena wątku:
  • 0 głosów - średnia: 0
  • 1
  • 2
  • 3
  • 4
  • 5
Problem z pHp
#5
div, wykorzystałem, ponieważ podałeś taki przykład. Niestety nie znam się dobrze na php i pewnie dla tego. Może to moja nie wiedza, ale nie widze w tym pliku czegoś, co zaczyna się, a mógłbym zakończyć po die.

Oto kawałem pliku myprofile.php, który dotyczy avatara :
Kod PHP:
<?php
/*
 ########################################################################
#                                                                        #
#           Version 4       /                        /   /               #
#          -----------__---/__---__------__----__---/---/-               #
#           | /| /  /___) /   ) (_ `   /   ) /___) /   /                 #
#          _|/_|/__(___ _(___/_(__)___/___/_(___ _/___/___               #
#                       Free Content / Management System                 #
#                                   /                                    #
#                                                                        #
#                                                                        #
#   Copyright 2005-2006 by webspell.org                                  #
#                                                                        #
#   visit webSPELL.org, webspell.info to get webSPELL for free           #
#   - Script runs under the GNU GENERAL PUBLIC LICENSE                   #
#   - It's NOT allowed to remove this copyright-tag                      #
#   -- http://www.fsf.org/licensing/licenses/gpl.html                    #
#                                                                        #
#   Code based on WebSPELL Clanpackage (Michael Gruber - webspell.at),   #
#   Far Development by Development Team - webspell.org                   #
#                                                                        #
#   visit webspell.org                                                   #
#                                                                        #
 ########################################################################
*/

if(!$userID) echo 'Musisz być zalogowany aby przegl&#261dać swój profil!<br><br>

              • <a href="index.php?site=register">Rejestracja</a><br>
              • <a href="index.php?site=login">Logowanie</a>'
;
              
else {              

    eval (
"\$title_myprofile = \"".gettemplate("title_myprofile")."\";");
    echo 
$title_myprofile;
    
    if(
$_POST['submit']) {
    
      
$nickname substr(trim($_POST['nickname']), 030);
      
$mail $_POST['mail'];
      
$usernamenew substr(trim($_POST['usernamenew']), 030);
      
$usertext $_POST['usertext'];
      
$firstname $_POST['firstname'];
      
$lastname $_POST['lastname'];
      
$b_day $_POST['b_day'];
      
$b_month $_POST['b_month'];
      
$b_year $_POST['b_year'];
      
$sex $_POST['sex'];
      
$flag $_POST['flag'];
      
$town $_POST['town'];
      
$icq $_POST['icq'];
      
$about $_POST['messageabout'];
      
$clantag $_POST['clantag'];
      
$clanname $_POST['clanname'];
      
$clanhp $_POST['clanhp'];
      
$clanirc $_POST['clanirc'];
      
$clanhistory $_POST['clanhistory'];
      
$cpu $_POST['cpu'];
      
$mainboard $_POST['mainboard'];
      
$monitor $_POST['monitor'];
      
$ram $_POST['ram'];
      
$graphiccard $_POST['graphiccard'];
      
$soundcard $_POST['soundcard'];
      
$connection $_POST['connection'];
      
$keyboard $_POST['keyboard'];
      
$mouse $_POST['mouse'];
      
$mousepad $_POST['mousepad'];
      
$newsletter $_POST['newsletter'];
      
$homepage $_POST['homepage'];
      
$pm_mail $_POST['pm_mail'];
      
$avatar $_FILES['avatar'];
      
$userpic $_FILES['userpic'];
      
$id $userID;
    
      if(
$_POST['userID'] OR $_GET['userID'] OR $userID=="") die('Nie zalogowany.');
    
        
$editname=false;
        
$ergebnis=safe_query("SELECT * FROM ".PREFIX."user WHERE userID='$id' ");
        
$ds=mysql_fetch_array($ergebnis);
        if(
$usernamenew != $ds[username]) {
            
$ergebnis safe_query("SELECT * FROM ".PREFIX."user WHERE username = '".$usernamenew."' ");
            
$num mysql_num_rows($ergebnis);
            if(
$num) {
                
$error="Wybrana nazwa użytkownika jest w użyciu!";
                die(
'<b>Bł&#261d: '.$error.'</b><br><br><input type="button" class="button" onClick="javascript:history.back()" value="Wróć">');
            }
            
$editname=true;
        }
    
        if(
$_POST['delavatar']) {
            
$filepath "./images/avatars/";
            if(
file_exists($filepath.$id.'.jpg')) @unlink($filepath.$id.'.jpg');
            if(
file_exists($filepath.$id.'.gif')) @unlink($filepath.$id.'.gif');
            
safe_query("UPDATE ".PREFIX."user SET avatar='' WHERE userID='$id' ");
        }
        if(
$_POST['deluserpic']) {
            
$filepath "./images/userpics/";
            if(
file_exists($filepath.$id.'.jpg')) @unlink($filepath.$id.'.jpg');
            if(
file_exists($filepath.$id.'.gif')) @unlink($filepath.$id.'.gif');
            
safe_query("UPDATE ".PREFIX."user SET userpic='' WHERE userID='$id' ");
        }
    
        
//avatar
        
$filepath "./images/avatars/";
        if (
$avatar['name'] != "" OR ($_POST['avatar_url'] != "" AND $_POST['avatar_url'] != "http://")) {
        if(
$avatar['name'] != "") {
         
move_uploaded_file($avatar[tmp_name], $filepath.$avatar[name].".tmp");
        } else {
         
$avatar[name] = strrchr($_POST['avatar_url'],"/");
         if(!
copy($_POST['avatar_url'],$filepath.$avatar[name].".tmp")) {
                
$error "Nie można skopiować pliku z serwera";
            die(
'Bł&#261d: '.$error.'<br><br><input type="button" class="button" onClick="javascript:history.back()" value="Wróć">');
         }
        }
        @
chmod($filepath.$avatar[name].".tmp"0755);
        
$info getimagesize($filepath.$avatar[name].".tmp");
            if(
$info[0] < 91 && $info[1] < 91) {
            if(
$info[2] == 2) {
                    
$pic=$id.'.jpg';
                   if(
file_exists($filepath.$pic)) @unlink($filepath.$pic);
                   if(
file_exists($filepath.$id.'.gif')) @unlink($filepath.$id.'.gif');
              
rename($filepath.$avatar[name].".tmp"$filepath.$pic);
                    
safe_query("UPDATE ".PREFIX."user SET avatar='$pic' WHERE userID='$id' ");
                }
                elseif(
$info[2] == 1) {
                    
$pic=$id.'.gif';
                   if(
file_exists($filepath.$pic)) @unlink($filepath.$pic);
                   if(
file_exists($filepath.$id.'.jpg')) @unlink($filepath.$id.'.jpg');
                    
rename($filepath.$avatar[name].".tmp"$filepath.$pic);
                    
safe_query("UPDATE ".PREFIX."user SET avatar='$pic' WHERE userID='$id' ");
                }
                else {
                    if(
unlink($filepath.$avatar[name].".tmp")) {
                            
$error "Niedozwolony format grafiki (dozwolone: gif lub jpg)";
                        die(
'Bł&#261d: '.$error.'<br><br><input type="button" class="button" onClick="javascript:history.back()" value="Wróć">');
                    } else {
                            
$error "Wgrywanie zakończone niepowodzeniem";
                        die(
'Bł&#261d: '.$error.'<br><br><input type="button" class="button" onClick="javascript:history.back()" value="Wróć">');
                    }
    
                }
            }
            else {
                @
unlink($filepath.$avatar[name].".tmp");
                
$error "Obrazek jest większy niż dozwolone 90/90px";
                die(
'Bł&#261d: '.$error.'<br><br><input type="button" class="button" onClick="javascript:history.back()" value="Wróć">');
            }
        } 
Odpowiedz


Wiadomości w tym wątku
Problem z pHp - przez Chuczek - 25-05-2008, 20:02
RE: Problem z pHp - przez Radek - 26-05-2008, 00:47
RE: Problem z pHp - przez Chuczek - 26-05-2008, 01:58
RE: Problem z pHp - przez Radek - 26-05-2008, 03:53
RE: Problem z pHp - przez Chuczek - 27-05-2008, 01:26
RE: Problem z pHp - przez Radek - 27-05-2008, 17:14
RE: Problem z pHp - przez kmd - 30-05-2008, 04:47

Skocz do:


Użytkownicy przeglądający ten wątek:
Sponsorzy i przyjaciele
SeoHost.pl