function hide_var ($name)
{
global $$name;
echo "\n";
// echo "${$name}";
}
function hide_post()
{
global $HTTP_POST_VARS;
reset($HTTP_POST_VARS);
while (list($key, $val) = each($HTTP_POST_VARS)) {
hide_var ("$key");
}
}
function mkdirr($pathname, $mode = null)
{
// Check if directory already exists
if (is_dir($pathname) || empty($pathname)) {
return true;
}
// Ensure a file does not already exist with the same name
if (is_file($pathname)) {
trigger_error('mkdirr() File exists', E_USER_WARNING);
return false;
}
// Crawl up the directory tree
$next_pathname = substr($pathname, 0, strrpos($pathname, DIRECTORY_SEPARATOR));
if (mkdirr($next_pathname, $mode)) {
if (!file_exists($pathname)) {
return mkdir($pathname, $mode);
}
}
return false;
}
function rmdirr($dirname)
{
// Sanity check
if (!file_exists($dirname)) {
return false;
}
// Simple delete for a file
if (is_file($dirname)) {
return unlink($dirname);
}
// Loop through the folder
$dir = dir($dirname);
while (false !== $entry = $dir->read()) {
// Skip pointers
if ($entry == '.' || $entry == '..') {
continue;
}
// Recurse
rmdirr("$dirname/$entry");
}
// Clean up
$dir->close();
return rmdir($dirname);
}
function makeRandomCheck() {
$salt = "abchefghjkmnpqrstuvwxyz0123456789";
srand((double)microtime()*1000000);
$i = 0;
while ($i <= 15) {
$num = rand() % 33;
$tmp = substr($salt, $num, 1);
$check = $check . $tmp;
$i++;
}
return $check;
}
function checkPaper($paperID, $paperTitle, $lastname) {
if (strlen($paperTitle) > 0) {
$query="select id, trim(title), author.check, status
from author
where id = $paperID and trim(title) = trim('$paperTitle')
and concat(name, ' ', co_authors) like '%$lastname%'
and status in ('oral', 'poster')";
}
else {
$query="select id, trim(title), author.check, status
from author
where id = $paperID
and concat(name, ' ', co_authors) like '%$lastname%'
and status in ('oral', 'poster')";
}
$result = mysql_query($query);
return mysql_fetch_row($result);
}
function latex_replace($from, $to, $where) {
$to = latexQuote($to);
return str_replace($from, $to, $where);
}
function latex_replace_title($from, $to, $where) {
$to = latexQuoteTitle($to);
return str_replace($from, $to, $where);
}
function latexQuote($string) {
$string = str_replace('\\', '$\\backslash$', $string);
$string = str_replace('#', '\\#', $string);
$string = str_replace('$', '\\$', $string);
$string = str_replace('%', '\\%', $string);
$string = str_replace('&', '\\&', $string);
$string = str_replace('{', '\\{', $string);
$string = str_replace('}', '\\}', $string);
$string = str_replace('~', '\\~{}', $string);
$string = str_replace('^', '\\^{}', $string);
$string = str_replace('\$\\backslash\$', '$\\backslash$', $string);
return $string;
}
function latexQuoteTitle($string) {
$string = str_replace('%', '\%', $string);
$string = str_replace('&', '\&', $string);
return $string;
}
function htmlQuote($string) {
return str_replace("\n", '
', htmlspecialchars($string, ENT_QUOTES));
}
function myscandir($dir, $exp, $how='name', $desc=0)
{
$r = array();
$dh = @opendir($dir);
if ($dh) {
while (($fname = readdir($dh)) !== false) {
if (preg_match('/^\.$/', $fname)) continue;
if (preg_match('/^\.\.$/', $fname)) continue;
if (preg_match($exp, $fname)) {
$stat = stat("$dir/$fname");
$r[$fname] = ($how == 'name')? $fname: $stat[$how];
}
}
closedir($dh);
if ($desc) {
arsort($r);
}
else {
asort($r);
}
}
return(array_keys($r));
}
function myscandirModified($dir, $exp, $how='name', $desc=0, $modifiedSince) {
$files = myscandir($dir, $exp, $how, $desc);
$tmpcnt = $files;
if ($modifiedSince != '') {
foreach ($files as $i => $value) {
$file = $dir . "/" . $files[$i];
$stats = stat($file);
$modified = $stats[9];
if ($modified < $modifiedSince) {
unset($tmpcnt[$i]);
}
}
}
return $tmpcnt;
}
# retrieves the mapping of table key (usually, primary key) to a given
# column/expression and returns it as associative map
function mysql_fetch_as_mapping($query, $key, $val) {
$arr = array();
$result = mysql_query($query);
if (!$result) {
echo "Error: $query: " . mysql_error();
}
else {
while ($row = mysql_fetch_row($result)) {
$arr[$row[0]] = $row[1];
}
return $arr;
}
}
function mysql_fetch_as_array($query) {
$arr = array();
$result = mysql_query($query);
while ($row = mysql_fetch_row($result)) {
array_push($arr, $row[0]);
}
return $arr;
}
function mysql_fetch_first_row($query) {
$result = mysql_query($query);
if (!$result) {
echo "Error: $query: " . mysql_error();
}
else {
return mysql_fetch_array($result);
}
}
function mysql_fetch_first_value($query) {
$result = mysql_query($query);
if (!$result) {
echo "Error: $query: " . mysql_error();
}
else {
$row = mysql_fetch_row($result);
return $row[0];
}
}
function reformat_time($stime='') {
if ($stime == '') $time = time();
else $time = strtotime($stime);
return date("D M d, g:ia", $time);
}
function format_time($time) {
return date("D M d, g:ia", $time);
}
function read_iccs_properties($prefix = '') {
global $iccs_global_properties;
if ($prefix) {
$iccs_global_properties = mysql_fetch_as_mapping(
"select name, value from properties order by name", "name", "value");
}
else {
$iccs_global_properties = mysql_fetch_as_mapping(
"select name, value from properties
where key like '$prefix%'
order by name", "name", "value");
}
}
function get_iccs_property($name, $default='') {
global $iccs_global_properties;
$val = $iccs_global_properties[$name];
if (!$val) $val = $default;
return $val;
}
function open_popup($url, $width=700, $height=250) {
echo "window.open($url, 'anycontent','toolbar=0,location=0,status=0,menubar=0,scrollbars=0,top='" .
"+Math.floor(screen.height/2-$height/2)+',left='+Math.floor(screen.width/2-$width/2)+" .
"',resizable=1,width='+$width+',height='+$height);";
}
# ICCS-related functions
function showPaperFiles($dir, $exp, $how='name', $desc=0, $modifiedSince,
$hideOlderFiles) {
$files = myscandir($dir, $exp, $how, $desc);
echo "
"; echo " | " . $fgcolorStart . $files[$i] . $fgcolorEnd . " | "; echo "$fgcolorStart" . date("Y-m-d H:i", $modified) . "$fgcolorEnd | "; echo "$fgcolorStart" . round($size/1024) . " KB$fgcolorEnd | "; $result = mysql_query("select page_count, errors from paper_files where inode=$ino"); $row = mysql_fetch_row($result); $pages = $row[0]; $error = $row[1]; if($error!=null) { $list=split("\n",$error); $error=$list[0]; } if($pages==null) { echo "$error | "; } else { echo "$fgcolorStart" . $pages . " pages$fgcolorEnd | "; } echo "
"; } function showPaperDetails($id, $basedir) { $author = mysql_fetch_first_row("select id, name, co_authors, title, abstract, status, email, author.check, id_workshop, notes, presenter from author where id = $id"); echo "
Abstract: " . $author['abstract'] . "
"; $parsed = parse_status($author['status']); echo "Track: $track
"; echo "Status: $parsed"; if ($author['status'] == 'oral' || $author['status'] == 'poster' || $author['status'] == 'invited') { echo "Presenter: " . $author['presenter'] . "
"; $regular_session_id = mysql_fetch_first_value('select id from session_type where title="Regular"'); if ($author['status'] == 'oral') { $sessions = mysql_fetch_as_mapping("select id, concat(code, ': ', title) as label from session where id_type = $regular_session_id and id_workshop = " . $author['id_workshop'] . " order by code", "id", "label"); } else if ($author['status'] == 'poster') { $poster_session_id = mysql_fetch_first_value('select id from session_type where title="Poster"'); $sessions = mysql_fetch_as_mapping("select id, concat(code, ': ', title) as label from session where (id_type = $regular_session_id and id_workshop = " . $author['id_workshop'] . ") or (id_type = $poster_session_id) order by code", "id", "label"); } else if ($author['status'] == 'invited') { $sessions = mysql_fetch_as_mapping("select id, concat(code, ': ', title) as label from session order by code", "id", "label"); } $current_session_id = mysql_fetch_first_value("select id_session from session_schedule_regular where id_author=$id"); echo ""; } $themes = mysql_fetch_as_array("select theme.theme from theme, theme_input where theme.id = theme_input.id_theme and theme_input.id_author = $id"); echo "";
foreach ($themes as $theme) {
echo "$theme
";
}
echo "
Notes: " . $author['notes'] . "
"; echo "Reviever | Rea. | Ori. | Sig. | Rel. | Ove. | Recomm. | Comments for the author | Comments for the committee |
"; } if ($i == 7) { echo "" . $recomm . ""; } else if ($i == 9 || $i == 10) { echo htmlQuote($row[$i]); } else if ($i == 11) { echo "Original review..."; } else { echo $row[$i]; } echo " | "; } } echo "