function save_password($email, $encoded_password, $iscdb = false) { global $Conf, $Now; $dblink = $iscdb ? Contact::contactdb() : $Conf->dblink; Dbl::qe($dblink, "update ContactInfo set password=?, passwordTime=? where email=?", $encoded_password, $Now, $email); ++$Now; }
function do_setting_update($sv) { global $Conf, $Group, $Me, $Now, $Opt, $OptOverride; // parse settings foreach (Si::$all as $si) { account_value($sv, $si); } // check date relationships foreach (array("sub_reg" => "sub_sub", "final_soft" => "final_done") as $dn1 => $dn2) { list($dv1, $dv2) = [$sv->savedv($dn1), $sv->savedv($dn2)]; } if (!$dv1 && $dv2) { $sv->save($dn1, $dv2); } else { if ($dv2 && $dv1 > $dv2) { $sv->set_error($dn1, unparse_setting_error(Si::get($dn1), "Must come before " . Si::get($dn2, "short_description") . ".")); $sv->set_error($dn2); } } if ($sv->has_savedv("sub_sub")) { $sv->save("sub_update", $sv->savedv("sub_sub")); } if (get($Opt, "defaultSiteContact")) { if ($sv->has_savedv("opt.contactName") && get($Opt, "contactName") === $sv->savedv("opt.contactName")) { $sv->save("opt.contactName", null); } if ($sv->has_savedv("opt.contactEmail") && get($Opt, "contactEmail") === $sv->savedv("opt.contactEmail")) { $sv->save("opt.contactEmail", null); } } if ($sv->has_savedv("resp_active") && $sv->savedv("resp_active")) { foreach (explode(" ", $sv->newv("resp_rounds")) as $i => $rname) { $isuf = $i ? "_{$i}" : ""; if ($sv->newv("resp_open{$isuf}") > $sv->newv("resp_done{$isuf}")) { $sv->set_error("resp_open{$isuf}", unparse_setting_error(Si::get("resp_open"), "Must come before " . Si::get("resp_done", "short_description") . ".")); $sv->set_error("resp_done{$isuf}"); } } } // update 'papersub' if ($sv->has_savedv("pc_seeall")) { // see also conference.php if ($sv->savedv("pc_seeall") <= 0) { $x = "timeSubmitted>0"; } else { $x = "timeWithdrawn<=0"; } $num = Dbl::fetch_ivalue("select paperId from Paper where {$x} limit 1") ? 1 : 0; if ($num != $Conf->setting("papersub")) { $sv->save("papersub", $num); } } // Setting relationships if ($sv->has_savedv("sub_open") && $sv->newv("sub_open", 1) <= 0 && $sv->oldv("sub_open") > 0 && $sv->newv("sub_sub") <= 0) { $sv->save("sub_close", $Now); } if ($sv->has_savedv("msg.clickthrough_submit")) { $sv->save("clickthrough_submit", null); } // make settings $changedn = []; if (!$sv->has_errors() && (count($sv->savedv) || count($sv->save_callbacks))) { $tables = "Settings write"; foreach ($sv->need_lock as $t => $need) { if ($need) { $tables .= ", {$t} write"; } } $Conf->qe("lock tables {$tables}"); // load db settings, pre-crosscheck $dbsettings = array(); $result = Dbl::qe("select name, value, data from Settings"); while ($row = edb_row($result)) { $dbsettings[$row[0]] = $row; } Dbl::free($result); // apply settings foreach ($sv->save_callbacks as $si) { $p = $sv->parser($si); $p->save($sv, $si); } $dv = $aq = $av = array(); foreach ($sv->savedv as $n => $v) { if (substr($n, 0, 4) === "opt." && $v !== null) { $okey = substr($n, 4); $oldv = array_key_exists($okey, $OptOverride) ? $OptOverride[$okey] : get($Opt, $okey); $Opt[$okey] = $v[1] === null ? $v[0] : $v[1]; if ($oldv === $Opt[$okey]) { $v = null; } else { if (!array_key_exists($okey, $OptOverride)) { $OptOverride[$okey] = $oldv; } } } if ($v === null ? !isset($dbsettings[$n]) : isset($dbsettings[$n]) && (int) $dbsettings[$n][1] === $v[0] && $dbsettings[$n][2] === $v[1]) { continue; } $changedn[] = $n; if ($v !== null) { $aq[] = "(?, ?, ?)"; array_push($av, $n, $v[0], $v[1]); } else { $dv[] = $n; } } if (count($dv)) { Dbl::qe_apply("delete from Settings where name?a", array($dv)); //Conf::msg_info(Ht::pre_text_wrap(Dbl::format_query_apply("delete from Settings where name?a", array($dv)))); } if (count($aq)) { Dbl::qe_apply("insert into Settings (name, value, data) values\n\t" . join(",\n\t", $aq) . "\n\ton duplicate key update value=values(value), data=values(data)", $av); //Conf::msg_info(Ht::pre_text_wrap(Dbl::format_query_apply("insert into Settings (name, value, data) values\n\t" . join(",\n\t", $aq) . "\n\ton duplicate key update value=values(value), data=values(data)", $av))); } $Conf->qe("unlock tables"); if (count($changedn)) { $Me->log_activity("Updated settings " . join(", ", $changedn)); } $Conf->load_settings(); // contactdb may need to hear about changes to shortName if ($sv->has_savedv("opt.shortName") && get($Opt, "contactdb_dsn") && ($cdb = Contact::contactdb())) { Dbl::ql($cdb, "update Conferences set shortName=? where dbName=?", $Opt["shortName"], $Opt["dbName"]); } } // update the review form in case it's changed ReviewForm::clear_cache(); if (!$sv->has_errors()) { $Conf->save_session("settings_highlight", $sv->error_fields()); if (count($changedn)) { $Conf->confirmMsg("Changes saved."); } else { $Conf->warnMsg("No changes."); } $sv->report(); redirectSelf(); } else { SettingGroup::crosscheck($sv, $Group); $sv->report(); } }
Dbl::free($result); } if ($papers) { $result = Dbl::ql(Contact::contactdb(), "select confid from Conferences where `dbname`=?", $Opt["dbName"]); $row = Dbl::fetch_first_row($result); if (!$row) { fwrite(STDERR, "Conference is not recored in contactdb\n"); exit(1); } $confid = $row[0]; $result = Dbl::ql($Conf->dblink, "select paperId, title from Paper"); $q = array(); while ($row = edb_row($result)) { $q[] = "(" . $confid . "," . $row[0] . ",'" . sqlq($row[1]) . "')"; } Dbl::free($result); for ($i = 0; $i < count($q); $i += 25) { $xq = array_slice($q, $i, 25); Dbl::ql_raw(Contact::contactdb(), "insert into ConferencePapers (confid,paperId,title) values " . join(",", $xq) . " on duplicate key update title=values(title)"); } } if ($collaborators) { $result = Dbl::ql($Conf->dblink, "select email, collaborators, updateTime, lastLogin from ContactInfo where collaborators is not null and collaborators!=''"); while ($row = edb_row($result)) { $time = (int) $row[2] ?: (int) $row[3]; if ($time > 0) { Dbl::ql(Contact::contactdb(), "update ContactInfo set collaborators=?, updateTime=? where email=? and (collaborators is null or collaborators='' or updateTime<?)", $row[1], $time, $row[0], $time); } } Dbl::free($result); }
{ fwrite(STDERR, $message); exit(1); } // Initialize from an empty database. if (!$Conf->dblink->multi_query(file_get_contents("{$ConfSitePATH}/src/schema.sql"))) { die_hard("* Can't reinitialize database.\n" . $Conf->dblink->error); } while ($Conf->dblink->more_results()) { Dbl::free($Conf->dblink->next_result()); } // No setup phase. $Conf->qe("delete from Settings where name='setupPhase'"); $Conf->load_settings(); // Contactdb. if ($cdb = Contact::contactdb()) { if (!$cdb->multi_query(file_get_contents("{$ConfSitePATH}/test/cdb-schema.sql"))) { die_hard("* Can't reinitialize contact database.\n" . $cdb->error); } while ($cdb->more_results()) { Dbl::free($cdb->next_result()); } } // Create initial administrator user. $Admin = Contact::create(array("email" => "chair@_.com", "name" => "Jane Chair", "password" => "testchair")); $Admin->save_roles(Contact::ROLE_ADMIN | Contact::ROLE_CHAIR | Contact::ROLE_PC, $Admin); // Load data. $json = json_decode(file_get_contents("{$ConfSitePATH}/test/db.json")); if (!$json) { die_hard("* test/testdb.json error: " . json_last_error_msg() . "\n"); }
public function capability_manager($for = null) { global $Opt; if ($for && substr($for, 0, 1) === "U") { if ($cdb = Contact::contactdb()) { return new CapabilityManager($cdb, "U"); } else { return null; } } else { return new CapabilityManager($this->dblink, ""); } }
} else { if ($qreq->fn === "events") { json_exit(["ok" => false]); } } if ($qreq->fn === "searchcompletion") { $s = new PaperSearch($Me, ""); $Conf->ajaxExit(array("ok" => true, "searchcompletion" => $s->search_completion())); } // from here on: `status` and `track` requests if ($qreq->fn === "track") { MeetingTracker::track_api($qreq, $Me); } // may fall through to act like `status` $j = $Me->my_deadlines($Conf->paper); if ($qreq->conflist && $Me->has_email() && ($cdb = Contact::contactdb())) { $j->conflist = array(); $result = Dbl::ql($cdb, "select c.confid, siteclass, shortName, url\n from Roles r join Conferences c on (c.confid=r.confid)\n join ContactInfo u on (u.contactDbId=r.contactDbId)\n where u.email=? order by r.updated_at desc", $Me->email); while ($row = edb_orow($result)) { $row->confid = (int) $row->confid; $j->conflist[] = $row; } } $pj = (object) array(); if ($Conf->paper && $Me->can_view_tags($Conf->paper)) { $Conf->paper->add_tag_info_json($pj, $Me); } if (count((array) $pj)) { $j->p = [$Conf->paper->paperId => $pj]; } $j->ok = true;
public function capability_manager($for) { global $Opt; if (@$Opt["contactdb_dsn"] && ($cdb = Contact::contactdb()) && (is_string($for) && substr($for, 0, 1) === "U" || $for instanceof Contact && $for->contactDbId)) { return new CapabilityManager($cdb, "U"); } else { return new CapabilityManager($this->dblink, ""); } }