Exemplo n.º 1
0
function set_path_variables()
{
    global $ConfSitePATH, $ConfSiteBase, $ConfSiteSuffix;
    if (!@$ConfSitePATH) {
        $ConfSitePATH = substr(__FILE__, 0, strrpos(__FILE__, "/"));
        while ($ConfSitePATH !== "" && !file_exists("{$ConfSitePATH}/src/init.php")) {
            $ConfSitePATH = substr($ConfSitePATH, 0, strrpos($ConfSitePATH, "/"));
        }
        if ($ConfSitePATH === "") {
            $ConfSitePATH = "/var/www/html";
        }
    }
    require_once "{$ConfSitePATH}/lib/navigation.php";
    if (@$ConfSiteBase === null) {
        $ConfSiteBase = Navigation::siteurl();
    }
    if (@$ConfSiteSuffix === null) {
        $ConfSiteSuffix = Navigation::php_suffix();
    }
}
Exemplo n.º 2
0
 public function table_html($listname, $options = array())
 {
     global $Conf;
     if (!$this->_prepare()) {
         return null;
     }
     if (isset($options["fold"])) {
         foreach ($options["fold"] as $n => $v) {
             $this->viewmap->{$n} = $v;
         }
     }
     if (isset($options["table_id"])) {
         $this->viewmap->table_id = $options["table_id"];
     }
     // need tags for row coloring
     if ($this->contact->can_view_tags(null)) {
         $this->qopts["tags"] = 1;
     }
     $this->table_type = $listname;
     // get column list, check sort
     $field_list = $this->_list_columns($listname);
     if (!$field_list) {
         Conf::msg_error("There is no paper list query named “" . htmlspecialchars($listname) . "”.");
         return null;
     }
     $field_list = $this->_columns($field_list, true);
     $body_attr = $this->row_attr;
     $rows = $this->_rows($field_list);
     if ($rows === null) {
         return null;
     }
     // return IDs if requested
     if (empty($rows)) {
         if ($altq = $this->search->alternate_query()) {
             $altqh = htmlspecialchars($altq);
             $url = $this->search->url_site_relative_raw($altq);
             if (substr($url, 0, 5) == "search") {
                 $altqh = "<a href=\"" . htmlspecialchars(Navigation::siteurl() . $url) . "\">" . $altqh . "</a>";
             }
             return "No matching papers. Did you mean “{$altqh}”?";
         } else {
             return "No matching papers";
         }
     }
     // get field array
     $fieldDef = array();
     $ncol = $titlecol = 0;
     // folds: au:1, anonau:2, fullrow:3, aufull:4, force:5, rownum:6, [fields]
     $next_fold = 7;
     foreach ($field_list as $fdef) {
         if ($fdef->view != Column::VIEW_NONE) {
             $fieldDef[] = $fdef;
         }
         if ($fdef->view != Column::VIEW_NONE && $fdef->foldable) {
             $fdef->foldable = $next_fold;
             ++$next_fold;
         }
         if ($fdef->name == "title") {
             $titlecol = $ncol;
         }
         if ($fdef->view == Column::VIEW_COLUMN && !$fdef->is_folded) {
             ++$ncol;
         }
     }
     // count non-callout columns
     $skipcallout = 0;
     foreach ($fieldDef as $fdef) {
         if ($fdef->name != "id" && !isset($fdef->is_selector)) {
             break;
         } else {
             ++$skipcallout;
         }
     }
     // create render state
     $rstate = new PaperListRenderState($ncol, $titlecol, $skipcallout);
     // collect row data
     $body = array();
     $lastheading = !empty($this->search->groupmap) ? -1 : -2;
     $need_render = false;
     foreach ($rows as $row) {
         ++$this->count;
         if ($lastheading > -2) {
             $lastheading = $this->_check_heading($this->_row_thenval($row), $rstate, $rows, $lastheading, $body);
         }
         $body[] = $this->_row_text($rstate, $row, $fieldDef);
         if ($this->need_render && !$need_render) {
             $Conf->footerScript('$(plinfo.render_needed)', 'plist_render_needed');
             $need_render = true;
         }
         if ($this->need_render && $this->count % 16 == 15) {
             $body[count($body) - 1] .= "  <script>plinfo.render_needed()</script>\n";
             $this->need_render = false;
         }
     }
     if ($lastheading > -2 && $this->search->is_order_anno) {
         while ($lastheading + 1 < count($this->search->groupmap)) {
             $lastheading = $this->_check_heading($lastheading + 1, $rstate, $rows, $lastheading, $body);
         }
     }
     // header cells
     $colhead = "";
     $url = $this->search->url_site_relative_raw();
     if (!defval($options, "noheader")) {
         $colhead .= " <thead class=\"pltable\">\n  <tr class=\"pl_headrow\">";
         $ord = 0;
         $titleextra = $this->_make_title_header_extra($rstate, $fieldDef, get($options, "header_links"));
         foreach ($fieldDef as $fdef) {
             if ($fdef->view != Column::VIEW_COLUMN || $fdef->is_folded) {
                 continue;
             }
             $colhead .= "<th class=\"pl " . $fdef->className;
             if ($fdef->foldable) {
                 $colhead .= " fx" . $fdef->foldable;
             }
             $colhead .= "\">";
             if ($fdef->has_content) {
                 $colhead .= $this->_field_title($fdef, $ord);
             }
             if ($titleextra && $fdef->className == "pl_title") {
                 $colhead .= $titleextra;
                 $titleextra = false;
             }
             $colhead .= "</th>";
             ++$ord;
         }
         $colhead .= "</tr>\n";
         if ($this->search->is_order_anno) {
             $colhead .= "  <tr class=\"pl_headrow pl_annorow\" data-anno-tag=\"{$this->search->is_order_anno}\">";
             if ($rstate->titlecol) {
                 $colhead .= "<td colspan=\"{$rstate->titlecol}\"></td>";
             }
             $colhead .= "<td colspan=\"" . ($rstate->ncol - $rstate->titlecol) . "\"><a href=\"#\" onclick=\"return plinfo_tags.edit_anno(this)\">Annotate order</a></td></tr>\n";
         }
         $colhead .= " </thead>\n";
     }
     // table skeleton including fold classes
     $foldclasses = array();
     if ($this->foldable) {
         $foldclasses = $this->_analyze_folds($rstate, $fieldDef);
     }
     $enter = "";
     if (self::$include_stash) {
         $enter .= Ht::take_stash();
     }
     $enter .= "<table class=\"pltable plt_" . htmlspecialchars($listname);
     if (defval($options, "class")) {
         $enter .= " " . $options["class"];
     }
     if ($this->listNumber) {
         $enter .= " has_hotcrp_list";
     }
     if (!empty($foldclasses)) {
         $enter .= " " . join(" ", $foldclasses);
     }
     if ($this->viewmap->table_id) {
         $enter .= "\" id=\"" . $this->viewmap->table_id;
     }
     if (defval($options, "attributes")) {
         foreach ($options["attributes"] as $n => $v) {
             $enter .= "\" {$n}=\"" . htmlspecialchars($v);
         }
     }
     if ($this->search->is_order_anno) {
         $enter .= "\" data-order-tag=\"{$this->search->is_order_anno}";
     }
     foreach ($body_attr as $k => $v) {
         $enter .= "\" {$k}=\"" . htmlspecialchars($v);
     }
     if ($this->listNumber) {
         $enter .= '" data-hotcrp-list="' . $this->listNumber;
     }
     $enter .= "\" data-fold=\"true\">\n";
     $exit = "</table>";
     // maybe make columns, maybe not
     $tbody_class = "pltable";
     if ($this->viewmap->columns && !empty($rstate->ids) && $this->_column_split($rstate, $colhead, $body)) {
         $enter = '<div class="plsplit_col_ctr_ctr"><div class="plsplit_col_ctr">' . $enter;
         $exit = $exit . "</div></div>";
         $ncol = $rstate->split_ncol;
         $tbody_class = "pltable_split";
     } else {
         $enter .= $colhead;
         $tbody_class .= $rstate->hascolors ? " pltable_colored" : "";
     }
     // footer
     $foot = "";
     if ($this->viewmap->statistics && !$this->viewmap->columns) {
         $foot .= $this->_statistics_rows($rstate, $fieldDef);
     }
     if ($fieldDef[0] instanceof SelectorPaperColumn && !defval($options, "nofooter")) {
         $foot .= $this->_footer($ncol, get_s($options, "footer_extra"));
     }
     if ($foot) {
         $enter .= ' <tfoot' . ($rstate->hascolors ? ' class="pltable_colored"' : "") . ">\n" . $foot . " </tfoot>\n";
     }
     // body
     $enter .= " <tbody class=\"{$tbody_class}\">\n";
     // header scripts to set up delegations
     if ($this->_header_script) {
         $enter .= '  <script>' . $this->_header_script . "</script>\n";
     }
     // session variable to remember the list
     if ($this->listNumber) {
         $sl = $this->search->create_session_list_object($rstate->ids, self::_listDescription($listname), $this->sortdef());
         if (isset($this->qreq->sort)) {
             $url .= (strpos($url, "?") ? "&" : "?") . "sort=" . urlencode($this->qreq->sort);
         }
         $sl->url = $url;
         if (get($options, "list_properties")) {
             foreach ($options["list_properties"] as $k => $v) {
                 $sl->{$k} = $v;
             }
         }
         SessionList::change($this->listNumber, $sl);
     }
     foreach ($fieldDef as $fdef) {
         if ($fdef->has_content) {
             $this->any[$fdef->name] = true;
         }
     }
     if ($rstate->has_openau) {
         $this->any->openau = true;
     }
     if ($rstate->has_anonau) {
         $this->any->anonau = true;
     }
     $this->ids = $rstate->ids;
     return $enter . join("", $body) . " </tbody>\n" . $exit;
 }
Exemplo n.º 3
0
function quicklinks($id, $baseUrl, $args, $listtype)
{
    global $Me, $Conf;
    $list = SessionList::active($listtype, $id);
    if (!$list) {
        return "";
    }
    $args["ls"] = null;
    $x = '<td class="quicklinks nw has_hotcrp_list" data-hotcrp-list="' . $list->listno . '">';
    if ($list->id_position > 0) {
        $x .= _one_quicklink($list->ids[$list->id_position - 1], $baseUrl, $args, $listtype, true);
    }
    if (@$list->description) {
        $x .= $list->id_position > 0 ? "&nbsp;&nbsp;" : "";
        if (@$list->url) {
            $x .= '<a id="quicklink_list" class="x" href="' . htmlspecialchars(Navigation::siteurl() . $list->url) . "\">" . $list->description . "</a>";
        } else {
            $x .= '<span id="quicklink_list">' . $list->description . '</span>';
        }
    }
    if (isset($list->ids[$list->id_position + 1])) {
        $x .= $list->id_position > 0 || @$list->description ? "&nbsp;&nbsp;" : "";
        $x .= _one_quicklink($list->ids[$list->id_position + 1], $baseUrl, $args, $listtype, false);
    }
    return $x . '</td>';
}
Exemplo n.º 4
0
function hoturl_image($page)
{
    return Navigation::siteurl() . $page;
}
Exemplo n.º 5
0
 function header($title, $id, $actionBar, $title_div = null)
 {
     global $ConfSitePATH, $Me, $Now, $Opt;
     if ($this->headerPrinted) {
         return;
     }
     // <head>
     if ($title === "Home") {
         $title = "";
     }
     $this->header_head($title);
     // <body>
     $body_class = "";
     if ($id === "paper_view" || $id === "paper_edit" || $id === "review" || $id === "assign") {
         $body_class = "paper";
     }
     echo "<body";
     if ($id) {
         echo ' id="', $id, '"';
     }
     if ($body_class) {
         echo ' class="', $body_class, '"';
     }
     echo ">\n";
     // initial load (JS's timezone offsets are negative of PHP's)
     Ht::stash_script("hotcrp_load.time(" . -date("Z", $Now) / 60 . "," . (get($Opt, "time24hour") ? 1 : 0) . ")");
     // deadlines settings
     if ($Me) {
         Ht::stash_script("hotcrp_deadlines.init(" . json_encode($Me->my_deadlines($this->paper)) . ")");
     }
     if (self::$gDefaultFormat) {
         Ht::stash_script("render_text.set_default_format(" . self::$gDefaultFormat . ")");
     }
     // meeting tracker
     $trackerowner = ($trackerstate = $this->setting_json("tracker")) && $trackerstate->trackerid && $trackerstate->sessionid == session_id();
     if ($trackerowner) {
         Ht::stash_script("hotcrp_deadlines.tracker(0)");
     }
     echo '<div id="prebody"><div id="header">';
     // $header_site
     $is_home = $id === "home";
     $site_div = '<div id="header_site" class="header_site_logo ' . ($is_home ? "header_site_home" : "header_site_page") . '"><h1><a class="qq" href="' . hoturl("index") . '">' . htmlspecialchars($Opt["shortName"]);
     if (!$is_home) {
         $site_div .= ' <span style="font-weight:normal">Home</span>';
     }
     $site_div .= '</a></h1></div>';
     // $header_profile
     $profile_html = "";
     if ($Me && !$Me->is_empty()) {
         // profile link
         $xsep = ' <span class="barsep">·</span> ';
         if ($Me->has_email()) {
             $profile_html .= '<a class="q" href="' . hoturl("profile") . '"><strong>' . htmlspecialchars($Me->email) . '</strong></a> &nbsp; <a href="' . hoturl("profile") . '">Profile</a>' . $xsep;
         }
         // "act as" link
         if (($actas = get($_SESSION, "last_actas")) && get($_SESSION, "trueuser") && ($Me->privChair || Contact::$trueuser_privChair === $Me)) {
             // Link becomes true user if not currently chair.
             if (!$Me->privChair || strcasecmp($Me->email, $actas) == 0) {
                 $actas = $_SESSION["trueuser"]->email;
             }
             if (strcasecmp($Me->email, $actas) != 0) {
                 $profile_html .= "<a href=\"" . selfHref(array("actas" => $actas)) . "\">" . ($Me->privChair ? htmlspecialchars($actas) : "Admin") . "&nbsp;" . Ht::img("viewas.png", "Act as " . htmlspecialchars($actas)) . "</a>" . $xsep;
             }
         }
         // help, sign out
         $x = $id == "search" ? "t={$id}" : ($id == "settings" ? "t=chair" : "");
         $profile_html .= '<a href="' . hoturl("help", $x) . '">Help</a>';
         if (!$Me->has_email() && !isset($Opt["httpAuthLogin"])) {
             $profile_html .= $xsep . '<a href="' . hoturl("index", "signin=1") . '">Sign&nbsp;in</a>';
         }
         if (!$Me->is_empty() || isset($Opt["httpAuthLogin"])) {
             $profile_html .= $xsep . '<a href="' . hoturl_post("index", "signout=1") . '">Sign&nbsp;out</a>';
         }
     }
     if (!$title_div && $title) {
         $title_div = '<div id="header_page"><h1>' . $title . '</h1></div>';
     }
     if (!$title_div && $actionBar) {
         $title_div = '<hr class="c" />';
     }
     $renderf = get($Opt, "headerRenderer");
     if (!$renderf) {
         $renderf = "Conf::echo_header";
     }
     if (is_array($renderf)) {
         require_once $renderf[0];
         $renderf = $renderf[1];
     }
     call_user_func($renderf, $this, $is_home, $site_div, $title_div, $profile_html, $actionBar);
     echo "  <hr class=\"c\" /></div>\n";
     echo "<div id=\"initialmsgs\">\n";
     if (get($Opt, "maintenance")) {
         echo "<div class=\"merror\"><strong>The site is down for maintenance.</strong> ", is_string($Opt["maintenance"]) ? $Opt["maintenance"] : "Please check back later.", "</div>";
     }
     $this->save_messages = false;
     if (($msgs = $this->session("msgs")) && count($msgs)) {
         $this->save_session("msgs", null);
         foreach ($msgs as $m) {
             $this->msg($m[0], $m[1]);
         }
     }
     echo "</div>\n";
     $this->headerPrinted = true;
     echo "</div>\n<div id=\"body\" class=\"body\">\n";
     // If browser owns tracker, send it the script immediately
     if ($trackerowner) {
         $this->echoScript();
     }
     // Callback for version warnings
     if ($Me && $Me->privChair && (!isset($_SESSION["updatecheck"]) || $_SESSION["updatecheck"] + 20 <= $Now) && (!isset($Opt["updatesSite"]) || $Opt["updatesSite"])) {
         $m = defval($Opt, "updatesSite", "//hotcrp.lcdf.org/updates");
         $m .= (strpos($m, "?") === false ? "?" : "&") . "addr=" . urlencode($_SERVER["SERVER_ADDR"]) . "&base=" . urlencode(Navigation::siteurl()) . "&version=" . HOTCRP_VERSION;
         $v = HOTCRP_VERSION;
         if (is_dir("{$ConfSitePATH}/.git")) {
             $args = array();
             exec("export GIT_DIR=" . escapeshellarg($ConfSitePATH) . "/.git; git rev-parse HEAD 2>/dev/null; git merge-base origin/master HEAD 2>/dev/null", $args);
             if (count($args) >= 1) {
                 $m .= "&git-head=" . urlencode($args[0]);
                 $v .= " " . $args[0];
             }
             if (count($args) >= 2) {
                 $m .= "&git-upstream=" . urlencode($args[1]);
                 $v .= " " . $args[1];
             }
         }
         Ht::stash_script("check_version(\"{$m}\",\"{$v}\")");
         $_SESSION["updatecheck"] = $Now;
     }
 }
Exemplo n.º 6
0
 private function header_head($title)
 {
     global $Me, $ConfSitePATH, $CurrentList;
     echo "<!DOCTYPE html>\n<html lang=\"en\">\n<head>\n<meta http-equiv=\"Content-Type\" content=\"text/html; charset=utf-8\" />\n<meta http-equiv=\"Content-Style-Type\" content=\"text/css\" />\n<meta http-equiv=\"Content-Script-Type\" content=\"text/javascript\" />\n<meta http-equiv=\"Content-Language\" content=\"en\" />\n<meta name=\"google\" content=\"notranslate\" />\n";
     if (strstr($title, "<") !== false) {
         $title = preg_replace("/<([^>\"']|'[^']*'|\"[^\"]*\")*>/", "", $title);
     }
     echo $this->opt("fontScript", "");
     echo $this->make_css_link("stylesheets/style.css"), "\n";
     if ($this->opt("mobileStylesheet")) {
         echo '<meta name="viewport" content="width=device-width, initial-scale=1">', "\n";
         echo $this->make_css_link("stylesheets/mobile.css", "screen and (max-width: 768px)"), "\n";
     }
     foreach (mkarray($this->opt("stylesheets", [])) as $css) {
         echo $this->make_css_link($css), "\n";
     }
     // favicon
     $favicon = $this->opt("favicon");
     if ($favicon) {
         if (strpos($favicon, "://") === false && $favicon[0] != "/") {
             if ($this->opt["assetsUrl"] && substr($favicon, 0, 7) === "images/") {
                 $favicon = $this->opt["assetsUrl"] . $favicon;
             } else {
                 $favicon = Navigation::siteurl() . $favicon;
             }
         }
         if (substr($favicon, -4) == ".png") {
             echo "<link rel=\"icon\" type=\"image/png\" href=\"{$favicon}\" />\n";
         } else {
             if (substr($favicon, -4) == ".ico") {
                 echo "<link rel=\"shortcut icon\" href=\"{$favicon}\" />\n";
             } else {
                 if (substr($favicon, -4) == ".gif") {
                     echo "<link rel=\"icon\" type=\"image/gif\" href=\"{$favicon}\" />\n";
                 } else {
                     echo "<link rel=\"icon\" href=\"{$favicon}\" />\n";
                 }
             }
         }
     }
     // jQuery
     if (isset($this->opt["jqueryUrl"])) {
         $jquery = $this->opt["jqueryUrl"];
     } else {
         if ($this->opt("jqueryCdn")) {
             $jquery = "//code.jquery.com/jquery-1.12.3.min.js";
         } else {
             $jquery = "scripts/jquery-1.12.3.min.js";
         }
     }
     Ht::stash_html($this->make_script_file($jquery, true) . "\n");
     Ht::stash_html($this->make_script_file("scripts/jquery.color-2.1.2.min.js", true) . "\n");
     Ht::stash_html($this->make_script_file("scripts/jquery.flot.min.js", true) . "\n");
     //Ht::stash_html($this->make_script_file("scripts/ZeroClipboard.min.js", true) . "\n");
     // Javascript settings to set before script.js
     Ht::stash_script("siteurl=" . json_encode(Navigation::siteurl()) . ";siteurl_suffix=\"" . Navigation::php_suffix() . "\"");
     if (session_id() !== "") {
         Ht::stash_script("siteurl_postvalue=\"" . post_value() . "\"");
     }
     if (@$CurrentList && ($list = SessionList::lookup($CurrentList))) {
         Ht::stash_script("hotcrp_list={num:{$CurrentList},id:\"" . addcslashes($list->listid, "\n\r\\\"/") . "\"}");
     }
     if ($urldefaults = hoturl_defaults()) {
         Ht::stash_script("siteurl_defaults=" . json_encode($urldefaults) . ";");
     }
     Ht::stash_script("assetsurl=" . json_encode($this->opt["assetsUrl"]) . ";");
     $huser = (object) array();
     if ($Me && $Me->email) {
         $huser->email = $Me->email;
     }
     if ($Me && $Me->is_pclike()) {
         $huser->is_pclike = true;
     }
     Ht::stash_script("hotcrp_user="******"ZeroClipboard.setDefaults({moviePath:\"" . Navigation::siteurl() . "cacheable" . Navigation::php_suffix() . "?file=scripts/ZeroClipboard.swf&amp;mtime=" . filemtime("$ConfSitePATH/scripts/ZeroClipboard.swf") . "\"})");
     // script.js
     if (!$this->opt("noDefaultScript")) {
         Ht::stash_html($this->make_script_file("scripts/script.js") . "\n");
     }
     echo Ht::unstash();
     echo "<title>";
     if ($title) {
         echo $title, " - ";
     }
     echo htmlspecialchars($this->short_name), "</title>\n</head>\n";
 }