示例#1
0
function workaroundToUpgradePortfolio()
{
    global $portfolioFolder;
    foreach (glob("{$portfolioFolder}/*-db.json") as $dbFilename) {
        $db = readDb($dbFilename);
        $db->sort = isset($db->sort) ? $db->sort : intval($db->id) * 10000;
        $db->original = isset($db->original) ? $db->original : $db->{"original-file-name"};
        $db->uploaded = isset($db->uploaded) ? $db->uploaded : $db->{"upload-date"};
        $db->display = isset($db->display) ? $db->display === "on" || $db->display === true : true;
        saveDb($dbFilename, $db);
    }
    logEvent("portfolio-upgrade-done", "last-image", $db->id, $db);
}
示例#2
0
function processUploads()
{
    global $uploadsFolder, $portfolioFolder;
    $files = array_values(preg_grep("/[.](jpg|jpeg|png)\$/i", scandir($uploadsFolder)));
    foreach ($files as $filename) {
        $id = getNextImageId();
        $pathInfo = pathinfo($filename);
        $extension = strtolower($pathInfo["extension"]);
        $origFile = "{$portfolioFolder}/{$id}-original.{$extension}";
        rename("{$uploadsFolder}/{$filename}", $origFile);
        createImages($origFile, $id);
        $dbFilename = "{$portfolioFolder}/{$id}-db.json";
        $imageDb = array("id" => $id, "sort" => intval($id) * 10000, "original" => $filename, "uploaded" => gmdate("Y-m-d"), "display" => false, "caption" => "", "description" => "", "badge" => "");
        saveDb($dbFilename, $imageDb);
    }
    $msg = "Images processed: " . count($files);
    return array("count" => count($files), "files" => $files, "message" => $msg);
}
示例#3
0
function saveAccountsDb($db)
{
    global $accountsDbFile;
    logEvent("save-accounts-db", count($db->users), count($db->invites));
    return saveDb($accountsDbFile, $db);
}
示例#4
0
        }
        echo json_encode($response);
        break;
    case 'confirmSubscription':
        $users = getDb(USER_DB);
        $current = false;
        foreach ($users as $key => $user) {
            if (isset($user['confirm']) && $_['c'] == $user['confirm']) {
                unset($users[$key]['confirm']);
                $current = $user;
            }
        }
        if ($current == false) {
            echo 'Ce code de validation ne correspond à aucun compte';
        } else {
            saveDb(USER_DB, $users);
            header('location:index.php?message=Inscription confirmée, vous pouvez vous identifier.');
        }
        break;
    case 'suscribeForm':
        $k = rand(0, count($botsphinx) - 1);
        $q = $botsphinx[$k];
        echo '
			<h1>Inscription</h1>
			<p>Merci de bien vouloir répondre aux questions ci dessous.</p>
			<form id="suscribe-form">
			<label for="login">E-mail</label> : <br/><input type="text" style="width:150px;padding:3px;" id="login"><br/>
			<label for="password">Mot de passe</label>  : <br/><input type="password" style="width:150px;padding:3px;" id="password"><br/>
			<label for="password-confirm">Confirmation mot de passe :</label> <br/><input type="password" style="width:150px;padding:3px;" id="password-confirm"><br/>
			<label for="robot">' . $q[0] . ' :</label> <br/><input type="text" style="width:150px;padding:3px;" id="robot"><input id="robot-num" value="' . $k . '" type="hidden"><br/>
			<button id="button-suscribe" onclick="sendSuscribe();">Inscription</button>