本文整理汇总了PHP中o函数的典型用法代码示例。如果您正苦于以下问题:PHP o函数的具体用法?PHP o怎么用?PHP o使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了o函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getEventsByTarget
static function getEventsByTarget($deviceDS)
{
$where = array('e_code LIKE ?', 'e_code LIKE ?', 'e_code LIKE ?');
$searchPatterns = array('%' . $deviceDS['d_id'] . '%', '%' . @first($deviceDS['d_alias'], 'NOMATCH') . '%');
return o(db)->get('SELECT * FROM #events WHERE
' . implode(' OR ', $where), $searchPatterns);
}
示例2: render
public function render()
{
if (!$this->value_is_valid) {
$this->attribute("ERROR");
}
$output = "<div class='form-element-wrapper'>";
if ($this->label && $this->attributes['id']) {
$output .= "<span id='" . o($this->attributes['id']) . "'>" . o($this->label) . ": </span>";
}
$output .= "<span " . $this->getAttributeString() . ">";
foreach ($this->options as $value => $option) {
$option = o($option);
$value = o($value);
$output .= "<span class='form-element-radio-option'>";
if ($option) {
$output .= "<label for='" . o($this->attributes['id']) . "-{$value}'>{$option}: </label>";
}
if ($value == $this->selected_option) {
$output .= "<input type='radio' name='" . o($this->name) . "' id='" . o($this->attributes['id']) . "-{$value}' value='{$value}' checked='checked' />";
} else {
$output .= "<input type='radio' name='" . o($this->name) . "' id='" . o($this->attributes['id']) . "-{$value}' value='{$value}' />";
}
$output .= "</span>";
}
$output .= "</span>";
$output .= "</div>";
return $output;
}
示例3: showBody
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';
}
示例4: ajax_getstate
function ajax_getstate()
{
$r = array();
foreach (o(db)->get('SELECT * FROM devices
ORDER BY d_room, d_key') as $d) {
$r['d' . $d['d_id']] = array('id' => $d['d_id'], 'state' => $d['d_state'], 'd_name' => $d['d_name']);
}
print json_encode($r);
}
示例5: getData
function getData()
{
$this->fields = o(db)->fields($this->props['table']);
$this->prepareFieldProperties();
if (sizeof($this->props['cols']) == 0) {
$this->makeAutoColumns();
}
$this->data = o(db)->get('SELECT * FROM ?', array('$' . $this->props['table']));
return $this;
}
示例6: render
public function render()
{
$output = parent::render();
$output .= "<div class='form-element-wrapper'>";
if ($this->label && $this->attributes['id']) {
$output .= "<label for='" . o($this->attributes['id']) . "'>" . o($this->label) . ": </label>";
}
$output .= "<input" . $this->getAttributeString() . "/>";
$output .= "</div>";
return $output;
}
示例7: getGroupsByDevice
static function getGroupsByDevice($deviceDS)
{
$matchingGroups = array();
foreach (o(db)->get('SELECT * FROM #nvstore WHERE nv_key LIKE "group/%" ORDER BY nv_key') as $grpData) {
$gName = $grpData['nv_key'];
CutSegment('/', $gName);
$gList = json_decode($grpData['nv_data']);
if (is_array($gList) && array_search($deviceDS['d_key'], $gList) !== false) {
$matchingGroups[] = $gName;
}
}
return $matchingGroups;
}
示例8: newRow
public function newRow($data = array())
{
$object = o(sha1(time() . $this->settings['entity'] . session_id() . Utils::token()));
$object->thin_litedb = $this;
$object->id = null;
if (count($data) && Arrays::isAssoc($data)) {
foreach ($this->settings['modelFields'] as $field => $infos) {
$value = ake($field, $data) ? $data[$field] : null;
$object->{$field} = $value;
}
}
return $object;
}
示例9: signin
function signin()
{
if ($_POST['fid'] == sha1($_SESSION['fid'])) {
$uds = o(db)->getDSMatch('accounts', array('a_username' => trim($_POST['username']), 'a_password' => sha1($_POST['password'])));
if ($uds['a_key'] > 0) {
WriteToFile('log/account.log', date('Y-m-d H:i:s') . ' (i) ' . $_SERVER['HTTP_X_FORWARDED_FOR'] . ' : ' . $_SERVER['REMOTE_ADDR'] . ' sign in with ' . trim($_POST['username']) . '/***' . chr(10));
$_SESSION['uid'] = $uds['a_key'];
$_SESSION['ds'] = $uds;
header('location: ./?');
die;
} else {
WriteToFile('log/account.log', date('Y-m-d H:i:s') . ' (f) ' . $_SERVER['HTTP_X_FORWARDED_FOR'] . ' : ' . $_SERVER['REMOTE_ADDR'] . ' sign in failed with ' . trim($_POST['username']) . '/***' . chr(10));
?>
<div style="text-align: center">Error signing in, try again.</div><?php
}
} else {
WriteToFile('log/account.log', date('Y-m-d H:i:s') . ' (a) ' . $_SERVER['HTTP_X_FORWARDED_FOR'] . ' : ' . gethostbyaddr($_SERVER['HTTP_X_FORWARDED_FOR']) . ' signin page ' . chr(10));
}
}
示例10: initController
function initController($controllerName)
{
$controllerName = first($controllerName, cfg('service/defaultcontroller'));
$this->controllerName = safeName($controllerName);
$this->controllerFile = 'mvc/' . strtolower($this->controllerName) . '/' . strtolower($this->controllerName) . '.controller.php';
if (!file_exists($this->controllerFile)) {
header($_SERVER["SERVER_PROTOCOL"] . " 404 Not Found");
header('Status: 404 Not Found');
die('File not found at: ' . $_SERVER['REQUEST_URI'] . '<br/>Controller: ' . $this->controllerName);
}
require_once $this->controllerFile;
$this->controllerClassName = $this->controllerName . 'Controller';
$this->controller = o(new $this->controllerClassName($this->controllerName), 'controller');
if (is_callable(array($this->controller, '__init'))) {
$this->controller->__init();
}
$_REQUEST['controller'] = $this->controllerName;
profile_point('H2Dispatcher.initController(' . $this->controllerName . ')');
return $this;
}
示例11: render
public function render()
{
$output = parent::render();
$output .= "<div class='form-element-wrapper'>";
if ($this->label && $this->attributes['id']) {
$output .= "<label for='" . o($this->attributes['id']) . "'>" . o($this->label) . ": </label>";
}
$output .= "<select" . $this->getAttributeString() . ">";
foreach ($this->options as $value => $option) {
$option = o($option);
$value = o($value);
if ($value == $this->selected_option) {
$output .= "<option selected value='{$value}'>{$option}</option>";
} else {
$output .= "<option value='{$value}'>{$option}</option>";
}
}
$output .= "</select>";
$output .= "</div>";
return $output;
}
示例12: group_delete
function group_delete()
{
o(db)->remove('groups', $_REQUEST['id']);
$this->viewName = 'groups';
}
示例13: listCompetitions
function listCompetitions () {
#----------------------------------------------------------------------
global $chosenEventId, $chosenYears, $chosenRegionId, $chosenPatternHtml;
global $chosenList, $chosenMap;
global $chosenCompetitions;
$chosenCompetitions = getCompetitions( $chosenList );
tableBegin( 'results', 5 );
tableCaption( false, spaced(array( eventName($chosenEventId), chosenRegionName(), $chosenYears, $chosenPatternHtml ? "\"$chosenPatternHtml\"" : '' )));
if( $chosenList ){
tableHeader( explode( '|', 'Year|Date|Name|Country, City|Venue' ),
array( 4 => 'class="f"' ));
foreach( $chosenCompetitions as $competition ){
extract( $competition );
if( isset( $previousYear ) && $year != $previousYear )
tableRowEmpty();
$previousYear = $year;
$isPast = wcaDate( 'Ymd' ) > (10000*$year + 100*$month + $day);
tableRow( array(
$year,
competitionDate( $competition ),
$isPast ? competitionLink( $id, $cellName ) : (( $showPreregForm || $showPreregList ) ? competitionLinkClassed( 'rg', $id, $cellName ) : competitionLinkClassed( 'fc', $id, $cellName )),
"<b>$countryName</b>, $cityName",
processLinks( $venue )
));
}
}
tableEnd();
if( $chosenMap ) {
// 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'];
$markers[$comp['id']]['info'] = "<a href='c.php?i=".$comp['id']."'>" . o($comp['cellName']) . "</a><br />"
. date("M j, Y", mktime(0,0,0,$comp['month'],$comp['day'],$comp['year']))
. " - " . o($comp['cityName']);
}
displayMap($markers);
}
}
示例14: log_error
/**
* Logs an error message to the error log. A newline character is appended to the message.
* The given message is also echoed to the console.
*
* @param $message string the message to log.
*/
function log_error(string $message)
{
global $board;
o($message);
file_put_contents($board . '.error', date("c: ") . $message . PHP_EOL, FILE_APPEND);
}
示例15: container
function container()
{
return o('thinContainer');
}