# Image to show when loading previews.
$generatingGif = "http://github.com/jedediahfrey/KISS-PHP-Gallery/raw/master/generating.gif";
# Image to show when generating thumbnails
/* End Config */
/* Baseline Variables. Stuff used everywhere */
$scriptPath = fixDir(getcwd());
$baseURL = dirname("http://" . $_SERVER['HTTP_HOST'] . $_SERVER['SCRIPT_NAME']) . "/";
# Fails if there are 'query string' characters in the query string.
# list($dir,$file) = getArguments($_GET['dir']); # Get the directory & image file
list($dir, $file) = getArguments(end(explode("=", $_SERVER['QUERY_STRING'])));
# Verify that the thumb binary is executable.
if (!is_executable($thumbBinary)) {
    exit("Thumb executable '{$thumbBinary}' is not executable");
}
# Create htaccess file. Required for all functions. This can be commented out after first run. Adds ~1E-5s to execution time.
makeHtaccess();
# If the script is called from the command line. Set variables.
if ($argc) {
    $_GET['command'] = "thumbs";
    $dir = $argv[1];
    $_GET['recursive'] = TRUE;
}
# BBClone Setup the bbclone information. Track visits via bbclone.
define("_BBCLONE_DIR", $scriptPath . "bbclone/");
define("COUNTER", _BBCLONE_DIR . "mark_page.php");
if (!empty($includeFile)) {
    include $includeFile;
}
# Control Central
switch ($_GET['command']) {
    case "gallery":
Beispiel #2
0
function runInstall($db, $sqlline = 0)
{
    global $arg;
    if ($sqlline == 0) {
        return;
    }
    if (strlen($db->olddb) > 0) {
        $upgrade = 1;
    } else {
        $upgrade = 0;
    }
    //Depending on our scenario, gather SQL strings
    //The beginning of our line# process is for migrating
    if ($upgrade) {
        $sqlstrings = initialMigrateTables() . migrateTwoFiveToThree();
        $arrSql = explode(";", $sqlstrings);
        $total = count($arrSql) + 13;
        $lineDeduct = 15;
    } else {
        $sqlstrings = ";;;";
        $arrSql = explode(";", $sqlstrings);
        $total = 16;
        $lineDeduct = 0;
    }
    switch ($sqlline) {
        case 1:
            if (!file_exists('core') && !file_exists('webstore.zip')) {
                $dest = isset($_POST['qa']) ? "qa/" . $_POST['qa'] : "latestwebstore";
                $cdn = isset($_POST['qa']) ? "webstore-qa" : "webstore-full";
                $jLatest = downloadFile("http://updater.lightspeedretail.com/site/" . $dest);
                $result = json_decode($jLatest);
                return json_encode(array('result' => "success", 'tag' => 'Downloading Web Store program file ' . $result->latest->filename . '...', 'line' => $sqlline, 'total' => $total, 'upgrade' => $upgrade));
            } else {
                return json_encode(array('result' => "success", 'tag' => 'Skipping downloading', 'line' => $sqlline, 'total' => $total, 'upgrade' => $upgrade));
            }
            break;
        case 2:
            downloadLatest();
            return json_encode(array('result' => "success", 'tag' => 'Extracting Web Store files...', 'line' => $sqlline, 'total' => $total, 'upgrade' => $upgrade));
            break;
        case 3:
            zipAndFolders();
            $tag = "Starting Install...";
            return json_encode(array('result' => "success", 'tag' => $tag, 'line' => $sqlline, 'total' => $total, 'upgrade' => $upgrade));
            break;
        case 4:
            if ($upgrade) {
                $db->changedb('old');
            }
            if ($upgrade) {
                if ($db->schemaNumber < 217) {
                    up217($db);
                }
            }
            if ($upgrade) {
                $db->changedb('old');
            }
            if ($upgrade) {
                if ($db->schemaNumber == 217) {
                    up250($db, $sqlline);
                }
            }
            $tag = "Applying pre-3.0 changes. Line #" . $sqlline;
            if (!$upgrade) {
                //we're going to skip ahead to the end. The butler did it!
                $sqlline = 15;
                $tag = "Setting up new database, stand by...";
                return json_encode(array('result' => "success", 'tag' => $tag, 'line' => $sqlline, 'total' => $total, 'upgrade' => $upgrade));
            }
            break;
        case 5:
        case 6:
        case 7:
        case 8:
        case 9:
        case 10:
        case 11:
            if ($upgrade) {
                $db->changedb('old');
            }
            if ($upgrade) {
                if ($db->schemaNumber == 217) {
                    up250($db, $sqlline);
                }
            }
            $tag = "Applying pre-3.0 changes. Line #" . $sqlline;
            break;
        case 12:
            if ($upgrade) {
                $db->changedb('old');
            }
            if ($upgrade) {
                if ($db->schemaNumber == 250) {
                    up251($db);
                }
            }
            $tag = "Applying pre-3.0 changes. Line #" . $sqlline;
            break;
        case 13:
            if ($upgrade) {
                $db->changedb('old');
            }
            if ($upgrade) {
                if ($db->schemaNumber == 251) {
                    up252($db);
                }
            }
            if ($upgrade) {
                prep252($db);
            }
            $tag = "Creating new tables. Line #" . $sqlline;
            break;
        case 14:
            $db->changedb('new');
            initialCreateTables($db);
            //Create all tables at once
            if (!$upgrade) {
                initialConfigLoad($db);
            }
            break;
        default:
            $db->changedb('new');
            if ($upgrade) {
                $sqlStringtoRun = trim($arrSql[$sqlline - 15], "\n\r\t");
                $sqlStringtoRun = str_replace("{newdbname}", $db->newdb, $sqlStringtoRun);
                if (!($upgrade == 0 && strpos($sqlStringtoRun, '{olddbname}') !== false)) {
                    $sqlStringtoRun = str_replace("{olddbname}", $db->olddb, $sqlStringtoRun);
                    $db->query('SET NAMES utf8');
                    $db->query('SET FOREIGN_KEY_CHECKS=0');
                    $db->query($sqlStringtoRun);
                    if ($sqlline < 28) {
                        $tag = "Creating tables";
                    }
                    if ($sqlline >= 28 && $sqlline <= 75) {
                        $tag = "Processing images table";
                    }
                }
            }
            //Build our main.php in config so we can run the system
            if ($sqlline == $total) {
                makeHtaccess();
                installMainConfig();
                if (!isset($arg['hosted'])) {
                    $tag = "Downloading default template...";
                }
            }
    }
    if (isset($tag)) {
        $retVal = json_encode(array('result' => "success", 'line' => $sqlline, 'tag' => $tag, 'total' => $total, 'upgrade' => $upgrade));
    } else {
        $retVal = json_encode(array('result' => "success", 'line' => $sqlline, 'total' => $total, 'upgrade' => $upgrade));
    }
    return $retVal;
}