예제 #1
0
 function change_grader($grader)
 {
     if (is_object($grader)) {
         $grader = $grader->contactId;
     }
     if ($this->pset->gitless_grades) {
         $q = Dbl::format_query("insert into ContactGrade (cid,pset,gradercid) values (?, ?, ?) on duplicate key update gradercid=values(gradercid)", $this->user->contactId, $this->pset->psetid, $grader);
     } else {
         assert(!!$this->commit);
         if (!$this->repo_grade || !$this->repo_grade->gradehash) {
             $q = Dbl::format_query("insert into RepositoryGrade set repoid=?, pset=?, gradehash=?, gradercid=?, placeholder=0 on duplicate key update gradehash=values(gradehash), gradercid=values(gradercid), placeholder=0", $this->repo->repoid, $this->pset->psetid, $this->commit ?: null, $grader);
         } else {
             $q = Dbl::format_query("update RepositoryGrade set gradehash=?, gradercid=?, placeholder=0 where repoid=? and pset=? and gradehash=?", $this->commit ?: $this->repo_grade->gradehash, $grader, $this->repo->repoid, $this->pset->psetid, $this->repo_grade->gradehash);
         }
         $this->update_commit_info(array("gradercid" => $grader));
     }
     if ($q) {
         Dbl::qe_raw($q);
     }
     $this->grade = $this->repo_grade = false;
 }
예제 #2
0
 public function contactdb_update()
 {
     global $Opt, $Now;
     if (!($cdb = self::contactdb()) || !$this->has_database_account()) {
         return false;
     }
     $update_password = null;
     $update_passwordTime = 0;
     if (!$this->disabled && $this->password && ($this->password[0] !== " " || $this->password[1] === "\$") && $this->passwordTime) {
         $update_password = $this->password;
         $update_passwordTime = $this->passwordTime;
     }
     $idquery = Dbl::format_query($cdb, "select ContactInfo.contactDbId, Conferences.confid, roles, password\n            from ContactInfo\n            left join Conferences on (Conferences.`dbname`=?)\n            left join Roles on (Roles.contactDbId=ContactInfo.contactDbId and Roles.confid=Conferences.confid)\n            where email=?", $Opt["dbName"], $this->email);
     $row = Dbl::fetch_first_row(Dbl::ql_raw($cdb, $idquery));
     if (!$row) {
         Dbl::ql($cdb, "insert into ContactInfo set firstName=?, lastName=?, email=?, affiliation=?, country=?, collaborators=?, password=?, passwordTime=? on duplicate key update firstName=firstName", $this->firstName, $this->lastName, $this->email, $this->affiliation, $this->country, $this->collaborators, $update_password, $update_passwordTime);
         $row = Dbl::fetch_first_row(Dbl::ql_raw($cdb, $idquery));
         $this->contactdb_user_ = false;
     }
     if ($row && $row[3] === null && $update_password) {
         Dbl::ql($cdb, "update ContactInfo set password=?, passwordTime=? where contactDbId=? and password is null", $update_password, $update_passwordTime, $row[0]);
     }
     if ($row && $row[1] && (int) $row[2] != $this->all_roles()) {
         $result = Dbl::ql($cdb, "insert into Roles set contactDbId=?, confid=?, roles=?, updated_at=? on duplicate key update roles=values(roles), updated_at=values(updated_at)", $row[0], $row[1], $this->all_roles(), $Now);
         return !!$result;
     } else {
         return false;
     }
 }
예제 #3
0
 private static function format_log_query($text, $who, $pids)
 {
     $pid = null;
     if (count($pids) == 1) {
         $pid = $pids[0];
     } else {
         if (count($pids) > 1) {
             $text .= " (papers " . join(", ", $pids) . ")";
         }
     }
     return Dbl::format_query("insert into ActionLog set ipaddr=?, contactId=?, paperId=?, action=?", get($_SERVER, "REMOTE_ADDR"), (int) $who, $pid, substr($text, 0, 4096));
 }
 static function options_sql($pj, $paperid)
 {
     $q = [];
     foreach (get($pj, "parsed_options", []) as $id => $ovs) {
         foreach ($ovs as $ov) {
             if (is_int($ov)) {
                 $q[] = "({$paperid},{$id},{$ov},null)";
             } else {
                 $q[] = Dbl::format_query("({$paperid},{$id},?,?)", $ov[0], get($ov, 1));
             }
         }
     }
     sort($q);
     return join(",", $q);
 }
예제 #5
0
require_once "{$ConfSitePATH}/test/setup.php";
// S3 unit tests
$s3d = new S3Document(array("key" => "AKIAIOSFODNN7EXAMPLE", "secret" => "wJalrXUtnFEMI/K7MDENG/bPxRfiCYEXAMPLEKEY", "fixed_time" => gmmktime(0, 0, 0, 5, 24, 2013)));
global $Now;
$Now = gmmktime(0, 0, 0, 5, 24, 2013);
$sig = $s3d->signature("https://examplebucket.s3.amazonaws.com/test.txt", array("Range" => "bytes=0-9"));
xassert_eqq($sig["signature"], "f0e8bdb87c964420e857bd35b5d6ed310bd44f0170aba48dd91039c6036bdb41");
$sig = $s3d->signature("https://examplebucket.s3.amazonaws.com/test%24file.text", array("x-amz-storage-class" => "REDUCED_REDUNDANCY", "method" => "PUT", "Date" => "Fri, 24 May 2013 00:00:00 GMT"), "Welcome to Amazon S3.");
xassert_eqq($sig["signature"], "98ad721746da40c64f1a55b78f14c238d841ea1380cd77a1b5971af0ece108bd");
$sig = $s3d->signature("https://examplebucket.s3.amazonaws.com?lifecycle", array());
xassert_eqq($sig["signature"], "fea454ca298b7da1c68078a5d1bdbfbbe0d65c699e0f91ac7a200a0136783543");
// Dbl::format_query tests
xassert_eqq(Dbl::format_query("Hello"), "Hello");
xassert_eqq(Dbl::format_query("Hello??"), "Hello?");
xassert_eqq(Dbl::format_query("Hello????"), "Hello??");
xassert_eqq(Dbl::format_query("select ?, ?, ?, ?s, ?s, ?s, ?", 1, "a", null, 2, "b", null, 3), "select 1, 'a', NULL, 2, b, , 3");
xassert_eqq(Dbl::format_query_apply("select ?, ?, ?, ?s, ?s, ?s, ?", array(1, "a", null, 2, "b", null, 3)), "select 1, 'a', NULL, 2, b, , 3");
xassert_eqq(Dbl::format_query_apply("select ?{2}, ?{1}, ?, ?s, ?s, ?s, ?", array(1, "a", null, 2, "b", null, 3)), "select 'a', 1, NULL, 2, b, , 3");
xassert_eqq(Dbl::format_query_apply("select ?{2}, ?{1}, ?{ab}, ?{2}s, ?{1}s, ?{ab}s, ?", array(1, "a", "ab" => "Woah", "Leftover")), "select 'a', 1, 'Woah', a, 1, Woah, 'Leftover'");
// Csv::split_lines tests
xassert_array_eqq(CsvParser::split_lines(""), array());
xassert_array_eqq(CsvParser::split_lines("\r"), array("\r"));
xassert_array_eqq(CsvParser::split_lines("\n"), array("\n"));
xassert_array_eqq(CsvParser::split_lines("\r\n"), array("\r\n"));
xassert_array_eqq(CsvParser::split_lines("\r\r\n"), array("\r", "\r\n"));
xassert_array_eqq(CsvParser::split_lines("\r\naaa"), array("\r\n", "aaa"));
xassert_array_eqq(CsvParser::split_lines("\na\r\nb\rc\n"), array("\n", "a\r\n", "b\r", "c\n"));
// random PHP behavior tests
if (PHP_MAJOR_VERSION >= 7) {
    xassert_eqq(substr("", 0, 1), "");
} else {