Exemplo n.º 1
0
function eoption($values, $cur, $info = "")
{
    if (is_array($values)) {
        foreach ($values as $k => $v) {
            echo "<option value=\"{$k}\"";
            if ($k == $cur) {
                echo " selected=\"selected\"";
            }
            echo ">" . $v . "</option>";
        }
    } else {
        if (is_array($info)) {
            $r = mqlist("SELECT " . $info[0] . ", " . $info[1] . " FROM {$values} ORDER BY " . $info[0] . ";");
        } else {
            $r = mqlist("SELECT * FROM {$values} ORDER BY 2;");
        }
        foreach ($r as $c) {
            echo "<option value=\"" . $c[0] . "\"";
            if ($c[0] == $cur) {
                echo " selected=\"selected\"";
            }
            echo ">" . sts($c[1]) . "</option>";
        }
    }
}
Exemplo n.º 2
0
 /** Get the details of the currently logged person */
 function indexAction()
 {
     global $view;
     if (isset($_SESSION["id"])) {
         $view["login"] = mqlist("SELECT user.* FROM user WHERE user.login='******';");
         $view["campaigns"] = mqlist("SELECT campaign.name, count(campaign.id) score FROM campaign, calls WHERE calls.uid=" . $_SESSION["id"]["id"] . " AND calls.campaign = campaign.id;");
         $view["calls"] = mqlist("SELECT lists.campaign, lists.name FROM lists, calls WHERE lists.phone = calls.callee AND calls.uid = " . $_SESSION["id"]["id"] . ";");
         render("logindetail");
     } else {
         render("loginregister");
     }
 }
Exemplo n.º 3
0
 /** Get the list of user accounts */
 function indexAction()
 {
     global $view;
     $view["user"] = mqlist("SELECT user.* FROM user ORDER BY user.login;");
     render("userlist");
 }
Exemplo n.º 4
0
 /** 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");
 }
Exemplo n.º 5
0
        $sql .= " AND downloadable = {$downloadable} ";
    }
}
if (isset($_REQUEST["q"])) {
    $q = explode(" ", $_REQUEST["q"]);
    foreach ($q as $word) {
        if (trim($word)) {
            $sql .= " AND (title LIKE '%" . addslashes($word) . "%' OR authors LIKE '%" . addslashes($word) . "%' OR ISBN='" . addslashes($word) . "' ) ";
        }
    }
}
// search 2 nice books to show in the last 5 uploaded, corresponding to this search ?
$catalog = array();
if ($showcatalog) {
    // We take 3 random books among the 5 latest uploads
    $c = mqlist("SELECT books.*, uploads.id AS uid FROM books LEFT JOIN uploads ON uploads.book_id=books.id AND uploads.status=0 WHERE downloadable=1 {$sql} ORDER BY dateuploaded DESC LIMIT 5;");
    if (count($c)) {
        $cat[] = rand(0, count($c) - 1);
        if (count($c) > 1) {
            do {
                $cat2 = rand(0, count($c) - 1);
            } while (in_array($cat2, $cat));
            $cat[] = $cat2;
        }
        if (count($c) > 2) {
            do {
                $cat2 = rand(0, count($c) - 1);
            } while (in_array($cat2, $cat));
            $cat[] = $cat2;
        }
        foreach ($cat as $cc) {
Exemplo n.º 6
0
 function hof2Action()
 {
     global $view, $params;
     if (!isset($params[0])) {
         // All star hall of fame
         $hof = mqlist("SELECT user.login, count(calls.id) score FROM calls, user WHERE calls.feedback IS NOT null AND calls.uid = user.id ORDER BY score LIMIT 10;");
         $view["hof"] = $hof;
         render("campaignhof2");
     } else {
         $slug = addslashes(trim($params[0]));
         $view["campaign"] = $this->_getCampaign($slug);
         // Exit in case of error
         $view["countries"] = $this->_getCampaignCountries($view["campaign"]["id"]);
         $view["lang"] = substr($GLOBALS["lang"], 0, 2);
         // Get the 10 best scores
         $hof = mqlist("SELECT user.login, count(calls.id) score FROM calls, user WHERE calls.feedback IS NOT null AND calls.uid = user.id AND calls.campaign = " . $view["campaign"]["id"] . " ORDER BY score LIMIT 10;");
         $view["hof"] = $hof;
         render("campaignhof2");
     }
 }
Exemplo n.º 7
0
 /** show the active campaigns */
 function indexAction()
 {
     global $view;
     $view["campaign"] = mqlist("SELECT * FROM campaign WHERE datestart<=NOW() AND datestop>=NOW() AND enabled=1 ORDER BY datestart DESC;");
     render("index");
 }