if (preg_match('#<div class="price"><strong>([0-9,]*) €</strong></div>#', $line, $mat)) { $price = doubleval(str_replace(",", ".", $mat[1])); $books[count($books) - 1][2] = $price; } if (preg_match('#<a class="next_page" rel="next" href="([^"]*)">#', $line, $mat)) { $nextfound = "http://librairie.immateriel.fr" . $mat[1]; } } if ($nextfound) { // get the next page :) $return = curl_simple_get($nextfound); } } while ($nextfound); foreach ($books as $book) { // scrap it. We don't expect to have duplicate names anytime soon there ;) $already = mqone("SELECT * FROM books WHERE title='" . addslashes($book[1]) . "';"); if ($already) { $attr = @json_decode($already["attribs"], true); if (isset($attr["immateriel"])) { echo "ALREADY have book " . $book[1] . " at " . $book[0] . "\n"; continue; } } else { $attr = array(); } $return = curl_simple_get($book[0]); $lines = explode("\n", $return); // description between a <div></div> multiline $description = ""; $status = 0; $isbn = false;
} switch ($action) { case 1: case 2: case 3: $oc = intval($_REQUEST["oc"]); if ($oc) { $oc = 1; } else { $oc = 0; } if ($upload["status"] == $action) { $_REQUEST["error"] = _("Upload already moderated"); break; } $book = mqone("SELECT * FROM books WHERE id=" . $upload["book_id"] . ";"); if (!$book) { $_REQUEST["error"] = _("Book not found"); break; } mq("UPDATE uploads SET othercollection='{$oc}', datemoderated=NOW(), status=" . $action . " WHERE id=" . $id . ";"); $aformat = array(1 => "epub", 2 => "mobi", 3 => "pdf"); $attr = @json_decode($book["attribs"], true); $attr["formats"][$aformat[$action]] = array("name" => $id, "size" => filesize(UPLOAD_ROOT . "/" . $id), "othercollection" => $oc); mq("UPDATE books SET dateuploaded=NOW(), downloadable=1, attribs='" . addslashes(json_encode($attr)) . "' WHERE id=" . $book["id"] . ";"); $_REQUEST["msg"] = _("The upload has been validated"); break; case 99: mq("UPDATE uploads SET datemoderated=NOW(), status=" . $action . " WHERE id=" . $id . ";"); $_REQUEST["msg"] = _("The upload has been trashed"); break;
/** Receive a URL to enable a user account */ function enableAction() { global $view, $params; if (!isset($params[0])) { not_found(); } $id = intval($params[0]); $user = mqone("SELECT * FROM user WHERE id={$id};"); if (!$user) { not_found(); } mq("UPDATE user SET enabled=1 WHERE id={$id};"); $view["message"] = "The user has been enabled successfully"; $this->indexAction(); }
<?php require_once "common.php"; require_once "head.php"; require_once "menu.php"; require "messagebox.php"; if (!isset($_REQUEST["id"]) || !($id = intval($_REQUEST["id"]))) { require_once "nothing.php"; exit; } $book = mqone("SELECT * FROM books WHERE id={$id};"); if (!$book) { $_REQUEST["error"] = _("Book not found"); require_once "nothing.php"; exit; } ?> <div class="container-fluid main"> <div class="row"> <div class="span12"> <div style="float: right; padding: 10px;"> <a href="https://fr.wikipedia.org/wiki/Domaine_public_%28propri%C3%A9t%C3%A9_intellectuelle%29"><img src="/assets/img/pd.png"/></a> </div> <h1><?php __("Uploading an eBook"); ?> </h1>
<?php require_once "common.php"; if (!isset($_SESSION["id"]) || !$_SESSION["id"]) { $_REQUEST["error"] = _("You are not allowed to see this page, sorry."); require_once "nothing.php"; exit; } $id = intval($_REQUEST["id"]); $up = mqone("SELECT * FROM uploads WHERE id={$id};"); if (!$up) { $_REQUEST["error"] = _("Upload not found."); require_once "nothing.php"; } header("Cache-Control: no-cache, must-revalidate"); // HTTP/1.1 header("Expires: Sat, 26 Jul 1997 05:00:00 GMT"); // Date in the past header('Content-type: application/octet-stream'); header("Content-Length: " . filesize(UPLOAD_ROOT . "/" . $up["id"])); header('Content-Disposition: attachment; filename="' . str_replace('"', '', str_replace("'", "", $up["name"])) . '"'); readfile(UPLOAD_ROOT . "/" . $up["id"]);
<?php $lang = "en_US"; if ($view['lang'] == "fr") { $lang = "fr_FR"; } putenv("LC_MESSAGES=" . $lang); putenv("LANG=" . $lang); putenv("LANGUAGE=" . $lang); setlocale(LC_ALL, $lang); $view["campaign"] = mqone("SELECT * FROM campaign WHERE datestop >= NOW() ORDER BY datestop ASC;"); if ($view["campaign"]) { if (strcmp($view["orientation"], "horiz") == 0) { header("Location: /campaign/widget2/" . $view["campaign"]["slug"] . "/horiz"); exit; } header("Location: /campaign/widget2/" . $view["campaign"]["slug"]); exit; } ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" class="nojs"> <head> <meta http-equiv="content-type" content="text/html; charset=utf-8" /> <title><?php echo PROJECTNAME; ?> <?php if (isset($view["title"])) { echo " - " . $view["title"]; }
/** Display stats for a given campaign */ function statsAction() { global $view, $params; if (!isset($params[0])) { not_found(); } $id = intval($params[0]); $campaign = mqone("SELECT name FROM campaign WHERE id={$id};"); if (!$campaign) { not_found(); } $view["title"] = "Showing stats for campaign " . $campaign["name"]; $view["rawstats"] = mqlist("SELECT calls.*, CONCAT(lists.name, ' ', calls.callee) as callee2 FROM calls INNER JOIN lists ON calls.callee = lists.phone WHERE calls.campaign={$id} and lists.campaign={$id} ORDER BY datestart DESC"); $view["withuuid"] = array_filter($view["rawstats"], function ($a) { return $a["uuid"] != ""; }); $view["withfeedback"] = array_filter($view["rawstats"], function ($a) { return $a["feedback"] != ""; }); render("adminstats"); }
<?php require_once "common.php"; $error = ""; if (isset($_POST["login"]) && isset($_POST["password"])) { $me = false; $me = mqone("SELECT * FROM users WHERE `login`='" . addslashes($_POST["login"]) . "';"); if ($me) { print_r($me); if ($me["pass"] != crypt($_POST["password"], $me["pass"])) { $error = _("Incorrect username or password"); } else { mq("UPDATE users SET lastlogin=NOW() WHERE id=" . $me["id"] . ";"); $_SESSION["id"] = $me["id"]; $_SESSION["me"] = $me; session_write_close(); header("Location: /?msg=" . _("Welcome")); exit; } } else { $error = _("Incorrect username or password"); } } if ($error) { $_REQUEST["error"] = $error; } require_once "head.php"; require_once "menu.php"; require_once "messagebox.php"; ?> <div class="container-fluid main">
function check_user_identity() { if (!isset($_SERVER['PHP_AUTH_USER'])) { header('WWW-Authenticate: Basic realm="PiPhone Login"'); header('HTTP/1.0 401 Unauthorized'); echo 'Please authenticate'; exit; } $GLOBALS["me"] = mqone("SELECT * FROM user WHERE login='******'PHP_AUTH_USER']) . "' AND pass=PASSWORD('" . mquote($_SERVER['PHP_AUTH_PW']) . "') AND enabled=1;"); if (!$GLOBALS["me"]) { header('WWW-Authenticate: Basic realm="PiPhone Login"'); header('HTTP/1.0 401 Unauthorized'); echo 'Login or password incorrect, or account disabled'; exit; } // mq("UPDATE user SET lastlogin=NOW() WHERE id='".$GLOBALS["me"]["id"]."';"); }
// UPDATE // search for existing login : $already = mqone("SELECT * FROM users WHERE id!='" . intval($_POST["id"]) . "' AND login='******';"); if ($already) { $_REQUEST["error"] = _("This login is already used, please choose another one"); $_REQUEST["action"] = "edit"; } mq("UPDATE users SET firstname='" . addslashes($_POST["firstname"]) . "', lastname='" . addslashes($_POST["lastname"]) . "', login='******', email='" . addslashes($_POST["email"]) . "' WHERE id='" . intval($_POST["id"]) . "';"); $_REQUEST["msg"] = _("Account edited successfully"); $_REQUEST["action"] = ""; } break; case "docreate": // CREATE // search for existing login : $already = mqone("SELECT * FROM users WHERE login='******';"); if ($already) { $_REQUEST["error"] = _("This login is already used, please choose another one"); $_REQUEST["action"] = "create"; } else { $pass = mkpass(); mq("INSERT INTO users SET firstname='" . addslashes($_POST["firstname"]) . "', lastname='" . addslashes($_POST["lastname"]) . "', login='******', email='" . addslashes($_POST["email"]) . "', pass='******', role=0;"); // FIXME: set the default role // Send the new password to the user's email : mail($_POST["email"], sprintf(_("Account created on https://%s"), $_SERVER["HTTP_HOST"]), sprintf(_("Hello,\nYour new account has just been created on https://%s\nPlease go there to login and change your password.\nYour login is %s\nand your password is %s\n\nThanks\n"), $_SERVER["HTTP_HOST"], $_REQUEST["login"], $pass)); $_REQUEST["msg"] = _("Account created successfully"); $_REQUEST["action"] = ""; } break; } // SWITCH
// UPDATE // search for existing name : $already = mqone("SELECT * FROM collections WHERE id!='" . intval($_POST["id"]) . "' AND name='" . addslashes($_POST["name"]) . "';"); if ($already) { $_REQUEST["error"] = _("This collection is already used, please choose another one"); $_REQUEST["action"] = "edit"; } mq("UPDATE collections SET name='" . addslashes($_POST["name"]) . "' WHERE id='" . intval($_POST["id"]) . "';"); $_REQUEST["msg"] = _("Collection renamed successfully"); $_REQUEST["action"] = ""; } break; case "docreate": // CREATE // search for existing name : $already = mqone("SELECT * FROM collections WHERE name='" . addslashes($_POST["name"]) . "';"); if ($already) { $_REQUEST["error"] = _("This collection is already used, please choose another one"); $_REQUEST["action"] = "create"; } else { $pass = mkpass(); mq("INSERT INTO collections SET name='" . addslashes($_POST["name"]) . "';"); $_REQUEST["msg"] = _("Collection created successfully"); $_REQUEST["action"] = ""; } break; case "delete": // DELETE mq("DELETE FROM collections WHERE id='" . addslashes($_REQUEST["id"]) . "';"); mq("UPDATE books SET collection=0 WHERE collection='" . addslashes($_REQUEST["id"]) . "';"); $_REQUEST["msg"] = _("Collection deleted successfully");
function feedback2Action() { global $view, $params; // Check the campaign if (!isset($params[0])) { not_found(); } $slug = addslashes(trim($params[0])); $view["campaign"] = $this->_getCampaign($slug); // Exit in case of error // Check the call : if (!isset($params[1])) { not_found(); } $view["callid"] = $cid = intval($params[1]); $call = mqone("SELECT * FROM calls WHERE id='" . $view["callid"] . "';"); $callee = mqone("SELECT * FROM lists WHERE phone='(" . $call["callee"] . ")';"); if ($call["feedback"]) { $view["error"] = _("A feedback has already been given for that call, sorry"); $this->call2Action(); exit; } mq("UPDATE calls SET feedback='" . addslashes($_REQUEST["feedback"]) . "' WHERE id='" . $view["callid"] . "';"); mq("UPDATE lists SET callcount=callcount+1 WHERE id='" . $callee["id"] . "');"); $view["message"] = _("Your feedback has been sent to us, thanks for your participation! CALLID:"); render("campaigncall2"); }
/** Receive a POST to del a login account */ function dodelAction() { global $view; $id = intval($_REQUEST["id"]); $login = mqone("SELECT * FROM login WHERE id={$id};"); if (!$login) { not_found(); } mq("DELETE FROM login WHERE id={$id};"); $view["message"] = "The login has been deleted successfully"; $this->indexAction(); }