public function saveConfigPmGmail($httpData) { G::LoadClass("pmGoogleApi"); $pmGoogle = new PMGoogleApi(); $result = new StdClass(); $result->success = true; if (!empty($httpData->status_pmgmail)) { $httpData->status_pmgmail = $httpData->status_pmgmail == 1 ? true : false; $pmGoogle->setStatusService($httpData->status_pmgmail); $message = G::LoadTranslation('ID_ENABLE_PMGMAIL') . ': ' . ($httpData->status_pmgmail ? G::LoadTranslation('ID_ENABLE') : G::LoadTranslation('ID_DISABLE')); $pmGoogle->setTypeAuthentication($httpData->typeAuth); if (!empty($httpData->email_service_account)) { $pmGoogle->setServiceAccountEmail($httpData->email_service_account); $message .= ', ' . G::LoadTranslation('ID_PMG_EMAIL') . ': ' . $httpData->email_service_account; } if (!empty($_FILES)) { if (!empty($_FILES['file_p12']) && $_FILES['file_p12']['error'] != 1) { if ($_FILES['file_p12']['tmp_name'] != '') { G::uploadFile($_FILES['file_p12']['tmp_name'], PATH_DATA_SITE, $_FILES['file_p12']['name']); $pmGoogle->setServiceAccountP12($_FILES['file_p12']['name']); $message .= ', ' . G::LoadTranslation('ID_PMG_FILE') . ': ' . $_FILES['file_p12']['name']; } } else { if (!empty($_FILES['file_json']) && $_FILES['file_json']['error'] != 1) { if ($_FILES['file_json']['tmp_name'] != '') { G::uploadFile($_FILES['file_json']['tmp_name'], PATH_DATA_SITE, $_FILES['file_json']['name']); $pmGoogle->setAccountJson($_FILES['file_json']['name']); $message .= ', ' . G::LoadTranslation('ID_PMG_FILE') . ': ' . $_FILES['file_json']['name']; } } else { $result->success = false; $result->fileError = true; print G::json_encode($result); die; } } } } else { $pmGoogle->setStatusService(false); $message = G::LoadTranslation('ID_ENABLE_PMGMAIL') . ': ' . G::LoadTranslation('ID_DISABLE'); } G::auditLog("Update Settings Gmail", $message); print G::json_encode($result); }
/** * Upload file * * @param array $aData */ public function uploadFile($aData) { try { if ($_FILES['file_content']['error'] != 1) { if ($_FILES['file_content']['tmp_name'] != '') { $aAux = explode('.', $_FILES['file_content']['name']); $content = file_get_contents($_FILES['file_content']['tmp_name']); $result = array('file_content' => $content); \G::uploadFile($_FILES['file_content']['tmp_name'], PATH_DOCUMENT . '/upload/', $_FILES['file_content']['name']); } } else { $result->success = false; $result->fileError = true; throw new \Exception($result); } return $result; } catch (\Exception $e) { throw $e; } }
/** * Return the Process Files Manager * * @param string $prjUid {@min 32} {@max 32} * @param string $prfUid {@min 32} {@max 32} * * * @access public */ public function uploadProcessFilesManager($prjUid, $prfUid) { try { $path = ''; $criteria = new \Criteria("workflow"); $criteria->addSelectColumn(\ProcessFilesPeer::PRF_PATH); $criteria->add(\ProcessFilesPeer::PRF_UID, $prfUid, \Criteria::EQUAL); $rsCriteria = \ProcessFilesPeer::doSelectRS($criteria); $rsCriteria->setFetchmode(\ResultSet::FETCHMODE_ASSOC); $rsCriteria->next(); while ($aRow = $rsCriteria->getRow()) { $path = $aRow['PRF_PATH']; $rsCriteria->next(); } if ($path == '') { throw new \Exception(\G::LoadTranslation('ID_PMTABLE_UPLOADING_FILE_PROBLEM')); } $extention = strstr($_FILES['prf_file']['name'], '.'); if (!$extention) { $extention = '.html'; $_FILES['prf_file']['name'] = $_FILES['prf_file']['name'].$extention; } $file = end(explode("/",$path)); if(strpos($file,"\\") > 0) { $file = str_replace('\\', '/', $file); $file = end(explode("/",$file)); } $path = str_replace($file,'',$path); if ($file == $_FILES['prf_file']['name']) { if ($_FILES['prf_file']['error'] != 1) { if ($_FILES['prf_file']['tmp_name'] != '') { \G::uploadFile($_FILES['prf_file']['tmp_name'], $path, $_FILES['prf_file']['name']); } } } else { throw new \Exception(\G::LoadTranslation('ID_PMTABLE_UPLOADING_FILE_PROBLEM')); } $oProcessFile = array('prf_uid' => $prfUid); return $oProcessFile; } catch (Exception $e) { throw $e; } }
/** * Upload Image * @global type $_FILES */ public function uploadImage() { //!dataSystem G::LoadSystem('inputfilter'); $filter = new InputFilter(); $_SERVER["REQUEST_URI"] = $filter->xssFilterHard($_SERVER["REQUEST_URI"]); $_FILES = $filter->xssFilterHard($_FILES); $ainfoSite = explode("/", $_SERVER["REQUEST_URI"]); $dir = PATH_DATA . "sites" . PATH_SEP . str_replace("sys", "", $ainfoSite[1]) . PATH_SEP . "files/logos"; global $_FILES; //| 0-> non fail //| 1-> fail in de type of the image //| 2-> fail in de size of the image //| 3-> fail in de myme of the image $failed = 0; //!dataSystem $ori_dir = $dir . '/img/ori/'; $thumb_dir = $dir . '/img/thumbs/'; $allowedType = array('image/jpg', 'image/jpeg', 'image/pjpeg', 'image/gif', 'image/png', 'image/x-png'); $allowedTypeArray['index' . base64_encode('image/jpg')] = IMAGETYPE_JPEG; $allowedTypeArray['index' . base64_encode('image/jpeg')] = IMAGETYPE_JPEG; $allowedTypeArray['index' . base64_encode('image/pjpeg')] = IMAGETYPE_JPEG; $allowedTypeArray['index' . base64_encode('image/gif')] = IMAGETYPE_GIF; $allowedTypeArray['index' . base64_encode('image/png')] = IMAGETYPE_PNG; $allowedTypeArray['index' . base64_encode('image/x-png')] = IMAGETYPE_PNG; $uploaded = 0; $failed = 0; $files_img_type = $_FILES['img']['type']; if (in_array($files_img_type, $allowedType)) { // max upload file is 500 KB if ($_FILES['img']['size'] <= 500000) { $formf = $_FILES['img']; $namefile = $formf['name']; $typefile = $formf['type']; $errorfile = $formf['error']; $tmpFile = $formf['tmp_name']; $aMessage1 = array(); $fileName = trim(str_replace(' ', '_', $namefile)); $fileName = self::changeNamelogo($fileName); G::uploadFile($tmpFile, $dir, 'tmp' . $fileName); try { if (extension_loaded('exif')) { $typeMime = exif_imagetype($dir . '/' . 'tmp' . $fileName); } else { $arrayInfo = getimagesize($dir . '/' . 'tmp' . $fileName); $typeMime = $arrayInfo[2]; } if ($typeMime == $allowedTypeArray['index' . base64_encode($files_img_type)]) { $error = false; try { list($imageWidth, $imageHeight, $imageType) = @getimagesize($dir . '/' . 'tmp' . $fileName); G::resizeImage($dir . '/tmp' . $fileName, $imageWidth, 49, $dir . '/' . $fileName); G::auditLog("UploadLogo", "File Name: " . $fileName); } catch (Exception $e) { $error = $e->getMessage(); } $uploaded++; } else { $failed = "3"; } $path = $filter->xssFilterHard($dir . '/tmp' . $fileName, 'path'); unlink($path); } catch (Exception $e) { $failed = "3"; } } else { $failed = "2"; } } elseif ($files_img_type != '') { $failed = "1"; } $uploaded = $filter->validateInput($uploaded, 'int'); $files_img_type = $filter->xssFilterHard($files_img_type); $failed = $filter->validateInput($failed, 'int'); $resp = array('success' => true, 'failed' => $failed, 'uploaded' => $uploaded, 'type' => $files_img_type); echo G::json_encode($resp); exit; }
/** * import a pm table * * @param string $httpData->id */ public function import($httpData) { require_once 'classes/model/AdditionalTables.php'; try { $errors = ''; $overWrite = isset($_POST['form']['OVERWRITE']) ? true : false; //save the file if ($_FILES['form']['error']['FILENAME'] !== 0) { throw new Exception(G::loadTranslation('ID_PMTABLE_UPLOADING_FILE_PROBLEM')); } $oAdditionalTables = new AdditionalTables(); $tableNameMap = array(); $processQueue = array(); $processQueueTables = array(); $PUBLIC_ROOT_PATH = PATH_DATA . 'sites' . PATH_SEP . SYS_SYS . PATH_SEP . 'public' . PATH_SEP; $filename = $_FILES['form']['name']['FILENAME']; $tempName = $_FILES['form']['tmp_name']['FILENAME']; G::uploadFile($tempName, $PUBLIC_ROOT_PATH, $filename); $fileContent = file_get_contents($PUBLIC_ROOT_PATH . $filename); if (strpos($fileContent, '-----== ProcessMaker Open Source Private Tables ==-----') === false) { throw new Exception(G::loadTranslation('ID_PMTABLE_INVALID_FILE')); } $fp = fopen($PUBLIC_ROOT_PATH . $filename, "rb"); $fsData = intval(fread($fp, 9)); //reading the metadata $sType = fread($fp, $fsData); // first create the tables structures while (!feof($fp)) { switch ($sType) { case '@META': $fsData = intval(fread($fp, 9)); $METADATA = fread($fp, $fsData); break; case '@SCHEMA': $fsUid = intval(fread($fp, 9)); $uid = fread($fp, $fsUid); $fsData = intval(fread($fp, 9)); $schema = fread($fp, $fsData); $contentSchema = unserialize($schema); $additionalTable = new additionalTables(); $tableExists = $additionalTable->loadByName($contentSchema['ADD_TAB_NAME']); $tableNameMap[$contentSchema['ADD_TAB_NAME']] = $contentSchema['ADD_TAB_NAME']; if ($overWrite) { if ($tableExists !== false) { $additionalTable->deleteAll($tableExists['ADD_TAB_UID']); } } else { if ($tableExists !== false) { // some table exists with the same name // renaming... $tNameOld = $contentSchema['ADD_TAB_NAME']; $newTableName = $contentSchema['ADD_TAB_NAME'] . '_' . date('YmdHis'); $contentSchema['ADD_TAB_UID'] = G::generateUniqueID(); $contentSchema['ADD_TAB_NAME'] = $newTableName; $contentSchema['ADD_TAB_CLASS_NAME'] = additionalTables::getPHPName($newTableName); //mapping the table name for posterior uses $tableNameMap[$tNameOld] = $contentSchema['ADD_TAB_NAME']; } } // validating invalid bds_uid in old tables definition -> mapped to workflow if (!$contentSchema['DBS_UID'] || $contentSchema['DBS_UID'] == '0' || !$contentSchema['DBS_UID']) { $contentSchema['DBS_UID'] = 'workflow'; } $columns = array(); foreach ($contentSchema['FIELDS'] as $field) { $column = array('uid' => '', 'field_uid' => '', 'field_name' => $field['FLD_NAME'], 'field_dyn' => isset($field['FLD_DYN_NAME']) ? $field['FLD_DYN_NAME'] : '', 'field_label' => isset($field['FLD_DESCRIPTION']) ? $field['FLD_DESCRIPTION'] : '', 'field_type' => $field['FLD_TYPE'], 'field_size' => $field['FLD_SIZE'], 'field_key' => isset($field['FLD_KEY']) ? $field['FLD_KEY'] : 0, 'field_null' => isset($field['FLD_NULL']) ? $field['FLD_NULL'] : 1, 'field_autoincrement' => isset($field['FLD_AUTO_INCREMENT']) ? $field['FLD_AUTO_INCREMENT'] : 0); $columns[] = $column; } $tableData = new stdClass(); $tableData->REP_TAB_UID = $contentSchema['ADD_TAB_UID']; $tableData->REP_TAB_NAME = $contentSchema['ADD_TAB_NAME']; $tableData->REP_TAB_DSC = $contentSchema['ADD_TAB_DESCRIPTION']; $tableData->REP_TAB_CONNECTION = $contentSchema['DBS_UID']; if (isset($_POST["form"]["PRO_UID"]) && !empty($_POST["form"]["PRO_UID"])) { $tableData->PRO_UID = $_POST["form"]["PRO_UID"]; } else { $tableData->PRO_UID = isset($contentSchema["PRO_UID"]) ? $contentSchema["PRO_UID"] : ""; } $tableData->REP_TAB_TYPE = isset($contentSchema['ADD_TAB_TYPE']) ? $contentSchema['ADD_TAB_TYPE'] : ''; $tableData->REP_TAB_GRID = isset($contentSchema['ADD_TAB_GRID']) ? $contentSchema['ADD_TAB_GRID'] : ''; $tableData->columns = G::json_encode($columns); $tableData->forceUid = true; //save the table $alterTable = false; $result = $this->save($tableData, $alterTable); if ($result->success) { $processQueueTables[$contentSchema['DBS_UID']][] = $contentSchema['ADD_TAB_NAME']; } else { $errors .= 'Error creating table: ' . $tableData->REP_TAB_NAME . '-> ' . $result->message . "\n\n"; } break; case '@DATA': $fstName = intval(fread($fp, 9)); $tableName = fread($fp, $fstName); $fsData = intval(fread($fp, 9)); if ($fsData > 0) { $data = fread($fp, $fsData); } break; } $fsData = intval(fread($fp, 9)); //reading the metadata if ($fsData > 0) { // reading next block type $sType = fread($fp, $fsData); } else { break; } } fclose($fp); G::loadClass('pmTable'); foreach ($processQueueTables as $dbsUid => $tables) { $pmTable = new pmTable(); ob_start(); $pmTable->buildModelFor($dbsUid, $tables); $buildResult = ob_get_contents(); ob_end_clean(); $errors .= $pmTable->upgradeDatabaseFor($pmTable->getDataSource(), $tables); } $fp = fopen($PUBLIC_ROOT_PATH . $filename, "rb"); $fsData = intval(fread($fp, 9)); $sType = fread($fp, $fsData); // data processing while (!feof($fp)) { switch ($sType) { case '@META': $fsData = intval(fread($fp, 9)); $METADATA = fread($fp, $fsData); break; case '@SCHEMA': $fsUid = intval(fread($fp, 9)); $uid = fread($fp, $fsUid); $fsData = intval(fread($fp, 9)); $schema = fread($fp, $fsData); $contentSchema = unserialize($schema); $additionalTable = new additionalTables(); $table = $additionalTable->loadByName($tableNameMap[$contentSchema['ADD_TAB_NAME']]); if ($table['PRO_UID'] != '') { // is a report table, try populate it $additionalTable->populateReportTable($table['ADD_TAB_NAME'], pmTable::resolveDbSource($table['DBS_UID']), $table['ADD_TAB_TYPE'], $table['PRO_UID'], $table['ADD_TAB_GRID'], $table['ADD_TAB_UID']); } break; case '@DATA': $fstName = intval(fread($fp, 9)); $tableName = fread($fp, $fstName); $fsData = intval(fread($fp, 9)); if ($fsData > 0) { $data = fread($fp, $fsData); $contentData = unserialize($data); $tableName = $tableNameMap[$tableName]; $oAdditionalTables = new AdditionalTables(); $table = $oAdditionalTables->loadByName($tableName); $isReport = $table['PRO_UID'] !== '' ? true : false; if ($table !== false) { if (!$isReport) { if (count($contentData) > 0) { foreach ($contentData as $row) { $data = new StdClass(); $data->id = $table['ADD_TAB_UID']; $data->rows = base64_encode(serialize($row)); $res = $this->dataCreate($data, 'base64'); if (!$res->success) { $errors .= $res->message; } } } } } } break; } $fsData = intval(fread($fp, 9)); if ($fsData > 0) { $sType = fread($fp, $fsData); } else { break; } } //////////// if ($errors == '') { $result->success = true; $msg = G::loadTranslation('ID_PMTABLE_IMPORT_SUCCESS', array($filename)); } else { $result->success = false; $result->errorType = 'warning'; $msg = G::loadTranslation('ID_PMTABLE_IMPORT_WITH_ERRORS', array($filename)) . "\n\n" . $errors; } $result->message = $msg; } catch (Exception $e) { $result->errorType = 'error'; $result->buildResult = ob_get_contents(); ob_end_clean(); $result->success = false; // if it is a propel exception message if (preg_match('/(.*)\\s\\[(.*):\\s(.*)\\]\\s\\[(.*):\\s(.*)\\]/', $e->getMessage(), $match)) { $result->message = $match[3]; $result->type = G::loadTranslation('ID_ERROR'); } else { $result->message = $e->getMessage(); $result->type = G::loadTranslation('ID_EXCEPTION'); } //$result->trace = $e->getTraceAsString(); } return $result; }
default: //New $aFields = array('APP_UID' => $appId, 'DEL_INDEX' => isset($_SESSION['INDEX']) ? $_SESSION['INDEX'] : 1, 'USR_UID' => $_SESSION['USER_LOGGED'], 'DOC_UID' => $docUid, 'APP_DOC_TYPE' => $_POST['form']['APP_DOC_TYPE'], 'APP_DOC_CREATE_DATE' => date('Y-m-d H:i:s'), 'APP_DOC_COMMENT' => isset($_POST['form']['APP_DOC_COMMENT']) ? $_POST['form']['APP_DOC_COMMENT'] : '', 'APP_DOC_TITLE' => '', 'APP_DOC_FILENAME' => isset($_FILES['form']['name']['APP_DOC_FILENAME']) ? $_FILES['form']['name']['APP_DOC_FILENAME'] : '', 'FOLDER_UID' => $folderId, 'APP_DOC_TAGS' => $fileTags); $oAppDocument->create($aFields); break; } $sAppDocUid = $oAppDocument->getAppDocUid(); $iDocVersion = $oAppDocument->getDocVersion(); $info = pathinfo($oAppDocument->getAppDocFilename()); $ext = isset($info['extension']) ? $info['extension'] : ''; //save the file if (!empty($_FILES['form'])) { if ($_FILES['form']['error']['APP_DOC_FILENAME'] == 0) { $sPathName = PATH_DOCUMENT . $appId . PATH_SEP; $sFileName = $sAppDocUid . "_" . $iDocVersion . '.' . $ext; G::uploadFile($_FILES['form']['tmp_name']['APP_DOC_FILENAME'], $sPathName, $sFileName); //Plugin Hook PM_UPLOAD_DOCUMENT for upload document $oPluginRegistry =& PMPluginRegistry::getSingleton(); if ($oPluginRegistry->existsTrigger(PM_UPLOAD_DOCUMENT) && class_exists('uploadDocumentData')) { $oData['APP_UID'] = $appId; $documentData = new uploadDocumentData($appId, $_SESSION['USER_LOGGED'], $sPathName . $sFileName, $aFields['APP_DOC_FILENAME'], $sAppDocUid); $oPluginRegistry->executeTriggers(PM_UPLOAD_DOCUMENT, $documentData); unlink($sPathName . $sFileName); } //end plugin } } G::header('location: appFolderList'); die; } catch (Exception $e) { /* Render Error page */
/** * Add a input document * * Return the application document ID * * @param string $inputDocumentUid Input document ID * @param string $appDocUid Application document ID * @param int $docVersion Document version * @param string $appDocType Document type * @param string $appDocComment Document comment * @param string $inputDocumentAction Action, posible values: null or empty (Add), "R" (Replace), "NV" (New Version) * @param string $applicationUid Application ID * @param int $delIndex Delegation index * @param string $taskUid Task ID * @param string $userUid User ID * @param string $option Option, posible values: "xmlform", "file" * @param string $file File ($_FILES["form"]["name"]["APP_DOC_FILENAME"] or path to file) * @param int $fileError File error ($_FILES["form"]["error"]["APP_DOC_FILENAME"] or 0) * @param string $fileTmpName File temporal name ($_FILES["form"]["tmp_name"]["APP_DOC_FILENAME"] or null) * @param string $fileSize File size ($_FILES["form"]["size"]["APP_DOC_FILENAME"] or 0) * @return string Return application document ID */ public function addInputDocument($inputDocumentUid, $appDocUid, $docVersion, $appDocType, $appDocComment, $inputDocumentAction, $applicationUid, $delIndex, $taskUid, $userUid, $option, $file, $fileError = 0, $fileTmpName = null, $fileSize = 0) { $appDocFileName = null; $sw = 0; switch ($option) { case "xmlform": $appDocFileName = $file; if ($fileError == 0) { $sw = 1; } break; case "file": $appDocFileName = basename($file); if (file_exists($file) && is_file($file)) { $sw = 1; } break; } if ($sw == 0) { return null; } //Info $inputDocument = new InputDocument(); $arrayInputDocumentData = $inputDocument->load($inputDocumentUid); //--- Validate Filesize of $_FILE $inpDocMaxFilesize = $arrayInputDocumentData["INP_DOC_MAX_FILESIZE"]; $inpDocMaxFilesizeUnit = $arrayInputDocumentData["INP_DOC_MAX_FILESIZE_UNIT"]; $inpDocMaxFilesize = $inpDocMaxFilesize * (($inpDocMaxFilesizeUnit == "MB")? 1024 *1024 : 1024); //Bytes if ($inpDocMaxFilesize > 0 && $fileSize > 0) { if ($fileSize > $inpDocMaxFilesize) { throw new Exception(G::LoadTranslation("ID_SIZE_VERY_LARGE_PERMITTED")); } } //Get the Custom Folder ID (create if necessary) $appFolder = new AppFolder(); $folderId = $appFolder->createFromPath($arrayInputDocumentData["INP_DOC_DESTINATION_PATH"], $applicationUid); $tags = $appFolder->parseTags($arrayInputDocumentData["INP_DOC_TAGS"], $applicationUid); $appDocument = new AppDocument(); $arrayField = array(); switch ($inputDocumentAction) { case "R": //Replace $arrayField = array( "APP_DOC_UID" => $appDocUid, "APP_UID" => $applicationUid, "DOC_VERSION" => $docVersion, "DEL_INDEX" => $delIndex, "USR_UID" => $userUid, "DOC_UID" => $inputDocumentUid, "APP_DOC_TYPE" => $appDocType, "APP_DOC_CREATE_DATE" => date("Y-m-d H:i:s"), "APP_DOC_COMMENT" => $appDocComment, "APP_DOC_TITLE" => "", "APP_DOC_FILENAME" => $appDocFileName, "FOLDER_UID" => $folderId, "APP_DOC_TAGS" => $tags ); $appDocument->update($arrayField); break; case "NV": //New Version $arrayField = array( "APP_DOC_UID" => $appDocUid, "APP_UID" => $applicationUid, "DEL_INDEX" => $delIndex, "USR_UID" => $userUid, "DOC_UID" => $inputDocumentUid, "APP_DOC_TYPE" => $appDocType, "APP_DOC_CREATE_DATE" => date("Y-m-d H:i:s"), "APP_DOC_COMMENT" => $appDocComment, "APP_DOC_TITLE" => "", "APP_DOC_FILENAME" => $appDocFileName, "FOLDER_UID" => $folderId, "APP_DOC_TAGS" => $tags ); $appDocument->create($arrayField); break; default: //New $arrayField = array( "APP_UID" => $applicationUid, "DEL_INDEX" => $delIndex, "USR_UID" => $userUid, "DOC_UID" => $inputDocumentUid, "APP_DOC_TYPE" => $appDocType, "APP_DOC_CREATE_DATE" => date("Y-m-d H:i:s"), "APP_DOC_COMMENT" => $appDocComment, "APP_DOC_TITLE" => "", "APP_DOC_FILENAME" => $appDocFileName, "FOLDER_UID" => $folderId, "APP_DOC_TAGS" => $tags ); $appDocument->create($arrayField); break; } //Save the file $appDocUid = $appDocument->getAppDocUid(); $docVersion = $appDocument->getDocVersion(); $arrayInfo = pathinfo($appDocument->getAppDocFilename()); $extension = (isset($arrayInfo["extension"])) ? $arrayInfo["extension"] : null; $strPathName = PATH_DOCUMENT . G::getPathFromUID($applicationUid) . PATH_SEP; $strFileName = $appDocUid . "_" . $docVersion . "." . $extension; switch ($option) { case "xmlform": G::uploadFile($fileTmpName, $strPathName, $strFileName); break; case "file": $umaskOld = umask(0); if (!is_dir($strPathName)) { G::verifyPath($strPathName, true); } G::LoadSystem('inputfilter'); $filter = new InputFilter(); $file = $filter->xssFilterHard($file, 'path'); copy($file, $strPathName . $strFileName); chmod($strPathName . $strFileName, 0666); umask($umaskOld); break; } //Plugin Hook PM_UPLOAD_DOCUMENT for upload document $pluginRegistry = &PMPluginRegistry::getSingleton(); if ($pluginRegistry->existsTrigger(PM_UPLOAD_DOCUMENT) && class_exists("uploadDocumentData")) { $triggerDetail = $pluginRegistry->getTriggerInfo(PM_UPLOAD_DOCUMENT); $documentData = new uploadDocumentData( $applicationUid, $userUid, $strPathName . $strFileName, $arrayField["APP_DOC_FILENAME"], $appDocUid, $docVersion ); $uploadReturn = $pluginRegistry->executeTriggers(PM_UPLOAD_DOCUMENT, $documentData); if ($uploadReturn) { $arrayField["APP_DOC_PLUGIN"] = $triggerDetail->sNamespace; if (!isset($arrayField["APP_DOC_UID"])) { $arrayField["APP_DOC_UID"] = $appDocUid; } if (!isset($arrayField["DOC_VERSION"])) { $arrayField["DOC_VERSION"] = $docVersion; } $appDocument->update($arrayField); unlink($strPathName . $strFileName); } } //End plugin return $appDocUid; }
$configuration = new Configurations(); $importResults = $language->import($languageFile); G::LoadClass("wsTools"); $renegerateContent = new workspaceTools(SYS_SYS); $messs = $renegerateContent->upgradeContent(); $result->msg = G::LoadTranslation('IMPORT_LANGUAGE_SUCCESS') . "\n"; $result->msg .= G::LoadTranslation("ID_FILE_NUM_RECORD") . $importResults->recordsCount . "\n"; $result->msg .= G::LoadTranslation("ID_SUCCESS_RECORD") . $importResults->recordsCountSuccess . "\n"; $result->msg .= G::LoadTranslation("ID_FAILED_RECORD") . ($importResults->recordsCount - $importResults->recordsCountSuccess) . "\n"; if ($importResults->errMsg != '') { $result->msg .= G::LoadTranslation("ID_ERROR_REGISTERED") . " \n" . $importResults->errMsg . "\n"; } //$result->msg = htmlentities($result->msg); $result->success = true; //saving metadata $configuration->aConfig = array('headers' => $importResults->headers, 'language' => $importResults->lang, 'import-date' => date('Y-m-d H:i:s'), 'user' => '', 'version' => '1.0'); $configuration->saveConfig('LANGUAGE_META', $importResults->lang); $dir = PATH_CORE . 'content' . PATH_SEP . 'translations' . PATH_SEP; if (!is_writable($dir)) { throw new Exception(G::LoadTranslation('ID_TRANSLATIONS_FOLDER_PERMISSIONS')); } G::uploadFile($languageFile, $dir, $languageFilename, 0777); ini_set('max_execution_time', $sMaxExecutionTime); } catch (Exception $oError) { $result->msg = $oError->getMessage(); //print_r($oError->getTrace()); $result->success = false; //G::SendTemporalMessage($oError->getMessage(), 'error', 'string'); //G::header('location: languages_ImportForm'); } echo G::json_encode($result);
* */ global $RBAC; $RBAC->requirePermissions('PM_SETUP_ADVANCE'); try { //load the variables G::LoadClass('plugin'); if (!isset($_FILES['form']['error']['PLUGIN_FILENAME']) || $_FILES['form']['error']['PLUGIN_FILENAME'] == 1) { throw new Exception(G::loadTranslation('ID_ERROR_UPLOADING_PLUGIN_FILENAME')); } //save the file if ($_FILES['form']['error']['PLUGIN_FILENAME'] == 0) { $filename = $_FILES['form']['name']['PLUGIN_FILENAME']; $path = PATH_DOCUMENT . 'input' . PATH_SEP; $tempName = $_FILES['form']['tmp_name']['PLUGIN_FILENAME']; G::uploadFile($tempName, $path, $filename); } //save the files Enterprise if ($_FILES['form']['error']['PLUGIN_FILENAME'] == 0) { $filename = $_FILES['form']['name']['PLUGIN_FILENAME']; $path = PATH_DOCUMENT . 'input' . PATH_SEP; if (strpos($filename, 'enterprise') !== false) { G::LoadThirdParty('pear/Archive', 'Tar'); $tar = new Archive_Tar($path . $filename); $sFileName = substr($filename, 0, strrpos($filename, '.')); $sClassName = substr($filename, 0, strpos($filename, '-')); $sClassName = !empty($sClassName) ? $sClassName : $sFileName; $files = $tar->listContent(); $licenseName = ''; $listFiles = array(); foreach ($files as $key => $val) {
$oFolder = new AppFolder(); $folderId = $oFolder->createFromPath($aID['INP_DOC_DESTINATION_PATH']); //Tags $fileTags = $oFolder->parseTags($aID['INP_DOC_TAGS']); $aFields = array('APP_UID' => $_SESSION['APPLICATION'], 'DEL_INDEX' => $_SESSION['INDEX'], 'USR_UID' => $_SESSION['USER_LOGGED'], 'DOC_UID' => $_POST['INPUTS'][$sFieldName], 'APP_DOC_TYPE' => 'INPUT', 'APP_DOC_CREATE_DATE' => date('Y-m-d H:i:s'), 'APP_DOC_COMMENT' => '', 'APP_DOC_TITLE' => '', 'APP_DOC_FILENAME' => $_FILES['form']['name'][$sFieldName], 'FOLDER_UID' => $folderId, 'APP_DOC_TAGS' => $fileTags); } else { $aFields = array('APP_UID' => $_SESSION['APPLICATION'], 'DEL_INDEX' => $_SESSION['INDEX'], 'USR_UID' => $_SESSION['USER_LOGGED'], 'DOC_UID' => -1, 'APP_DOC_TYPE' => 'ATTACHED', 'APP_DOC_CREATE_DATE' => date('Y-m-d H:i:s'), 'APP_DOC_COMMENT' => '', 'APP_DOC_TITLE' => '', 'APP_DOC_FILENAME' => $_FILES['form']['name'][$sFieldName]); } $oAppDocument->create($aFields); $iDocVersion = $oAppDocument->getDocVersion(); $sAppDocUid = $oAppDocument->getAppDocUid(); $aInfo = pathinfo($oAppDocument->getAppDocFilename()); $sExtension = isset($aInfo['extension']) ? $aInfo['extension'] : ''; $sPathName = PATH_DOCUMENT . $_SESSION['APPLICATION'] . PATH_SEP; $sFileName = $sAppDocUid . '_' . $iDocVersion . '.' . $sExtension; G::uploadFile($_FILES['form']['tmp_name'][$sFieldName], $sPathName, $sFileName); //Plugin Hook PM_UPLOAD_DOCUMENT for upload document $oPluginRegistry =& PMPluginRegistry::getSingleton(); if ($oPluginRegistry->existsTrigger(PM_UPLOAD_DOCUMENT) && class_exists("uploadDocumentData")) { $triggerDetail = $oPluginRegistry->getTriggerInfo(PM_UPLOAD_DOCUMENT); $documentData = new uploadDocumentData($_SESSION["APPLICATION"], $_SESSION["USER_LOGGED"], $sPathName . $sFileName, $aFields["APP_DOC_FILENAME"], $sAppDocUid, $iDocVersion); $uploadReturn = $oPluginRegistry->executeTriggers(PM_UPLOAD_DOCUMENT, $documentData); if ($uploadReturn) { $aFields["APP_DOC_PLUGIN"] = $triggerDetail->sNamespace; if (!isset($aFields["APP_DOC_UID"])) { $aFields["APP_DOC_UID"] = $sAppDocUid; } if (!isset($aFields["DOC_VERSION"])) { $aFields["DOC_VERSION"] = $iDocVersion; } $oAppDocument->update($aFields);
//$aFields['FOLDER_UID'] = $folderId, //$aFields['APP_DOC_TAGS']= $fileTags } else { //New record $aFields = array('APP_UID' => $_POST['APPLICATION'], 'DEL_INDEX' => $_POST['INDEX'], 'USR_UID' => $_POST['USR_UID'], 'DOC_UID' => $_POST['DOC_UID'], 'APP_DOC_TYPE' => $_POST['APP_DOC_TYPE'], 'APP_DOC_CREATE_DATE' => date('Y-m-d H:i:s'), 'APP_DOC_COMMENT' => isset($_POST['COMMENT']) ? $_POST['COMMENT'] : '', 'APP_DOC_TITLE' => isset($_POST['TITLE']) ? $_POST['TITLE'] : '', 'APP_DOC_FILENAME' => isset($_FILES['ATTACH_FILE']['name']) ? $_FILES['ATTACH_FILE']['name'] : '', 'FOLDER_UID' => $folderId, 'APP_DOC_TAGS' => $fileTags); } $oAppDocument->create($aFields); $sAppUid = $oAppDocument->getAppUid(); $sAppDocUid = $oAppDocument->getAppDocUid(); $iDocVersion = $oAppDocument->getDocVersion(); $info = pathinfo($oAppDocument->getAppDocFilename()); $ext = isset($info['extension']) ? $info['extension'] : ''; //Save the file echo $sPathName = PATH_DOCUMENT . $sAppUid . PATH_SEP; echo $sFileName = $sAppDocUid . '_' . $iDocVersion . '.' . $ext; print G::uploadFile($_FILES['ATTACH_FILE']['tmp_name'], $sPathName, $sFileName); print "* The file {$_FILES['ATTACH_FILE']['name']} was uploaded successfully in case {$sAppUid} as input document..\n"; //Get current Application Fields $application = new Application(); $appFields = $application->Load($_POST['APPLICATION']); $appFields = unserialize($appFields['APP_DATA']); $_SESSION['APPLICATION'] = $appFields['APPLICATION']; $_SESSION['PROCESS'] = $appFields['PROCESS']; $_SESSION['TASK'] = $appFields['TASK']; $_SESSION['INDEX'] = $appFields['INDEX']; $_SESSION['USER_LOGGED'] = $appFields['USER_LOGGED']; //$_POST['USR_UID'] //$_SESSION['USR_USERNAME'] = $appFields['USR_USERNAME']; //$_SESSION['STEP_POSITION'] = 0; //Plugin Hook PM_UPLOAD_DOCUMENT for upload document $oPluginRegistry =& PMPluginRegistry::getSingleton();
function uploadExternalDocument() { $response['action']=$_POST['action']. " - ".$_POST['option']; $response['error']="error"; $response['message']="error"; $response['success']=false; $overwrite = (isset($_REQUEST['overwrite_files'])) ? $_REQUEST['overwrite_files'] : false; if (isset($_POST["confirm"]) && $_POST["confirm"] == "true") { if (isset($_FILES['uploadedFile'])) { $uploadedInstances=count($_FILES['uploadedFile']['name']); $sw_error=false; $sw_error_exists=isset($_FILES['uploadedFile']['error']); $emptyInstances=0; $quequeUpload=array(); //overwrite files if ($overwrite) { for ($i=0; $i<$uploadedInstances; $i++) { overwriteFile($_REQUEST['dir'], stripslashes($_FILES['uploadedFile']['name'][$i])); } } // upload files & check for errors for ($i=0; $i<$uploadedInstances; $i++) { $errors[$i] = null; $tmp = $_FILES['uploadedFile']['tmp_name'][$i]; $items[$i] = stripslashes($_FILES['uploadedFile']['name'][$i]); if ($sw_error_exists) { $up_err = $_FILES['uploadedFile']['error'][$i]; } else { $up_err=(file_exists($tmp)?0:4); } if ($items[$i]=="" || $up_err==4) { $emptyInstances++; continue; } if ($up_err==1 || $up_err==2) { $errors[$i]='miscfilesize'; $sw_error = true; continue; } if ($up_err==3) { $errors[$i]='miscfilepart'; $sw_error=true; continue; } if (!@is_uploaded_file($tmp)) { $errors[$i]='uploadfile'; $sw_error=true; continue; } //The uplaoded files seems to be correct and ready to be uploaded. Add to the Queque $fileInfo=array("tempName"=>$tmp,"fileName"=>$items[$i]); $quequeUpload[]=$fileInfo; } } elseif (isset($_POST['selitems'])) { $response=""; $response['msg']= "correct reload"; $response['success']=true; if (isset($_REQUEST['option']) && isset($_REQUEST['copyMove'])) { if ($_REQUEST['option'] == 'directory' && $_REQUEST['copyMove'] == 'all') { $response['action'] = $_POST['action']. " - ".$_POST['option']; $response['error'] = "Complete"; $response['message']= str_replace("Execute", "", $_POST['action']). " ". "Complete"; $response['success']= 'success'; $response['node'] = ''; $_POST ['node'] = ""; $newFolderUid = checkTree($_REQUEST['dir'], $_REQUEST['new_dir']); } $_POST['selitems'] = array(); } else { require_once ("classes/model/AppDocument.php"); $oAppDocument = new AppDocument(); if (isset($_POST['selitems']) && is_array($_POST['selitems'])) { foreach ($_POST['selitems'] as $docId) { $arrayDocId = explode ('_',$docId); $docInfo=$oAppDocument->load($arrayDocId[0]); $docInfo['FOLDER_UID'] = $_POST['new_dir']; $docInfo['APP_DOC_CREATE_DATE'] = date('Y-m-d H:i:s'); $oAppDocument->update($docInfo); } } } } //G::pr($quequeUpload); //Read. Instance Document classes if (!empty($quequeUpload)) { $docUid=$_POST['docUid']; $appDocUid=isset($_POST['APP_DOC_UID'])?$_POST['APP_DOC_UID']:""; $docVersion=isset($_POST['docVersion'])?$_POST['docVersion']:""; $actionType=isset($_POST['actionType'])?$_POST['actionType']:""; $folderId=$_POST['dir']==""?"/":$_POST['dir']; $appId=$_POST['appId']; $docType=isset($_POST['docType'])?$_GET['docType']:"INPUT"; //save info require_once ("classes/model/AppDocument.php"); require_once ('classes/model/AppFolder.php'); require_once ('classes/model/InputDocument.php'); $oInputDocument = new InputDocument(); if ($docUid != -1) { $aID = $oInputDocument->load($docUid); } else { $oFolder=new AppFolder(); $folderStructure=$oFolder->getFolderStructure($folderId); $aID=array('INP_DOC_DESTINATION_PATH'=>$folderStructure['PATH']); } //Get the Custom Folder ID (create if necessary) $oFolder=new AppFolder(); if ($docUid!=-1) { //krumo("jhl"); $folderId=$oFolder->createFromPath($aID['INP_DOC_DESTINATION_PATH'],$appId); //Tags $fileTags=$oFolder->parseTags($aID['INP_DOC_TAGS'],$appId); } else { $folderId=$folderId; $fileTags="EXTERNAL"; } foreach ($quequeUpload as $key => $fileObj) { $oAppDocument = new AppDocument(); switch ($actionType) { case "R": //replace $aFields = array( 'APP_DOC_UID' => $appDocUid, 'APP_UID' => $appId, 'DOC_VERSION' => $docVersion, 'DEL_INDEX' => 1, 'USR_UID' => $_SESSION['USER_LOGGED'], 'DOC_UID' => $docUid, 'APP_DOC_TYPE' => $docType, 'APP_DOC_CREATE_DATE' => date('Y-m-d H:i:s'), 'APP_DOC_COMMENT' => isset($_POST['form']['APP_DOC_COMMENT']) ? $_POST['form']['APP_DOC_COMMENT'] : '', 'APP_DOC_TITLE' => '', 'APP_DOC_FILENAME' => $fileObj['fileName'], 'FOLDER_UID' => $folderId, 'APP_DOC_TAGS' => $fileTags ); $oAppDocument->update($aFields); break; case "NV": //New Version $aFields = array( 'APP_DOC_UID' => $appDocUid, 'APP_UID' => $appId, 'DEL_INDEX' => 1, 'USR_UID' => $_SESSION['USER_LOGGED'], 'DOC_UID' => $docUid, 'APP_DOC_TYPE' => $docType, 'APP_DOC_CREATE_DATE' => date('Y-m-d H:i:s'), 'APP_DOC_COMMENT' => isset($_POST['form']['APP_DOC_COMMENT']) ? $_POST['form']['APP_DOC_COMMENT'] : '', 'APP_DOC_TITLE' => '', 'APP_DOC_FILENAME' => $fileObj['fileName'], 'FOLDER_UID' => $folderId, 'APP_DOC_TAGS' => $fileTags ); $oAppDocument->create($aFields); break; default: //New $aFields = array( 'APP_UID' => $appId, 'DEL_INDEX' => isset($_SESSION['INDEX'])?$_SESSION['INDEX']:1, 'USR_UID' => $_SESSION['USER_LOGGED'], 'DOC_UID' => $docUid, 'APP_DOC_TYPE' => $docType, 'APP_DOC_CREATE_DATE' => date('Y-m-d H:i:s'), 'APP_DOC_COMMENT' => isset($_POST['form']['APP_DOC_COMMENT']) ? $_POST['form']['APP_DOC_COMMENT'] : '', 'APP_DOC_TITLE' => '', 'APP_DOC_FILENAME' => $fileObj['fileName'], 'FOLDER_UID' => $folderId, 'APP_DOC_TAGS' => $fileTags ); $oAppDocument->create($aFields); break; } $sAppDocUid = $oAppDocument->getAppDocUid(); $iDocVersion = $oAppDocument->getDocVersion(); $info = pathinfo($oAppDocument->getAppDocFilename()); $ext = (isset($info['extension']) ? $info['extension'] : ''); //save the file //if (!empty($_FILES['form'])) { //if ($_FILES['form']['error']['APP_DOC_FILENAME'] == 0) { $sPathName = PATH_DOCUMENT . G::getPathFromUID($appId) . PATH_SEP; $file = G::getPathFromFileUID($appId, $sAppDocUid); $sPathName .= $file[0]; $sFileName = $file[1] . "_" . $iDocVersion . '.' . $ext; G::uploadFile($fileObj['tempName'], $sPathName, $sFileName); //upload //Plugin Hook PM_UPLOAD_DOCUMENT for upload document $oPluginRegistry =& PMPluginRegistry::getSingleton(); if ($oPluginRegistry->existsTrigger (PM_UPLOAD_DOCUMENT) && class_exists ('uploadDocumentData')) { $oData['APP_UID'] = $appId; $documentData = new uploadDocumentData ( $appId, $_SESSION['USER_LOGGED'], $sPathName . $sFileName, $fileObj['fileName'], $sAppDocUid ); //$oPluginRegistry->executeTriggers (PM_UPLOAD_DOCUMENT , $documentData); //unlink ($sPathName . $sFileName); } //end plugin if ($sw_error) { // there were errors $err_msg=""; for ($i=0; $i<$uploadedInstances; $i++) { if ($errors[$i]==null) { continue; } $err_msg .= $items[$i]." : ".$errors[$i]."\n"; } $response['error']=$err_msg; $response['message']=$err_msg; $response['success']=false; } elseif ($emptyInstances==$uploadedInstances) { $response['error']= G::LoadTranslation('ID_UPLOAD_LEAST_FILE'); $response['message']= G::LoadTranslation('ID_UPLOAD_LEAST_FILE'); $response['success']=false; } else { $response['error']= G::LoadTranslation('ID_UPLOAD_COMPLETE'); $response['message']="Upload complete"; $response['success']=true; } } } } print_r(G::json_encode($response)); /* G::LoadClass ('case'); $oCase = new Cases (); $G_PUBLISH = new Publisher (); $Fields ['DOC_UID'] = "-1"; $Fields ['appId'] = "00000000000000000000000000000000"; $G_PUBLISH->AddContent ('xmlform', 'xmlform', 'cases/cases_AttachInputDocumentGeneral', '', $Fields, 'appFolderSaveDocument?UID=-1&appId=' . $Fields ['appId'] . "&folderId=" . $_POST ['folderID']); G::RenderPage ('publish', 'raw'); */ }
<?php try { require_once 'classes/model/OutputDocument.php'; if (empty($_FILES['form']) || $_FILES['form']['name']['OUT_DOC_FILE'] == '') { throw new Exception('you must upload a file.'); } $uid = $_POST['form']['OUT_DOC_UID']; $oOutputDocument = new OutputDocument(); $aFields = $oOutputDocument->load($uid); $type = $aFields['OUT_DOC_TYPE']; $aExtension = explode('.', strtolower(basename($_FILES['form']['name']['OUT_DOC_FILE']))); $extension = $aExtension[count($aExtension) - 1]; if ($extension != 'jrxml' && $type == 'JRXML') { throw new Exception("'{$extension}' is not a valid extension, you must upload a .jrxml file."); } if ($extension != 'pdf' && $type == 'ACROFORM') { throw new Exception("'{$extension}' is not a valid extension, you must upload a .pdf file."); } $fileJrxml = PATH_DYNAFORM . $aFields['PRO_UID'] . PATH_SEP . $aFields['OUT_DOC_UID'] . '.' . $extension; if (!empty($_FILES['form'])) { if ($_FILES['form']['error']['OUT_DOC_FILE'] == 0) { G::uploadFile($_FILES['form']['tmp_name']['OUT_DOC_FILE'], dirname($fileJrxml), basename($fileJrxml)); } } print "<font face='Arial' size='2' >File uploaded.</font>"; } catch (Exception $e) { print "<font face='Arial' size='2' color='red' >Error: " . $e->getMessage() . "</font>"; }
/** * Upload Image * @global type $_FILES */ public function uploadImage() { //!dataSystem $ainfoSite = explode("/", $_SERVER["REQUEST_URI"]); $dir = PATH_DATA . "sites" . PATH_SEP . str_replace("sys", "", $ainfoSite[1]) . PATH_SEP . "files/logos"; global $_FILES; //| 0-> non fail //| 1-> fail in de type of the image //| 2-> fail in de size of the image //| 3-> fail in de myme of the image $failed = 0; //!dataSystem $ori_dir = $dir . '/img/ori/'; $thumb_dir = $dir . '/img/thumbs/'; $allowedType = array('image/jpg', 'image/jpeg', 'image/pjpeg', 'image/gif', 'image/png', 'image/x-png'); $allowedTypeArray['index' . base64_encode('image/jpg')] = IMAGETYPE_JPEG; $allowedTypeArray['index' . base64_encode('image/jpeg')] = IMAGETYPE_JPEG; $allowedTypeArray['index' . base64_encode('image/pjpeg')] = IMAGETYPE_JPEG; $allowedTypeArray['index' . base64_encode('image/gif')] = IMAGETYPE_GIF; $allowedTypeArray['index' . base64_encode('image/png')] = IMAGETYPE_PNG; $allowedTypeArray['index' . base64_encode('image/x-png')] = IMAGETYPE_PNG; $uploaded = 0; $failed = 0; if (in_array($_FILES['img']['type'], $allowedType)) { // max upload file is 500 KB if ($_FILES['img']['size'] <= 500000) { $formf = $_FILES['img']; $namefile = $formf['name']; $typefile = $formf['type']; $errorfile = $formf['error']; $tmpFile = $formf['tmp_name']; $aMessage1 = array(); $fileName = trim(str_replace(' ', '_', $namefile)); $fileName = self::changeNamelogo($fileName); G::uploadFile($tmpFile, $dir, 'tmp' . $fileName); try { if (extension_loaded('exif')) { $typeMime = exif_imagetype($dir . '/' . 'tmp' . $fileName); } else { $arrayInfo = getimagesize($dir . '/' . 'tmp' . $fileName); $typeMime = $arrayInfo[2]; } if ($typeMime == $allowedTypeArray['index' . base64_encode($_FILES['img']['type'])]) { $error = false; try { list($imageWidth, $imageHeight, $imageType) = @getimagesize($dir . '/' . 'tmp' . $fileName); G::resizeImage($dir . '/tmp' . $fileName, $imageWidth, 49, $dir . '/' . $fileName); } catch (Exception $e) { $error = $e->getMessage(); } $uploaded++; } else { $failed = "3"; } unlink($dir . '/tmp' . $fileName); } catch (Exception $e) { $failed = "3"; } } else { $failed = "2"; } } elseif ($_FILES['img']['type'] != '') { $failed = "1"; } echo '{success: true, failed: ' . $failed . ', uploaded: ' . $uploaded . ', type: "' . $_FILES['img']['type'] . '"}'; exit; }
//$aFields["APP_DOC_TAGS"] = $fileTags $aFields["APP_DOC_FIELDNAME"] = $_POST["APP_DOC_FIELDNAME"]; } else { //New record $aFields = array("APP_UID" => $_POST["APPLICATION"], "DEL_INDEX" => $_POST["INDEX"], "USR_UID" => $_POST["USR_UID"], "DOC_UID" => $_POST["DOC_UID"], "APP_DOC_TYPE" => $_POST["APP_DOC_TYPE"], "APP_DOC_CREATE_DATE" => date("Y-m-d H:i:s"), "APP_DOC_COMMENT" => isset($_POST["COMMENT"]) ? $_POST["COMMENT"] : "", "APP_DOC_TITLE" => isset($_POST["TITLE"]) ? $_POST["TITLE"] : "", "APP_DOC_FILENAME" => isset($_FILES["ATTACH_FILE"]["name"]) ? $_FILES["ATTACH_FILE"]["name"] : "", "FOLDER_UID" => $folderId, "APP_DOC_TAGS" => $fileTags, "APP_DOC_FIELDNAME" => $_POST["APP_DOC_FIELDNAME"]); } $oAppDocument->create($aFields); $sAppUid = $oAppDocument->getAppUid(); $sAppDocUid = $oAppDocument->getAppDocUid(); $iDocVersion = $oAppDocument->getDocVersion(); $info = pathinfo($oAppDocument->getAppDocFilename()); $ext = isset($info["extension"]) ? $info["extension"] : ""; //Save the file echo $sPathName = PATH_DOCUMENT . $sAppUid . PATH_SEP; echo $sFileName = $sAppDocUid . "_" . $iDocVersion . "." . $ext; print G::uploadFile($_FILES["ATTACH_FILE"]["tmp_name"], $sPathName, $sFileName); print "* The file " . $_FILES["ATTACH_FILE"]["name"] . " was uploaded successfully in case " . $sAppUid . " as input document..\n"; //Get current Application Fields $application = new Application(); $appFields = $application->Load($_POST["APPLICATION"]); $appFields = unserialize($appFields["APP_DATA"]); $_SESSION["APPLICATION"] = $appFields["APPLICATION"]; $_SESSION["PROCESS"] = $appFields["PROCESS"]; $_SESSION["TASK"] = $appFields["TASK"]; $_SESSION["INDEX"] = $appFields["INDEX"]; $_SESSION["USER_LOGGED"] = $appFields["USER_LOGGED"]; //$_POST["USR_UID"] //$_SESSION["USR_USERNAME"] = $appFields["USR_USERNAME"]; //$_SESSION["STEP_POSITION"] = 0; //Plugin Hook PM_UPLOAD_DOCUMENT for upload document $oPluginRegistry =& PMPluginRegistry::getSingleton();
<?php global $RBAC; if ($RBAC->userCanAccess('PM_FACTORY') == 1) { G::LoadClass('processes'); $app = new Processes(); if (!$app->processExists($_POST['form']['PRO_UID'])) { echo G::LoadTranslation('ID_PROCESS_UID_NOT_DEFINED'); die; } switch ($_POST['form']['MAIN_DIRECTORY']) { case 'mailTemplates': $sDirectory = PATH_DATA_MAILTEMPLATES . $_POST['form']['PRO_UID'] . PATH_SEP . ($_POST['form']['CURRENT_DIRECTORY'] != '' ? $_POST['form']['CURRENT_DIRECTORY'] . PATH_SEP : ''); break; case 'public': $sDirectory = PATH_DATA_PUBLIC . $_POST['form']['PRO_UID'] . PATH_SEP . ($_POST['form']['CURRENT_DIRECTORY'] != '' ? $_POST['form']['CURRENT_DIRECTORY'] . PATH_SEP : ''); break; default: die; break; } for ($i = 1; $i <= 5; $i++) { if ($_FILES['form']['tmp_name']['FILENAME' . (string) $i] != '') { G::uploadFile($_FILES['form']['tmp_name']['FILENAME' . (string) $i], $sDirectory, $_FILES['form']['name']['FILENAME' . (string) $i]); } } } die('<script type="text/javascript">parent.goToDirectoryforie(\'' . $_POST['form']['PRO_UID'] . '\', \'' . $_POST['form']['MAIN_DIRECTORY'] . '\', \'' . $_POST['form']['CURRENT_DIRECTORY'] . '\');</script>');
/** * second step for upload file * upload file in foler app_uid * * @param $userUid * @param $Fields * @param $type * @throws \Exception */ public function documentUploadFiles($userUid, $app_uid, $app_doc_uid, $request_data) { $response = array("status" => "fail"); if (isset( $_FILES["form"]["name"] ) && count( $_FILES["form"]["name"] ) > 0) { $arrayField = array (); $arrayFileName = array (); $arrayFileTmpName = array (); $arrayFileError = array (); $i = 0; foreach ($_FILES["form"]["name"] as $fieldIndex => $fieldValue) { if (is_array( $fieldValue )) { foreach ($fieldValue as $index => $value) { if (is_array( $value )) { foreach ($value as $grdFieldIndex => $grdFieldValue) { $arrayField[$i]["grdName"] = $fieldIndex; $arrayField[$i]["grdFieldName"] = $grdFieldIndex; $arrayField[$i]["index"] = $index; $arrayFileName[$i] = $_FILES["form"]["name"][$fieldIndex][$index][$grdFieldIndex]; $arrayFileTmpName[$i] = $_FILES["form"]["tmp_name"][$fieldIndex][$index][$grdFieldIndex]; $arrayFileError[$i] = $_FILES["form"]["error"][$fieldIndex][$index][$grdFieldIndex]; $i = $i + 1; } } } } else { $arrayField[$i] = $fieldIndex; $arrayFileName[$i] = $_FILES["form"]["name"][$fieldIndex]; $arrayFileTmpName[$i] = $_FILES["form"]["tmp_name"][$fieldIndex]; $arrayFileError[$i] = $_FILES["form"]["error"][$fieldIndex]; $i = $i + 1; } } if (count( $arrayField ) > 0) { for ($i = 0; $i <= count( $arrayField ) - 1; $i ++) { if ($arrayFileError[$i] == 0) { $indocUid = null; $fieldName = null; $fileSizeByField = 0; $oAppDocument = new \AppDocument(); $aAux = $oAppDocument->load($app_doc_uid); $iDocVersion = $oAppDocument->getDocVersion(); $sAppDocUid = $oAppDocument->getAppDocUid(); $aInfo = pathinfo( $oAppDocument->getAppDocFilename() ); $sExtension = ((isset( $aInfo["extension"] )) ? $aInfo["extension"] : ""); $pathUID = G::getPathFromUID($app_uid); $sPathName = PATH_DOCUMENT . $pathUID . PATH_SEP; $sFileName = $sAppDocUid . "_" . $iDocVersion . "." . $sExtension; G::uploadFile( $arrayFileTmpName[$i], $sPathName, $sFileName ); $response = array("status" => "ok"); } } } } return $response; }
'APP_DOC_CREATE_DATE' => date ( 'Y-m-d H:i:s' ), 'APP_DOC_COMMENT' => '', 'APP_DOC_TITLE' => '', 'APP_DOC_FILENAME' => $_FILES ['form'] ['name'] [$fieldName] ); } $appDocument->create($fields); $docVersion = $appDocument->getDocVersion(); $appDocUid = $appDocument->getAppDocUid (); $info = pathinfo ( $appDocument->getAppDocFilename () ); $extension = (isset ( $info ['extension'] ) ? $info ['extension'] : ''); $pathName = PATH_DOCUMENT . $_REQUEST['APP_UID'] . PATH_SEP; $fileName = $appDocUid . '_'.$docVersion.'.' . $extension; G::uploadFile ( $_FILES ['form'] ['tmp_name'] [$fieldName], $pathName, $fileName ); } } } $assign = $result['message']; $aMessage['MESSAGE'] = '<strong>The information was submitted. Thank you.</strong>'; } else { throw new Exception('An error occurred while the application was being processed.<br /><br /> Error code: '.$result->status_code.'<br /> Error message: '.$result->message.'<br /><br />'); } // Update $dataResponses['ABE_RES_STATUS'] = ($code == 0 ? 'SENT' : 'ERROR'); $dataResponses['ABE_RES_MESSAGE'] = ($code == 0 ? '-' : $result->message);
<?php sleep(1); if (isset($_SESSION['processes_upload'])) { $form = $_SESSION['processes_upload']; switch ($form['MAIN_DIRECTORY']) { case 'mailTemplates': $sDirectory = PATH_DATA_MAILTEMPLATES . $form['PRO_UID'] . PATH_SEP . ($form['CURRENT_DIRECTORY'] != '' ? $form['CURRENT_DIRECTORY'] . PATH_SEP : ''); break; case 'public': $sDirectory = PATH_DATA_PUBLIC . $form['PRO_UID'] . PATH_SEP . ($form['CURRENT_DIRECTORY'] != '' ? $form['CURRENT_DIRECTORY'] . PATH_SEP : ''); break; default: die; break; } } if ($_FILES['form']['error'] == "0") { G::uploadFile($_FILES['form']['tmp_name'], $sDirectory, $_FILES['form']['name']); $msg = "Uploaded (" . round(filesize($sDirectory . $_FILES['form']['name']) / 1024 * 10) / 10 . " kb)"; $result = 1; //echo $sDirectory.$_FILES['form']['name']; } else { $msg = "Failed"; $result = 0; } echo "{'result': {$result}, 'msg':'{$msg}'}";
$documentFileStructure = $oFolder->getFolderStructure(); $aFields = array("APP_UID" => $_SESSION["APPLICATION"], "DEL_INDEX" => $_SESSION["INDEX"], "USR_UID" => $_SESSION["USER_LOGGED"], "DOC_UID" => $indocUid, "APP_DOC_TYPE" => "INPUT", "APP_DOC_CREATE_DATE" => date("Y-m-d H:i:s"), "APP_DOC_COMMENT" => "", "APP_DOC_TITLE" => "", "APP_DOC_FILENAME" => $arrayFileName[$i], "FOLDER_UID" => $oFolder->createFromPath($aID["INP_DOC_DESTINATION_PATH"]), "APP_DOC_TAGS" => $oFolder->parseTags($aID["INP_DOC_TAGS"]), "APP_DOC_FIELDNAME" => $fieldName); } else { $aFields = array("APP_UID" => $_SESSION["APPLICATION"], "DEL_INDEX" => $_SESSION["INDEX"], "USR_UID" => $_SESSION["USER_LOGGED"], "DOC_UID" => -1, "APP_DOC_TYPE" => "ATTACHED", "APP_DOC_CREATE_DATE" => date("Y-m-d H:i:s"), "APP_DOC_COMMENT" => "", "APP_DOC_TITLE" => "", "APP_DOC_FILENAME" => $arrayFileName[$i], "APP_DOC_FIELDNAME" => $fieldName); } $oAppDocument = new AppDocument(); $oAppDocument->create($aFields); $iDocVersion = $oAppDocument->getDocVersion(); $sAppDocUid = $oAppDocument->getAppDocUid(); $aInfo = pathinfo($oAppDocument->getAppDocFilename()); $sExtension = isset($aInfo["extension"]) ? $aInfo["extension"] : ""; $pathUID = G::getPathFromUID($_SESSION["APPLICATION"]); $sPathName = PATH_DOCUMENT . $pathUID . PATH_SEP; // . $documentFileStructure; $sFileName = $sAppDocUid . "_" . $iDocVersion . "." . $sExtension; G::uploadFile($arrayFileTmpName[$i], $sPathName, $sFileName); //Plugin Hook PM_UPLOAD_DOCUMENT for upload document $oPluginRegistry =& PMPluginRegistry::getSingleton(); if ($oPluginRegistry->existsTrigger(PM_UPLOAD_DOCUMENT) && class_exists("uploadDocumentData")) { $triggerDetail = $oPluginRegistry->getTriggerInfo(PM_UPLOAD_DOCUMENT); $documentData = new uploadDocumentData($_SESSION["APPLICATION"], $_SESSION["USER_LOGGED"], $sPathName . $sFileName, $aFields["APP_DOC_FILENAME"], $sAppDocUid, $iDocVersion); $uploadReturn = $oPluginRegistry->executeTriggers(PM_UPLOAD_DOCUMENT, $documentData); if ($uploadReturn) { $aFields["APP_DOC_PLUGIN"] = $triggerDetail->sNamespace; if (!isset($aFields["APP_DOC_UID"])) { $aFields["APP_DOC_UID"] = $sAppDocUid; } if (!isset($aFields["DOC_VERSION"])) { $aFields["DOC_VERSION"] = $iDocVersion; } $oAppDocument->update($aFields);
<img src='/images/processmaker.logo.jpg' border='0'/><br> <font color='#848484'>".G::LoadTranslation('ID_RESTORE_LOGO')."</font> </a></td></tr>"; $template->assign ('SET_LOGO_PM' ,$restoreLogo); }*/ if (sizeof($_POST) > 0) { //G::SendTemporalMessage('ID_CHANGES_SAVED', 'info', 'labels'); $formf = $_FILES['form']; $namefile = $formf['name']['LOGO_FILENAME']; $typefile = $formf['type']['LOGO_FILENAME']; $errorfile = $formf['error']['LOGO_FILENAME']; $tpnfile = $formf['tmp_name']['LOGO_FILENAME']; $aMessage1 = array(); $fileName = trim(str_replace(' ', '_', $namefile)); $fileName = changeNamelogo($fileName); G::uploadFile($tpnfile, $dir . '/', 'tmp' . $fileName); $error = false; try { G::resizeImage($dir . '/tmp' . $fileName, 250, 60, $dir . '/' . $fileName); } catch (Exception $e) { $error = $e->getMessage(); } unlink($dir . '/tmp' . $fileName); if ($error === false) { header('location: uplogo.php'); } else { G::SendTemporalMessage($error, 'error', 'string'); } } $content = $template->getOutputContent(); print $content;
$addon = null; } $result = array(); switch (strtolower($action)) { case "importlicense": if (sizeof($_FILES) > 0) { $aInfoLoadFile = $_FILES["upLicense"]; $aExtentionFile = explode(".", $aInfoLoadFile["name"]); //validating the extention before to upload it if (trim($aExtentionFile[sizeof($aExtentionFile) - 1]) != "dat") { //G::SendTemporalMessage("ID_ISNT_LICENSE", "tmp-info", "labels"); $result["errors"] = "Filename does not end with .dat"; $result["success"] = false; } else { $dir = PATH_DATA_SITE; G::uploadFile($aInfoLoadFile["tmp_name"], $dir, $aInfoLoadFile["name"]); //reading the file that was uploaded $oPmLicenseManager =& pmLicenseManager::getSingleton(); $response = $oPmLicenseManager->installLicense($dir . $aInfoLoadFile["name"]); /////// //This command also find the following file "AddonsStore.php" $licenseManager =& pmLicenseManager::getSingleton(); preg_match("/^license_(.*).dat\$/", $licenseManager->file, $matches); $realId = urlencode($matches[1]); $workspace = isset($licenseManager->workspace) ? $licenseManager->workspace : 'pmLicenseSrv'; $addonLocation = "http://{$licenseManager->server}/sys" . $workspace . "/en/green/services/addonsStore?action=getInfo&licId={$realId}"; /////// $cnn = Propel::getConnection("workflow"); $oCriteriaSelect = new Criteria("workflow"); $oCriteriaSelect->add(AddonsStorePeer::STORE_ID, $licenseManager->id); $oCriteriaUpdate = new Criteria("workflow");
/** * Upload image User * * @param string $userUid Unique id of User * */ public function uploadImage($userUid) { try { //Verify data $this->throwExceptionIfNotExistsUser($userUid, $this->arrayFieldNameForException["usrUid"]); if (!$_FILES) { throw new \Exception(\G::LoadTranslation("ID_UPLOAD_ERR_NO_FILE")); } if (!isset($_FILES["USR_PHOTO"])) { throw new \Exception(\G::LoadTranslation("ID_UNDEFINED_VALUE_IS_REQUIRED", array($this->arrayFieldNameForException["usrPhoto"]))); } if ($_FILES['USR_PHOTO']['error'] != 1) { if ($_FILES['USR_PHOTO']['tmp_name'] != '') { $aAux = explode('.', $_FILES['USR_PHOTO']['name']); \G::uploadFile($_FILES['USR_PHOTO']['tmp_name'], PATH_IMAGES_ENVIRONMENT_USERS, $userUid . '.' . $aAux[1]); \G::resizeImage(PATH_IMAGES_ENVIRONMENT_USERS . $userUid . '.' . $aAux[1], 96, 96, PATH_IMAGES_ENVIRONMENT_USERS . $userUid . '.gif'); } } else { $result->success = false; $result->fileError = true; throw (new \Exception($result)); } } catch (\Exception $e) { throw $e; } }
function importSkin() { try { if (!isset($_FILES['uploadedFile'])) { throw new Exception(G::LoadTranslation('ID_SKIN_FILE_REQUIRED')); } $uploadedInstances = count($_FILES['uploadedFile']['name']); $sw_error = false; $sw_error_exists = isset($_FILES['uploadedFile']['error']); $emptyInstances = 0; $quequeUpload = array(); // upload files & check for errors $tmp = $_FILES['uploadedFile']['tmp_name']; $items = stripslashes($_FILES['uploadedFile']['name']); if ($sw_error_exists) { $up_err = $_FILES['uploadedFile']['error']; } else { $up_err = file_exists($tmp) ? 0 : 4; } if ($items == "" || $up_err == 4) { throw new Exception(G::LoadTranslation('ID_SKIN_FILE_REQUIRED')); } if ($up_err == 1 || $up_err == 2) { throw new Exception(G::LoadTranslation('ID_FILE_TOO_BIG')); //$errors[$i]='miscfilesize'; } if ($up_err == 3) { throw new Exception(G::LoadTranslation('ID_ERROR_UPLOAD_FILE_CONTACT_ADMINISTRATOR')); //$errors[$i]='miscfilepart'; } if (!@is_uploaded_file($tmp)) { throw new Exception(G::LoadTranslation('ID_ERROR_UPLOAD_FILE_CONTACT_ADMINISTRATOR')); //$errors[$i]='uploadfile'; } $fileInfo = pathinfo($items); $validType = array('tar', 'gz'); if (!in_array($fileInfo['extension'], $validType)) { throw new Exception(G::LoadTranslation('ID_FILE_UPLOAD_INCORRECT_EXTENSION')); //$errors[$i]='wrongtype'; } $filename = $items; $tempPath = PATH_CUSTOM_SKINS . '.tmp' . PATH_SEP; G::verifyPath($tempPath, true); $tempName = $tmp; G::uploadFile($tempName, $tempPath, $filename); G::LoadThirdParty('pear/Archive', 'Tar'); $tar = new Archive_Tar($tempPath . $filename); $aFiles = $tar->listContent(); $swConfigFile = false; foreach ($aFiles as $key => $val) { if (basename($val['filename']) == 'config.xml') { $skinName = dirname($val['filename']); $skinArray = explode("/", $skinName); if (count($skinArray) == 1) { $swConfigFile = true; } } } if (!$swConfigFile) { @unlink(PATH_CUSTOM_SKINS . '.tmp' . PATH_SEP . $filename); throw new Exception(G::LoadTranslation('ID_SKIN_CONFIGURATION_MISSING')); } if (is_dir(PATH_CUSTOM_SKINS . $skinName)) { if (isset($_REQUEST['overwrite_files']) && $_REQUEST['overwrite_files'] == 'on') { G::rm_dir(PATH_CUSTOM_SKINS . $skinName, false); } else { throw new Exception(G::LoadTranslation('ID_SKIN_ALREADY_EXISTS')); } } $res = $tar->extract(PATH_CUSTOM_SKINS); if (!$res) { throw new Exception(G::LoadTranslation('ID_SKIN_ERROR_EXTRACTING')); } $configFileOriginal = PATH_CUSTOM_SKINS . $skinName . PATH_SEP . 'config.xml'; $configFileFinal = PATH_CUSTOM_SKINS . $skinName . PATH_SEP . 'config.xml'; $xmlConfiguration = file_get_contents($configFileOriginal); $workspace = $_REQUEST['workspace'] == 'global' ? '' : SYS_SYS; $xmlConfigurationObj = G::xmlParser($xmlConfiguration); $skinInformationArray = $xmlConfigurationObj->result["skinConfiguration"]["__CONTENT__"]["information"]["__CONTENT__"]; if (isset($skinInformationArray["workspace"]["__VALUE__"])) { $workspace = $workspace != "" && !empty($skinInformationArray["workspace"]["__VALUE__"]) ? $skinInformationArray["workspace"]["__VALUE__"] . "|" . $workspace : $workspace; $xmlConfiguration = preg_replace("/(<workspace>)(.*)(<\\/workspace>)/i", "<workspace>" . $workspace . "</workspace><!-- \$2 -->", $xmlConfiguration); } else { $xmlConfiguration = preg_replace("/(<name>)(.*)(<\\/name>)/i", "<name>" . $skinName . "</name><!-- \$2 -->\n<workspace>" . $workspace . "</workspace>", $xmlConfiguration); } file_put_contents($configFileFinal, $xmlConfiguration); //Delete Temporal @unlink(PATH_CUSTOM_SKINS . '.tmp' . PATH_SEP . $filename); $response['success'] = true; $response['message'] = G::LoadTranslation('ID_SKIN_SUCCESSFUL_IMPORTED'); G::auditLog("ImportSkin", "Skin Name: " . $skinName); print_r(G::json_encode($response)); } catch (Exception $e) { $response['success'] = false; $response['message'] = $e->getMessage(); $response['error'] = $e->getMessage(); print_r(G::json_encode($response)); } }
$sExtension = strtoupper($aPhotoFile[sizeof($aPhotoFile) - 1]); if (strlen($sPhotoFile) > 0 && !in_array($sExtension, $aExtensions)) { throw new Exception(G::LoadTranslation('ID_ERROR_UPLOADING_IMAGE_TYPE')); } if ($_FILES['form']['error']['USR_PHOTO'] != 1) { if ($_FILES['form']['tmp_name']['USR_PHOTO'] != '') { $aAux = explode('.', $_FILES['form']['name']['USR_PHOTO']); G::uploadFile($_FILES['form']['tmp_name']['USR_PHOTO'], PATH_IMAGES_ENVIRONMENT_USERS, $aData['USR_UID'] . '.' . $aAux[1]); G::resizeImage(PATH_IMAGES_ENVIRONMENT_USERS . $aData['USR_UID'] . '.' . $aAux[1], 96, 96, PATH_IMAGES_ENVIRONMENT_USERS . $aData['USR_UID'] . '.gif'); } } else { G::SendTemporalMessage('ID_FILE_TOO_BIG', 'error'); } if ($_FILES['form']['error']['USR_RESUME'] != 1) { if ($_FILES['form']['tmp_name']['USR_RESUME'] != '') { G::uploadFile($_FILES['form']['tmp_name']['USR_RESUME'], PATH_IMAGES_ENVIRONMENT_FILES . $aData['USR_UID'] . '/', $_FILES['form']['name']['USR_RESUME']); } } else { G::SendTemporalMessage('ID_FILE_TOO_BIG', 'error'); } } if ($_SESSION['USER_LOGGED'] == $form['USR_UID']) { /*UPDATING SESSION VARIABLES*/ $aUser = $RBAC->userObj->load($_SESSION['USER_LOGGED']); $_SESSION['USR_FULLNAME'] = $aUser['USR_FIRSTNAME'] . ' ' . $aUser['USR_LASTNAME']; } //Save Calendar assigment if (isset($form['USR_CALENDAR'])) { //Save Calendar ID for this user G::LoadClass("calendar"); $calendarObj = new Calendar();
if (isset($form['USR_ROLE'])) { $aData['USR_ROLE'] = $form['USR_ROLE']; } if (isset($form['USR_REPLACED_BY'])) { $aData['USR_REPLACED_BY'] = $form['USR_REPLACED_BY']; } if (isset($form['USR_AUTH_USER_DN'])) { $aData['USR_AUTH_USER_DN'] = $form['USR_AUTH_USER_DN']; } require_once 'classes/model/Users.php'; $oUser = new Users(); $oUser->update($aData); if ($_FILES['USR_PHOTO']['error'] != 1) { if ($_FILES['USR_PHOTO']['tmp_name'] != '') { $aAux = explode('.', $_FILES['USR_PHOTO']['name']); G::uploadFile($_FILES['USR_PHOTO']['tmp_name'], PATH_IMAGES_ENVIRONMENT_USERS, $aData['USR_UID'] . '.' . $aAux[1]); G::resizeImage(PATH_IMAGES_ENVIRONMENT_USERS . $aData['USR_UID'] . '.' . $aAux[1], 96, 96, PATH_IMAGES_ENVIRONMENT_USERS . $aData['USR_UID'] . '.gif'); } } else { $result->success = false; $result->fileError = true; print G::json_encode($result); die; } /* if ($_FILES['USR_RESUME']['error'] != 1) { if ($_FILES['USR_RESUME']['tmp_name'] != '') { G::uploadFile($_FILES['USR_RESUME']['tmp_name'], PATH_IMAGES_ENVIRONMENT_FILES . $aData['USR_UID'] . '/', $_FILES['USR_RESUME']['name']); } } else {
function importSkin() { try { if (!isset($_FILES['uploadedFile'])) { throw new Exception(G::LoadTranslation('ID_SKIN_FILE_REQUIRED')); } $uploadedInstances = count($_FILES['uploadedFile']['name']); $sw_error = false; $sw_error_exists = isset($_FILES['uploadedFile']['error']); $emptyInstances = 0; $quequeUpload = array(); // upload files & check for errors $tmp = $_FILES['uploadedFile']['tmp_name']; $items = stripslashes($_FILES['uploadedFile']['name']); if ($sw_error_exists) { $up_err = $_FILES['uploadedFile']['error']; } else { $up_err = file_exists($tmp) ? 0 : 4; } if ($items == "" || $up_err == 4) { throw new Exception(G::LoadTranslation('ID_SKIN_FILE_REQUIRED')); } if ($up_err == 1 || $up_err == 2) { throw new Exception(G::LoadTranslation('ID_FILE_TOO_BIG')); //$errors[$i]='miscfilesize'; } if ($up_err == 3) { throw new Exception(G::LoadTranslation('ID_ERROR_UPLOAD_FILE_CONTACT_ADMINISTRATOR')); //$errors[$i]='miscfilepart'; } if (!@is_uploaded_file($tmp)) { throw new Exception(G::LoadTranslation('ID_ERROR_UPLOAD_FILE_CONTACT_ADMINISTRATOR')); //$errors[$i]='uploadfile'; } $fileInfo = pathinfo($items); $validType = array('tar', 'gz'); if (!in_array($fileInfo['extension'], $validType)) { throw new Exception(G::LoadTranslation('ID_FILE_UPLOAD_INCORRECT_EXTENSION')); //$errors[$i]='wrongtype'; } $filename = $items; $tempPath = PATH_CUSTOM_SKINS . '.tmp' . PATH_SEP; G::verifyPath($tempPath, true); $tempName = $tmp; G::uploadFile($tempName, $tempPath, $filename); G::LoadThirdParty('pear/Archive', 'Tar'); $tar = new Archive_Tar($tempPath . $filename); $aFiles = $tar->listContent(); $swConfigFile = false; foreach ($aFiles as $key => $val) { if (basename($val['filename']) == 'config.xml') { $skinName = dirname($val['filename']); $skinArray = explode("/", $skinName); if (count($skinArray) == 1) { $swConfigFile = true; } } } if (!$swConfigFile) { @unlink(PATH_CUSTOM_SKINS . '.tmp' . PATH_SEP . $filename); throw new Exception(G::LoadTranslation('ID_SKIN_CONFIGURATION_MISSING')); } if (is_dir(PATH_CUSTOM_SKINS . $skinName)) { if (isset($_REQUEST['overwrite_files']) && $_REQUEST['overwrite_files'] == 'on') { G::rm_dir(PATH_CUSTOM_SKINS . $skinName, false); } else { throw new Exception(G::LoadTranslation('ID_SKIN_ALREADY_EXISTS')); } } $res = $tar->extract(PATH_CUSTOM_SKINS); if (!$res) { throw new Exception(G::LoadTranslation('ID_SKIN_ERROR_EXTRACTING')); } //Delete Temporal @unlink(PATH_CUSTOM_SKINS . '.tmp' . PATH_SEP . $filename); $response['success'] = true; $response['message'] = G::LoadTranslation('ID_SKIN_SUCCESSFUL_IMPORTED'); print_r(G::json_encode($response)); } catch (Exception $e) { $response['success'] = false; $response['message'] = $e->getMessage(); $response['error'] = $e->getMessage(); print_r(G::json_encode($response)); } }