}
}
/* ----------------------------------------
	Try InDesign - for CS5 (page previews)
   ----------------------------------------
*/
if ($exiftool_fullpath != false) {
    if ($extension == "indd" && !isset($newfile)) {
        $indd_thumbs = extract_indd_pages($file);
        if (is_array($indd_thumbs)) {
            $pagescommand = "";
            $n = 0;
            foreach ($indd_thumbs as $indd_page) {
                echo $indd_page;
                $pagescommand .= " " . $target . "_" . $n;
                base64_to_jpeg(str_replace("base64:", "", $indd_page), $target . "_" . $n);
                $n++;
            }
        }
        // process jpgs as a pdf so the existing pdf paging code can be used.
        $file = get_resource_path($ref, true, "", false, "pdf");
        $jpg2pdfcommand = $convert_fullpath . " " . $pagescommand . " " . $file;
        $output = run_command($jpg2pdfcommand);
        $n = 0;
        foreach ($indd_thumbs as $indd_page) {
            unlink($target . "_" . $n);
            $n++;
        }
        $extension = "pdf";
        $dUseCIEColor = false;
        $n = 0;
Example #2
0
function createOrder()
{
    $query = mysql_query("SELECT * FROM agent_sessions WHERE session = '" . $_POST['uid'] . "'");
    $res = mysql_fetch_array($query);
    if ($res['session'] == null) {
        return 0;
    }
    $agentID = $res['user_id'];
    file_put_contents("./logs/orders/orders" . date('Ymdhis') . ".txt", $_POST['data']);
    $orders = json_decode($_POST['data']);
    foreach ($orders as $order) {
        if ($order->Photo != "") {
            $photo = uniqid() . '.png';
            base64_to_jpeg(str_replace(" ", "+", str_replace("\n", "", $order->Photo)), $_SERVER['DOCUMENT_ROOT'] . '/Agents/Photos/' . $photo);
        }
        mysql_query("INSERT INTO agent_orders (customer_id, user_id, comment, photo, lat, lng) VALUES ('" . $order->CustomerID . "', '" . $agentID . "', '" . $order->Comment . "', '" . $photo . "', '" . $order->Lat . "', '" . $order->Lng . "')");
        $orderID = mysql_insert_id();
        foreach ($order->Cart as $cLine) {
            mysql_query("INSERT INTO agent_cart (order_id, product_id, quantity, price) VALUES ('" . $orderID . "', '" . $cLine->ProductID . "', '" . $cLine->Quant . "', '" . $cLine->Price . "') ");
        }
    }
    echo '1';
}
Example #3
0
<?php

function base64_to_jpeg($base64_string, $output_file)
{
    $ifp = fopen($output_file, "wb");
    fwrite($ifp, base64_decode($base64_string));
    fclose($ifp);
    return $output_file;
}
$nome = md5(microtime());
$imagem = str_replace('data:image/png;base64,', '', $_POST['imagem']);
$imagem = str_replace('data:image/jpg;base64,', '', $imagem);
base64_to_jpeg($imagem, "pasta12/" . $nome . ".png");
echo json_encode(array('imagem' => 1));
            unlink($target);
        }
    }
    hook("indesign");
}
/* ----------------------------------------
	Try InDesign - for CS5 (page previews)
   ----------------------------------------
*/
if ($exiftool_fullpath != false) {
    if ($extension == "indd" && !isset($newfile)) {
        $indd_thumbs = extract_indd_pages($file);
        if (is_array($indd_thumbs)) {
            $n = 0;
            foreach ($indd_thumbs as $indd_thumb) {
                base64_to_jpeg($indd_thumb, $target . "_" . $n);
                $n++;
            }
            $pagescommand = "";
            for ($x = 0; $x < $n; $x++) {
                $pagescommand .= " " . $target . "_" . $x;
            }
            // process jpgs as a pdf so the existing pdf paging code can be used.
            $file = get_resource_path($ref, true, "", false, "pdf");
            $jpg2pdfcommand = $convert_fullpath . " " . $pagescommand . " " . $file;
            $output = run_command($jpg2pdfcommand);
            for ($x = 0; $x < $n; $x++) {
                unlink($target . "_" . $x);
            }
            $extension = "pdf";
            $dUseCIEColor = false;
Example #5
0
<?php

require_once 'class.phpmailer.php';
function base64_to_jpeg($base64_string, $output_file)
{
    $ifp = fopen($output_file, "wb");
    $data = explode(',', $base64_string);
    fwrite($ifp, base64_decode($data[1]));
    fclose($ifp);
    return $output_file;
}
$data = $_POST['dataString'];
$data = json_decode($data, true);
$to = $data['email'];
$img = $data['image'];
$title = "Trajectory Drawing Image";
$image = base64_to_jpeg($img, 'tmp.jpg');
$email = new PHPMailer();
$email->From = '*****@*****.**';
$email->FromName = 'Trajectory Drawing';
$email->Subject = 'Trajectory Drawing';
$email->Body = 'Here your image';
$email->AddAddress($to);
$email->isHTML(true);
$email->AddAttachment($image, 'd1.png');
return $email->Send();
echo "Hello";
                                                                            }
                                                                            if (strlen($objResult1["c3"]) > 5000) {
                                                                                ?>3. <?
                                                                                $data = $objResult1["c3"];
                                                                                $type = "jpg";
                                                                                $base64 = 'data:image/' . $type . ';base64,' . "/9j/".$data;
                                                                                base64_to_jpeg($base64, 'c3_'.$i.'.jpg');
                                                                                ?><img src='img_buffer_test/c3_<?=$i?>.jpg' width="80"><BR><?
                                                                                    } else {
                                                                                        echo '&nbsp;&nbsp;' . "3. " . $objResult1["c3"] . "<BR>";
                                                                                    }if (strlen($objResult1["c4"]) > 5000) {
                                                                                        ?>4. <?
                                                                                        $data = $objResult1["c4"];
                                                                                        $type = "jpg";
                                                                                        $base64 = 'data:image/' . $type . ';base64,' . "/9j/".$data;
                                                                                        base64_to_jpeg($base64, 'c4_'.$i.'.jpg');
                                                                                        ?><img src='img_buffer_test/c4_<?=$i?>.jpg' width="80"><BR><?
                                                                                            } else {
                                                                                                echo '&nbsp;&nbsp;' . "4. " . $objResult1["c4"] . "<BR>";
                                                                                            }

                                                                                            $i++;
                                                                                            echo "<BR><BR>";
                                                                                            ?></td>
                                                                                            </tr>

                                                                                            <?php
                                                                                        }
                                                                                        ?>
                                                                                        </table>
<?php

require_once 'mpdf60/mpdf.php';
function base64_to_jpeg($base64_string, $output_file)
{
    $ifp = fopen($output_file, "wb");
    $data = explode(',', $base64_string);
    fwrite($ifp, base64_decode($data[1]));
    fclose($ifp);
    return $output_file;
}
$path = 'camilla.jpg';
$type = pathinfo($path, PATHINFO_EXTENSION);
echo $type;
$data = file_get_contents($path);
$base64 = 'data:image/' . $type . ';base64,' . base64_encode($data);
base64_to_jpeg($base64, 'tmp.jpg');
$html = "<img src='tmp.jpg' width=300>";
//
$mpdf = new mPDF('tahi', '', '', '', '5', '5', '5', '5', 'naramit');
//
$mpdf->WriteHTML($html);
//
$mpdf->Output();
Example #8
0
function receiveChunks($uploadFolder = null, $callbackFn = null)
{
    $targetFolder = @$uploadFolder ?: __DIR__;
    // 	$targetFolder = $targetFolder.DIRECTORY_SEPARATOR.'uploaded-files';
    $response = array();
    function base64_to_jpeg($base64_string, $output_file)
    {
        if (($ifp = fopen($output_file, "wb")) === false) {
            throw new Exception('Cannot create image file');
        }
        $data = explode(',', $base64_string);
        if (!@fwrite($ifp, base64_decode($data[1]))) {
            throw new Exception('Cannot write data to the image file');
        }
        fclose($ifp);
        return true;
    }
    try {
        // validate request
        if ($_SERVER['REQUEST_METHOD'] !== 'POST') {
            throw new Exception('request method is not POST');
        }
        // check parameters
        if (!isset($_POST['chunkContent']) || !isset($_POST['chunkNumber']) || !isset($_POST['size']) || !isset($_POST['chunkSize']) || !isset($_POST['fileName']) || !isset($_POST['last']) || !isset($_POST['uploadToken'])) {
            throw new Exception('bad request parameters');
        }
        // check target folder
        if (!is_dir($targetFolder)) {
            if (!@mkdir($targetFolder, 0777, true)) {
                throw new Exception('cannot create target folder');
            }
        }
        if (!is_writable($targetFolder)) {
            throw new Exception('no permissions to target folder');
        }
        // check/create token
        $token = empty($_POST['uploadToken']) || strcasecmp($_POST['uploadToken'], 'null') == 0 ? uniqid('uploadToken') : $_POST['uploadToken'];
        // create file with chunk content
        $chunkFileName = $targetFolder . DIRECTORY_SEPARATOR . $token . '_' . $_POST['chunkNumber'];
        file_put_contents($chunkFileName, $_POST['chunkContent']);
        if (strcasecmp($_POST['last'], 'true') == 0) {
            $totalChunks = $_POST['chunkNumber'];
            $base64String = '';
            $targetFile = $targetFolder . DIRECTORY_SEPARATOR . $_POST['fileName'];
            for ($i = 0; $i <= $totalChunks; $i++) {
                $chunkFileName = $targetFolder . DIRECTORY_SEPARATOR . $token . '_' . $i;
                $base64String .= file_get_contents($chunkFileName);
                if (!@unlink($chunkFileName)) {
                    throw new Exception('cannot delete temporary chunk file');
                }
            }
            base64_to_jpeg($base64String, $targetFile);
            if (is_callable($callbackFn)) {
                $callbackFn($targetFile, $_POST);
            }
        }
        $response['result'] = 'ok';
        $response['token'] = $token;
    } catch (Exception $e) {
        $response['result'] = 'error';
        $response['error'] = $e->getMessage();
    }
    echo json_encode($response, true);
}
Example #9
0
    $textcolor = @imagecolorallocate($im, 0, 0, 255);
    list($x, $y, $type) = getimagesize($inputfile);
    $txtpos_x = $x - 170;
    $txtpos_y = $y - 20;
    @imagestring($im, 5, $txtpos_x, $txtpos_y, 'Powered by Zetakey', $textcolor);
    $txtpos_x = $x - 145;
    $txtpos_y = 20;
    @imagestring($im, 3, $txtpos_x, $txtpos_y, date("Y-m-d H:i:s"), $textcolor);
    @imagepng($im, $outputfile);
    // Output the image
    //imagejpeg($im);
    @imagedestroy($im);
}
date_default_timezone_set("Asia/Hong_Kong");
$output_file = "captured/signature" . date("Y-m-d-H-i-s-") . time() . ".png";
base64_to_jpeg($_POST["image"], $output_file);
add_ZK_mark($output_file, $output_file);
$to = $_POST["email"];
$replyemail = $_POST["replyemail"];
$replyemail = "*****@*****.**";
if (!isset($_POST["email"]) || $to == "*****@*****.**" || $replyemail == "*****@*****.**" || $to == "") {
    echo "<p>Incorrect email address...</p>";
    echo "<a href=\"index.html\">Sign and Send again!</a>";
    exit;
}
$subject = "You got a captured sigature";
$curdir = dirname($_SERVER['REQUEST_URI']) . "/";
$dir = $_SERVER['SERVER_NAME'] . $curdir;
$urlonly = geturlonly();
$body = "Signed on " . date("Y.m.d H:i:s") . "\n Zetakey Webapp - Sign and Send " . $urlonly . "\n";
//$from = "*****@*****.**";
Example #10
0
<?php

include_once '../../assets/includes/db_conexion.php';
include_once '../../assets/includes/funciones.php';
sec_session_start();
$user = $_SESSION['username'];
if (isset($_POST['imagen'], $_POST['nombre'])) {
    $uploaddir = '../../users/' . $user . '/video/';
    $image = $_POST['imagen'];
    $new_image_name = $_POST['nombre'];
    $subject = $image;
    $search = 'data:image/gif;base64,';
    $trimmed = str_replace($search, '', $subject);
    function base64_to_jpeg($base64_string, $output_file)
    {
        $ifp = fopen($output_file, "wb");
        $code_binary = base64_decode($base64_string);
        fwrite($ifp, $code_binary);
        fclose($ifp);
        echo "hola";
    }
    $gif_file = $uploaddir . "/thumbs/" . $new_image_name . ".gif";
    $image = base64_to_jpeg($trimmed, $gif_file);
}
Example #11
0
    fclose($ifp);
    return $output_file;
}
function encodeEmotion($emotion)
{
    $emotion = str_replace(":", "_colon_", $emotion);
    $emotion = str_replace("-", "_dash_", $emotion);
    $emotion = str_replace("(", "_openparen_", $emotion);
    $emotion = str_replace(")", "_closeparen_", $emotion);
    $emotion = str_replace(" ", "_space_", $emotion);
    $emotion = str_replace(",", "_comma_", $emotion);
    $emotion = str_replace("'", "_apostrophe_", $emotion);
    $emotion = str_replace("|", "_bar_", $emotion);
    $emotion = str_replace("\\", "_backslash_", $emotion);
    $emotion = str_replace("/", "_slash_", $emotion);
    $emotion = str_replace("<", "_greaterthan_", $emotion);
    $emotion = str_replace(">", "_lessthan_", $emotion);
    $emotion = str_replace("*", "_asterix_", $emotion);
    $emotion = str_replace(",", "_period_", $emotion);
    $emotion = str_replace("^", "_caret_", $emotion);
    return $emotion;
}
$face = $_POST['face'];
$e = $_POST['emotion'];
if ($face && $e) {
    $e = encodeEmotion($e);
    $time = time();
    base64_to_jpeg($face, "./images/" . $time . $e . ".jpg");
} else {
    echo "No compatible data received.";
}
Example #12
0
                            <p class="title">' . countLikes($pictures[$i]["id"], $likes) . ' likes / ' . countLikes($pictures[$i]["id"], $comments) . ' Comments</p><br>
                        </div>
                    </div>
                </div>
        </div>
        </div>';
    $resp_infinite = array();
    $resp_infinite[0] = $node_to_add;
    $resp_infinite[1] = $limit;
    echo json_encode($resp_infinite);
}
if (isset($data["url"])) {
    $face = $data["face"];
    $pictureName = $data["url"];
    $facePicture = 'faces/' . $face . '.png';
    base64_to_jpeg($pictureName, 'temp/preview.png');
    $dest = imagecreatefrompng("temp/preview.png");
    $src = imagecreatefrompng($facePicture);
    //    imagealphablending($image_1, true);
    //    imagesavealpha($image_1, true);
    //    imagecopy($image_1, $image_2, 0, 0, 0, 0, 100, 100);
    //    imagepng($image_1, 'image_3.png')
    imagealphablending($dest, true);
    imagesavealpha($dest, true);
    imagecopy($dest, $src, 100, 0, 0, 0, 100, 142);
    //have to play with these numbers for it to work for you, etc.
    header('Content-Type: image/png');
    imagepng($dest, 'temp/blend.png');
    imagedestroy($dest);
    imagedestroy($src);
    echo 'temp/blend.png';
 public function upload_image()
 {
     //pr($_FILES);die;
     $retval = base64_to_jpeg($_POST['image']);
     $retval = str_replace("uploads/ad/tmp/", "", $retval);
     echo $retval;
 }
<?php

/*Recepcion de los 2 datos que se enviaran por post y que ya estan en formato JSON*/
$usuario = $_POST['imagen'];
$obj = json_decode($usuario);
/*Esto es de prueba, solo es para verificar que los datos recibidos se encuentren correctamente.
Se crea un archivo para los datos de usuario, y otro para los datos del test*/
$fileUser = fopen($obj->{'nombre'} . ".txt", "w") or die("Unable to open file!");
fwrite($fileUser, $obj->{'imagen'});
fclose($fileUser);
function base64_to_jpeg($base64_string, $output_file)
{
    $ifp = fopen($output_file, "wb");
    $data = explode(',', $base64_string);
    fwrite($ifp, base64_decode($data[0]));
    fclose($ifp);
    return $output_file;
}
$image = base64_to_jpeg($obj->{'imagen'}, $obj->{'nombre'} . '.jpg');
/*Finalmente se responde la peticion del consumo del webservice.*/
print json_encode(array('respuesta' => 'Exito en la operacion', 'var2' => 'xxx'));