Exemple #1
0
    if (strlen($val) == 0) {
        return 0;
    }
    $last = strtolower($val[strlen($val) - 1]);
    switch ($last) {
        // The 'G' modifier is available since PHP 5.1.0
        case 'g':
            $val *= 1024;
        case 'm':
            $val *= 1024;
        case 'k':
            $val *= 1;
    }
    return $val;
}
$m = is_renameable();
/* get maximum upload size */
function getMaximumUploadSize()
{
    $upload_max = return_kbytes(ini_get('upload_max_filesize'));
    $post_max = return_kbytes(ini_get('post_max_size'));
    return $upload_max < $post_max ? $upload_max : $post_max;
}
/*
compares caseinsensitive - normally this could be done with natcasesort -
but this seems to be buggy on my test system!
*/
function mycmp($a, $b)
{
    return strnatcasecmp($a, $b);
}
function register()
{
    global $mybasedir;
    $mainframe = JFactory::getApplication();
    $l = trim(JRequest::getVar('l', ''));
    $d = trim(JRequest::getVar('d', ''));
    $s = trim(JRequest::getVar('s', ''));
    // we remove invalid input
    $l = str_replace('$l="', '', $l);
    $d = str_replace('$d="', '', $d);
    $s = str_replace('$s="', '', $s);
    $l = str_replace('";', '', $l);
    $d = str_replace('";', '', $d);
    $s = str_replace('";', '', $s);
    $l = str_replace('"', '', $l);
    $d = str_replace('"', '', $d);
    $s = str_replace('"', '', $s);
    $filename = dirname(__FILE__) . "/" . $mybasedir . "tfu/twg.lic.php";
    $file = fopen($filename, 'w');
    fputs($file, "<?php\n");
    fputs($file, "\$l=\"" . $l . "\";\n");
    fputs($file, "\$d=\"" . $d . "\";\n");
    fputs($file, "\$s=\"" . $s . "\";\n");
    fputs($file, "?>");
    fclose($file);
    if (!file_exists($filename)) {
        $text = JText::_('MES_LICENSE_NOT_CREATED');
    } else {
        // we now check if the file can be renamed.
        $m = is_renameable();
        if ($m == "s" || $m == "w") {
            $text = JText::_('MES_LICENSE_WRONG');
            @unlink($filename);
        } else {
            $text = JText::_('MES_LICENSE_OK');
        }
    }
    cleanMessageQueue();
    $mainframe->redirect("index.php?option=com_jfuploader&act=help", $text);
}