function initialize_page() { $post_action = ""; if (isset($_POST['submit'])) { $post_action = $_POST['submit']; } if ($post_action == "Add Document" || $post_action == "Add and Return to List") { $name = $_POST['name']; $file_type = getFileExtension($_FILES['file']['name']); $filename = slug(getFileName($_FILES['file']['name'])); $filename_string = $filename . "." . $file_type; // Check to make sure there isn't already a file with that name $possibledoc = Documents::FindByFilename($filename_string); if (is_object($possibledoc)) { setFlash("<h3>Failure: Document filename already exists!</h3>"); redirect("admin/add_document"); } $target_path = SERVER_DOCUMENTS_ROOT . $filename_string; if (move_uploaded_file($_FILES['file']['tmp_name'], $target_path)) { $new_doc = MyActiveRecord::Create('Documents', array('name' => $name, 'filename' => $filename_string, 'file_type' => $file_type)); $new_doc->save(); if (!chmod($target_path, 0644)) { setFlash("<h3>Warning: Document Permissions not set; this file may not display properly</h3>"); } setFlash("<h3>Document uploaded</h3>"); } else { setFlash("<h3>Failure: Document could not be uploaded</h3>"); } if ($post_action == "Add and Return to List") { redirect("admin/list_documents"); } } }
/** * Initialize the upload class * @param string $upload The key value of the $_FILES superglobal to use */ private function _initialize($upload) { $this->_uploadedFile = $upload['name']; $this->_tempName = $upload['tmp_name']; $this->_fileSize = $upload['size']; $this->_extension = getFileExtension($this->_uploadedFile); $this->_mimeType = getFileType($this->_tempName); }
/** * Get file extension for database resource. * @param $fileId Id of file in database to get extension from. */ function getDatabaseFileExtension($fileId) { global $dbi; $result = $dbi->query("SELECT name FROM " . fileTableName . " WHERE id=" . $dbi->quote($fileId)); if ($result->rows()) { list($fileName) = $result->fetchrow_array(); return convertToLowercase(getFileExtension($fileName)); } return ""; }
function getFileName($album, $filename) { global $pic_root; $ext = getFileExtension($filename); $file_name = str_replace("." . $ext, "", $filename); $upload_file_name = $file_name; $i = 0; while (file_exists($pic_root . $album . "/" . $upload_file_name . "." . $ext)) { $upload_file_name = $file_name . "-" . ++$i; } return $upload_file_name . "." . $ext; }
function listFilesFromType($folder, $type) { $array = array(); if ($d = opendir($folder)) { while (false !== ($file = readdir($d))) { if ($file != '.' && $file != '..' && getFileExtension($file) == $type) { $array[] .= $folder . "/" . $file; } } } return $array; }
/** * Returns an overview of certain documents * * @param Array $documents Ids of the documents in question * @param mixed $open Array containing open states of documents * @return string Overview of documents as html, ready to be displayed */ function show_documents($documents, $open = null) { if (!is_array($documents)) { return; } if (!is_null($open) && !is_array($open)) { $open = null; } if (is_array($open)) { reset($open); $ank = key($open); } if (!empty($documents)) { $query = "SELECT {$GLOBALS['_fullname_sql']['full']} AS fullname, username, user_id,\n dokument_id, filename, filesize, downloads, protected, url, description,\n IF(IFNULL(name, '') = '', filename, name) AS t_name,\n GREATEST(a.chdate, a.mkdate) AS chdate\n FROM dokumente AS a\n LEFT JOIN auth_user_md5 USING (user_id)\n LEFT JOIN user_info USING (user_id)\n WHERE dokument_id IN (?)\n ORDER BY a.chdate DESC"; $statement = DBManager::get()->prepare($query); $statement->execute(array($documents)); $documents = $statement->fetchAll(PDO::FETCH_ASSOC); } foreach ($documents as $index => $document) { $type = empty($document['url']) ? 0 : 6; $is_open = is_null($open) || $open[$document['dokument_id']] ? 'open' : 'close'; $extension = getFileExtension($document['filename']); // Create icon $icon = sprintf('<a href="%s">%s</a>', GetDownloadLink($document['dokument_id'], $document['filename'], $type), GetFileIcon($extension, true)->asImg()); // Create open/close link $link = $is_open === 'open' ? URLHelper::getLink('#dok_anker', array('close' => $document['dokument_id'])) : URLHelper::getLink('#dok_anker', array('open' => $document['dokument_id'])); // Create title including filesize and number of downloads $size = $document['filesize'] > 1024 * 1024 ? sprintf('%u MB', round($document['filesize'] / 1024 / 1024)) : sprintf('%u kB', round($document['filesize'] / 1024)); $downloads = $document['downloads'] == 1 ? '1 ' . _('Download') : $document['downloads'] . ' ' . _('Downloads'); $title = sprintf('<a href="%s"%s class="tree">%s</a> (%s / %s)', $link, $ank == $document['dokument_id'] ? ' name="dok_anker"' : '', htmlReady(mila($document['t_name'])), $size, $downloads); // Create additional information $addon = sprintf('<a href="%s">%s</a> %s', URLHelper::getLink('dispatch.php/profile', array('username' => $document['username'])), $document['fullname'], date('d.m.Y H:i', $document['chdate'])); if ($document['protected']) { $addon = tooltipicon(_('Diese Datei ist urheberrechtlich geschützt!')) . ' ' . $addon; } if (!empty($document['url'])) { $addon .= ' ' . Icon::create('link-extern', 'clickable', ['title' => _('Diese Datei wird von einem externen Server geladen!')])->asImg(16); } // Attach created variables to document $documents[$index]['addon'] = $addon; $documents[$index]['extension'] = $extension; $documents[$index]['icon'] = $icon; $documents[$index]['is_open'] = $is_open; $documents[$index]['link'] = $link; $documents[$index]['title'] = $title; $documents[$index]['type'] = $type; } $template = $GLOBALS['template_factory']->open('user_activities/files-details'); $template->documents = $documents; return $template->render(); }
function move($path, $filename, $newname = null) { $allowed = array('jpg', 'jpeg', 'pdf', 'png', 'xls', 'xlsx', 'zip'); if (file_exists($_FILES[$filename]['tmp_name'])) { if (in_array(getFileExtension(getFileName($filename)), $allowed) && $_FILES[$filename]['error'] == 0) { $uploadname = isset($newname) ? $newname : getFileName($filename); try { move_uploaded_file($_FILES[$filename]['tmp_name'], $path . $uploadname); } catch (Exception $e) { echo "Error Occurred Uploading File: " . $e->getMessage(); } } } else { throw new Exception('FILE NOT FOUND'); } }
function uploadFiletoDB($UserFileName) { $TransactionArray = array(); $TblName = TableName; $FileName = $_FILES[$UserFileName]['name']; $FileServerName = $_FILES[$UserFileName]['tmp_name']; $CSVFIle = 'transactionTable.csv'; $CSVDelimiter = ';'; $ValidRecordswrited = 0; $InvalidRecords = 0; if (getFileExtension($FileName) == 'xlsx') { convertXLStoCSV($FileServerName, $CSVFIle); $CSVDelimiter = ','; } else { $CSVFIle = $FileServerName; } $TransactionArray = csv_to_array($CSVFIle, $CSVDelimiter); if (sizeof($TransactionArray) > 100000) { echo '<br>'; echo "Error - file rows cont is to much"; return false; } $Connection = mysql_connect(ServerName, UserName, Password); $db_selected = mysql_select_db(DBName, $Connection); if (!$Connection) { die("Connection failed: " . mysql_error()); } foreach ($TransactionArray as $Line) { if (checkTransactionRecord($Line)) { $Request = "INSERT INTO {$TblName}(`Account`, `Description`, `CurrencyCode`, `Ammount`) VALUES ('{$Line['Account']}','{$Line['Description']}','{$Line['CurrencyCode']}',{$Line['Amount']})"; $result = mysql_query($Request); if (!$result) { echo 'Query error: ' . mysql_error(); } else { $ValidRecordswrited++; } } else { $InvalidRecords++; } } mysql_close($Connection); echo '<br> <br>'; echo "Valid records writed to DataBase: {$ValidRecordswrited}"; echo '<br>'; echo "Invalid records count: {$InvalidRecords}"; }
function upload_file($tabla, $type, $archivo, $archivo_name) { $s_ = "select * from configuracion where variable='ruta_cargas'"; $r_ = mysql_query($s_); $d_ = mysql_fetch_array($r_); $r_server = $d_['valor']; $pext = getFileExtension($archivo_name); $nombre = date("YmdHis") . "." . $pext; $nom_final = $r_server . $nombre; if (is_uploaded_file($archivo)) { if (!copy($archivo, "{$nom_final}")) { echo "<script>alert('Error al subir el archivo: {$nom_final}');</script>"; upload_form($tabla); exit; } else { insert_csv($tabla, $type, $nombre); } } }
function save_uploaded_file($tmp_name, $file_name, $isportimg = false, $isentryimg = false, $maxwidth = 0, $maxheight = 0) { $filetype = getFileExtension($file_name); $file_name = slug(basename($file_name, $filetype)); $new_file_name = $this->id . "-" . $file_name . '.' . $filetype; move_uploaded_file($tmp_name, $this->get_local_image_path($new_file_name)); chmod($this->get_local_image_path($new_file_name), 0644); $max_width = 0; $max_height = 0; if ($maxwidth != 0) { $max_width = $maxwidth; } elseif ($maxheight != 0) { $max_height = $maxheight; } elseif ($isportimg) { if (defined("MAX_PORTFOLIO_IMAGE_HEIGHT")) { $max_height = MAX_PORTFOLIO_IMAGE_HEIGHT; } if (defined("MAX_PORTFOLIO_IMAGE_WIDTH")) { $max_width = MAX_PORTFOLIO_IMAGE_WIDTH; } } elseif ($isentryimg) { if (defined("MAX_ENTRY_IMAGE_HEIGHT")) { $max_height = MAX_ENTRY_IMAGE_HEIGHT; } if (defined("MAX_ENTRY_IMAGE_WIDTH")) { $max_width = MAX_ENTRY_IMAGE_WIDTH; } } else { if (defined("MAX_GALLERY_IMAGE_HEIGHT")) { $max_height = MAX_GALLERY_IMAGE_HEIGHT; } if (defined("MAX_GALLERY_IMAGE_WIDTH")) { $max_width = MAX_GALLERY_IMAGE_WIDTH; } } $this->filename = $new_file_name; $this->save(); resizeToMultipleMaxDimensions($this->get_local_image_path($new_file_name), $max_width, $max_height, $filetype); //$query = "UPDATE photos SET filename = $file_name WHERE id = {$this->id};"; //return mysql_query( $query, MyActiveRecord::Connection() ) or die( $query ); }
function saveFileTo($name, $path, $width = 0, $height = 0) { if (!$_FILES[$name]) { return; } if ($_FILES[$name]["error"] != 0) { return; } $tempFile = $_FILES[$name]['tmp_name']; $fileName = $_FILES[$name]['name']; //$fileSize = $_FILES['Filedata']['size']; if (!is_dir(dirname($path))) { mkdir(dirname($path), true); chmod(dirname($path), 777); } if ($width == 0) { move_uploaded_file($tempFile, $path); } else { move_uploaded_file($tempFile, $tempFile . "." . getFileExtension($fileName)); createImage($tempFile . "." . getFileExtension($fileName), $path, $width, $height); } }
function uploadFile($file, $path, $allowType, $maxSize) { $fileName = $file['name']; $ext = getFileExtension($fileName); $fileSize = $file['size']; $tmpFile = $file['tmp_name']; $result = ["error" => [], "path" => ""]; if ($fileSize > $maxSize) { $result['error'][] = ["msg" => "Exceeded filesize limit (" . $maxSize / 1000000 . "MB)"]; } if (count($result['error']) == 0) { $fileName = time() . "_" . $fileName; if (!is_dir(getcwd() . $path)) { mkdir($path, 0777, true); } $path = $path . "/" . $fileName; if (move_uploaded_file(stmpFile, getcwd() . $path)) { $result['path'] = $path; } else { $result['error'][] = ["msg" => " Error on upload file : Permission denied"]; } } return $result; }
function getMIMEType($ext, $filename = null) { if ($filename) { return getMIMEType(getFileExtension($filename)); } else { switch (strtolower($ext)) { // Image case 'gif': return 'image/gif'; case 'jpeg': case 'jpg': case 'jpe': return 'image/jpeg'; case 'png': return 'image/png'; case 'tiff': case 'tif': return 'image/tiff'; case 'bmp': return 'image/bmp'; // Sound // Sound case 'wav': return 'audio/x-wav'; case 'mpga': case 'mp2': case 'mp3': return 'audio/mpeg'; case 'm3u': return 'audio/x-mpegurl'; case 'wma': return 'audio/x-msaudio'; case 'ra': return 'audio/x-realaudio'; // Document // Document case 'css': return 'text/css'; case 'html': case 'htm': case 'xhtml': return 'text/html'; case 'rtf': return 'text/rtf'; case 'sgml': case 'sgm': return 'text/sgml'; case 'xml': case 'xsl': return 'text/xml'; case 'hwp': case 'hwpml': return 'application/x-hwp'; case 'pdf': return 'application/pdf'; case 'odt': case 'ott': return 'application/vnd.oasis.opendocument.text'; case 'ods': case 'ots': return 'application/vnd.oasis.opendocument.spreadsheet'; case 'odp': case 'otp': return 'application/vnd.oasis.opendocument.presentation'; case 'sxw': case 'stw': return ' application/vnd.sun.xml.writer'; case 'sxc': case 'stc': return ' application/vnd.sun.xml.calc'; case 'sxi': case 'sti': return ' application/vnd.sun.xml.impress'; case 'doc': return 'application/vnd.ms-word'; case 'xls': case 'xla': case 'xlt': case 'xlb': return 'application/vnd.ms-excel'; case 'ppt': case 'ppa': case 'pot': case 'pps': return 'application/vnd.mspowerpoint'; case 'vsd': case 'vss': case 'vsw': return 'application/vnd.visio'; case 'docx': case 'docm': case 'pptx': case 'pptm': case 'xlsx': case 'xlsm': return 'application/vnd.openxmlformats'; case 'csv': return 'text/comma-separated-values'; // Multimedia // Multimedia case 'mpeg': case 'mpg': case 'mpe': return 'video/mpeg'; case 'qt': case 'mov': return 'video/quicktime'; case 'avi': case 'wmv': return 'video/x-msvideo'; // Compression // Compression case 'bz2': return 'application/x-bzip2'; case 'gz': case 'tgz': return 'application/x-gzip'; case 'tar': return 'application/x-tar'; case 'zip': return 'application/zip'; case 'rar': return 'application/x-rar-compressed'; case '7z': return 'application/x-7z-compressed'; case 'alz': return 'application/x-alzip'; } } return ''; }
$outputFiles = ''; while (false !== ($file = readdir($handle))) { $previewFile = getPreviewFileFromLive(DIR . '/' . $file); if (strstr($file, 'phpthumb') || strstr($file, 'phpthumb') || !file_exists($previewFile)) { continue; } if (!in_array($file, $reserved_filenames)) { $itemsFound++; if (is_dir(DIR . '/' . $file)) { // Directory $outputDirs .= "\n<li class=\"dir\">"; $outputDirs .= '<a href="?dir=' . DIR . '/' . $file . '" title="Browse ' . $file . '">'; $outputDirs .= $file; $outputDirs .= '</a></li>'; } else { if (getFileExtension($file) == 'html' || getFileExtension($file) == 'php') { // File $outputFiles .= "\n" . '<li class="file"><a href="javascript:selectPage(\'' . DIR . '/' . $file . '\');" >'; $outputFiles .= $file; $outputFiles .= '</a>'; $outputFiles .= "\n</li>"; } } } } closedir($handle); if ($itemsFound > 0) { $outputHTML = '<div class="bigLinks"><ul>' . $outputDirs . $outputFiles . '<!-- 3 --></ul></div>'; } else { $outputHTML .= '<div><span class="info">No files or folders found</span></div>'; }
function guardar_1($partes, $partes_name, $comentario, $accion_correctiva) { $s_ = "select * from configuracion where variable='ruta_capturas'"; $r_ = mysql_query($s_); $d_ = mysql_fetch_array($r_); $r_server = $d_['valor']; $pext = getFileExtension($partes_name); $nombre_ = "partes_UID" . $_SESSION["IDEMP"] . "." . $pext; $nom_final_ = $r_server . $nombre_; if (is_uploaded_file($partes)) { if (!copy($partes, "{$nom_final_}")) { echo "<script>alert('Error al subir el archivo de partes: {$nom_final_}');</script>"; nuevo($comentario, $accion_correctiva); exit; } } insert_csv($nombre_, $comentario, $accion_correctiva); }
protected function processActionCommit() { $this->checkRequiredPostParams(array('editSessionId')); if ($this->errorCollection->hasErrors()) { $this->sendJsonErrorResponse(); } $this->checkUpdatePermissions(); $currentSession = $this->getEditSessionByCurrentUser((int) $this->request->getPost('editSessionId')); if (!$currentSession) { $this->errorCollection->add(array(new Error(Loc::getMessage('DISK_DOC_CONTROLLER_ERROR_COULD_NOT_FIND_EDIT_SESSION'), self::ERROR_COULD_NOT_FIND_EDIT_SESSION))); $this->sendJsonErrorResponse(); } $tmpFile = \CTempFile::getFileName(uniqid('_wd')); checkDirPath($tmpFile); $fileData = new FileData(); $fileData->setId($currentSession->getServiceFileId()); $fileData->setSrc($tmpFile); $newNameFileAfterConvert = null; if ($this->documentHandler->isNeedConvertExtension($this->file->getExtension())) { $newNameFileAfterConvert = getFileNameWithoutExtension($this->file->getName()) . '.' . $this->documentHandler->getConvertExtension($this->file->getExtension()); $fileData->setMimeType(TypeFile::getMimeTypeByFilename($newNameFileAfterConvert)); } else { $fileData->setMimeType(TypeFile::getMimeTypeByFilename($this->file->getName())); } $fileData = $this->documentHandler->downloadFile($fileData); if (!$fileData) { if ($this->documentHandler->isRequiredAuthorization()) { $this->sendNeedAuth(); } $this->errorCollection->add($this->documentHandler->getErrors()); $this->sendJsonErrorResponse(); } $this->deleteEditSession($currentSession); $oldName = $this->file->getName(); //rename in cloud service $renameInCloud = $fileData->getName() && $fileData->getName() != $this->file->getName(); if ($newNameFileAfterConvert || $renameInCloud) { if ($newNameFileAfterConvert && $renameInCloud) { $newNameFileAfterConvert = getFileNameWithoutExtension($fileData->getName()) . '.' . getFileExtension($newNameFileAfterConvert); } $this->file->rename($newNameFileAfterConvert); } $fileArray = \CFile::makeFileArray($tmpFile); $fileArray['name'] = $this->file->getName(); $fileArray['type'] = $fileData->getMimeType(); $fileArray['MODULE_ID'] = Driver::INTERNAL_MODULE_ID; /** @noinspection PhpDynamicAsStaticMethodCallInspection */ $fileId = \CFile::saveFile($fileArray, Driver::INTERNAL_MODULE_ID); if (!$fileId) { \CFile::delete($fileId); $this->errorCollection->add(array(new Error(Loc::getMessage('DISK_DOC_CONTROLLER_ERROR_COULD_NOT_SAVE_FILE'), self::ERROR_COULD_NOT_SAVE_FILE))); $this->sendJsonErrorResponse(); } $versionModel = $this->file->addVersion(array('ID' => $fileId, 'FILE_SIZE' => $fileArray['size']), $this->getUser()->getId(), true); if (!$versionModel) { \CFile::delete($fileId); $this->errorCollection->add(array(new Error(Loc::getMessage('DISK_DOC_CONTROLLER_ERROR_COULD_NOT_ADD_VERSION'), self::ERROR_COULD_NOT_ADD_VERSION))); $this->errorCollection->add($this->file->getErrors()); $this->sendJsonErrorResponse(); } if ($this->isLastEditSessionForFile()) { $this->deleteFile($currentSession, $fileData); } $this->sendJsonSuccessResponse(array('objectId' => $this->file->getId(), 'newName' => $this->file->getName(), 'oldName' => $oldName)); }
function guardar($turno, $proyecto, $area, $area_2, $estacion, $estacion_2, $linea, $linea_2, $defecto, $defecto_2, $causa, $causa_2, $codigo_scrap, $codigo_scrap_2, $supervisor, $operador, $no_personal, $apd, $o_mantto, $docto_sap, $info_1, $info_2, $comentario, $accion_correctiva, $archivo, $archivo_name) { $error = 0; $fecha = date("Y-m-d"); $hora = date("H:i:s"); $anio = date("Y"); list($anio, $mes, $dia) = split("-", $fecha); $semana = date('W', mktime(0, 0, 0, $mes, $dia, $anio)); $folio = get_folio(); $i = 0; aumenta_folio(); //Validar que el folio no esté duplicado $s_ = "select * from scrap_folios where no_folio='{$folio}'"; $r_ = mysql_query($s_); if (mysql_num_rows($r_) > 0) { $movimiento = "El folio esta duplicado."; $error++; } if ($archivo != '') { $s_ = "select * from configuracion where variable='ruta_evidencias'"; $r_ = mysql_query($s_); $d_ = mysql_fetch_array($r_); $r_server = $d_['valor']; $pext = getFileExtension($archivo_name); $nombre = "evidencia_" . $folio . "." . $pext; $nom_final = $r_server . $nombre; if (is_uploaded_file($archivo)) { if (!copy($archivo, "{$nom_final}")) { echo "<script>alert('Error al subir el archivo de evidencias: {$nom_final}');</script>"; } } } $folios[$i] = $_SESSION['IDEMP']; $i++; $folios[$i] = $_SESSION['NAME']; $i++; $folios[$i] = $folio; $i++; $folios[$i] = $fecha; $i++; $folios[$i] = $hora; $i++; $folios[$i] = $semana; $i++; $folios[$i] = $anio; $i++; $folios[$i] = $turno; $i++; $d_pr = get_datos_proyecto($proyecto); $folios[$i] = $d_pr['id_pr']; $i++; //ID Proyecto $folios[$i] = $d_pr['nom_pr']; $i++; //Nombre Proyecto $folios[$i] = $d_pr['id_p']; $i++; //ID Planta $folios[$i] = $d_pr['nom_p']; $i++; //Nombre Planta $folios[$i] = $d_pr['id_d']; $i++; //ID División $folios[$i] = $d_pr['nom_d']; $i++; //Nombre División $folios[$i] = $d_pr['id_s']; $i++; //ID Segmento $folios[$i] = $d_pr['nom_s']; $i++; //Nombre Segmento $folios[$i] = $d_pr['id_pc']; $i++; //ID ceco $folios[$i] = $d_pr['nom_pc']; $i++; //Nombre ceco $folios[$i] = $apd; $i++; $folios[$i] = get_dato("nombre", $apd, "apd"); $i++; $folios[$i] = $area; $i++; $folios[$i] = get_dato("nombre", $area, "areas"); $i++; $folios[$i] = $estacion; $i++; $folios[$i] = get_dato("nombre", $estacion, "estaciones"); $i++; $folios[$i] = $linea; $i++; $folios[$i] = get_dato("nombre", $linea, "lineas"); $i++; $folios[$i] = $defecto; $i++; $folios[$i] = get_dato("nombre", $defecto, "defectos"); $i++; $folios[$i] = $causa; $i++; $folios[$i] = get_dato("nombre", $causa, "causas"); $i++; $folios[$i] = $codigo_scrap; $i++; $cod_scr = data_cod_scrap($d_pr['nom_pc'], $codigo_scrap); $folios[$i] = $cod_scr['fin']; $i++; $folios[$i] = $cod_scr['rc']; $i++; $folios[$i] = $cod_scr['oi']; $i++; $folios[$i] = $cod_scr['txs']; $i++; $folios[$i] = $cod_scr['mov']; $i++; $folios[$i] = $supervisor; $i++; $folios[$i] = get_supervisor($supervisor); $i++; $operador = str_replace("/", "", $operador); $folios[$i] = $operador; $i++; $folios[$i] = $no_personal; $i++; if ($info_1 == '') { $info_1 = 'NA'; } $folios[$i] = $info_1; $i++; $folios[$i] = $info_2; $i++; $folios[$i] = $o_mantto; $i++; $folios[$i] = $nombre; $i++; $comentario = str_replace("/", "", $comentario); $folios[$i] = htmlentities($comentario, ENT_QUOTES, "UTF-8"); $i++; $accion_correctiva = str_replace("/", "", $accion_correctiva); $folios[$i] = htmlentities($accion_correctiva, ENT_QUOTES, "UTF-8"); $s_1 = "insert into scrap_folios values ('',"; for ($i = 0; $i < count($folios); $i++) { $s_1 = $s_1 . "'" . $folios[$i] . "',"; } $s_1 = $s_1 . "0,0,1,0)"; $r_1 = mysql_query($s_1); $i = 0; /*LOG SISTEMA*/ log_sistema("scrap_folios", "nuevo", $folio, $s_1); //Si es un código scrap que tiene financiero en 1 if ($cod_scr['fin'] == '1') { $cod_id_area = $area_2; $cod_nom_area = get_dato("nombre", $area_2, "areas"); $cod_id_est = $estacion_2; $cod_nom_est = get_dato("nombre", $estacion_2, "estaciones"); $cod_id_linea = $linea_2; $cod_nom_linea = get_dato("nombre", $linea_2, "lineas"); $cod_id_def = $defecto_2; $cod_nom_def = get_dato("nombre", $defecto_2, "defectos"); $cod_id_cau = $causa_2; $cod_nom_cau = get_dato("nombre", $causa_2, "causas"); $s_1 = "insert into scrap_codigos values('', '{$folio}', '{$cod_id_area}', '{$cod_nom_area}', '{$cod_id_est}', '{$cod_nom_est}', "; $s_1 .= "'{$cod_id_linea}', '{$cod_nom_linea}', '{$cod_id_def}', '{$cod_nom_def}', '{$cod_id_cau}', '{$cod_nom_cau}', '{$codigo_scrap_2}')"; $r_1 = mysql_query($s_1); /*LOG SISTEMA*/ log_sistema("scrap_codigos", "nuevo", $folio, $s_1); } $s_ = "select * from scrap_partes_tmp where id_emp='{$_SESSION['IDEMP']}'"; $r_ = mysql_query($s_); while ($d_ = mysql_fetch_array($r_)) { $s_1 = "insert into scrap_partes values('', '{$folio}', '{$d_['padre']}', '{$d_['no_parte']}', '{$d_['tipo']}', '{$d_['tipo_sub']}', "; $s_1 .= "'{$d_['descripcion']}', '{$d_['cantidad']}', '{$d_['costo']}', '{$d_['total']}', '{$d_['batch_id']}', '{$d_['serial_unidad']}', "; $s_1 .= "'{$d_['ubicacion']}', '0', '0', '0')"; $r_1 = mysql_query($s_1); /*LOG SISTEMA*/ log_sistema("scrap_partes", "nuevo", $folio, $s_1); } autorizaciones($folio, $d_pr['id_p'], $codigo_scrap, $d_pr['id_pr']); $s_ = "delete from scrap_partes_tmp where id_emp='{$_SESSION['IDEMP']}'"; $r_ = mysql_query($s_); $ruta = "&turno={$turno}&proyecto={$proyecto}&area={$area}&estacion={$estacion}&linea={$linea}&supervisor={$supervisor}&operador={$operador}"; $ruta .= "&no_personal={$no_personal}&apd={$apd}"; //Inserto en la bitácora de autorizaciones el movimiento correspondiente $s_2 = "insert into aut_bitacora values('', '{$folio}', '{$_SESSION['DEPTO']}', '{$_SESSION['IDEMP']}', '{$_SESSION['NAME']}', '6', "; $s_2 .= "'{$fecha}', '{$hora}', 'Creación de la boleta')"; $r_2 = mysql_query($s_2); /*LOG SISTEMA*/ log_sistema("aut_bitacora", "nuevo", $folio, $s_2); $s_3 = "DROP VIEW vw_padre_" . $_SESSION["IDEMP"]; $r_3 = mysql_query($s_3); //Validar que la boleta se haya guardado correctamente $s_2 = "select * from scrap_folios where no_folio='{$folio}'"; $r_2 = mysql_query($s_2); if (mysql_num_rows($r_2) <= 0) { $movimientos = "La boleta no se guardo en scrap_folios."; $error++; } $s_2 = "select * from scrap_partes where no_folio='{$folio}'"; $r_2 = mysql_query($s_2); if (mysql_num_rows($r_2) <= 0) { $movimientos = "La boleta no se guardo en scrap_partes."; $error++; } if ($cod_scr['fin'] == '1') { $s_2 = "select * from scrap_codigos where no_folio='{$folio}'"; $r_2 = mysql_query($s_2); if (mysql_num_rows($r_2) <= 0) { $movimientos = "La boleta no se guardo en scrap_codigos."; $error++; } } $s_2 = "select * from aut_bitacora where no_folio='{$folio}'"; $r_2 = mysql_query($s_2); if (mysql_num_rows($r_2) <= 0) { $movimientos = "La boleta no se guardo en aut_bitacora."; $error++; } $s_2 = "select * from autorizaciones where no_folio='{$folio}'"; $r_2 = mysql_query($s_2); if (mysql_num_rows($r_2) <= 0) { $movimientos = "La boleta no se guardo en autorizaciones."; $error++; } if ($error > 0) { echo "<br><br>"; echo "<table align=center width=500 bgcolor=#FFFFFF>"; echo "<tr><td align=center><img src='../imagenes/exclamation.gif'></td></tr>"; echo "<tr><td align=center>"; echo "<br><strong class=rojo><b>Error en la captura del folio o está duplicado:</strong><br><br>"; echo "<span style='color:#FF6600; font-size:20px;'><b>{$folio}</b><br><br>"; echo "<tr><td align=center class=texto>" . $detalles . "</td></tr>"; echo "<tr><td align=center>"; echo "<br><strong class=rojo><b>Contacte al administrador del sistema!</b><br><br>"; echo "</td></tr></table>"; echo "<form method='post' action='?op=nuevo'>"; echo "<div align=center><input type='submit' value='Regresar' class='submit'></div>"; echo "</form>"; $s_ = "update configuracion set valor='SI' where variable='bloqueado'"; $r_ = mysql_query($s_); /*LOG SISTEMA*/ log_sistema("configuracion", "error", $folio, $s_); /*LOG SISTEMA*/ log_sistema("configuracion", "error", $folio, $movimiento); } else { echo "<br><br>"; echo "<table align=center width=500 bgcolor=#FFFFFF>"; echo "<tr><td align=center><img src='../imagenes/aprobado.gif'></td></tr>"; echo "<tr><td align=center>"; echo "<br><strong class=texto>Boleta almacenada con el folio:</strong><br><br>"; echo "<span style='color:#FF6600; font-size:20px;'><b>{$folio}</b><br><br>"; echo "</td></tr></table>"; echo "<form method='post' action='?op=nuevo{$ruta}'>"; echo "<div align=center><input type='submit' value='Continuar' class='submit'></div>"; echo "</form>"; } }
function purgeFiles($temp_dir, $purge_time_limit, $file_type, $debug_ajax = 0) { //$now_time = mktime(); $now_time = time(); if (@is_dir($temp_dir)) { if ($dp = @opendir($temp_dir)) { while (($file_name = readdir($dp)) !== false) { if ($file_name !== '.' && $file_name !== '..' && strcmp(getFileExtension($file_name), $file_type) == 0) { if ($file_time = @filectime($temp_dir . $file_name)) { if ($now_time - $file_time > $purge_time_limit) { @unlink($temp_dir . $file_name); } } } } closedir($dp); } else { if ($debug_ajax) { showDebugMessage('Failed to open temp_dir ' . $temp_dir); } showAlertMessage("<span class='ubrError'>ERROR</span>: Failed to open temp_dir", 1); } } else { if ($debug_ajax) { showDebugMessage('Failed to find temp_dir ' . $temp_dir); } showAlertMessage("<span class='ubrError'>ERROR</span>: Failed to find temp_dir", 1); } }
/** * Return a directory of files and folders with heirarchy and additional data * * @since 3.1.3 * * @param $directory string directory to scan * @param $recursive boolean whether to do a recursive scan or not. * @param $exts array file extension include filter, array of extensions to include * @param $exclude bool true to treat exts as exclusion filter instead of include * @return multidimensional array or files and folders {type,path,name} */ function directoryToMultiArray($dir, $recursive = true, $exts = null, $exclude = false) { // $recurse is not implemented $result = array(); $dir = rtrim($dir, DIRECTORY_SEPARATOR); $cdir = scandir($dir); foreach ($cdir as $key => $value) { if (!in_array($value, array(".", ".."))) { if (is_dir($dir . DIRECTORY_SEPARATOR . $value)) { if (!$recursive) { continue; } $path = preg_replace("#\\\\|//#", "/", $dir . '/' . $value . '/'); $result[$value] = array(); $result[$value]['type'] = "directory"; $result[$value]['path'] = $path; $result[$value]['dir'] = $value; $result[$value]['value'] = call_user_func(__FUNCTION__, $path, $recursive, $exts, $exclude); } else { $path = preg_replace("#\\\\|//#", "/", $dir . '/'); // filetype filter $ext = getFileExtension($value); if (is_array($exts)) { if (!in_array($ext, $exts) and !$exclude) { continue; } if ($exclude and in_array($ext, $exts)) { continue; } } $result[$value] = array(); $result[$value]['type'] = 'file'; $result[$value]['path'] = $path; $result[$value]['value'] = $value; } } } return $result; }
function update($folio, $turno, $proyecto, $area, $area_2, $estacion, $estacion_2, $linea, $linea_2, $defecto, $defecto_2, $causa, $causa_2, $codigo_scrap, $codigo_scrap_2, $supervisor, $operador, $no_personal, $apd, $o_mantto, $docto_sap, $info_1, $info_2, $comentario, $accion_correctiva, $from, $archivo, $archivo_name) { //Obtengo el código de scrap viejo $s_2 = "select archivo, codigo_scrap from scrap_folios where no_folio='{$folio}'"; $r_2 = mysql_query($s_2); $d_2 = mysql_fetch_array($r_2); $cod = $d_2['codigo_scrap']; //Obtengo el id del autorizador que había rechazado $s_1 = "select id_emp, depto from autorizaciones where no_folio='{$folio}' and status='2'"; $r_1 = mysql_query($s_1); $d_1 = mysql_fetch_array($r_1); $emp = $d_1['id_emp']; //Borro todo de la boleta para volver a ingresarlo $s_1 = "delete from scrap_partes where no_folio='{$folio}'"; $r_1 = mysql_query($s_1); $s_1 = "delete from scrap_folios where no_folio='{$folio}'"; $r_1 = mysql_query($s_1); $s_1 = "delete from scrap_codigos where no_folio='{$folio}'"; $r_1 = mysql_query($s_1); if ($archivo != '') { $s_ = "select * from configuracion where variable='ruta_evidencias'"; $r_ = mysql_query($s_); $d_ = mysql_fetch_array($r_); $r_server = $d_['valor']; $pext = getFileExtension($archivo_name); $nombre = "evidencia_" . $folio . "." . $pext; $nom_final = $r_server . $nombre; if (file_exists($nom_final)) { unlink($nom_final); } if (is_uploaded_file($archivo)) { if (!copy($archivo, "{$nom_final}")) { echo "<script>alert('Error al subir el archivo: {$nom_final}');</script>"; } } } else { $nombre = $old; } $fecha = date("Y-m-d"); $anio = date("Y"); list($anio, $mes, $dia) = split("-", $fecha); $semana = date('W', mktime(0, 0, 0, $mes, $dia, $anio)); $i = 0; $folios[$i] = $_SESSION['IDEMP']; $i++; $folios[$i] = $_SESSION['NAME']; $i++; $folios[$i] = $folio; $i++; $folios[$i] = $fecha; $i++; $folios[$i] = $semana; $i++; $folios[$i] = $anio; $i++; $folios[$i] = $turno; $i++; $d_pr = get_datos_proyecto($proyecto); $folios[$i] = $d_pr['id_pr']; $i++; //ID Proyecto $folios[$i] = $d_pr['nom_pr']; $i++; //Nombre Proyecto $folios[$i] = $d_pr['id_p']; $i++; //ID Planta $folios[$i] = $d_pr['nom_p']; $i++; //Nombre Planta $folios[$i] = $d_pr['id_d']; $i++; //ID División $folios[$i] = $d_pr['nom_d']; $i++; //Nombre División $folios[$i] = $d_pr['id_s']; $i++; //ID Segmento $folios[$i] = $d_pr['nom_s']; $i++; //Nombre Segmento $folios[$i] = $d_pr['id_pc']; $i++; //ID ceco $folios[$i] = $d_pr['nom_pc']; $i++; //Nombre ceco $folios[$i] = $apd; $i++; $folios[$i] = get_dato("nombre", $apd, "apd"); $i++; $folios[$i] = $area; $i++; $folios[$i] = get_dato("nombre", $area, "areas"); $i++; $folios[$i] = $estacion; $i++; $folios[$i] = get_dato("nombre", $estacion, "estaciones"); $i++; $folios[$i] = $linea; $i++; $folios[$i] = get_dato("nombre", $linea, "lineas"); $i++; $folios[$i] = $defecto; $i++; $folios[$i] = get_dato("nombre", $defecto, "defectos"); $i++; $folios[$i] = $causa; $i++; $folios[$i] = get_dato("nombre", $causa, "causas"); $i++; $folios[$i] = $codigo_scrap; $i++; $cod_scr = data_cod_scrap($d_pr['nom_pc'], $codigo_scrap); $folios[$i] = $cod_scr['fin']; $i++; $folios[$i] = $cod_scr['rc']; $i++; $folios[$i] = $cod_scr['oi']; $i++; $folios[$i] = $cod_scr['txs']; $i++; $folios[$i] = $cod_scr['mov']; $i++; $folios[$i] = $supervisor; $i++; $folios[$i] = $operador; $i++; $folios[$i] = $no_personal; $i++; if ($info_1 == '') { $info_1 = 'NA'; } $folios[$i] = $info_1; $i++; $folios[$i] = $info_2; $i++; $folios[$i] = $o_mantto; $i++; //Revisar nuevamente los autorizadores que aplican por si estos cambiaron para el adjunto if (aplica_lo_loa($d_pr['id_p'], $codigo_scrap, $d_pr['id_d'], $d_pr['id_pc'], $area, $d_pr['id_pr']) == 'SI') { $folios[$i] = $nombre; $i++; } else { $folios[$i] = ''; $i++; } $folios[$i] = $comentario; $i++; $folios[$i] = $accion_correctiva; if ($from == 'proceso') { $estado = '0'; } if ($from == 'rechazado') { $estado = '2'; } $s_1 = "insert into scrap_folios values ('',"; for ($i = 0; $i < count($folios); $i++) { $s_1 = $s_1 . "'" . $folios[$i] . "',"; } $s_1 = $s_1 . "'{$estado}',1)"; $r_1 = mysql_query($s_1); $i = 0; /*LOG SISTEMA*/ log_sistema("scrap", "editar", $s_1); //Si es un código scrap que tiene financiero en 1 if ($cod_scr['fin'] == '1') { $cod_id_area = $area_2; $cod_nom_area = get_dato("nombre", $area_2, "areas"); $cod_id_est = $estacion_2; $cod_nom_est = get_dato("nombre", $estacion_2, "estaciones"); $cod_id_linea = $linea_2; $cod_nom_linea = get_dato("nombre", $linea_2, "lineas"); $cod_id_def = $defecto_2; $cod_nom_def = get_dato("nombre", $defecto_2, "defectos"); $cod_id_cau = $causa_2; $cod_nom_cau = get_dato("nombre", $causa_2, "causas"); $s_1 = "insert into scrap_codigos values('', '{$folio}', '{$cod_id_area}', '{$cod_nom_area}', '{$cod_id_est}', '{$cod_nom_est}', "; $s_1 .= "'{$cod_id_linea}', '{$cod_nom_linea}', '{$cod_id_def}', '{$cod_nom_def}', '{$cod_id_cau}', '{$cod_nom_cau}', '{$codigo_scrap_2}')"; $r_1 = mysql_query($s_1); /*LOG SISTEMA*/ log_sistema("scrap", "nuevo", $s_1); } $s_ = "select * from scrap_partes_tmp where id_emp='{$_SESSION['IDEMP']}'"; $r_ = mysql_query($s_); while ($d_ = mysql_fetch_array($r_)) { $s_1 = "insert into scrap_partes values('', '{$folio}', '{$d_['padre']}', '{$d_['no_parte']}', '{$d_['tipo']}', '{$d_['tipo_sub']}', "; $s_1 .= "'{$d_['descripcion']}', '{$d_['cantidad']}', '{$d_['costo']}', '{$d_['total']}', '{$d_['batch_id']}', '{$d_['serial_unidad']}', "; $s_1 .= "'{$d_['ubicacion']}', '0', '0')"; $r_1 = mysql_query($s_1); /*LOG SISTEMA*/ log_sistema("scrap", "editar", $s_1); } //Reasigno los autorizadores que aplican sólo si cambió el código de scrap if ($codigo_scrap != $cod) { $s_a = "delete from autorizaciones where no_folio='{$folio}'"; $r_a = mysql_query($s_a); autorizaciones($folio, $d_pr['id_p'], $codigo_scrap, $d_pr['id_d'], $d_pr['id_pc'], $area, $d_pr['id_pr']); } $s_ = "delete from scrap_temporal where id_emp='{$_SESSION['IDEMP']}'"; $r_ = mysql_query($s_); if ($from == 'rechazado') { enviar_aviso_autorizador($folio, $emp); } echo "<script>alert('Registro Almacenado');</script>"; }
public static function mobileDiskGetIconByFilename($name) { if (CFile::isImage($name)) { return 'img.png'; } $icons = array('pdf' => 'pdf.png', 'doc' => 'doc.png', 'docx' => 'doc.png', 'ppt' => 'ppt.png', 'pptx' => 'ppt.png', 'rar' => 'rar.png', 'xls' => 'xls.png', 'xlsx' => 'xls.png', 'zip' => 'zip.png'); $ext = strtolower(getFileExtension($name)); return isset($icons[$ext]) ? $icons[$ext] : 'blank.png'; }
function process_attachments($attachments) { $result = array(); foreach ($attachments as $info) { $orig_name = ""; $size = 0; $stored_name = ""; $type = ""; if (array_key_exists("Type", $info)) { $type = $info["Type"]; } if (array_key_exists("FileName", $info)) { $orig_name = $info["FileName"]; } if (!strlen($orig_name)) { continue; } if (array_key_exists("Data", $info)) { $data = $info["Data"]; $size = strlen($data); if ($size == 0) { continue; } $attachsdir = get_config("AttachmentsDir"); if (!is_dir($attachsdir)) { die('The attachments directory "' . $attachsdir . '" doesn\'t exist.'); } $stored_name = save_attachment($attachsdir, getFileExtension($orig_name), $data); } else { $stored_name = $info['DataFile']; $size = filesize($stored_name); } $result[] = array("orig_name" => $orig_name, "size" => $size, "stored_name" => $stored_name, "type" => $type); } return $result; }
if (!isset($_POST['textcontent'])) { print 'error:No content supplied.'; exit; } else { if (!isset($_POST['sourcefile'])) { print 'error:No source text file name supplied.'; exit; } else { $sourceFile = pathFromID($_POST['sourcefile']); $fileContent = $_POST['textcontent']; } } $mode = isset($_POST['mode']) ? $_POST['mode'] : false; if (isPageTemplate($sourceFile)) { $mode = 'pagetemplate'; } elseif (getFileExtension($sourceFile) == "php") { $mode = 'page'; } /* If a child include, save file to pv location, and save live copy if live not present or empty If a page, just save to pv location, and save live copy if not present or empty, PLUS correct the general-include call (for the LIVE version!) If a free include, save to pv location, and save live copy if not present or empty If a Page Template, simply save to PTs folder */ switch ($mode) { case "ptchildinclude": // ???????????????? $previewFile = pathFromID($_POST['sourcefile']); $liveFile = False; break; case "pagetemplate":
$liveFile = DIR . '/' . $arrFile; if (file_exists($liveFile)) { if (False === file_exists($previewFile)) { $filesMatch = 'liveonly'; } else { $filesMatch = md5_file($previewFile) == md5_file($liveFile) ? 'match' : 'dontmatch'; } } else { if (file_exists($previewFile)) { $filesMatch = 'previewonly'; } } /* Get the preview version - do the versions match? */ if (getFileExtension($arrFile) == "php") { $xmlr .= '<page><name>'; $xmlr .= $arrFile; $xmlr .= '</name><match>'; $xmlr .= $filesMatch; $xmlr .= '</match></page>'; } else { $xmlr .= '<file><name>'; $xmlr .= $arrFile; $xmlr .= '</name><match>'; $xmlr .= $filesMatch; $xmlr .= '</match></file>'; } } $xmlr .= "</xml>"; print $xmlr;
function saveFileToS3ByName($client, $name, $path, $s3bucket = "", $width = 0, $height = 0) { if (!$_FILES[$name]) { return; } if ($_FILES[$name]["error"] != 0) { return; } $tempFile = $_FILES[$name]['tmp_name']; $fileName = $_FILES[$name]['name']; if ($width == 0) { saveObjectToS3ByFile($client, $s3bucket, $path, $tempFile); } else { $tempName = $tempFile . "." . getFileExtension($fileName); $newName = $tempFile . "_new." . getFileExtension($path); move_uploaded_file($tempFile, $tempName); createImage($tempName, $newName, $width, $height); saveObjectToS3ByFile($client, $s3bucket, $path, $newName); unlink($newName); } }
/** * get extra files list for given module * @param $sModule - module name * @param $sFolder - folder name where to look for files * @param $bGetUserFile - get current user file (true) or default file (false) * @param $bGetDate - get dates of files * @return $aResult - files array without extension and/or current file */ function getExtraFiles($sModule, $sFolder = "langs", $bGetUserFile = true, $bGetDate = false) { global $sModulesPath; $sFilesPath = $sModulesPath . $sModule . "/" . $sFolder . "/"; $aFiles = array(); $aDates = array(); $sExtension = getFileExtension($sModule, $sFolder); if ($bGetDate) { clearstatcache(); } if ($rDirHandle = opendir($sFilesPath)) { while (false !== ($sFile = readdir($rDirHandle))) { if (is_file($sFilesPath . $sFile) && $sFile != "." && $sFile != ".." && $sExtension == substr($sFile, strpos($sFile, ".") + 1)) { $aFiles[] = substr($sFile, 0, strpos($sFile, ".")); if ($bGetDate) { $aDates[] = filectime($sFilesPath . $sFile); } } } } closedir($rDirHandle); $aResult = getSettingValue($sModule, FILE_DEFAULT_KEY, $sFolder, true); if ($aResult['status'] == FAILED_VAL || empty($aResult['value'])) { $sDefaultFile = $sFolder == "langs" ? "english" : "default"; } else { $sDefaultFile = $aResult['value']; } $sCurrentFile = in_array($sDefaultFile, $aFiles) ? $sDefaultFile : $aFiles[0]; if ($bGetUserFile) { $sCookieValue = $_COOKIE["ray_" . $sFolder . "_" . $sModule]; $sCurrentFile = isset($sCookieValue) && in_array($sCookieValue, $aFiles) ? $sCookieValue : $sDefaultFile; } return array('files' => $aFiles, 'dates' => $aDates, 'current' => $sCurrentFile, 'extension' => $sExtension); }
// show files if (count($filesSorted) != 0) { foreach ($filesSorted as $upload) { $counter++; $thumbnailLink = ''; $primarylink = getRelPath(GSDATAUPLOADPATH) . $urlPath . rawurlencode($upload['name']); echo '<tr class="all ' . $upload['type'] . '" >'; echo '<td class="imgthumb" >'; // handle images if ($upload['type'] == 'image') { $gallery = 'rel="fancybox_i"'; $pathlink = 'image.php?i=' . rawurlencode($upload['name']) . '&path=' . $subPath; $thumbLink = $urlPath . 'thumbsm.' . $upload['name']; $thumbLinkEncoded = $urlPath . 'thumbsm.' . rawurlencode($upload['name']); $thumbLinkExternal = $urlPath . 'thumbnail.' . $upload['name']; $ext = getFileExtension($upload['name']); // get thumbsm if (!file_exists(GSTHUMBNAILPATH . $thumbLink) || isset($_REQUEST['regenthumbsm'])) { $imgSrc = '<img class="' . $ext . '" src="inc/thumb.php?src=' . $urlPath . rawurlencode($upload['name']) . '&dest=' . $thumbLinkEncoded . '&f=1&x=' . $thumbsm_w . '&y=' . $thumbsm_h . '" />'; } else { $imgSrc = '<img class="' . $ext . '" src="' . tsl($SITEURL) . getRelPath(GSTHUMBNAILPATH) . $thumbLinkEncoded . '" />'; } // thumbnail link lightbox echo '<a href="' . tsl($SITEURL) . getRelPath($path) . rawurlencode($upload['name']) . '" title="' . rawurlencode($upload['name']) . '" rel="fancybox_i" >' . $imgSrc . '</a>'; # get external thumbnail link # if not exist generate it if (!file_exists(GSTHUMBNAILPATH . $thumbLinkExternal) || isset($_REQUEST['regenthumbnail'])) { genStdThumb($subPath, $upload['name']); } $thumbnailLink = '<a href="' . tsl($SITEURL) . getRelPath(GSTHUMBNAILPATH) . $thumbLinkExternal . '" class="label label-ghost thumblinkexternal" data-fileurl="' . getRelPath(GSTHUMBNAILPATH) . $thumbLinkExternal . '">' . i18n_r('THUMBNAIL') . '</a>'; } else {
function getPTChildIncludes($liveFile) { // e.g. $liveFile = "pagetemplates/ptname/" global $xmlr; $lciDir = PTSDIR . '/' . stripFileExtension(substr($liveFile, strlen(PTSDIR) + 1)); if (!is_dir($lciDir)) { return false; // Should we attempt to create folder?? } $lciDirHandle = opendir($lciDir); while (False !== ($lciFile = readdir($lciDirHandle))) { if ($lciFile != '.' & $lciFile != '..' && !is_dir($lciDir . '/' . $lciFile)) { $xmlr .= '<lci>'; $xmlr .= '<type>' . getFileExtension($lciFile) . '</type>'; $xmlr .= '<filename>' . $lciFile . '</filename>'; $xmlr .= '<filestatus>0</filestatus>'; $xmlr .= '</lci>'; } } closedir($lciDirHandle); }
function initialize_page() { $post_action = isset($_POST['submit']) ? $_POST['submit'] : ""; if ($post_action == "Add Image" || $post_action == "Add and Return to List") { $title = cleanupSpecialChars($_POST['title']); $description = cleanupSpecialChars($_POST['description']); if (ALLOW_SHORT_PAGE_NAMES) { $name = $_POST['name'] == "" ? slug($_POST['title']) : slug($_POST['name']); } else { $name = slug($_POST['title']); } // Was a file uploaded? if (is_uploaded_file($_FILES["image"]["tmp_name"])) { $mimeType = $_FILES["image"]["type"]; $filetype = getFileExtension($_FILES["image"]["name"]); list($width) = getimagesize($_FILES["image"]["tmp_name"]); $max_width = 0; $max_height = 0; if (defined("MAX_IMAGE_HEIGHT")) { $max_height = MAX_IMAGE_HEIGHT; } if (defined("MAX_IMAGE_WIDTH")) { $max_width = MAX_IMAGE_WIDTH; } resizeToMultipleMaxDimensions($_FILES["image"]["tmp_name"], $max_width, $max_height, $filetype); // Open the uploaded file $file = fopen($_FILES["image"]["tmp_name"], "r"); // Read in the uploaded file $fileContents = fread($file, filesize($_FILES["image"]["tmp_name"])); // Escape special characters in the file $fileContents = AddSlashes($fileContents); /*if( copy($_FILES["image"]["tmp_name"], $_FILES["image"]["tmp_name"] . "_thumb") ) { resizeToMultipleMaxDimensions($_FILES["image"]["tmp_name"] . "_thumb", 200, 0); $image = open_image($_FILES["image"]["tmp_name"] . "_thumb"); if ( $image === false ) { die ('Unable to open image for resizing'); } $width = imagesx($image); // Open the thumbnail file $thumb_file = fopen($_FILES["image"]["tmp_name"] . "_thumb", "r"); // Read in the thumbnail file $thumb_fileContents = fread($thumb_file, filesize($_FILES["image"]["tmp_name"] . "_thumb")); // Escape special characters in the file $thumb_fileContents = AddSlashes($thumb_fileContents); }*/ $thumb_fileContents = NULL; } else { $fileContents = $thumb_fileContents = NULL; } $insertQuery = "INSERT INTO images VALUES (NULL, \"{$title}\", \"{$description}\", \"{$fileContents}\", \"{$thumb_fileContents}\", \"{$mimeType}\", \"{$name}\")"; $result = mysql_Query($insertQuery, MyActiveRecord::Connection()); if (empty($result)) { //die( $updateQuery ); setFlash("<h3>FAILURE – Please notify HCd of this error: " . mysql_error() . "</h3>"); } setFlash("<h3>Image uploaded</h3>"); if ($post_action == "Add and Return to List") { redirect("/admin/list_images"); } } }
function Upload_and_Save_Image($image, $table_name, $file_field_name, $row_id, $thiswidth = null, $thisheight = null) { $mimeType = $image["type"]; switch ($mimeType) { case "image/gif": $mimeName = "GIF Image"; break; case "image/jpeg": $mimeName = "JPEG Image"; break; case "image/png": $mimeName = "PNG Image"; break; case "image/x-MS-bmp": $mimeName = "Windows Bitmap"; break; default: $mimeName = "Unknown image type"; } $filetype = getFileExtension($image["name"]); list($width) = getimagesize($image["tmp_name"]); $max_width = defined($thiswidth) ? $thiswidth : 0; $max_height = defined($thisheight) ? $thisheight : 0; resizeImageToMax($image["tmp_name"], $max_width, $max_height, $filetype); // Open the uploaded file $file = fopen($image["tmp_name"], "r"); // Read in the uploaded file $fileContents = fread($file, filesize($image["tmp_name"])); // Escape special characters in the file $fileContents = AddSlashes($fileContents); $updateQuery = 'UPDATE ' . $table_name . ' SET ' . $file_field_name . ' = "' . $fileContents . '", mime_type = "' . $mimeType . '" WHERE id = ' . $row_id . ';'; $result = mysql_Query($updateQuery, MyActiveRecord::Connection()); if (!$result) { echo 'Invalid query: ' . mysql_error(); } }