session_start(); require_once '../_librerias/php/funciones.php'; require_once '../_librerias/php/UploadService.php'; $token = post("token"); $prepare = post("PREPARE_UPLOAD"); $configSession = $_SESSION[$token]; //create a Upload Service //create constraints $constraints = new UploadService_Config_Constraints(); $constraints->setMaxSize($configSession["constraints"]["maxSize"]); $constraints->setExtensions($configSession["constraints"]["extensions"]); //create configs $config = new UploadService_Config(); $config->setToserver($configSession["toserver"]); $config->setPath($configSession["path"]); $config->setVideoPlatform($configSession["videoPlatform"]); $config->setConstraints($constraints); $upload = new UploadService(); $upload->setConfig($config); $fileResource = $upload->file; //$fileResource = new UploadService_File_Resource(); $response = null; if ($prepare) { $file = new UploadService_File(); $file->setName(post("name")); $file->setSize(post("size")); $response = $fileResource->prepare($file); } else { $response = $fileResource->put(); } echo json_encode($response);
function c_No_form_adp($titulo, $conexionA, $formC, $class, $path, $uRLForm, $codForm, $selectDinamico, $key) { $sql = 'SELECT Codigo,Tabla, Descripcion FROM sys_form WHERE Estado = "Activo" AND Codigo = "' . $formC . '" '; $rg = fetch($sql); $codigo = $rg["Codigo"]; $form = $rg["Descripcion"]; $tabla = $rg["Tabla"]; if ($codForm != "") { $form = $rg["Descripcion"] . "-UPD"; $idDiferenciador = "-UPD"; $sql = 'SELECT * FROM ' . $tabla . ' WHERE ' . $key . ' = ' . $codForm . ' '; $rg2 = fetch($sql); } else { $formNP = $formC; } $vSQL = 'SELECT * FROM sys_form_det WHERE Form = "' . $codigo . '" ORDER BY Posicion '; $consulta = mysql_query($vSQL, $conexionA); $resultadoB = $consulta or die(mysql_error()); $v = "<div class='panelCerrado' id='PanelForm-Oculto'></div>"; $v .= "<div class='panel-Abierto' style='width:100%;height:100%;float:left;padding:0px 10px;' id='PanelForm'>"; #$v .= "<form method='post' name='" . $form . "' id='" . $form . "' class='" . $class . "' action='javascript:void(null);' enctype='multipart/form-data'>"; $v .= "<ul>"; if ($titulo != "") { $v .= "<h1>" . $titulo . "</h1>"; $v .= "<div class='linea'></div>"; } $v .= "<div id='panelMsg'></div>"; $MatrisUrl = explode("}", $uRLForm); $atributoBotonUrl = explode("]", $MatrisUrl[0]); $UrlPrimerBtn = $atributoBotonUrl[1]; $CadenaValidacion = ""; $Contador = 0; while ($registro = mysql_fetch_array($resultadoB)) { $ContadorTabIndex += 1; $nameC = $registro['NombreCampo']; $WidthHeight = $registro['TamanoCampo']; $CmpX = explode("]", $WidthHeight); $vSizeLi = $CmpX[0] + 40; $TipoInput = $registro['TipoInput']; $Validacion = $registro['Validacion']; //Vacio | NO | SI if (!empty($Validacion)) { $CadenaValidacion .= "CmpValidacion--" . $nameC . ","; } if ($registro['TipoOuput'] == "text") { if ($registro['Visible'] != "NO") { if ($registro['TablaReferencia'] == "AutoCompletado") { # W(" formNP ".$formNP); $v .= InputAutocompletadoA($selectDinamico, $registro, $selectD, $rg2, $nameC, $vSizeLi, $UrlPrimerBtn, $formNP, $Validacion, $conexionA); } else { $v .= "<li style='width:" . $vSizeLi . "px;position:relative;' >"; $v .= "<div id='CmpValidacion--" . $registro['NombreCampo'] . "' class='PanelAlerta' style='position:absolute;' ></div>"; $v .= "<label>" . $registro['Alias'] . "</label>"; $v .= "<div style='position:relative;float:left;100%;' >"; $v .= InputTextA($registro, $Validacion, $UrlPrimerBtn, $formC, $nameC, $idDiferenciador, $formC, $rg2); $v .= IconoInputText($idDiferenciador, $nameC, $registro, $formC); $v .= "</div>"; $v .= "</li>"; if ($registro['TablaReferencia'] == "search") { $v .= InputReferenciaA($selectDinamico, $registro, $rg2, $conexionA, $formC, $nameC); } } } } elseif ($registro['TipoOuput'] == "select") { if ($registro['Visible'] != "NO") { $v .= "<li style='width:" . $vSizeLi . "px;position:relative;'>"; $v .= "<div id='CmpValidacion--" . $registro['NombreCampo'] . "' class='PanelAlerta' style='position:absolute;' ></div>"; $v .= "<label>" . $registro['Alias'] . "</label>"; if ($registro['TablaReferencia'] == "Fijo") { $v .= SelectFijo($registro, $TipoInput, $Validacion, $rg2, $nameC); } elseif ($registro['TablaReferencia'] == "Dinamico") { $v .= SelectDinamicoA($selectDinamico, $Validacion, $UrlPrimerBtn, $formNP, $registro, $TipoInput, $Validacion, $conexionA, $rg2, $nameC); } elseif ($registro['TablaReferencia'] == "Anidado") { $v .= SelectAnidadoA($selectDinamico, $registro, $TipoInput, $Validacion, $conexionA, $rg2, $nameC); } else { $v .= CierraSelectA($registro, $conexionA); } $v .= "</li>"; } } elseif ($registro['TipoOuput'] == "radio") { $OpcionesValue = $registro['OpcionesValue']; $MatrisOpcion = explode("}", $OpcionesValue); $NombreCmp = $rg2[$nameC]; $v .= "<li style='width:" . $vSizeLi . "px;'>"; $v .= "<div style='width:100%;float:left;'>"; $v .= "<label>" . $registro['Alias'] . " cmp " . $NombreCmp . "</label>"; $v .= "</div>"; $v .= "<div class='cont-inpt-radio'>"; for ($i = 0; $i < count($MatrisOpcion); $i++) { $MatrisOp = explode("]", $MatrisOpcion[$i]); $v .= "<div style='width:50%;float:left;' >"; $v .= "<div class='lbRadio'>" . $MatrisOp[0] . "</div> "; if ($NombreCmp == $MatrisOp[1]) { $v .= "<input type ='" . $registro['TipoOuput'] . "' name ='" . $registro['NombreCampo'] . "' id ='" . $MatrisOp[1] . "' value ='" . $MatrisOp[1] . "' data-valida='" . $Validacion . "' checked />"; } else { $v .= "<input type ='" . $registro['TipoOuput'] . "' name ='" . $registro['NombreCampo'] . "' id ='" . $MatrisOp[1] . "' value ='" . $MatrisOp[1] . "' data-valida='" . $Validacion . "' />"; } $v .= "</div>"; } $v .= "</div>"; $v .= "</li>"; } elseif ($registro['TipoOuput'] == "textarea") { $widthLi = $CmpX[0] + 30; $v .= "<li style='width:" . $vSizeLi . "px; position: relative;'>"; $v .= "<label >" . $registro['Alias'] . "</label>"; $v .= "<textarea name='" . $registro['NombreCampo'] . "' style='display:none;' data-valida='" . $Validacion . "'></textarea>"; $v .= "<div id='Pn-Op-Editor-Panel'>"; $v .= "<div onfocus=OWLEditor(this,'" . $registro['NombreCampo'] . "') contenteditable='true' id='" . $registro['NombreCampo'] . "-Edit' class= 'editor' style='width:100%;min-height:80px;' >" . $rg2[$nameC] . "</div>"; $v .= "<div class='CTAE_OWL_SUIT' id='CTAE_OWL_SUIT_" . $registro['NombreCampo'] . "'> Edicion... </div>"; # SUBIR IMAGES if ($path[$registro["NombreCampo"]]) { $MOpX = explode('}', $uRLForm); $MOpX2 = explode(']', $MOpX[0]); $tipos = explode(',', $registro['OpcionesValue']); foreach ($tipos as $key => $tipo) { $tipos[$key] = trim($tipo); } $inpuFileData = array('maxfile' => $registro['MaximoPeso'], 'tipos' => $tipos); $filedata = base64_encode(serialize($inpuFileData)); $label = array(); $label[] = "<strong>{$registro['Alias']}</strong>"; if (!empty($registro['AliasB'])) { $label[] = $registro['AliasB']; } if (!empty($registro['MaximoPeso'])) { $label[] = 'Peso Máximo ' . $registro['MaximoPeso'] . ' MB'; } if (!empty($tipos)) { $label[] = 'Formatos Soportados *.' . implode(', *.', $tipos); } $v .= "<div id='{$registro['NombreCampo']}_UIT' style='display:none;'>"; $v .= "<label >" . implode('<br>', $label) . "</label><div class='clean'></div>"; $v .= "<div class='content_upload' data-filedata='{$filedata}'>\n <div class='input-owl'>\n <input id='{$registro['NombreCampo']}' multiple onchange=uploadUIT('{$registro['NombreCampo']}','{$MOpX2[1]}&TipoDato=archivo','{$path[$registro['NombreCampo']]}','{$form}','{$registro["NombreCampo"]}'); type='file' title='Elegir un Archivo'>\n <input id='{$registro['NombreCampo']}-id' type='hidden'>\n </div>\n <div class='clean'></div>\n <div id='msg_upload_owl'>\n <div id='det_upload_owl' class='det_upload_owl'>\n <div id='speed'>Subiendo archivos...</div>\n <div id='remaining'>Calculando...</div>\n </div>\n <div id='progress_bar_content' class='progress_bar_owl'>\n <div id='progress_percent'></div>\n <div id='progress_owl'></div>\n <div class='clean'></div>\n </div>\n <div id='det_bupload_owl' class='det_upload_owl'>\n <div id='b_transfered'></div>\n <div id='upload_response'></div>\n </div>\n </div>\n <input type='hidden' name='{$registro['NombreCampo']}_response_array' id='upload_input_response'>\n </div>"; $v .= "</div>"; } # SUBIR IMAGES $v .= "</div>"; $v .= "</li>"; } elseif ($registro['TipoOuput'] == "texarea_n") { $widthLi = $CmpX[0] + 30; $v .= "<li style='width:" . $widthLi . "px; position: relative;'>"; $v .= "<label >" . $registro['Alias'] . "</label>"; $v .= "<div id='CmpValidacion--" . $registro['NombreCampo'] . "' class='PanelAlerta' style='position:absolute;' ></div>"; $v .= "<div style='position:relative;float:left;100%;' >"; $v .= "<textarea onblur=ValidaCampos('{$Validacion}','{$UrlPrimerBtn}','{$formNP}','" . $registro['NombreCampo'] . "');\n\t\t\t\tid='" . $nameC . "' name='" . $registro['NombreCampo'] . "'\n\t\t\t\tstyle='width:" . $CmpX[0] . "px;min-height:60px;height:" . $CmpX[1] . "px' data-valida='" . $Validacion . "'>" . $rg2[$nameC] . "</textarea>"; $v .= "</div>"; $v .= "</li>"; } elseif ($registro['TipoOuput'] == "password") { $v .= "<li style='width:" . $vSizeLi . "px;position:relative;' >"; $v .= "<label>" . $registro['Alias'] . "</label>"; $v .= "<div id='CmpValidacion--" . $registro['NombreCampo'] . "' class='PanelAlerta' style='position:absolute;' ></div>"; $v .= "<input onblur=ValidaCampos('{$Validacion}','{$UrlPrimerBtn}','{$formNP}','" . $registro['NombreCampo'] . "'); type='" . $registro['TipoOuput'] . "' name='" . $nameC . "' "; $v .= " value ='" . $rg2[$nameC] . "' "; $v .= " id='" . $nameC . "' "; $v .= " style='width:" . $registro['TamanoCampo'] . "px;' />"; $v .= "</li>"; } elseif ($registro['TipoOuput'] == "checkbox") { $v .= "<li style='width:" . $vSizeLi . "px;'>"; $v .= "<label >" . $registro['Alias'] . "</label>"; if ($rg2[$nameC] == !"") { $v .= "<input type='" . $registro['TipoOuput'] . "' name='" . $registro['NombreCampo'] . "' value='" . $registro['OpcionesValue'] . "' data-valida='" . $Validacion . "' checked />"; } else { $v .= "<input type='" . $registro['TipoOuput'] . "' name='" . $registro['NombreCampo'] . "' value='" . $registro['OpcionesValue'] . "' data-valida='" . $Validacion . "' />"; } $v .= "</li>"; } elseif ($registro['TipoOuput'] == "file") { $MOpX = explode("}", $uRLForm); $MOpX2 = explode("]", $MOpX[0]); $v .= "<li style='width:" . $vSizeLi . "px;'>"; $v .= "<label >" . $registro['AliasB'] . " , Peso Máximo " . $registro['MaximoPeso'] . " MB</label>"; $v .= "<div class='inp-file-Boton'>" . $registro['Alias']; $v .= "<input type='" . $registro['TipoOuput'] . "' name='" . $registro['NombreCampo'] . "' data-valida='" . $Validacion . "'\n id='" . $registro['NombreCampo'] . "'\n onchange=ImagenTemproral(event,'" . $registro['NombreCampo'] . "','" . $path["" . $registro['NombreCampo'] . ""] . "','" . $MOpX2[1] . "','" . $form . "'); />"; $v .= "</div>"; $v .= "<div id='" . $registro['NombreCampo'] . "' class='cont-img'>"; $v .= "<div id='" . $registro['NombreCampo'] . "-MS'></div>"; // $v .= "<BR>ENTRA : ".$rg2[$nameC]." </BR>"; if ($rg2[$nameC] != "") { $padX = explode("/", $rg2[$nameC]); $path2 = ""; $count = 0; for ($i = 0; $i < count($padX); $i++) { $count += 1; if (count($padX) == $count) { $separador = ""; } else { $separador = "/"; } if ($i == 0) { $archivo = "."; } else { $archivo = $padX[$i]; } $path2 .= $archivo . $separador; } $path_origin = str_replace("../", "", $path[$registro['NombreCampo']]); $path_origin = str_replace("//", "/", $path_origin); $path2B = $path_origin . $rg2[$nameC]; $pdf = validaExiCadena($path2B, ".pdf"); $doc = validaExiCadena($path2B, ".doc"); $docx = validaExiCadena($path2B, ".docx"); $S3_DOMAIN = getURLS3(); if ($pdf > 0) { $v .= "<ul style='width:100%;float:left;'><li style='float:left;width:20%;'><img src='./_imagenes/pdf.jpg' width='26px'></li><li style='float:left;width:70%;'>" . $rg2[$nameC] . "</li></ul>"; } elseif ($doc > 0 || $docx > 0) { $v .= "<ul style='width:100%;float:left;'><li style='float:left;width:20%;'><img src='./_imagenes/doc.jpg' width='26px'></li><li style='float:left;width:70%;'>" . $rg2[$nameC] . "</li></ul>"; } else { $v .= "<ul style='width:100%;float:left;'><li style='float:left;width:20%;'><img src='{$S3_DOMAIN}/{$path2B}' width='26px'></li><li style='float:left;width:70%;'>" . $rg2[$nameC] . "</li></ul>"; } } else { $v .= "<ul></ul>"; } $v .= "</div>\t"; $v .= "</li>"; } elseif ($registro['TipoOuput'] == 'upload-file') { $MOpX = explode('}', $uRLForm); $MOpX2 = explode(']', $MOpX[0]); $tipos = explode(',', $registro['OpcionesValue']); $maxSize = (int) $registro['MaximoPeso']; $extensions = array_map(function ($extension) { return trim($extension); }, $tipos); $cleandPath = file::cleanPath($path[$registro["NombreCampo"]]); $toServer = null; $videoPlatform = null; switch ($registro['destiny_upload']) { case "SERVER": $toServer = UploadService::TO_SERVER; break; case "BOTH": $toServer = UploadService::TO_BOTH; break; case "S3": default: $toServer = UploadService::TO_S3; break; } if ($registro["video_control"]) { switch ($registro['video_destiny_platform']) { case "VIDEO_SERVER": $videoPlatform = UploadService::VIDEO_PLATFORM_OWL; break; case "YOUTUBE": default: $videoPlatform = UploadService::VIDEO_PLATFORM_YOUTUBE; break; } } //create a Upload Service //create constraints $constraints = new UploadService_Config_Constraints(); $constraints->setMaxSize($maxSize); $constraints->setExtensions($extensions); //create configs $config = new UploadService_Config(); $config->setToserver($toServer); $config->setPath($cleandPath); $config->setVideoPlatform($videoPlatform); $config->setConstraints($constraints); $upload = new UploadService(); $upload->setConfig($config); $token = $upload->token->generate(); //save this in storage session $_SESSION[$token] = ["toserver" => $config->getToserver(), "path" => $config->getPath(), "videoPlatform" => $config->getVideoPlatform(), "constraints" => ["maxSize" => $constraints->getMaxSize(), "extensions" => $constraints->getExtensions()]]; $label = []; if (!empty($registro['AliasB'])) { array_push($label, $registro['AliasB']); } array_push($label, "Peso Máximo {$constraints->getMaxSize()} Megabytes"); if ($constraints->getExtensions()) { array_push($label, "Formatos Soportados *." . implode(', *.', $constraints->getExtensions())); } //See if exits past value $value = trim($rg2[$nameC]); $prefileStr = ""; if ($value) { $imageURI = null; if (file::isImage($value)) { switch ($config->getToserver()) { case UploadService::TO_S3: case UploadService::TO_BOTH: $imageURI = CONS_IPArchivos . "/{$cleandPath}/{$value}"; break; case UploadService::TO_SERVER: $imageURI = getDomain() . "/{$cleandPath}/{$value}"; break; } } $imageURI = $imageURI ? "'{$imageURI}'" : "null"; $prefileStr = "{ name: '{$value}', URI: {$imageURI}}"; } $label[] = "<strong>{$registro['Alias']}</strong>"; $v .= "<li style='width:" . $vSizeLi . "px;'>"; $v .= "<label>" . implode('<br>', $label) . "</label>"; $v .= "<div class='clear'></div>"; $v .= "\n <div id='{$registro['NombreCampo']}'></div>\n <script>\n var upload = new Upload({\n id : '#{$registro['NombreCampo']}',\n name : '{$registro['NombreCampo']}',\n token : '{$token}',\n preFiles: [{$prefileStr}],\n form : '{$form}'\n });\n\n upload.open();\n </script>\n "; $v .= "</li>"; } } $v .= "<li><input type='text' id='ContenedorValidacion" . $formNP . "' style='display:none;' >"; $v .= "<input type='text' id='ContenedorValidacion-Gen" . $formNP . "' value='" . $CadenaValidacion . "' style='display:none;'>"; $v .= "</li>"; $v .= "<li id='PanelBtn-" . $formC . "' >"; $MatrisOpX = explode("}", $uRLForm); for ($i = 0; $i < count($MatrisOpX) - 1; $i++) { $atributoBoton = explode("]", $MatrisOpX[$i]); $form = ereg_replace(" ", "", $form); $v .= "<div class='Botonera'>"; if ($atributoBoton[3] == "F") { $viewdata = array(); $viewdata['sUrl'] = $atributoBoton[1]; $viewdata['formid'] = $form; $viewdata['sDivCon'] = $atributoBoton[2]; $viewdata['sIdCierra'] = $atributoBoton[4]; $v .= "<button onclick=enviaFormS('" . json_encode($viewdata) . "'); class='" . $atributoBoton[5] . "' >" . $atributoBoton[0] . "</button>"; } elseif ($atributoBoton[3] == "JSB") { $v .= "<button onclick=" . $atributoBoton[2] . " class='" . $atributoBoton[5] . "' >" . $atributoBoton[0] . "</button>"; } elseif ($atributoBoton[3] == "JSBF") { $ParametrosInput = explode("|", $atributoBoton[4]); $viewdata = array(); $viewdata['sUrl'] = $atributoBoton[1]; $viewdata['formid'] = $form; $viewdata['sDivCon'] = $atributoBoton[2]; $viewdata['sIdCierra'] = ""; $viewdata['ParametrosInput'] = $ParametrosInput; $viewdata['UrlPrimerBtn'] = $UrlPrimerBtn; $v .= "<button onclick=enviaFormS('" . json_encode($viewdata) . "'); class='" . $atributoBoton[5] . "' >" . $atributoBoton[0] . "</button>"; } elseif ($atributoBoton[3] == "JS") { $functionJS = $atributoBoton[4]; $v .= "<button onclick=enviaFormNA('{$atributoBoton[1]}','{$form}','{$atributoBoton[2]}','');{$functionJS} id='{$formC}_Boton_{$i}' class='{$atributoBoton[5]}'>{$atributoBoton[0]}</button>"; } else { $v .= "<button onclick=enviaReg('" . $form . "','" . $atributoBoton[1] . "','" . $atributoBoton[2] . "','" . $atributoBoton[4] . "'); class='" . $atributoBoton[5] . "' >" . $atributoBoton[0] . "</button>"; } $v .= "</div>"; } $v .= "</li>"; $v .= "</ul>"; # $v .= "</form>"; $v .= "</div>"; return $v; }