function showBody()
{
    #----------------------------------------------------------------------
    global $chosenPersonId;
    // simple validation first...
    if (!preg_match('/\\d{4}\\w{4}\\d{2}/', $chosenPersonId)) {
        showErrorMessage('Invalid WCA id Format <strong>[</strong>' . o($chosenPersonId) . '<strong>]</strong>');
        print '<p><a href="persons.php">Click here to search for people.</a></p>';
        return;
    }
    #--- Get all incarnations of the person.
    $persons = dbQuery("\n    SELECT person.name personName, country.name countryName, day, month, year, gender\n    FROM Persons person, Countries country\n    WHERE person.id = '{$chosenPersonId}' AND country.id = person.countryId\n    ORDER BY person.subId\n  ");
    #--- If there are none, show an error and do no more.
    if (!count($persons)) {
        showErrorMessage('Unknown person id <strong>[</strong>' . o($chosenPersonId) . '<strong>]</strong>');
        $namepart = substr($chosenPersonId, 4, 4);
        print '<p><a href="persons.php?pattern=' . urlEncode($namepart) . '">Click to search for people with `' . o($namepart) . '` in their name.</a></p>';
        return;
    }
    #--- Get and show the current incarnation.
    $currentPerson = array_shift($persons);
    extract($currentPerson);
    echo "<h1>{$personName}</h1>";
    #--- Show previous incarnations if any.
    if (count($persons)) {
        echo "<p class='subtitle'>(previously ";
        foreach ($persons as $person) {
            $previous[] = "{$person['personName']}/{$person['countryName']}";
        }
        echo implode(', ', $previous) . ")</p>";
    }
    #--- Show the picture if any.
    $picture = getCurrentPictureFile($chosenPersonId);
    if ($picture) {
        echo "<center><img class='person' src='{$picture}' /></center>";
    }
    #--- Show the In Memoriam if any.
    $inMemoriamArray = array("2008COUR01" => "https://www.worldcubeassociation.org/forum/viewtopic.php?t=2028", "2003LARS01" => "https://www.worldcubeassociation.org/forum/viewtopic.php?t=1982", "2012GALA02" => "https://www.worldcubeassociation.org/forum/viewtopic.php?t=1044", "2008LIMR01" => "https://www.worldcubeassociation.org/forum/viewtopic.php?t=945", "2008KIRC01" => "https://www.worldcubeassociation.org/forum/viewtopic.php?t=470");
    if (array_key_exists($chosenPersonId, $inMemoriamArray)) {
        echo "<center><a target='_blank' href='{$inMemoriamArray[$chosenPersonId]}'>In Memoriam</a></center>";
    }
    #--- Show the details.
    tableBegin('results', 4);
    tableCaption(false, 'Details');
    tableHeader(explode('|', 'Country|WCA Id|Gender|Competitions'), array(3 => 'class="f"'));
    $gender_text = genderText($gender);
    $numberOfCompetitions = dbValue("SELECT count(distinct competitionId) FROM Results where personId='{$chosenPersonId}'");
    tableRow(array($countryName, $chosenPersonId, $gender_text, $numberOfCompetitions));
    tableEnd();
    #--- Try the cache for the results
    # tryCache( 'person', $chosenPersonId );
    #--- Now the results.
    require 'includes/person_personal_records_current.php';
    require 'includes/person_world_championship_podiums.php';
    require 'includes/person_world_records_history.php';
    require 'includes/person_continent_records_history.php';
    require 'includes/person_events.php';
}
function completeId($newSemiId)
{
    #----------------------------------------------------------------------
    global $doesPersonIdExist;
    #--- Load all existing person ids if we haven't done that yet.
    if (!$doesPersonIdExist) {
        foreach (dbQuery("SELECT * FROM Persons") as $person) {
            $doesPersonIdExist[$person['id']] = true;
        }
    }
    #--- Now search for the free running number to append to the semiId.
    foreach (range(1, 99) as $i) {
        $newId = $newSemiId . sprintf("%02d", $i);
        if (!$doesPersonIdExist[$newId]) {
            $doesPersonIdExist[$newId] = true;
            return $newId;
        }
    }
    #--- None found? We're doomed!
    showErrorMessage("Can't append a running number to semiId '{$semiId}'");
}
Example #3
0
        $stmt->execute();
        //Получаем данные SQL запроса
        $rows = $stmt->fetchAll(PDO::FETCH_ASSOC);
        //Если логин совподает, проверяем пароль
        if (count($rows) > 0) {
            //Получаем данные из таблицы
            if (md5(md5($_POST['pass']) . $rows[0]['salt']) == $rows[0]['pass']) {
                $_SESSION['user'] = true;
                //Сбрасываем параметры
                header('Location:http://' . $_SERVER['HTTP_HOST'] . '/admin.php');
                exit;
            } else {
                echo showErrorMessage('Неверный пароль!');
            }
        } else {
            echo showErrorMessage('Логин <b>' . $_POST['login'] . '</b> не найден!');
        }
    }
}
?>
    <title>Авторизация &raquo; Админпанель</title>
    <link rel="stylesheet" type="text/css" href="/engine/admin/styles/auth.css">
    <div class="form" style="height:244px;">
        <div class="header">Панель управления<br>JCat Radio Engine</div>
        <form action="" method="POST">
            <input class="input" required placeholder="Логин" type="text" size="30" name="login">
            <input class="input" required placeholder="Пароль" type="password" size="30" maxlength="20" name="pass">
            <input class="button" type="submit" value="Войти" name="submit">
            <div style="float:left;margin:3px 10px;">
                <a class="lostpassword" href="/admin.php?do=reg">Регистрация</a><br>
                <a class="lostpassword" href="/admin.php?do=lostpassword">Забыли пароль?</a>
function assertFoo($check, $message)
{
    if (!$check) {
        showErrorMessage($message);
    }
}
function installTheme($userfile)
{
    DOCMAN_token::check() or die('Invalid Token');
    // Check that the zlib is available
    if (!extension_loaded('zlib')) {
        HTML_DMThemes::showInstallMessage(_DML_NEED_ZLIB, _DML_INSTALLER_ERROR, 'index.php?option=com_docman&task=cpanel');
        exit;
    }
    $installer = new DOCMAN_InstallerTheme();
    $path = DOCMAN_Compat::mosPathName($userfile);
    if (!is_dir($path)) {
        $path = dirname($path);
    }
    if (!$installer->installPackage($path)) {
        showErrorMessage($installer);
        exit;
    }
    HTML_DMThemes::showInstallMessage('', _DML_SUCCESFULLY_INSTALLED . ' ' . $installer->installFilename(), 'index.php?option=com_docman&section=themes');
}
function getIso2FromCountryId($countryId) {
#----------------------------------------------------------------------
  $country = dbQueryHandle("
    SELECT iso2
    FROM Countries
    WHERE id='$countryId'
  ");
  $row = mysql_fetch_row( $country );
  if ( !$row ){
      showErrorMessage( "'$countryId' is not a known country ID'" );
      return null;
  }
  return $row[0];
}
Example #7
0
                return;
            } else {
                if ($androidVersion == '' && !ctype_alnum($androidVersion)) {
                    showError(ERROR_MISSING_ANDROID_VERSION);
                    return;
                } else {
                    if ($screenSize == '' && !ctype_alnum($screenSize)) {
                        showError(ERROR_MISSING_SCREEN_SIZE);
                        return;
                    } else {
                        if ($price == '' && !ctype_alnum($price)) {
                            showError(ERROR_MISSING_PRICE);
                            return;
                        }
                    }
                }
            }
        }
    }
    if ($isModification) {
        $db->exec(sprintf('UPDATE phone SET name=%s,manufacturer=%s,androidVersion=%s,screenSize=%s,price=%s WHERE id=\'%s\'', protectFields($name, $db), protectFields($manufacturer, $db), protectFields($androidVersion, $db), protectFields($screenSize, $db), protectFields($price, $db), $phoneId));
    } else {
        $db->exec(sprintf('INSERT INTO phone(userId,name,manufacturer,androidVersion,screenSize,price) VALUES (\'%s\',%s,%s,%s,%s,%s)', $userRow['id'], protectFields($name, $db), protectFields($manufacturer, $db), protectFields($androidVersion, $db), protectFields($screenSize, $db), protectFields($price, $db)));
        $phoneId = $db->lastInsertId();
    }
    $phone = array('phone' => array('id' => $phoneId, 'name' => $name, 'manufacturer' => $manufacturer, 'androidVersion' => $androidVersion, 'screenSize' => $screenSize, 'price' => $price));
    header('Content-type: application/json;charset=utf-8');
    echo json_encode($phone);
} catch (Exception $e) {
    showErrorMessage('Erreur : ' . $e->getMessage());
}
require_once 'includes/_framework.php';
$chosenPersonId = getNormalParam('i');
$chosenCompetitions = dbQuery("\n  SELECT \n    competition.*\n  FROM\n    Results result,\n    Competitions competition\n  WHERE 1\n    AND result.personId='{$chosenPersonId}'\n    AND competition.id = result.competitionId\n  GROUP BY\n    competition.id\n  ORDER BY\n    latitude, longitude, year, month, day");
require 'includes/_header.php';
// simple validation first...
if (!preg_match('/\\d{4}\\w{4}\\d{2}/', $chosenPersonId)) {
    showErrorMessage('Invalid WCA id Format <strong>[</strong>' . o($chosenPersonId) . '<strong>]</strong>');
    print '<p><a href="persons.php">Click here to search for people.</a></p>';
    require 'includes/_footer.php';
    die;
}
#--- Get all incarnations of the person.
$persons = dbQuery("\n  SELECT person.name personName, country.name countryName, day, month, year, gender\n  FROM Persons person, Countries country\n  WHERE person.id = '{$chosenPersonId}' AND country.id = person.countryId\n  ORDER BY person.subId\n");
#--- If there are none, show an error and do no more.
if (!count($persons)) {
    showErrorMessage('Unknown person id <strong>[</strong>' . o($chosenPersonId) . '<strong>]</strong>');
    $namepart = substr($chosenPersonId, 4, 4);
    print '<p><a href="persons.php?pattern=' . urlEncode($namepart) . '">Click to search for people with `' . o($namepart) . '` in their name.</a></p>';
    require 'includes/_footer.php';
    die;
}
#--- Get and show the current incarnation.
$currentPerson = array_shift($persons);
echo "<h1>" . o($currentPerson['personName']) . " - Map of Competitions</h1>";
echo "<h2><a href='p.php?i=" . urlEncode($chosenPersonId) . "'>Back to Competitor Page</a></h2>";
// create map markers
$markers = array();
foreach ($chosenCompetitions as $comp) {
    $markers[$comp['id']] = array();
    $markers[$comp['id']]['latitude'] = $comp['latitude'];
    $markers[$comp['id']]['longitude'] = $comp['longitude'];
Example #9
0
function showError($errorCode = '')
{
    // TODO a modifier
    showErrorMessage($errorCode);
}
function addList($list, $legacyId)
{
    #----------------------------------------------------------------------
    $competitions = readDatabaseTableWithId('Competitions');
    list($id, $title, $subtitle, $columnDefs, $rows) = $list;
    $info = isset($list[5]) ? $list[5] : '';
    #--- From column definitions like "[P] Person [N] Appearances [T] | [P] Person [N] Appearances"
    #--- extract classes and names like:
    #--- ('P', 'N', 'T', 'P', 'N', 'f')
    #--- ('Person', 'Appearances, '&nbsp; &nbsp; | &nbsp; &nbsp;', 'Person', 'Appearances', '&nbsp;')
    $columnDefs = "{$columnDefs} [f] &nbsp;";
    $columnDefs = preg_replace('/\\|/', ' &nbsp; &nbsp; | &nbsp; &nbsp; ', $columnDefs);
    preg_match_all('/\\[(\\w+)\\]\\s*([^[]*[^[ ])/', $columnDefs, $matches);
    $columnClasses = $matches[1];
    $columnNames = $matches[2];
    $ctr = 0;
    foreach ($columnClasses as $class) {
        if ($class == 'P') {
        } elseif ($class == 'E') {
        } elseif ($class == 'C') {
        } elseif ($class == 't') {
        } elseif ($class == 'T') {
            $attributes[$ctr] = 'class="L"';
        } elseif ($class == 'N') {
            $attributes[$ctr] = 'class="R2"';
        } elseif ($class == 'n') {
            $attributes[$ctr] = 'class="r"';
        } elseif ($class == 'R') {
            $attributes[$ctr] = 'class="R2"';
        } elseif ($class == 'r') {
            $attributes[$ctr] = 'class="r"';
        } elseif ($class == 'f') {
            $attributes[$ctr] = 'class="f"';
        } else {
            showErrorMessage("Unknown column type <b>'</b>{$class}<b>'</b>");
        }
        $ctr++;
    }
    if ($subtitle) {
        $subtitle = "<span style='color:#999'>({$subtitle})</span>";
    }
    if ($info) {
        $info = htmlEntities($info, ENT_QUOTES);
        $info = "(<a title='{$info}' style='color:#FC0' onclick='alert(\"{$info}\")'>info</a>)";
    }
    $columnCount = count($columnNames);
    echo "<div id='{$id}'>\n";
    TableBegin('results', $columnCount);
    TableCaptionNew(false, $legacyId, "{$title} {$subtitle} {$info}");
    TableHeader($columnNames, $attributes);
    #--- Display the table.
    $rowCtr = 0;
    foreach ($rows as $row) {
        $values = array();
        $numbers = '';
        #    array_unshift( $row, 0 );
        #    foreach( $row as $key => $value ){
        foreach (range(0, $columnCount - 2) as $i) {
            $value = $row[$i];
            $Class = ucfirst($columnClasses[$i]);
            if ($Class == 'P' && $value) {
                $value = personLink($value, extractRomanName(currentPersonName($value)));
            }
            if ($Class == 'E') {
                $value = eventLink($value, eventCellName($value));
            }
            if ($Class == 'C') {
                $value = competitionLink($value, $competitions[$value]['cellName']);
            }
            if ($Class == 'R') {
                $value = formatValue($value, isset($row['eventId']) ? valueFormat($row['eventId']) : 'time');
            }
            $values[] = $value;
            if ($Class == 'N') {
                $numbers .= "{$value}|";
            }
        }
        #--- Add the rank.
        $rowCtr++;
        $rank = isset($prevNumbers) && $numbers == $prevNumbers ? '' : $rowCtr;
        ###  $rank = $rowCtr;
        $prevNumbers = $numbers;
        #    $values[0] = $rank;
        #--- Add the filler column cell.
        $values[] = '';
        #--- Show the row.
        TableRow($values);
    }
    TableEnd();
    echo "</div>\n";
}
 /**
  * for SELECT querys...
  *
  * @param string $table
  * @param string $type
  * @param array $params
  * access public
  */
 public function select($table, $type, $params = array())
 {
     if (in_array($type, array('DB_FIRST', 'DB_ALL', 'DB_COUNT'))) {
         $this->DB_TYPE = $type;
     }
     $params = array_merge(array('cond' => array(), 'limit' => null, 'page' => null, 'fields' => null, 'order' => null, 'group' => null, 'alias' => null, 'joins' => array()), $params);
     if (!is_numeric($params['page']) || intval($params['page']) < 1) {
         $params['page'] = 1;
     }
     if ($params['page'] > 1 && !empty($params['limit'])) {
         $params['offset'] = ($params['page'] - 1) * $params['limit'];
     } else {
         $params['offset'] = 0;
     }
     $query = $this->__buildQuery($params, $table);
     // trying cache querys
     if (Config::read('cache_querys') == 1) {
         if ($this->turnSqlCache($query)) {
             return $this->getSqlCache($query);
         }
     }
     $start = getMicroTime();
     $data = mysql_query($query);
     $took = getMicroTime() - $start;
     // querys list
     $redirect = true;
     if (Config::read('debug_mode') == 1) {
         AtmDebug::addRow('DB Queries', array($query, $took));
         $redirect = false;
     }
     if (!$data) {
         showErrorMessage('Произошла ошибка при запросе к базе данных!', mysql_error() . '<br /><br />' . $query, $redirect, '/');
         die;
     }
     // compact results
     if ($data) {
         if ($type == 'DB_COUNT') {
             //if type is COUNT
             $_result = mysql_result($data, 0);
         } else {
             //if type not COUNT
             $_result = array();
             while ($result = mysql_fetch_assoc($data)) {
                 $_result[] = $result;
             }
         }
     }
     // write cache
     if (Config::read('cache_querys') == 1) {
         $this->writeSqlCache($query, $_result);
     }
     return $_result;
 }
Example #12
0
 /**
  * for SELECT querys...
  *
  * @param string $table
  * @param string $type
  * @param array $params
  * access public
  */
 public function select($table, $type, $params = array())
 {
     $this->queryParams = array();
     if (in_array($type, array('DB_FIRST', 'DB_ALL', 'DB_COUNT'))) {
         $this->DB_TYPE = $type;
     }
     if (!empty($params['alias'])) {
         $this->table_alias = $this->__name($params['alias']);
     }
     $query = $this->__buildQuery($params, $table);
     $this->table_alias = null;
     // trying cache querys
     if (Config::read('cache_querys') == 1) {
         if ($this->turnSqlCache($query)) {
             return $this->getSqlCache($query);
         }
     }
     $start = getMicroTime();
     $data = $this->runQuery($query);
     $took = getMicroTime($start);
     // querys list
     $redirect = true;
     if (Config::read('debug_mode') == 1) {
         AtmDebug::addRow('DB Queries', array($this->getQueryDump($query), $took));
         $redirect = false;
     }
     if (!$data) {
         showErrorMessage('Произошла ошибка при запросе к базе данных!' . '<br /><br />' . $query, $redirect, '/');
         die;
     }
     // compact results
     if ($data) {
         if ($type == 'DB_COUNT') {
             //if type is COUNT
             $_result = $data->fetchColumn();
         } else {
             //if type not COUNT
             //$_result = $data->fetchAll(PDO::FETCH_ASSOC);
             $_result = $this->prepareOutput($data);
         }
     }
     // write cache
     if (Config::read('cache_querys') == 1) {
         $this->writeSqlCache($query, $_result);
     }
     return $_result;
 }
Example #13
0
                $err[] = 'Пользователь с логином: <b>' . $_POST['login'] . '</b> уже зарегестрирован!';
            }
            $sql = 'SELECT `email`
					FROM `jre_users`
					WHERE `email` = :email';
            //Подготавливаем PDO выражение для SQL запроса
            $stmt = $pdo->prepare($sql);
            $stmt->bindValue(':email', $_POST['email'], PDO::PARAM_STR);
            $stmt->execute();
            $rows = $stmt->fetchAll(PDO::FETCH_ASSOC);
            if (count($rows) > 0) {
                $err[] = 'Пользователь с почтой: <b>' . $_POST['email'] . '</b> уже зарегестрирован!';
            }
            //Проверяем наличие ошибок и выводим пользователю
            if (count($err) > 0) {
                echo showErrorMessage($err);
            } else {
                //Получаем ХЕШ соли
                $salt = salt();
                //Солим пароль
                $pass = md5(md5($_POST['pass']) . $salt);
                /*Если все хорошо, пишем данные в базу*/
                $sql = 'INSERT INTO `jre_users`
						VALUES(
								"",
                                :login,
								:pass,
								:email,
								:salt,
								"' . md5($salt) . '",
								0