Пример #1
0
function resizeImage(&$filename, &$mime, $return = 0)
{
    //start timing
    $time_start = getmicrotime();
    /*** this disallows Win32 ***/
    if (DIRECTORY_SEPARATOR != "/" && !EWIKI_IMAGERESIZE_WIN || strpos($mime, "image/") !== 0) {
        return false;
    }
    if (!isMemoryFriendly($filename)) {
        return false;
    }
    if (isCandyCane($filename)) {
        return false;
    }
    $rescaled_filename = $filename;
    $type = getTypeFromMIME($mime);
    $orig_image = getImageStream($rescaled_filename, $type);
    if (!isset($orig_image)) {
        return false;
    }
    getXY($orig_image, $orig_x, $orig_y);
    if (!isResizeNeeded($orig_x, $filename)) {
        return true;
    }
    getInitialResize($orig_image, $new_x, $new_y);
    $orig_image = doResize($orig_image, $new_x, $new_y, $type);
    $rescaled_filename = tempnam(EWIKI_TMP, "ewiki.img_resize_gd.tmp.");
    doSave($orig_image, $rescaled_filename, $type);
    if (isResizeNeeded($new_x, $rescaled_filename)) {
        ewiki_log("Resize beyond initial resize is needed.  Carrying through.", 3);
        //set starting points for binary search
        $x_max = EWIKI_IMAGE_MAX_X - 1;
        $x_min = EWIKI_IMAGE_MIN_X;
        //set failsafe break to max number of iterations through the loop
        $failsafe = (int) (log($orig_x) + 1);
        while ($x_min <= $x_max && !isImageTolerable($rescaled_filename)) {
            ewiki_log("While loop initiated", 3);
            //somehow made it to an infinite loop, so get out
            if ($failsafe < 0) {
                return false;
            }
            //take a guess at the correct width
            $x_guess = (int) (($x_max + $x_min) / 2);
            if ($filename == $rescaled_filename) {
                $rescaled_filename = tempnam(EWIKI_TMP, "ewiki.img_resize_gd.tmp.");
            }
            #-- sizes
            $new_x = (int) $x_guess;
            $new_y = (int) ($x_guess * $orig_y / $orig_x);
            $new_image = doResize($orig_image, $new_x, $new_y, $type);
            doSave($new_image, $rescaled_filename, $type);
            #-- prepare next run
            imagedestroy($new_image);
            clearstatcache();
            $failsafe--;
            $ftmp = filesize($rescaled_filename);
            ewiki_log("xguess: {$x_guess}, xmin: {$x_min}, xmax: {$x_max}, filesize: {$ftmp}", 3);
            if (filesize($rescaled_filename) < EWIKI_IMAGE_TOLERANCE) {
                $x_min = $x_guess + 1;
            } else {
                if (filesize($rescaled_filename) > EWIKI_IMAGE_MAXSIZE) {
                    $x_max = $x_guess - 1;
                }
            }
        }
        ewiki_log("While loop ended", 3);
    }
    #-- stop
    imagedestroy($orig_image);
    clearstatcache();
    #-- security check filesizes, abort
    if (!filesize($filename) || !filesize($rescaled_filename) || filesize($rescaled_filename) > EWIKI_IMAGE_MAXSIZE) {
        unlink($rescaled_filename);
        return $false;
    }
    #-- set $mime, as it may have changed (.gif)
    $mime = strtok($mime, "/") . "/" . $type;
    if (!strstr($filename, ".{$type}")) {
        unlink($filename);
        $filename .= ".{$type}";
    }
    #-- move tmp file to old name
    copy($rescaled_filename, $filename);
    unlink($rescaled_filename);
    //end timing
    $time_end = getmicrotime();
    $time = $time_end - $time_start;
    ewiki_log("{$time} seconds to perform resizing", 3);
    return true;
}
Пример #2
0
 protected function eventSave($aEvent)
 {
     doSave();
 }
Пример #3
0
			}); 
		}); 
		</script>
	</head>
<body>
	<H2>Gruppen - Verwaltung</H2>
<?php 
if (isset($_POST['newFrm']) || isset($_GET['newFrm'])) {
    doEdit(null, true);
} else {
    if (isset($_GET['edit'])) {
        doEdit(addslashes($_GET['kurzbz']), false);
    } else {
        if (isset($_POST['type']) && $_POST['type'] == 'save') {
            printDropDown();
            doSave();
            getUebersicht();
        } else {
            if (isset($_GET['type']) && $_GET['type'] == 'delete') {
                printDropDown();
                $e = new gruppe();
                if (!$e->delete($_GET['einheit_id'])) {
                    echo $e->errormsg;
                }
                getUebersicht();
            } else {
                printDropDown();
                getUebersicht();
            }
        }
    }
Пример #4
0
//$data = file_get_contents("php://input");
//$objData = json_decode($data);
$objData = $_REQUEST[''];
// Action recebe a acao que sera executada
switch ($objData->action) {
    case 'login':
        login($objData);
        break;
    case 'sync_cliente':
        syncCliente();
        break;
    case 'sync_pedidos':
        syncPedidos();
        break;
    case 'save':
        doSave($objData);
        break;
    case 'search':
        doSearch();
        break;
    case 'find':
        findByCode();
        break;
    case 'delete':
        delete();
        break;
    default:
}
function login($objData)
{
    @(require_once "include/functions.inc.php");