コード例 #1
0
 public static function parse_sorter($text)
 {
     // parse the sorter
     $text = simplify_whitespace($text);
     if (preg_match('/\\A(\\d+)([a-z]*)\\z/i', $text, $m) || preg_match('/\\A([^-,+#]+)[,+#]([a-z]*)\\z/i', $text, $m)) {
         $sort = new ListSorter($m[1]);
         foreach (str_split(strtoupper($m[2])) as $x) {
             if ($x === "R" || $x === "N") {
                 $sort->reverse = $x === "R";
             } else {
                 if ($x === "M") {
                     $sort->score = "C";
                 } else {
                     if (isset(self::$score_sorts[$x])) {
                         $sort->score = $x;
                     }
                 }
             }
         }
     } else {
         $sort = PaperSearch::parse_sorter($text);
     }
     if ($sort->score === null) {
         $sort->score = self::default_score_sort();
     }
     return $sort;
 }
コード例 #2
0
function saveTagIndexes($tag, $filename, &$settings, &$titles, &$linenos, &$errors)
{
    global $Conf, $Me, $Error;
    $result = $Conf->qe($Conf->paperQuery($Me, array("paperId" => array_keys($settings))));
    while ($row = PaperInfo::fetch($result, $Me)) {
        if ($settings[$row->paperId] !== null && !$Me->can_change_tag($row, $tag, null, 1)) {
            $errors[$linenos[$row->paperId]] = "You cannot rank paper #{$row->paperId}.";
            unset($settings[$row->paperId]);
        } else {
            if ($titles[$row->paperId] !== "" && strcmp($row->title, $titles[$row->paperId]) != 0 && strcasecmp($row->title, simplify_whitespace($titles[$row->paperId])) != 0) {
                $errors[$linenos[$row->paperId]] = "Warning: Title doesn’t match";
            }
        }
    }
    if (!$tag) {
        defappend($Error["tags"], "No tag defined");
    } else {
        if (count($settings)) {
            $x = array("paper,tag,lineno");
            foreach ($settings as $pid => $value) {
                $x[] = "{$pid},{$tag}#" . ($value === null ? "clear" : $value) . "," . $linenos[$pid];
            }
            $assigner = new AssignmentSet($Me);
            $assigner->parse(join("\n", $x) . "\n", $filename);
            $assigner->report_errors();
            $assigner->execute();
        }
    }
    $settings = $titles = $linenos = array();
}
コード例 #3
0
 public function __construct($fx, $fy)
 {
     $fx = simplify_whitespace($fx);
     $fy = simplify_whitespace($fy);
     if (strcasecmp($fx, "query") == 0 || strcasecmp($fx, "search") == 0) {
         $this->fx = new Formula("0", true);
         $this->fx_query = true;
     } else {
         $this->fx = new Formula($fx, true);
     }
     if (strcasecmp($fy, "cdf") == 0) {
         $this->type = self::CDF;
         $this->fy = new Formula("0", true);
     } else {
         if (preg_match('/\\A(?:count|bar|bars|barchart)\\z/i', $fy)) {
             $this->type = self::BARCHART;
             $this->fy = new Formula("sum(1)", true);
         } else {
             if (preg_match('/\\A(?:stack|frac|fraction)\\z/i', $fy)) {
                 $this->type = self::FBARCHART;
                 $this->fy = new Formula("sum(1)", true);
             } else {
                 if (preg_match('/\\A(?:box|boxplot)\\s+(.*)\\z/i', $fy, $m)) {
                     $this->type = self::BOXPLOT;
                     $fy = $m[1];
                 } else {
                     if (preg_match('/\\Abars?\\s+(.+)\\z/i', $fy, $m)) {
                         $this->type = self::BARCHART;
                         $fy = $m[1];
                     } else {
                         if (preg_match('/\\Ascatter\\s+(.+)\\z/i', $fy, $m)) {
                             $this->type = self::SCATTER;
                             $fy = $m[1];
                         }
                     }
                 }
                 $this->fy = new Formula($fy, true);
                 if (!$this->type) {
                     $this->type = $this->fy->datatypes() ? self::SCATTER : self::BARCHART;
                 }
             }
         }
     }
     if ($this->fx->error_html()) {
         $this->error_html[] = "X axis formula: " . $this->fx->error_html();
         $this->errf["fx"] = true;
     }
     if ($this->fy->error_html()) {
         $this->error_html[] = "Y axis formula: " . $this->fy->error_html();
         $this->errf["fy"] = true;
     } else {
         if ($this->type & self::BARCHART && !$this->fy->can_combine()) {
             $this->error_html[] = "Y axis formula “" . htmlspecialchars($fy) . "” is unsuitable for bar charts, use an aggregate function like “sum(" . htmlspecialchars($fy) . ")”.";
             $this->errf["fy"] = true;
             $this->fy = new Formula("sum(0)", true);
         }
     }
 }
コード例 #4
0
ファイル: dbl.php プロジェクト: benesch/peteramati
 private static function query_args($args, $flags, $log_location)
 {
     $argpos = is_string($args[0]) ? 0 : 1;
     $dblink = $argpos ? $args[0] : self::$default_dblink;
     if ($flags & self::F_RAW && count($args) != $argpos + 1 || $flags & self::F_APPLY && count($args) > $argpos + 2) {
         trigger_error(caller_landmark(1, "/^Dbl::/") . ": wrong number of arguments");
     } else {
         if ($flags & self::F_APPLY && @$args[$argpos + 1] && !is_array($args[$argpos + 1])) {
             trigger_error(caller_landmark(1, "/^Dbl::/") . ": argument is not array");
         }
     }
     if ($log_location && self::$log_queries !== false) {
         $location = caller_landmark(1, "/^Dbl::/");
         if (!@self::$log_queries[$location]) {
             self::$log_queries[$location] = array(substr(simplify_whitespace($args[$argpos]), 0, 80), 0);
         }
         ++self::$log_queries[$location][1];
     }
     if (count($args) === $argpos + 1) {
         return array($dblink, $args[$argpos], array());
     } else {
         if ($flags & self::F_APPLY) {
             return array($dblink, $args[$argpos], $args[$argpos + 1]);
         } else {
             return array($dblink, $args[$argpos], array_slice($args, $argpos + 1));
         }
     }
 }
コード例 #5
0
ファイル: adminhome.php プロジェクト: benesch/peteramati
function admin_home_messages()
{
    global $Opt, $Conf;
    $m = array();
    $errmarker = "<span class=\"error\">Error:</span> ";
    if (preg_match("/^(?:[1-4]\\.|5\\.[012])/", phpversion())) {
        $m[] = $errmarker . "HotCRP requires PHP version 5.3 or higher.  You are running PHP version " . htmlspecialchars(phpversion()) . ".";
    }
    if (get_magic_quotes_gpc()) {
        $m[] = $errmarker . "The PHP <code>magic_quotes_gpc</code> feature is on, which is a bad idea.  Check that your Web server is using HotCRP’s <code>.htaccess</code> file.  You may also want to disable <code>magic_quotes_gpc</code> in your <code>php.ini</code> configuration file.";
    }
    if (get_magic_quotes_runtime()) {
        $m[] = $errmarker . "The PHP <code>magic_quotes_runtime</code> feature is on, which is a bad idea.  Check that your Web server is using HotCRP’s <code>.htaccess</code> file.  You may also want to disable <code>magic_quotes_runtime</code> in your <code>php.ini</code> configuration file.";
    }
    if (defined("JSON_HOTCRP")) {
        $m[] = "Your PHP was built without JSON functionality. HotCRP is using its built-in replacements; the native functions would be faster.";
    }
    if ((int) $Opt["globalSessionLifetime"] < $Opt["sessionLifetime"]) {
        $m[] = "PHP’s systemwide <code>session.gc_maxlifetime</code> setting, which is " . htmlspecialchars($Opt["globalSessionLifetime"]) . " seconds, is less than HotCRP’s preferred session expiration time, which is " . $Opt["sessionLifetime"] . " seconds.  You should update <code>session.gc_maxlifetime</code> in the <code>php.ini</code> file or users may be booted off the system earlier than you expect.";
    }
    if (!function_exists("imagecreate")) {
        $m[] = $errmarker . "This PHP installation lacks support for the GD library, so HotCRP cannot generate score charts (as backup for browsers that don’t support &lt;canvas&gt;). You should update your PHP installation. For example, on Ubuntu Linux, install the <code>php5-gd</code> package.";
    }
    $result = $Conf->qx("show variables like 'max_allowed_packet'");
    $max_file_size = ini_get_bytes("upload_max_filesize");
    if (($row = edb_row($result)) && $row[1] < $max_file_size && !@$Opt["dbNoPapers"]) {
        $m[] = $errmarker . "MySQL’s <code>max_allowed_packet</code> setting, which is " . htmlspecialchars($row[1]) . "&nbsp;bytes, is less than the PHP upload file limit, which is {$max_file_size}&nbsp;bytes.  You should update <code>max_allowed_packet</code> in the system-wide <code>my.cnf</code> file or the system may not be able to handle large papers.";
    }
    // Conference names
    if (@$Opt["shortNameDefaulted"]) {
        $m[] = "<a href=\"" . hoturl("settings", "group=msg") . "\">Set the conference abbreviation</a> to a short name for your conference, such as “OSDI ’14”.";
    } else {
        if (simplify_whitespace($Opt["shortName"]) != $Opt["shortName"]) {
            $m[] = "The <a href=\"" . hoturl("settings", "group=msg") . "\">conference abbreviation</a> setting has a funny value. To fix it, remove leading and trailing spaces, use only space characters (no tabs or newlines), and make sure words are separated by single spaces (never two or more).";
        }
    }
    $site_contact = Contact::site_contact();
    if (!$site_contact->email || $site_contact->email == "*****@*****.**") {
        $m[] = "<a href=\"" . hoturl("settings", "group=msg") . "\">Set the conference contact’s name and email</a> so submitters can reach someone if things go wrong.";
    }
    // Backwards compatibility
    if (@$Conf->setting_data("clickthrough_submit")) {
        // delete 12/2014
        $m[] = "You need to recreate the <a href=\"" . hoturl("settings", "group=msg") . "\">clickthrough submission terms</a>.";
    }
    // Weird URLs?
    foreach (array("conferenceSite", "paperSite") as $k) {
        if (isset($Opt[$k]) && $Opt[$k] && !preg_match('`\\Ahttps?://(?:[-.~\\w:/?#\\[\\]@!$&\'()*+,;=]|%[0-9a-fA-F][0-9a-fA-F])*\\z`', $Opt[$k])) {
            $m[] = $errmarker . "The <code>\$Opt[\"{$k}\"]</code> setting, ‘<code>" . htmlspecialchars($Opt[$k]) . "</code>’, is not a valid URL.  Edit the <code>conf/options.php</code> file to fix this problem.";
        }
    }
    // Double-encoding bugs found?
    if ($Conf->setting("bug_doubleencoding")) {
        $m[] = "Double-encoded URLs have been detected. Incorrect uses of Apache’s <code>mod_rewrite</code>, and other middleware, can encode URL parameters twice. This can cause problems, for instance when users log in via links in email. (“<code>a@b.com</code>” should be encoded as “<code>a%40b.com</code>”; a double encoding will produce “<code>a%2540b.com</code>”.) HotCRP has tried to compensate, but you really should fix the problem. For <code>mod_rewrite</code> add <a href='http://httpd.apache.org/docs/current/mod/mod_rewrite.html'>the <code>[NE]</code> option</a> to the relevant RewriteRule. <a href=\"" . hoturl_post("index", "clearbug=doubleencoding") . "\">(Clear&nbsp;this&nbsp;message)</a>";
    }
    // Unnotified reviews?
    if ($Conf->setting("pcrev_assigntime", 0) > $Conf->setting("pcrev_informtime", 0)) {
        $assigntime = $Conf->setting("pcrev_assigntime");
        $result = $Conf->qe("select paperId from PaperReview where reviewType>" . REVIEW_PC . " and timeRequested>timeRequestNotified and reviewSubmitted is null and reviewNeedsSubmit!=0 limit 1");
        if (edb_nrows($result)) {
            $m[] = "PC review assignments have changed. You may want to <a href=\"" . hoturl("mail", "template=newpcrev") . "\">send mail about the new assignments</a>. <a href=\"" . hoturl_post("index", "clearnewpcrev={$assigntime}") . "\">(Clear&nbsp;this&nbsp;message)</a>";
        } else {
            $Conf->save_setting("pcrev_informtime", $assigntime);
        }
    }
    if (count($m)) {
        $Conf->warnMsg("<div>" . join('</div><div style="margin-top:0.5em">', $m) . "</div>");
    }
}
コード例 #6
0
 public function compile_combine_functions(Contact $contact)
 {
     $this->check();
     $state = new FormulaCompiler($contact);
     $this->_parse && $this->_parse->compile_fragments($state);
     $t = self::compile_body($contact, $state, null);
     if (count($state->fragments) == 1) {
         $t .= "  return " . $state->fragments[0] . ";\n";
     } else {
         $t .= "  return [" . join(", ", $state->fragments) . "];\n";
     }
     $args = '$prow, $rrow_cid, $contact, $format = 0, $forceShow = false';
     self::DEBUG && Conf::msg_info(Ht::pre_text("function ({$args}) {\n  // fragments " . simplify_whitespace($this->expression) . "\n  {$t}}\n"));
     $outf = create_function($args, $t);
     // regroup function
     $state->clear();
     $state->combining = 0;
     $expr = $this->_parse ? $this->_parse->compile($state) : "0";
     $t = self::compile_body(null, $state, $expr);
     $args = '$groups, $format = null, $forceShow = false';
     self::DEBUG && Conf::msg_info(Ht::pre_text("function ({$args}) {\n  // combine " . simplify_whitespace($this->expression) . "\n  {$t}}\n"));
     $inf = create_function($args, $t);
     return [$outf, $inf];
 }
コード例 #7
0
ファイル: text.php プロジェクト: benesch/peteramati
 static function split_name($name, $with_email = false)
 {
     $name = simplify_whitespace($name);
     $ret = array("", "");
     if ($with_email) {
         $ret[2] = "";
         if (preg_match('%^\\s*\\"?(.*?)\\"?\\s*<([^<>]+)>\\s*$%', $name, $m) || preg_match('%^\\s*\\"(.*)\\"\\s+(\\S+)\\s*$%', $name, $m)) {
             list($name, $ret[2]) = array($m[1], $m[2]);
         } else {
             if (!preg_match('%^\\s*(.*?)\\s+(\\S+)\\s*$%', $name, $m)) {
                 return array("", "", trim($name));
             } else {
                 if (strpos($m[2], "@") !== false) {
                     list($name, $ret[2]) = array($m[1], $m[2]);
                 } else {
                     if (strpos($m[1], "@") !== false) {
                         list($name, $ret[2]) = array($m[2], $m[1]);
                     }
                 }
             }
         }
     }
     if (($p1 = strrpos($name, ",")) !== false) {
         $first = trim(substr($name, $p1 + 1));
         if (!preg_match('@^(Esq\\.?|Ph\\.?D\\.?|M\\.?[SD]\\.?|Esquire|Junior|Senior|Jr.?|Sr.?|I+)$@i', $first)) {
             list($ret[0], $ret[1]) = array($first, trim(substr($name, 0, $p1)));
             return $ret;
         }
     }
     if (preg_match('@[^\\s,]+(\\s+Jr\\.?|\\s+Sr\\.?|\\s+i+|\\s+Ph\\.?D\\.?|\\s+M\\.?[SD]\\.?)?(,.*)?\\s*$@i', $name, $m)) {
         $ret[0] = trim(substr($name, 0, strlen($name) - strlen($m[0])));
         $ret[1] = trim($m[0]);
         if (preg_match('@^(\\S.*?)\\s+(v[oa]n|d[eu])$@i', $ret[0], $m)) {
             list($ret[0], $ret[1]) = array($m[1], $m[2] . " " . $ret[1]);
         }
     } else {
         $ret[1] = trim($name);
     }
     return $ret;
 }
コード例 #8
0
ファイル: contact.php プロジェクト: kohler/peteramati
 private function trim()
 {
     $this->contactId = (int) trim($this->contactId);
     $this->cid = $this->contactId;
     $this->visits = trim($this->visits);
     $this->firstName = simplify_whitespace($this->firstName);
     $this->lastName = simplify_whitespace($this->lastName);
     foreach (array("email", "preferredEmail", "affiliation", "note") as $k) {
         if ($this->{$k}) {
             $this->{$k} = trim($this->{$k});
         }
     }
     self::set_sorter($this);
 }
コード例 #9
0
function parse_value($sv, $name, $info)
{
    global $Conf, $Me, $Now, $Opt;
    if (!isset($sv->req[$name])) {
        $xname = str_replace(".", "_", $name);
        if (isset($sv->req[$xname])) {
            $sv->req[$name] = $sv->req[$xname];
        } else {
            if ($info->type === "checkbox" || $info->type === "cdate") {
                return 0;
            } else {
                return null;
            }
        }
    }
    $v = trim($sv->req[$name]);
    if ($info->placeholder && $info->placeholder === $v || $info->invalid_value && $info->invalid_value === $v) {
        $v = "";
    }
    if ($info->type === "checkbox") {
        return $v != "" ? 1 : 0;
    } else {
        if ($info->type === "cdate" && $v == "1") {
            return 1;
        } else {
            if ($info->type === "date" || $info->type === "cdate" || $info->type === "ndate") {
                if ($v == "" || !strcasecmp($v, "N/A") || !strcasecmp($v, "same as PC") || $v == "0" || $info->type !== "ndate" && !strcasecmp($v, "none")) {
                    return -1;
                } else {
                    if (!strcasecmp($v, "none")) {
                        return 0;
                    } else {
                        if (($v = $Conf->parse_time($v)) !== false) {
                            return $v;
                        } else {
                            $err = unparse_setting_error($info, "Invalid date.");
                        }
                    }
                }
            } else {
                if ($info->type === "grace") {
                    if (($v = parseGrace($v)) !== null) {
                        return intval($v);
                    } else {
                        $err = unparse_setting_error($info, "Invalid grace period.");
                    }
                } else {
                    if ($info->type === "int" || $info->type === "zint") {
                        if (preg_match("/\\A[-+]?[0-9]+\\z/", $v)) {
                            return intval($v);
                        } else {
                            $err = unparse_setting_error($info, "Should be a number.");
                        }
                    } else {
                        if ($info->type === "string") {
                            // Avoid storing the default message in the database
                            if (substr($name, 0, 9) == "mailbody_") {
                                $t = expandMailTemplate(substr($name, 9), true);
                                $v = cleannl($v);
                                if ($t["body"] == $v) {
                                    return "";
                                }
                            }
                            return $v;
                        } else {
                            if ($info->type === "simplestring") {
                                return simplify_whitespace($v);
                            } else {
                                if ($info->type === "tag" || $info->type === "tagbase") {
                                    $tagger = new Tagger($Me);
                                    $v = trim($v);
                                    if ($v === "" && $info->optional) {
                                        return $v;
                                    }
                                    $v = $tagger->check($v, $info->type === "tagbase" ? Tagger::NOVALUE : 0);
                                    if ($v) {
                                        return $v;
                                    }
                                    $err = unparse_setting_error($info, $tagger->error_html);
                                } else {
                                    if ($info->type === "emailheader") {
                                        $v = MimeText::encode_email_header("", $v);
                                        if ($v !== false) {
                                            return $v == "" ? "" : MimeText::decode_header($v);
                                        }
                                        $err = unparse_setting_error($info, "Invalid email header.");
                                    } else {
                                        if ($info->type === "emailstring") {
                                            $v = trim($v);
                                            if ($v === "" && $info->optional) {
                                                return "";
                                            } else {
                                                if (validate_email($v) || $v === $v_active) {
                                                    return $v;
                                                } else {
                                                    $err = unparse_setting_error($info, "Invalid email.");
                                                }
                                            }
                                        } else {
                                            if ($info->type === "urlstring") {
                                                $v = trim($v);
                                                if ($v === "" && $info->optional || preg_match(',\\A(?:https?|ftp)://\\S+\\z,', $v)) {
                                                    return $v;
                                                } else {
                                                    $err = unparse_setting_error($info, "Invalid URL.");
                                                }
                                            } else {
                                                if ($info->type === "htmlstring") {
                                                    if (($v = CleanHTML::basic_clean($v, $err)) === false) {
                                                        $err = unparse_setting_error($info, $err);
                                                    } else {
                                                        if ($info->message_default && $v === $Conf->message_default_html($info->message_default)) {
                                                            return "";
                                                        } else {
                                                            return $v;
                                                        }
                                                    }
                                                } else {
                                                    if ($info->type === "radio") {
                                                        foreach ($info->values as $allowedv) {
                                                            if ((string) $allowedv === $v) {
                                                                return $allowedv;
                                                            }
                                                        }
                                                        $err = unparse_setting_error($info, "Parse error (unexpected value).");
                                                    } else {
                                                        return $v;
                                                    }
                                                }
                                            }
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
            }
        }
    }
    $sv->set_error($name, $err);
    return null;
}
コード例 #10
0
 private function option_search_term($oname)
 {
     $owords = preg_split(',[^a-z_0-9]+,', strtolower(trim($oname)));
     for ($i = 0; $i < count($owords); ++$i) {
         $attempt = join("-", array_slice($owords, 0, $i + 1));
         if (count(PaperOption::search($attempt)) == 1) {
             return $attempt;
         }
     }
     return simplify_whitespace($oname);
 }
コード例 #11
0
 static function decision_name_error($dname)
 {
     $dname = simplify_whitespace($dname);
     if ((string) $dname === "") {
         return "Empty decision name.";
     } else {
         if (preg_match(',\\A(?:yes|no|any|none|unknown|unspecified)\\z,i', $dname)) {
             return "Decision name “{$dname}” is reserved.";
         } else {
             return false;
         }
     }
 }
コード例 #12
0
 function _searchQueryWord($word, $report_error)
 {
     global $Conf;
     // check for paper number or "#TAG"
     if (preg_match('/\\A#?(\\d+)(?:-#?(\\d+))?\\z/', $word, $m)) {
         $m[2] = isset($m[2]) && $m[2] ? $m[2] : $m[1];
         return new SearchTerm("pn", 0, array(range($m[1], $m[2]), array()));
     } else {
         if (substr($word, 0, 1) === "#") {
             $qe = $this->_searchQueryWord("tag:" . $word, false);
             if (!$qe->is_false()) {
                 return $qe;
             }
         }
     }
     // Allow searches like "ovemer>2"; parse as "ovemer:>2".
     if (preg_match('/\\A([-_A-Za-z0-9]+)((?:[=!<>]=?|≠|≤|≥)[^:]+)\\z/', $word, $m)) {
         $qe = $this->_searchQueryWord($m[1] . ":" . $m[2], false);
         if (!$qe->is_false()) {
             return $qe;
         }
     }
     $keyword = null;
     if (($colon = strpos($word, ":")) > 0) {
         $x = substr($word, 0, $colon);
         if (strpos($x, '"') === false) {
             $keyword = get(self::$_keywords, $x) ?: $x;
             $word = substr($word, $colon + 1);
             if ($word === false) {
                 $word = "";
             }
         }
     }
     // Treat unquoted "*", "ANY", and "ALL" as special; return true.
     if ($word === "*" || $word === "ANY" || $word === "ALL" || $word === "") {
         return new SearchTerm("t");
     } else {
         if ($word === "NONE") {
             return new SearchTerm("f");
         }
     }
     $qword = $word;
     $quoted = $word[0] === '"';
     $negated = false;
     if ($quoted) {
         $word = str_replace('*', '\\*', preg_replace('/(?:\\A"|"\\z)/', '', $word));
     }
     if ($keyword === "notag") {
         $keyword = "tag";
         $negated = true;
     }
     $qt = array();
     if ($keyword ? $keyword === "ti" : isset($this->fields["ti"])) {
         $this->_searchField($word, "ti", $qt);
     }
     if ($keyword ? $keyword === "ab" : isset($this->fields["ab"])) {
         $this->_searchField($word, "ab", $qt);
     }
     if ($keyword ? $keyword === "au" : isset($this->fields["au"])) {
         $this->_searchAuthors($word, $qt, $keyword, $quoted);
     }
     if ($keyword ? $keyword === "co" : isset($this->fields["co"])) {
         $this->_searchField($word, "co", $qt);
     }
     if ($keyword ? $keyword === "re" : isset($this->fields["re"])) {
         $this->_search_reviewer($qword, "re", $qt);
     } else {
         if ($keyword && get(self::$_canonical_review_keywords, $keyword)) {
             $this->_search_reviewer($qword, $keyword, $qt);
         }
     }
     if (preg_match('/\\A(?:(?:draft-?)?\\w*resp(?:onse)|\\w*resp(?:onse)?(-?draft)?|cmt|aucmt|anycmt)\\z/', $keyword)) {
         $this->_search_comment($word, $keyword, $qt, $quoted);
     }
     if ($keyword === "pref" && $this->amPC) {
         $this->_search_revpref($word, $qt, $quoted, false);
     }
     if ($keyword === "prefexp" && $this->amPC) {
         $this->_search_revpref($word, $qt, $quoted, true);
     }
     foreach (array("lead", "shepherd", "manager") as $ctype) {
         if ($keyword === $ctype) {
             $x = $this->_one_pc_matcher($word, $quoted);
             $qt[] = new SearchTerm("pf", self::F_XVIEW, array("{$ctype}ContactId", $x));
             if ($ctype === "manager" && $word === "me" && !$quoted && $this->privChair) {
                 $qt[] = new SearchTerm("pf", self::F_XVIEW, array("{$ctype}ContactId", "=0"));
             }
         }
     }
     if (($keyword ? $keyword === "tag" : isset($this->fields["tag"])) || $keyword === "order" || $keyword === "rorder") {
         $this->_search_tags($word, $keyword, $qt);
     }
     if ($keyword === "color") {
         $this->_search_color($word, $qt);
     }
     if ($keyword === "topic") {
         $type = "topic";
         $value = null;
         if ($word === "none" || $word === "any") {
             $value = $word;
         } else {
             $x = strtolower(simplify_whitespace($word));
             $tids = array();
             foreach ($Conf->topic_map() as $tid => $tname) {
                 if (strstr(strtolower($tname), $x) !== false) {
                     $tids[] = $tid;
                 }
             }
             if (count($tids) == 0 && $word !== "none" && $word !== "any") {
                 $this->warn("“" . htmlspecialchars($x) . "” does not match any defined paper topic.");
                 $type = "f";
             } else {
                 $value = $tids;
             }
         }
         $qt[] = new SearchTerm($type, self::F_XVIEW, $value);
     }
     if ($keyword === "option") {
         $this->_search_options($word, $qt, true);
     }
     if ($keyword === "status" || $keyword === "is") {
         $this->_search_status($word, $qt, $quoted, true);
     }
     if ($keyword === "decision") {
         $this->_search_status($word, $qt, $quoted, false);
     }
     if ($keyword === "conflict" && $this->amPC) {
         $this->_search_conflict($word, $qt, $quoted, false);
     }
     if ($keyword === "pcconflict" && $this->amPC) {
         $this->_search_conflict($word, $qt, $quoted, true);
     }
     if ($keyword === "reconflict" && $this->privChair) {
         $this->_searchReviewerConflict($word, $qt, $quoted);
     }
     if ($keyword === "round" && $this->amPC) {
         $this->reviewAdjust = true;
         if ($word === "none") {
             $qt[] = new SearchTerm("revadj", 0, array("round" => array(0)));
         } else {
             if ($word === "any") {
                 $qt[] = new SearchTerm("revadj", 0, array("round" => range(1, count($Conf->round_list()) - 1)));
             } else {
                 $x = simplify_whitespace($word);
                 $rounds = Text::simple_search($x, $Conf->round_list());
                 if (count($rounds) == 0) {
                     $this->warn("“" . htmlspecialchars($x) . "” doesn’t match a review round.");
                     $qt[] = new SearchTerm("f");
                 } else {
                     $qt[] = new SearchTerm("revadj", 0, array("round" => array_keys($rounds)));
                 }
             }
         }
     }
     if ($keyword === "rate") {
         $this->_searchReviewRatings($word, $qt);
     }
     if ($keyword === "has") {
         $this->_search_has($word, $qt, $quoted);
     }
     if ($keyword === "formula") {
         $this->_search_formula($word, $qt, $quoted);
     }
     if ($keyword === "ss" && $this->amPC) {
         if ($nextq = self::_expand_saved_search($word, $this->_ssRecursion)) {
             $this->_ssRecursion[$word] = true;
             $qe = $this->_searchQueryType($nextq);
             unset($this->_ssRecursion[$word]);
         } else {
             $qe = null;
         }
         if (!$qe && $nextq === false) {
             $this->warn("Saved search “" . htmlspecialchars($word) . "” is incorrectly defined in terms of itself.");
         } else {
             if (!$qe && !$Conf->setting_data("ss:{$word}")) {
                 $this->warn("There is no “" . htmlspecialchars($word) . "” saved search.");
             } else {
                 if (!$qe) {
                     $this->warn("The “" . htmlspecialchars($word) . "” saved search is defined incorrectly.");
                 }
             }
         }
         $qt[] = $qe ?: new SearchTerm("f");
     }
     if ($keyword === "HEADING") {
         $heading = simplify_whitespace($word);
         $qt[] = SearchTerm::make_float(["heading" => $heading]);
     }
     if ($keyword === "show" || $keyword === "hide" || $keyword === "edit" || $keyword === "sort" || $keyword === "showsort" || $keyword === "editsort") {
         $editing = strpos($keyword, "edit") !== false;
         $sorting = strpos($keyword, "sort") !== false;
         $views = array();
         $a = $keyword === "hide" ? false : ($editing ? "edit" : true);
         $word = simplify_whitespace($word);
         $ch1 = substr($word, 0, 1);
         if ($ch1 === "-" && !$sorting) {
             list($a, $word) = array(false, substr($word, 1));
         }
         $wtype = $word;
         if ($sorting) {
             $sort = self::parse_sorter($wtype);
             $wtype = $sort->type;
         }
         if ($wtype !== "" && $keyword !== "sort") {
             $views[$wtype] = $a;
         }
         $f = array("view" => $views);
         if ($sorting) {
             $f["sort"] = array($word);
         }
         $qt[] = SearchTerm::make_float($f);
     }
     // Finally, look for a review field.
     if ($keyword && !isset(self::$_keywords[$keyword]) && count($qt) == 0) {
         if ($field = ReviewForm::field_search($keyword)) {
             $this->_search_review_field($word, $field, $qt, $quoted);
         } else {
             if (!$this->_search_options("{$keyword}:{$word}", $qt, false) && $report_error) {
                 $this->warn("Unrecognized keyword “" . htmlspecialchars($keyword) . "”.");
             }
         }
     }
     $qe = SearchTerm::make_op("or", $qt);
     return $negated ? SearchTerm::make_not($qe) : $qe;
 }
コード例 #13
0
ファイル: dbl.php プロジェクト: kohler/peteramati
 private static function query_args($args, $flags, $log_location)
 {
     $argpos = 0;
     $dblink = self::$default_dblink;
     if (is_object($args[0])) {
         $argpos = 1;
         $dblink = $args[0];
     } else {
         if ($args[0] === null && count($args) > 1) {
             $argpos = 1;
         }
     }
     if ($flags & self::F_RAW && count($args) != $argpos + 1 || $flags & self::F_APPLY && count($args) > $argpos + 2) {
         trigger_error(self::landmark() . ": wrong number of arguments");
     } else {
         if ($flags & self::F_APPLY && isset($args[$argpos + 1]) && !is_array($args[$argpos + 1])) {
             trigger_error(self::landmark() . ": argument is not array");
         }
     }
     $q = $args[$argpos];
     if ($flags & self::F_MULTI && is_array($q)) {
         $q = join(";", $q);
     }
     if ($log_location && self::$query_log !== false) {
         self::$query_log_key = $qx = simplify_whitespace($q);
         if (isset(self::$query_log[$qx])) {
             ++self::$query_log[$qx][1];
         } else {
             self::$query_log[$qx] = [0, 1, self::landmark()];
         }
     }
     if (count($args) === $argpos + 1) {
         return array($dblink, $q, array());
     } else {
         if ($flags & self::F_APPLY) {
             return array($dblink, $q, $args[$argpos + 1]);
         } else {
             return array($dblink, $q, array_slice($args, $argpos + 1));
         }
     }
 }
コード例 #14
0
 function normalize($pj, $old_pj)
 {
     // Errors prevent saving
     global $Conf, $Now;
     // Title, abstract
     $this->normalize_string($pj, "title", true);
     $this->normalize_string($pj, "abstract", false);
     $this->normalize_string($pj, "collaborators", false);
     if (isset($pj->collaborators)) {
         $collab = [];
         foreach (preg_split('/[\\r\\n]+/', $pj->collaborators) as $line) {
             $collab[] = preg_replace('/[,;\\s]+\\z/', '', $line);
         }
         while (!empty($collab) && $collab[count($collab) - 1] === "") {
             array_pop($collab);
         }
         if (!empty($collab)) {
             $pj->collaborators = join("\n", $collab) . "\n";
         } else {
             $pj->collaborators = "";
         }
     }
     // Authors
     $au_by_email = array();
     $pj->bad_authors = array();
     if (isset($pj->authors)) {
         if (!is_array($pj->authors)) {
             $this->set_error_html("author", "Format error [authors]");
         }
         // old author information
         $old_au_by_email = [];
         if ($old_pj && isset($old_pj->authors)) {
             foreach ($old_pj->authors as $au) {
                 if (isset($au->email)) {
                     $old_au_by_email[strtolower($au->email)] = $au;
                 }
             }
         }
         // new author information
         $curau = is_array($pj->authors) ? $pj->authors : array();
         $pj->authors = array();
         foreach ($curau as $k => $au) {
             if (is_string($au) || is_object($au)) {
                 $aux = Text::analyze_name($au);
                 $aux->first = simplify_whitespace($aux->firstName);
                 $aux->last = simplify_whitespace($aux->lastName);
                 $aux->email = simplify_whitespace($aux->email);
                 $aux->affiliation = simplify_whitespace($aux->affiliation);
                 // borrow from old author information
                 if ($aux->email && $aux->first === "" && $aux->last === "" && ($old_au = get($old_au_by_email, strtolower($aux->email)))) {
                     $aux->first = get($old_au, "first", "");
                     $aux->last = get($old_au, "last", "");
                     if ($aux->affiliation === "") {
                         $aux->affiliation = get($old_au, "affiliation", "");
                     }
                 }
                 if ($aux->first !== "" || $aux->last !== "" || $aux->email !== "" || $aux->affiliation !== "") {
                     $pj->authors[] = $aux;
                 } else {
                     $pj->bad_authors[] = $aux;
                 }
                 $aux->index = count($pj->authors) + count($pj->bad_authors);
                 if (is_object($au) && isset($au->contact)) {
                     $aux->contact = !!$au->contact;
                 }
                 if (get($aux, "email")) {
                     $au_by_email[strtolower($aux->email)] = $aux;
                 }
             } else {
                 $this->set_error_html("author", "Format error [authors]");
             }
         }
     }
     // Status
     foreach (array("withdrawn_at", "submitted_at", "final_submitted_at") as $k) {
         if (isset($pj->{$k})) {
             if (is_numeric($pj->{$k})) {
                 $pj->{$k} = (int) $pj->{$k};
             } else {
                 if (is_string($pj->{$k})) {
                     $pj->{$k} = $Conf->parse_time($pj->{$k}, $Now);
                 } else {
                     $pj->{$k} = false;
                 }
             }
             if ($pj->{$k} === false || $pj->{$k} < 0) {
                 $pj->{$k} = $Now;
             }
         }
     }
     // Blindness
     if (isset($pj->nonblind)) {
         if (($x = friendly_boolean($pj->nonblind)) !== null) {
             $pj->nonblind = $x;
         } else {
             $this->set_error_html("nonblind", "Format error [nonblind]");
         }
     }
     // Topics
     $pj->bad_topics = array();
     if (get($pj, "topics") !== null) {
         $this->normalize_topics($pj);
     }
     // Options
     $pj->bad_options = array();
     if (get($pj, "options") && is_object($pj->options)) {
         $this->normalize_options($pj);
     } else {
         if (get($pj, "options") === false) {
             $pj->options = (object) array();
         } else {
             if (get($pj, "options") !== null) {
                 $this->set_error_html("options", "Format error [options]");
             }
         }
     }
     // PC conflicts
     $pj->bad_pc_conflicts = (object) array();
     if (get($pj, "pc_conflicts") && (is_object($pj->pc_conflicts) || is_array($pj->pc_conflicts))) {
         $this->normalize_pc_conflicts($pj);
     } else {
         if (get($pj, "pc_conflicts") === false) {
             $pj->pc_conflicts = (object) array();
         } else {
             if (get($pj, "pc_conflicts") !== null) {
                 $this->set_error_html("pc_conflicts", "Format error [PC conflicts]");
             }
         }
     }
     // Old contacts (to avoid validate_email errors on unchanged contacts)
     $old_contacts = array();
     if ($old_pj && get($old_pj, "authors")) {
         foreach ($old_pj->authors as $au) {
             if (get($au, "contact")) {
                 $old_contacts[strtolower($au->email)] = true;
             }
         }
     }
     if ($old_pj && get($old_pj, "contacts")) {
         foreach ($old_pj->contacts as $conf) {
             $old_contacts[strtolower($conf->email)] = true;
         }
     }
     // verify emails on authors marked as contacts
     $pj->bad_contacts = array();
     foreach (get($pj, "authors") ?: array() as $au) {
         if (get($au, "contact") && (!get($au, "email") || !$this->valid_contact(strtolower($au->email), $old_contacts))) {
             $pj->bad_contacts[] = $au;
         }
     }
     // Contacts
     $contacts = get($pj, "contacts");
     if ($contacts !== null) {
         if (is_object($contacts) || is_array($contacts)) {
             $contacts = (array) $contacts;
         } else {
             $this->set_error_html("contacts", "Format error [contacts]");
             $contacts = array();
         }
         $pj->contacts = array();
         // verify emails on explicitly named contacts
         foreach ($contacts as $k => $v) {
             if (!$v) {
                 continue;
             }
             if ($v === true) {
                 $v = (object) array();
             } else {
                 if (is_string($v) && is_int($k)) {
                     $v = trim($v);
                     if ($this->valid_contact(strtolower($v), $old_contacts)) {
                         $v = (object) array("email" => $v);
                     } else {
                         $v = Text::analyze_name($v);
                     }
                 }
             }
             if (is_object($v) && !get($v, "email") && is_string($k)) {
                 $v->email = $k;
             }
             if (is_object($v) && get($v, "email")) {
                 $lemail = strtolower($v->email);
                 if ($this->valid_contact($lemail, $old_contacts)) {
                     $pj->contacts[] = (object) array_merge((array) get($au_by_email, $lemail), (array) $v);
                 } else {
                     $pj->bad_contacts[] = $v;
                 }
             } else {
                 $this->set_error_html("contacts", "Format error [contacts]");
             }
         }
     }
     // Inherit contactness
     if (isset($pj->authors) && $old_pj && isset($old_pj->authors)) {
         foreach ($old_pj->authors as $au) {
             if (get($au, "contact") && $au->email && ($aux = get($au_by_email, strtolower($au->email))) && !isset($aux->contact)) {
                 $aux->contact = true;
             }
         }
     }
     if (isset($pj->authors) && $old_pj && isset($old_pj->contacts)) {
         foreach ($old_pj->contacts as $au) {
             if (($aux = get($au_by_email, strtolower($au->email))) && !isset($aux->contact)) {
                 $aux->contact = true;
             }
         }
     }
 }
コード例 #15
0
 public function parse($sv, $si)
 {
     $dec_revmap = array();
     foreach ($sv->req as $k => &$dname) {
         if (str_starts_with($k, "dec") && ($k === "decn" || ($dnum = cvtint(substr($k, 3), 0))) && ($k !== "decn" || trim($dname) !== "")) {
             $dname = simplify_whitespace($dname);
             if ($dname === "") {
                 /* remove decision */
             } else {
                 if ($derror = Conf::decision_name_error($dname)) {
                     $sv->set_error($k, htmlspecialchars($derror));
                 } else {
                     if (isset($dec_revmap[strtolower($dname)])) {
                         $sv->set_error($k, "Decision name “{$dname}” was already used.");
                     } else {
                         $dec_revmap[strtolower($dname)] = true;
                     }
                 }
             }
         }
     }
     unset($dname);
     if (get($sv->req, "decn") && !get($sv->req, "decn_confirm")) {
         $delta = defval($sv->req, "dtypn", 1) > 0 ? 1 : -1;
         $match_accept = stripos($sv->req["decn"], "accept") !== false;
         $match_reject = stripos($sv->req["decn"], "reject") !== false;
         if ($delta > 0 && $match_reject) {
             $sv->set_error("decn", "You are trying to add an Accept-class decision that has “reject” in its name, which is usually a mistake.  To add the decision anyway, check the “Confirm” box and try again.");
         } else {
             if ($delta < 0 && $match_accept) {
                 $sv->set_error("decn", "You are trying to add a Reject-class decision that has “accept” in its name, which is usually a mistake.  To add the decision anyway, check the “Confirm” box and try again.");
             }
         }
     }
     $sv->need_lock["Paper"] = true;
     return true;
 }
コード例 #16
0
 static function encode_header($header, $str)
 {
     if (preg_match('/[\\r\\n]/', $str)) {
         $str = simplify_whitespace($str);
     }
     $text = $header;
     $linelen = strlen($text);
     if (preg_match('/[\\x80-\\xFF]/', $str)) {
         self::append($text, $linelen, $str, true);
     } else {
         self::append($text, $linelen, $str, false);
     }
     return $text;
 }
コード例 #17
0
function pc_request_as_json($cj)
{
    global $Conf, $Me, $Acct;
    if ($Me->privChair && isset($_REQUEST["pctype"])) {
        $cj->roles = (object) array();
        if (@$_REQUEST["pctype"] === "chair") {
            $cj->roles->chair = $cj->roles->pc = true;
        }
        if (@$_REQUEST["pctype"] === "pc") {
            $cj->roles->pc = true;
        }
        if (@$_REQUEST["ass"]) {
            $cj->roles->sysadmin = true;
        }
    }
    $cj->follow = (object) array();
    if (@$_REQUEST["watchcomment"]) {
        $cj->follow->reviews = true;
    }
    if (($Me->privChair || $Acct->isPC) && @$_REQUEST["watchcommentall"]) {
        $cj->follow->allreviews = true;
    }
    if ($Me->privChair && @$_REQUEST["watchfinalall"]) {
        $cj->follow->allfinal = true;
    }
    if ($Me->privChair && isset($_REQUEST["contactTags"])) {
        $cj->tags = explode(" ", simplify_whitespace($_REQUEST["contactTags"]));
    }
    if ($Me->privChair ? @$cj->roles->pc : $Me->isPC) {
        $topics = (object) array();
        foreach ($Conf->topic_map() as $id => $t) {
            if (isset($_REQUEST["ti{$id}"]) && is_numeric($_REQUEST["ti{$id}"])) {
                $topics->{$id} = (int) $_REQUEST["ti{$id}"];
            }
        }
        if (count(get_object_vars($topics))) {
            $cj->topics = (object) $topics;
        }
    }
    return $cj;
}
コード例 #18
0
 function option_request_to_json($sv, &$new_opts, $id, $current_opts)
 {
     global $Conf;
     $name = simplify_whitespace(defval($sv->req, "optn{$id}", ""));
     if (!isset($sv->req["optn{$id}"]) && $id[0] !== "n") {
         if (get($current_opts, $id)) {
             $new_opts[$id] = $current_opts[$id];
         }
         return;
     } else {
         if ($name === "" || $sv->req["optfp{$id}"] === "delete" || $id[0] === "n" && ($name === "New option" || $name === "(Enter new option)")) {
             return;
         }
     }
     $oarg = ["name" => $name, "id" => (int) $id, "final" => false];
     if ($id[0] === "n") {
         $nextid = max($Conf->setting("next_optionid", 1), 1);
         foreach ($new_opts as $haveid => $o) {
             $nextid = max($nextid, $haveid + 1);
         }
         foreach ($current_opts as $haveid => $o) {
             $nextid = max($nextid, $haveid + 1);
         }
         $oarg["id"] = $nextid;
     }
     if (get($sv->req, "optd{$id}") && trim($sv->req["optd{$id}"]) != "") {
         $t = CleanHTML::basic_clean($sv->req["optd{$id}"], $err);
         if ($t !== false) {
             $oarg["description"] = $t;
         } else {
             $sv->set_error("optd{$id}", $err);
         }
     }
     if ($optvt = get($sv->req, "optvt{$id}")) {
         if (($pos = strpos($optvt, ":")) !== false) {
             $oarg["type"] = substr($optvt, 0, $pos);
             if (preg_match('/:final/', $optvt)) {
                 $oarg["final"] = true;
             }
             if (preg_match('/:ds_(\\d+)/', $optvt, $m)) {
                 $oarg["display_space"] = (int) $m[1];
             }
         } else {
             $oarg["type"] = $optvt;
         }
     } else {
         $oarg["type"] = "checkbox";
     }
     if (PaperOption::type_has_selector($oarg["type"])) {
         $oarg["selector"] = array();
         $seltext = trim(cleannl(defval($sv->req, "optv{$id}", "")));
         if ($seltext != "") {
             foreach (explode("\n", $seltext) as $t) {
                 $oarg["selector"][] = $t;
             }
         } else {
             $sv->set_error("optv{$id}", "Enter selectors one per line.");
         }
     }
     $oarg["visibility"] = defval($sv->req, "optp{$id}", "rev");
     if ($oarg["final"]) {
         $oarg["visibility"] = "rev";
     }
     $oarg["position"] = (int) defval($sv->req, "optfp{$id}", 1);
     $oarg["display"] = defval($sv->req, "optdt{$id}");
     if ($oarg["type"] === "pdf" && $oarg["final"]) {
         $oarg["display"] = "submission";
     }
     $new_opts[$oarg["id"]] = $o = PaperOption::make($oarg);
     $o->req_id = $id;
     $o->is_new = $id[0] === "n";
 }
コード例 #19
0
ファイル: text.php プロジェクト: kohler/peteramati
 static function split_name($name, $with_email = false)
 {
     $name = simplify_whitespace($name);
     $ret = array("", "");
     if ($with_email) {
         $ret[2] = "";
         if (preg_match('%^\\s*\\"?(.*?)\\"?\\s*<([^<>]+)>\\s*$%', $name, $m) || preg_match('%^\\s*\\"(.*)\\"\\s+(\\S+)\\s*$%', $name, $m)) {
             list($name, $ret[2]) = array($m[1], $m[2]);
         } else {
             if (!preg_match('%^\\s*(.*?)\\s+(\\S+)\\s*$%', $name, $m)) {
                 return array("", "", trim($name));
             } else {
                 if (strpos($m[2], "@") !== false) {
                     list($name, $ret[2]) = array($m[1], $m[2]);
                 } else {
                     if (strpos($m[1], "@") !== false) {
                         list($name, $ret[2]) = array($m[2], $m[1]);
                     }
                 }
             }
         }
     }
     // parenthetical comment on name attaches to first or last whole
     $paren = "";
     if ($name !== "" && $name[strlen($name) - 1] === ")" && preg_match('{\\A(.*?)(\\s*\\(.*?\\))\\z}', $name, $m)) {
         $name = $m[1];
         $paren = $m[2];
     }
     // `last, first`
     $suffix = "";
     while (($comma = strrpos($name, ",")) !== false) {
         $first = ltrim(substr($name, $comma + 1));
         if (!preg_match('{\\A(?:' . self::SUFFIX_REGEX . ')\\z}i', $first)) {
             $ret[0] = $first . $paren;
             $ret[1] = trim(substr($name, 0, $comma)) . $suffix;
             return $ret;
         }
         $suffix = substr($name, $comma) . $suffix . $paren;
         $paren = "";
         $name = rtrim(substr($name, 0, $comma));
     }
     if (preg_match('{[^\\s,]+(?:\\s+(?:' . self::SUFFIX_REGEX . '))?(?:,.*)?\\z}i', $name, $m)) {
         $ret[0] = rtrim(substr($name, 0, strlen($name) - strlen($m[0])));
         $ret[1] = ltrim($m[0]) . $suffix . $paren;
         // see also split_von
         if (preg_match('@^(\\S.*?)\\s+(v[oa]n|d[eu])$@i', $ret[0], $m)) {
             list($ret[0], $ret[1]) = array($m[1], $m[2] . " " . $ret[1]);
         }
     } else {
         $ret[1] = $name . $suffix . $paren;
     }
     return $ret;
 }
コード例 #20
0
 private static function query_args($args, $flags, $log_location)
 {
     $argpos = is_object($args[0]) ? 1 : 0;
     $dblink = $argpos ? $args[0] : self::$default_dblink;
     if ($flags & self::F_RAW && count($args) != $argpos + 1 || $flags & self::F_APPLY && count($args) > $argpos + 2) {
         trigger_error(self::landmark() . ": wrong number of arguments");
     } else {
         if ($flags & self::F_APPLY && isset($args[$argpos + 1]) && !is_array($args[$argpos + 1])) {
             trigger_error(self::landmark() . ": argument is not array");
         }
     }
     if ($log_location && self::$log_queries !== false) {
         $location = self::landmark();
         if (!isset(self::$log_queries[$location])) {
             self::$log_queries[$location] = array(substr(simplify_whitespace($args[$argpos]), 0, 80), 0);
         }
         ++self::$log_queries[$location][1];
     }
     $q = $args[$argpos];
     if ($flags & self::F_MULTI && is_array($q)) {
         $q = join(";", $q);
     }
     if (count($args) === $argpos + 1) {
         return array($dblink, $q, array());
     } else {
         if ($flags & self::F_APPLY) {
             return array($dblink, $q, $args[$argpos + 1]);
         } else {
             return array($dblink, $q, array_slice($args, $argpos + 1));
         }
     }
 }
コード例 #21
0
 public function apply(Contact $user, $pj, $opj, $qreq, $action)
 {
     global $Conf;
     // Title, abstract, collaborators
     foreach (array("title", "abstract", "collaborators") as $k) {
         if (isset($qreq[$k])) {
             $pj->{$k} = $qreq[$k];
         }
     }
     // Authors
     $bad_author = ["name" => "Name", "email" => "Email", "aff" => "Affiliation"];
     $authors = array();
     foreach ($qreq as $k => $v) {
         if (preg_match('/\\Aau(name|email|aff)(\\d+)\\z/', $k, $m) && ($v = simplify_whitespace($v)) !== "" && $v !== $bad_author[$m[1]]) {
             $au = $authors[$m[2]] = get($authors, $m[2]) ?: (object) array();
             $x = $m[1] == "aff" ? "affiliation" : $m[1];
             $au->{$x} = $v;
         }
     }
     if (!empty($authors)) {
         ksort($authors, SORT_NUMERIC);
         $pj->authors = array_values($authors);
     }
     // Contacts
     if ($qreq->setcontacts || $qreq->has_contacts) {
         PaperSaver::replace_contacts($pj, $qreq);
     } else {
         if (!$opj) {
             $pj->contacts = array($user);
         }
     }
     // Status
     if ($action === "submit") {
         $pj->submitted = true;
     } else {
         if ($action === "final") {
             $pj->final_submitted = true;
         } else {
             $pj->submitted = false;
         }
     }
     // Paper upload
     if ($qreq->_FILES->paperUpload) {
         if ($action === "final") {
             $pj->final = Filer::file_upload_json($qreq->_FILES->paperUpload);
         } else {
             if ($action === "update" || $action === "submit") {
                 $pj->submission = Filer::file_upload_json($qreq->_FILES->paperUpload);
             }
         }
     }
     // Blindness
     if ($action !== "final" && $Conf->subBlindOptional()) {
         $pj->nonblind = !$qreq->blind;
     }
     // Topics
     if ($qreq->has_topics) {
         $pj->topics = (object) array();
         foreach ($Conf->topic_map() as $tid => $tname) {
             if (+$qreq["top{$tid}"] > 0) {
                 $pj->topics->{$tname} = true;
             }
         }
     }
     // Options
     if (!isset($pj->options)) {
         $pj->options = (object) [];
     }
     foreach (PaperOption::option_list() as $o) {
         if ($qreq["has_opt{$o->id}"] && (!$o->final || $action === "final")) {
             $okey = $o->abbr;
             $pj->options->{$okey} = $o->parse_request(get($pj->options, $okey), $qreq, $user, $pj);
         }
     }
     if (!count(get_object_vars($pj->options))) {
         unset($pj->options);
     }
     // PC conflicts
     if ($Conf->setting("sub_pcconf") && ($action !== "final" || $user->privChair) && $qreq->has_pcconf) {
         $cmax = $user->privChair ? CONFLICT_CHAIRMARK : CONFLICT_MAXAUTHORMARK;
         $pj->pc_conflicts = (object) array();
         foreach (pcMembers() as $pcid => $pc) {
             $ctype = cvtint($qreq["pcc{$pcid}"], 0);
             $ctype = max(min($ctype, $cmax), 0);
             if ($ctype) {
                 $email = $pc->email;
                 $pj->pc_conflicts->{$email} = Conflict::$type_names[$ctype];
             }
         }
     }
 }
コード例 #22
0
 private function _save_assign_field($k, $v, Contact_Update $cu)
 {
     global $Conf;
     $fieldtype = get_i(self::$save_fields, $k);
     if ($fieldtype & 2) {
         $v = simplify_whitespace($v);
     } else {
         if ($fieldtype & 1) {
             $v = trim($v);
         }
     }
     // check CDB version first (in case $this === $cdbu)
     $cdbu = $this->contactDbId ? $this : $this->contactdb_user_;
     if ($fieldtype & 4 && (!$cdbu || $cu->different_email || $cdbu->{$k} !== $v)) {
         $cu->cdb_uqv[$k] = $v;
     }
     // change local version
     if ($this->{$k} !== $v || !$this->contactId) {
         $cu->qv[$k] = $this->{$k} = $v;
     }
 }
コード例 #23
0
function admin_home_messages()
{
    global $Opt, $Conf;
    $m = array();
    $errmarker = "<span class=\"error\">Error:</span> ";
    if (preg_match("/^(?:[1-4]\\.|5\\.[0123])/", phpversion())) {
        $m[] = $errmarker . "HotCRP requires PHP version 5.4 or higher.  You are running PHP version " . htmlspecialchars(phpversion()) . ".";
    }
    if (get_magic_quotes_gpc()) {
        $m[] = $errmarker . "The PHP <code>magic_quotes_gpc</code> feature is on, which is a bad idea.  Check that your Web server is using HotCRP’s <code>.htaccess</code> file.  You may also want to disable <code>magic_quotes_gpc</code> in your <code>php.ini</code> configuration file.";
    }
    if (get_magic_quotes_runtime()) {
        $m[] = $errmarker . "The PHP <code>magic_quotes_runtime</code> feature is on, which is a bad idea.  Check that your Web server is using HotCRP’s <code>.htaccess</code> file.  You may also want to disable <code>magic_quotes_runtime</code> in your <code>php.ini</code> configuration file.";
    }
    if (defined("JSON_HOTCRP")) {
        $m[] = "Your PHP was built without JSON functionality. HotCRP is using its built-in replacements; the native functions would be faster.";
    }
    if ((int) $Opt["globalSessionLifetime"] < $Opt["sessionLifetime"]) {
        $m[] = "PHP’s systemwide <code>session.gc_maxlifetime</code> setting, which is " . htmlspecialchars($Opt["globalSessionLifetime"]) . " seconds, is less than HotCRP’s preferred session expiration time, which is " . $Opt["sessionLifetime"] . " seconds.  You should update <code>session.gc_maxlifetime</code> in the <code>php.ini</code> file or users may be booted off the system earlier than you expect.";
    }
    if (!function_exists("imagecreate") && $Conf->setting("__gd_required")) {
        $m[] = $errmarker . "This PHP installation lacks support for the GD library, so HotCRP can’t generate backup score charts for old browsers. Some of your users require this backup. You should update your PHP installation. For example, on Ubuntu Linux, install the <code>php" . PHP_MAJOR_VERSION . "-gd</code> package.";
    }
    $result = Dbl::qx_raw("show variables like 'max_allowed_packet'");
    $max_file_size = ini_get_bytes("upload_max_filesize");
    if (($row = edb_row($result)) && $row[1] < $max_file_size && !get($Opt, "dbNoPapers")) {
        $m[] = $errmarker . "MySQL’s <code>max_allowed_packet</code> setting, which is " . htmlspecialchars($row[1]) . "&nbsp;bytes, is less than the PHP upload file limit, which is {$max_file_size}&nbsp;bytes.  You should update <code>max_allowed_packet</code> in the system-wide <code>my.cnf</code> file or the system may not be able to handle large papers.";
    }
    // Conference names
    if (get($Opt, "shortNameDefaulted")) {
        $m[] = "<a href=\"" . hoturl("settings", "group=basics") . "\">Set the conference abbreviation</a> to a short name for your conference, such as “OSDI ’14”.";
    } else {
        if (simplify_whitespace(Conf::$gShortName) != Conf::$gShortName) {
            $m[] = "The <a href=\"" . hoturl("settings", "group=basics") . "\">conference abbreviation</a> setting has a funny value. To fix it, remove leading and trailing spaces, use only space characters (no tabs or newlines), and make sure words are separated by single spaces (never two or more).";
        }
    }
    $site_contact = Contact::site_contact();
    if (!$site_contact->email || $site_contact->email == "*****@*****.**") {
        $m[] = "<a href=\"" . hoturl("settings", "group=basics") . "\">Set the conference contact’s name and email</a> so submitters can reach someone if things go wrong.";
    }
    // Any -100 preferences around?
    $result = Dbl::ql_raw($Conf->preferenceConflictQuery(false, "limit 1"));
    if ($row = edb_row($result)) {
        $m[] = "PC members have indicated paper conflicts (using review preferences of &#8722;100 or less) that aren’t yet confirmed. <a href='" . hoturl_post("autoassign", "a=prefconflict&amp;assign=1") . "' class='nw'>Confirm these conflicts</a>";
    }
    // Weird URLs?
    foreach (array("conferenceSite", "paperSite") as $k) {
        if (isset($Opt[$k]) && $Opt[$k] && !preg_match('`\\Ahttps?://(?:[-.~\\w:/?#\\[\\]@!$&\'()*+,;=]|%[0-9a-fA-F][0-9a-fA-F])*\\z`', $Opt[$k])) {
            $m[] = $errmarker . "The <code>\$Opt[\"{$k}\"]</code> setting, ‘<code>" . htmlspecialchars($Opt[$k]) . "</code>’, is not a valid URL.  Edit the <code>conf/options.php</code> file to fix this problem.";
        }
    }
    // Unnotified reviews?
    if ($Conf->setting("pcrev_assigntime", 0) > $Conf->setting("pcrev_informtime", 0)) {
        $assigntime = $Conf->setting("pcrev_assigntime");
        $result = Dbl::qe_raw("select paperId from PaperReview where reviewType>" . REVIEW_PC . " and timeRequested>timeRequestNotified and reviewSubmitted is null and reviewNeedsSubmit!=0 limit 1");
        if (edb_nrows($result)) {
            $m[] = "PC review assignments have changed.&nbsp; <a href=\"" . hoturl("mail", "template=newpcrev") . "\">Send review assignment notifications</a> <span class=\"barsep\">·</span> <a href=\"" . hoturl_post("index", "clearnewpcrev={$assigntime}") . "\">Clear this message</a>";
        } else {
            $Conf->save_setting("pcrev_informtime", $assigntime);
        }
    }
    // Review round expired?
    if (count($Conf->round_list()) > 1 && $Conf->time_review_open() && $Conf->missed_review_deadline($Conf->current_round(), true, false)) {
        $any_rounds_open = false;
        foreach ($Conf->defined_round_list() as $i => $rname) {
            if (!$any_rounds_open && !$Conf->missed_review_deadline($i, true, false) && $Conf->setting($Conf->review_deadline($i, true, false))) {
                $any_rounds_open = $rname;
            }
        }
        if ($any_rounds_open) {
            $m[] = "The deadline for the current review round, " . htmlspecialchars($Conf->current_round_name()) . ", has passed. You may want to <a href=\"" . hoturl("settings", "group=reviews") . "\">change the current round</a> to " . htmlspecialchars($any_rounds_open) . ".";
        }
    }
    if (count($m)) {
        $Conf->warnMsg('<div class="multimessage"><div>' . join('</div><div>', $m) . "</div></div>");
    }
}
コード例 #24
0
    $_REQUEST["emailBody"] = $null_mailer->expand($mailTemplates["genericmailtool"]["body"]);
}
if (substr($_REQUEST["subject"], 0, strlen($subjectPrefix)) == $subjectPrefix) {
    $_REQUEST["subject"] = substr($_REQUEST["subject"], strlen($subjectPrefix));
}
if (isset($_REQUEST["cc"]) && $Me->privChair) {
    $_REQUEST["cc"] = simplify_whitespace($_REQUEST["cc"]);
} else {
    if (isset($Opt["emailCc"])) {
        $_REQUEST["cc"] = $Opt["emailCc"] ? $Opt["emailCc"] : "";
    } else {
        $_REQUEST["cc"] = Text::user_email_to(Contact::site_contact());
    }
}
if (isset($_REQUEST["replyto"]) && $Me->privChair) {
    $_REQUEST["replyto"] = simplify_whitespace($_REQUEST["replyto"]);
} else {
    $_REQUEST["replyto"] = defval($Opt, "emailReplyTo", "");
}
// Check or send
if (defval($_REQUEST, "loadtmpl") || defval($_REQUEST, "cancel") || defval($_REQUEST, "psearch")) {
    /* do nothing */
} else {
    if (defval($_REQUEST, "send") && !$recip->error && check_post()) {
        MailSender::send($recip);
    } else {
        if ((@$_REQUEST["check"] || @$_REQUEST["group"] || @$_REQUEST["ungroup"]) && !$recip->error && check_post()) {
            MailSender::check($recip);
        }
    }
}
コード例 #25
0
 public function parse($sv, $si)
 {
     global $Conf;
     $this->nrfj = (object) array();
     $option_error = "Review fields with options must have at least two choices, numbered sequentially from 1 (higher numbers are better) or lettered with consecutive uppercase letters (lower letters are better). Example: <pre>1. Low quality\n    2. Medium quality\n    3. High quality</pre>";
     $rf = ReviewForm::get();
     foreach ($rf->fmap as $fid => $f) {
         $fj = (object) array();
         $sn = simplify_whitespace(defval($sv->req, "shortName_{$fid}", ""));
         if ($sn == "<None>" || $sn == "<New field>" || $sn == "Field name") {
             $sn = "";
         }
         $pos = cvtint(get($sv->req, "order_{$fid}"));
         if ($pos > 0 && $sn == "" && trim(defval($sv->req, "description_{$fid}", "")) == "" && trim(defval($sv->req, "options_{$fid}", "")) == "") {
             $pos = -1;
         }
         if ($sn != "") {
             $fj->name = $sn;
         } else {
             if ($pos > 0) {
                 $sv->set_error("shortName_{$fid}", "Missing review field name.");
             }
         }
         $fj->visibility = get($sv->req, "authorView_{$fid}");
         $x = CleanHTML::basic_clean(defval($sv->req, "description_{$fid}", ""), $err);
         if ($x === false) {
             if (get($f, "description")) {
                 $fj->description = $f->description;
             }
             if ($pos > 0) {
                 $sv->set_error("description_{$fid}", htmlspecialchars($sn) . " description: " . $err);
             }
         } else {
             if (($x = trim($x)) != "") {
                 $fj->description = $x;
             }
         }
         if ($pos > 0) {
             $fj->position = $pos;
         }
         if ($f->has_options) {
             $fj->options = array_values($f->options);
             // default
             if (!$this->check_options($sv, $fid, $fj) && $pos > 0) {
                 $sv->set_error("options_{$fid}", "Invalid options.");
                 if ($option_error) {
                     $sv->set_error(null, $option_error);
                 }
                 $option_error = false;
             }
             $prefixes = array("sv", "svr", "sv-blpu", "sv-publ", "sv-viridis", "sv-viridisr");
             $class_prefix = defval($sv->req, "option_class_prefix_{$fid}", "sv");
             $prefix_index = array_search($class_prefix, $prefixes) ?: 0;
             if (get($sv->req, "option_class_prefix_flipped_{$fid}")) {
                 $prefix_index ^= 1;
             }
             $fj->option_class_prefix = $prefixes[$prefix_index];
         }
         $fj->round_mask = 0;
         if ($rlist = get($sv->req, "round_list_{$fid}")) {
             foreach (explode(" ", trim($rlist)) as $round_name) {
                 $fj->round_mask |= 1 << $Conf->round_number($round_name, false);
             }
         }
         $xf = clone $f;
         $xf->assign($fj);
         $this->nrfj->{$fid} = $xf->unparse_json();
     }
     $sv->need_lock["PaperReview"] = true;
     return true;
 }