// Retrieve the status using the getStatus() function below echo json_encode(getStatusAPC($_GET['key'])) . ';'; } else { // Process any files in the PHP $_FILES[] array and return to the // main script if everything went well. Otherwise we'll display a // error page. $allowedExtensions = array('jpg', 'jpeg', 'gif', 'png'); $errorMessage = null; $storedFiles = array(); if (count($_FILES) > 0) { try { // Process each file foreach ($_FILES as $key => $info) { if ($_FILES[$key]['filename']) { // storeFile() throws exceptions $file = storeFile($key, 'uploads/', $allowedExtensions); // Keep track of stored files incase you need to // remove them. $storedFiles[] = $file; } } if ($_POST['APC_UPLOAD_PROGRESS'] && function_exists('apc_store')) { // Store the file information so it can be // retrieved in the progress watcher apc_store('upload_finished_' . $_POST['APC_UPLOAD_PROGRESS'], $storedFiles); // Die. This message will display in the iframe die('Upload complete.'); } // Everything was successful so redirect back // to the main index page header('Location: ../');
function prepareUpload($name, $kA, &$data) { # Returns the same errCode from storefile, plus 8 (unable to create thumbails), 9 (near time limit), 10 (quota exceeded) # file format should be [field][ids_]#_thumbid (or 1 for no thumb) if (!isset($_FILES[$name])) { return 4; } else { if ($_FILES[$name]['error'] < 5 && $_FILES[$name]['error'] != 0) { return $_FILES[$name]['error']; } else { if (!is_file($_FILES[$name]['tmp_name'])) { return 3; // file not found } } } $isImg = isset($this->fields[$name][CONS_XML_TWEAKIMAGES]) || isset($this->fields[$name][CONS_XML_THUMBNAILS]); if ($isImg) { # prepare thumbnail handling variables, as well conditional thumbs if (isset($this->fields[$name][CONS_XML_CONDTHUMBNAILS])) { // /> 'a' 'b' // / t1 t2 t1 t2 // field:[ | ;][ | ;] preg_match("@ENUM \\(([^)]*)\\).*@", $this->fields[$this->fields[$name][CONS_XML_CONDTHUMBNAILS][0]][CONS_XML_SQL], $regs); $thumbsettings = explode(";", $this->fields[$name][CONS_XML_CONDTHUMBNAILS][1]); $enums = explode(",", $regs[1]); $c = 0; $found = false; foreach ($enums as $reg) { if ($data[$this->fields[$name][CONS_XML_CONDTHUMBNAILS][0]] == str_replace("'", "", $reg)) { $thumbsettings = explode("|", $thumbsettings[$c]); $found = true; break; } $c++; } if (!$found) { $thumbsettings = isset($this->fields[$name][CONS_XML_THUMBNAILS]) ? $this->fields[$name][CONS_XML_THUMBNAILS] : explode("|", $thumbsettings[0]); } } else { $thumbsettings = isset($this->fields[$name][CONS_XML_THUMBNAILS]) ? $this->fields[$name][CONS_XML_THUMBNAILS] : array(array(0, 0)); } } # quota test $this->parent->loadDimconfig(true); if (isset($this->parent->dimconfig['_usedquota']) && isset($this->parent->dimconfig['quota']) && $this->parent->dimconfig['quota'] > 0) { if ($this->parent->dimconfig['_usedquota'] > $this->parent->dimconfig['quota']) { return 10; } # quota exceeded } # prepares path $path = CONS_FMANAGER . $this->name . "/"; if (!is_dir($path)) { makeDirs($path); } if (isset($this->fields[$name][CONS_XML_FILEPATH])) { # custom path $path .= $this->fields[$name][CONS_XML_FILEPATH]; if ($path[strlen($path) - 1] != "/") { $path .= "/"; } if (!is_dir($path)) { safe_mkdir($path); } } # prepares filename with item keys $filename = $name . "_"; foreach ($kA as $id => $value) { $filename .= $value . "_"; } # prepares filetype filter if (isset($this->fields[$name][CONS_XML_FILETYPES])) { $ftypes = "udef:" . $this->fields[$name][CONS_XML_FILETYPES]; } else { $ftypes = ""; } # prepares watermark and/or crop (for images) $WM_TODO = array(); if (isset($this->fields[$name][CONS_XML_TWEAKIMAGES])) { foreach ($this->fields[$name][CONS_XML_TWEAKIMAGES] as $c => $WM) { # stamp:over(filename@x,y)[r] # [r] not implemented yet # stamp:under(filename@x,y)[r] # croptofit:top bottom left right # might have multiple with + separator $TODO = array(); $WM = explode("+", $WM); foreach ($WM as $thisWM) { $concept = explode(":", $thisWM); if ($concept[0] == "stamp") { $thisTODO = array(); $stamptype = explode("(", $concept[1]); // ...(...@x,y)R $parameters = explode(")", $stamptype[1]); // ...@x,y)R $stamptype = $stamptype[0]; $thisTODO['isBack'] = $stamptype == "under"; $resample = isset($parameters[1]) && $parameters[1] == "r"; $parameters = $parameters[0]; $parameters = explode("@", $parameters); // ...@x,y $parameters[1] = explode(",", $parameters[1]); // x,y $thisTODO['position'] = $parameters[1]; $thisTODO['filename'] = CONS_PATH_PAGES . $_SESSION['CODE'] . "/files/" . $parameters[0]; if ($resample) { $thisTODO['resample'] = explode(",", $thumbsettings[$c]); } $TODO[] = $thisTODO; } else { if ($concept[0] == "croptofit") { $TODO[] = "C" . (isset($concept[1]) ? $concept[1] : ''); } } } $WM_TODO[$c] = $TODO; } } # perform upload and possible thumbnails if the file was uploaded $errCode = 4; # supose no upload if (isset($_FILES[$name])) { # initial size check (no need to even try if it's bigger) $mfs = isset($this->fields[$name][CONS_XML_FILEMAXSIZE]) ? $this->fields[$name][CONS_XML_FILEMAXSIZE] : 0; if ($mfs > 0 && !$isImg) { if (filesize($_FILES[$name]['tmp_name']) > $mfs) { if (!isset($_FILES[$name]['virtual'])) { @unlink($_FILES[$name]['tmp_name']); } return 2; # file larger than allowed by field and is not an image (thus, we cannot reduce) } } # perform upload $thisFilename = $path . $filename . "1"; $errCode = storeFile($_FILES[$name], $thisFilename, $ftypes); # <----------------- upload happens here //$errCode = storeFile($_FILES[$name],$thisFilename,$ftypes,true); # <----------------- use this (note the true) for full debug $arquivo = explode(".", $thisFilename); $ext = strtolower(array_pop($arquivo)); # <-- ext for the file $arquivo = implode(".", $arquivo); # if ok and is an image, check thumbnails if ($errCode == 0 && $isImg) { # delete other images (could have uploaded a different image type than before on edit) $exts = array("jpg", "gif", "swf", "png", "jpeg", "ico", "bmp"); foreach ($exts as $x => $sext) { if ($sext != $ext && is_file($arquivo . "." . $sext)) { @unlink($arquivo . "." . $sext); } } # if this is not an JPG image, and it's larger then mfs, won't work at all. Abort if ($mfs > 0 && filesize($thisFilename) > $mfs && $ext != 'jpg') { if (!isset($_FILES[$name]['virtual'])) { @unlink($thisFilename); } return 2; # file larger than allowed by field and is not a resizable image } if ($ext == "swf") { // might have tweakimages (isImg) but accept flash #check if the dimensions of the flash are too big $dim = explode(",", $thumbsettings[0]); $h = getimagesize($thisFilename); if ($h[2] != IMAGETYPE_SWF && $h[2] != IMAGETYPE_SWC) { die; return 7; // swf but not a swf!? } else { if ($h[0] > $dim[0] || $h[1] > $dim[1]) { return 12; // too big } } } else { # $thisFilename has the image untreated. # Create all thumbnails, then treat the main image: $thumbVersions = count($thumbsettings); if ($thumbVersions > 1) { # has other versions/thumbnails, work these first if (!is_dir($path . "t/")) { makeDirs($path . "t/"); } for ($tb = 1; $tb < $thumbVersions; $tb++) { # for all thumbs ... if ($this->parent->nearTimeLimit()) { return 9; } $dim = explode(",", $thumbsettings[$tb]); # remember, the array start at 0, not 1 $thisFilenameT = $path . "t/" . $filename . ($tb + 1); if (!resizeImage($thisFilename, $thisFilenameT, $dim[0], isset($dim[1]) ? $dim[1] : 0, 0, isset($WM_TODO[$tb]) ? $WM_TODO[$tb] : array()) == 2) { # error! @unlink($thisFilename); return 8; // whoever called this function should also perform cleanup } } #for each thumb } # done, process main image $dim = explode(",", $thumbsettings[0]); if (resizeImageCond($thisFilename, $dim[0], isset($dim[1]) ? $dim[1] : 0, isset($WM_TODO[0]) ? $WM_TODO[0] : array()) == 2) { @unlink($thisFilename); return 8; // whoever called this function should also perform cleanup } # check mfs clearstatcache(); # resize could have changed file size if ($mfs > 0 && filesize($thisFilename) > $mfs) { if ($ext == 'jpg') { $miniatura_id = imagecreatefromjpeg($thisFilename); imagejpeg($miniatura_id, $thisFilename, 50); // reduce step2 imagedestroy($miniatura_id); clearstatcache(); if (filesize($thisFilename) > $mfs) { unlink($thisFilename); return 2; // unable to reduce more } } else { # can't reduce quality on non-jpg unlink($thisFilename); return 2; // unable to reduce more } } } } } # upload + image handling ok? if ($errCode == 0) { $this->parent->dimconfig['_usedquota'] += filesize($thisFilename); # simple quota controler, note this is not counting thumbs $this->parent->saveConfig(); } return $errCode; }
echo "Valid"; } exit; } //Functions function storeFile() { move_uploaded_file($_FILES["file"]["name"], "uploads"); echo "<script type='text/javascript'>alert('Uploading: " . $_FILES['file']['name'] . "');</script><br />"; //Check that it is in the uploads folder if (file_exists($uploadPath . $_FILES["file"]["name"])) { echo $_FILES["file"]["name"]; echo "<script type='text/javascript'>alert('" . $_FILES['file']['name'] . " was uploaded');</script><br />"; } else { echo "<script type='text/javascript'>alert('ERROR');</script><br />"; } } function getFileData($filename) { $chosenFile = $_FILES['file']['name']; $fileContent = file_get_contents($chosenFile); $jsonString = json_encode($fileContent); echo $jsonString; } //Run Upon Submit if (array_key_exists('file', $_GET) && array_key_exists('chartType', $_GET)) { $fileName = escape_html($_GET['file']); $chartType = escape_html($_GET['chartType']); storeFile(); getFileData($fileName); }
require_once "getid3/getid3.php"; $getID3 = new getID3(); //find all files in the new music directory $srcdir = "newmusic"; $destdir = "library"; $files = scandir($srcdir); //move the files to the library foreach ($files as $f) { //ignore the parent and current directories if ($f != "." && $f != "..") { //get ID3 info $info = $getID3->analyze("newmusic/" . $f); //copy info into comments getid3_lib::CopyTagsToComments($info); //store this audio file in the library $ret = storeFile($info, $con); //check for errors moving to the library if ($ret != "") { $errorOut .= $ret . "<br>"; } } } if ($errorOut != "Errors are as follows: <br>") { echo $errorOut; } mysql_close(); ?> <?php //stores files into their proper location in the library and adds their record to the db function storeFile($info, $con)
//Declare variables $titleName = 'Temperature Chart'; $yAxisTitle = 'Temperature'; $celcius = array(); $fahrenheit = array(); $time = array(); $date = array(); $fileName; $fileContent; $fileLines; $chartType = array_key_exists('chartType', $_POST) ? escape_html($_POST['chartType']) : 'No Type Chosen'; $uploadPath = "uploads/"; //Logic if (array_key_exists('newFile', $_FILES) && !empty($_FILES['newFile']['name']) && $_POST['existingFile'] == 'default') { $fileName = escape_html($_FILES['newFile']['name']); storeFile($uploadPath, $fileName); makeFileLines(); makeHTML($fileLines); } else { if (array_key_exists('existingFile', $_POST) && $_POST['existingFile'] != 'default' && $_FILES['newFile']['name'] == '') { $fileName = $_POST['existingFile']; existingFileContent(); makeFileLines(); makeHTML($fileLines); } else { if (array_key_exists('existingFile', $_POST) && $_POST['existingFile'] != 'default' && array_key_exists('newFile', $_FILES) && !empty($_FILES['newFile']['name'])) { $fileName = escape_html($_FILES['newFile']['name']); $previousFileName = $_POST['existingFile']; bothMethods(); } else { die('Sorry buddy, you either didn\'t upload a file or it wasn\'t a CSV file.');
// GCM Registration ID $data = 0; if (isset($_FILES['upfile']) && isset($_FILES['upfile']['tmp_name']) && $_FILES['upfile']['tmp_name'] != "") { $data = 2; } if (isset($_FILES['upfile']['error'])) { switch ($_FILES['upfile']['error']) { case UPLOAD_ERR_OK: break; case UPLOAD_ERR_NO_FILE: error_log('Error: No file sent.'); break; case UPLOAD_ERR_INI_SIZE: case UPLOAD_ERR_FORM_SIZE: error_log('Error: Exceeded PHP filesize limit.'); break; default: error_log('Error: Unknown error.'); break; } } $mid = storeMessage($message, $gcm_regid, $data); if (isset($_FILES['upfile']) && isset($_FILES['upfile']['tmp_name']) && $_FILES['upfile']['tmp_name'] != "") { $handle = fopen($_FILES['upfile']['tmp_name'], "r"); storeFile($mid, $handle); fclose($handle); } } else { // message details missing } dbclose();
} } if (isset($dimconfigMD[$name][CONS_XML_FILETYPES])) { $ftypes = "udef:" . $dimconfigMD[$name][CONS_XML_FILETYPES]; } else { $ftypes = ""; } $mfs = isset($dimconfigMD[$name][CONS_XML_FILEMAXSIZE]) ? $dimconfigMD[$name][CONS_XML_FILEMAXSIZE] : 0; if (isset($dimconfigMD[$name][CONS_XML_FILEMAXSIZE]) && !$isImg) { if (filesize($_FILES[$name]['tmp_name']) > $dimconfigMD[$name][CONS_XML_FILEMAXSIZE]) { @unlink($_FILES[$name]['tmp_name']); $core->errorControl->raise(202, $name, 'dincomfig'); continue; } } $errCode = storeFile($_FILES[$name], $FirstfileName, $ftypes); if ($errCode == 0 && $isImg) { # $FirstfileName has the file untreated # delete other images (could have uploaded a different image type than before on edit) $arquivo = explode(".", $FirstfileName); $ext = strtolower(array_pop($arquivo)); # <-- ext for the file $arquivo = implode(".", $arquivo); $exts = array("jpg", "gif", "swf", "png", "jpeg", "ico"); foreach ($exts as $x => $sext) { if ($sext != $ext && is_file($arquivo . "." . $sext)) { @unlink($arquivo . "." . $sext); } } # if this is not an JPG image, and it's larger then mfs, won't work at all. Abort if ($mfs > 0 && filesize($FirstfileName) > $mfs && $ext != 'jpg') {