本文整理汇总了PHP中num函数的典型用法代码示例。如果您正苦于以下问题:PHP num函数的具体用法?PHP num怎么用?PHP num使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了num函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: main
/**
* Método principal del comando
* @author Esteban De La Fuente Rubio, DeLaF (esteban[at]sasco.cl)
* @version 2015-09-30
*/
public function main($ambiente = \sasco\LibreDTE\Sii::PRODUCCION)
{
// obtener conexión a la base de datos
$db =& \sowerphp\core\Model_Datasource_Database::get();
// obtener firma electrónica
try {
$Firma = new \sasco\LibreDTE\FirmaElectronica();
} catch (\sowerphp\core\Exception $e) {
$this->out('<error>No fue posible obtener la firma electrónica</error>');
return 1;
}
// obtener contribuyentes de ambiente de producción
$contribuyentes = \sasco\LibreDTE\Sii::getContribuyentes($Firma, $ambiente);
if (!$contribuyentes) {
$this->out('<error>No fue posible obtener los contribuyentes desde el SII</error>');
return 2;
}
// procesar cada uno de los contribuyentes
$registros = num(count($contribuyentes));
$procesados = 0;
foreach ($contribuyentes as $c) {
// contabilizar contribuyente procesado
$procesados++;
if ($this->verbose >= 1) {
$this->out('Procesando ' . num($procesados) . '/' . $registros . ': contribuyente ' . $c[1]);
}
// agregar y/o actualizar datos del contribuyente si no tiene usuario administrador
list($rut, $dv) = explode('-', $c[0]);
$Contribuyente = new \website\Dte\Model_Contribuyente($rut);
if (!$Contribuyente->usuario) {
$Contribuyente->dv = $dv;
$Contribuyente->razon_social = substr($c[1], 0, 100);
if (isset($c[3][9])) {
$aux = explode('-', $c[3]);
if (isset($aux[2])) {
list($d, $m, $Y) = $aux;
$Contribuyente->resolucion_fecha = $Y . '-' . $m . '-' . $d;
}
}
if (is_numeric($c[2])) {
$Contribuyente->resolucion_numero = (int) $c[2];
}
if (strpos($c[4], '@')) {
$Contribuyente->intercambio_user = substr($c[4], 0, 50);
}
$Contribuyente->modificado = date('Y-m-d H:i:s');
try {
$Contribuyente->save();
} catch (\sowerphp\core\Exception_Model_Datasource_Database $e) {
if ($this->verbose >= 2) {
$this->out('<error>Contribuyente ' . $c[1] . ' no pudo ser guardado en la base de datos</error>');
}
}
}
}
$this->showStats();
return 0;
}
示例2: num
function num($n, $len, $newNum)
{
if ($len == 0) {
if ($n === $newNum) {
return $newNum . ' да.';
} else {
return $newNum . ' не.';
}
}
$newNum = $newNum . $n[$len - 1];
return num($n, $len - 1, $newNum);
}
示例3: user_create
/**
* user_create
*
* creates a new user in the database with the
* given parameters
*
* $data - an array of items to be JSON encoded in
* the data field
* $options - an array of options to be added to the
* options database table for the user
* $mail - an array with the keys 'subject', 'message',
* for the users notification email
*
* @param string $name
* @param string $email
* @param string $password
* @param array $groups
* @param array $data optional
* @param array $options optional
* @param array $mail optional
* @return int|bool $id
*/
function user_create($name, $email, $password, $groups, $data = array(), $options = array(), $mail = true)
{
/**
* if email is in use, return false
* note; one account per email
*/
if (num('select id from ' . DB_USERS . ' where email="' . $email . '"') != 0) {
return false;
}
/**
* add to users table
*/
$hash = md5(mt_rand());
query('insert into ' . DB_USERS . ' values (' . '"",' . '"' . $name . '",' . '"' . $email . '",' . '"' . md5($password) . '",' . '"' . $hash . '",' . '"",' . '"' . json_encode($data) . '"' . ')');
$id = mysql_insert_id();
/**
* add to groups table for each group
*/
foreach ($groups as $group) {
query('insert into ' . DB_USERS_GROUPS . ' values( ' . $id . ', ' . $group . ' )');
}
/**
* create user files directory
*/
$FileManager = FileManager::getInstance();
$FileManager->addDir('users/' . $id);
/**
* add options to options table if nessecary
*/
if (!empty($options)) {
foreach ($options as $name => $value) {
query('insert into ' . DB_OPTIONS . ' values( "' . $name . '", "' . $value . '", "user_' . $id . '"');
}
}
// default email
if ($mail) {
$mail = array();
$mail['subject'] = 'User Activation - Furasta.Org';
$mail['message'] = $name . ',<br/>
<br/>
Please activate your new user by clicking on the link below:<br/>
<br/>
<a href="' . SITE_URL . 'admin/users/activate.php?hash=' . $hash . '">' . $url . '/admin/users/activate.php?hash=' . $hash . '</a><br/>
<br/>
If you are not the person stated above please ignore this email.<br/>
';
}
// send notification email to user
email($email, $mail['subject'], $mail['message']);
cache_clear('DB_USERS');
return $id;
}
示例4: _bot_timbre
/**
* Comando que verifica el timbre del documento (sus datos)
* @param ted String con el timbre electrónico
* @author Esteban De La Fuente Rubio, DeLaF (esteban[at]sasco.cl)
* @version 2015-10-13
*/
protected function _bot_timbre($timbre_xml = null)
{
// si no hay timbre se pide uno
if (!$timbre_xml) {
$this->Bot->send('Ahora envíame el XML del timbre');
$this->setNextCommand('timbre');
} else {
$this->setNextCommand();
$this->Bot->sendChatAction();
$timbre_xml = implode(' ', func_get_args());
$rest = new \sowerphp\core\Network_Http_Rest();
$rest->setAuth(\sowerphp\core\Configure::read('api.default.token'));
$response = $rest->post($this->request->url . '/api/dte/documentos/verificar_ted', json_encode(base64_encode($timbre_xml)));
if ($response['status']['code'] != 200) {
$this->Bot->send($response['body']);
return;
}
$xml = new \SimpleXMLElement(utf8_encode($timbre_xml), LIBXML_COMPACT);
list($rut, $dv) = explode('-', $xml->xpath('/TED/DD/RE')[0]);
$this->Bot->send((new \website\Dte\Admin\Model_DteTipo($xml->xpath('/TED/DD/TD')[0]))->tipo . ' N° ' . $xml->xpath('/TED/DD/F')[0] . ' del ' . \sowerphp\general\Utility_Date::format($xml->xpath('/TED/DD/FE')[0]) . ' por $' . num($xml->xpath('/TED/DD/MNT')[0]) . '.-' . ' emitida por ' . $xml->xpath('/TED/DD/CAF/DA/RS')[0] . ' (' . num($rut) . '-' . $dv . ')' . ' a ' . $xml->xpath('/TED/DD/RSR')[0] . "\n\n" . $response['body']['ESTADO'] . ' - ' . $response['body']['GLOSA_ESTADO'] . "\n" . $response['body']['GLOSA_ERR']);
}
}
示例5: compress_file
function compress_file($file, $tipo = 'js')
{
global $root_dir;
$result = file_get_contents($root_dir . 'img/' . $file);
$len_antes = strlen($result);
echo '<tr><td><b>' . strtoupper($tipo) . '</b></td><td>' . $file . '</td><td align="right"><b>' . num($len_antes) . '</b>bytes</td>';
switch ($tipo) {
case 'js':
$result = minify_js($result);
break;
case 'css':
$result = minify_css($result);
$result = str_replace('url(img/', 'url(lib/kickstart/css/img/', $result);
/* corrige URLs de kickstart (codigo malo) */
$result = str_replace('url(\'img/', 'url(\'lib/kickstart/css/img/', $result);
/* corrige URLs de kickstart (codigo malo) */
break;
}
$len_ahora = strlen($result);
echo '<td align="right">- <b>' . num($len_antes - $len_ahora) . '</b>bytes = </td><td align="right"><b>' . num($len_ahora) . '</b>bytes</td><td align="right">' . num(100 - $len_ahora * 100 / $len_antes, 1) . '%</td></tr>';
$result = '/* ' . $file . ' */' . "\n" . $result . "\n";
return $result;
}
示例6: email_gen
function email_gen()
{
$em = array();
$em_ext = array("@gmail.com", "@yahoo.com", "@AOL.com");
$back = rand(0, 2);
//generates random email address
for ($i = 0; $i < 10; $i++) {
$guess = rand(0, 1);
//returns num 0-9
$num = num();
//returns random letter
$char = char();
if ($guess == 0) {
array_push($em, $char);
} else {
array_push($em, $num);
}
}
//end for loop
//converts array into string
$email = implode($em) . $em_ext[$back];
return $email;
}
示例7: num
<div role="tabpanel">
<ul class="nav nav-tabs" role="tablist">
<li role="presentation" class="active"><a href="#email" aria-controls="email" role="tab" data-toggle="tab">Email recibido</a></li>
<li role="presentation"><a href="#documentos" aria-controls="documentos" role="tab" data-toggle="tab">Documentos</a></li>
</ul>
<div class="tab-content">
<!-- INICIO DATOS BÁSICOS -->
<div role="tabpanel" class="tab-pane active" id="email">
<?php
$de = $DteIntercambio->de;
if ($DteIntercambio->de != $DteIntercambio->responder_a) {
$de .= '<br/><span>' . $DteIntercambio->responder_a . '</span>';
}
new \sowerphp\general\View_Helper_Table([['Recibido', 'De', 'Emisor', 'Firma', 'DTEs', 'Estado', 'Usuario'], [$DteIntercambio->fecha_hora_email, $de, $DteIntercambio->getEmisor()->razon_social, $DteIntercambio->fecha_hora_firma, num($DteIntercambio->documentos), $DteIntercambio->getEstado()->estado, $DteIntercambio->getUsuario()->usuario]]);
?>
<p><strong>Asunto</strong>: <?php
echo $DteIntercambio->asunto;
?>
</p>
<p><?php
echo str_replace("\n", '</p><p>', strip_tags(base64_decode($DteIntercambio->mensaje)));
?>
</p>
<?php
if ($DteIntercambio->mensaje_html) {
?>
<a class="btn btn-default btn-lg btn-block" href="javascript:__.popup('<?php
echo $_base;
示例8: execute
//验证管理员是否登录
$query = "select * from cfc_manage where id={$_SESSION['manage']['id']}";
$result_manage = execute($link, $query);
$data_manage = mysqli_fetch_assoc($result_manage);
$query = "select count(*) from cfc_father_module";
$count_father_module = num($link, $query);
$query = "select count(*) from cfc_son_module";
$count_son_module = num($link, $query);
$query = "select count(*) from cfc_content";
$count_content = num($link, $query);
$query = "select count(*) from cfc_reply";
$count_reply = num($link, $query);
$query = "select count(*) from cfc_member";
$count_member = num($link, $query);
$query = "select count(*) from cfc_manage";
$count_manage = num($link, $query);
if ($data_manage['level'] == '0') {
$data_manage['level'] = '超级管理员';
} else {
$data_manage['level'] = '普通管理员';
}
$template['title'] = '系统信息';
$template['css'] = array('style/public.css');
include 'inc/header.inc.php';
?>
<div id="main">
<div class="title">系统信息</div>
<div class="explain">
<ul>
<li>|- 您好,<?php
echo $data_manage['name'];
示例9: boton
if ($r2['cargo'] == 'true') {
$activos[] = '<tr>
<td>' . ($asignador ? '<form action="/accion.php?a=cargo&b=del&ID=' . $r['cargo_ID'] . '" method="post">
<input type="hidden" name="user_ID" value="' . $r2['user_ID'] . '" />' . boton('X', 'submit', '¿Seguro que quieres QUITAR el cargo a ' . strtoupper($r2['nick']) . '?', 'small red') . '</form>' : '') . '</td>
<td align="right">' . ++$activos_num . '.</td>
<td><img src="' . IMG . 'cargos/' . $r['cargo_ID'] . '.gif" alt="icono ' . $r['nombre'] . '" width="16" height="16" border="0" style="margin-bottom:-3px;" /> <b>' . crear_link($r2['nick']) . '</b></td>
<td align="right" class="gris">' . timer($r2['fecha_last']) . '</td>
</tr>';
} else {
$candidatos[] = '<tr>
<td>' . ($asignador ? '<form action="/accion.php?a=cargo&b=add&ID=' . $r['cargo_ID'] . '" method="POST">
<input type="hidden" name="user_ID" value="' . $r2['user_ID'] . '" />' . boton('Asignar', 'submit', false, 'small blue') . '</form>' : '') . '</td>
<td><b>' . crear_link($r2['nick']) . '</b></td>
<td align="right" class="gris">' . timer($r2['fecha_last']) . '</td>
<td align="right">' . confianza($r2['voto_confianza']) . '</td>
<td align="right"><b>' . num($r2['nota'], 1) . '</b></td>
</tr>';
}
}
}
$txt .= '<table border="0"><tr><td valign="top">
<table border="0">
<tr>
<th></th>
<th colspan="2" align="left">' . $r['nombre'] . ' <span style="font-weight:normal;">(' . count($activos) . ')</span></th>
<th style="font-weight:normal;">Último acceso</th>
</tr>
' . implode('', $activos) . '
</table>
示例10: foreach
echo $Emisor->razon_social;
?>
.</p>
<div class="text-right">
<a href="<?php
echo $_base;
?>
/dte/dte_recibidos/agregar" class="btn btn-default">
<span class="fa fa-plus"></span>
Agregar DTE recibido
</a>
<br/><br/>
</div>
<?php
foreach ($documentos as &$d) {
$acciones = '<a href="' . $_base . '/dte/dte_recibidos/modificar/' . $d['emisor'] . '/' . $d['dte'] . '/' . $d['folio'] . '" title="Modificar DTE" class="btn btn-default' . ($d['intercambio'] ? ' disabled' : '') . '"><span class="fa fa-edit"></span></a>';
$acciones .= ' <a href="' . $_base . '/dte/dte_intercambios/pdf/' . $d['intercambio'] . '" title="Descargar PDF del DTE" class="btn btn-default' . (!$d['intercambio'] ? ' disabled' : '') . '" role="button"><span class="fa fa-file-pdf-o"></span></a>';
$d[] = $acciones;
$d['total'] = num($d['total']);
unset($d['emisor'], $d['dte']);
}
$f = new \sowerphp\general\View_Helper_Form(false);
array_unshift($documentos, [$f->input(['type' => 'select', 'name' => 'dte', 'options' => ['' => 'Todos'] + $tipos_dte, 'value' => isset($search['dte']) ? $search['dte'] : '']), $f->input(['name' => 'folio', 'value' => isset($search['folio']) ? $search['folio'] : '', 'check' => 'integer']), $f->input(['name' => 'emisor', 'value' => isset($search['emisor']) ? $search['emisor'] : '', 'check' => 'integer', 'placeholder' => 'RUT sin dv']), $f->input(['type' => 'date', 'name' => 'fecha', 'value' => isset($search['fecha']) ? $search['fecha'] : '', 'check' => 'date']), $f->input(['name' => 'total', 'value' => isset($search['total']) ? $search['total'] : '', 'check' => 'integer']), $f->input(['name' => 'intercambio', 'value' => isset($search['intercambio']) ? $search['intercambio'] : '', 'check' => 'integer']), $f->input(['type' => 'select', 'name' => 'usuario', 'options' => ['' => 'Todos'] + $usuarios, 'value' => isset($search['usuario']) ? $search['usuario'] : '']), '<button type="submit" class="btn btn-default"><span class="glyphicon glyphicon-search" aria-hidden="true"></span></button>']);
array_unshift($documentos, ['Documento', 'Folio', 'Emisor', 'Fecha', 'Total', 'Intercambio', 'Usuario', 'Acciones']);
// renderizar el mantenedor
$maintainer = new \sowerphp\app\View_Helper_Maintainer(['link' => $_base . '/dte/dte_recibidos', 'linkEnd' => $searchUrl]);
$maintainer->setId('dte_recibidos_' . $Emisor->rut);
$maintainer->setColsWidth([null, null, null, null, null, null, null, 100]);
echo $maintainer->listar($documentos, $paginas, $pagina, false);
示例11: addslashes
/**
* make sure ajax script was loaded and user is
* logged in
*/
if (!defined('AJAX_LOADED') || !defined('AJAX_VERIFIED')) {
die;
}
$name = addslashes(@$_POST['name']);
$perms = addslashes(@$_POST['perms']);
/**
* validate post info
*/
if (empty($name)) {
die('error');
}
/**
* check if group name is used already
*/
if (num('select name from ' . DB_GROUPS . ' where name="' . $name . '"') != 0) {
die('error');
}
/**
* add group to database
*/
mysql_query('insert into ' . DB_GROUPS . ' values( "", "' . $name . '", "' . $perms . '" )');
$id = mysql_insert_id();
// make group dirs
Group::createGroupDirs($id);
// clear caches
cache_clear('DB_USERS');
die(print $id);
示例12: num
$txt .= '<h1 class="quitar">Censo:</h1>';
}
if ($_GET['b'] == 'busqueda') {
$busqueda = $_GET['c'];
} else {
$busqueda = '';
}
$txt .= '
<div style="float:right;">
<input name="qcmq" size="10" value="' . $busqueda . '" type="text" id="cmq">
<input value="Buscador de perfiles" type="submit" onclick="var cmq = $(\'#cmq\').attr(\'value\'); window.location.href=\'/info/censo/busqueda/\'+cmq+\'/\'; return false;">
</div>
<p>' . $p_paginas . '</p>
<p><abbr title="Numero de ciudadanos en la plataforma ' . PAIS . '"><b>' . num($pol['config']['info_censo']) . '</b> ciudadanos de ' . PAIS . '</abbr> (<abbr title="Ciudadanos -no nuevos- que entraron en las últimas 24h, en la plataforma ' . PAIS . '">activos <b>' . $censo_activos . '</b></abbr>, <abbr title="Ciudadanos activos en todo VirtualPol">activos global <b>' . $censo_activos_vp . '</b></abbr>)
' . (ECONOMIA ? ' | <a href="/control/expulsiones" class="expulsado">Expulsados</a>: <b>' . $censo_expulsados . '</b> | <a href="/info/censo/riqueza" title="Los ciudadanos con más monedas.">Ricos</a>' : '') . ' | <a href="/info/censo/SC" title="Todos los ciudadanos registrados en VirtualPol globalmente">Censo de VirtualPol</a>
</p>
<table border="0" cellspacing="2" cellpadding="0" class="pol_table">
<tr>
<th></th>
' . (ASAMBLEA ? '' : '<th style="font-size:18px;"><a href="/info/censo/nivel">Nivel</a></th>') . '
<th></th>
<th style="font-size:18px;"><a href="/info/censo/nombre">Nick</a></th>
<th style="font-size:18px;" colspan="2"><a href="/info/censo/confianza">Confianza</a></th>
' . (ASAMBLEA ? '' : '<th style="font-size:18px;"><a href="/info/censo/afiliacion">Afil</a></th>') . '
<th style="font-size:18px;"><a href="/info/censo/online">Online</a></th>
<th style="font-size:18px;"><a href="/info/censo/' . $old . '">Antigüedad</a></th>
<!--<th style="font-size:18px;"><a href="/info/censo/elec"><abbr title="Elecciones en las que ha participado">Elec</abbr></a></th>-->
示例13: elseif
</table>
</center>';
if (!$pol['nick']) {
$txt .= '<p style="text-align:center;"><span class="amarillo" style="padding:17px 9px 13px 9px;"><input value="REGISTRAR CIUDADANO" onclick="window.location.href=\'' . REGISTRAR . '\';" type="button" style="font-size:18px;height:40px;" /></span></p>';
} elseif ($pol['pais'] == 'ninguno') {
$txt .= '<p>' . boton('Solicitar ciudadania', REGISTRAR) . '</p>';
}
$time_pre = date('Y-m-d H:i:00', time() - 3600);
// 1 hora
$result = mysql_query("SELECT nick, pais, estado\r\nFROM users \r\nWHERE fecha_last > '" . $time_pre . "' AND estado != 'expulsado'\r\nORDER BY fecha_last DESC", $link);
while ($r = mysql_fetch_array($result)) {
$li_online_num++;
$gf['censo_online'][$r['pais']]++;
$pais_url = strtolower($r['pais']);
if ($pais_url == 'ninguno') {
$pais_url = 'vp';
}
$li_online .= ' <a href="http://' . $pais_url . '.' . DOMAIN . '/perfil/' . $r['nick'] . '" class="nick redondeado ' . $r['estado'] . '" style="padding:2px;line-height:25px;background:' . $vp['bg'][$r['pais']] . ';">' . $r['nick'] . '</a>';
}
$txt .= '<br />
<div class="amarillo" style="width:90%;margin:0 auto;">
<table border="0">
<tr>
<td valign="top"><b style="font-size:34px;">' . num($li_online_num) . '</b></td>
<td>Ciudadanos online: ' . $li_online . '</td>
</tr>
</table></div>';
$txt_header .= '<style type="text/css">td b { font-size:15px; }</style>';
include 'theme.php';
示例14: edit_staff
public function edit_staff($parametr)
{
$data = connectDb::db()->prepare("UPDATE staff SET " . $parametr['parametr'] . " = ? WHERE ID = ?");
switch ($parametr['parametr']) {
case 'Date_of_birth':
$masTime = explode("/", $parametr['text']);
$parametr['text'] = mktime(0, 0, 0, $masTime[1], $masTime[2], $masTime[0]);
break;
case 'ID_role':
function num($param)
{
$data = connectDb::db()->prepare('SELECT ID FROM role WHERE Name = ?');
$data->execute([$param]);
return $data->fetch(PDO::FETCH_COLUMN);
}
$var = num($parametr['text']);
if (empty($var)) {
$data2 = connectDb::db()->prepare('INSERT INTO role(Name) VALUES(?)');
$data2->execute([$parametr['text']]);
}
$parametr['text'] = num($parametr['text']);
break;
}
$data->execute([$parametr['text'], $parametr['id']]);
}
示例15: mysql_query
$result = mysql_query("SELECT pais FROM users WHERE ID = '" . $pol['user_ID'] . "' LIMIT 1", $link);
while ($r = mysql_fetch_array($result)) {
$user_pais = $r['pais'];
}
if ($pol['user_ID'] and $tiene_kick != true and $user_pais == 'ninguno' and $pol['estado'] == 'turista' and !in_array($_POST['pais'], $vp['paises_congelados'])) {
mysql_query("UPDATE users SET estado = 'ciudadano', pais = '" . $_POST['pais'] . "' WHERE estado = 'turista' AND pais = 'ninguno' AND ID = '" . $pol['user_ID'] . "' LIMIT 1", $link);
if ($pol['pols'] > 0 and $_POST['pais'] != '15M' and $_POST['pais'] != '15MBCN') {
$trae = ', trayendo consigo: ' . pols($pol['pols']) . ' ' . MONEDA;
} else {
$trae = '';
}
$result2 = mysql_query("SELECT COUNT(*) AS num FROM users WHERE estado = 'ciudadano' AND pais = '" . $_POST['pais'] . "'", $link);
while ($r2 = mysql_fetch_array($result2)) {
$ciudadanos_num = $r2['num'];
}
evento_chat('<b>[#] Nuevo ciudadano</b> de <b>' . $_POST['pais'] . '</b> <span style="color:grey;">(<b>' . num($ciudadanos_num) . '</b> ciudadanos, <b><a href="http://' . strtolower($_POST['pais']) . '.' . DOMAIN . '/perfil/' . $pol['nick'] . '/" class="nick">' . $pol['nick'] . '</a></b>)</span>', 0, 0, false, 'e', $_POST['pais'], $r['nick']);
mysql_query("INSERT INTO " . strtolower($_POST['pais']) . "_log \r\n(time, user_ID, user_ID2, accion, dato) \r\nVALUES ('" . date('Y-m-d H:i:s') . "', '" . $pol['user_ID'] . "', '" . $pol['user_ID'] . "', '2', '')", $link);
unset($_SESSION);
session_unset();
session_destroy();
redirect('http://' . strtolower($_POST['pais']) . '.' . DOMAIN . '/');
} else {
redirect(REGISTRAR);
}
break;
default:
$verror = ' ';
break;
}
if ($pol['estado'] == 'ciudadano') {
// load config full