本文整理汇总了PHP中cut函数的典型用法代码示例。如果您正苦于以下问题:PHP cut函数的具体用法?PHP cut怎么用?PHP cut使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了cut函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: wiz_set_LANGPACK
function wiz_set_LANGPACK()
{
$lcode = $_GET["language"];
//TRACE_error("lcode=".$lcode);
if ($lcode == "auto" || $lcode == "") {
$count = cut_count($_SERVER["HTTP_ACCEPT_LANGUAGE"], ',');
$i = 0;
while ($i < $count) {
$tag = cut($_SERVER["HTTP_ACCEPT_LANGUAGE"], $i, ',');
$pri = cut($tag, 0, '-');
$sub = cut($tag, 1, '-');
$lcode = convert_lcode($pri, $sub);
//The accept language for Japan from IE is ja-JP and the language code for our language pack is jp.
if ($lcode == "ja") {
$lcode = "jp";
}
if (wiz_load_slp($lcode) > 0) {
return $lcode;
}
$i++;
}
} else {
if (wiz_load_slp($lcode) > 0) {
return $lcode;
}
}
sealpac("/etc/sealpac/wizard/wiz_en.slp");
// Use system default language, en.
return "en";
}
示例2: ftopics
function ftopics()
{
global $db, $maxftopics, $lftopics, $maxfposts, $allowHover;
$f = 0;
$qry = db("SELECT s1.*,s2.id AS subid FROM " . $db['f_threads'] . " s1, " . $db['f_skats'] . " s2, " . $db['f_kats'] . " s3\n WHERE s1.kid = s2.id AND s2.sid = s3.id ORDER BY s1.lp DESC LIMIT 100");
while ($get = _fetch($qry)) {
if ($f == $maxftopics) {
break;
}
if (fintern($get['kid'])) {
$lp = cnt($db['f_posts'], " WHERE sid = '" . $get['id'] . "'");
$pagenr = ceil($lp / $maxfposts);
if ($pagenr == 0) {
$page = 1;
} else {
$page = $pagenr;
}
if ($allowHover == 1) {
$info = 'onmouseover="DZCP.showInfo(\'<tr><td colspan=2 align=center padding=3 class=infoTop>' . jsconvert(re($get['topic'])) . '</td></tr><tr><td><b>' . _forum_posts . ':</b></td><td>' . $lp . '</td></tr><tr><td><b>' . _forum_lpost . ':</b></td><td>' . date("d.m.Y H:i", $get['lp']) . _uhr . '</td></tr>\')" onmouseout="DZCP.hideInfo()"';
}
$ftopics .= show("menu/forum_topics", array("id" => $get['id'], "pagenr" => $page, "p" => $lp + 1, "titel" => cut(re($get['topic']), $lftopics), "info" => $info, "kid" => $get['kid']));
$f++;
}
}
return empty($ftopics) ? '' : '<table class="navContent" cellspacing="0">' . $ftopics . '</table>';
}
示例3: fatlady_dhcps
function fatlady_dhcps($prefix, $svc)
{
$service = cut($svc, 0, ".");
$version = scut($service, 0, "DHCPS");
XNODE_set_var("FATLADY_DHCPS_PATH", $prefix);
XNODE_set_var("SERVICE_NAME", $svc);
$b = "/htdocs/phplib/fatlady/DHCPS";
if ($version == 4) {
dophp("load", $b . "/dhcps4.php");
} else {
if ($version == 6) {
dophp("load", $b . "/dhcps6.php");
} else {
$_GLOBALS["FATLADY_result"] = "FAILED";
$_GLOBALS["FATLADY_node"] = "";
$_GLOBALS["FATLADY_message"] = "Unsupported DHCP service : " . $svc;
/* internal error, no i18n(). */
}
}
XNODE_del_var("FATLADY_DHCPS_PATH");
XNODE_del_var("SERVICE_NAME");
if ($_GLOBALS["FATLADY_result"] == "OK") {
set($prefix . "/valid", 1);
}
}
示例4: getContent
public function getContent()
{
global $sql;
//Lang::load('blocks/shoutbox/lang.*.php');
$err = new Error();
$note = new Notifier('note-shoutbox');
$form['author'] = LOGGED ? User::$nickname : '';
$form['message'] = '';
if (isset($_POST['reply-shoutbox'])) {
$form['author'] = LOGGED ? User::$nickname : filter($_POST['author-shoutbox'], 100);
$form['message'] = filter($_POST['message-shoutbox'], Kio::getConfig('message_max', 'shoutbox'));
$err->setError('author_empty', t('Author field is required.'))->condition(!$form['author']);
$err->setError('author_exists', t('Entered nickname is registered.'))->condition(!LOGGED && is_registered($form['author']));
$err->setError('message_empty', t('Message field is required.'))->condition(!$form['message']);
// No errors
if ($err->noErrors()) {
$sql->exec('
INSERT INTO ' . DB_PREFIX . 'shoutbox (added, author, message, author_id, author_ip)
VALUES (
' . TIMESTAMP . ',
"' . $form['author'] . '",
"' . cut($form['message'], Kio::getConfig('message_max', 'shoutbox')) . '",
' . UID . ',
"' . IP . '")');
$sql->clearCache('shoutbox');
$note->success(t('Entry was added successfully.'));
redirect(HREF . PATH . '#shoutbox');
} else {
$note->error($err->toArray());
}
}
// If cache for shoutbox doesn't exists
if (!($entries = $sql->getCache('shoutbox'))) {
$query = $sql->query('
SELECT u.nickname, u.group_id, s.added, s.author, s.author_id, s.message
FROM ' . DB_PREFIX . 'shoutbox s
LEFT JOIN ' . DB_PREFIX . 'users u ON u.id = s.author_id
ORDER BY s.id DESC
LIMIT ' . Kio::getConfig('limit', 'shoutbox'));
while ($row = $query->fetch()) {
if ($row['author_id']) {
$row['author'] = User::format($row['author_id'], $row['nickname'], $row['group_id']);
$row['message'] = parse($row['message'], Kio::getConfig('parser', 'shoutbox'));
}
$entries[] = $row;
}
$sql->putCacheContent('shoutbox', $entries);
}
try {
$tpl = new PHPTAL('blocks/shoutbox/shoutbox.tpl.html');
$tpl->entries = $entries;
$tpl->err = $err->toArray();
$tpl->form = $form;
$tpl->note = $note;
return $tpl->execute();
} catch (Exception $e) {
return template_error($e->getMessage());
//echo Note::error($e->getMessage());
}
}
示例5: get_plugin_stuff
function get_plugin_stuff($plugin, $info)
{
if (strrpos($plugin, ".rb") or strrpos($plugin, ".js") or strrpos($plugin, ".php")) {
$arr = file(abspath . "/plugins/" . $plugin);
} else {
$arr = file(abspath . "/plugins/" . $plugin . "/info.data");
}
foreach ($arr as $line => $linestuff) {
if ("# " . $info . "\n" == $linestuff) {
$linenum = $line + 1;
$output = $arr[$linenum];
}
}
if ($info == "active" and !strrpos($plugin, ".rb") and !strrpos($plugin, ".js") and !strrpos($plugin, ".php")) {
$output = file_get_contents(abspath . "/plugins/" . $plugin . "/active.data");
}
if ($info == "hook") {
$output = explode(",", trim($output));
}
if ($info == "name" and !isset($output)) {
$output = ucfirst(preg_replace('/\\.\\w+$/', '', $plugin));
}
cut($output);
return $output;
}
示例6: dhcps_setcfg
function dhcps_setcfg($prefix, $svc)
{
/* set dhcpX of inf */
$inf = cut($svc, 1, ".");
$svc = tolower(cut($svc, 0, "."));
$base = XNODE_getpathbytarget("", "inf", "uid", $inf, 0);
$dhcps_uid = query($prefix . "/inf/" . $svc);
set($base . "/" . $svc, $dhcps_uid);
/* copy the dhcp profile. */
$uid = INF_getinfinfo($inf, $svc);
$spath = XNODE_getpathbytarget($prefix . "/" . $svc, "entry", "uid", $dhcps_uid, 0);
$dhcps = XNODE_getpathbytarget("/" . $svc, "entry", "uid", $uid, 0);
if ($dhcps != "") {
if ($svc == "dhcps4") {
copy_dhcps4($spath, $dhcps);
} else {
if ($svc == "dhcps6") {
$_GLOBALS["SETCFG_DHCPS6_SRC_PATH"] = $spath;
$_GLOBALS["SETCFG_DHCPS6_DST_PATH"] = $dhcps;
$b = "/htdocs/phplib/setcfg/libs";
dophp("load", $b . "/dhcps6.php");
}
}
} else {
TRACE_error("SETCFG/DHCPS: no dhcps entry for [" . $uid . "] found!");
}
}
示例7: top_match
function top_match()
{
global $db, $allowHover, $llwars, $picformat, $sql_prefix;
$qry = db("SELECT s1.datum,s1.cid,s1.id,s1.bericht,s1.xonx,s1.punkte,s1.gpunkte,s1.squad_id,s2.icon,s2.name FROM " . $db['cw'] . " AS s1\n LEFT JOIN " . $db['squads'] . " AS s2 ON s1.squad_id = s2.id\n WHERE `top` = '1'\n ORDER BY RAND()");
if ($get = _fetch($qry)) {
//Clans Mod
$clandetailssql = db("SELECT clantag, gegner FROM " . $sql_prefix . "clans WHERE id LIKE " . $get['cid']);
$clans = _fetch($clandetailssql);
$squad = '_defaultlogo.jpg';
$gegner = '_defaultlogo.jpg';
foreach ($picformat as $end) {
if (file_exists(basePath . '/inc/images/clanwars/' . $get['cid'] . '_logo.' . $end)) {
$gegner = $get['cid'] . '_logo.' . $end;
}
if (file_exists(basePath . '/inc/images/squads/' . $get['squad_id'] . '_logo.' . $end)) {
$squad = $get['squad_id'] . '_logo.' . $end;
}
}
if ($allowHover == 1 || $allowHover == 2) {
$hover = 'onmouseover="DZCP.showInfo(\'<tr><td colspan=2 align=center padding=3 class=infoTop>' . jsconvert(re($get['name'])) . '<br/>vs.<br/> ' . jsconvert(re($clans['gegner'])) . '</td></tr><tr><td><b>' . _played_at . ':</b></td><td>' . date("d.m.Y H:i", $get['datum']) . _uhr . '</td></tr><tr><td><b>' . _cw_xonx . ':</b></td><td>' . jsconvert(re($get['xonx'])) . '</td></tr><tr><td><b>' . _result . ':</b></td><td>' . cw_result_nopic_raw($get['punkte'], $get['gpunkte']) . '</td></tr><tr><td><b>' . _comments_head . ':</b></td><td>' . cnt($db['cw_comments'], "WHERE cw = '" . $get['id'] . "'") . '</td></tr>\')" onmouseout="DZCP.hideInfo()"';
}
$topmatch .= show("menu/top_match", array("id" => $get['id'], "clantag" => re(cut($clans['clantag'], $llwars)), "team" => re(cut($get['name'], $llwars)), "game" => substr(strtoupper(str_replace('.' . $icon, '', re($get['icon']))), 0, 5), "id" => $get['id'], "gegner" => $gegner, "squad" => $squad, "hover" => $hover, "info" => $get['datum'] > time() ? date("d.m.Y", $get['datum']) : cw_result_nopic($get['punkte'], $get['gpunkte'])));
}
return empty($topmatch) ? '<center style="margin:3px 0">' . _no_top_match . '</center>' : '<table class="navContent" cellspacing="0">' . $topmatch . '</table>';
}
示例8: check_pin
function check_pin($pin)
{
/* more checking added for WPS 2.0
We allow pin with : xxxx-xxxx
xxxx xxxx
xxxxxxxx
*/
$len = strlen($pin);
$delim = "";
//we support 4 digits
if ($len == 4) {
if (isdigit($pin) != 1) {
return 0;
} else {
return $pin;
}
}
if ($len == 9) {
if (cut_count($pin, "-") == 2) {
$delim = "-";
} else {
if (cut_count($pin, " ") == 2) {
$delim = " ";
} else {
return 0;
}
}
$val1 = cut($pin, 0, $delim);
$val2 = cut($pin, 1, $delim);
if (strlen($val1) != 4 || strlen($val2) != 4) {
return 0;
}
$pin = $val1 . $val2;
}
if (isdigit($pin) != 1) {
return 0;
}
if (strlen($pin) != 8) {
return 0;
}
$i = 0;
$pow = 3;
$sum = 0;
while ($i < 8) {
$sum = $pow * substr($pin, $i, 1) + $sum;
if ($pow == 3) {
$pow = 1;
} else {
$pow = 3;
}
$i++;
}
$sum = $sum % 10;
if ($sum == 0) {
return $pin;
} else {
return 0;
}
}
示例9: check_datetime
function check_datetime($prefix)
{
$date = query($prefix . "/date");
$time = query($prefix . "/time");
$month = cut($date, 0, "/");
$day = cut($date, 1, "/");
$year = cut($date, 2, "/");
$hour = cut($time, 0, ":");
$min = cut($time, 1, ":");
$sec = cut($time, 2, ":");
TRACE_debug("FATLADY: RUNTIME.TIME: " . $year . "/" . $month . "/" . $day);
TRACE_debug("FATLADY: RUNTIME.TIME: " . $hour . ":" . $min . ":" . $sec);
/* The latest time linux can support is: Tue Jan 19 11:14:07 CST 2038. */
if (isdigit($year) == 0 || $year < 1999 || $year > 2037) {
set_result("FAILED", $prefix . "/date", i18n("Invalid year") . " - " . $year);
return;
}
if (isdigit($month) == 0 || $month <= 0 || $month > 12) {
set_result("FAILED", $prefix . "/date", i18n("Invalid month"));
return;
}
if (isdigit($day) == 0 || $day <= 0 || $day > 31) {
set_result("FAILED", $prefix . "/date", i18n("Invalid day"));
return;
}
if ($month == 2 || $month == 4 || $month == 6 || $month == 9 || $month == 11) {
if ($day > 30) {
set_result("FAILED", $prefix . "/date", i18n("Invalid day"));
return;
}
if ($month == 2) {
if (is29year($year) == 1) {
if ($day > 29) {
set_result("FAILED", $prefix . "/date", i18n("Invalid day"));
return;
}
} else {
if ($day > 28) {
set_result("FAILED", $prefix . "/date", i18n("Invalid day"));
return;
}
}
}
}
if (isdigit($hour) == 0 || $hour < 0 || $hour > 23) {
set_result("FAILED", $prefix . "/time", i18n("Invalid hour"));
return;
}
if (isdigit($min) == 0 || $min < 0 || $min > 59) {
set_result("FAILED", $prefix . "/time", i18n("Invalid minute"));
return;
}
if (isdigit($sec) == 0 || $sec < 0 || $sec > 59) {
set_result("FAILED", $prefix . "/time", i18n("Invalid second"));
return;
}
set_result("OK", "", "");
}
示例10: dhcpc6setup
function dhcpc6setup($inf)
{
$hlp = "/var/servd/" . $inf . "-dhcp6c.sh";
$pid = "/var/servd/" . $inf . "-dhcp6c.pid";
$cfg = "/var/servd/" . $inf . "-dhcp6c.cfg";
/* DHCP over PPP session ? */
//$previnf = XNODE_get_var($inf."_PREVINF");
//XNODE_del_var($inf."_PREVINF");
$infp = XNODE_getpathbytarget("", "inf", "uid", $inf, 0);
$previnf = query($infp . "/infprevious");
$phyinf = query($infp . "/phyinf");
$inet = query($infp . "/inet");
$inetp = XNODE_getpathbytarget("/inet", "entry", "uid", $inet, 0);
$devnam = PHYINF_getifname($phyinf);
/* dslite ? */
$nextinf = query($infp . "/infnext");
//if ($mode=="PPPDHCP" && $_GLOBALS["PREVINF"]!="")
//msg("mode is ".$mode.", previnf is ".$previnf);
startcmd('# dhcpc6setup(' . $inf . ',' . $inetp . ')');
startcmd("previnf is " . $previnf . ", nextinf is " . $nextinf);
//if ($mode=="PPPDHCP" && $previnf!="")
//{
// $pppdev = PHYINF_getruntimeifname($previnf);
// if ($pppdev=="") return error("no PPP device.");
//}
/* Gererate DHCP-IAID from 32-bit of mac address*/
$mac = PHYINF_getphymac($inf);
$mac1 = cut($mac, 3, ":");
$mac2 = cut($mac, 0, ":");
$mac3 = cut($mac, 1, ":");
$mac4 = cut($mac, 2, ":");
$iaidstr = $mac1 . $mac2 . $mac3 . $mac4;
$iaid = strtoul($iaidstr, 16);
/* Generate configuration file. */
$send = "\tinformation-only;\n";
$idas = "";
//if($mode=="PPPDHCP") $dname = $pppdev;
//else $dname = $devnam;
$dname = $devnam;
$nextinfp = XNODE_getpathbytarget("", "inf", "uid", $nextinf, 0);
$nextinet = query($nextinfp . "/inet");
$nextinetp = XNODE_getpathbytarget("inet", "entry", "uid", $nextinet, 0);
$nextmode = query($nextinetp . "/ipv4/ipv4in6/mode");
if ($nextinf != "" && $nextmode == "dslite") {
$rqstmsg = "\trequest aftr-server-domain-name;\n";
} else {
$rqstmsg = "";
}
fwrite(w, $cfg, "interface " . $dname . " {\n" . $send . $rqstmsg . "\tscript \"" . $hlp . "\";\n" . "};\n" . $idas);
/* generate callback script */
fwrite(w, $hlp, "#!/bin/sh\n" . "phpsh /etc/services/INET/inet6_dhcpc_helper.php" . " INF=" . $inf . " MODE=INFOONLY" . " DEVNAM=" . $dname . " GATEWAY=" . "" . " DHCPOPT=" . "" . ' "NAMESERVERS=$new_domain_name_servers"' . ' "NEW_ADDR=$new_addr"' . ' "NEW_PD_PREFIX=$new_pd_prefix"' . ' "NEW_PD_PLEN=$new_pd_plen"' . ' "DNS=' . "" . '"' . ' "NEW_AFTR_NAME=$new_aftr_name"' . ' "NTPSERVER=$new_ntp_servers"' . "\n");
/* Start DHCP client */
startcmd("chmod +x " . $hlp);
//if ($pppdev=="")
startcmd("dhcp6c -c " . $cfg . " -p " . $pid . " -t LL " . $devnam);
//else startcmd("dhcp6c -c ".$cfg." -p ".$pid." -t LL -o ".$devnam." ".$pppdev);
stopcmd("/etc/scripts/killpid.sh /var/servd/" . $inf . "-dhcp6c.pid");
}
示例11: l_reg
function l_reg()
{
global $db, $llreg, $maxlreg;
$qry = db("SELECT id,nick,country,regdatum FROM " . $db['users'] . "\n ORDER BY regdatum DESC\n LIMIT " . $maxlreg . "");
while ($get = _fetch($qry)) {
$lreg .= show("menu/last_reg", array("nick" => re(cut($get['nick'], $llreg)), "country" => flag($get['country']), "reg" => date("d.m.", $get['regdatum']), "id" => $get['id']));
}
return empty($lreg) ? '' : '<table class="navContent" cellspacing="0">' . $lreg . '</table>';
}
示例12: cut_preg
function cut_preg($str, $start, $end, $preg)
{
$title_str = cut($str, $start, $end);
if (!empty($title_str)) {
$title_arr = preg($title_str, $preg);
$title = empty($title_arr[1]) ? '' : strip_tags($title_arr[1]);
return $title;
} else {
return false;
}
}
示例13: perform
function perform($jsonObject)
{
$action = $jsonObject->action;
switch ($action) {
case "load":
return loadCompany($jsonObject);
case "save":
return saveName($jsonObject);
case "cut":
return cut($jsonObject);
}
}
示例14: l_wars
function l_wars()
{
global $db, $maxlwars, $llwars, $allowHover;
$qry = db("SELECT s1.datum,s1.gegner,s1.id,s1.bericht,s1.xonx,s1.clantag,s1.punkte,s1.gpunkte,s1.squad_id,s2.icon,s2.name FROM " . $db['cw'] . " AS s1\n LEFT JOIN " . $db['squads'] . " AS s2 ON s1.squad_id = s2.id\n WHERE datum < " . time() . "\n ORDER BY datum DESC\n LIMIT " . $maxlwars . "");
while ($get = _fetch($qry)) {
if ($allowHover == 1 || $allowHover == 2) {
$info = 'onmouseover="DZCP.showInfo(\'<tr><td colspan=2 align=center padding=3 class=infoTop>' . jsconvert(re($get['name'])) . '<br/>vs.<br/> ' . jsconvert(re($get['gegner'])) . '</td></tr><tr><td><b>' . _played_at . ':</b></td><td>' . date("d.m.Y H:i", $get['datum']) . _uhr . '</td></tr><tr><td><b>' . _cw_xonx . ':</b></td><td>' . jsconvert(re($get['xonx'])) . '</td></tr><tr><td><b>' . _result . ':</b></td><td>' . cw_result_nopic_raw($get['punkte'], $get['gpunkte']) . '</td></tr><tr><td><b>' . _comments_head . ':</b></td><td>' . cnt($db['cw_comments'], "WHERE cw = '" . $get['id'] . "'") . '</td></tr>\')" onmouseout="DZCP.hideInfo()"';
}
$lwars .= show("menu/last_wars", array("id" => $get['id'], "clantag" => re(cut($get['clantag'], $llwars)), "icon" => re($get['icon']), "info" => $info, "result" => cw_result_pic($get['punkte'], $get['gpunkte'])));
}
return empty($lwars) ? '' : '<table class="navContent" cellspacing="0">' . $lwars . '</table>';
}
示例15: perform
function perform($jsonObject)
{
$action = $jsonObject->action;
switch ($action) {
case "load":
return loadEmployee($jsonObject);
case "save":
return saveEmployee($jsonObject);
case "cut":
return cut($jsonObject);
}
}