1
0
forked from qwerty/milfs

Organizando el directorio de MILFS para poderlo convertir en un submodulo

This commit is contained in:
kleper 2018-07-01 17:21:48 -05:00
parent d392b54f61
commit d2945ffc5a
533 changed files with 107902 additions and 14928 deletions

103
API.md
View File

@ -1,103 +0,0 @@
# API de MILFS
El api consulta a nivel local todos los datos si se ha logueado en el
sistema a nivel remoto o sin logueo los datos de los formularios que
se han marcado como de contenido publico.
http://localhost/milfs/api.php
Consulta cuales formularios hay en la instancia.
http://localhost/milfs/api.php?id=3
Consulta todo el contenido que se ha introducido en un formulario
pasándole el id como parametro.
http://localhost/milfs/api.php?identificador=04718326a4922f93d9f7b5f6f682d111
Para que se muestren las imagenes por medio de la api.php en las versiones antes del 20150218
se debe hacer la siguiente entrada en el mysql
INSERT INTO `form_campos` (`id`, `id_especialista`, `id_empresa`, `campo_nombre`, `campo_descripcion`, `campo_tipo`, `campo_area`, `orden`, `activo`, `identificador`, `bloqueo`, `tipo_contenido`) VALUES
(0, 0, 1, 'imagen', 'Campo especial para la imagen', 15, 0, 0, 1, 'imagen', 0, '');
Consulta todos los datos que se han llenado en cada formulario pasando
el identificador como parametro, cabe anotar que cuando se edita un
formulario se guarda la versión anterior de este campo por lo que si
se quiere conocer el estado actual de un formulario que ha sido
editado, debería filtrarse por timestamp para conocer su ultima
versión o vesiones anteriores.
http://datos.labmde.org/api.php?dato=52772
Consulta la info sobre un dato en concreto pasando el id del dato
como parametro.
Para entender el manejo de la api se debe tener en cuenta lo siguiente:
Cuando se crea un formulario MILF le asigna un ID unico a cada formulario que aparece en el JSON como: "form_id": pero esto solo es util si se quiere hacer referencia al fomulario especifico llamando la API sin ningun parametro, asi:
http://datos.labmde.org/api.php
Si se quiere leer los datos en un formulario especifico la api se llama de la siguiente forma:
http://datos.labmde.org/api.php?id=19
De esta forma la API nos entrega todos los datos, para hacer ejercicios de visualizacion de datos lo recomendable es utilizar los ID de los campos, especificado en el JSON asi: "id_campo"
Cada campo asociado a un formulario se le asigna un ID unico.
# Manejo de Imagenes
Milf permite almacenar imagenes para los formularios, las imagenes quedan almacenadas en el sistema de archivos del servidor, y genera de forma automatica 3 tamaños (150px 300px y 600px) y tambien almacena la imagen en el tamaño original.
Lo siguiente es un ejemplo de como la **API** entrega un dato tipo **IMAGEN**:
~~~
{
"0": 53326,
"id_dato": 53326,
"1": 21,
"id_formulario": 21,
"2": "Viaje a pie",
"formulario": "Viaje a pie",
"3": "imagen",
"campo_nombre": "imagen",
"4": 0,
"id_campo": 0,
"5": "7b2deb5cb4580984c8acd71c09e0f1f1.jpg",
"contenido": "7b2deb5cb4580984c8acd71c09e0f1f1.jpg",
"6": 1432608321,
"timestamp": 1432608321,
"7": "4b0d9a636567465bed3ada5a2e6f2fa6",
"identificador": "4b0d9a636567465bed3ada5a2e6f2fa6",
"8": 0,
"orden": 0
},
~~~
Ahora para usar la imagen se debe completar la URL, como se ve en los siguientes ejemplos:
**Para usar la imagen de 600px**
http://datos.labmde.org/milfs/images/secure/?file=600/7b2deb5cb4580984c8acd71c09e0f1f1.jpg
**Para usar la imagen de 300px**
http://datos.labmde.org/milfs/images/secure/?file=300/7b2deb5cb4580984c8acd71c09e0f1f1.jpg
**Para usar la imagen de 150px**
http://datos.labmde.org/milfs/images/secure/?file=150/7b2deb5cb4580984c8acd71c09e0f1f1.jpg
**Para usar la imagen FULL o Original**
http://datos.labmde.org/milfs/images/secure/?file=full/7b2deb5cb4580984c8acd71c09e0f1f1.jpg
**Nota:** Es importante que observe que el JSON entrega el dato de la siguiente forma:
~~~
"5": "7b2deb5cb4580984c8acd71c09e0f1f1.jpg",
~~~
Cada imagen queda codificada de la siguiente forma: 7b2deb5cb4580984c8acd71c09e0f1f1.jpg que sera el nombre de la imagen asignada por el sistema.

View File

@ -0,0 +1,510 @@
<?php
//include("funciones/funciones.php");
$id_formulario = "58";
$ancho = "500";
$tags = array();
$tags[] = "milfs/addon/logis/images/logos/c.png";
foreach ($tags as &$valor) {
$imagen .= "<td onclick=\" document.getElementById('marca').src='$valor' ; marcar('top-left') \" ><a href='#medio' class='' >
<img class='img ' src='$valor'>
</a></td>";
}
$imagen = "
<div class='table-responsive'>
<table class='table table table-condensed text-center '>
<tr >
$imagen
</tr>
</table>
</div>";
?>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js"></script>
<div>
<style type="text/css">
.fa{
font-size:60px important!;
}
#imagen_origina{
width: <?echo $ancho ?>px;
}
body{
background-color:white !important;
}
.pin {
text-align: center;
/*border: solid 1px red;*/
opacity: 0.5;
}
.fileUpload {
position: relative;
overflow: hidden;
margin: 10px;
width: 80%;
}
.fileUpload input.upload {
position: absolute;
top: 0;
right: 0;
margin: 10;
padding: 0;
font-size: 50px;
cursor: pointer;
opacity: 0;
filter: alpha(opacity=0);
}
.ing-touch{
border: solid 1px red;
width:20% !important;
}
</style>
<div class='container' style='backgroun-color:white;' >
<div class='fileUpload btn btn-primary center-block'>
<span><h1><i class="fa fa-camera"></i></h1></span>
<input class='upload' type="file" id="file-input" /></span>
<div id="original" ></div>
</div>
<!-- <p><input type="file" id="file-input"></p> -->
<div id="actions" style="display:none;">
<img class="center-block" src= "<?php echo $tags[0]; ?>" style='display:none' id="marca" name="marca">
<img class="center-block" style='' id="image_output" name="image_output">
<img class="center-block" style='' id="otra_imagen" name="otra_imagen">
<div id="result" class="result">
<p></p>
</div>
<a name="arriba"></a>
<div style="position:relative">
<div style="position:absolute; width:100%; height:100%;" >
<table style="width:100%; height:100%;" class="">
<tr >
<td class="pin" ><a href="#arriba" onclick=" javascript: marcar('top-left')"><img class="ing-touch img img-circle img-responsive center-block " style="width:20%;" src="milfs/images/oscuro40.png"></a></td>
<td class="pin"><a href="#arriba" onclick=" javascript: marcar('top-center')"><img class="ing-touch img img-circle img-responsive center-block " style="width:20%;" src="milfs/images/oscuro40.png"></a></td>
<td class="pin"><a href="#arriba" onclick=" javascript: marcar('top-rigth')"><img class="ing-touch img img-circle img-responsive center-block " style="width:50%;" src="milfs/images/oscuro40.png"></a></td>
</tr>
<tr>
<td class="pin"><a name="medio"></a><a href="#arriba" onclick=" javascript: marcar('middle-left')"><img class="ing-touch img img-circle img-responsive center-block " style="width:50%;" src="milfs/images/oscuro40.png"></a></td>
<td class="pin" ><a href="#medio" onclick=" javascript: marcar('middle-center')"><img class="ing-touch img img-circle img-responsive center-block " style="width:50%;" src="milfs/images/oscuro40.png"></a></td>
<td class="pin"><a href="#medio" onclick=" javascript: marcar('middle-rigth')"><img class="ing-touch img img-circle img-responsive center-block " style="width:50%;" src="milfs/images/oscuro40.png"></td>
</tr>
<tr>
<td class="pin"><a href="#medio" onclick=" javascript: marcar('bottom-left')"><img class="ing-touch img img-circle img-responsive center-block " style="width:50%;" src="milfs/images/oscuro40.png"></a></td>
<td class="pin"><a href="#medio" onclick=" javascript: marcar('bottom-center')"><img class="ing-touch img img-circle img-responsive center-block " style="width:50%;" src="milfs/images/oscuro40.png"></a></td>
<td class="pin"><a href="#medio" onclick=" javascript: marcar('bottom-rigth')"><img class="ing-touch img img-circle img-responsive center-block " style="width:50%;" src="milfs/images/oscuro40.png"></a></td>
</tr>
</table>
</div>
<canvas id="micanvas" style="position:absolute" >
Tu navegador no soporta canvas.
</canvas>
</div>
<div class="row " style="position:relative">
<form id='formulario_brigadistas' name='formulario_brigadistas' >
<input class='form-control' type='' id="debugConsole" name="debugConsole" >
<input type='' id="identificador" name="identificador" >
<input type='hidden' id="formulario_id" name="formulario_id" value="<?php echo $id_formulario; ?>">
<input type='hidden' id="imagen" name="imagen" value="">
<?php $formulario = formulario_areas("$id_formulario",'campos','','');
echo $formulario; ?>
</form>
</div>
<div id='aviso'>Aviso</div>
<div class="row">
<div class="col-md-12">
<!-- this.disabled= true; xajax_wait('aviso','Grabando... un momento por favor...'); -->
<button class='fileUpload btn btn-success btn-block' onclick=" xajax_brigadistas_grabar(xajax.getFormValues('formulario_brigadistas'))">
<span><i class="fa fa-save"></i> <span class='fa'> Grabalo! </span></span>
</button>
</div>
</div>
</div>
</div>
<script language="javascript">
$(function () {
'use strict';
var result = $('#result'),
exifNode = $('#exif'),
thumbNode = $('#thumbnail'),
actionsNode = $('#actions'),
currentFile,
replaceResults = function (img) {
var content;
if (!(img.src || img instanceof HTMLCanvasElement)) {
content = $('<span>Loading image file failed</span>');
} else {
content = $('<img />').append(img)
//.attr('download', currentFile.name)
.attr('src', img.src || img.toDataURL())
.attr('width', '<?echo $ancho ?>px')
.attr('style', 'width:100%')
.attr('id', 'imagen_original');
}
//document.getElementById('image_output').src = img.src;
result.children().replaceWith(content);
if (img.getContext) {
actionsNode.show();
window.setTimeout("marcar('middle-center');", 500);
}
},
displayImage = function (file, options) {
currentFile = file;
if (!loadImage(
file,
replaceResults,
options
)) {
result.children().replaceWith(
$('<span>Your browser does not support the URL or FileReader API.</span>')
);
}
},
displayExifData = function (exif) {
var thumbnail = exif.get('Thumbnail'),
tags = exif.getAll(),
table = exifNode.find('table').empty(),
row = $('<tr></tr>'),
cell = $('<td></td>'),
prop;
if (thumbnail) {
thumbNode.empty();
loadImage(thumbnail, function (img) {
thumbNode.append(img).show();
}, {orientation: exif.get('Orientation')});
}
for (prop in tags) {
if (tags.hasOwnProperty(prop)) {
table.append(
row.clone()
.append(cell.clone().text(prop))
.append(cell.clone().text(tags[prop]))
);
}
}
exifNode.show();
},
dropChangeHandler = function (e) {
e.preventDefault();
e = e.originalEvent;
var target = e.dataTransfer || e.target,
file = target && target.files && target.files[0],
options = {
maxWidth: result.width(),
canvas: true
};
if (!file) {
return;
}
exifNode.hide();
thumbNode.hide();
loadImage.parseMetaData(file, function (data) {
if (data.exif) {
options.orientation = data.exif.get('Orientation');
displayExifData(data.exif);
}
displayImage(file, options);
});
},
coordinates;
// Hide URL/FileReader API requirement message in capable browsers:
if (window.createObjectURL || window.URL || window.webkitURL || window.FileReader) {
result.children().hide();
}
$(document)
.on('dragover', function (e) {
e.preventDefault();
e = e.originalEvent;
e.dataTransfer.dropEffect = 'copy';
})
.on('drop', dropChangeHandler);
$('#file-input').on('change', dropChangeHandler);
$('#edit').on('click', function (event) {
event.preventDefault();
var imgNode = result.find('img, canvas'),
img = imgNode[0];
imgNode.Jcrop({
setSelect: [40, 40, img.width - 40, img.height - 40],
onSelect: function (coords) {
coordinates = coords;
},
onRelease: function () {
coordinates = null;
}
}).parent().on('click', function (event) {
event.preventDefault();
});
});
$('#crop').on('click', function (event) {
event.preventDefault();
var img = result.find('img, canvas')[0];
if (img && coordinates) {
replaceResults(loadImage.scale(img, {
left: coordinates.x,
top: coordinates.y,
sourceWidth: coordinates.w,
sourceHeight: coordinates.h,
minWidth: result.width()
}));
coordinates = null;
}
});
});
</script>
<script language="javascript">
function cargaContextoCanvas(idCanvas){
var elemento = document.getElementById(idCanvas);
if(elemento && elemento.getContext){
var contexto = elemento.getContext('2d');
if(contexto){
return contexto;
}
}
return FALSE;
}
function marcar(ubicacion){
//if (ubicacion == 'arriba'){ var x = '0';var y = '0';}
//if (ubicacion == 'abajo'){ var x = '10';var y = '50';}
//Recibimos el elemento canvas
var ctx = cargaContextoCanvas('micanvas');
if(ctx){
//Creo una imagen conun objeto Image de Javascript
var img = new Image();
var img2 = new Image();
//img.src = document.getElementById("image_output2").src;
//readAsDataURL(
img.src = document.getElementById("imagen_original").src;
document.getElementById("imagen_original").style.display="none";
//img2.src = 'images/logos/a.png';
img2.src = document.getElementById("marca").src;
if (ubicacion =='') {
ubicacion ='middle-center';
}
x = 0,
y = 0;
if(ubicacion.indexOf("top")!=-1)
y = 10;
else if(ubicacion.indexOf("middle")!=-1)
y = (micanvas.height - img2.height)/2;
else
y = micanvas.height-img2.height-10;
if(ubicacion.indexOf("left")!=-1)
x = 10;
else if(ubicacion.indexOf("center")!=-1)
x = (micanvas.width - img2.width) /2;
else
x = micanvas.width-img2.width-10;
var proporcion = ( img.height / img.width );
var ancho = <?echo $ancho ?>;
micanvas.width =ancho;
micanvas.height = (micanvas.width * proporcion);
micanvas.setAttribute('width', ancho);
micanvas.setAttribute('height', micanvas.height);
micanvas.setAttribute('style',"width:100%");
img.onload = function(){
ctx.drawImage(img, 0, 0,micanvas.width,micanvas.height);
ctx.drawImage(img2, x, y);
var debugConsole= document.getElementById("debugConsole");
var testCanvas = document.getElementById("micanvas");
var canvasData = testCanvas.toDataURL("image/png");
var postData = "canvasData="+canvasData;
debugConsole.value=canvasData;
var identificador = Math.random();
document.getElementById('identificador').value= identificador;
}
}
}
$(function () {
'use strict';
var result = $('#result'),
exifNode = $('#exif'),
thumbNode = $('#thumbnail'),
actionsNode = $('#actions'),
currentFile,
replaceResults = function (img) {
var content;
if (!(img.src || img instanceof HTMLCanvasElement)) {
content = $('<span>Loading image file failed</span>');
} else {
content = $('<img />').append(img)
//.attr('download', currentFile.name)
.attr('src', img.src || img.toDataURL())
.attr('width', '<?echo $ancho ?>')
.attr('style', 'width:100%')
.attr('id', 'imagen_original');
}
//document.getElementById('image_output').src = img.src;
result.children().replaceWith(content);
if (img.getContext) {
actionsNode.show();
window.setTimeout("marcar('middle-center');", 500);
}
},
displayImage = function (file, options) {
currentFile = file;
if (!loadImage(
file,
replaceResults,
options
)) {
result.children().replaceWith(
$('<span>Your browser does not support the URL or FileReader API.</span>')
);
}
},
displayExifData = function (exif) {
var thumbnail = exif.get('Thumbnail'),
tags = exif.getAll(),
table = exifNode.find('table').empty(),
row = $('<tr></tr>'),
cell = $('<td></td>'),
prop;
if (thumbnail) {
thumbNode.empty();
loadImage(thumbnail, function (img) {
thumbNode.append(img).show();
}, {orientation: exif.get('Orientation')});
}
for (prop in tags) {
if (tags.hasOwnProperty(prop)) {
table.append(
row.clone()
.append(cell.clone().text(prop))
.append(cell.clone().text(tags[prop]))
);
}
}
exifNode.show();
},
dropChangeHandler = function (e) {
e.preventDefault();
e = e.originalEvent;
var target = e.dataTransfer || e.target,
file = target && target.files && target.files[0],
options = {
maxWidth: result.width(),
canvas: true
};
if (!file) {
return;
}
exifNode.hide();
thumbNode.hide();
loadImage.parseMetaData(file, function (data) {
if (data.exif) {
options.orientation = data.exif.get('Orientation');
displayExifData(data.exif);
}
displayImage(file, options);
});
},
coordinates;
// Hide URL/FileReader API requirement message in capable browsers:
if (window.createObjectURL || window.URL || window.webkitURL || window.FileReader) {
result.children().hide();
}
$(document)
.on('dragover', function (e) {
e.preventDefault();
e = e.originalEvent;
e.dataTransfer.dropEffect = 'copy';
})
.on('drop', dropChangeHandler);
$('#file-input').on('change', dropChangeHandler);
$('#edit').on('click', function (event) {
event.preventDefault();
var imgNode = result.find('img, canvas'),
img = imgNode[0];
imgNode.Jcrop({
setSelect: [40, 40, img.width - 40, img.height - 40],
onSelect: function (coords) {
coordinates = coords;
},
onRelease: function () {
coordinates = null;
}
}).parent().on('click', function (event) {
event.preventDefault();
});
});
$('#crop').on('click', function (event) {
event.preventDefault();
var img = result.find('img, canvas')[0];
if (img && coordinates) {
replaceResults(loadImage.scale(img, {
left: coordinates.x,
top: coordinates.y,
sourceWidth: coordinates.w,
sourceHeight: coordinates.h,
minWidth: result.width()
}));
coordinates = null;
}
});
});
</script>
<br>
<script src="milfs/addon/logis/js/load-image.all.min.js"></script>
<!-- <script src="js/load-image.js"></script> -->
<!-- <script src="js/load-image-ios.js"></script> -->
<!-- <script src="js/load-image-orientation.js"></script> -->
<!-- <script src="js/load-image-meta.js"></script> -->
<!-- <script src="js/load-image-exif.js"></script> -->
<!-- <script src="js/load-image-exif-map.js"></script> -->
<!-- jQuery and Jcrop are not required by JavaScript Load Image, but included for the demo -->
<!-- <script src="//ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js"></script> -->
<!-- <script src="js/vendor/jquery.Jcrop.js"></script> -->
<!-- <script src="js/demo.js"></script> -->
</div>

View File

@ -0,0 +1,91 @@
<?php
function brigadistas_grabar_imagen($data,$identificador) {
$respuesta = new xajaxResponse('utf-8');
$control = md5("$identificador");
//$form_id = $fomulario["formulario_id"];
$imagen= grabar_imagen($data,$control);
$preview = "<img src='$_SESSION[url]/images/secure/?file=150/$imagen'>";
$respuesta->addScript("javascript: document.getElementById('imagen').value= '$imagen' ;");
$respuesta->addAssign("aviso","innerHTML","$preview");
return $respuesta;
}
$xajax->registerFunction("brigadistas_grabar_imagen");
function brigadistas_grabar($formulario) {
$identificador = $formulario['identificador'];
$control = md5("$identificador");
$data = $formulario['debugConsole'];
$imagen= grabar_imagen($data,$control);
$texto_url = urlencode("#BrigadaDigital");
$uri = urlencode("$_SESSION[url]/images/secure/?file=600/$imagen");
$url ="https://twitter.com/share?url=$uri&text=$texto_url";
//$respuesta->addScript("window.location.href ='$url';");
$respuesta = new xajaxResponse('utf-8');
//$identificador = $formulario['identificador'];
$id_formulario = $formulario['formulario_id'];
$campo_imagen = buscar_campo_tipo("$id_formulario","15");
$formulario[$campo_imagen[0]][0] = $imagen;
$empresa = remplacetas('form_id','id',"$id_formulario",'id_empresa',"") ;
$id_empresa = $empresa[0];
include_once("librerias/conex.php");
$link=Conectarse();
mysqli_query("SET NAMES 'utf8'");
foreach($formulario as $campo=>$valor){
if(is_array($valor)) {
foreach($valor as $c=>$v){
$consulta = "INSERT INTO form_datos ( timestamp,id_usuario,id_empresa,form_id,ip,control,id_campo,contenido) VALUES
( UNIX_TIMESTAMP(),'$_SESSION[id]','$id_empresa','$id_formulario','$ip' ,'$control', '$campo' , '".mysql_real_escape_string( $v )."')
";
$sql=mysqli_query($consulta,$link);
// $campos .= " $campo // $valor // $c -> $v $consulta <br>";
}
}
}
$twitter = $formulario['498'][0];
$_SESSION['logis'] = "$control";
$_SESSION['mensaje'] = "$twitter";
$preview = "
<div class='row'>
<div class='center-block'>
<div class='thumbnail'>
<img src='$_SESSION[url]/images/secure/?file=300/$imagen'>
<h2 class='text-center'>$twitter<h2>
<a download='brigadistas.png' href='$_SESSION[url]images/secure/?file=600/$imagen' >
<span class='btn btn-default'><i class='fa fa-download'></i> </span>
</a>
<span class='btn btn-default'>
<a target= 'twitter' href ='milfs/addon/logis/funciones/twitter/tuitear.php' ><i class='fa fa-twitter'></i></a>
</span>
<a href='S58'>
<span class='btn btn-default'><i class='fa fa-eye'></i> </span>
</a>
<a href='#' onclick = \"javascript:location.reload(); \">
<span class='btn btn-default'><i class='fa fa-refresh'></i> </span>
</a>
</div>
</div>
</div>
";
$resultado = "$preview ";
$respuesta->addAssign("aviso","innerHTML","$preview");
//$respuesta->addAlert("$resultado");
//$respuesta->addScript("javascript:location.reload(true);");
return $respuesta;
}
$xajax->registerFunction("brigadistas_grabar");
?>

View File

@ -0,0 +1,36 @@
<?php
/**
* Use to autoload needed classes without Composer.
*
* @param string $class The fully-qualified class name.
* @return void
*/
spl_autoload_register(function ($class) {
// project-specific namespace prefix
$prefix = 'Abraham\\TwitterOAuth\\';
// base directory for the namespace prefix
$base_dir = __DIR__ . '/src/';
// does the class use the namespace prefix?
$len = strlen($prefix);
if (strncmp($prefix, $class, $len) !== 0) {
// no, move to the next registered autoloader
return;
}
// get the relative class name
$relative_class = substr($class, $len);
// replace the namespace prefix with the base directory, replace namespace
// separators with directory separators in the relative class name, append
// with .php
$file = $base_dir . str_replace('\\', '/', $relative_class) . '.php';
// if the file exists, require it
if (file_exists($file)) {
require $file;
}
});

Binary file not shown.

After

Width:  |  Height:  |  Size: 38 KiB

View File

@ -0,0 +1,6 @@
<?php
define('CONSUMER_KEY', 'QS1JHXs7OgJcFArJmMv117JEn');
define('CONSUMER_SECRET', 'NoO1FUXHmTB74HUrnDbcs64XgZoroBkaPav8w0FgbK3ZYSU9PZ');
define('OAUTH_CALLBACK', 'http://datos.labmde.org/milfs/toa/hola.php');
?>

View File

@ -0,0 +1,31 @@
<?php
ini_set('display_errors', 1);
require 'autoload.php';
use Abraham\TwitterOAuth\TwitterOAuth;
/*
define('CONSUMER_KEY', getenv('wMtivKDSAgZmkP7EZhYcfw'));
define('CONSUMER_SECRET', getenv('AvWbHfjuSJkZYhkxsU8ojsDpNtvapBoiRUzwF3OAvbo'));
define('OAUTH_CALLBACK', getenv('http://datos.labmde.org/milfs/toa/hola.php'));
*/
define('CONSUMER_KEY', 'QS1JHXs7OgJcFArJmMv117JEn');
define('CONSUMER_SECRET', 'NoO1FUXHmTB74HUrnDbcs64XgZoroBkaPav8w0FgbK3ZYSU9PZ');
define('OAUTH_CALLBACK', 'http://datos.labmde.org/milfs/addon/logis/funciones/twitter/hola.php');
$connection = new TwitterOAuth(CONSUMER_KEY, CONSUMER_SECRET);
//print $connection; //print connection contents
//$request_token = $connection->oauth('oauth/request_token', array('oauth_callback' => OAUTH_CALLBACK));
$request_token = $connection->oauth('oauth/request_token');
//$url = $connection->url('oauth/authorize', array('oauth_token' => $request_token['oauth_token']));
$user = $connection->get("account/verify_credentials");
//print $user->screen_name;
print_r($user);
// Post Update
$content = $connection->post('statuses/update', array('status' => 'Bonito dia'));
print_r( $content);
print_r($url);
//print_r($request_token); //print connection contentsa
?>

View File

@ -0,0 +1,65 @@
<?php
session_start();
ini_set('display_errors', 1);
require 'autoload.php';
use Abraham\TwitterOAuth\TwitterOAuth;
require_once('config.php');
/* Crear un objeto TwitteroAuth con las credenciales de la aplicacion y el token temporal */
//$connection = new TwitterOAuth(CONSUMER_KEY, CONSUMER_SECRET,
$connection = new TwitterOAuth(CONSUMER_KEY, CONSUMER_SECRET,
$_SESSION['oauth_token'], $_SESSION['oauth_token_secret']);
/* Solicitar a twitter el token de acceso */
//$access_token = $connection->getAccessToken($_REQUEST['oauth_verifier']);
$access_token = $connection->oauth("oauth/access_token", array("oauth_verifier" => $_REQUEST['oauth_verifier']));
/* Guardar el token de acceso. Normalmente, este token se guardará también en una base
de datos para volver a ser utilizado en otras ocasiones. */
$_SESSION['access_token'] = $access_token;
/* Eliminar el token temporal de solicitud */
unset($_SESSION['oauth_token']);
unset($_SESSION['oauth_token_secret']);
/* Si todo va bien, presentar al usuario la página principal "index.php" del servicio */
//if (200 == $connection->http_code) {
/* El usuario ha sido verificado */
$_SESSION['status'] = 'verified';
echo send_tweet($access_token);
//}
function base64_encode_image ($filename=string,$filetype=string) {
if ($filename) {
$imgbinary = fread(fopen($filename, "r"), filesize($filename));
return base64_encode($imgbinary);
}
}
function send_tweet($access_token) {
$tweet = new TwitterOAuth(CONSUMER_KEY, CONSUMER_SECRET,
$access_token['oauth_token'], $access_token['oauth_token_secret']);
$nombre= $_SESSION['logis'].".png";
$nombre = "$_SESSION[path_images_secure]/600/$nombre";
$media1 = $tweet->upload('media/upload', array('media' => "$nombre"));
$parameters = array('status' =>"$_SESSION[mensaje] #BrigadaDigital #CD2015 http://datos.labmde.org/jlogis",'media_ids' => implode(',', array($media1->media_id_string)),
);
$result = $tweet-> post('statuses/update', $parameters);
$image = "$nombre";
$base64 = base64_encode_image (''.$image,'png');
$result = $tweet-> post('account/update_profile_image', array('image' => $base64.';type=image/jpg;filename='.$image));
// $message = "Bonito dia $nombre";
// $tweet->post('statuses/update', array('status' => "$message"));
//
}
header('Location: https://twitter.com/hashtag/CD2015');
// header('Location: ./index.php');
//} else {
//header('Location: ./clearsessions.php');
//

View File

@ -0,0 +1,64 @@
<?php
namespace Abraham\TwitterOAuth;
/**
* Handle setting and storing config for TwitterOAuth.
*
* @author Abraham Williams <abraham@abrah.am>
*/
class Config
{
/** @var int How long to wait for a response from the API */
protected $timeout = 5;
/** @var int how long to wait while connecting to the API */
protected $connectionTimeout = 5;
/**
* Decode JSON Response as associative Array
*
* @see http://php.net/manual/en/function.json-decode.php
*
* @var bool
*/
protected $decodeJsonAsArray = false;
/** @var string User-Agent header */
protected $userAgent = 'TwitterOAuth (+https://twitteroauth.com)';
/** @var array Store proxy connection details */
protected $proxy = [];
/**
* Set the connection and response timeouts.
*
* @param int $connectionTimeout
* @param int $timeout
*/
public function setTimeouts($connectionTimeout, $timeout)
{
$this->connectionTimeout = (int)$connectionTimeout;
$this->timeout = (int)$timeout;
}
/**
* @param bool $value
*/
public function setDecodeJsonAsArray($value)
{
$this->decodeJsonAsArray = (bool)$value;
}
/**
* @param string $userAgent
*/
public function setUserAgent($userAgent)
{
$this->userAgent = (string)$userAgent;
}
/**
* @param array $proxy
*/
public function setProxy(array $proxy)
{
$this->proxy = $proxy;
}
}

View File

@ -0,0 +1,36 @@
<?php
/**
* The MIT License
* Copyright (c) 2007 Andy Smith
*/
namespace Abraham\TwitterOAuth;
class Consumer
{
/** @var string */
public $key;
/** @var string */
public $secret;
/** @var string|null */
public $callbackUrl;
/**
* @param string $key
* @param string $secret
* @param null $callbackUrl
*/
public function __construct($key, $secret, $callbackUrl = null)
{
$this->key = $key;
$this->secret = $secret;
$this->callbackUrl = $callbackUrl;
}
/**
* @return string
*/
public function __toString()
{
return "Consumer[key=$this->key,secret=$this->secret]";
}
}

View File

@ -0,0 +1,39 @@
<?php
/**
* The MIT License
* Copyright (c) 2007 Andy Smith
*/
namespace Abraham\TwitterOAuth;
/**
* The HMAC-SHA1 signature method uses the HMAC-SHA1 signature algorithm as defined in [RFC2104]
* where the Signature Base String is the text and the key is the concatenated values (each first
* encoded per Parameter Encoding) of the Consumer Secret and Token Secret, separated by an '&'
* character (ASCII code 38) even if empty.
* - Chapter 9.2 ("HMAC-SHA1")
*/
class HmacSha1 extends SignatureMethod
{
/**
* {@inheritDoc}
*/
public function getName()
{
return "HMAC-SHA1";
}
/**
* {@inheritDoc}
*/
public function buildSignature(Request $request, Consumer $consumer, Token $token = null)
{
$signatureBase = $request->getSignatureBaseString();
$parts = [$consumer->secret, null !== $token ? $token->secret : ""];
$parts = Util::urlencodeRfc3986($parts);
$key = implode('&', $parts);
return base64_encode(hash_hmac('sha1', $signatureBase, $key, true));
}
}

View File

@ -0,0 +1,254 @@
<?php
/**
* The MIT License
* Copyright (c) 2007 Andy Smith
*/
namespace Abraham\TwitterOAuth;
class Request
{
protected $parameters;
protected $httpMethod;
protected $httpUrl;
public static $version = '1.0';
/**
* Constructor
*
* @param string $httpMethod
* @param string $httpUrl
* @param array|null $parameters
*/
public function __construct($httpMethod, $httpUrl, array $parameters = [])
{
$parameters = array_merge(Util::parseParameters(parse_url($httpUrl, PHP_URL_QUERY)), $parameters);
$this->parameters = $parameters;
$this->httpMethod = $httpMethod;
$this->httpUrl = $httpUrl;
}
/**
* pretty much a helper function to set up the request
*
* @param Consumer $consumer
* @param Token $token
* @param string $httpMethod
* @param string $httpUrl
* @param array $parameters
*
* @return Request
*/
public static function fromConsumerAndToken(
Consumer $consumer,
Token $token = null,
$httpMethod,
$httpUrl,
array $parameters = []
) {
$defaults = [
"oauth_version" => Request::$version,
"oauth_nonce" => Request::generateNonce(),
"oauth_timestamp" => time(),
"oauth_consumer_key" => $consumer->key
];
if (null !== $token) {
$defaults['oauth_token'] = $token->key;
}
$parameters = array_merge($defaults, $parameters);
return new Request($httpMethod, $httpUrl, $parameters);
}
/**
* @param string $name
* @param string $value
*/
public function setParameter($name, $value)
{
$this->parameters[$name] = $value;
}
/**
* @param $name
*
* @return string|null
*/
public function getParameter($name)
{
return isset($this->parameters[$name]) ? $this->parameters[$name] : null;
}
/**
* @return array
*/
public function getParameters()
{
return $this->parameters;
}
/**
* @param $name
*/
public function removeParameter($name)
{
unset($this->parameters[$name]);
}
/**
* The request parameters, sorted and concatenated into a normalized string.
*
* @return string
*/
public function getSignableParameters()
{
// Grab all parameters
$params = $this->parameters;
// Remove oauth_signature if present
// Ref: Spec: 9.1.1 ("The oauth_signature parameter MUST be excluded.")
if (isset($params['oauth_signature'])) {
unset($params['oauth_signature']);
}
return Util::buildHttpQuery($params);
}
/**
* Returns the base string of this request
*
* The base string defined as the method, the url
* and the parameters (normalized), each urlencoded
* and the concated with &.
*
* @return string
*/
public function getSignatureBaseString()
{
$parts = [
$this->getNormalizedHttpMethod(),
$this->getNormalizedHttpUrl(),
$this->getSignableParameters()
];
$parts = Util::urlencodeRfc3986($parts);
return implode('&', $parts);
}
/**
* Returns the HTTP Method in uppercase
*
* @return string
*/
public function getNormalizedHttpMethod()
{
return strtoupper($this->httpMethod);
}
/**
* parses the url and rebuilds it to be
* scheme://host/path
*
* @return string
*/
public function getNormalizedHttpUrl()
{
$parts = parse_url($this->httpUrl);
$scheme = $parts['scheme'];
$host = strtolower($parts['host']);
$path = $parts['path'];
return "$scheme://$host$path";
}
/**
* Builds a url usable for a GET request
*
* @return string
*/
public function toUrl()
{
$postData = $this->toPostdata();
$out = $this->getNormalizedHttpUrl();
if ($postData) {
$out .= '?' . $postData;
}
return $out;
}
/**
* Builds the data one would send in a POST request
*
* @return string
*/
public function toPostdata()
{
return Util::buildHttpQuery($this->parameters);
}
/**
* Builds the Authorization: header
*
* @return string
* @throws TwitterOAuthException
*/
public function toHeader()
{
$first = true;
$out = 'Authorization: OAuth';
foreach ($this->parameters as $k => $v) {
if (substr($k, 0, 5) != "oauth") {
continue;
}
if (is_array($v)) {
throw new TwitterOAuthException('Arrays not supported in headers');
}
$out .= ($first) ? ' ' : ', ';
$out .= Util::urlencodeRfc3986($k) . '="' . Util::urlencodeRfc3986($v) . '"';
$first = false;
}
return $out;
}
/**
* @return string
*/
public function __toString()
{
return $this->toUrl();
}
/**
* @param SignatureMethod $signatureMethod
* @param Consumer $consumer
* @param Token $token
*/
public function signRequest(SignatureMethod $signatureMethod, Consumer $consumer, Token $token = null)
{
$this->setParameter("oauth_signature_method", $signatureMethod->getName());
$signature = $this->buildSignature($signatureMethod, $consumer, $token);
$this->setParameter("oauth_signature", $signature);
}
/**
* @param SignatureMethod $signatureMethod
* @param Consumer $consumer
* @param Token $token
*
* @return string
*/
public function buildSignature(SignatureMethod $signatureMethod, Consumer $consumer, Token $token = null)
{
return $signatureMethod->buildSignature($this, $consumer, $token);
}
/**
* @return string
*/
public static function generateNonce()
{
return md5(microtime() . mt_rand());
}
}

View File

@ -0,0 +1,107 @@
<?php
namespace Abraham\TwitterOAuth;
/**
* The result of the most recent API request.
*
* @author Abraham Williams <abraham@abrah.am>
*/
class Response
{
/** @var string|null API path from the most recent request */
private $apiPath;
/** @var int HTTP status code from the most recent request */
private $httpCode = 0;
/** @var array HTTP headers from the most recent request */
private $headers = [];
/** @var array|object Response body from the most recent request */
private $body = [];
/** @var array HTTP headers from the most recent request that start with X */
private $xHeaders = [];
/**
* @param string $apiPath
*/
public function setApiPath($apiPath)
{
$this->apiPath = $apiPath;
}
/**
* @return string|null
*/
public function getApiPath()
{
return $this->apiPath;
}
/**
* @param array|object $body
*/
public function setBody($body)
{
$this->body = $body;
}
/**
* @return array|object|string
*/
public function getBody()
{
return $this->body;
}
/**
* @param int $httpCode
*/
public function setHttpCode($httpCode)
{
$this->httpCode = $httpCode;
}
/**
* @return int
*/
public function getHttpCode()
{
return $this->httpCode;
}
/**
* @param array $headers
*/
public function setHeaders($headers)
{
foreach ($headers as $key => $value) {
if (substr($key, 0, 1) == 'x') {
$this->xHeaders[$key] = $value;
}
}
$this->headers = $headers;
}
/**
* @return array
*/
public function getsHeaders()
{
return $this->headers;
}
/**
* @param array $xHeaders
*/
public function setXHeaders($xHeaders)
{
$this->xHeaders = $xHeaders;
}
/**
* @return array
*/
public function getXHeaders()
{
return $this->xHeaders;
}
}

View File

@ -0,0 +1,66 @@
<?php
/**
* The MIT License
* Copyright (c) 2007 Andy Smith
*/
namespace Abraham\TwitterOAuth;
/**
* A class for implementing a Signature Method
* See section 9 ("Signing Requests") in the spec
*/
abstract class SignatureMethod
{
/**
* Needs to return the name of the Signature Method (ie HMAC-SHA1)
*
* @return string
*/
abstract public function getName();
/**
* Build up the signature
* NOTE: The output of this function MUST NOT be urlencoded.
* the encoding is handled in OAuthRequest when the final
* request is serialized
*
* @param Request $request
* @param Consumer $consumer
* @param Token $token
*
* @return string
*/
abstract public function buildSignature(Request $request, Consumer $consumer, Token $token = null);
/**
* Verifies that a given signature is correct
*
* @param Request $request
* @param Consumer $consumer
* @param Token $token
* @param string $signature
*
* @return bool
*/
public function checkSignature(Request $request, Consumer $consumer, Token $token, $signature)
{
$built = $this->buildSignature($request, $consumer, $token);
// Check for zero length, although unlikely here
if (strlen($built) == 0 || strlen($signature) == 0) {
return false;
}
if (strlen($built) != strlen($signature)) {
return false;
}
// Avoid a timing leak with a (hopefully) time insensitive compare
$result = 0;
for ($i = 0; $i < strlen($signature); $i++) {
$result |= ord($built{$i}) ^ ord($signature{$i});
}
return $result == 0;
}
}

View File

@ -0,0 +1,38 @@
<?php
/**
* The MIT License
* Copyright (c) 2007 Andy Smith
*/
namespace Abraham\TwitterOAuth;
class Token
{
/** @var string */
public $key;
/** @var string */
public $secret;
/**
* @param string $key The OAuth Token
* @param string $secret The OAuth Token Secret
*/
public function __construct($key, $secret)
{
$this->key = $key;
$this->secret = $secret;
}
/**
* Generates the basic string serialization of a token that a server
* would respond to request_token and access_token calls with
*
* @return string
*/
public function __toString()
{
return sprintf("oauth_token=%s&oauth_token_secret=%s",
Util::urlencodeRfc3986($this->key),
Util::urlencodeRfc3986($this->secret)
);
}
}

View File

@ -0,0 +1,448 @@
<?php
/**
* The most popular PHP library for use with the Twitter OAuth REST API.
*
* @license MIT
*/
namespace Abraham\TwitterOAuth;
use Abraham\TwitterOAuth\Util\JsonDecoder;
/**
* TwitterOAuth class for interacting with the Twitter API.
*
* @author Abraham Williams <abraham@abrah.am>
*/
class TwitterOAuth extends Config
{
const API_VERSION = '1.1';
const API_HOST = 'https://api.twitter.com';
const UPLOAD_HOST = 'https://upload.twitter.com';
const UPLOAD_CHUNK = 40960; // 1024 * 40
/** @var Response details about the result of the last request */
private $response;
/** @var string|null Application bearer token */
private $bearer;
/** @var Consumer Twitter application details */
private $consumer;
/** @var Token|null User access token details */
private $token;
/** @var HmacSha1 OAuth 1 signature type used by Twitter */
private $signatureMethod;
/**
* Constructor
*
* @param string $consumerKey The Application Consumer Key
* @param string $consumerSecret The Application Consumer Secret
* @param string|null $oauthToken The Client Token (optional)
* @param string|null $oauthTokenSecret The Client Token Secret (optional)
*/
public function __construct($consumerKey, $consumerSecret, $oauthToken = null, $oauthTokenSecret = null)
{
$this->resetLastResponse();
$this->signatureMethod = new HmacSha1();
$this->consumer = new Consumer($consumerKey, $consumerSecret);
if (!empty($oauthToken) && !empty($oauthTokenSecret)) {
$this->token = new Token($oauthToken, $oauthTokenSecret);
}
if (empty($oauthToken) && !empty($oauthTokenSecret)) {
$this->bearer = $oauthTokenSecret;
}
}
/**
* @param string $oauthToken
* @param string $oauthTokenSecret
*/
public function setOauthToken($oauthToken, $oauthTokenSecret)
{
$this->token = new Token($oauthToken, $oauthTokenSecret);
}
/**
* @return string|null
*/
public function getLastApiPath()
{
return $this->response->getApiPath();
}
/**
* @return int
*/
public function getLastHttpCode()
{
return $this->response->getHttpCode();
}
/**
* @return array
*/
public function getLastXHeaders()
{
return $this->response->getXHeaders();
}
/**
* @return array|object|null
*/
public function getLastBody()
{
return $this->response->getBody();
}
/**
* Resets the last response cache.
*/
public function resetLastResponse()
{
$this->response = new Response();
}
/**
* Make URLs for user browser navigation.
*
* @param string $path
* @param array $parameters
*
* @return string
*/
public function url($path, array $parameters)
{
$this->resetLastResponse();
$this->response->setApiPath($path);
$query = http_build_query($parameters);
return sprintf('%s/%s?%s', self::API_HOST, $path, $query);
}
/**
* Make /oauth/* requests to the API.
*
* @param string $path
* @param array $parameters
*
* @return array
* @throws TwitterOAuthException
*/
public function oauth($path, array $parameters = [])
{
$response = [];
$this->resetLastResponse();
$this->response->setApiPath($path);
$url = sprintf('%s/%s', self::API_HOST, $path);
$result = $this->oAuthRequest($url, 'POST', $parameters);
if ($this->getLastHttpCode() != 200) {
throw new TwitterOAuthException($result);
}
parse_str($result, $response);
$this->response->setBody($response);
return $response;
}
/**
* Make /oauth2/* requests to the API.
*
* @param string $path
* @param array $parameters
*
* @return array|object
*/
public function oauth2($path, array $parameters = [])
{
$method = 'POST';
$this->resetLastResponse();
$this->response->setApiPath($path);
$url = sprintf('%s/%s', self::API_HOST, $path);
$request = Request::fromConsumerAndToken($this->consumer, $this->token, $method, $url, $parameters);
$authorization = 'Authorization: Basic ' . $this->encodeAppAuthorization($this->consumer);
$result = $this->request($request->getNormalizedHttpUrl(), $method, $authorization, $parameters);
$response = JsonDecoder::decode($result, $this->decodeJsonAsArray);
$this->response->setBody($response);
return $response;
}
/**
* Make GET requests to the API.
*
* @param string $path
* @param array $parameters
*
* @return array|object
*/
public function get($path, array $parameters = [])
{
return $this->http('GET', self::API_HOST, $path, $parameters);
}
/**
* Make POST requests to the API.
*
* @param string $path
* @param array $parameters
*
* @return array|object
*/
public function post($path, array $parameters = [])
{
return $this->http('POST', self::API_HOST, $path, $parameters);
}
/**
* Make DELETE requests to the API.
*
* @param string $path
* @param array $parameters
*
* @return array|object
*/
public function delete($path, array $parameters = [])
{
return $this->http('DELETE', self::API_HOST, $path, $parameters);
}
/**
* Make PUT requests to the API.
*
* @param string $path
* @param array $parameters
*
* @return array|object
*/
public function put($path, array $parameters = [])
{
return $this->http('PUT', self::API_HOST, $path, $parameters);
}
/**
* Upload media to upload.twitter.com.
*
* @param string $path
* @param array $parameters
* @param boolean $chunked
*
* @return array|object
*/
public function upload($path, array $parameters = [], $chunked = false)
{
if ($chunked) {
return $this->uploadMediaChunked($path, $parameters);
} else {
return $this->uploadMediaNotChunked($path, $parameters);
}
}
/**
* Private method to upload media (not chunked) to upload.twitter.com.
*
* @param string $path
* @param array $parameters
*
* @return array|object
*/
private function uploadMediaNotChunked($path, $parameters)
{
$file = file_get_contents($parameters['media']);
$base = base64_encode($file);
$parameters['media'] = $base;
return $this->http('POST', self::UPLOAD_HOST, $path, $parameters);
}
/**
* Private method to upload media (chunked) to upload.twitter.com.
*
* @param string $path
* @param array $parameters
*
* @return array|object
*/
private function uploadMediaChunked($path, $parameters)
{
// Init
$init = $this->http('POST', self::UPLOAD_HOST, $path, [
'command' => 'INIT',
'media_type' => $parameters['media_type'],
'total_bytes' => filesize($parameters['media'])
]);
// Append
$segment_index = 0;
$media = fopen($parameters['media'], 'rb');
while (!feof($media))
{
$this->http('POST', self::UPLOAD_HOST, 'media/upload', [
'command' => 'APPEND',
'media_id' => $init->media_id_string,
'segment_index' => $segment_index++,
'media_data' => base64_encode(fread($media, self::UPLOAD_CHUNK))
]);
}
fclose($media);
// Finalize
$finalize = $this->http('POST', self::UPLOAD_HOST, 'media/upload', [
'command' => 'FINALIZE',
'media_id' => $init->media_id_string
]);
return $finalize;
}
/**
* @param string $method
* @param string $host
* @param string $path
* @param array $parameters
*
* @return array|object
*/
private function http($method, $host, $path, array $parameters)
{
$this->resetLastResponse();
$url = sprintf('%s/%s/%s.json', $host, self::API_VERSION, $path);
$this->response->setApiPath($path);
$result = $this->oAuthRequest($url, $method, $parameters);
$response = JsonDecoder::decode($result, $this->decodeJsonAsArray);
$this->response->setBody($response);
return $response;
}
/**
* Format and sign an OAuth / API request
*
* @param string $url
* @param string $method
* @param array $parameters
*
* @return string
* @throws TwitterOAuthException
*/
private function oAuthRequest($url, $method, array $parameters)
{
$request = Request::fromConsumerAndToken($this->consumer, $this->token, $method, $url, $parameters);
if (array_key_exists('oauth_callback', $parameters)) {
// Twitter doesn't like oauth_callback as a parameter.
unset($parameters['oauth_callback']);
}
if ($this->bearer === null) {
$request->signRequest($this->signatureMethod, $this->consumer, $this->token);
$authorization = $request->toHeader();
} else {
$authorization = 'Authorization: Bearer ' . $this->bearer;
}
return $this->request($request->getNormalizedHttpUrl(), $method, $authorization, $parameters);
}
/**
* Make an HTTP request
*
* @param string $url
* @param string $method
* @param string $authorization
* @param array $postfields
*
* @return string
* @throws TwitterOAuthException
*/
private function request($url, $method, $authorization, $postfields)
{
/* Curl settings */
$options = [
// CURLOPT_VERBOSE => true,
CURLOPT_CAINFO => __DIR__ . DIRECTORY_SEPARATOR . 'cacert.pem',
CURLOPT_CONNECTTIMEOUT => $this->connectionTimeout,
CURLOPT_HEADER => true,
CURLOPT_HTTPHEADER => ['Accept: application/json', $authorization, 'Expect:'],
CURLOPT_RETURNTRANSFER => true,
CURLOPT_SSL_VERIFYHOST => 2,
CURLOPT_SSL_VERIFYPEER => true,
CURLOPT_TIMEOUT => $this->timeout,
CURLOPT_URL => $url,
CURLOPT_USERAGENT => $this->userAgent,
CURLOPT_ENCODING => 'gzip',
];
if (!empty($this->proxy)) {
$options[CURLOPT_PROXY] = $this->proxy['CURLOPT_PROXY'];
$options[CURLOPT_PROXYUSERPWD] = $this->proxy['CURLOPT_PROXYUSERPWD'];
$options[CURLOPT_PROXYPORT] = $this->proxy['CURLOPT_PROXYPORT'];
$options[CURLOPT_PROXYAUTH] = CURLAUTH_BASIC;
$options[CURLOPT_PROXYTYPE] = CURLPROXY_HTTP;
}
switch ($method) {
case 'GET':
break;
case 'POST':
$options[CURLOPT_POST] = true;
$options[CURLOPT_POSTFIELDS] = Util::buildHttpQuery($postfields);
break;
case 'DELETE':
$options[CURLOPT_CUSTOMREQUEST] = 'DELETE';
break;
case 'PUT':
$options[CURLOPT_CUSTOMREQUEST] = 'PUT';
break;
}
if (in_array($method, ['GET', 'PUT', 'DELETE']) && !empty($postfields)) {
$options[CURLOPT_URL] .= '?' . Util::buildHttpQuery($postfields);
}
$curlHandle = curl_init();
curl_setopt_array($curlHandle, $options);
$response = curl_exec($curlHandle);
// Throw exceptions on cURL errors.
if (curl_errno($curlHandle) > 0) {
throw new TwitterOAuthException(curl_error($curlHandle), curl_errno($curlHandle));
}
$this->response->setHttpCode(curl_getinfo($curlHandle, CURLINFO_HTTP_CODE));
$parts = explode("\r\n\r\n", $response);
$responseBody = array_pop($parts);
$responseHeader = array_pop($parts);
$this->response->setHeaders($this->parseHeaders($responseHeader));
curl_close($curlHandle);
return $responseBody;
}
/**
* Get the header info to store.
*
* @param string $header
*
* @return array
*/
private function parseHeaders($header)
{
$headers = [];
foreach (explode("\r\n", $header) as $line) {
if (strpos($line, ':') !== false) {
list ($key, $value) = explode(': ', $line);
$key = str_replace('-', '_', strtolower($key));
$headers[$key] = trim($value);
}
}
return $headers;
}
/**
* Encode application authorization header with base64.
*
* @param Consumer $consumer
*
* @return string
*/
private function encodeAppAuthorization($consumer)
{
// TODO: key and secret should be rfc 1738 encoded
$key = $consumer->key;
$secret = $consumer->secret;
return base64_encode($key . ':' . $secret);
}
}

View File

@ -0,0 +1,10 @@
<?php
namespace Abraham\TwitterOAuth;
/**
* @author Abraham Williams <abraham@abrah.am>
*/
class TwitterOAuthException extends \Exception
{
}

View File

@ -0,0 +1,115 @@
<?php
/**
* The MIT License
* Copyright (c) 2007 Andy Smith
*/
namespace Abraham\TwitterOAuth;
class Util
{
/**
* @param $input
*
* @return array|mixed|string
*/
public static function urlencodeRfc3986($input)
{
$output = '';
if (is_array($input)) {
$output = array_map([__NAMESPACE__ . '\Util', 'urlencodeRfc3986'], $input);
} elseif (is_scalar($input)) {
$output = rawurlencode($input);
}
return $output;
}
/**
* @param string $string
*
* @return string
*/
public static function urldecodeRfc3986($string)
{
return urldecode($string);
}
/**
* This function takes a input like a=b&a=c&d=e and returns the parsed
* parameters like this
* array('a' => array('b','c'), 'd' => 'e')
*
* @param mixed $input
*
* @return array
*/
public static function parseParameters($input)
{
if (!isset($input) || !$input) {
return [];
}
$pairs = explode('&', $input);
$parameters = [];
foreach ($pairs as $pair) {
$split = explode('=', $pair, 2);
$parameter = Util::urldecodeRfc3986($split[0]);
$value = isset($split[1]) ? Util::urldecodeRfc3986($split[1]) : '';
if (isset($parameters[$parameter])) {
// We have already recieved parameter(s) with this name, so add to the list
// of parameters with this name
if (is_scalar($parameters[$parameter])) {
// This is the first duplicate, so transform scalar (string) into an array
// so we can add the duplicates
$parameters[$parameter] = [$parameters[$parameter]];
}
$parameters[$parameter][] = $value;
} else {
$parameters[$parameter] = $value;
}
}
return $parameters;
}
/**
* @param $params
*
* @return string
*/
public static function buildHttpQuery($params)
{
if (!$params) {
return '';
}
// Urlencode both keys and values
$keys = Util::urlencodeRfc3986(array_keys($params));
$values = Util::urlencodeRfc3986(array_values($params));
$params = array_combine($keys, $values);
// Parameters are sorted by name, using lexicographical byte value ordering.
// Ref: Spec: 9.1.1 (1)
uksort($params, 'strcmp');
$pairs = [];
foreach ($params as $parameter => $value) {
if (is_array($value)) {
// If two or more parameters share the same name, they are sorted by their value
// Ref: Spec: 9.1.1 (1)
// June 12th, 2010 - changed to sort because of issue 164 by hidetaka
sort($value, SORT_STRING);
foreach ($value as $duplicateValue) {
$pairs[] = $parameter . '=' . $duplicateValue;
}
} else {
$pairs[] = $parameter . '=' . $value;
}
}
// For each parameter, the name is separated from the corresponding value by an '=' character (ASCII code 61)
// Each name-value pair is separated by an '&' character (ASCII code 38)
return implode('&', $pairs);
}
}

View File

@ -0,0 +1,26 @@
<?php
namespace Abraham\TwitterOAuth\Util;
/**
* @author louis <louis@systemli.org>
*/
class JsonDecoder
{
/**
* Decodes a JSON string to stdObject or associative array
*
* @param string $string
* @param bool $asArray
*
* @return array|object
*/
public static function decode($string, $asArray)
{
if (version_compare(PHP_VERSION, '5.4.0', '>=') && !(defined('JSON_C_VERSION') && PHP_INT_SIZE > 4)) {
return json_decode($string, $asArray, 512, JSON_BIGINT_AS_STRING);
}
return json_decode($string, $asArray);
}
}

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,31 @@
<?php
session_start();
ini_set('display_errors', 1);
require 'autoload.php';
use Abraham\TwitterOAuth\TwitterOAuth;
require_once('config.php');
/* Prepara la conexión */
$connection = new TwitterOAuth(CONSUMER_KEY, CONSUMER_SECRET);
/* Solicita a twitter las credenciales temporales */
//$request_token = $connection->getRequestToken(OAUTH_CALLBACK);
$request_token = $connection->oauth('oauth/request_token');
/* Guarda la credenciales temporales en sesión. */
$_SESSION['oauth_token'] = $token = $request_token['oauth_token'];
$_SESSION['oauth_token_secret'] = $request_token['oauth_token_secret'];
//switch ($connection->http_code) {
// case 200:
/* Construye la url de autorización y envía al usuario a Twitter. */
$url = $connection->url('oauth/authorize', array('oauth_token' => $request_token['oauth_token']));
//$url = $connection->url('oauth/authorize', array('oauth_token' => $request_token['oauth_token']));
//$url = $connection->getAuthorizeURL($token);
// print $url;
header('Location: ' . $url);
//break;
// default:
/* Indica que se ha producido un error. */
// echo 'Error de conexión a Twitter.';
// echo "\nHTTP CODE: " . $connection->http_code;
//}

177
addon/brigada/grabar.php Normal file
View File

@ -0,0 +1,177 @@
<?php session_start();
ini_set('display_errors', 'On');
if(isset($_REQUEST['debug'])) {ini_set('display_errors', 'On');}
include_once("$_SESSION[path]/funciones/conex.php");
echo brigadistas_grabar($_POST);
function brigadistas_grabar($formulario) {
$identificador = $_POST['identificador'];
$control = md5("$identificador");
$data = $_POST['debugConsole'];
$imagen= grabar_imagen($data,$control);
$texto_url = urlencode("#BrigadaDigital");
$uri = urlencode("$_SESSION[url]/images/secure/?file=600/$imagen");
$url ="https://twitter.com/share?url=$uri&text=$texto_url";
//$respuesta->addScript("window.location.href ='$url';");
$preview = "
<div class='row'>
<div class='center-block'>
<div class='thumbnail'>
<img src='$_SESSION[url]/images/secure/?file=300/$imagen'>
<a download='brigadistas.png' href='$_SESSION[url]images/secure/?file=600/$imagen' >
<span class='btn btn-default'><i class='fa fa-download'></i> </span>
</a>
<span class='btn btn-default'>
<a onclick =\"javascript:window.location.href ='$url'; \" ><i class='fa fa-twitter'></i> </a>
</span>
<a href='?set=$formulario[formulario_id]&embebido'>
<span class='btn btn-default'><i class='fa fa-eye'></i> </span>
</a>
<a href='#' onclick = \"javascript:location.reload(); \">
<span class='btn btn-default'><i class='fa fa-refresh'></i> </span>
</a>
</div>
</div>
</div>
";
//$respuesta = new xajaxResponse('utf-8');
//$identificador = $formulario['identificador'];
$id_formulario = $_POST['formulario_id'];
$campo_imagen = buscar_campo_tipo("$id_formulario","15");
$_POST[$campo_imagen[0]][0] = $imagen;
$empresa = remplacetas('form_id','id',"$id_formulario",'id_empresa',"") ;
$id_empresa = $empresa[0];
include_once("$_SESSION[path]/funciones/conex.php");
//include_once("$_SESSION[url]funciones/conex.php");
$link=Conectarse();
mysqli_query("SET NAMES 'utf8'");
$ip = obtener_ip();
$ip = " INET_ATON('".$ip."') ";
foreach($_POST as $campo=>$valor){
if(is_array($valor)) {
foreach($valor as $c=>$v){
$consulta = "INSERT INTO form_datos ( timestamp,id_usuario,id_empresa,form_id,ip,control,id_campo,contenido) VALUES
( UNIX_TIMESTAMP(),'$_SESSION[id]','$id_empresa','$id_formulario','$ip' ,'$control', '$campo' , '$v')
";
$sql=mysqli_query($consulta,$link);
// $campos .= " $campo // $valor // $c -> $v $consulta <br>";
}
}
}
$resultado = "$preview $consulta ";
///$respuesta->addAssign("aviso","innerHTML","$preview");
//$respuesta->addAlert("$resultado");
//$respuesta->addScript("javascript:location.reload(true);");
return $resultado;
}
function remplacetas($tabla,$campo,$valor,$por,$and){
$link=Conectarse();
mysqli_query("SET NAMES 'utf8'");
if(@$and !=''){$AND = "AND $and";}else{$AND ="";}
//$consulta = "SELECT * , md5(binary $por ) as md5_".$por." FROM $tabla WHERE $campo = '$valor' $AND order by $campo DESC limit 1";
$consulta = "SELECT * , md5(binary $por ) as md5_".$por." FROM $tabla WHERE $campo = '$valor' $AND order by id DESC limit 1";
$sql=mysqli_query($consulta,$link);
if (@mysql_num_rows($sql)!=0){
$resultado[] = mysql_result($sql,0,$por);
$resultado[] = mysql_result($sql,0,'id');
$resultado[] = $consulta;
$resultado[] = mysql_result($sql,0,"md5_$por");
}else{
$resultado[0] = '';
$resultado[1] ="";
$resultado[2] = $consulta;
$resultado[3] = NULL;
}
return $resultado;
}
function grabar_imagen($imagen,$control) {
$imgData = str_replace(' ','+',$imagen);
$imgData = substr($imgData,strpos($imgData,",")+1);
$imgData = base64_decode($imgData);
$nombre= $control.".png";
$filePath = "$_SESSION[path]/tmp/".$nombre;
$file = fopen($filePath, 'w');
fwrite($file, $imgData);
fclose($file);
$full= "$_SESSION[path_images_secure]/full/".$nombre;
if (!rename($filePath,$full)){}
else {
echo generar_miniatura($nombre,"150");
echo generar_miniatura($nombre,"300");
echo generar_miniatura($nombre,"600");
}
//return "$nombre";
return "$nombre";
}
function generar_miniatura($file,$width) { //$archivo = $file;
$archivo = "$_SESSION[path_images_secure]/full/".$file; // Ponemos el . antes del nombre del archivo porque estamos considerando que la ruta está a partir del archivo thumb.php $file_info = getimagesize($archivo); // Obtenemos la relación de aspecto $ratio = $file_info[0] / $file_info[1]; // Calculamos las nuevas dimensiones $newwidth = $width; $newheight = round($newwidth / $ratio); // Sacamos la extensión del archivo $ext = explode(".", $file); $ext = strtolower($ext[count($ext) - 1]); if ($ext == "jpeg") $ext = "jpg"; // Dependiendo de la extensión llamamos a distintas funciones switch ($ext) { case "jpg": $img = imagecreatefromjpeg($archivo); break; case "png": $img = imagecreatefrompng($archivo); break; case "gif": $img = imagecreatefromgif($archivo); break; } // Creamos la miniatura $thumb = imagecreatetruecolor($newwidth, $newheight);
imagealphablending( $thumb, false );
imagesavealpha( $thumb, true ); // La redimensionamos imagecopyresampled($thumb, $img, 0, 0, 0, 0, $newwidth, $newheight, $file_info[0], $file_info[1]); // La mostramos como jpg //header("Content-type: image/jpeg"); imagejpeg($thumb,"$_SESSION[path_images_secure]/".$width."/$file", 80);
imagepng($thumb,"$_SESSION[path_images_secure]/".$width."/$file", 9);
//imagegif($thumb,"$_SESSION[path_images_secure]/".$width."/$file");
//imagejpeg($thumb,null, 80);
}
function buscar_campo_tipo($id,$tipo) {
//// esta función retorna el id para un campo de un tipo especifico dentro de un formulario.
$consulta ="SELECT form_campos.id, form_campos.campo_nombre FROM form_tipo_campo,form_campos,form_contenido_campos
WHERE form_tipo_campo.id_tipo_campo = form_campos.campo_tipo
AND form_contenido_campos.id_campo = form_campos.id
AND form_tipo_campo.id_tipo_campo = '$tipo'
AND form_contenido_campos.id_form = '$id'";
$link=Conectarse();
mysqli_query("SET NAMES 'utf8'");
$sql=mysqli_query($consulta,$link);
if (mysql_num_rows($sql)!='0'){
$resultado[0]=mysql_result($sql,0,"id");
$resultado[1]=mysql_result($sql,0,"campo_nombre");
$resultado[2] =$consulta;
}else{ $resultado[0]='';
$resultado[2] =$consulta;
}
return $resultado;
}
function obtener_ip()
{
if (isset($_SERVER["HTTP_CLIENT_IP"]))
{
return $_SERVER["HTTP_CLIENT_IP"];
}
elseif (isset($_SERVER["HTTP_X_FORWARDED_FOR"]))
{
return $_SERVER["HTTP_X_FORWARDED_FOR"];
}
elseif (isset($_SERVER["HTTP_X_FORWARDED"]))
{
return $_SERVER["HTTP_X_FORWARDED"];
}
elseif (isset($_SERVER["HTTP_FORWARDED_FOR"]))
{
return $_SERVER["HTTP_FORWARDED_FOR"];
}
elseif (isset($_SERVER["HTTP_FORWARDED"]))
{
return $_SERVER["HTTP_FORWARDED"];
}
else
{
return $_SERVER["REMOTE_ADDR"];
}
}
?>

Binary file not shown.

After

Width:  |  Height:  |  Size: 20 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 49 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 38 KiB

13
addon/brigada/js/demo.js Normal file
View File

@ -0,0 +1,13 @@
/*
* JavaScript Load Image Demo JS 1.9.1
* https://github.com/blueimp/JavaScript-Load-Image
*
* Copyright 2013, Sebastian Tschan
* https://blueimp.net
*
* Licensed under the MIT license:
* http://www.opensource.org/licenses/MIT
*/

View File

@ -0,0 +1,143 @@
/*
* JavaScript Load Image Meta 1.0.2
* https://github.com/blueimp/JavaScript-Load-Image
*
* Copyright 2013, Sebastian Tschan
* https://blueimp.net
*
* Image meta data handling implementation
* based on the help and contribution of
* Achim Stöhr.
*
* Licensed under the MIT license:
* http://www.opensource.org/licenses/MIT
*/
/*jslint continue:true */
/*global define, window, DataView, Blob, Uint8Array, console */
(function (factory) {
'use strict';
if (typeof define === 'function' && define.amd) {
// Register as an anonymous AMD module:
define(['load-image'], factory);
} else {
// Browser globals:
factory(window.loadImage);
}
}(function (loadImage) {
'use strict';
var hasblobSlice = window.Blob && (Blob.prototype.slice ||
Blob.prototype.webkitSlice || Blob.prototype.mozSlice);
loadImage.blobSlice = hasblobSlice && function () {
var slice = this.slice || this.webkitSlice || this.mozSlice;
return slice.apply(this, arguments);
};
loadImage.metaDataParsers = {
jpeg: {
0xffe1: [] // APP1 marker
}
};
// Parses image meta data and calls the callback with an object argument
// with the following properties:
// * imageHead: The complete image head as ArrayBuffer (Uint8Array for IE10)
// The options arguments accepts an object and supports the following properties:
// * maxMetaDataSize: Defines the maximum number of bytes to parse.
// * disableImageHead: Disables creating the imageHead property.
loadImage.parseMetaData = function (file, callback, options) {
options = options || {};
var that = this,
// 256 KiB should contain all EXIF/ICC/IPTC segments:
maxMetaDataSize = options.maxMetaDataSize || 262144,
data = {},
noMetaData = !(window.DataView && file && file.size >= 12 &&
file.type === 'image/jpeg' && loadImage.blobSlice);
if (noMetaData || !loadImage.readFile(
loadImage.blobSlice.call(file, 0, maxMetaDataSize),
function (e) {
if (e.target.error) {
// FileReader error
console.log(e.target.error);
callback(data);
return;
}
// Note on endianness:
// Since the marker and length bytes in JPEG files are always
// stored in big endian order, we can leave the endian parameter
// of the DataView methods undefined, defaulting to big endian.
var buffer = e.target.result,
dataView = new DataView(buffer),
offset = 2,
maxOffset = dataView.byteLength - 4,
headLength = offset,
markerBytes,
markerLength,
parsers,
i;
// Check for the JPEG marker (0xffd8):
if (dataView.getUint16(0) === 0xffd8) {
while (offset < maxOffset) {
markerBytes = dataView.getUint16(offset);
// Search for APPn (0xffeN) and COM (0xfffe) markers,
// which contain application-specific meta-data like
// Exif, ICC and IPTC data and text comments:
if ((markerBytes >= 0xffe0 && markerBytes <= 0xffef) ||
markerBytes === 0xfffe) {
// The marker bytes (2) are always followed by
// the length bytes (2), indicating the length of the
// marker segment, which includes the length bytes,
// but not the marker bytes, so we add 2:
markerLength = dataView.getUint16(offset + 2) + 2;
if (offset + markerLength > dataView.byteLength) {
console.log('Invalid meta data: Invalid segment size.');
break;
}
parsers = loadImage.metaDataParsers.jpeg[markerBytes];
if (parsers) {
for (i = 0; i < parsers.length; i += 1) {
parsers[i].call(
that,
dataView,
offset,
markerLength,
data,
options
);
}
}
offset += markerLength;
headLength = offset;
} else {
// Not an APPn or COM marker, probably safe to
// assume that this is the end of the meta data
break;
}
}
// Meta length must be longer than JPEG marker (2)
// plus APPn marker (2), followed by length bytes (2):
if (!options.disableImageHead && headLength > 6) {
if (buffer.slice) {
data.imageHead = buffer.slice(0, headLength);
} else {
// Workaround for IE10, which does not yet
// support ArrayBuffer.slice:
data.imageHead = new Uint8Array(buffer)
.subarray(0, headLength);
}
}
} else {
console.log('Invalid JPEG file: Missing JPEG marker.');
}
callback(data);
},
'readAsArrayBuffer'
)) {
callback(data);
}
};
}));

View File

@ -0,0 +1,166 @@
/*
* JavaScript Load Image Orientation 1.1.0
* https://github.com/blueimp/JavaScript-Load-Image
*
* Copyright 2013, Sebastian Tschan
* https://blueimp.net
*
* Licensed under the MIT license:
* http://www.opensource.org/licenses/MIT
*/
/*global define, window */
(function (factory) {
'use strict';
if (typeof define === 'function' && define.amd) {
// Register as an anonymous AMD module:
define(['load-image'], factory);
} else {
// Browser globals:
factory(window.loadImage);
}
}(function (loadImage) {
'use strict';
var originalHasCanvasOption = loadImage.hasCanvasOption,
originalTransformCoordinates = loadImage.transformCoordinates,
originalGetTransformedOptions = loadImage.getTransformedOptions;
// This method is used to determine if the target image
// should be a canvas element:
loadImage.hasCanvasOption = function (options) {
return originalHasCanvasOption.call(loadImage, options) ||
options.orientation;
};
// Transform image orientation based on
// the given EXIF orientation option:
loadImage.transformCoordinates = function (canvas, options) {
originalTransformCoordinates.call(loadImage, canvas, options);
var ctx = canvas.getContext('2d'),
width = canvas.width,
height = canvas.height,
orientation = options.orientation;
if (!orientation || orientation > 8) {
return;
}
if (orientation > 4) {
canvas.width = height;
canvas.height = width;
}
switch (orientation) {
case 2:
// horizontal flip
ctx.translate(width, 0);
ctx.scale(-1, 1);
break;
case 3:
// 180° rotate left
ctx.translate(width, height);
ctx.rotate(Math.PI);
break;
case 4:
// vertical flip
ctx.translate(0, height);
ctx.scale(1, -1);
break;
case 5:
// vertical flip + 90 rotate right
ctx.rotate(0.5 * Math.PI);
ctx.scale(1, -1);
break;
case 6:
// 90° rotate right
ctx.rotate(0.5 * Math.PI);
ctx.translate(0, -height);
break;
case 7:
// horizontal flip + 90 rotate right
ctx.rotate(0.5 * Math.PI);
ctx.translate(width, -height);
ctx.scale(-1, 1);
break;
case 8:
// 90° rotate left
ctx.rotate(-0.5 * Math.PI);
ctx.translate(-width, 0);
break;
}
};
// Transforms coordinate and dimension options
// based on the given orientation option:
loadImage.getTransformedOptions = function (img, opts) {
var options = originalGetTransformedOptions.call(loadImage, img, opts),
orientation = options.orientation,
newOptions,
i;
if (!orientation || orientation > 8 || orientation === 1) {
return options;
}
newOptions = {};
for (i in options) {
if (options.hasOwnProperty(i)) {
newOptions[i] = options[i];
}
}
switch (options.orientation) {
case 2:
// horizontal flip
newOptions.left = options.right;
newOptions.right = options.left;
break;
case 3:
// 180° rotate left
newOptions.left = options.right;
newOptions.top = options.bottom;
newOptions.right = options.left;
newOptions.bottom = options.top;
break;
case 4:
// vertical flip
newOptions.top = options.bottom;
newOptions.bottom = options.top;
break;
case 5:
// vertical flip + 90 rotate right
newOptions.left = options.top;
newOptions.top = options.left;
newOptions.right = options.bottom;
newOptions.bottom = options.right;
break;
case 6:
// 90° rotate right
newOptions.left = options.top;
newOptions.top = options.right;
newOptions.right = options.bottom;
newOptions.bottom = options.left;
break;
case 7:
// horizontal flip + 90 rotate right
newOptions.left = options.bottom;
newOptions.top = options.right;
newOptions.right = options.top;
newOptions.bottom = options.left;
break;
case 8:
// 90° rotate left
newOptions.left = options.bottom;
newOptions.top = options.left;
newOptions.right = options.top;
newOptions.bottom = options.right;
break;
}
if (options.orientation > 4) {
newOptions.maxWidth = options.maxHeight;
newOptions.maxHeight = options.maxWidth;
newOptions.minWidth = options.minHeight;
newOptions.minHeight = options.minWidth;
newOptions.sourceWidth = options.sourceHeight;
newOptions.sourceHeight = options.sourceWidth;
}
return newOptions;
};
}));

File diff suppressed because one or more lines are too long

View File

@ -0,0 +1,305 @@
/*
* JavaScript Load Image 1.10.0
* https://github.com/blueimp/JavaScript-Load-Image
*
* Copyright 2011, Sebastian Tschan
* https://blueimp.net
*
* Licensed under the MIT license:
* http://www.opensource.org/licenses/MIT
*/
/*jslint nomen: true */
/*global define, window, document, URL, webkitURL, Blob, File, FileReader */
(function ($) {
'use strict';
// Loads an image for a given File object.
// Invokes the callback with an img or optional canvas
// element (if supported by the browser) as parameter:
var loadImage = function (file, callback, options) {
var img = document.createElement('img'),
url,
oUrl;
//img.setAttribute('class', 'watermark');
// img.setAttribute('id', 'image_output2');
img.onerror = callback;
img.onload = function () {
if (oUrl && !(options && options.noRevoke)) {
loadImage.revokeObjectURL(oUrl);
}
if (callback) {
callback(loadImage.scale(img, options));
}
};
if (loadImage.isInstanceOf('Blob', file) ||
// Files are also Blob instances, but some browsers
// (Firefox 3.6) support the File API but not Blobs:
loadImage.isInstanceOf('File', file)) {
url = oUrl = loadImage.createObjectURL(file);
// Store the file type for resize processing:
img._type = file.type;
} else if (typeof file === 'string') {
url = file;
if (options && options.crossOrigin) {
img.crossOrigin = options.crossOrigin;
}
} else {
return false;
}
if (url) {
img.src = url;
//document.getElementById('image_output').src = url ;
//document.getElementById('image_output').className = "watermark" ;
return img;
}
return loadImage.readFile(file, function (e) {
var target = e.target;
if (target && target.result) {
img.src = target.result;
} else {
if (callback) {
callback(e);
}
}
});
},
// The check for URL.revokeObjectURL fixes an issue with Opera 12,
// which provides URL.createObjectURL but doesn't properly implement it:
urlAPI = (window.createObjectURL && window) ||
(window.URL && URL.revokeObjectURL && URL) ||
(window.webkitURL && webkitURL);
loadImage.isInstanceOf = function (type, obj) {
// Cross-frame instanceof check
return Object.prototype.toString.call(obj) === '[object ' + type + ']';
};
// Transform image coordinates, allows to override e.g.
// the canvas orientation based on the orientation option,
// gets canvas, options passed as arguments:
loadImage.transformCoordinates = function () {
return;
};
// Returns transformed options, allows to override e.g.
// maxWidth, maxHeight and crop options based on the aspectRatio.
// gets img, options passed as arguments:
loadImage.getTransformedOptions = function (img, options) {
var aspectRatio = options.aspectRatio,
newOptions,
i,
width,
height;
if (!aspectRatio) {
return options;
}
newOptions = {};
for (i in options) {
if (options.hasOwnProperty(i)) {
newOptions[i] = options[i];
}
}
newOptions.crop = true;
width = img.naturalWidth || img.width;
height = img.naturalHeight || img.height;
if (width / height > aspectRatio) {
newOptions.maxWidth = height * aspectRatio;
newOptions.maxHeight = height;
} else {
newOptions.maxWidth = width;
newOptions.maxHeight = width / aspectRatio;
}
return newOptions;
};
// Canvas render method, allows to override the
// rendering e.g. to work around issues on iOS:
loadImage.renderImageToCanvas = function (
canvas,
img,
sourceX,
sourceY,
sourceWidth,
sourceHeight,
destX,
destY,
destWidth,
destHeight
) {
canvas.getContext('2d').drawImage(
img,
sourceX,
sourceY,
sourceWidth,
sourceHeight,
destX,
destY,
destWidth,
destHeight
);
return canvas;
};
// This method is used to determine if the target image
// should be a canvas element:
loadImage.hasCanvasOption = function (options) {
return options.canvas || options.crop || options.aspectRatio;
};
// Scales and/or crops the given image (img or canvas HTML element)
// using the given options.
// Returns a canvas object if the browser supports canvas
// and the hasCanvasOption method returns true or a canvas
// object is passed as image, else the scaled image:
loadImage.scale = function (img, options) {
options = options || {};
var canvas = document.createElement('canvas'),
useCanvas = img.getContext ||
(loadImage.hasCanvasOption(options) && canvas.getContext),
width = img.naturalWidth || img.width,
height = img.naturalHeight || img.height,
destWidth = width,
destHeight = height,
maxWidth,
maxHeight,
minWidth,
minHeight,
sourceWidth,
sourceHeight,
sourceX,
sourceY,
tmp,
scaleUp = function () {
var scale = Math.max(
(minWidth || destWidth) / destWidth,
(minHeight || destHeight) / destHeight
);
if (scale > 1) {
destWidth = destWidth * scale;
destHeight = destHeight * scale;
}
},
scaleDown = function () {
var scale = Math.min(
(maxWidth || destWidth) / destWidth,
(maxHeight || destHeight) / destHeight
);
if (scale < 1) {
destWidth = destWidth * scale;
destHeight = destHeight * scale;
}
};
if (useCanvas) {
options = loadImage.getTransformedOptions(img, options);
sourceX = options.left || 0;
sourceY = options.top || 0;
if (options.sourceWidth) {
sourceWidth = options.sourceWidth;
if (options.right !== undefined && options.left === undefined) {
sourceX = width - sourceWidth - options.right;
}
} else {
sourceWidth = width - sourceX - (options.right || 0);
}
if (options.sourceHeight) {
sourceHeight = options.sourceHeight;
if (options.bottom !== undefined && options.top === undefined) {
sourceY = height - sourceHeight - options.bottom;
}
} else {
sourceHeight = height - sourceY - (options.bottom || 0);
}
destWidth = sourceWidth;
destHeight = sourceHeight;
}
maxWidth = options.maxWidth;
maxHeight = options.maxHeight;
minWidth = options.minWidth;
minHeight = options.minHeight;
if (useCanvas && maxWidth && maxHeight && options.crop) {
destWidth = maxWidth;
destHeight = maxHeight;
tmp = sourceWidth / sourceHeight - maxWidth / maxHeight;
if (tmp < 0) {
sourceHeight = maxHeight * sourceWidth / maxWidth;
if (options.top === undefined && options.bottom === undefined) {
sourceY = (height - sourceHeight) / 2;
}
} else if (tmp > 0) {
sourceWidth = maxWidth * sourceHeight / maxHeight;
if (options.left === undefined && options.right === undefined) {
sourceX = (width - sourceWidth) / 2;
}
}
} else {
if (options.contain || options.cover) {
minWidth = maxWidth = maxWidth || minWidth;
minHeight = maxHeight = maxHeight || minHeight;
}
if (options.cover) {
scaleDown();
scaleUp();
} else {
scaleUp();
scaleDown();
}
}
if (useCanvas) {
canvas.width = destWidth;
canvas.height = destHeight;
loadImage.transformCoordinates(
canvas,
options
);
return loadImage.renderImageToCanvas(
canvas,
img,
sourceX,
sourceY,
sourceWidth,
sourceHeight,
0,
0,
destWidth,
destHeight
);
}
img.width = destWidth;
img.height = destHeight;
return img;
};
loadImage.createObjectURL = function (file) {
return urlAPI ? urlAPI.createObjectURL(file) : false;
};
loadImage.revokeObjectURL = function (url) {
return urlAPI ? urlAPI.revokeObjectURL(url) : false;
};
// Loads a given File object via FileReader interface,
// invokes the callback with the event object (load or error).
// The result can be read via event.target.result:
loadImage.readFile = function (file, callback, method) {
if (window.FileReader) {
var fileReader = new FileReader();
fileReader.onload = fileReader.onerror = callback;
method = method || 'readAsDataURL';
if (fileReader[method]) {
fileReader[method](file);
return fileReader;
}
}
return false;
};
if (typeof define === 'function' && define.amd) {
define(function () {
return loadImage;
});
} else {
$.loadImage = loadImage;
}
}(window));

363
addon/brigada/logis.php Normal file
View File

@ -0,0 +1,363 @@
<?php
//include("funciones/funciones.php");
$id_formulario = "58";
$ancho = "600";
$tags = array();
$tags[] = "milfs/addon/logis/images/logos/250.png";
$imagen="";
foreach ($tags as &$valor) {
$imagen .= "<td onclick=\" document.getElementById('marca').src='$valor' ; marcar('top-left') \" ><a href='#medio' class='' >
<img class='img ' src='$valor'>
</a></td>";
}
$imagen = "
<div class='table-responsive'>
<table class='table table table-condensed text-center '>
<tr >
$imagen
</tr>
</table>
</div>";
?>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js"></script>
<div>
<style type="text/css">
.fa{
font-size:60px important!;
}
#imagen_origina{
width: <?echo $ancho ?>px;
}
body{
background-color:white !important;
}
.pin {
text-align: center;
/*border: solid 1px red;*/
opacity: 0.5;
}
.fileUpload {
position: relative;
overflow: hidden;
margin: 10px;
width: 80%;
}
.fileUpload input.upload {
position: absolute;
top: 0;
right: 0;
margin: 10;
padding: 0;
font-size: 50px;
cursor: pointer;
opacity: 0;
filter: alpha(opacity=0);
}
.ing-touch{
border: solid 5px white;
width:20% !important;
}
</style>
<div class='container' style='height:100%; backgroun-color:white;' id='aviso'>
<div class='fileUpload btn btn-primary center-block'>
<span><h1><i class="fa fa-camera"></i> + tu Foto</h1></span>
<input class='upload' type="file" id="file-input" /></span>
<div id="original" ></div>
</div>
<!-- <p><input type="file" id="file-input"></p> -->
<div id="actions" style="display:none;">
<img class="center-block" src= "<?php echo $tags[0]; ?>" style='display:none' id="marca" name="marca">
<img class="center-block" style='' id="image_output" name="image_output">
<img class="center-block" style='' id="otra_imagen" name="otra_imagen">
<div id="result" class="result">
<p></p>
</div>
<a name="arriba"></a>
<canvas id="micanvasOriginal" style="position:absolute" >
Tu navegador no soporta canvas.
</canvas>
<div style="position:relative">
<div style="position:absolute; width:100%; height:100%;" >
<table style="width:100%; height:100%;" class="">
<tr >
<td class="pin" ><a href="#arriba" onclick=" javascript: marcar('top-left')"><img class="ing-touch img img-circle img-responsive center-block " style="width:20%;" src="milfs/images/oscuro40.png"></a></td>
<td class="pin"><a href="#arriba" onclick=" javascript: marcar('top-center')"><img class="ing-touch img img-circle img-responsive center-block " style="width:20%;" src="milfs/images/oscuro40.png"></a></td>
<td class="pin"><a href="#arriba" onclick=" javascript: marcar('top-rigth')"><img class="ing-touch img img-circle img-responsive center-block " style="width:50%;" src="milfs/images/oscuro40.png"></a></td>
</tr>
<tr>
<td class="pin"><a name="medio"></a><a href="#arriba" onclick=" javascript: marcar('middle-left')"><img class="ing-touch img img-circle img-responsive center-block " style="width:50%;" src="milfs/images/oscuro40.png"></a></td>
<td class="pin" ><a href="#medio" onclick=" javascript: marcar('middle-center')"><img class="ing-touch img img-circle img-responsive center-block " style="width:50%;" src="milfs/images/oscuro40.png"></a></td>
<td class="pin"><a href="#medio" onclick=" javascript: marcar('middle-rigth')"><img class="ing-touch img img-circle img-responsive center-block " style="width:50%;" src="milfs/images/oscuro40.png"></td>
</tr>
<tr>
<td class="pin"><a href="#medio" onclick=" javascript: marcar('bottom-left')"><img class="ing-touch img img-circle img-responsive center-block " style="width:50%;" src="milfs/images/oscuro40.png"></a></td>
<td class="pin"><a href="#medio" onclick=" javascript: marcar('bottom-center')"><img class="ing-touch img img-circle img-responsive center-block " style="width:50%;" src="milfs/images/oscuro40.png"></a></td>
<td class="pin"><a href="#medio" onclick=" javascript: marcar('bottom-rigth')"><img class="ing-touch img img-circle img-responsive center-block " style="width:50%;" src="milfs/images/oscuro40.png"></a></td>
</tr>
</table>
</div>
<canvas id="micanvas" style="position:absolute" >
Tu navegador no soporta canvas.
</canvas>
</div>
<div class="row " style="position:relative">
<form id='formulario_brigadistas' name='formulario_brigadistas' >
<!-- <input class='form-control' type='' id="debugConsole" name="debugConsole" > -->
<textarea class='form-control' id="debugConsole" name="debugConsole" style="display:none;" ></textarea>
<input type='hidden' id="identificador" name="identificador" >
<input type='hidden' id="formulario_id" name="formulario_id" value="<?php echo $id_formulario; ?>">
<input type='hidden' id="imagen" name="imagen" value="">
<?php $formulario = formulario_areas("$id_formulario",'campos','','');
echo $formulario; ?>
</form>
</div>
<!-- <div id='aviso'></div> -->
<div class="row">
<div class="col-md-12">
<!-- this.disabled= true; xajax_wait('aviso','Grabando... un momento por favor...'); xajax_brigadistas_grabar(xajax.getFormValues('formulario_brigadistas')) -->
<!-- <button class='fileUpload btn btn-success btn-block' onclick="document.getElementById('formulario_brigadistas').submit(); "> -->
<button class='fileUpload btn btn-success btn-block' onclick=" xajax_wait('aviso','Grabando... un momento por favor...'); xajax_brigadistas_grabar(xajax.getFormValues('formulario_brigadistas')) ; ">
<span><i class="fa fa-save"></i> <span class='fa'> Grabalo! </span></span>
</button>
</div>
</div>
</div>
<?php $ultimo = formulario_uso("$id_formulario",'','ultimo') ;
//echo $ultimo[1];
echo mostrar_identificador("$ultimo[1]","","landingpage",'simple');
?>
</div>
<script language="javascript">
function cargaContextoCanvas(idCanvas){
var elemento = document.getElementById(idCanvas);
if(elemento && elemento.getContext){
var contexto = elemento.getContext('2d');
if(contexto){
return contexto;
}
}
return FALSE;
}
function marcar(ubicacion){
//if (ubicacion == 'arriba'){ var x = '0';var y = '0';}
//if (ubicacion == 'abajo'){ var x = '10';var y = '50';}
//Recibimos el elemento canvas
var ctx = cargaContextoCanvas('micanvas');
if(ctx){
//Creo una imagen conun objeto Image de Javascript
var img = new Image();
var img2 = new Image();
//img.src = document.getElementById("image_output2").src;
//readAsDataURL(
img.src = document.getElementById("imagen_original").src;
document.getElementById("imagen_original").style.display="none";
//img2.src = 'images/logos/a.png';
img2.src = document.getElementById("marca").src;
if (ubicacion =='') {
ubicacion ='middle-center';
}
x = 0,
y = 0;
if(ubicacion.indexOf("top")!=-1)
y = 10;
else if(ubicacion.indexOf("middle")!=-1)
y = (micanvas.height - img2.height)/2;
else
y = micanvas.height-img2.height-10;
if(ubicacion.indexOf("left")!=-1)
x = 10;
else if(ubicacion.indexOf("center")!=-1)
x = (micanvas.width - img2.width) /2;
else
x = micanvas.width-img2.width-10;
var proporcion = ( img.height / img.width );
var ancho = <?echo $ancho ?>;
micanvas.width =ancho;
micanvas.height = (micanvas.width * proporcion);
micanvas.setAttribute('width', ancho);
micanvas.setAttribute('height', micanvas.height);
micanvas.setAttribute('style',"width:100%");
img.onload = function(){
ctx.drawImage(img, 0, 0,micanvas.width,micanvas.height);
ctx.drawImage(img2, x, y);
var debugConsole= document.getElementById("debugConsole");
var testCanvas = document.getElementById("micanvas");
var canvasData = testCanvas.toDataURL("image/png");
var postData = "canvasData="+canvasData;
debugConsole.value=canvasData;
var identificador = Math.random();
document.getElementById('identificador').value= identificador;
}
}
}
$(function () {
'use strict';
var result = $('#result'),
exifNode = $('#exif'),
thumbNode = $('#thumbnail'),
actionsNode = $('#actions'),
currentFile,
replaceResults = function (img) {
var content;
if (!(img.src || img instanceof HTMLCanvasElement)) {
content = $('<span>Loading image file failed</span>');
} else {
content = $('<img />').append(img)
//.attr('download', currentFile.name)
.attr('src', img.src || img.toDataURL())
.attr('width', '<?echo $ancho ?>')
.attr('style', 'width:100%')
.attr('id', 'imagen_original');
}
//document.getElementById('image_output').src = img.src;
result.children().replaceWith(content);
if (img.getContext) {
actionsNode.show();
/// render(img.src);
window.setTimeout("marcar('middle-center');", 500);
}
},
displayImage = function (file, options) {
currentFile = file;
if (!loadImage(
file,
replaceResults,
options
)) {
result.children().replaceWith(
$('<span>Your browser does not support the URL or FileReader API.</span>')
);
}
},
dropChangeHandler = function (e) {
e.preventDefault();
e = e.originalEvent;
var target = e.dataTransfer || e.target,
file = target && target.files && target.files[0],
options = {
//maxWidth: result.width(),
maxWidth: <?echo $ancho ?>,
canvas: true
};
if (!file) {
return;
}
exifNode.hide();
thumbNode.hide();
loadImage.parseMetaData(file, function (data) {
if (data.exif) {
options.orientation = data.exif.get('Orientation');
// displayExifData(data.exif);
}
displayImage(file, options);
});
},
coordinates;
// Hide URL/FileReader API requirement message in capable browsers:
if (window.createObjectURL || window.URL || window.webkitURL || window.FileReader) {
result.children().hide();
}
$(document)
.on('dragover', function (e) {
e.preventDefault();
e = e.originalEvent;
e.dataTransfer.dropEffect = 'copy';
})
.on('drop', dropChangeHandler);
$('#file-input').on('change', dropChangeHandler);
$('#edit').on('click', function (event) {
event.preventDefault();
var imgNode = result.find('img, canvas'),
img = imgNode[0];
imgNode.Jcrop({
setSelect: [40, 40, img.width - 40, img.height - 40],
onSelect: function (coords) {
coordinates = coords;
},
onRelease: function () {
coordinates = null;
}
}).parent().on('click', function (event) {
event.preventDefault();
});
});
$('#crop').on('click', function (event) {
event.preventDefault();
var img = result.find('img, canvas')[0];
if (img && coordinates) {
replaceResults(loadImage.scale(img, {
left: coordinates.x,
top: coordinates.y,
sourceWidth: coordinates.w,
sourceHeight: coordinates.h,
minWidth: result.width()
}));
coordinates = null;
}
});
});
</script>
<br>
<script src="milfs/addon/logis/js/load-image.all.min.js"></script>
<!-- <script src="js/load-image.js"></script> -->
<!-- <script src="js/load-image-ios.js"></script> -->
<!-- <script src="js/load-image-orientation.js"></script> -->
<!-- <script src="js/load-image-meta.js"></script> -->
<!-- <script src="js/load-image-exif.js"></script> -->
<!-- <script src="js/load-image-exif-map.js"></script> -->
<!-- jQuery and Jcrop are not required by JavaScript Load Image, but included for the demo -->
<!-- <script src="//ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js"></script> -->
<!-- <script src="js/vendor/jquery.Jcrop.js"></script> -->
<!-- <script src="js/demo.js"></script> -->
</div>

207
addon/brigada/logis.php.php Normal file
View File

@ -0,0 +1,207 @@
<?php
//include("funciones/funciones.php");
$id_formulario = "58";
$ancho = "600";
$tags = array();
$tags[] = "images/logos/c.png";
foreach ($tags as &$valor) {
$imagen .= "<td onclick=\" document.getElementById('marca').src='$valor' ; marcar('top-left') \" ><a href='#medio' class='' >
<img class='img ' src='$valor'>
</a></td>";
}
$imagen = "
<div class='table-responsive'>
<table class='table table table-condensed text-center '>
<tr >
$imagen
</tr>
</table>
</div>";
?>
<html lang="en">
<head>
<!--[if IE]>
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
<![endif]-->
<meta charset="utf-8">
<title></title>
<meta name="description" content="JavaScript Load Image is a library to load images provided as File or Blob objects or via URL. It returns an optionally scaled and/or cropped HTML img or canvas element. It also provides a method to parse image meta data to extract Exif tags and thumbnails and to restore the complete image header after resizing.">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<!-- Jcrop is not required by JavaScript Load Image, but included for the demo -->
<!-- <link rel="stylesheet" href="css/vendor/jquery.Jcrop.css"> -->
<!-- <link rel="stylesheet" href="css/demo.css"> -->
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/font-awesome/4.5.0/css/font-awesome.min.css">
<!-- Latest compiled and minified CSS -->
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css" integrity="sha384-1q8mTJOASx8j1Au+a5WDVnPi2lkFfwwEAa8hDDdjZlpLegxhjVME1fgjWPGmkzs7" crossorigin="anonymous">
<style type="text/css">
.fa{
font-size:60px;
}
#imagen_origina{
width: 800px;
}
.pin {
text-align: center;
border: solid 1px red;
opacity: 0.5;
}
.fileUpload {
position: relative;
overflow: hidden;
margin: 10px;
width: 80%;
}
.fileUpload input.upload {
position: absolute;
top: 0;
right: 0;
margin: 10;
padding: 0;
font-size: 50px;
cursor: pointer;
opacity: 0;
filter: alpha(opacity=0);
}
</style>
</head>
<body>
<div class='container'>
<div class='fileUpload btn btn-primary '>
<span> <i class="fa fa-picture-o"></i> <span class='fa' > Imagen <i class="fa fa-camera"></i> </span>
<input class='upload' type="file" id="file-input" /></span>
<div id="original" ></div>
</div>
</div>
<!-- <p><input type="file" id="file-input"></p> -->
<div id="actions" style="display:none;">
<img class="center-block" src= "<?php echo $tags[0]; ?>" style='display:none' id="marca" name="marca">
<img class="center-block" style='' id="image_output" name="image_output">
<img class="center-block" style='' id="otra_imagen" name="otra_imagen">
<input type="hidden" id='identificador' name='identificador'>
<div id="result" class="result">
<p></p>
</div>
<a name="arriba"></a>
<div style="position:relative">
<div style="position:absolute; width:100%; height:100%;" >
<table style="width:100%; height:100%;" class="">
<tr >
<td class="pin"><a href="#arriba" onclick=" javascript: marcar('top-left')"><i class="fa fa-circle-o"></i></a></td>
<td class="pin"><a href="#arriba" onclick=" javascript: marcar('top-center')"><i class="fa fa-circle-o"></i></a></td>
<td class="pin"><a href="#arriba" onclick=" javascript: marcar('top-rigth')"><i class="fa fa-circle-o"></i></a></td>
</tr>
<tr>
<td class="pin"><a name="medio"></a><a href="#arriba" onclick=" javascript: marcar('middle-left')"><i class="fa fa-circle-o"></i></a></td>
<td class="pin"><a href="#medio" onclick=" javascript: marcar('middle-center')"><i class="fa fa-circle-o"></i></a></td>
<td class="pin"><a href="#medio" onclick=" javascript: marcar('middle-rigth')"><i class="fa fa-circle-o"></i></td>
</tr>
<tr>
<td class="pin"><a href="#medio" onclick=" javascript: marcar('bottom-left')"><i class="fa fa-circle-o"></i></a></td>
<td class="pin"><a href="#medio" onclick=" javascript: marcar('bottom-center')"><i class="fa fa-circle-o"></i></a></td>
<td class="pin"><a href="#medio" onclick=" javascript: marcar('bottom-rigth')"><i class="fa fa-circle-o"></i></a></td>
</tr>
</table>
</div>
<canvas id="micanvas" style="position:absolute" >
Tu navegador no soporta canvas.
</canvas>
</div>
</div>
<script language="javascript">
function cargaContextoCanvas(idCanvas){
var elemento = document.getElementById(idCanvas);
if(elemento && elemento.getContext){
var contexto = elemento.getContext('2d');
if(contexto){
return contexto;
}
}
return FALSE;
}
function marcar(ubicacion){
//if (ubicacion == 'arriba'){ var x = '0';var y = '0';}
//if (ubicacion == 'abajo'){ var x = '10';var y = '50';}
//Recibimos el elemento canvas
var ctx = cargaContextoCanvas('micanvas');
if(ctx){
//Creo una imagen conun objeto Image de Javascript
var img = new Image();
var img2 = new Image();
//img.src = document.getElementById("image_output2").src;
//readAsDataURL(
img.src = document.getElementById("imagen_original").src;
document.getElementById("imagen_original").style.display="none";
//img2.src = 'images/logos/a.png';
img2.src = document.getElementById("marca").src;
if (ubicacion =='') {
ubicacion ='middle-center';
}
x = 0,
y = 0;
if(ubicacion.indexOf("top")!=-1)
y = 10;
else if(ubicacion.indexOf("middle")!=-1)
y = (micanvas.height - img2.height)/2;
else
y = micanvas.height-img2.height-10;
if(ubicacion.indexOf("left")!=-1)
x = 10;
else if(ubicacion.indexOf("center")!=-1)
x = (micanvas.width - img2.width) /2;
else
x = micanvas.width-img2.width-10;
var proporcion = ( img.height / img.width );
var ancho = 800;
micanvas.width = ancho;
micanvas.height = (micanvas.width * proporcion);
micanvas.setAttribute('width', ancho);
micanvas.setAttribute('height', micanvas.height);
micanvas.setAttribute('style',"width:100%");
img.onload = function(){
ctx.drawImage(img, 0, 0,micanvas.width,micanvas.height);
ctx.drawImage(img2, x, y);
var identificador = Math.random();
document.getElementById('identificador').value= identificador;
}
}
}
</script>
<br>
<script src="js/load-image.all.min.js"></script>
<!-- <script src="js/load-image.js"></script> -->
<!-- <script src="js/load-image-ios.js"></script> -->
<!-- <script src="js/load-image-orientation.js"></script> -->
<!-- <script src="js/load-image-meta.js"></script> -->
<!-- <script src="js/load-image-exif.js"></script> -->
<!-- <script src="js/load-image-exif-map.js"></script> -->
<!-- jQuery and Jcrop are not required by JavaScript Load Image, but included for the demo -->
<script src="//ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js"></script>
<!-- <script src="js/vendor/jquery.Jcrop.js"></script> -->
<script src="js/demo.js"></script>
</body>
</html>

View File

@ -0,0 +1,207 @@
<?php
//include("funciones/funciones.php");
$id_formulario = "58";
$ancho = "600";
$tags = array();
$tags[] = "images/logos/c.png";
foreach ($tags as &$valor) {
$imagen .= "<td onclick=\" document.getElementById('marca').src='$valor' ; marcar('top-left') \" ><a href='#medio' class='' >
<img class='img ' src='$valor'>
</a></td>";
}
$imagen = "
<div class='table-responsive'>
<table class='table table table-condensed text-center '>
<tr >
$imagen
</tr>
</table>
</div>";
?>
<!DOCTYPE HTML>
<html lang="en">
<head>
<!--[if IE]>
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
<![endif]-->
<meta charset="utf-8">
<title></title>
<meta name="description" content="JavaScript Load Image is a library to load images provided as File or Blob objects or via URL. It returns an optionally scaled and/or cropped HTML img or canvas element. It also provides a method to parse image meta data to extract Exif tags and thumbnails and to restore the complete image header after resizing.">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<!-- Jcrop is not required by JavaScript Load Image, but included for the demo -->
<!-- <link rel="stylesheet" href="css/vendor/jquery.Jcrop.css"> -->
<!-- <link rel="stylesheet" href="css/demo.css"> -->
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/font-awesome/4.5.0/css/font-awesome.min.css">
<!-- Latest compiled and minified CSS -->
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css" integrity="sha384-1q8mTJOASx8j1Au+a5WDVnPi2lkFfwwEAa8hDDdjZlpLegxhjVME1fgjWPGmkzs7" crossorigin="anonymous">
<style type="text/css">
.fa{
font-size:60px;
}
#imagen_origina{
width: 800px;
}
.pin {
text-align: center;
border: solid 1px red;
opacity: 0.5;
}
.fileUpload {
position: relative;
overflow: hidden;
margin: 10px;
width: 80%;
}
.fileUpload input.upload {
position: absolute;
top: 0;
right: 0;
margin: 10;
padding: 0;
font-size: 50px;
cursor: pointer;
opacity: 0;
filter: alpha(opacity=0);
}
</style>
</head>
<body>
<div class='container'>
<div class='fileUpload btn btn-primary '>
<span> <i class="fa fa-picture-o"></i> <span class='fa' > Imagen <i class="fa fa-camera"></i> </span>
<input class='upload' type="file" id="file-input" /></span>
<div id="original" ></div>
</div>
</div>
<!-- <p><input type="file" id="file-input"></p> -->
<div id="actions" style="display:none;">
<img class="center-block" src= "<?php echo $tags[0]; ?>" style='display:none' id="marca" name="marca">
<img class="center-block" style='' id="image_output" name="image_output">
<img class="center-block" style='' id="otra_imagen" name="otra_imagen">
<input type="hidden" id='identificador' name='identificador'>
<div id="result" class="result">
<p></p>
</div>
<a name="arriba"></a>
<div style="position:relative">
<div style="position:absolute; width:100%; height:100%;" >
<table style="width:100%; height:100%;" class="">
<tr >
<td class="pin"><a href="#arriba" onclick=" javascript: marcar('top-left')"><i class="fa fa-circle-o"></i></a></td>
<td class="pin"><a href="#arriba" onclick=" javascript: marcar('top-center')"><i class="fa fa-circle-o"></i></a></td>
<td class="pin"><a href="#arriba" onclick=" javascript: marcar('top-rigth')"><i class="fa fa-circle-o"></i></a></td>
</tr>
<tr>
<td class="pin"><a name="medio"></a><a href="#arriba" onclick=" javascript: marcar('middle-left')"><i class="fa fa-circle-o"></i></a></td>
<td class="pin"><a href="#medio" onclick=" javascript: marcar('middle-center')"><i class="fa fa-circle-o"></i></a></td>
<td class="pin"><a href="#medio" onclick=" javascript: marcar('middle-rigth')"><i class="fa fa-circle-o"></i></td>
</tr>
<tr>
<td class="pin"><a href="#medio" onclick=" javascript: marcar('bottom-left')"><i class="fa fa-circle-o"></i></a></td>
<td class="pin"><a href="#medio" onclick=" javascript: marcar('bottom-center')"><i class="fa fa-circle-o"></i></a></td>
<td class="pin"><a href="#medio" onclick=" javascript: marcar('bottom-rigth')"><i class="fa fa-circle-o"></i></a></td>
</tr>
</table>
</div>
<canvas id="micanvas" style="position:absolute" >
Tu navegador no soporta canvas.
</canvas>
</div>
</div>
<script language="javascript">
function cargaContextoCanvas(idCanvas){
var elemento = document.getElementById(idCanvas);
if(elemento && elemento.getContext){
var contexto = elemento.getContext('2d');
if(contexto){
return contexto;
}
}
return FALSE;
}
function marcar(ubicacion){
//if (ubicacion == 'arriba'){ var x = '0';var y = '0';}
//if (ubicacion == 'abajo'){ var x = '10';var y = '50';}
//Recibimos el elemento canvas
var ctx = cargaContextoCanvas('micanvas');
if(ctx){
//Creo una imagen conun objeto Image de Javascript
var img = new Image();
var img2 = new Image();
//img.src = document.getElementById("image_output2").src;
//readAsDataURL(
img.src = document.getElementById("imagen_original").src;
document.getElementById("imagen_original").style.display="none";
//img2.src = 'images/logos/a.png';
img2.src = document.getElementById("marca").src;
if (ubicacion =='') {
ubicacion ='middle-center';
}
x = 0,
y = 0;
if(ubicacion.indexOf("top")!=-1)
y = 10;
else if(ubicacion.indexOf("middle")!=-1)
y = (micanvas.height - img2.height)/2;
else
y = micanvas.height-img2.height-10;
if(ubicacion.indexOf("left")!=-1)
x = 10;
else if(ubicacion.indexOf("center")!=-1)
x = (micanvas.width - img2.width) /2;
else
x = micanvas.width-img2.width-10;
var proporcion = ( img.height / img.width );
var ancho = 800;
micanvas.width = ancho;
micanvas.height = (micanvas.width * proporcion);
micanvas.setAttribute('width', ancho);
micanvas.setAttribute('height', micanvas.height);
micanvas.setAttribute('style',"width:100%");
img.onload = function(){
ctx.drawImage(img, 0, 0,micanvas.width,micanvas.height);
ctx.drawImage(img2, x, y);
var identificador = Math.random();
document.getElementById('identificador').value= identificador;
}
}
}
</script>
<br>
<script src="js/load-image.all.min.js"></script>
<!-- <script src="js/load-image.js"></script> -->
<!-- <script src="js/load-image-ios.js"></script> -->
<!-- <script src="js/load-image-orientation.js"></script> -->
<!-- <script src="js/load-image-meta.js"></script> -->
<!-- <script src="js/load-image-exif.js"></script> -->
<!-- <script src="js/load-image-exif-map.js"></script> -->
<!-- jQuery and Jcrop are not required by JavaScript Load Image, but included for the demo -->
<script src="//ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js"></script>
<!-- <script src="js/vendor/jquery.Jcrop.js"></script> -->
<script src="js/demo.js"></script>
</body>
</html>

View File

@ -0,0 +1,436 @@
<?php
//include("funciones/funciones.php");
$id_formulario = "58";
$ancho = "600";
$tags = array();
$tags[] = "milfs/addon/brigadistas/images/logos/a.png";
$tags[] = "milfs/addon/brigadistas/images/logos/b.png";
$tags[] = "milfs/addon/brigadistas/images/logos/c.png";
foreach ($tags as &$valor) {
$imagen .= "<td><a href='#medio' class='' onclick=\" document.getElementById('marca').src='$valor' \" >
<img class='img ' src='$valor'>
</a></td>";
}
$imagen = "
<div class='table-responsive'>
<table class='table table table-condensed text-center '>
<tr>
$imagen
</tr>
</table>
</div>";
?>
<script src="https://9b8d22ae00fff2954b7cdd00a6feb4176bc56576.googledrive.com/host/0B7R2T-U-1ZrheTlfaHNQMm0zTWM/plump_modernizr.js"></script>
<link rel="stylesheet" media="screen" href="https://fontlibrary.org/face/cabin" type="text/css"/>
<style type="text/css">
body {
font-family: 'CabinRegular';
font-weight: normal;
font-style: normal;
}
.fileUpload {
position: relative;
overflow: hidden;
margin: 10px;
}
.fileUpload input.upload {
position: absolute;
top: 0;
right: 0;
margin: 10;
padding: 0;
font-size: 50px;
cursor: pointer;
opacity: 0;
filter: alpha(opacity=0);
}
.fa{
font-size:60px;
}
#downlink_hidden , #fieldset_General , #canvas_ed , #original{
display:none;
}
#body{
background-color: white;
}
#aviso{
background-color: gray;
width: 100%;
}
</style>
<div id='aviso'>
<div id ="body" class="container" >
<div id="div_brigadistas" class="">
<span class='btn btn-primary btn-block' > <!-- <i class="fa fa-picture-o"></i> --> <span class='fa' > Elige un Logo </span></span>
<?php echo $imagen; ?>
<a name="medio"></a>
<div class="row">
<div class="col-md-12">
<div class='fileUpload btn btn-primary btn-block'>
<span> <i class="fa fa-picture-o"></i> <span class='fa' > Sube una imágen</span>
<input class='upload' type="file" id="files" name="files[]" /></span>
<div id="original" ></div>
</div>
</div>
</div>
<a name="abajo"></a>
<div class="row">
<div class="col-md-12">
<div class='container-fluid'>
<table style="" class="table text-center table-responsive">
<tr>
<td><a href="#abajo" onclick=" javascript: marcar('top-left')"><i class="fa fa-caret-square-o-left"></i></a></td>
<td><a href="#abajo" onclick=" javascript: marcar('top-center')"><i class="fa fa-caret-square-o-up"></i></a></td>
<td><a href="#abajo" onclick=" javascript: marcar('top-rigth')"><i class="fa fa-caret-square-o-right"></i></a></td>
</tr>
<tr>
<td><a href="#abajo" onclick=" javascript: marcar('middle-left')"><i class="fa fa-caret-square-o-left"></i></a></td>
<td><a href="#abajo" onclick=" javascript: marcar('middle-center')"><i class="fa fa-circle-o"></i></a></td>
<td><a href="#abajo" onclick=" javascript: marcar('middle-rigth')"><i class="fa fa-caret-square-o-right"></i></td>
</tr>
<tr>
<td><a href="#abajo" onclick=" javascript: marcar('bottom-left')"><i class="fa fa-caret-square-o-left"></i></a></td>
<td><a href="#abajo" onclick=" javascript: marcar('bottom-center')"><i class="fa fa-caret-square-o-down"></i></a></td>
<td><a href="#abajo" onclick=" javascript: marcar('bottom-rigth')"><i class="fa fa-caret-square-o-right"></i></a></td>
</tr>
</table>
</div>
</div>
</div>
<!-- editor -->
<div class='container-fluid'>
<div style="background-color:; " >
<img class="center-block" style='' id="marca" name="marca">
<div id="list" style=" "></div>
<img id='image_output2' name='image_output2' src="" class="" />
<div id='div_canvas' style='display: none'> </div>
</div>
</div>
<div class="row">
<form id='formulario_brigadistas' name='formulario_brigadistas' >
<input type='hidden' id="debugConsole" name="debugConsole" >
<input type='hidden' id="identificador" name="identificador" >
<input type='hidden' id="formulario_id" name="formulario_id" value="<?php echo $id_formulario; ?>">
<input type='hidden' id="imagen" name="imagen" value="">
<?php $formulario = formulario_areas("$id_formulario",'campos','','');
echo $formulario; ?>
</form>
</div>
<div class="row">
<div class="col-md-12">
<!-- -->
<button class='fileUpload btn btn-success btn-block' onclick=" this.disabled= true; xajax_wait('aviso','Grabando... un momento por favor...'); saveViaAJAX(); xajax_brigadistas_grabar(xajax.getFormValues('formulario_brigadistas'))">
<span><i class="fa fa-save"></i> <span class='fa'> Grabalo! </span></span>
</button>
</div>
</div>
</div><!-- fin aviso -->
</div>
</div>
<script type="text/javascript">
function convertImageToCanvas(i, image) {
var canvas = document.createElement("canvas");
canvas.width = image.width;
canvas.height = image.height;
var ctx = canvas.getContext("2d");
ctx.drawImage(image, 0, 0);
$("body").append(canvas);
};
function convertImageToCanvas(image) {
var canvas = document.createElement("canvas");
canvas.width = image.width;
canvas.height = image.height;
canvas.getContext("2d").drawImage(image, 0, 0);
return canvas;
}
function convertCanvasToImage(canvas) {
var image = new Image();
image.src = canvas.toDataURL("image/png");
return image;
}
function saveViaAJAX()
{
$(document).ready(function() {
function convertImageToCanvas(i, image) {
var canvasOld = document.getElementById("holamundo");
// canvasOld.holamundo.removeChild(canvasOld);
document.getElementById("div_canvas").innerHTML=""
var canvas = document.createElement("canvas");
div = document.getElementById('div_canvas');
canvas.width = image.width;
canvas.height = image.height;
canvas.id = "holamundo";
var ctx = canvas.getContext("2d");
ctx.drawImage(image, 0, 0);
div.appendChild(canvas);
};
$('.watermark').each(convertImageToCanvas);
});
var testCanvas = document.getElementById("holamundo");
var canvasData = testCanvas.toDataURL("image/png");
var postData = "canvasData="+canvasData;
var debugConsole= document.getElementById("debugConsole");
debugConsole.value=canvasData;
}
function archivo(evt) {
var files = evt.target.files; // FileList object
// Obtenemos la imagen del campo "file".
for (var i = 0, f; f = files[i]; i++) {
//Solo admitimos imágenes.
if (!f.type.match('image.*')) {
continue;
}
var reader = new FileReader();
reader.onload = (function(theFile) {
return function(e) {
// Insertamos la imagen
document.getElementById("original").innerHTML = ['<img id="image_output2" name="image_output2" src="', e.target.result,'" title="', escape(theFile.name), '"/>'].join('');
document.getElementById("list").innerHTML = ['<img style="width:<?php echo $ancho; ?>px;" id="image_output" name="image_output" class="img img-responsive watermark center-block" src="', e.target.result,'" title="', escape(theFile.name), '"/>'].join('');
};
})(f);
reader.readAsDataURL(f);
}
}
document.getElementById('files').addEventListener('change', archivo, false);
/* marca */
(function(w){
var wm = (function(w){
var doc = w.document,
gcanvas = {},
gctx = {},
imgQueue = [],
className = "watermark",
watermark = false,
watermarkPosition = "bottom-right",
watermarkPath = "<?php echo $tags['1']; ?>"+(+(new Date())),
opacity = (255/(100/50)), // 50%
initCanvas = function(){
gcanvas = doc.createElement("canvas");
gcanvas.style.cssText = "display:none;";
gctx = gcanvas.getContext("2d");
doc.body.appendChild(gcanvas);
},
initWatermark = function(){
watermark = new Image();
watermark.src = "";
watermark.src = watermarkPath;
if(opacity != 255){
if(!watermark.complete)
watermark.onload = function(){
applyTransparency();
}
else
applyTransparency();
}else{
applyWatermarks();
}
},
// function for applying transparency to the watermark
applyTransparency = function(){
var w = watermark.width || watermark.offsetWidth,
h = watermark.height || watermark.offsetHeight;
setCanvasSize(w, h);
gctx.drawImage(watermark, 0, 0);
var image = gctx.getImageData(0, 0, w, h);
var imageData = image.data,
length = imageData.length;
for(var i=3; i < length; i+=4){
imageData[i] = (imageData[i]<opacity)?imageData[i]:opacity;
}
image.data = imageData;
gctx.putImageData(image, 0, 0);
watermark.onload = null;
watermark.src = "";
watermark.src = gcanvas.toDataURL();
// assign img attributes to the transparent watermark
// because browsers recalculation doesn't work as fast as needed
watermark.width = w;
watermark.height = h;
applyWatermarks();
},
configure = function(config){
if(config["watermark"])
watermark = config["watermark"];
if(config["path"])
watermarkPath = config["path"];
if(config["position"])
watermarkPosition = config["position"];
if(config["opacity"])
opacity = (255/(100/config["opacity"]));
if(config["className"])
className = config["className"];
initCanvas();
initWatermark();
}
setCanvasSize = function(w, h){
gcanvas.width = w;
gcanvas.height = h;
},
applyWatermark = function(img){
/*
var f = image.height / image.width;
var newHeight = canvas.width * f;
*/
var proporcion = ( img.height / img.width );
var ancho = <?php echo $ancho; ?>;
//var alto_orginal = img.height;
//var alto = (alto_original * proporcion);
//alert("hola pro"+alto);
gcanvas.width = ancho;// || img.offsetWidth;
//gcanvas.width = img.width || img.offsetWidth;
//gcanvas.height = img.height || img.offsetHeight;
gcanvas.height = (gcanvas.width * proporcion);// || img.offsetHeight;
gctx.drawImage(img, 0, 0,ancho,gcanvas.height);
var position = watermarkPosition,
x = 0,
y = 0;
if(position.indexOf("top")!=-1)
y = 20;
else if(position.indexOf("middle")!=-1)
y = (gcanvas.height -watermark.height)/2;
else
y = gcanvas.height-watermark.height-20;
if(position.indexOf("left")!=-1)
x = 20;
else if(position.indexOf("center")!=-1)
x = (gcanvas.width - watermark.width) /2;
else
x = gcanvas.width-watermark.width-20;
gctx.drawImage(watermark, x, y);
img.onload = null;
img.src = gcanvas.toDataURL();
},
applyWatermarks = function(){
setTimeout(function(){
var els = doc.getElementsByClassName(className),
len = els.length;
while(len--){
var img = els[len];
if(img.tagName.toUpperCase() != "IMG")
continue;
if(!img.complete){
img.onload = function(){
applyWatermark(this);
};
}else{
applyWatermark(img);
}
}
},10);
};
return {
init: function(config){
configure(config);
}
};
})(w);
w.wmark = wm;
})(window);
/* marca */
</script>
<script>
function marcar(position){
var position = position;
var original = document.getElementById('image_output2').src ;
var marca = document.getElementById('marca').src ;
document.getElementById('image_output').src = original ;
wmark.init({
/* config goes here */
"position": position, // default "bottom-right"
"opacity": 100, // default 50
"className": "watermark", // default "watermark"
"path": marca
// "path": "../milfs/addon/machitroll/images/054843d530f3c83fcdbd55e688d874ec.png"
});
var identificador = Math.random();
document.getElementById('identificador').value= identificador;
//window.setTimeout("saveViaAJAX()", 3000); ///
//saveViaAJAX(); ///
//xajax_wait('aviso','Subiendo imágen');
//window.setTimeout("xajax_machitroll_grabar_imagen(document.getElementById('debugConsole').value,"+identificador+")", 5000);
}
</script>

View File

@ -0,0 +1,84 @@
<?php
function brigadiastas_grabar_imagen($data,$identificador) {
$respuesta = new xajaxResponse('utf-8');
$control = md5("$identificador");
//$form_id = $fomulario["formulario_id"];
$imagen= grabar_imagen($data,$control);
$preview = "<img src='$_SESSION[url]/images/secure/?file=150/$imagen'>";
$respuesta->addScript("javascript: document.getElementById('imagen').value= '$imagen' ;");
$respuesta->addAssign("aviso","innerHTML","$preview");
return $respuesta;
}
$xajax->registerFunction("brigadistas_grabar_imagen");
function brigadistas_grabar($formulario) {
$identificador = $formulario['identificador'];
$control = md5("$identificador");
$data = $formulario['debugConsole'];
$imagen= grabar_imagen($data,$control);
$texto_url = urlencode("#BrigadaDigital");
$uri = urlencode("$_SESSION[url]/images/secure/?file=600/$imagen");
$url ="https://twitter.com/share?url=$uri&text=$texto_url";
//$respuesta->addScript("window.location.href ='$url';");
$preview = "
<div class='row'>
<div class='center-block'>
<div class='thumbnail'>
<img src='$_SESSION[url]/images/secure/?file=300/$imagen'>
<a download='brigadistas.png' href='$_SESSION[url]images/secure/?file=600/$imagen' >
<span class='btn btn-default'><i class='fa fa-download'></i> </span>
</a>
<span class='btn btn-default'>
<a onclick =\"javascript:window.location.href ='$url'; \" ><i class='fa fa-twitter'></i> </a>
</span>
<a href='?set=$formulario[formulario_id]&embebido'>
<span class='btn btn-default'><i class='fa fa-eye'></i> </span>
</a>
<a href='#' onclick = \"javascript:location.reload(); \">
<span class='btn btn-default'><i class='fa fa-refresh'></i> </span>
</a>
</div>
</div>
</div>
";
$respuesta = new xajaxResponse('utf-8');
//$identificador = $formulario['identificador'];
$id_formulario = $formulario['formulario_id'];
$campo_imagen = buscar_campo_tipo("$id_formulario","15");
$formulario[$campo_imagen[0]][0] = $imagen;
$empresa = remplacetas('form_id','id',"$id_formulario",'id_empresa',"") ;
$id_empresa = $empresa[0];
include_once("librerias/conex.php");
$link=Conectarse();
mysqli_query("SET NAMES 'utf8'");
foreach($formulario as $campo=>$valor){
if(is_array($valor)) {
foreach($valor as $c=>$v){
$consulta = "INSERT INTO form_datos ( timestamp,id_usuario,id_empresa,form_id,ip,control,id_campo,contenido) VALUES
( UNIX_TIMESTAMP(),'$_SESSION[id]','$id_empresa','$id_formulario','$ip' ,'$control', '$campo' , '$v')
";
$sql=mysqli_query($consulta,$link);
// $campos .= " $campo // $valor // $c -> $v $consulta <br>";
}
}
}
$resultado = "$preview ";
$respuesta->addAssign("aviso","innerHTML","$preview");
//$respuesta->addAlert("$resultado");
//$respuesta->addScript("javascript:location.reload(true);");
return $respuesta;
}
$xajax->registerFunction("brigadistas_grabar");
?>

Binary file not shown.

After

Width:  |  Height:  |  Size: 7.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 38 KiB

6
addon/funciones.php Normal file
View File

@ -0,0 +1,6 @@
<?php
require("machitroll/funciones/funciones.php");
require("logis/funciones/funciones.php");
require("tuitealo/funciones/funciones.php");
//require("dummy/funciones/funciones.php");
?>

View File

@ -0,0 +1,510 @@
<?php
//include("funciones/funciones.php");
$id_formulario = "58";
$ancho = "500";
$tags = array();
$tags[] = "milfs/addon/logis/images/logos/c.png";
foreach ($tags as &$valor) {
$imagen .= "<td onclick=\" document.getElementById('marca').src='$valor' ; marcar('top-left') \" ><a href='#medio' class='' >
<img class='img ' src='$valor'>
</a></td>";
}
$imagen = "
<div class='table-responsive'>
<table class='table table table-condensed text-center '>
<tr >
$imagen
</tr>
</table>
</div>";
?>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js"></script>
<div>
<style type="text/css">
.fa{
font-size:60px important!;
}
#imagen_origina{
width: <?echo $ancho ?>px;
}
body{
background-color:white !important;
}
.pin {
text-align: center;
/*border: solid 1px red;*/
opacity: 0.5;
}
.fileUpload {
position: relative;
overflow: hidden;
margin: 10px;
width: 80%;
}
.fileUpload input.upload {
position: absolute;
top: 0;
right: 0;
margin: 10;
padding: 0;
font-size: 50px;
cursor: pointer;
opacity: 0;
filter: alpha(opacity=0);
}
.ing-touch{
border: solid 1px red;
width:20% !important;
}
</style>
<div class='container' style='backgroun-color:white;' >
<div class='fileUpload btn btn-primary center-block'>
<span><h1><i class="fa fa-camera"></i></h1></span>
<input class='upload' type="file" id="file-input" /></span>
<div id="original" ></div>
</div>
<!-- <p><input type="file" id="file-input"></p> -->
<div id="actions" style="display:none;">
<img class="center-block" src= "<?php echo $tags[0]; ?>" style='display:none' id="marca" name="marca">
<img class="center-block" style='' id="image_output" name="image_output">
<img class="center-block" style='' id="otra_imagen" name="otra_imagen">
<div id="result" class="result">
<p></p>
</div>
<a name="arriba"></a>
<div style="position:relative">
<div style="position:absolute; width:100%; height:100%;" >
<table style="width:100%; height:100%;" class="">
<tr >
<td class="pin" ><a href="#arriba" onclick=" javascript: marcar('top-left')"><img class="ing-touch img img-circle img-responsive center-block " style="width:20%;" src="milfs/images/oscuro40.png"></a></td>
<td class="pin"><a href="#arriba" onclick=" javascript: marcar('top-center')"><img class="ing-touch img img-circle img-responsive center-block " style="width:20%;" src="milfs/images/oscuro40.png"></a></td>
<td class="pin"><a href="#arriba" onclick=" javascript: marcar('top-rigth')"><img class="ing-touch img img-circle img-responsive center-block " style="width:50%;" src="milfs/images/oscuro40.png"></a></td>
</tr>
<tr>
<td class="pin"><a name="medio"></a><a href="#arriba" onclick=" javascript: marcar('middle-left')"><img class="ing-touch img img-circle img-responsive center-block " style="width:50%;" src="milfs/images/oscuro40.png"></a></td>
<td class="pin" ><a href="#medio" onclick=" javascript: marcar('middle-center')"><img class="ing-touch img img-circle img-responsive center-block " style="width:50%;" src="milfs/images/oscuro40.png"></a></td>
<td class="pin"><a href="#medio" onclick=" javascript: marcar('middle-rigth')"><img class="ing-touch img img-circle img-responsive center-block " style="width:50%;" src="milfs/images/oscuro40.png"></td>
</tr>
<tr>
<td class="pin"><a href="#medio" onclick=" javascript: marcar('bottom-left')"><img class="ing-touch img img-circle img-responsive center-block " style="width:50%;" src="milfs/images/oscuro40.png"></a></td>
<td class="pin"><a href="#medio" onclick=" javascript: marcar('bottom-center')"><img class="ing-touch img img-circle img-responsive center-block " style="width:50%;" src="milfs/images/oscuro40.png"></a></td>
<td class="pin"><a href="#medio" onclick=" javascript: marcar('bottom-rigth')"><img class="ing-touch img img-circle img-responsive center-block " style="width:50%;" src="milfs/images/oscuro40.png"></a></td>
</tr>
</table>
</div>
<canvas id="micanvas" style="position:absolute" >
Tu navegador no soporta canvas.
</canvas>
</div>
<div class="row " style="position:relative">
<form id='formulario_brigadistas' name='formulario_brigadistas' >
<input class='form-control' type='' id="debugConsole" name="debugConsole" >
<input type='' id="identificador" name="identificador" >
<input type='hidden' id="formulario_id" name="formulario_id" value="<?php echo $id_formulario; ?>">
<input type='hidden' id="imagen" name="imagen" value="">
<?php $formulario = formulario_areas("$id_formulario",'campos','','');
echo $formulario; ?>
</form>
</div>
<div id='aviso'>Aviso</div>
<div class="row">
<div class="col-md-12">
<!-- this.disabled= true; xajax_wait('aviso','Grabando... un momento por favor...'); -->
<button class='fileUpload btn btn-success btn-block' onclick=" xajax_brigadistas_grabar(xajax.getFormValues('formulario_brigadistas'))">
<span><i class="fa fa-save"></i> <span class='fa'> Grabalo! </span></span>
</button>
</div>
</div>
</div>
</div>
<script language="javascript">
$(function () {
'use strict';
var result = $('#result'),
exifNode = $('#exif'),
thumbNode = $('#thumbnail'),
actionsNode = $('#actions'),
currentFile,
replaceResults = function (img) {
var content;
if (!(img.src || img instanceof HTMLCanvasElement)) {
content = $('<span>Loading image file failed</span>');
} else {
content = $('<img />').append(img)
//.attr('download', currentFile.name)
.attr('src', img.src || img.toDataURL())
.attr('width', '<?echo $ancho ?>px')
.attr('style', 'width:100%')
.attr('id', 'imagen_original');
}
//document.getElementById('image_output').src = img.src;
result.children().replaceWith(content);
if (img.getContext) {
actionsNode.show();
window.setTimeout("marcar('middle-center');", 500);
}
},
displayImage = function (file, options) {
currentFile = file;
if (!loadImage(
file,
replaceResults,
options
)) {
result.children().replaceWith(
$('<span>Your browser does not support the URL or FileReader API.</span>')
);
}
},
displayExifData = function (exif) {
var thumbnail = exif.get('Thumbnail'),
tags = exif.getAll(),
table = exifNode.find('table').empty(),
row = $('<tr></tr>'),
cell = $('<td></td>'),
prop;
if (thumbnail) {
thumbNode.empty();
loadImage(thumbnail, function (img) {
thumbNode.append(img).show();
}, {orientation: exif.get('Orientation')});
}
for (prop in tags) {
if (tags.hasOwnProperty(prop)) {
table.append(
row.clone()
.append(cell.clone().text(prop))
.append(cell.clone().text(tags[prop]))
);
}
}
exifNode.show();
},
dropChangeHandler = function (e) {
e.preventDefault();
e = e.originalEvent;
var target = e.dataTransfer || e.target,
file = target && target.files && target.files[0],
options = {
maxWidth: result.width(),
canvas: true
};
if (!file) {
return;
}
exifNode.hide();
thumbNode.hide();
loadImage.parseMetaData(file, function (data) {
if (data.exif) {
options.orientation = data.exif.get('Orientation');
displayExifData(data.exif);
}
displayImage(file, options);
});
},
coordinates;
// Hide URL/FileReader API requirement message in capable browsers:
if (window.createObjectURL || window.URL || window.webkitURL || window.FileReader) {
result.children().hide();
}
$(document)
.on('dragover', function (e) {
e.preventDefault();
e = e.originalEvent;
e.dataTransfer.dropEffect = 'copy';
})
.on('drop', dropChangeHandler);
$('#file-input').on('change', dropChangeHandler);
$('#edit').on('click', function (event) {
event.preventDefault();
var imgNode = result.find('img, canvas'),
img = imgNode[0];
imgNode.Jcrop({
setSelect: [40, 40, img.width - 40, img.height - 40],
onSelect: function (coords) {
coordinates = coords;
},
onRelease: function () {
coordinates = null;
}
}).parent().on('click', function (event) {
event.preventDefault();
});
});
$('#crop').on('click', function (event) {
event.preventDefault();
var img = result.find('img, canvas')[0];
if (img && coordinates) {
replaceResults(loadImage.scale(img, {
left: coordinates.x,
top: coordinates.y,
sourceWidth: coordinates.w,
sourceHeight: coordinates.h,
minWidth: result.width()
}));
coordinates = null;
}
});
});
</script>
<script language="javascript">
function cargaContextoCanvas(idCanvas){
var elemento = document.getElementById(idCanvas);
if(elemento && elemento.getContext){
var contexto = elemento.getContext('2d');
if(contexto){
return contexto;
}
}
return FALSE;
}
function marcar(ubicacion){
//if (ubicacion == 'arriba'){ var x = '0';var y = '0';}
//if (ubicacion == 'abajo'){ var x = '10';var y = '50';}
//Recibimos el elemento canvas
var ctx = cargaContextoCanvas('micanvas');
if(ctx){
//Creo una imagen conun objeto Image de Javascript
var img = new Image();
var img2 = new Image();
//img.src = document.getElementById("image_output2").src;
//readAsDataURL(
img.src = document.getElementById("imagen_original").src;
document.getElementById("imagen_original").style.display="none";
//img2.src = 'images/logos/a.png';
img2.src = document.getElementById("marca").src;
if (ubicacion =='') {
ubicacion ='middle-center';
}
x = 0,
y = 0;
if(ubicacion.indexOf("top")!=-1)
y = 10;
else if(ubicacion.indexOf("middle")!=-1)
y = (micanvas.height - img2.height)/2;
else
y = micanvas.height-img2.height-10;
if(ubicacion.indexOf("left")!=-1)
x = 10;
else if(ubicacion.indexOf("center")!=-1)
x = (micanvas.width - img2.width) /2;
else
x = micanvas.width-img2.width-10;
var proporcion = ( img.height / img.width );
var ancho = <?echo $ancho ?>;
micanvas.width =ancho;
micanvas.height = (micanvas.width * proporcion);
micanvas.setAttribute('width', ancho);
micanvas.setAttribute('height', micanvas.height);
micanvas.setAttribute('style',"width:100%");
img.onload = function(){
ctx.drawImage(img, 0, 0,micanvas.width,micanvas.height);
ctx.drawImage(img2, x, y);
var debugConsole= document.getElementById("debugConsole");
var testCanvas = document.getElementById("micanvas");
var canvasData = testCanvas.toDataURL("image/png");
var postData = "canvasData="+canvasData;
debugConsole.value=canvasData;
var identificador = Math.random();
document.getElementById('identificador').value= identificador;
}
}
}
$(function () {
'use strict';
var result = $('#result'),
exifNode = $('#exif'),
thumbNode = $('#thumbnail'),
actionsNode = $('#actions'),
currentFile,
replaceResults = function (img) {
var content;
if (!(img.src || img instanceof HTMLCanvasElement)) {
content = $('<span>Loading image file failed</span>');
} else {
content = $('<img />').append(img)
//.attr('download', currentFile.name)
.attr('src', img.src || img.toDataURL())
.attr('width', '<?echo $ancho ?>')
.attr('style', 'width:100%')
.attr('id', 'imagen_original');
}
//document.getElementById('image_output').src = img.src;
result.children().replaceWith(content);
if (img.getContext) {
actionsNode.show();
window.setTimeout("marcar('middle-center');", 500);
}
},
displayImage = function (file, options) {
currentFile = file;
if (!loadImage(
file,
replaceResults,
options
)) {
result.children().replaceWith(
$('<span>Your browser does not support the URL or FileReader API.</span>')
);
}
},
displayExifData = function (exif) {
var thumbnail = exif.get('Thumbnail'),
tags = exif.getAll(),
table = exifNode.find('table').empty(),
row = $('<tr></tr>'),
cell = $('<td></td>'),
prop;
if (thumbnail) {
thumbNode.empty();
loadImage(thumbnail, function (img) {
thumbNode.append(img).show();
}, {orientation: exif.get('Orientation')});
}
for (prop in tags) {
if (tags.hasOwnProperty(prop)) {
table.append(
row.clone()
.append(cell.clone().text(prop))
.append(cell.clone().text(tags[prop]))
);
}
}
exifNode.show();
},
dropChangeHandler = function (e) {
e.preventDefault();
e = e.originalEvent;
var target = e.dataTransfer || e.target,
file = target && target.files && target.files[0],
options = {
maxWidth: result.width(),
canvas: true
};
if (!file) {
return;
}
exifNode.hide();
thumbNode.hide();
loadImage.parseMetaData(file, function (data) {
if (data.exif) {
options.orientation = data.exif.get('Orientation');
displayExifData(data.exif);
}
displayImage(file, options);
});
},
coordinates;
// Hide URL/FileReader API requirement message in capable browsers:
if (window.createObjectURL || window.URL || window.webkitURL || window.FileReader) {
result.children().hide();
}
$(document)
.on('dragover', function (e) {
e.preventDefault();
e = e.originalEvent;
e.dataTransfer.dropEffect = 'copy';
})
.on('drop', dropChangeHandler);
$('#file-input').on('change', dropChangeHandler);
$('#edit').on('click', function (event) {
event.preventDefault();
var imgNode = result.find('img, canvas'),
img = imgNode[0];
imgNode.Jcrop({
setSelect: [40, 40, img.width - 40, img.height - 40],
onSelect: function (coords) {
coordinates = coords;
},
onRelease: function () {
coordinates = null;
}
}).parent().on('click', function (event) {
event.preventDefault();
});
});
$('#crop').on('click', function (event) {
event.preventDefault();
var img = result.find('img, canvas')[0];
if (img && coordinates) {
replaceResults(loadImage.scale(img, {
left: coordinates.x,
top: coordinates.y,
sourceWidth: coordinates.w,
sourceHeight: coordinates.h,
minWidth: result.width()
}));
coordinates = null;
}
});
});
</script>
<br>
<script src="milfs/addon/logis/js/load-image.all.min.js"></script>
<!-- <script src="js/load-image.js"></script> -->
<!-- <script src="js/load-image-ios.js"></script> -->
<!-- <script src="js/load-image-orientation.js"></script> -->
<!-- <script src="js/load-image-meta.js"></script> -->
<!-- <script src="js/load-image-exif.js"></script> -->
<!-- <script src="js/load-image-exif-map.js"></script> -->
<!-- jQuery and Jcrop are not required by JavaScript Load Image, but included for the demo -->
<!-- <script src="//ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js"></script> -->
<!-- <script src="js/vendor/jquery.Jcrop.js"></script> -->
<!-- <script src="js/demo.js"></script> -->
</div>

View File

@ -0,0 +1,91 @@
<?php
function brigadistas_grabar_imagen($data,$identificador) {
$respuesta = new xajaxResponse('utf-8');
$control = md5("$identificador");
//$form_id = $fomulario["formulario_id"];
$imagen= grabar_imagen($data,$control);
$preview = "<img src='$_SESSION[url]/images/secure/?file=150/$imagen'>";
$respuesta->addScript("javascript: document.getElementById('imagen').value= '$imagen' ;");
$respuesta->addAssign("aviso","innerHTML","$preview");
return $respuesta;
}
$xajax->registerFunction("brigadistas_grabar_imagen");
function brigadistas_grabar($formulario) {
$identificador = $formulario['identificador'];
$control = md5("$identificador");
$data = $formulario['debugConsole'];
$imagen= grabar_imagen($data,$control);
$texto_url = urlencode("#BrigadaDigital");
$uri = urlencode("$_SESSION[url]/images/secure/?file=600/$imagen");
$url ="https://twitter.com/share?url=$uri&text=$texto_url";
//$respuesta->addScript("window.location.href ='$url';");
$respuesta = new xajaxResponse('utf-8');
//$identificador = $formulario['identificador'];
$id_formulario = $formulario['formulario_id'];
$campo_imagen = buscar_campo_tipo("$id_formulario","15");
$formulario[$campo_imagen[0]][0] = $imagen;
$empresa = remplacetas('form_id','id',"$id_formulario",'id_empresa',"") ;
$id_empresa = $empresa[0];
include_once("librerias/conex.php");
$link=Conectarse();
mysqli_query("SET NAMES 'utf8'");
foreach($formulario as $campo=>$valor){
if(is_array($valor)) {
foreach($valor as $c=>$v){
$consulta = "INSERT INTO form_datos ( timestamp,id_usuario,id_empresa,form_id,ip,control,id_campo,contenido) VALUES
( UNIX_TIMESTAMP(),'$_SESSION[id]','$id_empresa','$id_formulario','$ip' ,'$control', '$campo' , '".mysql_real_escape_string( $v )."')
";
$sql=mysqli_query($consulta,$link);
// $campos .= " $campo // $valor // $c -> $v $consulta <br>";
}
}
}
$twitter = $formulario['498'][0];
$_SESSION['logis'] = "$control";
$_SESSION['mensaje'] = "$twitter";
$preview = "
<div class='row'>
<div class='center-block'>
<div class='thumbnail'>
<img src='$_SESSION[url]/images/secure/?file=300/$imagen'>
<h2 class='text-center'>$twitter<h2>
<a download='brigadistas.png' href='$_SESSION[url]images/secure/?file=600/$imagen' >
<span class='btn btn-default'><i class='fa fa-download'></i> </span>
</a>
<span class='btn btn-default'>
<a target= 'twitter' href ='milfs/addon/logis/funciones/twitter/tuitear.php' ><i class='fa fa-twitter'></i></a>
</span>
<a href='S58'>
<span class='btn btn-default'><i class='fa fa-eye'></i> Ver</span>
</a>
<a href='#' onclick = \"javascript:location.reload(); \">
<span class='btn btn-default'><i class='fa fa-refresh'></i> Actualizar</span>
</a>
</div>
</div>
</div>
";
$resultado = "$preview ";
$respuesta->addAssign("aviso","innerHTML","$preview");
//$respuesta->addAlert("$resultado");
//$respuesta->addScript("javascript:location.reload(true);");
return $respuesta;
}
$xajax->registerFunction("brigadistas_grabar");
?>

View File

@ -0,0 +1,36 @@
<?php
/**
* Use to autoload needed classes without Composer.
*
* @param string $class The fully-qualified class name.
* @return void
*/
spl_autoload_register(function ($class) {
// project-specific namespace prefix
$prefix = 'Abraham\\TwitterOAuth\\';
// base directory for the namespace prefix
$base_dir = __DIR__ . '/src/';
// does the class use the namespace prefix?
$len = strlen($prefix);
if (strncmp($prefix, $class, $len) !== 0) {
// no, move to the next registered autoloader
return;
}
// get the relative class name
$relative_class = substr($class, $len);
// replace the namespace prefix with the base directory, replace namespace
// separators with directory separators in the relative class name, append
// with .php
$file = $base_dir . str_replace('\\', '/', $relative_class) . '.php';
// if the file exists, require it
if (file_exists($file)) {
require $file;
}
});

Binary file not shown.

After

Width:  |  Height:  |  Size: 38 KiB

View File

@ -0,0 +1,6 @@
<?php
define('CONSUMER_KEY', 'QS1JHXs7OgJcFArJmMv117JEn');
define('CONSUMER_SECRET', 'NoO1FUXHmTB74HUrnDbcs64XgZoroBkaPav8w0FgbK3ZYSU9PZ');
define('OAUTH_CALLBACK', 'http://datos.labmde.org/milfs/toa/hola.php');
?>

View File

@ -0,0 +1,31 @@
<?php
ini_set('display_errors', 1);
require 'autoload.php';
use Abraham\TwitterOAuth\TwitterOAuth;
/*
define('CONSUMER_KEY', getenv('wMtivKDSAgZmkP7EZhYcfw'));
define('CONSUMER_SECRET', getenv('AvWbHfjuSJkZYhkxsU8ojsDpNtvapBoiRUzwF3OAvbo'));
define('OAUTH_CALLBACK', getenv('http://datos.labmde.org/milfs/toa/hola.php'));
*/
define('CONSUMER_KEY', 'QS1JHXs7OgJcFArJmMv117JEn');
define('CONSUMER_SECRET', 'NoO1FUXHmTB74HUrnDbcs64XgZoroBkaPav8w0FgbK3ZYSU9PZ');
define('OAUTH_CALLBACK', 'http://datos.labmde.org/milfs/addon/logis/funciones/twitter/hola.php');
$connection = new TwitterOAuth(CONSUMER_KEY, CONSUMER_SECRET);
//print $connection; //print connection contents
//$request_token = $connection->oauth('oauth/request_token', array('oauth_callback' => OAUTH_CALLBACK));
$request_token = $connection->oauth('oauth/request_token');
//$url = $connection->url('oauth/authorize', array('oauth_token' => $request_token['oauth_token']));
$user = $connection->get("account/verify_credentials");
//print $user->screen_name;
print_r($user);
// Post Update
$content = $connection->post('statuses/update', array('status' => 'Bonito dia'));
print_r( $content);
print_r($url);
//print_r($request_token); //print connection contentsa
?>

View File

@ -0,0 +1,65 @@
<?php
session_start();
ini_set('display_errors', 1);
require 'autoload.php';
use Abraham\TwitterOAuth\TwitterOAuth;
require_once('config.php');
/* Crear un objeto TwitteroAuth con las credenciales de la aplicacion y el token temporal */
//$connection = new TwitterOAuth(CONSUMER_KEY, CONSUMER_SECRET,
$connection = new TwitterOAuth(CONSUMER_KEY, CONSUMER_SECRET,
$_SESSION['oauth_token'], $_SESSION['oauth_token_secret']);
/* Solicitar a twitter el token de acceso */
//$access_token = $connection->getAccessToken($_REQUEST['oauth_verifier']);
$access_token = $connection->oauth("oauth/access_token", array("oauth_verifier" => $_REQUEST['oauth_verifier']));
/* Guardar el token de acceso. Normalmente, este token se guardará también en una base
de datos para volver a ser utilizado en otras ocasiones. */
$_SESSION['access_token'] = $access_token;
/* Eliminar el token temporal de solicitud */
unset($_SESSION['oauth_token']);
unset($_SESSION['oauth_token_secret']);
/* Si todo va bien, presentar al usuario la página principal "index.php" del servicio */
//if (200 == $connection->http_code) {
/* El usuario ha sido verificado */
$_SESSION['status'] = 'verified';
echo send_tweet($access_token);
//}
function base64_encode_image ($filename=string,$filetype=string) {
if ($filename) {
$imgbinary = fread(fopen($filename, "r"), filesize($filename));
return base64_encode($imgbinary);
}
}
function send_tweet($access_token) {
$tweet = new TwitterOAuth(CONSUMER_KEY, CONSUMER_SECRET,
$access_token['oauth_token'], $access_token['oauth_token_secret']);
$nombre= $_SESSION['logis'].".png";
$nombre = "$_SESSION[path_images_secure]/600/$nombre";
$media1 = $tweet->upload('media/upload', array('media' => "$nombre"));
$parameters = array('status' =>"$_SESSION[mensaje] #BrigadaDigital #CD2015 http://datos.labmde.org/jlogis",'media_ids' => implode(',', array($media1->media_id_string)),
);
$result = $tweet-> post('statuses/update', $parameters);
/*$image = "$nombre";
$base64 = base64_encode_image (''.$image,'png');
$result = $tweet-> post('account/update_profile_image', array('image' => $base64.';type=image/jpg;filename='.$image));
*/
// $message = "Bonito dia $nombre";
// $tweet->post('statuses/update', array('status' => "$message"));
//
}
header('Location: https://twitter.com/hashtag/CD2015');
// header('Location: ./index.php');
//} else {
//header('Location: ./clearsessions.php');
//

View File

@ -0,0 +1,64 @@
<?php
namespace Abraham\TwitterOAuth;
/**
* Handle setting and storing config for TwitterOAuth.
*
* @author Abraham Williams <abraham@abrah.am>
*/
class Config
{
/** @var int How long to wait for a response from the API */
protected $timeout = 5;
/** @var int how long to wait while connecting to the API */
protected $connectionTimeout = 5;
/**
* Decode JSON Response as associative Array
*
* @see http://php.net/manual/en/function.json-decode.php
*
* @var bool
*/
protected $decodeJsonAsArray = false;
/** @var string User-Agent header */
protected $userAgent = 'TwitterOAuth (+https://twitteroauth.com)';
/** @var array Store proxy connection details */
protected $proxy = [];
/**
* Set the connection and response timeouts.
*
* @param int $connectionTimeout
* @param int $timeout
*/
public function setTimeouts($connectionTimeout, $timeout)
{
$this->connectionTimeout = (int)$connectionTimeout;
$this->timeout = (int)$timeout;
}
/**
* @param bool $value
*/
public function setDecodeJsonAsArray($value)
{
$this->decodeJsonAsArray = (bool)$value;
}
/**
* @param string $userAgent
*/
public function setUserAgent($userAgent)
{
$this->userAgent = (string)$userAgent;
}
/**
* @param array $proxy
*/
public function setProxy(array $proxy)
{
$this->proxy = $proxy;
}
}

View File

@ -0,0 +1,36 @@
<?php
/**
* The MIT License
* Copyright (c) 2007 Andy Smith
*/
namespace Abraham\TwitterOAuth;
class Consumer
{
/** @var string */
public $key;
/** @var string */
public $secret;
/** @var string|null */
public $callbackUrl;
/**
* @param string $key
* @param string $secret
* @param null $callbackUrl
*/
public function __construct($key, $secret, $callbackUrl = null)
{
$this->key = $key;
$this->secret = $secret;
$this->callbackUrl = $callbackUrl;
}
/**
* @return string
*/
public function __toString()
{
return "Consumer[key=$this->key,secret=$this->secret]";
}
}

View File

@ -0,0 +1,39 @@
<?php
/**
* The MIT License
* Copyright (c) 2007 Andy Smith
*/
namespace Abraham\TwitterOAuth;
/**
* The HMAC-SHA1 signature method uses the HMAC-SHA1 signature algorithm as defined in [RFC2104]
* where the Signature Base String is the text and the key is the concatenated values (each first
* encoded per Parameter Encoding) of the Consumer Secret and Token Secret, separated by an '&'
* character (ASCII code 38) even if empty.
* - Chapter 9.2 ("HMAC-SHA1")
*/
class HmacSha1 extends SignatureMethod
{
/**
* {@inheritDoc}
*/
public function getName()
{
return "HMAC-SHA1";
}
/**
* {@inheritDoc}
*/
public function buildSignature(Request $request, Consumer $consumer, Token $token = null)
{
$signatureBase = $request->getSignatureBaseString();
$parts = [$consumer->secret, null !== $token ? $token->secret : ""];
$parts = Util::urlencodeRfc3986($parts);
$key = implode('&', $parts);
return base64_encode(hash_hmac('sha1', $signatureBase, $key, true));
}
}

View File

@ -0,0 +1,254 @@
<?php
/**
* The MIT License
* Copyright (c) 2007 Andy Smith
*/
namespace Abraham\TwitterOAuth;
class Request
{
protected $parameters;
protected $httpMethod;
protected $httpUrl;
public static $version = '1.0';
/**
* Constructor
*
* @param string $httpMethod
* @param string $httpUrl
* @param array|null $parameters
*/
public function __construct($httpMethod, $httpUrl, array $parameters = [])
{
$parameters = array_merge(Util::parseParameters(parse_url($httpUrl, PHP_URL_QUERY)), $parameters);
$this->parameters = $parameters;
$this->httpMethod = $httpMethod;
$this->httpUrl = $httpUrl;
}
/**
* pretty much a helper function to set up the request
*
* @param Consumer $consumer
* @param Token $token
* @param string $httpMethod
* @param string $httpUrl
* @param array $parameters
*
* @return Request
*/
public static function fromConsumerAndToken(
Consumer $consumer,
Token $token = null,
$httpMethod,
$httpUrl,
array $parameters = []
) {
$defaults = [
"oauth_version" => Request::$version,
"oauth_nonce" => Request::generateNonce(),
"oauth_timestamp" => time(),
"oauth_consumer_key" => $consumer->key
];
if (null !== $token) {
$defaults['oauth_token'] = $token->key;
}
$parameters = array_merge($defaults, $parameters);
return new Request($httpMethod, $httpUrl, $parameters);
}
/**
* @param string $name
* @param string $value
*/
public function setParameter($name, $value)
{
$this->parameters[$name] = $value;
}
/**
* @param $name
*
* @return string|null
*/
public function getParameter($name)
{
return isset($this->parameters[$name]) ? $this->parameters[$name] : null;
}
/**
* @return array
*/
public function getParameters()
{
return $this->parameters;
}
/**
* @param $name
*/
public function removeParameter($name)
{
unset($this->parameters[$name]);
}
/**
* The request parameters, sorted and concatenated into a normalized string.
*
* @return string
*/
public function getSignableParameters()
{
// Grab all parameters
$params = $this->parameters;
// Remove oauth_signature if present
// Ref: Spec: 9.1.1 ("The oauth_signature parameter MUST be excluded.")
if (isset($params['oauth_signature'])) {
unset($params['oauth_signature']);
}
return Util::buildHttpQuery($params);
}
/**
* Returns the base string of this request
*
* The base string defined as the method, the url
* and the parameters (normalized), each urlencoded
* and the concated with &.
*
* @return string
*/
public function getSignatureBaseString()
{
$parts = [
$this->getNormalizedHttpMethod(),
$this->getNormalizedHttpUrl(),
$this->getSignableParameters()
];
$parts = Util::urlencodeRfc3986($parts);
return implode('&', $parts);
}
/**
* Returns the HTTP Method in uppercase
*
* @return string
*/
public function getNormalizedHttpMethod()
{
return strtoupper($this->httpMethod);
}
/**
* parses the url and rebuilds it to be
* scheme://host/path
*
* @return string
*/
public function getNormalizedHttpUrl()
{
$parts = parse_url($this->httpUrl);
$scheme = $parts['scheme'];
$host = strtolower($parts['host']);
$path = $parts['path'];
return "$scheme://$host$path";
}
/**
* Builds a url usable for a GET request
*
* @return string
*/
public function toUrl()
{
$postData = $this->toPostdata();
$out = $this->getNormalizedHttpUrl();
if ($postData) {
$out .= '?' . $postData;
}
return $out;
}
/**
* Builds the data one would send in a POST request
*
* @return string
*/
public function toPostdata()
{
return Util::buildHttpQuery($this->parameters);
}
/**
* Builds the Authorization: header
*
* @return string
* @throws TwitterOAuthException
*/
public function toHeader()
{
$first = true;
$out = 'Authorization: OAuth';
foreach ($this->parameters as $k => $v) {
if (substr($k, 0, 5) != "oauth") {
continue;
}
if (is_array($v)) {
throw new TwitterOAuthException('Arrays not supported in headers');
}
$out .= ($first) ? ' ' : ', ';
$out .= Util::urlencodeRfc3986($k) . '="' . Util::urlencodeRfc3986($v) . '"';
$first = false;
}
return $out;
}
/**
* @return string
*/
public function __toString()
{
return $this->toUrl();
}
/**
* @param SignatureMethod $signatureMethod
* @param Consumer $consumer
* @param Token $token
*/
public function signRequest(SignatureMethod $signatureMethod, Consumer $consumer, Token $token = null)
{
$this->setParameter("oauth_signature_method", $signatureMethod->getName());
$signature = $this->buildSignature($signatureMethod, $consumer, $token);
$this->setParameter("oauth_signature", $signature);
}
/**
* @param SignatureMethod $signatureMethod
* @param Consumer $consumer
* @param Token $token
*
* @return string
*/
public function buildSignature(SignatureMethod $signatureMethod, Consumer $consumer, Token $token = null)
{
return $signatureMethod->buildSignature($this, $consumer, $token);
}
/**
* @return string
*/
public static function generateNonce()
{
return md5(microtime() . mt_rand());
}
}

View File

@ -0,0 +1,107 @@
<?php
namespace Abraham\TwitterOAuth;
/**
* The result of the most recent API request.
*
* @author Abraham Williams <abraham@abrah.am>
*/
class Response
{
/** @var string|null API path from the most recent request */
private $apiPath;
/** @var int HTTP status code from the most recent request */
private $httpCode = 0;
/** @var array HTTP headers from the most recent request */
private $headers = [];
/** @var array|object Response body from the most recent request */
private $body = [];
/** @var array HTTP headers from the most recent request that start with X */
private $xHeaders = [];
/**
* @param string $apiPath
*/
public function setApiPath($apiPath)
{
$this->apiPath = $apiPath;
}
/**
* @return string|null
*/
public function getApiPath()
{
return $this->apiPath;
}
/**
* @param array|object $body
*/
public function setBody($body)
{
$this->body = $body;
}
/**
* @return array|object|string
*/
public function getBody()
{
return $this->body;
}
/**
* @param int $httpCode
*/
public function setHttpCode($httpCode)
{
$this->httpCode = $httpCode;
}
/**
* @return int
*/
public function getHttpCode()
{
return $this->httpCode;
}
/**
* @param array $headers
*/
public function setHeaders($headers)
{
foreach ($headers as $key => $value) {
if (substr($key, 0, 1) == 'x') {
$this->xHeaders[$key] = $value;
}
}
$this->headers = $headers;
}
/**
* @return array
*/
public function getsHeaders()
{
return $this->headers;
}
/**
* @param array $xHeaders
*/
public function setXHeaders($xHeaders)
{
$this->xHeaders = $xHeaders;
}
/**
* @return array
*/
public function getXHeaders()
{
return $this->xHeaders;
}
}

View File

@ -0,0 +1,66 @@
<?php
/**
* The MIT License
* Copyright (c) 2007 Andy Smith
*/
namespace Abraham\TwitterOAuth;
/**
* A class for implementing a Signature Method
* See section 9 ("Signing Requests") in the spec
*/
abstract class SignatureMethod
{
/**
* Needs to return the name of the Signature Method (ie HMAC-SHA1)
*
* @return string
*/
abstract public function getName();
/**
* Build up the signature
* NOTE: The output of this function MUST NOT be urlencoded.
* the encoding is handled in OAuthRequest when the final
* request is serialized
*
* @param Request $request
* @param Consumer $consumer
* @param Token $token
*
* @return string
*/
abstract public function buildSignature(Request $request, Consumer $consumer, Token $token = null);
/**
* Verifies that a given signature is correct
*
* @param Request $request
* @param Consumer $consumer
* @param Token $token
* @param string $signature
*
* @return bool
*/
public function checkSignature(Request $request, Consumer $consumer, Token $token, $signature)
{
$built = $this->buildSignature($request, $consumer, $token);
// Check for zero length, although unlikely here
if (strlen($built) == 0 || strlen($signature) == 0) {
return false;
}
if (strlen($built) != strlen($signature)) {
return false;
}
// Avoid a timing leak with a (hopefully) time insensitive compare
$result = 0;
for ($i = 0; $i < strlen($signature); $i++) {
$result |= ord($built{$i}) ^ ord($signature{$i});
}
return $result == 0;
}
}

View File

@ -0,0 +1,38 @@
<?php
/**
* The MIT License
* Copyright (c) 2007 Andy Smith
*/
namespace Abraham\TwitterOAuth;
class Token
{
/** @var string */
public $key;
/** @var string */
public $secret;
/**
* @param string $key The OAuth Token
* @param string $secret The OAuth Token Secret
*/
public function __construct($key, $secret)
{
$this->key = $key;
$this->secret = $secret;
}
/**
* Generates the basic string serialization of a token that a server
* would respond to request_token and access_token calls with
*
* @return string
*/
public function __toString()
{
return sprintf("oauth_token=%s&oauth_token_secret=%s",
Util::urlencodeRfc3986($this->key),
Util::urlencodeRfc3986($this->secret)
);
}
}

View File

@ -0,0 +1,448 @@
<?php
/**
* The most popular PHP library for use with the Twitter OAuth REST API.
*
* @license MIT
*/
namespace Abraham\TwitterOAuth;
use Abraham\TwitterOAuth\Util\JsonDecoder;
/**
* TwitterOAuth class for interacting with the Twitter API.
*
* @author Abraham Williams <abraham@abrah.am>
*/
class TwitterOAuth extends Config
{
const API_VERSION = '1.1';
const API_HOST = 'https://api.twitter.com';
const UPLOAD_HOST = 'https://upload.twitter.com';
const UPLOAD_CHUNK = 40960; // 1024 * 40
/** @var Response details about the result of the last request */
private $response;
/** @var string|null Application bearer token */
private $bearer;
/** @var Consumer Twitter application details */
private $consumer;
/** @var Token|null User access token details */
private $token;
/** @var HmacSha1 OAuth 1 signature type used by Twitter */
private $signatureMethod;
/**
* Constructor
*
* @param string $consumerKey The Application Consumer Key
* @param string $consumerSecret The Application Consumer Secret
* @param string|null $oauthToken The Client Token (optional)
* @param string|null $oauthTokenSecret The Client Token Secret (optional)
*/
public function __construct($consumerKey, $consumerSecret, $oauthToken = null, $oauthTokenSecret = null)
{
$this->resetLastResponse();
$this->signatureMethod = new HmacSha1();
$this->consumer = new Consumer($consumerKey, $consumerSecret);
if (!empty($oauthToken) && !empty($oauthTokenSecret)) {
$this->token = new Token($oauthToken, $oauthTokenSecret);
}
if (empty($oauthToken) && !empty($oauthTokenSecret)) {
$this->bearer = $oauthTokenSecret;
}
}
/**
* @param string $oauthToken
* @param string $oauthTokenSecret
*/
public function setOauthToken($oauthToken, $oauthTokenSecret)
{
$this->token = new Token($oauthToken, $oauthTokenSecret);
}
/**
* @return string|null
*/
public function getLastApiPath()
{
return $this->response->getApiPath();
}
/**
* @return int
*/
public function getLastHttpCode()
{
return $this->response->getHttpCode();
}
/**
* @return array
*/
public function getLastXHeaders()
{
return $this->response->getXHeaders();
}
/**
* @return array|object|null
*/
public function getLastBody()
{
return $this->response->getBody();
}
/**
* Resets the last response cache.
*/
public function resetLastResponse()
{
$this->response = new Response();
}
/**
* Make URLs for user browser navigation.
*
* @param string $path
* @param array $parameters
*
* @return string
*/
public function url($path, array $parameters)
{
$this->resetLastResponse();
$this->response->setApiPath($path);
$query = http_build_query($parameters);
return sprintf('%s/%s?%s', self::API_HOST, $path, $query);
}
/**
* Make /oauth/* requests to the API.
*
* @param string $path
* @param array $parameters
*
* @return array
* @throws TwitterOAuthException
*/
public function oauth($path, array $parameters = [])
{
$response = [];
$this->resetLastResponse();
$this->response->setApiPath($path);
$url = sprintf('%s/%s', self::API_HOST, $path);
$result = $this->oAuthRequest($url, 'POST', $parameters);
if ($this->getLastHttpCode() != 200) {
throw new TwitterOAuthException($result);
}
parse_str($result, $response);
$this->response->setBody($response);
return $response;
}
/**
* Make /oauth2/* requests to the API.
*
* @param string $path
* @param array $parameters
*
* @return array|object
*/
public function oauth2($path, array $parameters = [])
{
$method = 'POST';
$this->resetLastResponse();
$this->response->setApiPath($path);
$url = sprintf('%s/%s', self::API_HOST, $path);
$request = Request::fromConsumerAndToken($this->consumer, $this->token, $method, $url, $parameters);
$authorization = 'Authorization: Basic ' . $this->encodeAppAuthorization($this->consumer);
$result = $this->request($request->getNormalizedHttpUrl(), $method, $authorization, $parameters);
$response = JsonDecoder::decode($result, $this->decodeJsonAsArray);
$this->response->setBody($response);
return $response;
}
/**
* Make GET requests to the API.
*
* @param string $path
* @param array $parameters
*
* @return array|object
*/
public function get($path, array $parameters = [])
{
return $this->http('GET', self::API_HOST, $path, $parameters);
}
/**
* Make POST requests to the API.
*
* @param string $path
* @param array $parameters
*
* @return array|object
*/
public function post($path, array $parameters = [])
{
return $this->http('POST', self::API_HOST, $path, $parameters);
}
/**
* Make DELETE requests to the API.
*
* @param string $path
* @param array $parameters
*
* @return array|object
*/
public function delete($path, array $parameters = [])
{
return $this->http('DELETE', self::API_HOST, $path, $parameters);
}
/**
* Make PUT requests to the API.
*
* @param string $path
* @param array $parameters
*
* @return array|object
*/
public function put($path, array $parameters = [])
{
return $this->http('PUT', self::API_HOST, $path, $parameters);
}
/**
* Upload media to upload.twitter.com.
*
* @param string $path
* @param array $parameters
* @param boolean $chunked
*
* @return array|object
*/
public function upload($path, array $parameters = [], $chunked = false)
{
if ($chunked) {
return $this->uploadMediaChunked($path, $parameters);
} else {
return $this->uploadMediaNotChunked($path, $parameters);
}
}
/**
* Private method to upload media (not chunked) to upload.twitter.com.
*
* @param string $path
* @param array $parameters
*
* @return array|object
*/
private function uploadMediaNotChunked($path, $parameters)
{
$file = file_get_contents($parameters['media']);
$base = base64_encode($file);
$parameters['media'] = $base;
return $this->http('POST', self::UPLOAD_HOST, $path, $parameters);
}
/**
* Private method to upload media (chunked) to upload.twitter.com.
*
* @param string $path
* @param array $parameters
*
* @return array|object
*/
private function uploadMediaChunked($path, $parameters)
{
// Init
$init = $this->http('POST', self::UPLOAD_HOST, $path, [
'command' => 'INIT',
'media_type' => $parameters['media_type'],
'total_bytes' => filesize($parameters['media'])
]);
// Append
$segment_index = 0;
$media = fopen($parameters['media'], 'rb');
while (!feof($media))
{
$this->http('POST', self::UPLOAD_HOST, 'media/upload', [
'command' => 'APPEND',
'media_id' => $init->media_id_string,
'segment_index' => $segment_index++,
'media_data' => base64_encode(fread($media, self::UPLOAD_CHUNK))
]);
}
fclose($media);
// Finalize
$finalize = $this->http('POST', self::UPLOAD_HOST, 'media/upload', [
'command' => 'FINALIZE',
'media_id' => $init->media_id_string
]);
return $finalize;
}
/**
* @param string $method
* @param string $host
* @param string $path
* @param array $parameters
*
* @return array|object
*/
private function http($method, $host, $path, array $parameters)
{
$this->resetLastResponse();
$url = sprintf('%s/%s/%s.json', $host, self::API_VERSION, $path);
$this->response->setApiPath($path);
$result = $this->oAuthRequest($url, $method, $parameters);
$response = JsonDecoder::decode($result, $this->decodeJsonAsArray);
$this->response->setBody($response);
return $response;
}
/**
* Format and sign an OAuth / API request
*
* @param string $url
* @param string $method
* @param array $parameters
*
* @return string
* @throws TwitterOAuthException
*/
private function oAuthRequest($url, $method, array $parameters)
{
$request = Request::fromConsumerAndToken($this->consumer, $this->token, $method, $url, $parameters);
if (array_key_exists('oauth_callback', $parameters)) {
// Twitter doesn't like oauth_callback as a parameter.
unset($parameters['oauth_callback']);
}
if ($this->bearer === null) {
$request->signRequest($this->signatureMethod, $this->consumer, $this->token);
$authorization = $request->toHeader();
} else {
$authorization = 'Authorization: Bearer ' . $this->bearer;
}
return $this->request($request->getNormalizedHttpUrl(), $method, $authorization, $parameters);
}
/**
* Make an HTTP request
*
* @param string $url
* @param string $method
* @param string $authorization
* @param array $postfields
*
* @return string
* @throws TwitterOAuthException
*/
private function request($url, $method, $authorization, $postfields)
{
/* Curl settings */
$options = [
// CURLOPT_VERBOSE => true,
CURLOPT_CAINFO => __DIR__ . DIRECTORY_SEPARATOR . 'cacert.pem',
CURLOPT_CONNECTTIMEOUT => $this->connectionTimeout,
CURLOPT_HEADER => true,
CURLOPT_HTTPHEADER => ['Accept: application/json', $authorization, 'Expect:'],
CURLOPT_RETURNTRANSFER => true,
CURLOPT_SSL_VERIFYHOST => 2,
CURLOPT_SSL_VERIFYPEER => true,
CURLOPT_TIMEOUT => $this->timeout,
CURLOPT_URL => $url,
CURLOPT_USERAGENT => $this->userAgent,
CURLOPT_ENCODING => 'gzip',
];
if (!empty($this->proxy)) {
$options[CURLOPT_PROXY] = $this->proxy['CURLOPT_PROXY'];
$options[CURLOPT_PROXYUSERPWD] = $this->proxy['CURLOPT_PROXYUSERPWD'];
$options[CURLOPT_PROXYPORT] = $this->proxy['CURLOPT_PROXYPORT'];
$options[CURLOPT_PROXYAUTH] = CURLAUTH_BASIC;
$options[CURLOPT_PROXYTYPE] = CURLPROXY_HTTP;
}
switch ($method) {
case 'GET':
break;
case 'POST':
$options[CURLOPT_POST] = true;
$options[CURLOPT_POSTFIELDS] = Util::buildHttpQuery($postfields);
break;
case 'DELETE':
$options[CURLOPT_CUSTOMREQUEST] = 'DELETE';
break;
case 'PUT':
$options[CURLOPT_CUSTOMREQUEST] = 'PUT';
break;
}
if (in_array($method, ['GET', 'PUT', 'DELETE']) && !empty($postfields)) {
$options[CURLOPT_URL] .= '?' . Util::buildHttpQuery($postfields);
}
$curlHandle = curl_init();
curl_setopt_array($curlHandle, $options);
$response = curl_exec($curlHandle);
// Throw exceptions on cURL errors.
if (curl_errno($curlHandle) > 0) {
throw new TwitterOAuthException(curl_error($curlHandle), curl_errno($curlHandle));
}
$this->response->setHttpCode(curl_getinfo($curlHandle, CURLINFO_HTTP_CODE));
$parts = explode("\r\n\r\n", $response);
$responseBody = array_pop($parts);
$responseHeader = array_pop($parts);
$this->response->setHeaders($this->parseHeaders($responseHeader));
curl_close($curlHandle);
return $responseBody;
}
/**
* Get the header info to store.
*
* @param string $header
*
* @return array
*/
private function parseHeaders($header)
{
$headers = [];
foreach (explode("\r\n", $header) as $line) {
if (strpos($line, ':') !== false) {
list ($key, $value) = explode(': ', $line);
$key = str_replace('-', '_', strtolower($key));
$headers[$key] = trim($value);
}
}
return $headers;
}
/**
* Encode application authorization header with base64.
*
* @param Consumer $consumer
*
* @return string
*/
private function encodeAppAuthorization($consumer)
{
// TODO: key and secret should be rfc 1738 encoded
$key = $consumer->key;
$secret = $consumer->secret;
return base64_encode($key . ':' . $secret);
}
}

View File

@ -0,0 +1,10 @@
<?php
namespace Abraham\TwitterOAuth;
/**
* @author Abraham Williams <abraham@abrah.am>
*/
class TwitterOAuthException extends \Exception
{
}

View File

@ -0,0 +1,115 @@
<?php
/**
* The MIT License
* Copyright (c) 2007 Andy Smith
*/
namespace Abraham\TwitterOAuth;
class Util
{
/**
* @param $input
*
* @return array|mixed|string
*/
public static function urlencodeRfc3986($input)
{
$output = '';
if (is_array($input)) {
$output = array_map([__NAMESPACE__ . '\Util', 'urlencodeRfc3986'], $input);
} elseif (is_scalar($input)) {
$output = rawurlencode($input);
}
return $output;
}
/**
* @param string $string
*
* @return string
*/
public static function urldecodeRfc3986($string)
{
return urldecode($string);
}
/**
* This function takes a input like a=b&a=c&d=e and returns the parsed
* parameters like this
* array('a' => array('b','c'), 'd' => 'e')
*
* @param mixed $input
*
* @return array
*/
public static function parseParameters($input)
{
if (!isset($input) || !$input) {
return [];
}
$pairs = explode('&', $input);
$parameters = [];
foreach ($pairs as $pair) {
$split = explode('=', $pair, 2);
$parameter = Util::urldecodeRfc3986($split[0]);
$value = isset($split[1]) ? Util::urldecodeRfc3986($split[1]) : '';
if (isset($parameters[$parameter])) {
// We have already recieved parameter(s) with this name, so add to the list
// of parameters with this name
if (is_scalar($parameters[$parameter])) {
// This is the first duplicate, so transform scalar (string) into an array
// so we can add the duplicates
$parameters[$parameter] = [$parameters[$parameter]];
}
$parameters[$parameter][] = $value;
} else {
$parameters[$parameter] = $value;
}
}
return $parameters;
}
/**
* @param $params
*
* @return string
*/
public static function buildHttpQuery($params)
{
if (!$params) {
return '';
}
// Urlencode both keys and values
$keys = Util::urlencodeRfc3986(array_keys($params));
$values = Util::urlencodeRfc3986(array_values($params));
$params = array_combine($keys, $values);
// Parameters are sorted by name, using lexicographical byte value ordering.
// Ref: Spec: 9.1.1 (1)
uksort($params, 'strcmp');
$pairs = [];
foreach ($params as $parameter => $value) {
if (is_array($value)) {
// If two or more parameters share the same name, they are sorted by their value
// Ref: Spec: 9.1.1 (1)
// June 12th, 2010 - changed to sort because of issue 164 by hidetaka
sort($value, SORT_STRING);
foreach ($value as $duplicateValue) {
$pairs[] = $parameter . '=' . $duplicateValue;
}
} else {
$pairs[] = $parameter . '=' . $value;
}
}
// For each parameter, the name is separated from the corresponding value by an '=' character (ASCII code 61)
// Each name-value pair is separated by an '&' character (ASCII code 38)
return implode('&', $pairs);
}
}

View File

@ -0,0 +1,26 @@
<?php
namespace Abraham\TwitterOAuth\Util;
/**
* @author louis <louis@systemli.org>
*/
class JsonDecoder
{
/**
* Decodes a JSON string to stdObject or associative array
*
* @param string $string
* @param bool $asArray
*
* @return array|object
*/
public static function decode($string, $asArray)
{
if (version_compare(PHP_VERSION, '5.4.0', '>=') && !(defined('JSON_C_VERSION') && PHP_INT_SIZE > 4)) {
return json_decode($string, $asArray, 512, JSON_BIGINT_AS_STRING);
}
return json_decode($string, $asArray);
}
}

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,31 @@
<?php
session_start();
ini_set('display_errors', 1);
require 'autoload.php';
use Abraham\TwitterOAuth\TwitterOAuth;
require_once('config.php');
/* Prepara la conexión */
$connection = new TwitterOAuth(CONSUMER_KEY, CONSUMER_SECRET);
/* Solicita a twitter las credenciales temporales */
//$request_token = $connection->getRequestToken(OAUTH_CALLBACK);
$request_token = $connection->oauth('oauth/request_token');
/* Guarda la credenciales temporales en sesión. */
$_SESSION['oauth_token'] = $token = $request_token['oauth_token'];
$_SESSION['oauth_token_secret'] = $request_token['oauth_token_secret'];
//switch ($connection->http_code) {
// case 200:
/* Construye la url de autorización y envía al usuario a Twitter. */
$url = $connection->url('oauth/authorize', array('oauth_token' => $request_token['oauth_token']));
//$url = $connection->url('oauth/authorize', array('oauth_token' => $request_token['oauth_token']));
//$url = $connection->getAuthorizeURL($token);
// print $url;
header('Location: ' . $url);
//break;
// default:
/* Indica que se ha producido un error. */
// echo 'Error de conexión a Twitter.';
// echo "\nHTTP CODE: " . $connection->http_code;
//}

177
addon/logis/grabar.php Normal file
View File

@ -0,0 +1,177 @@
<?php session_start();
ini_set('display_errors', 'On');
if(isset($_REQUEST['debug'])) {ini_set('display_errors', 'On');}
include_once("$_SESSION[path]/funciones/conex.php");
echo brigadistas_grabar($_POST);
function brigadistas_grabar($formulario) {
$identificador = $_POST['identificador'];
$control = md5("$identificador");
$data = $_POST['debugConsole'];
$imagen= grabar_imagen($data,$control);
$texto_url = urlencode("#BrigadaDigital");
$uri = urlencode("$_SESSION[url]/images/secure/?file=600/$imagen");
$url ="https://twitter.com/share?url=$uri&text=$texto_url";
//$respuesta->addScript("window.location.href ='$url';");
$preview = "
<div class='row'>
<div class='center-block'>
<div class='thumbnail'>
<img src='$_SESSION[url]/images/secure/?file=300/$imagen'>
<a download='brigadistas.png' href='$_SESSION[url]images/secure/?file=600/$imagen' >
<span class='btn btn-default'><i class='fa fa-download'></i> </span>
</a>
<span class='btn btn-default'>
<a onclick =\"javascript:window.location.href ='$url'; \" ><i class='fa fa-twitter'></i> </a>
</span>
<a href='?set=$formulario[formulario_id]&embebido'>
<span class='btn btn-default'><i class='fa fa-eye'></i> </span>
</a>
<a href='#' onclick = \"javascript:location.reload(); \">
<span class='btn btn-default'><i class='fa fa-refresh'></i> </span>
</a>
</div>
</div>
</div>
";
//$respuesta = new xajaxResponse('utf-8');
//$identificador = $formulario['identificador'];
$id_formulario = $_POST['formulario_id'];
$campo_imagen = buscar_campo_tipo("$id_formulario","15");
$_POST[$campo_imagen[0]][0] = $imagen;
$empresa = remplacetas('form_id','id',"$id_formulario",'id_empresa',"") ;
$id_empresa = $empresa[0];
include_once("$_SESSION[path]/funciones/conex.php");
//include_once("$_SESSION[url]funciones/conex.php");
$link=Conectarse();
mysqli_query("SET NAMES 'utf8'");
$ip = obtener_ip();
$ip = " INET_ATON('".$ip."') ";
foreach($_POST as $campo=>$valor){
if(is_array($valor)) {
foreach($valor as $c=>$v){
$consulta = "INSERT INTO form_datos ( timestamp,id_usuario,id_empresa,form_id,ip,control,id_campo,contenido) VALUES
( UNIX_TIMESTAMP(),'$_SESSION[id]','$id_empresa','$id_formulario','$ip' ,'$control', '$campo' , '$v')
";
$sql=mysqli_query($consulta,$link);
// $campos .= " $campo // $valor // $c -> $v $consulta <br>";
}
}
}
$resultado = "$preview $consulta ";
///$respuesta->addAssign("aviso","innerHTML","$preview");
//$respuesta->addAlert("$resultado");
//$respuesta->addScript("javascript:location.reload(true);");
return $resultado;
}
function remplacetas($tabla,$campo,$valor,$por,$and){
$link=Conectarse();
mysqli_query("SET NAMES 'utf8'");
if(@$and !=''){$AND = "AND $and";}else{$AND ="";}
//$consulta = "SELECT * , md5(binary $por ) as md5_".$por." FROM $tabla WHERE $campo = '$valor' $AND order by $campo DESC limit 1";
$consulta = "SELECT * , md5(binary $por ) as md5_".$por." FROM $tabla WHERE $campo = '$valor' $AND order by id DESC limit 1";
$sql=mysqli_query($consulta,$link);
if (@mysql_num_rows($sql)!=0){
$resultado[] = mysql_result($sql,0,$por);
$resultado[] = mysql_result($sql,0,'id');
$resultado[] = $consulta;
$resultado[] = mysql_result($sql,0,"md5_$por");
}else{
$resultado[0] = '';
$resultado[1] ="";
$resultado[2] = $consulta;
$resultado[3] = NULL;
}
return $resultado;
}
function grabar_imagen($imagen,$control) {
$imgData = str_replace(' ','+',$imagen);
$imgData = substr($imgData,strpos($imgData,",")+1);
$imgData = base64_decode($imgData);
$nombre= $control.".png";
$filePath = "$_SESSION[path]/tmp/".$nombre;
$file = fopen($filePath, 'w');
fwrite($file, $imgData);
fclose($file);
$full= "$_SESSION[path_images_secure]/full/".$nombre;
if (!rename($filePath,$full)){}
else {
echo generar_miniatura($nombre,"150");
echo generar_miniatura($nombre,"300");
echo generar_miniatura($nombre,"600");
}
//return "$nombre";
return "$nombre";
}
function generar_miniatura($file,$width) { //$archivo = $file;
$archivo = "$_SESSION[path_images_secure]/full/".$file; // Ponemos el . antes del nombre del archivo porque estamos considerando que la ruta está a partir del archivo thumb.php $file_info = getimagesize($archivo); // Obtenemos la relación de aspecto $ratio = $file_info[0] / $file_info[1]; // Calculamos las nuevas dimensiones $newwidth = $width; $newheight = round($newwidth / $ratio); // Sacamos la extensión del archivo $ext = explode(".", $file); $ext = strtolower($ext[count($ext) - 1]); if ($ext == "jpeg") $ext = "jpg"; // Dependiendo de la extensión llamamos a distintas funciones switch ($ext) { case "jpg": $img = imagecreatefromjpeg($archivo); break; case "png": $img = imagecreatefrompng($archivo); break; case "gif": $img = imagecreatefromgif($archivo); break; } // Creamos la miniatura $thumb = imagecreatetruecolor($newwidth, $newheight);
imagealphablending( $thumb, false );
imagesavealpha( $thumb, true ); // La redimensionamos imagecopyresampled($thumb, $img, 0, 0, 0, 0, $newwidth, $newheight, $file_info[0], $file_info[1]); // La mostramos como jpg //header("Content-type: image/jpeg"); imagejpeg($thumb,"$_SESSION[path_images_secure]/".$width."/$file", 80);
imagepng($thumb,"$_SESSION[path_images_secure]/".$width."/$file", 9);
//imagegif($thumb,"$_SESSION[path_images_secure]/".$width."/$file");
//imagejpeg($thumb,null, 80);
}
function buscar_campo_tipo($id,$tipo) {
//// esta función retorna el id para un campo de un tipo especifico dentro de un formulario.
$consulta ="SELECT form_campos.id, form_campos.campo_nombre FROM form_tipo_campo,form_campos,form_contenido_campos
WHERE form_tipo_campo.id_tipo_campo = form_campos.campo_tipo
AND form_contenido_campos.id_campo = form_campos.id
AND form_tipo_campo.id_tipo_campo = '$tipo'
AND form_contenido_campos.id_form = '$id'";
$link=Conectarse();
mysqli_query("SET NAMES 'utf8'");
$sql=mysqli_query($consulta,$link);
if (mysql_num_rows($sql)!='0'){
$resultado[0]=mysql_result($sql,0,"id");
$resultado[1]=mysql_result($sql,0,"campo_nombre");
$resultado[2] =$consulta;
}else{ $resultado[0]='';
$resultado[2] =$consulta;
}
return $resultado;
}
function obtener_ip()
{
if (isset($_SERVER["HTTP_CLIENT_IP"]))
{
return $_SERVER["HTTP_CLIENT_IP"];
}
elseif (isset($_SERVER["HTTP_X_FORWARDED_FOR"]))
{
return $_SERVER["HTTP_X_FORWARDED_FOR"];
}
elseif (isset($_SERVER["HTTP_X_FORWARDED"]))
{
return $_SERVER["HTTP_X_FORWARDED"];
}
elseif (isset($_SERVER["HTTP_FORWARDED_FOR"]))
{
return $_SERVER["HTTP_FORWARDED_FOR"];
}
elseif (isset($_SERVER["HTTP_FORWARDED"]))
{
return $_SERVER["HTTP_FORWARDED"];
}
else
{
return $_SERVER["REMOTE_ADDR"];
}
}
?>

Binary file not shown.

After

Width:  |  Height:  |  Size: 20 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 49 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 38 KiB

13
addon/logis/js/demo.js Normal file
View File

@ -0,0 +1,13 @@
/*
* JavaScript Load Image Demo JS 1.9.1
* https://github.com/blueimp/JavaScript-Load-Image
*
* Copyright 2013, Sebastian Tschan
* https://blueimp.net
*
* Licensed under the MIT license:
* http://www.opensource.org/licenses/MIT
*/

View File

@ -0,0 +1,143 @@
/*
* JavaScript Load Image Meta 1.0.2
* https://github.com/blueimp/JavaScript-Load-Image
*
* Copyright 2013, Sebastian Tschan
* https://blueimp.net
*
* Image meta data handling implementation
* based on the help and contribution of
* Achim Stöhr.
*
* Licensed under the MIT license:
* http://www.opensource.org/licenses/MIT
*/
/*jslint continue:true */
/*global define, window, DataView, Blob, Uint8Array, console */
(function (factory) {
'use strict';
if (typeof define === 'function' && define.amd) {
// Register as an anonymous AMD module:
define(['load-image'], factory);
} else {
// Browser globals:
factory(window.loadImage);
}
}(function (loadImage) {
'use strict';
var hasblobSlice = window.Blob && (Blob.prototype.slice ||
Blob.prototype.webkitSlice || Blob.prototype.mozSlice);
loadImage.blobSlice = hasblobSlice && function () {
var slice = this.slice || this.webkitSlice || this.mozSlice;
return slice.apply(this, arguments);
};
loadImage.metaDataParsers = {
jpeg: {
0xffe1: [] // APP1 marker
}
};
// Parses image meta data and calls the callback with an object argument
// with the following properties:
// * imageHead: The complete image head as ArrayBuffer (Uint8Array for IE10)
// The options arguments accepts an object and supports the following properties:
// * maxMetaDataSize: Defines the maximum number of bytes to parse.
// * disableImageHead: Disables creating the imageHead property.
loadImage.parseMetaData = function (file, callback, options) {
options = options || {};
var that = this,
// 256 KiB should contain all EXIF/ICC/IPTC segments:
maxMetaDataSize = options.maxMetaDataSize || 262144,
data = {},
noMetaData = !(window.DataView && file && file.size >= 12 &&
file.type === 'image/jpeg' && loadImage.blobSlice);
if (noMetaData || !loadImage.readFile(
loadImage.blobSlice.call(file, 0, maxMetaDataSize),
function (e) {
if (e.target.error) {
// FileReader error
console.log(e.target.error);
callback(data);
return;
}
// Note on endianness:
// Since the marker and length bytes in JPEG files are always
// stored in big endian order, we can leave the endian parameter
// of the DataView methods undefined, defaulting to big endian.
var buffer = e.target.result,
dataView = new DataView(buffer),
offset = 2,
maxOffset = dataView.byteLength - 4,
headLength = offset,
markerBytes,
markerLength,
parsers,
i;
// Check for the JPEG marker (0xffd8):
if (dataView.getUint16(0) === 0xffd8) {
while (offset < maxOffset) {
markerBytes = dataView.getUint16(offset);
// Search for APPn (0xffeN) and COM (0xfffe) markers,
// which contain application-specific meta-data like
// Exif, ICC and IPTC data and text comments:
if ((markerBytes >= 0xffe0 && markerBytes <= 0xffef) ||
markerBytes === 0xfffe) {
// The marker bytes (2) are always followed by
// the length bytes (2), indicating the length of the
// marker segment, which includes the length bytes,
// but not the marker bytes, so we add 2:
markerLength = dataView.getUint16(offset + 2) + 2;
if (offset + markerLength > dataView.byteLength) {
console.log('Invalid meta data: Invalid segment size.');
break;
}
parsers = loadImage.metaDataParsers.jpeg[markerBytes];
if (parsers) {
for (i = 0; i < parsers.length; i += 1) {
parsers[i].call(
that,
dataView,
offset,
markerLength,
data,
options
);
}
}
offset += markerLength;
headLength = offset;
} else {
// Not an APPn or COM marker, probably safe to
// assume that this is the end of the meta data
break;
}
}
// Meta length must be longer than JPEG marker (2)
// plus APPn marker (2), followed by length bytes (2):
if (!options.disableImageHead && headLength > 6) {
if (buffer.slice) {
data.imageHead = buffer.slice(0, headLength);
} else {
// Workaround for IE10, which does not yet
// support ArrayBuffer.slice:
data.imageHead = new Uint8Array(buffer)
.subarray(0, headLength);
}
}
} else {
console.log('Invalid JPEG file: Missing JPEG marker.');
}
callback(data);
},
'readAsArrayBuffer'
)) {
callback(data);
}
};
}));

View File

@ -0,0 +1,166 @@
/*
* JavaScript Load Image Orientation 1.1.0
* https://github.com/blueimp/JavaScript-Load-Image
*
* Copyright 2013, Sebastian Tschan
* https://blueimp.net
*
* Licensed under the MIT license:
* http://www.opensource.org/licenses/MIT
*/
/*global define, window */
(function (factory) {
'use strict';
if (typeof define === 'function' && define.amd) {
// Register as an anonymous AMD module:
define(['load-image'], factory);
} else {
// Browser globals:
factory(window.loadImage);
}
}(function (loadImage) {
'use strict';
var originalHasCanvasOption = loadImage.hasCanvasOption,
originalTransformCoordinates = loadImage.transformCoordinates,
originalGetTransformedOptions = loadImage.getTransformedOptions;
// This method is used to determine if the target image
// should be a canvas element:
loadImage.hasCanvasOption = function (options) {
return originalHasCanvasOption.call(loadImage, options) ||
options.orientation;
};
// Transform image orientation based on
// the given EXIF orientation option:
loadImage.transformCoordinates = function (canvas, options) {
originalTransformCoordinates.call(loadImage, canvas, options);
var ctx = canvas.getContext('2d'),
width = canvas.width,
height = canvas.height,
orientation = options.orientation;
if (!orientation || orientation > 8) {
return;
}
if (orientation > 4) {
canvas.width = height;
canvas.height = width;
}
switch (orientation) {
case 2:
// horizontal flip
ctx.translate(width, 0);
ctx.scale(-1, 1);
break;
case 3:
// 180° rotate left
ctx.translate(width, height);
ctx.rotate(Math.PI);
break;
case 4:
// vertical flip
ctx.translate(0, height);
ctx.scale(1, -1);
break;
case 5:
// vertical flip + 90 rotate right
ctx.rotate(0.5 * Math.PI);
ctx.scale(1, -1);
break;
case 6:
// 90° rotate right
ctx.rotate(0.5 * Math.PI);
ctx.translate(0, -height);
break;
case 7:
// horizontal flip + 90 rotate right
ctx.rotate(0.5 * Math.PI);
ctx.translate(width, -height);
ctx.scale(-1, 1);
break;
case 8:
// 90° rotate left
ctx.rotate(-0.5 * Math.PI);
ctx.translate(-width, 0);
break;
}
};
// Transforms coordinate and dimension options
// based on the given orientation option:
loadImage.getTransformedOptions = function (img, opts) {
var options = originalGetTransformedOptions.call(loadImage, img, opts),
orientation = options.orientation,
newOptions,
i;
if (!orientation || orientation > 8 || orientation === 1) {
return options;
}
newOptions = {};
for (i in options) {
if (options.hasOwnProperty(i)) {
newOptions[i] = options[i];
}
}
switch (options.orientation) {
case 2:
// horizontal flip
newOptions.left = options.right;
newOptions.right = options.left;
break;
case 3:
// 180° rotate left
newOptions.left = options.right;
newOptions.top = options.bottom;
newOptions.right = options.left;
newOptions.bottom = options.top;
break;
case 4:
// vertical flip
newOptions.top = options.bottom;
newOptions.bottom = options.top;
break;
case 5:
// vertical flip + 90 rotate right
newOptions.left = options.top;
newOptions.top = options.left;
newOptions.right = options.bottom;
newOptions.bottom = options.right;
break;
case 6:
// 90° rotate right
newOptions.left = options.top;
newOptions.top = options.right;
newOptions.right = options.bottom;
newOptions.bottom = options.left;
break;
case 7:
// horizontal flip + 90 rotate right
newOptions.left = options.bottom;
newOptions.top = options.right;
newOptions.right = options.top;
newOptions.bottom = options.left;
break;
case 8:
// 90° rotate left
newOptions.left = options.bottom;
newOptions.top = options.left;
newOptions.right = options.top;
newOptions.bottom = options.right;
break;
}
if (options.orientation > 4) {
newOptions.maxWidth = options.maxHeight;
newOptions.maxHeight = options.maxWidth;
newOptions.minWidth = options.minHeight;
newOptions.minHeight = options.minWidth;
newOptions.sourceWidth = options.sourceHeight;
newOptions.sourceHeight = options.sourceWidth;
}
return newOptions;
};
}));

1
addon/logis/js/load-image.all.min.js vendored Normal file

File diff suppressed because one or more lines are too long

View File

@ -0,0 +1,305 @@
/*
* JavaScript Load Image 1.10.0
* https://github.com/blueimp/JavaScript-Load-Image
*
* Copyright 2011, Sebastian Tschan
* https://blueimp.net
*
* Licensed under the MIT license:
* http://www.opensource.org/licenses/MIT
*/
/*jslint nomen: true */
/*global define, window, document, URL, webkitURL, Blob, File, FileReader */
(function ($) {
'use strict';
// Loads an image for a given File object.
// Invokes the callback with an img or optional canvas
// element (if supported by the browser) as parameter:
var loadImage = function (file, callback, options) {
var img = document.createElement('img'),
url,
oUrl;
//img.setAttribute('class', 'watermark');
// img.setAttribute('id', 'image_output2');
img.onerror = callback;
img.onload = function () {
if (oUrl && !(options && options.noRevoke)) {
loadImage.revokeObjectURL(oUrl);
}
if (callback) {
callback(loadImage.scale(img, options));
}
};
if (loadImage.isInstanceOf('Blob', file) ||
// Files are also Blob instances, but some browsers
// (Firefox 3.6) support the File API but not Blobs:
loadImage.isInstanceOf('File', file)) {
url = oUrl = loadImage.createObjectURL(file);
// Store the file type for resize processing:
img._type = file.type;
} else if (typeof file === 'string') {
url = file;
if (options && options.crossOrigin) {
img.crossOrigin = options.crossOrigin;
}
} else {
return false;
}
if (url) {
img.src = url;
//document.getElementById('image_output').src = url ;
//document.getElementById('image_output').className = "watermark" ;
return img;
}
return loadImage.readFile(file, function (e) {
var target = e.target;
if (target && target.result) {
img.src = target.result;
} else {
if (callback) {
callback(e);
}
}
});
},
// The check for URL.revokeObjectURL fixes an issue with Opera 12,
// which provides URL.createObjectURL but doesn't properly implement it:
urlAPI = (window.createObjectURL && window) ||
(window.URL && URL.revokeObjectURL && URL) ||
(window.webkitURL && webkitURL);
loadImage.isInstanceOf = function (type, obj) {
// Cross-frame instanceof check
return Object.prototype.toString.call(obj) === '[object ' + type + ']';
};
// Transform image coordinates, allows to override e.g.
// the canvas orientation based on the orientation option,
// gets canvas, options passed as arguments:
loadImage.transformCoordinates = function () {
return;
};
// Returns transformed options, allows to override e.g.
// maxWidth, maxHeight and crop options based on the aspectRatio.
// gets img, options passed as arguments:
loadImage.getTransformedOptions = function (img, options) {
var aspectRatio = options.aspectRatio,
newOptions,
i,
width,
height;
if (!aspectRatio) {
return options;
}
newOptions = {};
for (i in options) {
if (options.hasOwnProperty(i)) {
newOptions[i] = options[i];
}
}
newOptions.crop = true;
width = img.naturalWidth || img.width;
height = img.naturalHeight || img.height;
if (width / height > aspectRatio) {
newOptions.maxWidth = height * aspectRatio;
newOptions.maxHeight = height;
} else {
newOptions.maxWidth = width;
newOptions.maxHeight = width / aspectRatio;
}
return newOptions;
};
// Canvas render method, allows to override the
// rendering e.g. to work around issues on iOS:
loadImage.renderImageToCanvas = function (
canvas,
img,
sourceX,
sourceY,
sourceWidth,
sourceHeight,
destX,
destY,
destWidth,
destHeight
) {
canvas.getContext('2d').drawImage(
img,
sourceX,
sourceY,
sourceWidth,
sourceHeight,
destX,
destY,
destWidth,
destHeight
);
return canvas;
};
// This method is used to determine if the target image
// should be a canvas element:
loadImage.hasCanvasOption = function (options) {
return options.canvas || options.crop || options.aspectRatio;
};
// Scales and/or crops the given image (img or canvas HTML element)
// using the given options.
// Returns a canvas object if the browser supports canvas
// and the hasCanvasOption method returns true or a canvas
// object is passed as image, else the scaled image:
loadImage.scale = function (img, options) {
options = options || {};
var canvas = document.createElement('canvas'),
useCanvas = img.getContext ||
(loadImage.hasCanvasOption(options) && canvas.getContext),
width = img.naturalWidth || img.width,
height = img.naturalHeight || img.height,
destWidth = width,
destHeight = height,
maxWidth,
maxHeight,
minWidth,
minHeight,
sourceWidth,
sourceHeight,
sourceX,
sourceY,
tmp,
scaleUp = function () {
var scale = Math.max(
(minWidth || destWidth) / destWidth,
(minHeight || destHeight) / destHeight
);
if (scale > 1) {
destWidth = destWidth * scale;
destHeight = destHeight * scale;
}
},
scaleDown = function () {
var scale = Math.min(
(maxWidth || destWidth) / destWidth,
(maxHeight || destHeight) / destHeight
);
if (scale < 1) {
destWidth = destWidth * scale;
destHeight = destHeight * scale;
}
};
if (useCanvas) {
options = loadImage.getTransformedOptions(img, options);
sourceX = options.left || 0;
sourceY = options.top || 0;
if (options.sourceWidth) {
sourceWidth = options.sourceWidth;
if (options.right !== undefined && options.left === undefined) {
sourceX = width - sourceWidth - options.right;
}
} else {
sourceWidth = width - sourceX - (options.right || 0);
}
if (options.sourceHeight) {
sourceHeight = options.sourceHeight;
if (options.bottom !== undefined && options.top === undefined) {
sourceY = height - sourceHeight - options.bottom;
}
} else {
sourceHeight = height - sourceY - (options.bottom || 0);
}
destWidth = sourceWidth;
destHeight = sourceHeight;
}
maxWidth = options.maxWidth;
maxHeight = options.maxHeight;
minWidth = options.minWidth;
minHeight = options.minHeight;
if (useCanvas && maxWidth && maxHeight && options.crop) {
destWidth = maxWidth;
destHeight = maxHeight;
tmp = sourceWidth / sourceHeight - maxWidth / maxHeight;
if (tmp < 0) {
sourceHeight = maxHeight * sourceWidth / maxWidth;
if (options.top === undefined && options.bottom === undefined) {
sourceY = (height - sourceHeight) / 2;
}
} else if (tmp > 0) {
sourceWidth = maxWidth * sourceHeight / maxHeight;
if (options.left === undefined && options.right === undefined) {
sourceX = (width - sourceWidth) / 2;
}
}
} else {
if (options.contain || options.cover) {
minWidth = maxWidth = maxWidth || minWidth;
minHeight = maxHeight = maxHeight || minHeight;
}
if (options.cover) {
scaleDown();
scaleUp();
} else {
scaleUp();
scaleDown();
}
}
if (useCanvas) {
canvas.width = destWidth;
canvas.height = destHeight;
loadImage.transformCoordinates(
canvas,
options
);
return loadImage.renderImageToCanvas(
canvas,
img,
sourceX,
sourceY,
sourceWidth,
sourceHeight,
0,
0,
destWidth,
destHeight
);
}
img.width = destWidth;
img.height = destHeight;
return img;
};
loadImage.createObjectURL = function (file) {
return urlAPI ? urlAPI.createObjectURL(file) : false;
};
loadImage.revokeObjectURL = function (url) {
return urlAPI ? urlAPI.revokeObjectURL(url) : false;
};
// Loads a given File object via FileReader interface,
// invokes the callback with the event object (load or error).
// The result can be read via event.target.result:
loadImage.readFile = function (file, callback, method) {
if (window.FileReader) {
var fileReader = new FileReader();
fileReader.onload = fileReader.onerror = callback;
method = method || 'readAsDataURL';
if (fileReader[method]) {
fileReader[method](file);
return fileReader;
}
}
return false;
};
if (typeof define === 'function' && define.amd) {
define(function () {
return loadImage;
});
} else {
$.loadImage = loadImage;
}
}(window));

365
addon/logis/logis.php Normal file
View File

@ -0,0 +1,365 @@
<?php
//include("funciones/funciones.php");
//$id_formulario = "58";
$id_formulario = "88";
$ancho = "600";
$tags = array();
//$tags[] = "milfs/addon/logis/images/logos/250.png";
$tags[] = "milfs/addon/logis/images/logos/c.png";
$imagen="";
foreach ($tags as &$valor) {
$imagen .= "<td onclick=\" document.getElementById('marca').src='$valor' ; marcar('top-left') \" ><a href='#medio' class='' >
<img class='img ' src='$valor'>
</a></td>";
}
$imagen = "
<div class='table-responsive'>
<table class='table table table-condensed text-center '>
<tr >
$imagen
</tr>
</table>
</div>";
?>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js"></script>
<div>
<style type="text/css">
.fa{
font-size:60px important!;
}
#imagen_origina{
width: <?php echo $ancho ?>px;
}
body{
background-color:white !important;
}
.pin {
text-align: center;
/*border: solid 1px red;*/
opacity: 0.5;
}
.fileUpload {
position: relative;
overflow: hidden;
margin: 10px;
width: 80%;
}
.fileUpload input.upload {
position: absolute;
top: 0;
right: 0;
margin: 10;
padding: 0;
font-size: 50px;
cursor: pointer;
opacity: 0;
filter: alpha(opacity=0);
}
.ing-touch{
border: solid 5px white;
width:20% !important;
}
</style>
<div class='container' style='height:100%; backgroun-color:white;' id='aviso'>
<div class='fileUpload btn btn-primary center-block'>
<span><h1><i class="fa fa-camera"></i> + tu Foto</h1></span>
<input class='upload' type="file" id="file-input" /></span>
<div id="original" ></div>
</div>
<!-- <p><input type="file" id="file-input"></p> -->
<div id="actions" style="display:none;">
<img class="center-block" src= "<?php echo $tags[0]; ?>" style='display:none' id="marca" name="marca">
<img class="center-block" style='' id="image_output" name="image_output">
<img class="center-block" style='' id="otra_imagen" name="otra_imagen">
<div id="result" class="result">
<p></p>
</div>
<a name="arriba"></a>
<canvas id="micanvasOriginal" style="position:absolute" >
Tu navegador no soporta canvas.
</canvas>
<div style="position:relative">
<div style="position:absolute; width:100%; height:100%;" >
<table style="width:100%; height:100%;" class="">
<tr >
<td class="pin" ><a href="#arriba" onclick=" javascript: marcar('top-left')"><img class="ing-touch img img-circle img-responsive center-block " style="width:20%;" src="milfs/images/oscuro40.png"></a></td>
<td class="pin"><a href="#arriba" onclick=" javascript: marcar('top-center')"><img class="ing-touch img img-circle img-responsive center-block " style="width:20%;" src="milfs/images/oscuro40.png"></a></td>
<td class="pin"><a href="#arriba" onclick=" javascript: marcar('top-rigth')"><img class="ing-touch img img-circle img-responsive center-block " style="width:50%;" src="milfs/images/oscuro40.png"></a></td>
</tr>
<tr>
<td class="pin"><a name="medio"></a><a href="#arriba" onclick=" javascript: marcar('middle-left')"><img class="ing-touch img img-circle img-responsive center-block " style="width:50%;" src="milfs/images/oscuro40.png"></a></td>
<td class="pin" ><a href="#medio" onclick=" javascript: marcar('middle-center')"><img class="ing-touch img img-circle img-responsive center-block " style="width:50%;" src="milfs/images/oscuro40.png"></a></td>
<td class="pin"><a href="#medio" onclick=" javascript: marcar('middle-rigth')"><img class="ing-touch img img-circle img-responsive center-block " style="width:50%;" src="milfs/images/oscuro40.png"></td>
</tr>
<tr>
<td class="pin"><a href="#medio" onclick=" javascript: marcar('bottom-left')"><img class="ing-touch img img-circle img-responsive center-block " style="width:50%;" src="milfs/images/oscuro40.png"></a></td>
<td class="pin"><a href="#medio" onclick=" javascript: marcar('bottom-center')"><img class="ing-touch img img-circle img-responsive center-block " style="width:50%;" src="milfs/images/oscuro40.png"></a></td>
<td class="pin"><a href="#medio" onclick=" javascript: marcar('bottom-rigth')"><img class="ing-touch img img-circle img-responsive center-block " style="width:50%;" src="milfs/images/oscuro40.png"></a></td>
</tr>
</table>
</div>
<canvas id="micanvas" style="position:absolute" >
Tu navegador no soporta canvas.
</canvas>
</div>
<div class="row " style="position:relative">
<form id='formulario_brigadistas' name='formulario_brigadistas' >
<!-- <input class='form-control' type='' id="debugConsole" name="debugConsole" > -->
<textarea class='form-control' id="debugConsole" name="debugConsole" style="display:none;" ></textarea>
<input type='hidden' id="identificador" name="identificador" >
<input type='hidden' id="formulario_id" name="formulario_id" value="<?php echo $id_formulario; ?>">
<input type='hidden' id="imagen" name="imagen" value="">
<?php $formulario = formulario_areas("$id_formulario",'campos','','');
echo $formulario; ?>
</form>
</div>
<!-- <div id='aviso'></div> -->
<div class="row">
<div class="col-md-12">
<!-- this.disabled= true; xajax_wait('aviso','Grabando... un momento por favor...'); xajax_brigadistas_grabar(xajax.getFormValues('formulario_brigadistas')) -->
<!-- <button class='fileUpload btn btn-success btn-block' onclick="document.getElementById('formulario_brigadistas').submit(); "> -->
<button class='fileUpload btn btn-success btn-block' onclick=" xajax_wait('aviso','Grabando... un momento por favor...'); xajax_brigadistas_grabar(xajax.getFormValues('formulario_brigadistas')) ; ">
<span><i class="fa fa-save"></i> <span class='fa'> Grabalo! </span></span>
</button>
</div>
</div>
</div>
<?php $ultimo = formulario_uso("$id_formulario",'','ultimo') ;
//echo $ultimo[1];
echo mostrar_identificador("$ultimo[1]","","landingpage",'simple');
?>
</div>
<script language="javascript">
function cargaContextoCanvas(idCanvas){
var elemento = document.getElementById(idCanvas);
if(elemento && elemento.getContext){
var contexto = elemento.getContext('2d');
if(contexto){
return contexto;
}
}
return FALSE;
}
function marcar(ubicacion){
//if (ubicacion == 'arriba'){ var x = '0';var y = '0';}
//if (ubicacion == 'abajo'){ var x = '10';var y = '50';}
//Recibimos el elemento canvas
var ctx = cargaContextoCanvas('micanvas');
if(ctx){
//Creo una imagen conun objeto Image de Javascript
var img = new Image();
var img2 = new Image();
//img.src = document.getElementById("image_output2").src;
//readAsDataURL(
img.src = document.getElementById("imagen_original").src;
document.getElementById("imagen_original").style.display="none";
//img2.src = 'images/logos/a.png';
img2.src = document.getElementById("marca").src;
if (ubicacion =='') {
ubicacion ='middle-center';
}
x = 0,
y = 0;
if(ubicacion.indexOf("top")!=-1)
y = 10;
else if(ubicacion.indexOf("middle")!=-1)
y = (micanvas.height - img2.height)/2;
else
y = micanvas.height-img2.height-10;
if(ubicacion.indexOf("left")!=-1)
x = 10;
else if(ubicacion.indexOf("center")!=-1)
x = (micanvas.width - img2.width) /2;
else
x = micanvas.width-img2.width-10;
var proporcion = ( img.height / img.width );
var ancho = <?php echo $ancho ?>;
micanvas.width =ancho;
micanvas.height = (micanvas.width * proporcion);
micanvas.setAttribute('width', ancho);
micanvas.setAttribute('height', micanvas.height);
micanvas.setAttribute('style',"width:100%");
img.onload = function(){
ctx.drawImage(img, 0, 0,micanvas.width,micanvas.height);
ctx.drawImage(img2, x, y);
var debugConsole= document.getElementById("debugConsole");
var testCanvas = document.getElementById("micanvas");
var canvasData = testCanvas.toDataURL("image/png");
var postData = "canvasData="+canvasData;
debugConsole.value=canvasData;
var identificador = Math.random();
document.getElementById('identificador').value= identificador;
}
}
}
$(function () {
'use strict';
var result = $('#result'),
exifNode = $('#exif'),
thumbNode = $('#thumbnail'),
actionsNode = $('#actions'),
currentFile,
replaceResults = function (img) {
var content;
if (!(img.src || img instanceof HTMLCanvasElement)) {
content = $('<span>Loading image file failed</span>');
} else {
content = $('<img />').append(img)
//.attr('download', currentFile.name)
.attr('src', img.src || img.toDataURL())
.attr('width', '<?php echo $ancho ?>')
.attr('style', 'width:100%')
.attr('id', 'imagen_original');
}
//document.getElementById('image_output').src = img.src;
result.children().replaceWith(content);
if (img.getContext) {
actionsNode.show();
/// render(img.src);
window.setTimeout("marcar('middle-center');", 500);
}
},
displayImage = function (file, options) {
currentFile = file;
if (!loadImage(
file,
replaceResults,
options
)) {
result.children().replaceWith(
$('<span>Your browser does not support the URL or FileReader API.</span>')
);
}
},
dropChangeHandler = function (e) {
e.preventDefault();
e = e.originalEvent;
var target = e.dataTransfer || e.target,
file = target && target.files && target.files[0],
options = {
//maxWidth: result.width(),
maxWidth: <?php echo $ancho ?>,
canvas: true
};
if (!file) {
return;
}
exifNode.hide();
thumbNode.hide();
loadImage.parseMetaData(file, function (data) {
if (data.exif) {
options.orientation = data.exif.get('Orientation');
// displayExifData(data.exif);
}
displayImage(file, options);
});
},
coordinates;
// Hide URL/FileReader API requirement message in capable browsers:
if (window.createObjectURL || window.URL || window.webkitURL || window.FileReader) {
result.children().hide();
}
$(document)
.on('dragover', function (e) {
e.preventDefault();
e = e.originalEvent;
e.dataTransfer.dropEffect = 'copy';
})
.on('drop', dropChangeHandler);
$('#file-input').on('change', dropChangeHandler);
$('#edit').on('click', function (event) {
event.preventDefault();
var imgNode = result.find('img, canvas'),
img = imgNode[0];
imgNode.Jcrop({
setSelect: [40, 40, img.width - 40, img.height - 40],
onSelect: function (coords) {
coordinates = coords;
},
onRelease: function () {
coordinates = null;
}
}).parent().on('click', function (event) {
event.preventDefault();
});
});
$('#crop').on('click', function (event) {
event.preventDefault();
var img = result.find('img, canvas')[0];
if (img && coordinates) {
replaceResults(loadImage.scale(img, {
left: coordinates.x,
top: coordinates.y,
sourceWidth: coordinates.w,
sourceHeight: coordinates.h,
minWidth: result.width()
}));
coordinates = null;
}
});
});
</script>
<br>
<script src="milfs/addon/logis/js/load-image.all.min.js"></script>
<!-- <script src="js/load-image.js"></script> -->
<!-- <script src="js/load-image-ios.js"></script> -->
<!-- <script src="js/load-image-orientation.js"></script> -->
<!-- <script src="js/load-image-meta.js"></script> -->
<!-- <script src="js/load-image-exif.js"></script> -->
<!-- <script src="js/load-image-exif-map.js"></script> -->
<!-- jQuery and Jcrop are not required by JavaScript Load Image, but included for the demo -->
<!-- <script src="//ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js"></script> -->
<!-- <script src="js/vendor/jquery.Jcrop.js"></script> -->
<!-- <script src="js/demo.js"></script> -->
</div>

207
addon/logis/logis.php.php Normal file
View File

@ -0,0 +1,207 @@
<?php
//include("funciones/funciones.php");
$id_formulario = "58";
$ancho = "600";
$tags = array();
$tags[] = "images/logos/c.png";
foreach ($tags as &$valor) {
$imagen .= "<td onclick=\" document.getElementById('marca').src='$valor' ; marcar('top-left') \" ><a href='#medio' class='' >
<img class='img ' src='$valor'>
</a></td>";
}
$imagen = "
<div class='table-responsive'>
<table class='table table table-condensed text-center '>
<tr >
$imagen
</tr>
</table>
</div>";
?>
<html lang="en">
<head>
<!--[if IE]>
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
<![endif]-->
<meta charset="utf-8">
<title></title>
<meta name="description" content="JavaScript Load Image is a library to load images provided as File or Blob objects or via URL. It returns an optionally scaled and/or cropped HTML img or canvas element. It also provides a method to parse image meta data to extract Exif tags and thumbnails and to restore the complete image header after resizing.">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<!-- Jcrop is not required by JavaScript Load Image, but included for the demo -->
<!-- <link rel="stylesheet" href="css/vendor/jquery.Jcrop.css"> -->
<!-- <link rel="stylesheet" href="css/demo.css"> -->
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/font-awesome/4.5.0/css/font-awesome.min.css">
<!-- Latest compiled and minified CSS -->
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css" integrity="sha384-1q8mTJOASx8j1Au+a5WDVnPi2lkFfwwEAa8hDDdjZlpLegxhjVME1fgjWPGmkzs7" crossorigin="anonymous">
<style type="text/css">
.fa{
font-size:60px;
}
#imagen_origina{
width: 800px;
}
.pin {
text-align: center;
border: solid 1px red;
opacity: 0.5;
}
.fileUpload {
position: relative;
overflow: hidden;
margin: 10px;
width: 80%;
}
.fileUpload input.upload {
position: absolute;
top: 0;
right: 0;
margin: 10;
padding: 0;
font-size: 50px;
cursor: pointer;
opacity: 0;
filter: alpha(opacity=0);
}
</style>
</head>
<body>
<div class='container'>
<div class='fileUpload btn btn-primary '>
<span> <i class="fa fa-picture-o"></i> <span class='fa' > Imagen <i class="fa fa-camera"></i> </span>
<input class='upload' type="file" id="file-input" /></span>
<div id="original" ></div>
</div>
</div>
<!-- <p><input type="file" id="file-input"></p> -->
<div id="actions" style="display:none;">
<img class="center-block" src= "<?php echo $tags[0]; ?>" style='display:none' id="marca" name="marca">
<img class="center-block" style='' id="image_output" name="image_output">
<img class="center-block" style='' id="otra_imagen" name="otra_imagen">
<input type="hidden" id='identificador' name='identificador'>
<div id="result" class="result">
<p></p>
</div>
<a name="arriba"></a>
<div style="position:relative">
<div style="position:absolute; width:100%; height:100%;" >
<table style="width:100%; height:100%;" class="">
<tr >
<td class="pin"><a href="#arriba" onclick=" javascript: marcar('top-left')"><i class="fa fa-circle-o"></i></a></td>
<td class="pin"><a href="#arriba" onclick=" javascript: marcar('top-center')"><i class="fa fa-circle-o"></i></a></td>
<td class="pin"><a href="#arriba" onclick=" javascript: marcar('top-rigth')"><i class="fa fa-circle-o"></i></a></td>
</tr>
<tr>
<td class="pin"><a name="medio"></a><a href="#arriba" onclick=" javascript: marcar('middle-left')"><i class="fa fa-circle-o"></i></a></td>
<td class="pin"><a href="#medio" onclick=" javascript: marcar('middle-center')"><i class="fa fa-circle-o"></i></a></td>
<td class="pin"><a href="#medio" onclick=" javascript: marcar('middle-rigth')"><i class="fa fa-circle-o"></i></td>
</tr>
<tr>
<td class="pin"><a href="#medio" onclick=" javascript: marcar('bottom-left')"><i class="fa fa-circle-o"></i></a></td>
<td class="pin"><a href="#medio" onclick=" javascript: marcar('bottom-center')"><i class="fa fa-circle-o"></i></a></td>
<td class="pin"><a href="#medio" onclick=" javascript: marcar('bottom-rigth')"><i class="fa fa-circle-o"></i></a></td>
</tr>
</table>
</div>
<canvas id="micanvas" style="position:absolute" >
Tu navegador no soporta canvas.
</canvas>
</div>
</div>
<script language="javascript">
function cargaContextoCanvas(idCanvas){
var elemento = document.getElementById(idCanvas);
if(elemento && elemento.getContext){
var contexto = elemento.getContext('2d');
if(contexto){
return contexto;
}
}
return FALSE;
}
function marcar(ubicacion){
//if (ubicacion == 'arriba'){ var x = '0';var y = '0';}
//if (ubicacion == 'abajo'){ var x = '10';var y = '50';}
//Recibimos el elemento canvas
var ctx = cargaContextoCanvas('micanvas');
if(ctx){
//Creo una imagen conun objeto Image de Javascript
var img = new Image();
var img2 = new Image();
//img.src = document.getElementById("image_output2").src;
//readAsDataURL(
img.src = document.getElementById("imagen_original").src;
document.getElementById("imagen_original").style.display="none";
//img2.src = 'images/logos/a.png';
img2.src = document.getElementById("marca").src;
if (ubicacion =='') {
ubicacion ='middle-center';
}
x = 0,
y = 0;
if(ubicacion.indexOf("top")!=-1)
y = 10;
else if(ubicacion.indexOf("middle")!=-1)
y = (micanvas.height - img2.height)/2;
else
y = micanvas.height-img2.height-10;
if(ubicacion.indexOf("left")!=-1)
x = 10;
else if(ubicacion.indexOf("center")!=-1)
x = (micanvas.width - img2.width) /2;
else
x = micanvas.width-img2.width-10;
var proporcion = ( img.height / img.width );
var ancho = 800;
micanvas.width = ancho;
micanvas.height = (micanvas.width * proporcion);
micanvas.setAttribute('width', ancho);
micanvas.setAttribute('height', micanvas.height);
micanvas.setAttribute('style',"width:100%");
img.onload = function(){
ctx.drawImage(img, 0, 0,micanvas.width,micanvas.height);
ctx.drawImage(img2, x, y);
var identificador = Math.random();
document.getElementById('identificador').value= identificador;
}
}
}
</script>
<br>
<script src="js/load-image.all.min.js"></script>
<!-- <script src="js/load-image.js"></script> -->
<!-- <script src="js/load-image-ios.js"></script> -->
<!-- <script src="js/load-image-orientation.js"></script> -->
<!-- <script src="js/load-image-meta.js"></script> -->
<!-- <script src="js/load-image-exif.js"></script> -->
<!-- <script src="js/load-image-exif-map.js"></script> -->
<!-- jQuery and Jcrop are not required by JavaScript Load Image, but included for the demo -->
<script src="//ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js"></script>
<!-- <script src="js/vendor/jquery.Jcrop.js"></script> -->
<script src="js/demo.js"></script>
</body>
</html>

View File

@ -0,0 +1,207 @@
<?php
//include("funciones/funciones.php");
$id_formulario = "58";
$ancho = "600";
$tags = array();
$tags[] = "images/logos/c.png";
foreach ($tags as &$valor) {
$imagen .= "<td onclick=\" document.getElementById('marca').src='$valor' ; marcar('top-left') \" ><a href='#medio' class='' >
<img class='img ' src='$valor'>
</a></td>";
}
$imagen = "
<div class='table-responsive'>
<table class='table table table-condensed text-center '>
<tr >
$imagen
</tr>
</table>
</div>";
?>
<!DOCTYPE HTML>
<html lang="en">
<head>
<!--[if IE]>
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
<![endif]-->
<meta charset="utf-8">
<title></title>
<meta name="description" content="JavaScript Load Image is a library to load images provided as File or Blob objects or via URL. It returns an optionally scaled and/or cropped HTML img or canvas element. It also provides a method to parse image meta data to extract Exif tags and thumbnails and to restore the complete image header after resizing.">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<!-- Jcrop is not required by JavaScript Load Image, but included for the demo -->
<!-- <link rel="stylesheet" href="css/vendor/jquery.Jcrop.css"> -->
<!-- <link rel="stylesheet" href="css/demo.css"> -->
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/font-awesome/4.5.0/css/font-awesome.min.css">
<!-- Latest compiled and minified CSS -->
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css" integrity="sha384-1q8mTJOASx8j1Au+a5WDVnPi2lkFfwwEAa8hDDdjZlpLegxhjVME1fgjWPGmkzs7" crossorigin="anonymous">
<style type="text/css">
.fa{
font-size:60px;
}
#imagen_origina{
width: 800px;
}
.pin {
text-align: center;
border: solid 1px red;
opacity: 0.5;
}
.fileUpload {
position: relative;
overflow: hidden;
margin: 10px;
width: 80%;
}
.fileUpload input.upload {
position: absolute;
top: 0;
right: 0;
margin: 10;
padding: 0;
font-size: 50px;
cursor: pointer;
opacity: 0;
filter: alpha(opacity=0);
}
</style>
</head>
<body>
<div class='container'>
<div class='fileUpload btn btn-primary '>
<span> <i class="fa fa-picture-o"></i> <span class='fa' > Imagen <i class="fa fa-camera"></i> </span>
<input class='upload' type="file" id="file-input" /></span>
<div id="original" ></div>
</div>
</div>
<!-- <p><input type="file" id="file-input"></p> -->
<div id="actions" style="display:none;">
<img class="center-block" src= "<?php echo $tags[0]; ?>" style='display:none' id="marca" name="marca">
<img class="center-block" style='' id="image_output" name="image_output">
<img class="center-block" style='' id="otra_imagen" name="otra_imagen">
<input type="hidden" id='identificador' name='identificador'>
<div id="result" class="result">
<p></p>
</div>
<a name="arriba"></a>
<div style="position:relative">
<div style="position:absolute; width:100%; height:100%;" >
<table style="width:100%; height:100%;" class="">
<tr >
<td class="pin"><a href="#arriba" onclick=" javascript: marcar('top-left')"><i class="fa fa-circle-o"></i></a></td>
<td class="pin"><a href="#arriba" onclick=" javascript: marcar('top-center')"><i class="fa fa-circle-o"></i></a></td>
<td class="pin"><a href="#arriba" onclick=" javascript: marcar('top-rigth')"><i class="fa fa-circle-o"></i></a></td>
</tr>
<tr>
<td class="pin"><a name="medio"></a><a href="#arriba" onclick=" javascript: marcar('middle-left')"><i class="fa fa-circle-o"></i></a></td>
<td class="pin"><a href="#medio" onclick=" javascript: marcar('middle-center')"><i class="fa fa-circle-o"></i></a></td>
<td class="pin"><a href="#medio" onclick=" javascript: marcar('middle-rigth')"><i class="fa fa-circle-o"></i></td>
</tr>
<tr>
<td class="pin"><a href="#medio" onclick=" javascript: marcar('bottom-left')"><i class="fa fa-circle-o"></i></a></td>
<td class="pin"><a href="#medio" onclick=" javascript: marcar('bottom-center')"><i class="fa fa-circle-o"></i></a></td>
<td class="pin"><a href="#medio" onclick=" javascript: marcar('bottom-rigth')"><i class="fa fa-circle-o"></i></a></td>
</tr>
</table>
</div>
<canvas id="micanvas" style="position:absolute" >
Tu navegador no soporta canvas.
</canvas>
</div>
</div>
<script language="javascript">
function cargaContextoCanvas(idCanvas){
var elemento = document.getElementById(idCanvas);
if(elemento && elemento.getContext){
var contexto = elemento.getContext('2d');
if(contexto){
return contexto;
}
}
return FALSE;
}
function marcar(ubicacion){
//if (ubicacion == 'arriba'){ var x = '0';var y = '0';}
//if (ubicacion == 'abajo'){ var x = '10';var y = '50';}
//Recibimos el elemento canvas
var ctx = cargaContextoCanvas('micanvas');
if(ctx){
//Creo una imagen conun objeto Image de Javascript
var img = new Image();
var img2 = new Image();
//img.src = document.getElementById("image_output2").src;
//readAsDataURL(
img.src = document.getElementById("imagen_original").src;
document.getElementById("imagen_original").style.display="none";
//img2.src = 'images/logos/a.png';
img2.src = document.getElementById("marca").src;
if (ubicacion =='') {
ubicacion ='middle-center';
}
x = 0,
y = 0;
if(ubicacion.indexOf("top")!=-1)
y = 10;
else if(ubicacion.indexOf("middle")!=-1)
y = (micanvas.height - img2.height)/2;
else
y = micanvas.height-img2.height-10;
if(ubicacion.indexOf("left")!=-1)
x = 10;
else if(ubicacion.indexOf("center")!=-1)
x = (micanvas.width - img2.width) /2;
else
x = micanvas.width-img2.width-10;
var proporcion = ( img.height / img.width );
var ancho = 800;
micanvas.width = ancho;
micanvas.height = (micanvas.width * proporcion);
micanvas.setAttribute('width', ancho);
micanvas.setAttribute('height', micanvas.height);
micanvas.setAttribute('style',"width:100%");
img.onload = function(){
ctx.drawImage(img, 0, 0,micanvas.width,micanvas.height);
ctx.drawImage(img2, x, y);
var identificador = Math.random();
document.getElementById('identificador').value= identificador;
}
}
}
</script>
<br>
<script src="js/load-image.all.min.js"></script>
<!-- <script src="js/load-image.js"></script> -->
<!-- <script src="js/load-image-ios.js"></script> -->
<!-- <script src="js/load-image-orientation.js"></script> -->
<!-- <script src="js/load-image-meta.js"></script> -->
<!-- <script src="js/load-image-exif.js"></script> -->
<!-- <script src="js/load-image-exif-map.js"></script> -->
<!-- jQuery and Jcrop are not required by JavaScript Load Image, but included for the demo -->
<script src="//ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js"></script>
<!-- <script src="js/vendor/jquery.Jcrop.js"></script> -->
<script src="js/demo.js"></script>
</body>
</html>

View File

@ -0,0 +1,145 @@
<?php
function machitroll_grabar_imagen($data,$identificador) {
$respuesta = new xajaxResponse('utf-8');
$control = md5("$identificador");
//$form_id = $fomulario["formulario_id"];
$imagen= grabar_imagen($data,$control);
$preview = "<img src='$_SESSION[url]/images/secure/?file=150/$imagen'>";
$respuesta->addScript("javascript: document.getElementById('imagen').value= '$imagen' ;");
$respuesta->addAssign("aviso","innerHTML","$preview");
return $respuesta;
}
$xajax->registerFunction("machitroll_grabar_imagen");
function machitroll_grabar($formulario) {
$identificador = $formulario['identificador'];
$control = md5("$identificador");
$data = $formulario['debugConsole'];
$imagen= grabar_imagen($data,$control);
$texto_url = urlencode("#AlertaMachiTroll https://actua.karisma.org.co/alertamachitroll");
$uri = urlencode("$_SESSION[url]/images/secure/?file=600/$imagen");
$url ="https://twitter.com/share?url=$uri&text=$texto_url";
//$respuesta->addScript("window.location.href ='$url';");
$preview = "
<div class='row'>
<div class='center-block'>
<div class='thumbnail'>
<img src='$_SESSION[url]/images/secure/?file=600/$imagen'>
<a download='machitroll.png' href='$_SESSION[url]images/secure/?file=600/$imagen' >
<span class='btn btn-default'><i class='fa fa-download'></i> </span>
</a>
<span class='btn btn-default'>
<a onclick =\"javascript:window.location.href ='$url'; \" ><i class='fa fa-twitter'></i> </a>
</span>
<a href='?set=$formulario[formulario_id]&embebido'>
<span class='btn btn-default'><i class='fa fa-eye'></i> </span>
</a>
<a href='#' onclick = \"javascript:location.reload(); \">
<span class='btn btn-default'><i class='fa fa-refresh'></i> </span>
</a>
</div>
</div>
</div>
";
$respuesta = new xajaxResponse('utf-8');
//$identificador = $formulario['identificador'];
$id_formulario = $formulario['formulario_id'];
$campo_imagen = buscar_campo_tipo("$id_formulario","15");
$formulario[$campo_imagen[0]][0] = $imagen;
$empresa = remplacetas('form_id','id',"$id_formulario",'id_empresa',"") ;
$id_empresa = $empresa[0];
include_once("librerias/conex.php");
$link=Conectarse();
mysqli_query("SET NAMES 'utf8'");
foreach($formulario as $campo=>$valor){
if(is_array($valor)) {
foreach($valor as $c=>$v){
$consulta = "INSERT INTO form_datos ( timestamp,id_usuario,id_empresa,form_id,ip,control,id_campo,contenido) VALUES
( UNIX_TIMESTAMP(),'$_SESSION[id]','$id_empresa','$id_formulario','$ip' ,'$control', '$campo' , '$v')
";
$sql=mysqli_query($consulta,$link);
// $campos .= " $campo // $valor // $c -> $v $consulta <br>";
}
}
}
$resultado = "$preview ";
$respuesta->addAssign("aviso","innerHTML","$resultado");
//$respuesta->addAlert("$resultado");
//$respuesta->addScript("javascript:location.reload(true);");
return $respuesta;
}
$xajax->registerFunction("machitroll_grabar");
function machitroll_grabarX($formulario) {
$respuesta = new xajaxResponse('utf-8');
$control = md5($formulario['identificador']);
$form_id = $fomulario["formulario_id"];
if($formulario['debugConsole'] !="") {
$imagen= grabar_imagen($formulario['debugConsole'],$control);
}
$campo_imagen = buscar_campo_tipo("$form_id","15");
$formulario["$campo_imagen[0]"][0] = "$imagen";
$formulario["formulario_id"] = $fomulario["formulario_id"];
$formulario["formulario_id"] = $fomulario["formulario_id"];
include_once("librerias/conex.php");
$link=Conectarse();
mysqli_query("SET NAMES 'utf8'");
/*
foreach($formulario as $c=>$v){
$campo .= "( $c : $v )<br> ";
//LISTA ELEMENTOS DE UN ARRAY
if (is_array($v) ){
foreach($v as $C=>$V){
$campo .= " Array ( $c : $V )<br> ";
if($V != '') {
}
}
}
}
*/
foreach($formulario as $C=>$V){
$campo = "$C";
$form_id= $formulario['formulario_id'];
if(is_array($V)) {
foreach($V as $c=>$v){
//$hora = $id_orden['hora'][$C];
//$dia = "$V";
//$control = md5(rand(1,99999999).microtime());
$consulta = "INSERT INTO form_datos ( timestamp,id_usuario,id_empresa,form_id,ip,control,id_campo,contenido) VALUES
( UNIX_TIMESTAMP(),'$_SESSION[id]','$_SESSION[id_empresa]','$form_id','$ip' ,'$control', '$campo' , '$v')
";
$sql=mysqli_query($consulta,$link);
$filas .= "<li> $C - $V - $c - $v ///$campo -> $V $consulta $debug </li>";
}
}
}
//$resultado = "Hola mundo ".$formulario[498][0]." <textarea class='form-group'>$formulario[debugConsole]</textarea> ";
//$resultado= " $campo ";
$respuesta->addAssign("aviso","innerHTML","$resultado ");
//$respuesta->addAlert("$resultado");
//$respuesta->addScript("javascript:location.reload(true);");
return $respuesta;
}
$xajax->registerFunction("machitroll_grabarX");
?>

Binary file not shown.

After

Width:  |  Height:  |  Size: 17 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 44 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 74 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 109 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 145 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 14 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 39 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 71 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 107 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 148 KiB

View File

View File

@ -0,0 +1,487 @@
<?php
//include("funciones/funciones.php");
$id_formulario = "61";
$ancho = "600";
/*
$tags = array();
$tags[] = "milfs/addon/machitroll/images/incurable/100.png";
$tags[] = "milfs/addon/machitroll/images/incurable/200.png";
//$tags[] = "milfs/addon/machitroll/images/incurable/300.png";
//$tags[] = "milfs/addon/machitroll/images/incurable/400.png";
//$tags[] = "milfs/addon/machitroll/images/incurable/500.png";
$tags[] = "milfs/addon/machitroll/images/rescatable/100.png";
$tags[] = "milfs/addon/machitroll/images/rescatable/200.png";
//$tags[] = "milfs/addon/machitroll/images/rescatable/300.png";
//$tags[] = "milfs/addon/machitroll/images/rescatable/400.png";
//$tags[] = "milfs/addon/machitroll/images/rescatable/500.png";
foreach ($tags as &$valor) {
$imagen .= "<td><a href='#medio' class='' onclick=\" document.getElementById('marca').src='$valor' \" >
<img class='img ' src='$valor'>
</a></td>";
}
$imagen = "
<div class='table-responsive'>
<table class='table table table-condensed text-center '>
<tr>
$imagen
</tr>
</table>
</div>";
*/
$imagen = "
<div class='table-responsive'>
<table class='table table table-condensed text-center '>
<tbody>
<tr>
<td>
<a href='#medio' class='' onclick=\" document.getElementById('marca').src='milfs/addon/machitroll/images/incurable/100.png '\" >
<img class='img ' src='milfs/addon/machitroll/images/incurable/100.png'>
</a>
<br>
<span>INCURABLE</span>
</td>
<td>
<a href='#medio' class='' onclick=\" document.getElementById('marca').src='milfs/addon/machitroll/images/incurable/200.png '\" >
<img class='img ' src='milfs/addon/machitroll/images/incurable/200.png'>
</a><br>
<span>INCURABLE</span>
</td>
<td>
<a href='#medio' class='' onclick=\" document.getElementById('marca').src='milfs/addon/machitroll/images/rescatable/100.png '\" >
<img class='img ' src='milfs/addon/machitroll/images/rescatable/100.png'>
</a><br>
<span>RESCATABLE</span>
</td>
<td>
<a href='#medio' class='' onclick=\" document.getElementById('marca').src='milfs/addon/machitroll/images/rescatable/200.png '\" >
<img class='img ' src='milfs/addon/machitroll/images/rescatable/200.png'>
</a><br>
<span>RESCATABLE</span>
</td>
</tr>
</tbody>
</table>
</div>";
?>
<script src="https://9b8d22ae00fff2954b7cdd00a6feb4176bc56576.googledrive.com/host/0B7R2T-U-1ZrheTlfaHNQMm0zTWM/plump_modernizr.js"></script>
<link rel="stylesheet" media="screen" href="https://fontlibrary.org/face/cabin" type="text/css"/>
<style type="text/css">
body {
font-family: 'CabinRegular';
font-weight: normal;
font-style: normal;
}
.fileUpload {
position: relative;
overflow: hidden;
margin: 10px;
}
.fileUpload input.upload {
position: absolute;
top: 0;
right: 0;
margin: 10;
padding: 0;
font-size: 50px;
cursor: pointer;
opacity: 0;
filter: alpha(opacity=0);
}
.fa{
font-size:20px;
}
#downlink_hidden , #fieldset_General , #canvas_ed , #original{
display:none;
}
#body{
background-color: white;
}
</style>
<div id='aviso'>
<div id ="body" class="container-fluid">
<div id="div_machitroll" class="container">
<span class='btn btn-primary btn-block' > <!-- <i class="fa fa-picture-o"></i> --> <span class='fa' > Elige un #MachiTroll </span></span>
<?php echo $imagen; ?>
<a name="medio"></a>
<div class="row">
<div class="col-md-12">
<div class='fileUpload btn btn-primary btn-block'>
<span> <i class="fa fa-picture-o"></i> <span class='fa' > Sube pantallazo</span>
<input class='upload' type="file" id="files" name="files[]" /></span>
<div id="original" ></div>
</div>
</div>
</div>
<a name="abajo"></a>
<div class="row">
<div class="col-md-12">
<div class='container-fluid'>
<table style="" class="table text-center table-responsive">
<tr>
<td><a href="#abajo" onclick=" javascript: marcar('top-left')"><i class="fa fa-caret-square-o-left"></i></a></td>
<td><a href="#abajo" onclick=" javascript: marcar('top-center')"><i class="fa fa-caret-square-o-up"></i></a></td>
<td><a href="#abajo" onclick=" javascript: marcar('top-rigth')"><i class="fa fa-caret-square-o-right"></i></a></td>
</tr>
<tr>
<td><a href="#abajo" onclick=" javascript: marcar('middle-left')"><i class="fa fa-caret-square-o-left"></i></a></td>
<td><a href="#abajo" onclick=" javascript: marcar('middle-center')"><i class="fa fa-circle-o"></i></a></td>
<td><a href="#abajo" onclick=" javascript: marcar('middle-rigth')"><i class="fa fa-caret-square-o-right"></i></td>
</tr>
<tr>
<td><a href="#abajo" onclick=" javascript: marcar('bottom-left')"><i class="fa fa-caret-square-o-left"></i></a></td>
<td><a href="#abajo" onclick=" javascript: marcar('bottom-center')"><i class="fa fa-caret-square-o-down"></i></a></td>
<td><a href="#abajo" onclick=" javascript: marcar('bottom-rigth')"><i class="fa fa-caret-square-o-right"></i></a></td>
</tr>
</table>
</div>
</div>
</div>
<!-- editor -->
<div class='container-fluid'>
<div style="background-color:; " >
<img class="center-block" style='display: none' id="marca" name="marca">
<div id="list" style=" "></div>
<img id='image_output2' name='image_output2' src="" class="" />
<div id='div_canvas' style='display: none'> </div>
</div>
</div>
<div class="row">
<div class="col-md-12">
<form id='formulario_machitroll' name='formulario_machitroll' >
<input type='hidden' id="debugConsole" name="debugConsole" >
<input type='hidden' id="identificador" name="identificador" >
<input type='hidden' id="formulario_id" name="formulario_id" value="<?php echo $id_formulario; ?>">
<input type='hidden' id="imagen" name="imagen" value="">
<?php $formulario = formulario_areas("$id_formulario",'campos','','');
echo $formulario; ?>
</form>
</div>
</div>
<div class="row">
<div class="col-md-12">
<!-- -->
<button class='fileUpload btn btn-success btn-block' onclick=" this.disabled= true; xajax_wait('aviso','Grabando... un momento por favor...'); saveViaAJAX(); xajax_machitroll_grabar(xajax.getFormValues('formulario_machitroll'))">
<span><i class="fa fa-save"></i> <span class='fa'> Grabalo! </span></span>
</button>
</div>
</div>
</div><!-- fin aviso -->
</div>
</div>
<script type="text/javascript">
function convertImageToCanvas(i, image) {
var canvas = document.createElement("canvas");
canvas.width = image.width;
canvas.height = image.height;
var ctx = canvas.getContext("2d");
ctx.drawImage(image, 0, 0);
$("body").append(canvas);
};
function convertImageToCanvas(image) {
var canvas = document.createElement("canvas");
canvas.width = image.width;
canvas.height = image.height;
canvas.getContext("2d").drawImage(image, 0, 0);
return canvas;
}
function convertCanvasToImage(canvas) {
var image = new Image();
image.src = canvas.toDataURL("image/png");
return image;
}
function saveViaAJAX()
{
/* function loadCanvas(id) {
var canvas = document.createElement('canvas');
div = document.getElementById(id);
canvas.id = "CursorLayer";
canvas.width = 1224;
canvas.height = 768;
canvas.style.zIndex = 8;
canvas.style.position = "absolute";
canvas.style.border = "1px solid";
div.appendChild(canvas)
}
*/
$(document).ready(function() {
function convertImageToCanvas(i, image) {
var canvasOld = document.getElementById("holamundo");
// canvasOld.holamundo.removeChild(canvasOld);
document.getElementById("div_canvas").innerHTML=""
var canvas = document.createElement("canvas");
div = document.getElementById('div_canvas');
canvas.width = image.width;
canvas.height = image.height;
canvas.id = "holamundo";
var ctx = canvas.getContext("2d");
ctx.drawImage(image, 0, 0);
div.appendChild(canvas);
};
$('.watermark').each(convertImageToCanvas);
});
var testCanvas = document.getElementById("holamundo");
var canvasData = testCanvas.toDataURL("image/png");
var postData = "canvasData="+canvasData;
var debugConsole= document.getElementById("debugConsole");
debugConsole.value=canvasData;
}
</script>
<script>
function archivo(evt) {
var files = evt.target.files; // FileList object
// Obtenemos la imagen del campo "file".
for (var i = 0, f; f = files[i]; i++) {
//Solo admitimos imágenes.
if (!f.type.match('image.*')) {
continue;
}
var reader = new FileReader();
reader.onload = (function(theFile) {
return function(e) {
// Insertamos la imagen
document.getElementById("original").innerHTML = ['<img id="image_output2" name="image_output2" src="', e.target.result,'" title="', escape(theFile.name), '"/>'].join('');
document.getElementById("list").innerHTML = ['<img style="width:<?php echo $ancho; ?>px;" id="image_output" name="image_output" class="img img-responsive watermark center-block" src="', e.target.result,'" title="', escape(theFile.name), '"/>'].join('');
};
})(f);
reader.readAsDataURL(f);
}
}
document.getElementById('files').addEventListener('change', archivo, false);
/* marca */
(function(w){
var wm = (function(w){
var doc = w.document,
gcanvas = {},
gctx = {},
imgQueue = [],
className = "watermark",
watermark = false,
watermarkPosition = "bottom-right",
watermarkPath = "milfs/addon/machitroll/images/incurable/100.png?"+(+(new Date())),
opacity = (255/(100/50)), // 50%
initCanvas = function(){
gcanvas = doc.createElement("canvas");
gcanvas.style.cssText = "display:none;";
gctx = gcanvas.getContext("2d");
doc.body.appendChild(gcanvas);
},
initWatermark = function(){
watermark = new Image();
watermark.src = "";
watermark.src = watermarkPath;
if(opacity != 255){
if(!watermark.complete)
watermark.onload = function(){
applyTransparency();
}
else
applyTransparency();
}else{
applyWatermarks();
}
},
// function for applying transparency to the watermark
applyTransparency = function(){
var w = watermark.width || watermark.offsetWidth,
h = watermark.height || watermark.offsetHeight;
setCanvasSize(w, h);
gctx.drawImage(watermark, 0, 0);
var image = gctx.getImageData(0, 0, w, h);
var imageData = image.data,
length = imageData.length;
for(var i=3; i < length; i+=4){
imageData[i] = (imageData[i]<opacity)?imageData[i]:opacity;
}
image.data = imageData;
gctx.putImageData(image, 0, 0);
watermark.onload = null;
watermark.src = "";
watermark.src = gcanvas.toDataURL();
// assign img attributes to the transparent watermark
// because browsers recalculation doesn't work as fast as needed
watermark.width = w;
watermark.height = h;
applyWatermarks();
},
configure = function(config){
if(config["watermark"])
watermark = config["watermark"];
if(config["path"])
watermarkPath = config["path"];
if(config["position"])
watermarkPosition = config["position"];
if(config["opacity"])
opacity = (255/(100/config["opacity"]));
if(config["className"])
className = config["className"];
initCanvas();
initWatermark();
}
setCanvasSize = function(w, h){
gcanvas.width = w;
gcanvas.height = h;
},
applyWatermark = function(img){
/*
var f = image.height / image.width;
var newHeight = canvas.width * f;
*/
var proporcion = ( img.height / img.width );
var ancho = <?php echo $ancho; ?>;
//var alto_orginal = img.height;
//var alto = (alto_original * proporcion);
//alert("hola pro"+alto);
gcanvas.width = ancho;// || img.offsetWidth;
//gcanvas.width = img.width || img.offsetWidth;
//gcanvas.height = img.height || img.offsetHeight;
gcanvas.height = (gcanvas.width * proporcion);// || img.offsetHeight;
gctx.drawImage(img, 0, 0,ancho,gcanvas.height);
var position = watermarkPosition,
x = 0,
y = 0;
if(position.indexOf("top")!=-1)
y = 20;
else if(position.indexOf("middle")!=-1)
y = (gcanvas.height -watermark.height)/2;
else
y = gcanvas.height-watermark.height-20;
if(position.indexOf("left")!=-1)
x = 20;
else if(position.indexOf("center")!=-1)
x = (gcanvas.width - watermark.width) /2;
else
x = gcanvas.width-watermark.width-20;
gctx.drawImage(watermark, x, y);
img.onload = null;
img.src = gcanvas.toDataURL();
},
applyWatermarks = function(){
setTimeout(function(){
var els = doc.getElementsByClassName(className),
len = els.length;
while(len--){
var img = els[len];
if(img.tagName.toUpperCase() != "IMG")
continue;
if(!img.complete){
img.onload = function(){
applyWatermark(this);
};
}else{
applyWatermark(img);
}
}
},10);
};
return {
init: function(config){
configure(config);
}
};
})(w);
w.wmark = wm;
})(window);
/* marca */
</script>
<script>
function marcar(position){
var position = position;
var original = document.getElementById('image_output2').src ;
var marca = document.getElementById('marca').src ;
document.getElementById('image_output').src = original ;
wmark.init({
/* config goes here */
"position": position, // default "bottom-right"
"opacity": 100, // default 50
"className": "watermark", // default "watermark"
"path": marca
// "path": "../milfs/addon/machitroll/images/054843d530f3c83fcdbd55e688d874ec.png"
});
var identificador = Math.random();
document.getElementById('identificador').value= identificador;
//window.setTimeout("saveViaAJAX()", 3000); ///
//saveViaAJAX(); ///
//xajax_wait('aviso','Subiendo imágen');
//window.setTimeout("xajax_machitroll_grabar_imagen(document.getElementById('debugConsole').value,"+identificador+")", 5000);
}
</script>

View File

@ -0,0 +1,24 @@
<?php
function marcador_grabar($formulario) {
$respuesta = new xajaxResponse('utf-8');
$resultado = "Hola mundo ".$formulario[498][0]."--- $formulario[debugConsole] ---";
$imgData = str_replace(' ','+',$formulario['debugConsole']);
$imgData = substr($imgData,strpos($imgData,",")+1);
$imgData = base64_decode($imgData);
// Path where the image is going to be saved
$nombre= MD5(rand().time());
$filePath = "milfs/tmp/".$nombre.".png";
// Write $imgData into the image file
$file = fopen($filePath, 'w');
fwrite($file, $imgData);
fclose($file);
$respuesta->addAssign("aviso","innerHTML","$resultado");
//$respuesta->addAlert("$resultado");
//$respuesta->addScript("javascript:location.reload(true);");
return $respuesta;
}
$xajax->registerFunction("marcador_grabar");
?>

Binary file not shown.

After

Width:  |  Height:  |  Size: 7.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 38 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.8 KiB

412
addon/marcador/marcador.php Normal file
View File

@ -0,0 +1,412 @@
<?php
//include("funciones/funciones.php");
$tags = array();
$tags[] = "milfs/addon/marcador/images/fb198e8742561eb1a9d8da9d95fddeae.png";
$tags[] = "milfs/addon/marcador/images/fca0a98bc665e9f026d5ea4331046893.png";
$tags[] = "milfs/addon/marcador/images/054843d530f3c83fcdbd55e688d874ec.png";
$id_formulario = "58";
foreach ($tags as &$valor) {
$imagen .= "<a href='#' class='list-group-item ' onclick=\" document.getElementById('marca').src='$valor' \" >
<img class='img img-responsive center-block' src='$valor'>
</a>";
}
$imagen = "<div class='container-fluid'><ul class='list-group list-inline'>$imagen<div><div class='clearfix'></ul></div>";
?>
<script src="https://9b8d22ae00fff2954b7cdd00a6feb4176bc56576.googledrive.com/host/0B7R2T-U-1ZrheTlfaHNQMm0zTWM/plump_modernizr.js"></script>
<style type="text/css">
.fileUpload {
position: relative;
overflow: hidden;
margin: 10px;
}
.fileUpload input.upload {
position: absolute;
top: 0;
right: 0;
margin: 10;
padding: 0;
font-size: 50px;
cursor: pointer;
opacity: 0;
filter: alpha(opacity=0);
}
.fa{
font-size:50px;
}
#downlink_hidden , #canvas_ed, #original{
display:none;
}
#body{
background-color: white;
}
</style>
<div id ="body" class="container-fluid">
<div id="div_marcador" class="container">
<?php echo $imagen; ?>
<div class="row">
<div class="col-md-12">
<div class='fileUpload btn btn-primary btn-block'>
<span> <i class="fa fa-picture-o"></i>
<input class='upload' type="file" id="files" name="files[]" /></span>
<div id="original" ></div>
</div>
</div>
</div>
<div class="row">
<div class="col-md-12">
<div class='container-fluid'>
<table style="" class="table text-center table-responsive">
<tr>
<td><a href="#abajo" onclick=" javascript: marcar('top-left')"><i class="fa fa-caret-square-o-left"></i></a></td>
<td><a href="#abajo" onclick=" javascript: marcar('top-center')"><i class="fa fa-caret-square-o-up"></i></a></td>
<td><a href="#abajo" onclick=" javascript: marcar('top-rigth')"><i class="fa fa-caret-square-o-right"></i></a></td>
</tr>
<tr>
<td><a href="#abajo" onclick=" javascript: marcar('middle-left')"><i class="fa fa-caret-square-o-left"></i></a></td>
<td><a href="#abajo" onclick=" javascript: marcar('middle-center')"><i class="fa fa-circle-o"></i></a></td>
<td><a href="#abajo" onclick=" javascript: marcar('middle-rigth')"><i class="fa fa-caret-square-o-right"></i></td>
</tr>
<tr>
<td><a href="#abajo" onclick=" javascript: marcar('bottom-left')"><i class="fa fa-caret-square-o-left"></i></a></td>
<td><a href="#abajo" onclick=" javascript: marcar('bottom-center')"><i class="fa fa-caret-square-o-down"></i></a></td>
<td><a href="#abajo" onclick=" javascript: marcar('bottom-rigth')"><i class="fa fa-caret-square-o-right"></i></a></td>
</tr>
</table>
</div>
</div>
</div>
<!-- editor -->
<div class='container-fluid'>
<a name="abajo"></a>
<div style="background-color:; " >
<img class="center-block" style='display: none' id="marca" name="marca">
<div id="list" style=" "></div>
<img id='image_output2' name='image_output2' src="" class="" />
<div id='div_canvas' style='display: none'> </div>
</div>
</div>
<div class="row">
<div class="col-md-12">
<form id='formulario_marcador' >
<input type='hidden' id="debugConsole" name="debugConsole" >
<?php $formulario = formulario_areas("$id_formulario",'campos','','');
echo $formulario; ?>
</form>
</div>
</div>
<div class="row">
<div class="col-md-12">
<div class='fileUpload btn btn-success btn-block' onclick="saveViaAJAX(); xajax_marcador_grabar(xajax.getFormValues('formulario_marcador'))"><span><i class="fa fa-save"></i></span> </div>
<div id='aviso'></div>
</div>
</div>
</div>
<script type="text/javascript">
function convertImageToCanvas(i, image) {
var canvas = document.createElement("canvas");
canvas.width = image.width;
canvas.height = image.height;
var ctx = canvas.getContext("2d");
ctx.drawImage(image, 0, 0);
$("body").append(canvas);
};
function convertImageToCanvas(image) {
var canvas = document.createElement("canvas");
canvas.width = image.width;
canvas.height = image.height;
canvas.getContext("2d").drawImage(image, 0, 0);
return canvas;
}
function convertCanvasToImage(canvas) {
var image = new Image();
image.src = canvas.toDataURL("image/png");
return image;
}
function saveViaAJAX()
{
/* function loadCanvas(id) {
var canvas = document.createElement('canvas');
div = document.getElementById(id);
canvas.id = "CursorLayer";
canvas.width = 1224;
canvas.height = 768;
canvas.style.zIndex = 8;
canvas.style.position = "absolute";
canvas.style.border = "1px solid";
div.appendChild(canvas)
}
*/
$(document).ready(function() {
function convertImageToCanvas(i, image) {
var canvasOld = document.getElementById("holamundo");
// canvasOld.holamundo.removeChild(canvasOld);
document.getElementById("div_canvas").innerHTML=""
var canvas = document.createElement("canvas");
div = document.getElementById('div_canvas');
canvas.width = image.width;
canvas.height = image.height;
canvas.id = "holamundo";
var ctx = canvas.getContext("2d");
ctx.drawImage(image, 0, 0);
div.appendChild(canvas);
};
$('.watermark').each(convertImageToCanvas);
});
var testCanvas = document.getElementById("holamundo");
var canvasData = testCanvas.toDataURL("image/png");
var postData = "canvasData="+canvasData;
var debugConsole= document.getElementById("debugConsole");
debugConsole.value=canvasData;
}
</script>
<script>
function archivo(evt) {
var files = evt.target.files; // FileList object
// Obtenemos la imagen del campo "file".
for (var i = 0, f; f = files[i]; i++) {
//Solo admitimos imágenes.
if (!f.type.match('image.*')) {
continue;
}
var reader = new FileReader();
reader.onload = (function(theFile) {
return function(e) {
// Insertamos la imagen
document.getElementById("original").innerHTML = ['<img id="image_output2" name="image_output2" src="', e.target.result,'" title="', escape(theFile.name), '"/>'].join('');
document.getElementById("list").innerHTML = ['<img style="width:max-600px;" id="image_output" name="image_output" class="img img-responsive watermark center-block" src="', e.target.result,'" title="', escape(theFile.name), '"/>'].join('');
};
})(f);
reader.readAsDataURL(f);
}
}
document.getElementById('files').addEventListener('change', archivo, false);
/* marca */
(function(w){
var wm = (function(w){
var doc = w.document,
gcanvas = {},
gctx = {},
imgQueue = [],
className = "watermark",
watermark = false,
watermarkPosition = "bottom-right",
watermarkPath = "watermark.png?"+(+(new Date())),
opacity = (255/(100/50)), // 50%
initCanvas = function(){
gcanvas = doc.createElement("canvas");
gcanvas.style.cssText = "display:none;";
gctx = gcanvas.getContext("2d");
doc.body.appendChild(gcanvas);
},
initWatermark = function(){
watermark = new Image();
watermark.src = "";
watermark.src = watermarkPath;
if(opacity != 255){
if(!watermark.complete)
watermark.onload = function(){
applyTransparency();
}
else
applyTransparency();
}else{
applyWatermarks();
}
},
// function for applying transparency to the watermark
applyTransparency = function(){
var w = watermark.width || watermark.offsetWidth,
h = watermark.height || watermark.offsetHeight;
setCanvasSize(w, h);
gctx.drawImage(watermark, 0, 0);
var image = gctx.getImageData(0, 0, w, h);
var imageData = image.data,
length = imageData.length;
for(var i=3; i < length; i+=4){
imageData[i] = (imageData[i]<opacity)?imageData[i]:opacity;
}
image.data = imageData;
gctx.putImageData(image, 0, 0);
watermark.onload = null;
watermark.src = "";
watermark.src = gcanvas.toDataURL();
// assign img attributes to the transparent watermark
// because browsers recalculation doesn't work as fast as needed
watermark.width = w;
watermark.height = h;
applyWatermarks();
},
configure = function(config){
if(config["watermark"])
watermark = config["watermark"];
if(config["path"])
watermarkPath = config["path"];
if(config["position"])
watermarkPosition = config["position"];
if(config["opacity"])
opacity = (255/(100/config["opacity"]));
if(config["className"])
className = config["className"];
initCanvas();
initWatermark();
}
setCanvasSize = function(w, h){
gcanvas.width = w;
gcanvas.height = h;
},
applyWatermark = function(img){
/*
var f = image.height / image.width;
var newHeight = canvas.width * f;
*/
var proporcion = ( img.height / img.width );
var ancho = 600;
//var alto_orginal = img.height;
//var alto = (alto_original * proporcion);
//alert("hola pro"+alto);
gcanvas.width = ancho;// || img.offsetWidth;
//gcanvas.width = img.width || img.offsetWidth;
//gcanvas.height = img.height || img.offsetHeight;
gcanvas.height = (gcanvas.width * proporcion);// || img.offsetHeight;
gctx.drawImage(img, 0, 0,ancho,gcanvas.height);
var position = watermarkPosition,
x = 0,
y = 0;
if(position.indexOf("top")!=-1)
y = 20;
else if(position.indexOf("middle")!=-1)
y = (gcanvas.height -watermark.height)/2;
else
y = gcanvas.height-watermark.height-20;
if(position.indexOf("left")!=-1)
x = 20;
else if(position.indexOf("center")!=-1)
x = (gcanvas.width - watermark.width) /2;
else
x = gcanvas.width-watermark.width-20;
gctx.drawImage(watermark, x, y);
img.onload = null;
img.src = gcanvas.toDataURL();
},
applyWatermarks = function(){
setTimeout(function(){
var els = doc.getElementsByClassName(className),
len = els.length;
while(len--){
var img = els[len];
if(img.tagName.toUpperCase() != "IMG")
continue;
if(!img.complete){
img.onload = function(){
applyWatermark(this);
};
}else{
applyWatermark(img);
}
}
},10);
};
return {
init: function(config){
configure(config);
}
};
})(w);
w.wmark = wm;
})(window);
/* marca */
</script>
<script>
function marcar(position){
var position = position;
var original = document.getElementById('image_output2').src ;
var marca = document.getElementById('marca').src ;
document.getElementById('image_output').src = original ;
wmark.init({
/* config goes here */
"position": position, // default "bottom-right"
"opacity": 100, // default 50
"className": "watermark", // default "watermark"
"path": marca
// "path": "../milfs/addon/marcador/images/054843d530f3c83fcdbd55e688d874ec.png"
});
}
</script>

View File

@ -0,0 +1,108 @@
<?php
function tuitealo($form,$tipo) {
if($tipo =='formulario') {
$formulario = formulario_areas('297','campos');
$descripcion = remplacetas('form_id','id','297','descripcion',"") ;
$nombre = remplacetas('form_id','id','297','nombre',"") ;
$formulario ="
<h1 >$nombre[0]</h1>
<h2>$descripcion[0]</h2>
<form id='form_tuitealo' >
$formulario
<br>
<div id='tuitealo_div'>
<div id='tuitealo_error'></div>
<a class='btn btn-block btn-primary' onclick=\"xajax_tuitealo(xajax.getFormValues('form_tuitealo'),'previsualizar');\">Previsualizar</a>
</div>
</form>
</div>
<br>
<div class='text-center'>
<p class='text-center'>Powered by: <a href='https://qwerty.co/milfs'>MILFS</a></p>
</div>
<br>
";
return $formulario;
}
$respuesta = new xajaxResponse('utf-8');
$sujeto = $form[1301][0];
$accion = $form[1302][0];
$verbo = $form[1303][0];
$tiempo = $form[1305][0];
$ht = $form[1306][0];
$mensaje = $form[1307][0];
$arroba = $form[1301][0];
if( $accion =="" or $verbo =="" or $tiempo =="" or $ht =="" or $arroba =="" ) {
$error ="<div class='alert alert-warning text-center'><h1><i class='fa fa-exclamation-triangle'></i> Hay campos vacíos</h1></div>";
$respuesta->addAssign("tuitealo_error","innerHTML","$error");
return $respuesta;
}
$arroba = remplacetas('form_datos','control',"$arroba",'contenido',"id_campo = '77'") ;
$arroba = $arroba[0];
$url_propia = urlencode("https://patos.redpatodos.co");
$texto="$sujeto $accion $verbo $tiempo $ht $mensaje cc $arroba ";
$texto = ucfirst($texto);
$texto_url=urlencode($texto);
$largo = strlen($texto.$url_propia);
if($largo > 140) { $alert ="danger"; $mensaje ="<i class='fa fa-exclamation-triangle'></i> El texto es demasiado largo y se recortará";
$texto = substr($texto, 0, 140)."..."; }
else{$alert='success'; $mensaje="";}
$url ="https://twitter.com/share?url=$url_propia&text=$texto_url";
$previsualizar ="<br>
<div id='tuitealo_error'></div>
<div class='alert alert-$alert'><div class='badge'>$largo</div>$mensaje<h1>$texto</h1></div>
<a class='btn btn-block btn-primary' onclick=\"xajax_tuitealo(xajax.getFormValues('form_tuitealo'),'previsualizar');\">Previsualizar</a>
<a class='btn btn-block btn-success' onclick=\"xajax_tuitealo(xajax.getFormValues('form_tuitealo'),'confirmar');\">Tuitéalo</a>
<img style='width:1px;' src='milfs/images/100x100.png'
onload=\"
document.getElementById('1301[0]').onchange = function(){xajax_tuitealo(xajax.getFormValues('form_tuitealo'),'previsualizar')};
document.getElementById('1302[0]').onkeyup = function(){xajax_tuitealo(xajax.getFormValues('form_tuitealo'),'previsualizar')};
document.getElementById('1303[0]').onchange = function(){xajax_tuitealo(xajax.getFormValues('form_tuitealo'),'previsualizar')};
document.getElementById('1304[0]').onchange = function(){xajax_tuitealo(xajax.getFormValues('form_tuitealo'),'previsualizar')};
document.getElementById('1305[0]').onchange = function(){xajax_tuitealo(xajax.getFormValues('form_tuitealo'),'previsualizar')};
document.getElementById('1306[0]').onchange = function(){xajax_tuitealo(xajax.getFormValues('form_tuitealo'),'previsualizar')};
document.getElementById('1307[0]').onchange = function(){xajax_tuitealo(xajax.getFormValues('form_tuitealo'),'previsualizar')};
\" >
";
if( $tipo =="previsualizar") {
$control = md5(rand(1,99999999).microtime());
$formulario_grabar ="
<input type='hidden' id= '1308[0]' name= '1308[0]' value='$texto' >
<input type='hidden' id= 'form_id' name= 'form_id' value='297' >
<input type='hidden' id= 'control' name= 'control' value='$control' >
";
$previsualizar .="$formulario_grabar";
$respuesta->addAssign("tuitealo_div","innerHTML","$previsualizar");
}else{
// <div onclick=\" xajax_formulario_grabar(xajax.getFormValues('$control'));\" class='btn btn-block btn-success'>Grabar</div>
//$respuesta->addAssign("xajax_formulario_grabar(xajax.getFormValues('form_tuitealo'));");
$respuesta->addScript("window.location.href ='$url';");
}
return $respuesta;
}
$xajax->registerFunction("tuitealo");
?>

View File

@ -0,0 +1,66 @@
<?php
///este archivo debe estar un nivel superior al directorio milfs
//session_start();
//ini_set('display_errors', 'On');
//require ('milfs/xajax/xajax.inc.php');
//$xajax = new xajax();
//require ('milfs/funciones/funciones.php');
//require("tuitealo/funciones/funciones.php");
//require ('milfs/funciones/convert.php');
//require ('milfs/funciones/login.php');
//require_once ('milfs/includes/markdown.php');
//require ("milfs/funciones/conex.php");
//$xajax->processRequests();
$logo = remplacetas('empresa','id','1','imagen') ;
$direccion = remplacetas('empresa','id','1','direccion') ;
$telefono = remplacetas('empresa','id','1','telefono') ;
$email = remplacetas('empresa','id','1','email') ;
?>
<!DOCTYPE html>
<html lang="en">
<head >
<meta charset="utf-8">
<meta name="viewport" content="user-scalable=no, width=device-width, maximum-scale=1, initial-scale=1">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<meta name="description" content="">
<meta name="author" content="fredyrivera" >
<?php $xajax->printJavascript("milfs/xajax/");
?>
<link rel="shortcut icon" href="favicon-152.png">
<link rel="apple-touch-icon-precomposed" href="favicon-152.png">
<link href="milfs/css/font-awesome/css/font-awesome.css" rel="stylesheet">
<link href="milfs/css/bootstrap.min.css" rel="stylesheet">
<!-- <link href="milfs/css/estilos.php" rel="stylesheet"> -->
<script src="milfs/js/jquery.min.js"></script>
<script src="milfs/js/jquery.timelinr-0.9.54.js"></script>
<script type="text/javascript">
//se.onchange = function(){alert('Dynamic')};
</script>
</head>
<body >
<!-- /container -->
<div id ='contenedor' style=' ' class="container-fluid">
<?php echo tuitealo("",'formulario'); ?>
</div>
<br>
<br>
<script src="milfs/js/bootstrap.min.js"></script>
<script src="milfs/js/scripts.js"></script>
</body>
</html>

40
api.php Normal file
View File

@ -0,0 +1,40 @@
<?php
session_start();
//ini_set('display_errors', 'On');
require ('xajax/xajax.inc.php');
$xajax = new xajax();
require ('funciones/funciones.php');
require ('funciones/convert.php');
require ("includes/markdown.php");
require ("funciones/conex.php");
$datos['id']=$_REQUEST['id'];
if(isset($_REQUEST['identificador'])) {$datos['identificador']=$_REQUEST['identificador'];}
if(isset($_REQUEST['dato'])) {$datos['dato']=$_REQUEST['dato'];}
if(isset($_REQUEST['inicio'])) {$datos['inicio']=$_REQUEST['inicio'];}
if(isset($_REQUEST['start'])) {$datos['start']=$_REQUEST['start'];}
if(isset($_REQUEST['fin'])) {$datos['fin']=$_REQUEST['fin'];}
if(isset($_REQUEST['end'])) {$datos['end']=$_REQUEST['end'];}
if(isset($_REQUEST['tipo'])) {$datos['tipo']=$_REQUEST['tipo'];}
if(isset($_REQUEST['formato'])) {$datos['formato']=$_REQUEST['formato'];}
if(isset($_REQUEST['registros'])) {$datos['registros']=$_REQUEST['registros'];}
if(isset($_REQUEST['pagina'])) {$datos['pagina']=$_REQUEST['pagina'];}
if(isset($_REQUEST['plantilla'])) {$datos['plantilla']=$_REQUEST['plantilla'];}
/*$datos['dato']=$_REQUEST['dato'];
$datos['inicio']=$_REQUEST['inicio'];
$datos['start']=$_REQUEST['start'];
$datos['fin']=$_REQUEST['fin'];
$datos['end']=$_REQUEST['end'];
$datos['tipo']=$_REQUEST['tipo'];*/
if(isset($_REQUEST['debug'])) {ini_set('display_errors', 'On');}
if(!isset($_REQUEST['formato'])) {
header('Content-Type: application/json');
echo json($datos);
}else{
echo "<br><br><div class='container-fluid '>".consultar_contenido_formulario("$datos[id]","$datos[registros]","$datos[pagina]","$datos[formato]",'',"$datos[plantilla]")."</div>";
}
//echo "hola /// $_REQUEST[id] // " ;
?>

96
archivos/index.php Normal file
View File

@ -0,0 +1,96 @@
<?php
session_start();
// Comprobamos si existe la variable
/*if ( !isset ( $_SESSION['id'] ) ) {
// Si no existe
header("Location: ../nodisponible.jpg");
// echo "hola mundo2";
}*/
if(!isset($_GET['archivo']) ){
header("Location: ../images/sinimagen.jpg");
}else {$archivo = $_GET['archivo'];}
include("../includes/datos.php");
function remplacetas($tabla,$campo,$valor,$por,$and){
include_once("../funciones/conex.php");
$link=Conectarse_recursivo();
mysqli_set_charset($link, "utf8");
if(@$and !=''){$AND = "AND $and";}else{$AND ="";}
//$consulta = "SELECT * , md5(binary $por ) as md5_".$por." FROM $tabla WHERE $campo = '$valor' $AND order by $campo DESC limit 1";
$consulta = "SELECT * , md5(binary $por ) as md5_".$por." FROM $tabla WHERE $campo = '$valor' $AND order by id DESC limit 1";
$sql=mysqli_query($link,$consulta);
if (@mysqli_num_rows($sql)!=0){
$resultado[] = mysqli_result($sql,0,$por);
$resultado[] = mysqli_result($sql,0,'id');
$resultado[] = $consulta;
$resultado[] = mysqli_result($sql,0,"md5_$por");
$resultado[] = @mysqli_result($sql,0,"timestamp");
$resultado[] = @mysqli_result($sql,0,"form_id");
$resultado[] = @mysqli_result($sql,0,"id_usuario"); //6
$resultado[] = @mysqli_result($sql,0,"id_empresa"); //7
$resultado[] = @mysqli_result($sql,0,"equipo");
}else{
$resultado[0] = '';
$resultado[1] ="";
$resultado[2] = $consulta;
$resultado[3] = NULL;
$resultado[4] = NULL;
$resultado[4] = NULL;
}
return $resultado;
}
function mysqli_result($res,$row=0,$col=0){
$numrows = @mysqli_num_rows($res);
if ($numrows && $row <= ($numrows-1) && $row >=0){
mysqli_data_seek($res,$row);
$resrow = (is_numeric($col)) ? mysqli_fetch_row($res) : mysqli_fetch_assoc($res);
if (isset($resrow[$col])){
return $resrow[$col];
}
}
return false;
}
$control = remplacetas('form_datos','contenido',"$archivo",'control',"") ;
$privacidad = remplacetas('form_id','id',"$control[5]",'publico',"") ;
//if($privacidad[0] == 0 AND ($_SESSION['id'] != $control[6] OR $_SESSION['id_empresa'] != $control[7]) or $_SESSION['equipo'] != $control[8] ) {
if($privacidad[0] == 0 AND ($_SESSION['id'] != $control[6] OR $_SESSION['id_empresa'] != $control[7] or $_SESSION['equipo'] != $control[8] )) {
header("Location: ../images/seguridad.gif");
//echo "if($privacidad[0] == 0 AND ($_SESSION[id] != $control[6] OR $_SESSION[id_empresa] != $control[7] or $_SESSION[equipo] != $control[8])";
exit();
}
//else{ echo "$privacidad[2]"; exit();}
$dir="$path_images_secure/full/";
if ((!$file=realpath($dir.$_GET['archivo']))
|| strpos($file,realpath($dir))!==0 || substr($file,-4)=='.php'){
//header('HTTP/1.0 404 Not Found');
header("Location: ../images/sinimagen.jpg");
exit();
}
$ref=$_SERVER['HTTP_REFERER'];
if (strpos($ref,'https://')===0 || strpos($ref,'https')!==0){
/* $mime=array(
'jpg'=>'image/jpeg',
'png'=>'image/png',
'mid'=>'audio/x-midi',
'wav'=>'audio/x-wav'
);
if($mime[substr($file,-3)] =='') {
header('Location: ../pixel.png');
exit();
}*/
$stat=stat($file);
header('Content-Type: '.$mime[substr($file,-3)]);
header('Content-Length: '.$stat[7]);
header('Last-Modified: '.gmdate('D, d M Y H:i:s',$stat[9]).' GMT');
readfile($file);
exit();
}
header('Pragma: no-cache');
header('Cache-Control: no-cache, no-store, must-revalidate');
include($file.'.php');
?>

Some files were not shown because too many files have changed in this diff Show More