function download() { $this->error = false; define('HTTP_EOL', "\r\n"); if (!empty($this->remote_file)) { $this->file_name = ''; $info = parse_url($this->remote_file); $fileop = new fileop(); $header = 'GET ' . $info['path']; if (isset($info['query'])) { $header .= '?' . $info['query']; } $header .= ' HTTP/1.0' . HTTP_EOL; $header .= 'Host: ' . $info['host'] . HTTP_EOL; $header .= 'Connection: close' . HTTP_EOL . HTTP_EOL; $socket = fsockopen($info['host'], 80, $errno, $errstr, 30); if ($socket) { fputs($socket, $header); } $reply = ''; $headerdone = false; while (!feof($socket)) { $line = fgets($socket); if (strcmp($line, HTTP_EOL) == 0) { // read the header $headerdone = true; } elseif (!$headerdone) { if (empty($this->file_name)) { if (preg_match('/Content\\-Disposition: attachment; filename="(.+)"/', $line, $m)) { $this->file_name = $m[1]; } elseif (preg_match('/Content\\-Type: application\\/octet\\-stream; name="(.+)"/', $line, $m)) { $this->file_name = $m[1]; } elseif (preg_match('/Content\\-Type: application\\/octetstream; name="(.+)"/', $line, $m)) { $this->file_name = $m[1]; } } } elseif ($headerdone) { // header has been read. now read the contents $reply .= $line; } } fclose($socket); if (!empty($reply) && !empty($this->file_name)) { $fileop->file_put_contents(_BASEPATH_ . '/tmp/' . $this->file_name, $reply); if ($this->verify()) { $fileop->rename(_BASEPATH_ . '/tmp/' . $this->file_name, _BASEPATH_ . '/tmp/packages/' . $this->file_name); } } else { $this->error = true; $this->error_text = 'Unable to download package.'; } } else { $this->error = true; $this->error_text = 'Invalid package selected for download.'; } return !$this->error; }
$input['file1'] = ''; $error = true; $topass['message']['type'] = MESSAGE_ERROR; $topass['message']['text'][] = sprintf($GLOBALS['_lang'][94], 1, $config['min_size']); } elseif (!empty($config['max_size']) && filesize(_BASEPATH_ . '/tmp/' . $input['file1']) > $config['max_size']) { $input['file1'] = ''; $error = true; $topass['message']['type'] = MESSAGE_ERROR; $topass['message']['text'][] = sprintf($GLOBALS['_lang'][95], 1, $config['max_size']); } else { mt_srand(make_seed()); $rand = mt_rand(0, 9); if (save_thumbnail(_BASEPATH_ . '/tmp/' . $input['file1'], $config['t1_width'], _BASEPATH_ . '/tmp', $filename . '_1', $config_t1) && save_thumbnail(_BASEPATH_ . '/tmp/' . $input['file1'], $config['t2_width'], _BASEPATH_ . '/tmp', $filename . '_2', $config_t2) && save_thumbnail(_BASEPATH_ . '/tmp/' . $input['file1'], $config['pic_width'], _BASEPATH_ . '/tmp', $filename . '_3', $config)) { @unlink(_BASEPATH_ . '/tmp/' . $input['file1']); $input['file1'] = $rand . '/' . $filename . '.jpg'; if (!$fileop->rename(_BASEPATH_ . '/tmp/' . $filename . '_1.jpg', _PHOTOPATH_ . '/t1/' . $input['file1']) || !$fileop->rename(_BASEPATH_ . '/tmp/' . $filename . '_2.jpg', _PHOTOPATH_ . '/t2/' . $input['file1']) || !$fileop->rename(_BASEPATH_ . '/tmp/' . $filename . '_3.jpg', _PHOTOPATH_ . '/' . $input['file1'])) { $error = true; } if ($photos_remaining > 0) { --$photos_remaining; } } else { $error = true; } } } elseif ($input['file1'] === false) { $error = true; // we should have $topass['message'] set from within upload_file(); } } if (!$error && ($photos_remaining > 0 || $photos_remaining == -1)) {
$input[$rsrow['fk_module_code']][$rsrow['config_option']] = sanitize_and_format_gpc($_POST, $rsrow['fk_module_code'] . '_' . $rsrow['config_option'], TYPE_STRING, $__field2format[FIELD_TEXTFIELD], ''); break; case FIELD_INT: $input[$rsrow['fk_module_code']][$rsrow['config_option']] = sanitize_and_format_gpc($_POST, $rsrow['fk_module_code'] . '_' . $rsrow['config_option'], TYPE_INT, 0, 0); break; case FIELD_TEXTAREA: $input[$rsrow['fk_module_code']][$rsrow['config_option']] = sanitize_and_format_gpc($_POST, $rsrow['fk_module_code'] . '_' . $rsrow['config_option'], TYPE_STRING, $__field2format[FIELD_TEXTAREA], ''); break; case FIELD_SELECT: $input[$rsrow['fk_module_code']][$rsrow['config_option']] = sanitize_and_format_gpc($_POST, $rsrow['fk_module_code'] . '_' . $rsrow['config_option'], TYPE_INT, 0, 0); break; case FIELD_FILE: if (!empty($_FILES[$rsrow['fk_module_code'] . '_' . $rsrow['config_option']]['tmp_name'])) { if ($temp = upload_file(_BASEPATH_ . '/tmp', $rsrow['fk_module_code'] . '_' . $rsrow['config_option'])) { $f = new fileop(); if ($f->rename(_BASEPATH_ . '/tmp/' . $temp, _BASEPATH_ . $rsrow['choices'] . '/' . $temp)) { $input[$rsrow['fk_module_code']][$rsrow['config_option']] = _BASEPATH_ . $rsrow['choices'] . '/' . $temp; } else { $error = true; } } else { $error = true; } } break; } } if (!$error) { foreach ($input as $module_code => $v) { foreach ($v as $config_option => $config_value) { $query = "UPDATE `{$dbtable_prefix}site_options3` SET `config_value`='{$config_value}' WHERE `config_option`='{$config_option}' AND `fk_module_code`='{$module_code}'";