/** * UTF-8 aware alternative to str_pad. * * $pad_str may contain multi-byte characters. * * @author Oliver Saunders <*****@*****.**> * @package php-utf-8 * @subpackage functions * @see http://www.php.net/str_pad * @uses utf8_substr * * @param string $input * @param int $length * @param string $pad_str * @param int $type (same constants as str_pad) * * @return string */ function pad($input, $length, $pad_str = ' ', $type = STR_PAD_RIGHT) { $input_len = len($input); if ($length <= $input_len) { return $input; } $pad_str_len = len($pad_str); $pad_len = $length - $input_len; if ($type == STR_PAD_RIGHT) { $repeat_times = ceil($pad_len / $pad_str_len); return sub($input . str_repeat($pad_str, $repeat_times), 0, $length); } if ($type == STR_PAD_LEFT) { $repeat_times = ceil($pad_len / $pad_str_len); return sub(str_repeat($pad_str, $repeat_times), 0, floor($pad_len)) . $input; } if ($type == STR_PAD_BOTH) { $pad_len /= 2; $pad_amount_left = floor($pad_len); $pad_amount_right = ceil($pad_len); $repeat_times_left = ceil($pad_amount_left / $pad_str_len); $repeat_times_right = ceil($pad_amount_right / $pad_str_len); $padding_left = sub(str_repeat($pad_str, $repeat_times_left), 0, $pad_amount_left); $padding_right = sub(str_repeat($pad_str, $repeat_times_right), 0, $pad_amount_right); return $padding_left . $input . $padding_right; } trigger_error('utf8_str_pad: Unknown padding type (' . $type . ')', E_USER_ERROR); }
function sub($items, $id, $count) { $count++; echo '<ul>'; foreach ($items as $item) { if ($item['parent'] == $id) { echo '<li><label><input type="checkbox" value="' . $item['id'] . '">' . $item['title'] . '</label></li>'; sub($items, $item['id'], $count); } } echo '</ul>'; }
/** * UTF-8 aware alternative to strcspn. * * Find length of initial segment not matching mask. * * @package php-utf-8 * @subpackage functions * @see http://www.php.net/strcspn * @uses utf8_strlen * @uses utf8_substr * * @param string $str * @param string $mask * @param integer $start * @param integer $length * * @return integer|null */ function cspn($str, $mask, $start = null, $length = null) { if (empty($mask) || strlen($mask) == 0) { return null; } $mask = preg_replace('!([\\\\\\-\\]\\[/^])!', '\\\\${1}', $mask); if ($start !== null || $length !== null) { $str = sub($str, $start, $length); } preg_match('/^[^' . $mask . ']+/u', $str, $matches); if (isset($matches[0])) { return len($matches[0]); } return 0; }
/** * Проверка пользовательских данных, полученных по токену */ protected function checkTokenError() { if (!is_array($this->u_data)) { $this->sendMessage(array('title' => $this->user->lang['ULOGIN_AUTH_ERROR'], 'msg' => $this->user->lang['ULOGIN_WRONG_USER_DATA_ERROR'], 'type' => 'error')); return false; } if (isset($this->u_data['error'])) { $strpos = strpos($this->u_data['error'], 'host is not'); if ($strpos) { $this->sendMessage(array('title' => $this->user->lang['ULOGIN_AUTH_ERROR'], 'msg' => sprintf($this->user->lang['ULOGIN_HOST_ADDRESS_ERROR'], sub($this->u_data['error'], intval($strpos) + 12)), 'type' => 'error')); return false; } switch ($this->u_data['error']) { case 'token expired': $this->sendMessage(array('title' => $this->user->lang['ULOGIN_AUTH_ERROR'], 'msg' => $this->user->lang['ULOGIN_TOKEN_EXPIRED_ERROR'], 'type' => 'error')); break; case 'invalid token': $this->sendMessage(array('title' => $this->user->lang['ULOGIN_AUTH_ERROR'], 'msg' => $this->user->lang['ULOGIN_INVALID_TOKEN_ERROR'], 'type' => 'error')); break; default: $this->sendMessage(array('title' => $this->user->lang['ULOGIN_AUTH_ERROR'], 'msg' => "<i>ERROR</i>: " . $this->u_data['error'], 'type' => 'error')); } return false; } if (!isset($this->u_data['identity'])) { $this->sendMessage(array('title' => $this->user->lang['ULOGIN_AUTH_ERROR'], 'msg' => sprintf($this->user->lang['ULOGIN_NO_VARIABLE_ERROR'], 'identity'), 'type' => 'error')); return false; } if (!isset($this->u_data['email'])) { $this->sendMessage(array('title' => $this->user->lang['ULOGIN_AUTH_ERROR'], 'msg' => sprintf($this->user->lang['ULOGIN_NO_VARIABLE_ERROR'], 'email'), 'type' => 'error')); return false; } return true; }
function sub($items, $id, $count) { $count++; foreach ($items as $item) { if ($item['parent'] == $id) { echo '<tr class="category-wrap-main"> <td><input value="' . $item['id'] . '" type="checkbox"/></td> <td>'; for ($i = 0; $i < $count; $i++) { echo " - "; } echo $item['title'] . "</a></td>"; echo '<td>' . $item['describe_category'] . '</td> <td> <a href="" class="quickedit-btn">ویرایش سریع</a> | <a href="update-catws.php?id=' . $item['id'] . '" class="lupwsc">ویرایش</a> | <a href="" class="quickdelete-btn">حذف</a> </td> </tr>'; echo '<tr class="quickedit"> <td colspan="5"> <fieldset> <h4>ویرایش سریع</h4> <div> <div class="col-md-1"><label for="">نام</label></div> <div class="col-md-11"> <input type="text" class="ptitle" value="' . $item['title'] . '"/> </div> </div> <div> <div class="col-md-1"><label class="wrap-txt-quick-edit" for="">توضیح</label></div> <div class="col-md-11"> <input type="text" class="ptitle" value="' . $item['describe_category'] . '"/> </div> </div> <div class="quick-edit-wrap-btn"> <input type="submit" class="btn btn-default btn-sm quick-edit-cancel-btn" value="لغو"> <input type="submit" class="btn btn-primary text-left btn-sm quick-update" value="بروز رسانی"> </div>'; sub($items, $item['id'], $count); } } }
/** * Проверка пользовательских данных, полученных по токену * @param $u_user - пользовательские данные * @return bool */ function ulogin_check_token_error($u_user) { if (!is_array($u_user)) { wp_die(__("<b>Ошибка работы uLogin:</b></br></br>" . "Данные о пользователе содержат неверный формат."), 'uLogin error', array('back_link' => true)); return false; } if (isset($u_user['error'])) { $strpos = strpos($u_user['error'], 'host is not'); if ($strpos) { wp_die(__("<b>Ошибка работы uLogin:</b></br></br>" . "<i>ERROR</i>: адрес хоста не совпадает с оригиналом") . sub($u_user['error'], intval($strpos) + 12), 'uLogin error', array('back_link' => true)); } switch ($u_user['error']) { case 'token expired': wp_die(__("<b>Ошибка работы uLogin:</b></br></br>" . "<i>ERROR</i>: время жизни токена истекло"), 'uLogin error', array('back_link' => true)); break; case 'invalid token': wp_die(__("<b>Ошибка работы uLogin:</b></br></br>" . "<i>ERROR</i>: неверный токен"), 'uLogin error', array('back_link' => true)); break; default: wp_die(__("<b>Ошибка работы uLogin:</b></br></br>" . "<i>ERROR</i>: ") . $u_user['error'], 'uLogin error', array('back_link' => true)); } return false; } if (!isset($u_user['identity'])) { wp_die(__("<b>Ошибка работы uLogin:</b></br></br>" . "В возвращаемых данных отсутствует переменная <b>identity</b>."), 'uLogin error', array('back_link' => true)); return false; } return true; }
function div($x, $y) { return lt($x, $y) ? 0 : add(1, div(sub($x, $y), $y)); }
/** * Проверка пользовательских данных, полученных по токену */ protected function checkTokenError() { if (!is_array($this->u_data)) { $this->sendMessage(array('title' => 'ulogin_auth_error', 'msg' => 'ulogin_wrong_user_data_error', 'type' => 'error')); return false; } if (isset($this->u_data['error'])) { $strpos = strpos($this->u_data['error'], 'host is not'); if ($strpos) { $this->sendMessage(array('title' => 'ulogin_auth_error', 'msg' => array('ulogin_host_address_error', sub($this->u_data['error'], intval($strpos) + 12)), 'type' => 'error')); return false; } switch ($this->u_data['error']) { case 'token expired': $this->sendMessage(array('title' => 'ulogin_auth_error', 'msg' => 'ulogin_token_expired_error', 'type' => 'error')); break; case 'invalid token': $this->sendMessage(array('title' => 'ulogin_auth_error', 'msg' => 'ulogin_invalid_token_error', 'type' => 'error')); break; default: $this->sendMessage(array('title' => 'ulogin_auth_error', 'msg' => "<i>ERROR</i>: " . $this->u_data['error'], 'type' => 'error')); } return false; } if (!isset($this->u_data['identity'])) { $this->sendMessage(array('title' => 'ulogin_auth_error', 'msg' => array('ulogin_no_variable_error', 'identity'), 'type' => 'error')); return false; } if (!isset($this->u_data['email'])) { $this->sendMessage(array('title' => 'ulogin_auth_error', 'msg' => array('ulogin_no_variable_error', 'email'), 'type' => 'error')); return false; } if (!isset($this->u_data['first_name'])) { $this->sendMessage(array('title' => 'ulogin_auth_error', 'msg' => array('ulogin_no_variable_error', 'first_name'), 'type' => 'error')); return false; } if (!isset($this->u_data['last_name'])) { $this->sendMessage(array('title' => 'ulogin_auth_error', 'msg' => array('ulogin_no_variable_error', 'last_name'), 'type' => 'error')); return false; } return true; }
public function sub($other) { return sub($this, $other); }
<pre><?php include 'cal.php'; echo '5 + 2= ' . soma(5, 2) . '<br>'; echo '5 - 2= ' . sub(5, 2) . '<br>'; echo '5 / 2= ' . div(5, 2) . '<br>'; echo '5 * 2= ' . mult(5, 2) . '<br>'; echo '5 + 2 * 3= ' . soma(5, mult(2, 3)) . '<br>'; echo '8 - 3 + 5= ' . soma(sub(8, 3), 5) . '<br>'; echo '9 / 3 + 4 * 2= ' . soma(div(9, 3), mult(4, 2)) . '<br>'; ?> </pre>
<?php if (!defined('InEmpireCMS')) { exit; } $i = 0; $line = 3; //每行显示图片数 $width = 100; $height = 80; $sub = 23; //编号截取数 while ($r = $empire->fetch($sql)) { $ono = $r[no]; $r[no] = sub($r[no], 0, $sub, false); $filesize = ChTheFilesize($r[filesize]); //文件大小 $filetype = GetFiletype($r[filename]); //取得文件扩展名 $i++; if (($i - 1) % $line == 0 || $i == 1) { $class_text .= "<tr bgcolor='#DBEAF5'>"; } //文件 $fspath = ReturnFileSavePath($r[classid], $r[fpath]); $filepath = $r[path] ? $r[path] . '/' : $r[path]; $file = $fspath['fileurl'] . $filepath . $r[filename]; $buttonr = ToReturnDoFileButton($doing, $tranfrom, $field, $file, $r[filename], $r[fileid], $filesize, $filetype, $ono, $type); $button = $buttonr['button']; $buttonurl = $buttonr['bturl']; $class_text .= "<td><table width='100%' border='0' cellspacing='1' cellpadding='2'>\n <tr> \n <td width='96%' rowspan='2'><div align='center'><a href='#empirecms' title='点击选择' onclick=\"javascript:" . $buttonurl . "\"><img src='" . $file . "' width='" . $width . "' height='" . $height . "' border=0></a></div></td>\n <td width='4%' valign='top'> <div align='center'> \n <input type=checkbox name=fileid[] value='{$r['fileid']}'>\n </div></td>\n </tr>\n <tr>\n <td valign='bottom'>\n<div align='center'><a href='cropimg/CropImage.php?fileid=" . $r[fileid] . "&filepass="******"&classid={$classid}&infoid={$infoid}&modtype={$modtype}&fstb={$fstb}" . $ecms_hashur['ehref'] . "' target='_blank' title='裁剪'><img src='../../data/images/cropimg.gif' width='13' height='13' border='0'></a></div></td>\n </tr>\n <tr> \n <td><div align='center'><a title='" . $ono . "'>" . $r[no] . "</a></div></td>\n <td><div align='center'><a href='../../ViewImg/index.html?url=" . $file . "' target='_blank' title='预览:" . $r[filename] . "'><img src='../../data/images/viewimg.gif' width='13' height='13' border='0'></a></div></td>\n </tr>\n</table></td>";
function sub($items, $id, $segment1, $segment2) { echo "<ul class='treeview-menu'>"; foreach ($items as $item) { if ($item['parent_id'] == $id) { $active = ''; if ("{$segment1}/{$segment2}" == $item['menu_url']) { $active = 'class="active"'; } $menu_url = base_url($item['menu_url']); echo "<li {$active}>\n <a href='{$menu_url}'>\n <i class='fa {$item['menu_icon']}'></i>{$item['menu_name']}\n </a>"; foreach ($items as $value) { if ($value['parent_id'] == $item['menu_id']) { sub($items, $item['menu_id'], $segment1, $segment2); break; } } echo "</li>"; } } echo "</ul>"; }
<form method="post" action="" name='sub'> <input class="textbox2" type="email" name="emailxxx" placeholder="Nhập địa chỉ email..." autocomplete="off" required> <button type='submit' name='sub' style='background-color: #fff; border: 0;' ><input width="25px" height="25px" type="image" onclick='document.getElementById("sub").submit();' style='margin: -6px; background-color: #fff;' src="./images/sub.png" alt="Gửi" title="Gửi"></input></button> <br/> </form> <div id="form2"> <h3>Đăng ký nhận đề kiểm tra mới</h3> <div> <span id="form_content2"> </span> </div> <span id="form_close2"></span> </div> <?php if (isset($_POST["emailxxx"])) { sub(); } ?> </div> <div class="clear"></div> </div> <div class="boxnav"> <h3 class="titlenav" style="margin-bottom: -2px;"><a href="#" class="menuitem submenuheader">Danh mục đề kiểm tra</a></h3> <ul class="navigation"> <?php if ($this3 == NULL) { $this3 = 1; } $sql = "SELECT * FROM `cate3`"; $query = @mysql_query($sql); $i = 0;
<?php require "example.php"; # First create some objects using the pointer library. print "Testing the pointer library\n"; $a = 37.145; $b = 42.555; $c = ""; // $c must be defined and not null. print "\ta = {$a}\n"; print "\tb = {$b}\n"; print "\tc = {$c}\n"; # Call the add() function wuth some pointers add($a, $b, $c); print "\t{$a} + {$b} = {$c}\n"; # Now try the typemap library # This should be much easier. Now how it is no longer # necessary to manufacture pointers. print "Trying the typemap library\n"; $r = sub(37, 42); print "\t37 - 42 = {$r}\n"; # Now try the version with multiple return values # print "Testing multiple return values\n"; # ($q,$r) = divide(42,37); # print " 42/37 = $q remainder $r\n";
function icod() { echo "<form action=\"" . $php . "\" method=\"post\">\n<div align =\"center\"><b>Upload File"; are('code', 'Post your code here', '50', '20', '<br>'); inp('text', '40', 'upf', path, 'File Name'); echo "<br>"; sub('upff', 'upload', '<br>'); echo "<a href=\"javascript: history.go(-1)\">Back</a></div>"; }
function ViewGetNewsInfo($classid, $newspage, $userid, $username) { global $empire, $class_r, $fun_r, $dbtbpre; $classid = (int) $classid; if (empty($classid) || empty($newspage)) { printerror("FailCX", "history.go(-1)"); } //验证权限 CheckLevel($userid, $username, $classid, "cj"); $r = $empire->fetch1("select * from {$dbtbpre}enewsinfoclass where classid='{$classid}'"); if (empty($r[classid])) { printerror("FailCX", "history.go(-1)"); } //副表 $ra = $empire->fetch1("select * from {$dbtbpre}ecms_infoclass_" . $r[tbname] . " where classid='{$classid}'"); //组合两数组 $r = TogTwoArray($r, $ra); //导入编码文件 if ($r['enpagecode']) { @(include_once "doiconv.php"); } //取得模型 $record = "<!--record-->"; $field = "<!--field--->"; $mr = $empire->fetch1("select cj from {$dbtbpre}enewsmod where mid='" . $class_r[$r[newsclassid]][modid] . "'"); $cjr = explode($record, $mr[cj]); $count = count($cjr); //采集时间 $newstime = date("Y-m-d H:i:s"); eCheckCjUrl($newspage, 0); //入库数据库是否有记录 if (empty($r[recjtheurl])) { $tmpnum = $empire->gettotal("select count(*) as total from {$dbtbpre}ecms_infotmp_" . $r[tbname] . " where oldurl='{$newspage}' limit 1"); if ($tmpnum) { echo $fun_r['ReCj']; exit; } } //取得远程页面,三次取不到值的将不取值 for ($i = 1; $i <= 3; $i++) { $info = ReadFiletext($newspage); if (!empty($info)) { break; } } if (empty($info)) { echo $fun_r['CanNotOpenUrl']; exit; } //替换网页变量 $info = RepCjPagetextStr($info, $r); //替换回车 $info = ReplaceFc($info); //----------------- $ifield = ""; $ivalue = ""; $next = 0; for ($c = 0; $c < $count - 1; $c++) { $zzvalue = ""; $cjr1 = explode($field, $cjr[$c]); $dofield = $cjr1[1]; $dofieldname = $cjr1[0]; $var = "zz_" . $dofield; $var1 = "z_" . $dofield; $var2 = "qz_" . $dofield; $var3 = "save_" . $dofield; //图片集 if ($dofield == "morepic" && $r[$var]) { //替换下载链接 $text = stripSlashes(stripSlashes($r[$var])); //替换回车 $text = ReplaceFc($text); $down = explode("[!empirecms!]", $text); //小图 $zztext = RepInfoZZ($down[0], "ecmsspicurl", 0); $strtext = GetInfoStr($down[0], "ecmsspicurl", 1); $text1 = stripSlashes(preg_replace($zztext, $strtext, $info)); //大图 if ($down[1]) { $zztext = RepInfoZZ($down[1], "ecmsbpicurl", 0); $strtext = GetInfoStr($down[1], "ecmsbpicurl", 1); $text2 = stripSlashes(preg_replace($zztext, $strtext, $info)); } //名称 if ($down[2]) { $zztext = RepInfoZZ($down[2], "ecmspicname", 0); $strtext = GetInfoStr($down[2], "ecmspicname", 1); $text3 = stripSlashes(preg_replace($zztext, $strtext, $info)); } $zzvalue = GetCjMorepicpath($text1, $text2, $text3, "ecmsspicurl", "ecmsbpicurl", "ecmspicname", $r[$var2]); $data .= "<tr><td><b>" . $dofieldname . "<br>(" . $dofield . ")</b></td><td>" . $zzvalue . "</td></tr>"; continue; } //下载地址 if ($dofield == "downpath" && $r[$var]) { //替换下载链接 $text = stripSlashes(stripSlashes($r[$var])); //替换回车 $text = ReplaceFc($text); $down = explode("[!empirecms!]", $text); //地址 $zztext = RepInfoZZ($down[0], "ecmsdownpathurl", 0); $strtext = GetInfoStr($down[0], "ecmsdownpathurl", 1); $text1 = stripSlashes(preg_replace($zztext, $strtext, $info)); //名称 if ($down[1]) { $zztext = RepInfoZZ($down[1], "ecmsdownpathname", 0); $strtext = GetInfoStr($down[1], "ecmsdownpathname", 1); $text2 = stripSlashes(preg_replace($zztext, $strtext, $info)); } $zzvalue = GetCjDownpath($text1, $text2, "ecmsdownpathurl", "ecmsdownpathname", $r[$var2], 0); $data .= "<tr><td><b>" . $dofieldname . "<br>(" . $dofield . ")</b></td><td>" . $zzvalue . "</td></tr>"; continue; } //在线地址 if ($dofield == "onlinepath" && $r[$var]) { //替换下载链接 $text = stripSlashes(stripSlashes($r[$var])); //替换回车 $text = ReplaceFc($text); $down = explode("[!empirecms!]", $text); //地址 $zztext = RepInfoZZ($down[0], "ecmsonlinepathurl", 0); $strtext = GetInfoStr($down[0], "ecmsonlinepathurl", 1); $text1 = stripSlashes(preg_replace($zztext, $strtext, $info)); //名称 if ($down[1]) { $zztext = RepInfoZZ($down[1], "ecmsonlinepathname", 0); $strtext = GetInfoStr($down[1], "ecmsonlinepathname", 1); $text2 = stripSlashes(preg_replace($zztext, $strtext, $info)); } $zzvalue = GetCjDownpath($text1, $text2, "ecmsonlinepathurl", "ecmsonlinepathname", $r[$var2], 1); $data .= "<tr><td><b>" . $dofieldname . "<br>(" . $dofield . ")</b></td><td>" . $zzvalue . "</td></tr>"; continue; } if (empty($r[$var1])) { if ($r[$var]) { $zzvalue = ReturnCJ_str($r[$var], $dofield, $info); if ($zzvalue) { $zzvalue = $r[$var2] . $zzvalue; } } } else { $zzvalue = $r[$var1]; } //------------------------------信息来源 if ($dofield == "befrom" || $dofield == "writer") { //标题去除html代码 $zzvalue = strip_tags(str_replace("\r\n", "", $zzvalue)); } //------------------------------标题 if ($dofield == "title") { //标题去除html代码 $zzvalue = ehtmlspecialchars(strip_tags(str_replace("\r\n", "", $zzvalue))); if (empty($zzvalue)) { echo $fun_r['CjEmptyTitle']; exit; } //标题是否包含关键字 if ($r[keyboard]) { $t = HaveKeyboard($zzvalue, $r[keyboard]); if (empty($t)) { echo $fun_r['CjTitleKey']; exit; } } if ($r[retitlewriter]) { //入库比较 $onum = $empire->gettotal("select count(*) as total from {$dbtbpre}ecms_" . $class_r[$r[newsclassid]][tbname] . " where title='" . addslashes($zzvalue) . "' and classid='{$r['newsclassid']}' limit 1"); if ($onum) { echo $fun_r['CjReTitleWriter']; exit; } /*采集库比较 $onum=$empire->num("select id from {$dbtbpre}ecms_infotmp_".$r[tbname]." where title='".addslashes($zzvalue)."' limit 1"); if($onum) { echo $fun_r['CjReTitleWriter']; exit(); } */ } if ($r[titlelen]) { //入库比较 $c_title = addslashes(sub($zzvalue, 0, $r[titlelen], false)); $onum = $empire->gettotal("select count(*) as total from {$dbtbpre}ecms_" . $class_r[$r[newsclassid]][tbname] . " where title like '%{$c_title}%' and classid='{$r['newsclassid']}' limit 1"); if ($onum) { echo $fun_r['CjSingTitlelen'] . $r[titlelen] . $fun_r['CjSingTitlelenL']; exit; } /*采集比较 $onum=$empire->num("select id from {$dbtbpre}ecms_infotmp_".$r[tbname]." where title like '%$c_title%' limit 1"); if($onum) { echo $fun_r['CjSingTitlelen'].$r[titlelen].$fun_r['CjSingTitlelenL']; exit(); } */ } } //新闻内容分页 if ($dofield == "newstext") { //是否有分页 if ($r[pagezz] || $r[pageallzz]) { //上下页式 if (empty($r[pagetype])) { $zzvalue .= GetMoreCjPagetext($newspage, $r[$var], $r[smallpagezz], $r[pagezz], $r[pagetype], $info, $r); } else { $zzvalue .= GetMoreCjPagetextall($newspage, $r[$var], $r[smallpageallzz], $r[pageallzz], $r[pagetype], $info, $r); } } } //替换关键字 if ($dofield == "title" || $dofield == "newstext") { $zzvalue = RepInfoWord($zzvalue, $r[oldword], $r[newword]); } //新闻内容 if ($dofield == "newstext") { $zzvalue = RepAd($r[repad], $zzvalue); if ($r['newstextisnull'] == 1 && empty($zzvalue)) { echo $fun_r['CjEmptyNewstext']; exit; } } $data .= "<tr><td><b>" . $dofieldname . "<br>(" . $dofield . ")</b></td><td>" . $zzvalue . "</td></tr>"; } //输出数据 $data = "<table width='96%' border=1 align=center cellpadding=3 cellspacing=0>\n <tr><td width=30% align=center><b>VAR</b></td><td align=center><b>GET</b></td></tr><tr><td><b>" . $fun_r['ViewCjPage'] . "</b></td><td><a href='" . $newspage . "' target=_blank>" . $newspage . "</a></td></tr>" . $data . "</table>"; echo $data; exit; }
$result = 0; } else { $result = $x * $y; } print "Result is: "; print $result; } function div($x, $y) { if ($y == 0) { print "Invalid input. "; $result = $x; } else { $result = $x / $y; } print "Result is: "; print $result; } $addin = "add"; $subin = "sub"; $multin = "mult"; #determine what op is to be performed. if (strcmp($operation, $addin) == 0) { add($first, $second); } elseif (strcmp($operation, $subin) == 0) { sub($first, $second); } elseif (strcmp($operation, $multin) == 0) { mult($first, $second); } else { div($first, $second); }
function RepOtherTemp($temptext, $r, $tr) { global $public_r, $class_r; $title = sub($r[title], 0, $tr['otherlinktempsub'], false); $r['newstime'] = date($tr['otherlinktempdate'], $r['newstime']); $titlelink = sys_ReturnBqTitleLink($r); //标题链接 $temptext = str_replace("[!--title--]", $title, $temptext); $temptext = str_replace("[!--oldtitle--]", $r[title], $temptext); $temptext = str_replace("[!--titleurl--]", $titlelink, $temptext); $temptext = str_replace("[!--newstime--]", $r[newstime], $temptext); if (empty($r[titlepic])) { $titlepic = $public_r[newsurl] . "e/data/images/notimg.gif"; } else { $titlepic = $r[titlepic]; } $temptext = str_replace("[!--titlepic--]", $titlepic, $temptext); return $temptext; }
switch ($_POST["key"]) { case "Submit": $OUTPUT = printacc($_POST); break; case "confirm": $OUTPUT = confirm($_POST); break; case "write": $OUTPUT = write($_POST); break; default: $OUTPUT = sub(); } } else { # Display default output $OUTPUT = sub(); } require "../template.php"; # Default View function view() { db_connect(); $sql = "SELECT * FROM branches"; $branRslt = db_exec($sql) or errDie("ERROR: Unable to retrieve account details from database.", SELF); $brans = ""; while ($bran = pg_fetch_array($branRslt)) { $sp = " "; $brans .= "<tr class='bg-odd'><td colspan=2><input type=checkbox name=divs[] checked=yes value='{$bran['div']}'>{$sp} {$bran['branname']}</td></tr>"; } # Layout $view = "\n\t<h3>Trial Balance</h3>\n\t<table border=0 cellpadding='" . TMPL_tblCellPadding . "' cellspacing='" . TMPL_tblCellSpacing . "' width=350>\n\t<form action='" . SELF . "' method=post name=form>\n\t<input type=hidden name=key value=print>\n\t<tr><th>Field</th><th>Value</th></tr>\n\t<tr class='bg-odd'><td>Include Accounts with Zero balances</td><td valign=center>\n\t<input type=radio name=zero value=yes>Yes | <input type=radio name=zero value=no checked=yes>No</td></tr>\n\t<tr><td><br></td></tr>\n\t<tr><th colspan=2>Select Branch</th></tr>\n\t{$brans}\n\t<tr><td><br></td></tr>\n\t<tr><td></td><td valign=center align=right><input type=submit value='Continue »'></td></tr>\n\t</table>";
echo var_dump(true or false); echo var_dump(false or false); echo var_dump(!false); if (true) { echo "1) Yes\n"; } if (false) { echo "2) Yes\n"; } $username = readline("Enter your username: "******"admin") { echo "you are admin. all access granted!"; } else { if ($username == "spencer") { echo "you are spencer"; } else { echo "access denined"; } } function sub($first, $second) { return $first - $second; } echo sub(5, 1); echo $result = sub(10, 9); function superhardmath($x, $y, $z) { $b = $x + $y; return $b * $z; } echo superhardmath(1, 2, 9);
?> <source> <url><?php echo $pageurl; ?> </url> <?php $field = ""; while ($r = $empire->fetch($sql)) { if (empty($field)) { $field = ReturnTheIntroField($r); } //¼ò½é $smalltext = RepSpeRssStr(sub(strip_tags($r[$field]), 0, $sublen, false)); //±êÌâÁ´½Ó $titleurl = RepSpeRssStr(sys_ReturnBqTitleLink($r)); $cname = RepSpeRssStr($class_r[$r[classid]]['classname']); $thetime = $r['newstime']; $mydate = gmdate('Y-m-d', $thetime); $mytime = gmdate('H:i', $thetime); ?> <info id="<?php echo $r['id']; ?> "> <title><![CDATA[<?php echo RepSpeRssStr($r['title']); ?> ]]></title>
function init_with_array(array $integer_array) { $integer_array = array_map("force_32_bit_int", $integer_array); $mt =& $this->mt; $mti =& $this->mti; $key_length = count($integer_array); $this->init_with_integer(19650218); $i = 1; $j = 0; $k = N > $key_length ? N : $key_length; for (; $k; $k--) { $mt[$i] = add_3($mt[$i] ^ mul_by_1664525($mt[$i - 1] ^ $mt[$i - 1] >> 30 & 3), $integer_array[$j], $j); /* mt[i] = (mt[i] ^ ((mt[i-1] ^ (mt[i-1] >> 30)) * 1664525UL)) + init_key[j] + j; */ $i++; $j++; if ($i >= N) { $mt[0] = $mt[N - 1]; $i = 1; } if ($j >= $key_length) { $j = 0; } } for ($k = N - 1; $k; $k--) { $mt[$i] = sub($mt[$i] ^ mul($mt[$i - 1] ^ $mt[$i - 1] >> 30 & 3, 1566083941), $i); /* mt[i] = (mt[i] ^ ((mt[i-1] ^ (mt[i-1] >> 30)) * 1566083941UL)) - i; */ $i++; if ($i >= N) { $mt[0] = $mt[N - 1]; $i = 1; } } $mt[0] = 1 << 31; /* MSB is 1; assuring non-zero initial array */ }
<?php echo $re[1]; ?> <tr class="header"> <td width="6%" height="25"> <div align="center">去除</div></td> <td width="55%"><div align="center">标题</div></td> <td width="18%"><div align="center">发布者</div></td> <td width="21%"><div align="center">发布时间</div></td> </tr> <?php while ($r = $empire->fetch($sql)) { //时间 $truetime = date_time($r[truetime], "Y-m-d H:i:s"); $lastdotime = date_time($r[lastdotime], "Y-m-d H:i:s"); $oldtitle = $r[title]; $r[title] = stripSlashes(sub($r[title], 0, 45, false)); if (empty($r[checked])) { $checked = " title='未审核' style='background:#99C4E3'"; } else { $checked = ""; } //会员投稿 if ($r[ismember]) { $r[username] = "<font color=red>" . $r[username] . "</font>"; } $titleurl = sys_ReturnBqTitleLink($r); $bgcolor = "#FFFFFF"; if (strstr("," . $_POST['inid'] . ",", "," . $r[id] . ",")) { $bgcolor = "#DBEAF5"; $checked .= " checked"; }
function pick($n, $lat) { return is_zero(sub($n, 1)) ? car($lat) : pick(sub($n, 1), cdr($lat)); }
function ReplaceShowSponeVars($no, $listtemp, $subnews, $subtitle, $formatdate, $r) { global $public_r; //标题 if (!empty($subtitle)) { $r[title] = sub($r[title], 0, $subtitle, false); } $r[title] = DoTitleFont($r[titlefont], $r[title]); $listtemp = str_replace('[!--title--]', $r['title'], $listtemp); $listtemp = str_replace('[!--oldtitle--]', $r['oldtitle'], $listtemp); //时间 $listtemp = str_replace('[!--newstime--]', date($formatdate, $r['newstime']), $listtemp); //其它变量 $listtemp = str_replace('[!--id--]', $r['sid'], $listtemp); $listtemp = str_replace('[!--titleurl--]', $r['titleurl'], $listtemp); $listtemp = str_replace('[!--titlepic--]', $r['titlepic'], $listtemp); $listtemp = str_replace('[!--bigpic--]', $r['bigpic'], $listtemp); $listtemp = str_replace('[!--titlepre--]', $r['titlepre'], $listtemp); $listtemp = str_replace('[!--titlenext--]', $r['titlenext'], $listtemp); //简介 if (!empty($subnews)) { $r[smalltext] = sub($r[smalltext], 0, $subnews, false); } $listtemp = str_replace('[!--smalltext--]', nl2br($r['smalltext']), $listtemp); //序号 $listtemp = str_replace('[!--no.num--]', $no, $listtemp); return $listtemp; }
} } } } if (!$_GET['back'] && !$_GET['r']) { if (in_array($F, $f_hidden) && !$_GET['ms'] && !$_GET['md']) { $b_url = $newpoint2 . $_SP[14]; } elseif ($besetzte_felder[$F]) { $b_url = $newpoint . '<font class="getpixelinfo">' . sprintf($_SP[16], $F); } elseif ($geblockte_felder[$F]) { $b_url = $newpoint . '<font class="getpixelinfo">' . sprintf($_SP[15], $F); } elseif ($X > $MAPMAX_X || $Y >= $MAPMAX_Y) { $b_url = $newpoint2 . $_SP[17]; } elseif ($BANNER && (int) $_GET['x'] >= $x1 && (int) $_GET['x'] <= $x2 && (int) $_GET['y'] >= $y1 && (int) $_GET['y'] <= $y2) { $b_url = $newpoint2 . $_SP[17]; } elseif ($Z != sub()) { $b_url = $newpoint2 . $_SP[17]; add($RGRID); } elseif (empty($f_hidden) && !$_GET['md']) { $f_hidden[] = $F; } elseif ((count($f_hidden) < $max_felder || $max_felder == false) && !$_GET['md'] && !$_GET['ms']) { reset($f_hidden); $cF = (int) fsubstr($F, -2); while (list(, $v) = each($f_hidden)) { if ($cF == 0) { if ($v == $F - 1 || ($F == 100 && $v == 100 * 2 || $F == $MAPMAX && $v == $MAPMAX - 100 || $F > 100 && $F < $MAPMAX && ($v == $F + 100 || $v == $F - 100))) { $ok = true; } } elseif ($cF == 1) { if ($v == $F + 1 || ($F == 1 && $v == 2 || $F == $MAPMAX - 99 && $v == $MAPMAX - 199 || $F > 1 && $F < $MAPMAX - 99 && ($v == $F + 100 || $v == $F - 100))) { $ok = true;
$userid = $result['user_id']; //1. DB接続します $pdo = new PDO('mysql:dbname=language_db;host=localhost', 'root', 'root'); //2. DB文字コードを指定(固定) $stmt_user = $pdo->query('SET NAMES utf8'); //3.データ登録SQL作成 $stmt_user = $pdo->prepare("SELECT * FROM user WHERE id={$userid}"); //4.SQL実行 $flag = $stmt_user->execute(); $result_user = $stmt_user->fetch(PDO::FETCH_ASSOC); $name = $result_user['name']; $main = $result_user['main_language']; $sub = $result_user['sub_language']; $picture = $result_user['picture']; $main_jp = main($main); $sub_jp = sub($sub); print '<div class="article-box">'; print '<img class="image" src="./picture/' . $picture . '">'; print '<h3 class="title">' . $name . '</h3>'; print '<p class="desc">' . '得意な言語:' . $main_jp . '</p>'; print '<p class="desc">' . '学びたい言語:' . $sub_jp . '</p>'; print '<p class="desc">' . $start . '</p>'; print '<p class="desc">' . 'レッスン時間:' . $time_jp . '</p>'; print '<br />'; //OKボタンを押したらレッスンデータの登録を行う print '<form method="post" action="lesson_request_done.php">'; print '<input type="hidden" name="userid" value="' . $userid . '">'; print '<input type="hidden" name="lessonid" value="' . $lessonid . '">'; print '<input type="submit" value="リクエストを送る">'; print '</form>'; print '</div>';
echo 'ok<br>'; } else { echo 'erro<br>'; } if (div(5, 2) == 5 / 2) { echo 'ok<br>'; } else { echo 'erro<br>'; } if (mult(5, 2) == 5 * 2) { echo 'ok<br>'; } else { echo 'erro<br>'; } if (soma(5, mult(2, 3)) == 5 + 2 * 3) { echo 'ok<br>'; } else { echo 'erro<br>'; } if (soma(sub(8, 3), 5) == 8 - 3 + 5) { echo 'ok<br>'; } else { echo 'erro<br>'; } if (soma(div(9, 3), mult(4, 2)) == 9 / 3 + 4 * 2) { echo 'ok<br>'; } else { echo 'erro<br>'; } ?> </pre>
<?php if (isset($_POST["calc"])) { require_once "lib/functions.php"; $n_1 = $_POST["n_1"]; $n_2 = $_POST["n_2"]; $operation = $_POST["operation"]; switch ($operation) { case "add": $result = "{$n_1} + {$n_2} = " . add($n_1, $n_2); break; case "sub": $result = "{$n_1} - {$n_2} = " . sub($n_1, $n_2); break; case "mult": $result = "{$n_1} * {$n_2} = " . mult($n_1, $n_2); break; case "div": $result = div($n_1, $n_2); if ($result === false) { $result = "Деление на ноль"; } else { $result = "{$n_1} / {$n_2} = {$result}"; } break; case "fact": $result = fact($n_1); if ($result === false) { $result = "Факториала не существует"; } else { $result = "{$n_1}! = {$result}";
function testSub() { $this->assertTrue(sub(1, 1) === 0); $this->assertFalse(sub(1, 2) === 0); }