Pomoc - Szukaj - Użytkownicy - Kalendarz
Pełna wersja: o co chodzi?
Forum PHP.pl > Forum > PHP
adamkaraczun
wyswietla mi sie taki blad:


Fatal error: Cannot re-assign $this in D:\Serwer\WebServ\httpd\commerce\sklep\admin\includes\classes\upload.php on line 31



a oto plik: (tresc edytowana w notatniku)

  1. <?php
  2. /*
  3.   $Id: upload.php,v 1.2 2003/06/20 00:18:30 hpdl Exp $
  4.  
  5.   osCommerce, Open Source E-Commerce Solutions
  6.  
  7.   Copyright Š 2003 osCommerce
  8.  
  9.   Released under the GNU General Public License
  10. */
  11.  
  12. class upload {
  13. var $file, $filename, $destination, $permissions, $extensions, $tmp_filename, $message_location;
  14.  
  15. function upload($file = '', $destination = '', $permissions = '777', $extensions = '') {
  16. $this->set_file($file);
  17. $this->set_destination($destination);
  18. $this->set_permissions($permissions);
  19. $this->set_extensions($extensions);
  20.  
  21. $this->set_output_messages('direct');
  22.  
  23. if (tep_not_null($this->file) && tep_not_null($this->destination)) {
  24. $this->set_output_messages('session');
  25.  
  26. if ( ($this->parse() == true) && ($this->save() == true) ) {
  27. return true;
  28. } else {
  29. // self destruct
  30. $this = null;
  31.  
  32. return false;
  33. }
  34. }
  35. }
  36.  
  37. function parse() {
  38. global $messageStack;
  39.  
  40. if (isset($_FILES[$this->file])) {
  41. $file = array('name' => $_FILES[$this->file]['name'],
  42. 'type' => $_FILES[$this->file]['type'],
  43. 'size' => $_FILES[$this->file]['size'],
  44. 'tmp_name' => $_FILES[$this->file]['tmp_name']);
  45. } elseif (isset($GLOBALS['HTTP_POST_FILES'][$this->file])) {
  46. global $HTTP_POST_FILES;
  47.  
  48. $file = array('name' => $HTTP_POST_FILES[$this->file]['name'],
  49. 'type' => $HTTP_POST_FILES[$this->file]['type'],
  50. 'size' => $HTTP_POST_FILES[$this->file]['size'],
  51. 'tmp_name' => $HTTP_POST_FILES[$this->file]['tmp_name']);
  52. } else {
  53. $file = array('name' => (isset($GLOBALS[$this->file . '_name']) ? $GLOBALS[$this->file . '_name'] : ''),
  54. 'type' => (isset($GLOBALS[$this->file . '_type']) ? $GLOBALS[$this->file . '_type'] : ''),
  55. 'size' => (isset($GLOBALS[$this->file . '_size']) ? $GLOBALS[$this->file . '_size'] : ''),
  56. 'tmp_name' => (isset($GLOBALS[$this->file]) ? $GLOBALS[$this->file] : ''));
  57. }
  58.  
  59. if ( tep_not_null($file['tmp_name']) && ($file['tmp_name'] != 'none') && is_uploaded_file($file['tmp_name']) ) {
  60. if (sizeof($this->extensions) > 0) {
  61. if (!in_array(strtolower(substr($file['name'], strrpos($file['name'], '.')+1)), $this->extensions)) {
  62. if ($this->message_location == 'direct') {
  63. $messageStack->add(ERROR_FILETYPE_NOT_ALLOWED, 'error');
  64. } else {
  65. $messageStack->add_session(ERROR_FILETYPE_NOT_ALLOWED, 'error');
  66. }
  67.  
  68. return false;
  69. }
  70. }
  71.  
  72. $this->set_file($file);
  73. $this->set_filename($file['name']);
  74. $this->set_tmp_filename($file['tmp_name']);
  75.  
  76. return $this->check_destination();
  77. } else {
  78. if ($this->message_location == 'direct') {
  79. $messageStack->add(WARNING_NO_FILE_UPLOADED, 'warning');
  80. } else {
  81. $messageStack->add_session(WARNING_NO_FILE_UPLOADED, 'warning');
  82. }
  83.  
  84. return false;
  85. }
  86. }
  87.  
  88. function save() {
  89. global $messageStack;
  90.  
  91. if (substr($this->destination, -1) != '/') $this->destination .= '/';
  92.  
  93. if (move_uploaded_file($this->file['tmp_name'], $this->destination . $this->filename)) {
  94. chmod($this->destination . $this->filename, $this->permissions);
  95.  
  96. if ($this->message_location == 'direct') {
  97. $messageStack->add(SUCCESS_FILE_SAVED_SUCCESSFULLY, 'success');
  98. } else {
  99. $messageStack->add_session(SUCCESS_FILE_SAVED_SUCCESSFULLY, 'success');
  100. }
  101.  
  102. return true;
  103. } else {
  104. if ($this->message_location == 'direct') {
  105. $messageStack->add(ERROR_FILE_NOT_SAVED, 'error');
  106. } else {
  107. $messageStack->add_session(ERROR_FILE_NOT_SAVED, 'error');
  108. }
  109.  
  110. return false;
  111. }
  112. }
  113.  
  114. function set_file($file) {
  115. $this->file = $file;
  116. }
  117.  
  118. function set_destination($destination) {
  119. $this->destination = $destination;
  120. }
  121.  
  122. function set_permissions($permissions) {
  123. $this->permissions = octdec($permissions);
  124. }
  125.  
  126. function set_filename($filename) {
  127. $this->filename = $filename;
  128. }
  129.  
  130. function set_tmp_filename($filename) {
  131. $this->tmp_filename = $filename;
  132. }
  133.  
  134. function set_extensions($extensions) {
  135. if (tep_not_null($extensions)) {
  136. if (is_array($extensions)) {
  137. $this->extensions = $extensions;
  138. } else {
  139. $this->extensions = array($extensions);
  140. }
  141. } else {
  142. $this->extensions = array();
  143. }
  144. }
  145.  
  146. function check_destination() {
  147. global $messageStack;
  148.  
  149. if (!is_writeable($this->destination)) {
  150. if (is_dir($this->destination)) {
  151. if ($this->message_location == 'direct') {
  152. $messageStack->add(sprintf(ERROR_DESTINATION_NOT_WRITEABLE, $this->destination), 'error');
  153. } else {
  154. $messageStack->add_session(sprintf(ERROR_DESTINATION_NOT_WRITEABLE, $this->destination), 'error');
  155. }
  156. } else {
  157. if ($this->message_location == 'direct') {
  158. $messageStack->add(sprintf(ERROR_DESTINATION_DOES_NOT_EXIST, $this->destination), 'error');
  159. } else {
  160. $messageStack->add_session(sprintf(ERROR_DESTINATION_DOES_NOT_EXIST, $this->destination), 'error');
  161. }
  162. }
  163.  
  164. return false;
  165. } else {
  166. return true;
  167. }
  168. }
  169.  
  170. function set_output_messages($location) {
  171. switch ($location) {
  172. case 'session':
  173. $this->message_location = 'session';
  174. break;
  175. case 'direct':
  176. default:
  177. $this->message_location = 'direct';
  178. break;
  179. }
  180. }
  181. }
  182. ?>
ikioloak
uzyj bbcode to zobaczymy.
NuLL
Jaką masz wersję php ?

W linii 31 zamiast $this=null; napisz unset($this);
adamkaraczun
dziekuje kolego - jestes wielki smile.gif dziala smile.gif
To jest wersja lo-fi głównej zawartości. Aby zobaczyć pełną wersję z większą zawartością, obrazkami i formatowaniem proszę kliknij tutaj.
Invision Power Board © 2001-2025 Invision Power Services, Inc.