public function handle($type)
 {
     $this->_setType($type);
     // handle file upload
     $upload = new HTTP_Upload('en');
     $this->file = $upload->getFiles($this->_store['formName']);
     if (PEAR::isError($this->file)) {
         throw new Exception($this->file->getMessage(), $this->file->getCode());
     }
     if ($this->file->isMissing()) {
         throw new Exception('Please select a file!', 404);
     }
     if ($this->file->isValid()) {
         $this->_store['seed'] = substr(md5(time()), 0, 10);
         $this->_saveToDb();
         $name = $this->_createName();
         //throw new Exception($name);
         $this->file->setName($name);
         $moved = $this->file->moveTo($this->_store['fileVault']);
         if (!PEAR::isError($moved)) {
             return true;
         }
         $msg = $moved->getMessage();
         throw new Exception('We could not save the file: ' . $msg, 500);
     }
 }
function HandleLoadImageOurCategory()
{
    require_once "../includes/HTTP/Upload.php";
    $upload = new HTTP_Upload();
    $file = $upload->getFiles("imageFile");
    if (!$file->isValid()) {
        print "ќшибка при загрузке файла.";
        return;
    }
    $tempDir = "../data/tmp/";
    $moved = $file->moveTo($tempDir);
    if (PEAR::isError($moved)) {
        print "ќшибка при загрузке файла: " . $moved->getMessage();
        return;
    }
    $fName = "../data/ourcategory/" . $_REQUEST["id"] . "." . IMAGE_EXT;
    if (file_exists($fName)) {
        unlink($fName);
    }
    if (!rename($tempDir . $moved, $fName)) {
        print "ќшибка - файл не скопирован.";
        return;
    }
    print "‘айл успешно загружен.";
}
function HandleLoadImage()
{
    require_once "../includes/HTTP/Upload.php";
    $upload = new HTTP_Upload();
    $files = $upload->getFiles();
    $tempDir = "../data/tmp/";
    if ($_REQUEST["imgType"] == "normal") {
        // Получение большого файла
        $file = current($files);
        if (PEAR::isError($file) || !$file->isValid()) {
            print "Ошибка при загрузке файла: " . $file->getMessage();
            return;
        }
        $moved = $file->moveTo($tempDir);
        if (PEAR::isError($moved)) {
            print "Ошибка при загрузке файла: " . $moved->getMessage();
            return;
        }
        if ($_REQUEST["newItem"]) {
            $fName = "../" . getNormImagePath("new" . $_REQUEST["id"]);
        } else {
            $fName = "../" . getNormImagePath($_REQUEST["id"]);
        }
        if (file_exists($fName)) {
            unlink($fName);
        }
        if (!rename($tempDir . $moved, $fName)) {
            print "Ошибка - файл {$moved} не скопирован.";
            return;
        }
        chmod($fName, 0755);
        setUploaded($_REQUEST["id"], $_REQUEST["newItem"]);
    } else {
        if ($_REQUEST["imgType"] == "small") {
            // Получение маленького файла
            $file = next($files);
            if (PEAR::isError($file) || !$file->isValid()) {
                print "Ошибка при загрузке файла: " . $file->getMessage();
                return;
            }
            $moved = $file->moveTo($tempDir);
            if (PEAR::isError($moved)) {
                print "Ошибка при загрузке файла: " . $moved->getMessage();
                return;
            }
            if ($_REQUEST["newItem"]) {
                $fName = "../" . getSmallImagePath("new" . $_REQUEST["id"]);
            } else {
                $fName = "../" . getSmallImagePath($_REQUEST["id"]);
            }
            if (file_exists($fName)) {
                unlink($fName);
            }
            if (!rename($tempDir . $moved, $fName)) {
                print "Ошибка - файл {$moved} не скопирован.";
                return;
            }
            chmod($fName, 0755);
        }
    }
    print "Файлы успешно загружены.";
}
Example #4
0
<?php

require 'HTTP/Upload.php';
// New HTTP_Upload object
$upload = new HTTP_Upload();
// Retrieve the classnotes file
$file = $upload->getFiles('classnotes');
// If no problems with uploaded file
if ($file->isValid()) {
    $file->moveTo('/home/httpd/html/uploads');
    echo "File successfully uploaded!";
} else {
    echo $file->errorMsg();
}
?>

Example #5
0
define('HTML_FORM_MAX_FILE_SIZE', 16 * 1024 * 1024);
// 16 MB
$display_form = true;
$display_verification = false;
$success = false;
$errors = array();
PEAR::pushErrorHandling(PEAR_ERROR_RETURN);
do {
    if (isset($_POST['upload'])) {
        if (!validate_csrf_token($csrf_token_name)) {
            $errors[] = 'Invalid token.';
            break;
        }
        // Upload Button
        include_once 'HTTP/Upload.php';
        $upload_obj = new HTTP_Upload('en');
        $file = $upload_obj->getFiles('distfile');
        if (PEAR::isError($file)) {
            $errors[] = $file->getMessage();
            $log->err($file->getMessage() . "\n");
            $log->debug(print_r($file, true));
            break;
        }
        if ($file->isValid()) {
            $file->setName('uniq', 'pear-');
            $file->setValidExtensions('tgz', 'accept');
            $tmpfile = $file->moveTo(PEAR_UPLOAD_TMPDIR);
            if (PEAR::isError($tmpfile)) {
                $errors[] = $tmpfile->getMessage();
                $log->err("Failed to move uploaded file to " . PEAR_UPLOAD_TMPDIR);
                $log->err($tmpfile->getMessage());
 function process($params)
 {
     $errormsgs = array();
     $upload = new HTTP_Upload();
     $ftext = $upload->getFiles("ftext");
     if (!$ftext->isValid()) {
         $errormsgs[] = "Ошибка при загрузке файла текста";
     }
     $furls = $upload->getFiles("furls");
     if (!$furls->isValid()) {
         $errormsgs[] = "Ошибка при загрузке файла ссылок";
     }
     $fpagenames = $upload->getFiles("fpagenames");
     if (!$fpagenames->isValid()) {
         $errormsgs[] = "Ошибка при загрузке файла названий страниц";
     }
     $ftemplate = $upload->getFiles("ftemplate");
     if (!$ftemplate->isValid()) {
         $errormsgs[] = "Ошибка при загрузке файла шаблона";
     }
     if (!isset($params["x"]) || trim($params["x"]) == "") {
         $errormsgs[] = "X - не задано";
     }
     if (!isset($params["y"]) || trim($params["y"]) == "") {
         $errormsgs[] = "Y - не задано";
     }
     if (!isset($params["urls_wordsnum"]) || trim($params["urls_wordsnum"]) == "") {
         $errormsgs[] = "Минимальное кол-во слов между УРЛами - не задано";
     }
     if (sizeof($errormsgs) > 0) {
         $resultmsg = implode("<br>", $errormsgs);
         include "v/results.html";
         return;
     }
     $text_words = IndexController::get_words(fload($ftext->getProp("tmp_name")));
     $text_wordsnum = sizeof($text_words);
     $urls = file($furls->getProp("tmp_name"));
     $urls_num = sizeof($urls);
     $pagenames = file($fpagenames->getProp("tmp_name"));
     $pagenames_num = sizeof($pagenames);
     $template = fload($ftemplate->getProp("tmp_name"));
     $x = $params["x"];
     $y = $params["y"];
     $urls_wordsnum = $params["urls_wordsnum"];
     $resultmsg = "";
     if (($res1 = $text_wordsnum / $y / ($urls_num / $x)) >= 1) {
         //~ if (($res2 = ($pagenames_num / ($text_wordsnum / $y))) >= 1)  {
         if (($res3 = $y / ($x * $urls_wordsnum)) >= 1) {
             IndexController::clean_tmp();
             IndexController::generate_files($text_words, $y, $urls, $x, $pagenames, $urls_wordsnum, $template);
             IndexController::insert_links();
             $resultmsg = "Мышн комплит!";
         } else {
             $resultmsg = "Не хватает названий страниц.\n\t\t\t\t\t\tМинимальное кол-во слов между УРЛами: {$urls_wordsnum}.\n\t\t\t\t\t\tРезультат условия: {$y} / ({$x} * {$urls_wordsnum}) = " . round($res3, 5) . ".";
         }
         //~ }
         //~ else {
         //~ print $pagenames_num / ($text_wordsnum / $y);
         //~ $resultmsg = "Не хватает названий страниц.
         //~ Слов: $text_wordsnum, названий страниц: $pagenames_num.
         //~ Результат условия: " . round($res2, 5) . ".";
         //~ }
     } else {
         $resultmsg = "Не хватает СЛОВ исходного текста.\n\t\t\t\tСлов: {$text_wordsnum}.\n\t\t\t\tРезультат условия: " . round($res1, 5) . ".";
     }
     include "v/results.html";
 }
Example #7
0
 function postMultipart()
 {
     /*
     if ($this->identity()->anonymous()) {
         throw new k_NotAuthorized();
     }
     */
     if ($this->getForm()->validate()) {
         // @todo should be replaced by the construct wrapper
         // $adapter = new k_adapter_DefaultUploadedFileAccess();
         // $adapter->copy($this->body('file'), 'uploads/');
         // upload picture
         $upload = new HTTP_Upload("en");
         $file = $upload->getFiles("file");
         // @todo gives the wrong permissions when uploading
         if ($file->isValid()) {
             $moved = $file->moveTo('uploads/');
             if (PEAR::isError($moved)) {
                 throw new Exception($moved->getMessage());
             }
         } elseif ($file->isMissing()) {
             throw new Exception("No file was provided.");
         } elseif ($file->isError()) {
             throw new Exception($file->errorMsg());
         }
         $record = $this->event_gateway->fetch(array('gcal_event_id' => $this->getEventId(), "parameter" => 'image'));
         if (empty($record)) {
             $this->event_gateway->insert(array('gcal_event_id' => $this->getEventId(), "parameter" => 'image', 'key' => $file->getProp('name')));
         } else {
             $this->event_gateway->update(array('key' => $file->getProp('name')), array('gcal_event_id' => $this->getEventId(), "parameter" => 'image'));
         }
         return new k_SeeOther($this->url());
     }
     return $this->render();
 }
Example #8
0
 $sql = "\n\tINSERT INTO property\n\t(Price,Pricetype,Price2,PriceType2,house_number,Address1,Postcode,osx,osy,lease_free,state_of_trade_id,type_id,\n\tarea_id,longDescription,description,gch,doubleGlazed,receptions,bedrooms,bathrooms,garden,parking,\n\tnotes,total_area,image0,image1,image2,image3,image4,image5,image6,image7,image8,\n\timage9,image10,image11,image12,image13,image14,image15,banner,BannerLink,ThumbNail,\n\tCountdown,Dates,Hits,Neg,Branch,SaleLet,managed,furnished,lease_length,service_charge,ground_rent,other_details)\n\tVALUES\n\t('{$Price}','{$PriceType}','{$Price2}','{$PriceType2}','{$house_number}','{$Address1}','{$Postcode}','{$osx}','{$osy}','{$lease_free}','{$state_of_trade_id}','{$type_id}',\n\t'{$area_id}','{$longDescription}','{$description}','{$gch}','{$doubleGlazed}','{$receptions}','{$bedrooms}','{$bathrooms}','{$garden}','{$parking}',\n\t'{$notes}','{$total_area}','{$image0}','{$image1}','{$image2}','{$image3}','{$image4}','{$image5}','{$image6}','{$image7}','{$image8}',\n\t'{$image9}','{$image10}','{$image11}','{$image12}','{$image13}','{$image14}','{$image15}','{$banner}','{$BannerLink}','{$ThumbNail}',\n\t'{$Countdown}','{$dateToday}','{$Hits}','{$Neg}','{$Branch}','{$SaleLet}','{$managed}','{$furnished}','{$lease_length}','{$service_charge}','{$ground_rent}','{$other_details}')";
 $q = $db->query($sql);
 //echo $sql;
 if (DB::isError($q)) {
     die("insert error: " . $q->getMessage());
 }
 $query = 'SELECT LAST_INSERT_ID()';
 $result = mysql_query($query);
 $rec = mysql_fetch_array($result);
 $insert_id = $rec[0];
 $intPropID = $insert_id;
 //$sql_body = "Dates = 'Record Created'";
 //change_log($_SESSION["s_userid"],"property","prop_ID",$intPropID,$sql_body,$PHPSESSID);
 // images
 $mode = $dateFile . ".jpg";
 $upload = new HTTP_Upload();
 $files = $upload->getFiles();
 // returns an array of file objects or error
 //print_r($files);
 $prepend = $intPropID . '_';
 $i = 0;
 foreach ($files as $key => $value) {
     if (!$value->isMissing()) {
         // if there is a file
         if ($value->isValid()) {
             // if the file is valid
             $value->setName($mode, $prepend, $append);
             // naming
             $properties = $value->getProp();
             // get properties array
             $file_name = $value->moveTo($uploadPath);
Example #9
0
		</tr>
		</table>
		<input type="hidden" name="action" value="create">
		</form>
		';
    }
} elseif ($action == "upload") {
    // upload a completed pdf and add to db
    if ($_POST["issue"]) {
        $issue = $_POST["issue"];
        $pdf = $_FILES["pdf"];
        $position = $_POST["position"];
        $notes = $_POST["notes"];
        // alt upload
        $mode = "uniq";
        $upload = new HTTP_Upload();
        $file = $upload->getFiles("pdf");
        if ($file->isValid()) {
            $file->setName($mode, $prepend, $append);
            $properties = $file->getProp();
            $moved = $file->moveTo($advertUploadPath);
            if (!PEAR::isError($moved)) {
                //echo "File was moved to $advertUploadPath";
            }
        }
        $filename = $properties["name"];
        $origfile = $properties["real"];
        $filesize = $properties["size"];
        $filetype = $properties["type"];
        //print_r($properties);
        //exit;
Example #10
0
 function update_record()
 {
     //echo "eid:".$this->eid.",type_id:".$this->type_id.",I'm in update!<br>";
     PostFieldSetter::set_prop_fields_from_standin();
     PostFieldSetter::set_post_password_field();
     $upload = new HTTP_Upload("en");
     foreach ($_FILES as $fldname => $fileobj) {
         //echo "yo:".$fldname.":yo";
         if (ereg("^pi26epi|^pi27epi|^pi61epi", $fldname) and !empty($fileobj['tmp_name'])) {
             $file = $upload->getFiles($fldname);
             $file->setName('uniq');
             if ($file->isValid()) {
                 $moved = $file->moveTo(APP_ROOT . "/client_uploaded_images/");
                 if (PEAR::isError($moved)) {
                     die("unable to upload the image(s). Error ref: @E@123543fwq<br>" . $moved->getMessage());
                 }
                 $_REQUEST[$fldname] = $file->getProp('name');
             } else {
                 echo $file->getMessage();
             }
         }
     }
     $this->glu->eid = $this->eid;
     $this->glu->set_type_id($this->type_id);
     $this->glu->set_ent_prop_3dhash_from_post($this->eid);
     $this->glu->commit_updates_from_ent_prop_3dhash();
     if ($_REQUEST['groups_to_delete']) {
         foreach ($_REQUEST['groups_to_delete'] as $pgidNridN) {
             ereg("^pgid([0-9]+)rid([0-9]+)\$", $pgidNridN, $subpatterns);
             $type_id = $_REQUEST['rec_type_id'];
             $eid = $_REQUEST['rec_eid'];
             $prop_group_id = $subpatterns[1];
             $ron = $subpatterns[2];
             RecordsSys_EntityManagementSystems::del_prop_group_by_ron($type_id, $prop_group_id, $ron, $eid);
         }
     }
     if ($_REQUEST['props_to_delete']) {
         foreach ($_REQUEST['props_to_delete'] as $pidNridN) {
             ereg("^pid([0-9]+)rid([0-9]+)\$", $pidNridN, $subpatterns);
             $eid = $_REQUEST['rec_eid'];
             $prop_id = $subpatterns[1];
             $ron = $subpatterns[2];
             RecordsSys_EntityManagementSystems::del_prop_by_ron($prop_id, $ron, $eid);
         }
     }
     if ($_REQUEST['rep_prop_quals']) {
         foreach ($_REQUEST['rep_prop_quals'] as $pqiNpgiNronN) {
             if (ereg("^pqi([0-9]+)pgi([0-9]+)ron([0-9]+)\$", $pqiNpgiNronN, $subpatterns) and $subpatterns[1] != 0) {
                 $eid = $_REQUEST['rec_eid'];
                 $prop_qual_id = $subpatterns[1];
                 $prop_group_id = $subpatterns[2];
                 $ron = $subpatterns[3];
                 RecordsSys_EntityManagementSystems::update_repeat_prop_qualifier($eid, $prop_group_id, 0, $ron, $prop_qual_id);
             } else {
                 if (ereg("^pqi([0-9]+)pi([0-9]+)ron([0-9]+)\$", $pqiNpgiNronN, $subpatterns) and $subpatterns[1] != 0) {
                     $eid = $_REQUEST['rec_eid'];
                     $prop_qual_id = $subpatterns[1];
                     $prop_id = $subpatterns[2];
                     $ron = $subpatterns[3];
                     RecordsSys_EntityManagementSystems::update_repeat_prop_qualifier($eid, 0, $prop_id, $ron, $prop_qual_id);
                 }
             }
         }
     }
     //$memcache_obj = memcache_pconnect('localhost', 11211);
     //memcache_delete($memcache_obj, $this->eid,0);
     //memcache_search_key::delete_search_keys();
 }
Example #11
0
 function upload($field_name)
 {
     $upload = new HTTP_Upload('en');
     $file = $upload->getFiles($field_name);
     if ($file->isError()) {
         $this->error[] = $file->getMessage();
         return false;
     }
     $prop = $file->getProp();
     // returnere et array med oplysninger om filen.
     if (!$file->isValid()) {
         $this->error[] = "Filen er ikke en gyldig upload fil";
         return false;
     }
     if (!isset($prop['ext']) || $prop['ext'] == "") {
         // Ved ikke om denne skal v�re der. Mener at mac-computere tit undlader at bruge extensions. /Sune 2/3 2006
         // den skal v�re der, synes jeg for jeg har ofte oplevet at mac snyder / lo
         $this->error[] = 'Filen mangler en filtype, f.eks. .pdf';
         return false;
     }
     // $instance_id = $this->updateInstance(array('type' => 'original', ));
     $id = $this->update(array('file_name' => $prop['real'], 'file_size' => $prop['size'], 'file_type' => $prop['type']));
     $server_file_name = $id . "." . strtolower($prop['ext']);
     $file->setName($server_file_name);
     $moved = $file->moveTo($this->upload_path);
     if (PEAR::isError($moved)) {
         $this->error[] = 'Der opstod en fejl under flytningen af filen';
         return false;
     }
     $mime_type = $this->_getMimeType($prop['type'], 'mime_type');
     if ($mime_type['image']) {
         $imagesize = getimagesize($this->upload_path . $server_file_name);
         $width = $imagesize[0];
         // imagesx($file);
         $height = $imagesize[1];
         // imagesy($file);
     } else {
         $width = 0;
         $height = 0;
     }
     $this->update(array('server_file_name' => $server_file_name, 'width' => $width, 'height' => $height));
     $this->load();
     return $id;
 }
Example #12
0
     # mulitple recipients
     /*(if (strpos($recipient,';') == true) {
     		$recipient = explode(';',$recipient);
     		}			*/
 }
 if (!validate_email($_POST["sender"])) {
     $errors[] = "Sender is required and must be a valid email address";
 } else {
     $sender = $_POST["sender"];
 }
 $title = $_POST["title"];
 #if ($_POST["thefile"]) {
 $thefile = $_FILES["thefile"];
 // alt upload
 $mode = "uniq";
 $upload = new HTTP_Upload();
 $file = $upload->getFiles("thefile");
 if ($file->isValid()) {
     $file->setName($mode, $prepend, $append);
     $properties = $file->getProp();
     $moved = $file->moveTo($filesUploadPath);
     if (!PEAR::isError($moved)) {
         //echo "File was moved to $advertUploadPath";
     }
 }
 $filename = $properties["name"];
 $origfile = $properties["real"];
 $filesize = $properties["size"];
 $filetype = $properties["type"];
 #if ($filetype !== "application/pdf") {
 #	$errors[] = "File must be a PDF";