本文整理汇总了PHP中leading_zero函数的典型用法代码示例。如果您正苦于以下问题:PHP leading_zero函数的具体用法?PHP leading_zero怎么用?PHP leading_zero使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了leading_zero函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: time_parser
function time_parser($detik)
{
if ($detik > 60) {
$menit = floor($detik / 60);
if ($menit > 60) {
$jam = floor($menit / 60);
$sisa = $menit % 60;
return leading_zero($jam, 2) . ":" . leading_zero($sisa, 2);
} else {
return "00:" . leading_zero($menit, 2);
}
} else {
return "00:00";
}
}
示例2: leading_zero
protected function leading_zero($num, $places = 0)
{
if (defined('STRICT_TYPES') && CAMEL_CASE == '1') {
return (string) self::parameters(['num' => [DT::INT64, DT::UINT64], 'places' => DT::UINT8])->call(__FUNCTION__)->with($num, $places)->returning(DT::STRING);
} else {
return (string) leading_zero($num, $places);
}
}
示例3: leading_zero
if (count($error) > 0) {
error('admin.php?action=members&job=edit&id='.$query['id'], $error);
}
else {
// Now we create the birthday...
if (empty($query['birthmonth']) || empty($query['birthday'])) {
$query['birthmonth'] = 0;
$query['birthday'] = 0;
$query['birthyear'] = 0;
}
if (empty($_POST['birthyear'])) {
$query['birthyear'] = 1000;
}
$query['birthmonth'] = leading_zero($query['birthmonth']);
$query['birthday'] = leading_zero($query['birthday']);
$query['birthyear'] = leading_zero($query['birthyear'], 4);
$bday = $query['birthyear'].'-'.$query['birthmonth'].'-'.$query['birthday'];
$query['icq'] = str_replace('-', '', $query['icq']);
if (!is_id($query['icq'])) {
$query['icq'] = 0;
}
if (!empty($query['pw']) && strlen($query['pw']) >= $config['minpwlength']) {
$md5 = md5($query['pw']);
$update_sql = ", pw = '{$md5}' ";
}
else {
$update_sql = ' ';
}
示例4: cb_plain_code
function cb_plain_code($matches)
{
global $lang;
$pid = $this->noparse_id();
list(, , $code) = $matches;
$rows = explode("\n", $code);
$code = $this->code_prepare($code);
if (count($rows) > 1) {
$a = 0;
$code = '';
$lines = strlen(count($rows));
foreach ($rows as $row) {
$a++;
$code .= leading_zero($a, $lines) . ": {$row}\n";
}
$this->noparse[$pid] = "\n" . $lang->phrase('bb_sourcecode') . "\n-------------------\n{$code}-------------------\n";
} else {
$this->noparse[$pid] = $code;
}
return '<!PID:' . $pid . '>';
}
示例5: error
if (($_POST['birthyear'] < gmdate('Y') - 120 || $_POST['birthyear'] > gmdate('Y')) && $_POST['birthyear'] != 0) {
$error[] = $lang->phrase('editprofile_birthyear_incorrect');
}
if (strxlen($_POST['fullname']) > 128) {
$error[] = $lang->phrase('editprofile_fullname_incorrect');
}
if (count($error) > 0) {
error($error, "editprofile.php?action=profile" . SID2URL_x);
} else {
// Now we create the birthday...
if (!$_POST['birthmonth'] && !$_POST['birthday'] && !$_POST['birthyear']) {
$bday = '0000-00-00';
} else {
$_POST['birthmonth'] = leading_zero($_POST['birthmonth']);
$_POST['birthday'] = leading_zero($_POST['birthday']);
$_POST['birthyear'] = leading_zero($_POST['birthyear'], 4);
$bday = $_POST['birthyear'] . '-' . $_POST['birthmonth'] . '-' . $_POST['birthday'];
}
$_POST['icq'] = str_replace('-', '', $_POST['icq']);
if (!is_id($_POST['icq'])) {
$_POST['icq'] = 0;
}
if ($config['changename_allowed'] == 1) {
$changename = ", name = '{$_POST['name']}'";
} else {
$changename = '';
}
$db->query("UPDATE {$db->pre}user SET icq = '{$_POST['icq']}', yahoo = '{$_POST['yahoo']}', aol = '{$_POST['aol']}', msn = '{$_POST['msn']}', jabber = '{$_POST['jabber']}', birthday = '{$bday}', gender = '{$_POST['gender']}', hp = '{$_POST['hp']}', signature = '{$_POST['signature']}', location = '{$_POST['location']}', fullname = '{$_POST['fullname']}', mail = '{$_POST['email']}'{$changename} WHERE id = '{$my->id}' LIMIT 1", __LINE__, __FILE__);
ok($lang->phrase('data_success'), "editprofile.php?action=profile" . SID2URL_x);
}
} elseif ($_GET['action'] == "settings") {
示例6: getTimezone
/**
* Returns the timezone for the current user (GMT +/-??:?? or just GMT).
*/
function getTimezone($base = null) {
global $my, $lang;
$tz = $lang->phrase('gmt');
if ($base === null || $base === '') {
$base = $my->timezone;
}
if ($base != 0) {
preg_match('~^(\+|-)?(\d{1,2})\.?(\d{0,2})?$~', $base, $parts);
$parts[2] = intval($parts[2]);
$parts[3] = intval($parts[3]);
}
else {
$parts = array(
1 => '',
2 => 0,
3 => 0
);
}
$summer = (date('I', times()) == 1);
if ($summer && $parts[1] == '-') {
$parts[2] = $parts[2] - 1;
}
else if ($summer) {
$parts[2] = $parts[2] + 1;
}
if ($parts[2] != 0) {
if (empty($parts[1])) {
$parts[1] = '+';
}
$parts[2] = leading_zero($parts[2]);
$parts[3] = $parts[3]/100*60;
$parts[3] = leading_zero($parts[3]);
$tz .= ' '.$parts[1].$parts[2].':'.$parts[3];
}
return $tz;
}
示例7: substr
}
// Get the correct formatted timzone
$posneg = substr($my->timezone, 0, 1);
if ($posneg != '+' && $posneg != '-') {
$posneg = '+';
$mtz = $my->timezone;
} else {
$mtz = substr($my->timezone, 1);
}
if (strpos($mtz, '.') === false) {
$tz3 = '00';
$tz2 = leading_zero($mtz, 2);
} else {
$tz = explode('.', $mtz);
$tz3 = $tz[1] / 100 * 60;
$tz2 = leading_zero($tz[1], 2);
}
define("TIME_ZONE", $posneg . $tz2 . ':' . $tz3);
// Include the Feedcreator class
include "classes/class.feedcreator.php";
BBProfile($bbcode);
($code = $plugins->load('external_start')) ? eval($code) : null;
$action = strtoupper($_GET['action']);
$data = file('data/feedcreator.inc.php');
foreach ($data as $feed) {
$feed = explode("|", $feed);
$feed = array_map('trim', $feed);
$f[$feed[0]] = array('class' => $feed[0], 'file' => $feed[1], 'name' => $feed[2], 'active' => $feed[3], 'header' => $feed[4]);
}
if (!isset($f[$action])) {
$t = current($f);
示例8: mysql_real_escape_string
// Check for knowledge base stuff, prior to confirming:
if ($_REQUEST['kbarticle'] == 'yes') {
$sql = "INSERT INTO `{$dbKBArticles}` (doctype, title, distribution, author, published, keywords) VALUES ";
$sql .= "('1', ";
$sql .= "'{$kbtitle}', ";
$sql .= "'{$distribution}', ";
$sql .= "'" . mysql_real_escape_string($sit[2]) . "', ";
$sql .= "'" . date('Y-m-d H:i:s', mktime(date('H'), date('i'), date('s'), date('m'), date('d'), date('Y'))) . "', ";
$sql .= "'[{$id}]') ";
mysql_query($sql);
if (mysql_error()) {
trigger_error("MySQL Query Error " . mysql_error(), E_USER_ERROR);
}
$docid = mysql_insert_id();
// Update the incident to say that a KB article was created, with the KB Article number
$update = "<b>{$_SESSION['syslang']['strKnowledgeBaseArticleCreated']}: {$CONFIG['kb_id_prefix']}" . leading_zero(4, $docid);
$sql = "INSERT INTO `{$dbUpdates}` (incidentid, userid, type, bodytext, timestamp) ";
$sql .= "VALUES ('{$id}', '{$sit['2']}', 'default', '{$update}', '{$now}')";
$result = mysql_query($sql);
if (mysql_error()) {
trigger_error("MySQL Query Error " . mysql_error(), E_USER_ERROR);
}
// Get softwareid from Incident record
$sql = "SELECT softwareid FROM `{$dbIncidents}` WHERE id='{$id}'";
$result = mysql_query($sql);
if (mysql_error()) {
trigger_error("MySQL Query Error " . mysql_error(), E_USER_ERROR);
}
list($softwareid) = mysql_fetch_row($result);
if (!empty($_POST['summary'])) {
$query[] = "INSERT INTO `{$dbKBContent}` (docid, ownerid, headerstyle, header, contenttype, content, distribution) VALUES ('{$docid}', '" . mysql_real_escape_string($sit[2]) . "', 'h1', 'Summary', '1', '{$summary}', 'public') ";
示例9: profile
//.........这里部分代码省略.........
}
if ($user->d('user_rank')) {
$sql = 'SELECT user_id
FROM _members
WHERE user_rank = ?';
$size_rank = sql_rowset(sql_filter($sql, $user->d('user_rank')), false, 'user_id');
if (sizeof($size_rank) == 1) {
$sql = 'DELETE FROM _ranks
WHERE rank_id = ?';
sql_query(sql_filter($sql, $user->d('user_rank')));
}
}
$_fields->rank = $rank_id;
$cache->delete('ranks');
}
if (!$_fields->birthday_month || !$_fields->birthday_day || !$_fields->birthday_year) {
$error[] = 'EMPTY_BIRTH_MONTH';
}
// Update user avatar
if (!sizeof($error)) {
$upload->avatar_process($user->d('username_base'), $_fields, $error);
}
if (!sizeof($error)) {
if (!empty($_fields->sig)) {
$_fields->sig = $comments->prepare($_fields->sig);
}
$_fields->birthday = (string) (leading_zero($_fields->birthday_year) . leading_zero($_fields->birthday_month) . leading_zero($_fields->birthday_day));
unset($_fields->birthday_day, $_fields->birthday_month, $_fields->birthday_year);
$_fields->dateformat = 'd M Y H:i';
$_fields->hideuser = $user->d('user_hideuser');
$_fields->email_dc = $user->d('user_email_dc');
$member_data = w();
foreach ($_fields as $field => $value) {
if ($value != $user->d($field)) {
$member_data['user_' . $field] = $_fields->$field;
}
}
if (sizeof($member_data)) {
$sql = 'UPDATE _members SET ' . sql_build('UPDATE', $member_data) . sql_filter('
WHERE user_id = ?', $user->d('user_id'));
$sql = 'UPDATE _members SET ??
WHERE user_id = ?';
sql_query(sql_filter($sql, sql_build('UPDATE', $member_data), $user->d('user_id')));
}
redirect(s_link('m', $user->d('username_base')));
}
}
if (sizeof($error)) {
_style('error', array(
'MESSAGE' => parse_error($error))
);
}
示例10: cb_plain_code
function cb_plain_code($code)
{
$pid = $this->noparse_id();
$code = trim($code);
$rows = explode("\n", $code);
$code2 = str_replace("]", "]", $code);
$code2 = str_replace("[", "[", $code2);
if (count($rows) > 1) {
$a = 0;
$code = '';
$lines = strlen(count($rows));
foreach ($rows as $row) {
$a++;
$code .= leading_zero($a, $lines) . ": " . $row . "\n";
}
$this->noparse[$pid] = "\nQuelltext:\n" . $code;
} else {
$this->noparse[$pid] = $code2;
}
return '<!PID:' . $pid . '>';
}
示例11: colheader
echo colheader('keywords', $strKeywords, FALSE);
echo "</tr>\n";
$shade = 'shade1';
while ($kbarticle = mysql_fetch_object($result)) {
if (empty($kbarticle->title)) {
$kbarticle->title = $strUntitled;
} else {
$kbarticle->title = $kbarticle->title;
}
if (is_number($kbarticle->author)) {
$kbarticle->author = user_realname($kbarticle->author);
} else {
$kbarticle->author = $kbarticle->author;
}
echo "<tr class='{$shade}'>";
echo "<td>" . icon('kb', 16) . " {$CONFIG['kb_id_prefix']}" . leading_zero(4, $kbarticle->docid) . "</td>";
echo "<td>";
// Lookup what software this applies to
$ssql = "SELECT * FROM `{$dbKBSoftware}` AS kbs, `{$dbSoftware}` AS s WHERE kbs.softwareid = s.id ";
$ssql .= "AND kbs.docid = '{$kbarticle->docid}' ORDER BY s.name";
$sresult = mysql_query($ssql);
if (mysql_error()) {
trigger_error("MySQL Query Error " . mysql_error(), E_USER_WARNING);
}
$rowcount = mysql_num_rows($sresult);
if ($rowcount >= 1 and $rowcount < 3) {
$count = 1;
while ($kbsoftware = mysql_fetch_object($sresult)) {
echo "{$kbsoftware->name}";
if ($count < $rowcount) {
echo ", ";
示例12: do_login
//.........这里部分代码省略.........
$error['email'] = $result['error_msg'];
}
} else {
$error['email'] = 'EMAIL_MISMATCH';
$error['email_confirm'] = 'EMAIL_MISMATCH';
}
}
if (!empty($v_fields['key']) && !empty($v_fields['key_confirm'])) {
if ($v_fields['key'] != $v_fields['key_confirm']) {
$error['key'] = 'PASSWORD_MISMATCH';
} else if (strlen($v_fields['key']) > 32) {
$error['key'] = 'PASSWORD_LONG';
}
} else {
if (empty($v_fields['key'])) {
$error['key'] = 'EMPTY_PASSWORD';
} elseif (empty($v_fields['key_confirm'])) {
$error['key_confirm'] = 'EMPTY_PASSWORD_CONFIRM';
}
}
if (!$v_fields['birthday_month'] || !$v_fields['birthday_day'] || !$v_fields['birthday_year']) {
$error['birthday'] = 'EMPTY_BIRTH_MONTH';
}
if (!$v_fields['tos']) {
$error['tos'] = 'AGREETOS_ERROR';
}
if (!sizeof($error)) {
//$v_fields['country'] = strtolower(geoip_country_code_by_name($user->ip));
$v_fields['country'] = 90;
$v_fields['birthday'] = leading_zero($v_fields['birthday_year']) . leading_zero($v_fields['birthday_month']) . leading_zero($v_fields['birthday_day']);
$member_data = array(
'user_type' => USER_INACTIVE,
'user_active' => 1,
'username' => $v_fields['username'],
'username_base' => $v_fields['username_base'],
'user_password' => HashPassword($v_fields['key']),
'user_regip' => $user->ip,
'user_session_time' => 0,
'user_lastpage' => '',
'user_lastvisit' => time(),
'user_regdate' => time(),
'user_level' => 0,
'user_posts' => 0,
'userpage_posts' => 0,
'user_points' => 0,
'user_timezone' => $config['board_timezone'],
'user_dst' => $config['board_dst'],
'user_lang' => $config['default_lang'],
'user_dateformat' => $config['default_dateformat'],
'user_country' => (int) $v_fields['country'],
'user_rank' => 0,
'user_avatar' => '',
'user_avatar_type' => 0,
'user_email' => $v_fields['email'],
'user_lastlogon' => 0,
'user_totaltime' => 0,
'user_totallogon' => 0,
'user_totalpages' => 0,
'user_gender' => $v_fields['gender'],
'user_birthday' => (string) $v_fields['birthday'],
'user_mark_items' => 0,
示例13: cb_plain_code
function cb_plain_code($code)
{
global $lang;
$pid = $this->noparse_id();
$code = trim($code);
$rows = explode("\n", $code);
$code2 = str_replace("]", "]", $code);
$code2 = str_replace("[", "[", $code2);
if (count($rows) > 1) {
$a = 0;
$code = '';
$lines = strlen(count($rows));
foreach ($rows as $row) {
$a++;
$code .= leading_zero($a, $lines) . ": " . $row . "\n";
}
$this->noparse[$pid] = "\n" . $lang->phrase('bb_sourcecode') . "\n-------------------\n{$code}-------------------\n";
} else {
$this->noparse[$pid] = $code2;
}
return '<!PID:' . $pid . '>';
}
示例14: date
?>
</span></td>
<td><span><?php
echo $ia['epp_pregnant'] == 1 ? 'Yes' : 'No';
?>
</span></td>
<td><span><?php
echo $ia['implant_prob'] == 1 ? 'Yes' : 'No';
?>
</span></td>
<td><span><?php
echo date('d-m-Y', $ia['implant_date']);
?>
</span></td>
<td><span><?php
echo leading_zero($ia['implant_time']) . ':' . leading_zero($ia['implant_min']);
?>
</span></td>
<td><?php
echo get_batch_map($ia['implant_batch']);
?>
</td>
</tr>
<?php
}
} else {
?>
<tr>
<td colspan="20">
<em>No Data yet.</em>
</td>
示例15: kb_article
//.........这里部分代码省略.........
$html .= "<h3>{$GLOBALS['strEnvironment']}</h3>";
$html .= "<p>{$GLOBALS['strTheInfoInThisArticle']}:</p>\n";
$html .= "<ul>\n";
while ($kbsoftware = mysql_fetch_object($sresult)) {
$html .= "<li>{$kbsoftware->name}</li>\n";
}
$html .= "</ul>\n";
}
$csql = "SELECT * FROM `{$GLOBALS['dbKBContent']}` WHERE docid='{$id}' ";
$cresult = mysql_query($csql);
if (mysql_error()) {
trigger_error("MySQL Query Error " . mysql_error(), E_USER_WARNING);
}
$restrictedcontent = 0;
while ($kbcontent = mysql_fetch_object($cresult)) {
switch ($kbcontent->distribution) {
case 'private':
if ($mode != 'internal') {
echo "<p class='error'>{$GLOBALS['strPermissionDenied']}</p>";
include APPLICATION_INCPATH . 'htmlfooter.inc.php';
exit;
}
$html .= "<div class='kbprivate'><h3>{$kbcontent->header} (private)</h3>";
$restrictedcontent++;
break;
case 'restricted':
if ($mode != 'internal') {
echo "<p class='error'>{$GLOBALS['strPermissionDenied']}</p>";
include APPLICATION_INCPATH . 'htmlfooter.inc.php';
exit;
}
$html .= "<div class='kbrestricted'><h3>{$kbcontent->header}</h3>";
$restrictedcontent++;
break;
default:
$html .= "<div><h3>{$kbcontent->header}</h3>";
}
//$html .= "<{$kbcontent->headerstyle}>{$kbcontent->header}</{$kbcontent->headerstyle}>\n";
$html .= '';
$kbcontent->content = nl2br($kbcontent->content);
$search = array("/(?<!quot;|[=\"]|:\\/{2})\\b((\\w+:\\/{2}|www\\.).+?)" . "(?=\\W*([<>\\s]|\$))/i", "/(([\\w\\.]+))(@)([\\w\\.]+)\\b/i");
$replace = array("<a href=\"\$1\">\$1</a>", "<a href=\"mailto:\$0\">\$0</a>");
$kbcontent->content = preg_replace("/href=\"www/i", "href=\"http://www", preg_replace($search, $replace, $kbcontent->content));
$html .= bbcode($kbcontent->content);
$author[] = $kbcontent->ownerid;
$html .= "</div>\n";
}
if ($restrictedcontent > 0) {
$html .= "<h3>{$GLOBALS['strKey']}</h3>";
$html .= "<p><span class='keykbprivate'>{$GLOBALS['strPrivate']}</span>" . help_link('KBPrivate') . " ";
$html .= "<span class='keykbrestricted'>{$GLOBALS['strRestricted']}</span>" . help_link('KBRestricted') . "</p>";
}
$html .= "<h3>{$GLOBALS['strArticle']}</h3>";
//$html .= "<strong>{$GLOBALS['strDocumentID']}</strong>: ";
$html .= "<p><strong>{$CONFIG['kb_id_prefix']}" . leading_zero(4, $kbarticle->docid) . "</strong> ";
$pubdate = mysql2date($kbarticle->published);
if ($pubdate > 0) {
$html .= "{$GLOBALS['strPublished']} ";
$html .= ldate($CONFIG['dateformat_date'], $pubdate) . "<br />";
}
if ($mode == 'internal') {
if (is_array($author)) {
$author = array_unique($author);
$countauthors = count($author);
$count = 1;
if ($countauthors > 1) {
$html .= "<strong>{$GLOBALS['strAuthors']}</strong>:<br />";
} else {
$html .= "<strong>{$GLOBALS['strAuthor']}:</strong> ";
}
foreach ($author as $authorid) {
$html .= user_realname($authorid, TRUE);
if ($count < $countauthors) {
$html .= ", ";
}
$count++;
}
}
}
$html .= "<br />";
if (!empty($kbarticle->keywords)) {
$html .= "<strong>{$GLOBALS['strKeywords']}</strong>: ";
if ($mode == 'internal') {
$html .= preg_replace("/\\[([0-9]+)\\]/", "<a href=\"incident_details.php?id=\$1\" target=\"_blank\">\$0</a>", $kbarticle->keywords);
} else {
$html .= $kbarticle->keywords;
}
$html .= "<br />";
}
//$html .= "<h3>{$GLOBALS['strDisclaimer']}</h3>";
$html .= "</p><hr />";
$html .= $CONFIG['kb_disclaimer_html'];
$html .= "</div>";
if ($mode == 'internal') {
$html .= "<p align='center'>";
$html .= "<a href='kb.php'>{$GLOBALS['strBackToList']}</a> | ";
$html .= "<a href='kb_article.php?id={$kbarticle->docid}'>{$GLOBALS['strEdit']}</a></p>";
}
return $html;
}