protected function onUpload() { try { if (!$this->options['upload']) { throw new FileManagerException('disabled'); } if (empty($this->get['directory']) || function_exists('UploadIsAuthenticated') && !UploadIsAuthenticated($this->get)) { throw new FileManagerException('authenticated'); } $dir = $this->getDir($this->get['directory']); $name = pathinfo(File_Upload::exists('Filedata') ? $this->getName($_FILES['Filedata']['name'], $dir) : null, PATHINFO_FILENAME); $ftp = new File_FTP($this->registry); $file = File_Upload::move('Filedata', $dir . '/', array('name' => $name, 'extension' => $this->options['safe'] && $name && in_array(strtolower(pathinfo($_FILES['Filedata']['name'], PATHINFO_EXTENSION)), array('exe', 'dll', 'php', 'php3', 'php4', 'php5', 'phps')) ? 'txt' : null, 'size' => $this->options['maxUploadSize'], 'mimes' => $this->getAllowedMimeTypes(), 'ftp' => $ftp)); if (File_Utility::startsWith(File_Upload::mime($file), 'image/') && !empty($this->get['resize'])) { $ftp_file = $this->getFTPPath($ftp->public_html, $file); $ftp->chmod($ftp_file, 0646); $img = new File_Image($file); $size = $img->getSize(); if ($size['width'] > 800) { $img->resize(800)->save(); } elseif ($size['height'] > 600) { $img->resize(null, 600)->save(); } $ftp->chmod($ftp_file, 0644); } echo json_encode(array('status' => 1, 'name' => pathinfo($file, PATHINFO_BASENAME))); } catch (UploadException $e) { echo json_encode(array('status' => 0, 'error' => '${upload.' . $e->getMessage() . '}')); } catch (FileManagerException $e) { echo json_encode(array('status' => 0, 'error' => '${upload.' . $e->getMessage() . '}')); } }
public function logIPNResults($success) { if (!$this->ipn_log) { return; } // is logging turned off? // Timestamp $text = '[' . date('m/d/Y g:i A') . '] - '; // Success or failure being logged? if ($success) { $text .= "SUCCESS!\n"; } else { $text .= 'FAIL: ' . $this->last_error . "\n"; } // Log the POST variables $text .= "IPN POST Vars from Paypal:\n"; foreach ($this->ipn_data as $key => $value) { $text .= "{$key}={$value}, "; } // Log the response from the paypal server $text .= "\nIPN Response from Paypal Server:\n " . $this->ipn_response; $ftp = new File_FTP($this->registry); if ($ftp) { $logs = __SITE_PATH . '/../../uthando/logs'; if (!is_file($logs . '/' . $this->ipn_log_file)) { $this->makeLogFile(); } $ftp->chmod($ftp->uthando_dir . '/logs/' . $this->ipn_log_file, 0646); // Write to log file_put_contents($logs . '/' . $this->ipn_log_file, $text . "\n\n", FILE_APPEND); $ftp->chmod($ftp->uthando_dir . '/logs/' . $this->ipn_log_file, 0644); } }
public function save() { try { if ($this->path == null) { throw new ConfigException("Config::save() - ini path not set, error."); } $content = null; // PROTECTED_MODE-prefix if ($this->protected_mode) { $content .= "<?php\n; /*\n; -- BEGIN PROTECTED_MODE\n"; } // config-header $content .= "; This file was automatically generated by Config\n"; $content .= "; Do not edit this file by hand, use Config instead.\n"; $content .= "; Last modified: " . date('d M Y H:i s') . "\n"; // check if there are sections to process if ($this->process_sections) { foreach ($this->vars as $key => $elem) { $content .= "[" . $key . "]\n"; foreach ($elem as $key2 => $elem2) { if (is_array($elem2)) { foreach ($elem2 as $elem3) { $content .= $key2 . "[] = \"" . $elem3 . "\"\n"; } } else { $content .= $key2 . " = \"" . $elem2 . "\"\n"; } } } } else { foreach ($this->vars as $key => $elem) { $content .= $key . " = \"" . $elem . "\"\n"; } } // add PROTECTED_MODE-ending if ($this->protected_mode) { $content .= "\n; -- END PROTECTED_MODE\n; */\n?>\n"; } $ftp = new File_FTP($this->registry); $dir = preg_replace("/(.*?)" . str_replace("/", "\\/", $ftp->public_html) . "|(.*?)" . str_replace("/", "\\/", $ftp->uthando_dir) . "/", "", $this->path); if ($this->public_html) { $path = $ftp->public_html . $dir; } else { $path = $ftp->uthando_dir . $dir; } $ftp->chmod($path, 0646); if (!file_put_contents($this->path, $content)) { throw new ConfigException("Config::save() - Could not write to file('" . $this->path . "'), error."); } $ftp->chmod($path, 0644); $ftp->disconnect(); return true; } catch (ConfigException $e) { $this->registry->Error($e->getMessage()); return false; } }