public function login($nick = "", $clave = "") { if (emptyempty($nick) || emptyempty($clave)) { return FALSE; } $this->CI =& get_instance(); $loginValido = $this->mod_usu->comprobarUsuarioYPassword($nick, $clave); //login ok if ($loginValido) { $this->CI->session->set_userdata('id', $loginValido->id_usuario); $this->_id = $loginValido->id_usuario; $this->CI->session->set_userdata('nombreRegistro', $nick); $this->_nombreRegistro = $nick; $this->CI->session->set_userdata('pass', $clave); $this->_pass = $clave; $this->CI->session->set_userdata('nivel', $loginValido->nivel_usuario); $this->_nivel = $loginValido->nivel_usuario; $this->_autentificado = TRUE; return TRUE; } else { $this->_autentificado = FALSE; $this->logout(); return FALSE; } }
function upload() { //文件上传地址提交给他,并且上传完成之后返回一个信息,让其写入数据库 if (emptyempty($_FILES)) { $this->error('必须选择上传文件'); } else { $a = $this->up(); if (isset($a)) { //写入数据库的自定义c方法 if ($this->c($a)) { $this->success('上传成功'); } else { $this->error('写入数据库失败'); } } else { $this - error('上传文件异常,请与系统管理员联系'); } } }
public function realIp() { static $realip = NULL; if ($realip !== NULL) { return $realip; } if (isset($_SERVER)) { if (isset($_SERVER['HTTP_X_FORWARDED_FOR'])) { $arr = explode(',', $_SERVER['HTTP_X_FORWARDED_FOR']); foreach ($arr as $ip) { $ip = trim($ip); if ($ip != 'unknown') { $realip = $ip; break; } } } elseif (isset($_SERVER['HTTP_CLIENT_IP'])) { $realip = $_SERVER['HTTP_CLIENT_IP']; } else { if (isset($_SERVER['REMOTE_ADDR'])) { $realip = $_SERVER['REMOTE_ADDR']; } else { $realip = '0.0.0.0'; } } } else { if (getenv('HTTP_X_FORWARDED_FOR')) { $realip = getenv('HTTP_X_FORWARDED_FOR'); } elseif (getenv('HTTP_CLIENT_IP')) { $realip = getenv('HTTP_CLIENT_IP'); } else { $realip = getenv('REMOTE_ADDR'); } } preg_match("/[\\d\\.]{7,15}/", $realip, $onlineip); $realip = !emptyempty($onlineip[0]) ? $onlineip[0] : '0.0.0.0'; return $realip; }
private function imageWaterMark($groundImage, $waterPos = 0, $waterImage = "", $waterText = "", $textFont = 5, $textColor = "#FF0000") { $isWaterImage = FALSE; $formatMsg = "暂不支持该文件格式,请用图片处理软件将图片转换为GIF、JPG、PNG格式。"; //读取水印文件 if (!empty($waterImage) && file_exists($waterImage)) { $isWaterImage = TRUE; $water_info = getimagesize($waterImage); $water_w = $water_info[0]; //取得水印图片的宽 $water_h = $water_info[1]; //取得水印图片的高 switch ($water_info[2]) { case 1: $water_im = imagecreatefromgif($waterImage); break; case 2: $water_im = imagecreatefromjpeg($waterImage); break; case 3: $water_im = imagecreatefrompng($waterImage); break; default: die($formatMsg); } } //读取背景图片 if (!empty($groundImage) && file_exists($groundImage)) { $ground_info = getimagesize($groundImage); $ground_w = $ground_info[0]; //取得背景图片的宽 $ground_h = $ground_info[1]; //取得背景图片的高 switch ($ground_info[2]) { case 1: $ground_im = imagecreatefromgif($groundImage); break; case 2: $ground_im = imagecreatefromjpeg($groundImage); break; case 3: $ground_im = imagecreatefrompng($groundImage); break; default: die($formatMsg); } } else { die("需要加水印的图片不存在!"); } //水印位置 if ($isWaterImage) { $w = $water_w; $h = $water_h; $label = "图片的"; } else { $temp = imagettfbbox(ceil($textFont * 5), 0, "./cour.ttf", $waterText); //取得使用 TrueType 字体的文本的范围 $w = $temp[2] - $temp[6]; $h = $temp[3] - $temp[7]; unset($temp); $label = "文字区域"; } if ($ground_w < $w || $ground_h < $h) { echo "需要加水印的图片的长度或宽度比水印" . $label . "还小,无法生成水印!"; return; } switch ($waterPos) { case 0: //随机 $posX = rand(0, $ground_w - $w); $posY = rand(0, $ground_h - $h); break; case 1: //1为顶端居左 $posX = 0; $posY = 0; break; case 2: //2为顶端居中 $posX = ($ground_w - $w) / 2; $posY = 0; break; case 3: //3为顶端居右 $posX = $ground_w - $w; $posY = 0; break; case 4: //4为中部居左 $posX = 0; $posY = ($ground_h - $h) / 2; break; case 5: //5为中部居中 $posX = ($ground_w - $w) / 2; $posY = ($ground_h - $h) / 2; break; case 6: //6为中部居右 $posX = $ground_w - $w; $posY = ($ground_h - $h) / 2; break; case 7: //7为底端居左 $posX = 0; $posY = $ground_h - $h; break; case 8: //8为底端居中 $posX = ($ground_w - $w) / 2; $posY = $ground_h - $h; break; case 9: //9为底端居右 $posX = $ground_w - $w - 10; // -10 是距离右侧10px 可以自己调节 $posY = $ground_h - $h - 10; // -10 是距离底部10px 可以自己调节 break; default: //随机 $posX = rand(0, $ground_w - $w); $posY = rand(0, $ground_h - $h); break; } //设定图像的混色模式 imagealphablending($ground_im, true); if ($isWaterImage) { imagecopy($ground_im, $water_im, $posX, $posY, 0, 0, $water_w, $water_h); //拷贝水印到目标文件 } else { if (!emptyempty($textColor) && strlen($textColor) == 7) { $R = hexdec(substr($textColor, 1, 2)); $G = hexdec(substr($textColor, 3, 2)); $B = hexdec(substr($textColor, 5)); } else { die("水印文字颜色格式不正确!"); } imagestring($ground_im, $textFont, $posX, $posY, $waterText, imagecolorallocate($ground_im, $R, $G, $B)); } //生成水印后的图片 @unlink($groundImage); switch ($ground_info[2]) { case 1: imagegif($ground_im, $groundImage); break; case 2: imagejpeg($ground_im, $groundImage); break; case 3: imagepng($ground_im, $groundImage); break; default: die($errorMsg); } //释放内存 if (isset($water_info)) { unset($water_info); } if (isset($water_im)) { imagedestroy($water_im); } unset($ground_info); imagedestroy($ground_im); }
<!DOCTYPE html> <?php if (isset($_POST['enter'])) { if (emptyempty($_POST['bidang'])) { echo "Anda belum memilih!"; } else { echo "Pilihan anda: " . $_POST['bidang']; } } ?> <html> <head> <title>Dinas Tenaga Kerja, Transmigrasi dan Kependudukan</title> <meta name="description" content="website description" /> <meta name="keywords" content="website keywords, website keywords" /> <meta http-equiv="content-type" content="text/html; charset=windows-1252" /> <link rel="stylesheet" type="text/css" href="css/style.css" /> <!-- modernizr enables HTML5 elements and feature detects --> <script type="text/javascript" src="js/modernizr-1.5.min.js"></script> </head> <body> <div id="main"> <header> <div id="banner"> <div id="welcome"> <h2>Dinas Tenaga Kerja, Transmigrasi dan Kependudukan</h2> </div><!--close welcome--> <div class="slideshow">
{ foreach ($ArrFiltrate as $key => $value) { if (eregi($value, $StrFiltrate)) { return true; } } return false; } //合并$_POST 和 $_GET if (function_exists(array_merge)) { $ArrPostAndGet = array_merge($HTTP_POST_VARS, $HTTP_GET_VARS); } else { foreach ($HTTP_POST_VARS as $key => $value) { $ArrPostAndGet[] = $value; } foreach ($HTTP_GET_VARS as $key => $value) { $ArrPostAndGet[] = $value; } } //验证开始 foreach ($ArrPostAndGet as $key => $value) { if (FunStringExist($value, $ArrFiltrate)) { echo "<script language=\"javascript\">alert(\"非法字符\");</script>"; if (emptyempty($StrGoUrl)) { echo "<script language=\"javascript\">history.go(-1);</script>"; } else { echo "<script language=\"javascript\">window.location=\"" . $StrGoUrl . "\";</script>"; } exit; } }
function par_pagenavi($range = 9) { if (is_singular()) { return; } global $wp_query, $paged; $max_page = $wp_query->max_num_pages; if ($max_page == 1) { return; } if (emptyempty($paged)) { $paged = 1; } echo '<span class="page-numbers">' . 第 . $paged . 页 . (共 . $max_page . 页) . ' </span> '; global $paged, $wp_query; if (!$max_page) { $max_page = $wp_query->max_num_pages; } if ($max_page > 1) { if (!$paged) { $paged = 1; } if ($paged != 1) { echo "<a href='" . get_pagenum_link(1) . "' class='extend' title='跳转到首页'> NO.1 </a>"; } previous_posts_link(' « '); if ($max_page > $range) { if ($paged < $range) { for ($i = 1; $i <= $range + 1; $i++) { echo "<a href='" . get_pagenum_link($i) . "'"; if ($i == $paged) { echo " class='current'"; } echo ">{$i}</a>"; } } elseif ($paged >= $max_page - ceil($range / 2)) { for ($i = $max_page - $range; $i <= $max_page; $i++) { echo "<a href='" . get_pagenum_link($i) . "'"; if ($i == $paged) { echo " class='current'"; } echo ">{$i}</a>"; } } elseif ($paged >= $range && $paged < $max_page - ceil($range / 2)) { for ($i = $paged - ceil($range / 2); $i <= $paged + ceil($range / 2); $i++) { echo "<a href='" . get_pagenum_link($i) . "'"; if ($i == $paged) { echo " class='current'"; } echo ">{$i}</a>"; } } } else { for ($i = 1; $i <= $max_page; $i++) { echo "<a href='" . get_pagenum_link($i) . "'"; if ($i == $paged) { echo " class='current'"; } echo ">{$i}</a>"; } } next_posts_link(' » '); if ($paged != $max_page) { echo "<a href='" . get_pagenum_link($max_page) . "' class='extend' title='跳转到最后一页'> END </a>"; } } }
private function handleChat($obj){ $keywords=$obj->Content; $curlPost=array("chat"=>$keywords); $ch = curl_init();//初始化curl curl_setopt($ch, CURLOPT_URL,'http://www.xiaojo.com/bot/chata.php');//抓取指定网页 curl_setopt($ch, CURLOPT_HEADER, 0);//设置header curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);//要求结果为字符串且输出到屏幕上 curl_setopt($ch, CURLOPT_POST, 1);//post提交方式 curl_setopt($ch, CURLOPT_POSTFIELDS, $curlPost); $data = curl_exec($ch);//运行curl curl_close($ch); if(!emptyempty($data)){ $contentStr=$data; }else{ $ran=rand(1,5); switch($ran){ case 1: $contentStr= "小九今天累了,明天再陪你聊天吧"; break; case 2: $contentStr= "小九睡觉喽~~"; break; case 3: $contentStr= "呼呼~~呼呼~~"; break; case 4: $contentStr= "你话好多啊,不跟你聊了"; break; case 5: $contentStr= "你话好多啊,不跟你聊了"; break; } } return $contentStr; }
/** * 获取用户IP地址 */ function getIP() { if (!emptyempty($_SERVER['HTTP_CLIENT_IP'])) { $ip = $_SERVER['HTTP_CLIENT_IP']; } elseif (!emptyempty($_SERVER['HTTP_X_FORWARDED_FOR'])) { $ip = $_SERVER['HTTP_X_FORWARDED_FOR']; } else { $ip = $_SERVER['REMOTE_ADDR']; } return $ip; }
/** * 查找记录 * * 参数: * $table_name:表名 * $query_condition:字段查找条件 * $result_condition:查询结果限制条件-limit/sort等 * $fields:获取字段 * * 返回值: * 成功:记录集 * 失败:false */ function find($table_name, $query_condition, $result_condition = array(), $fields = array()) { $dbname = $this->curr_db_name; $cursor = $this->mongo->{$dbname}->{$table_name}->find($query_condition, $fields); if (!emptyempty($result_condition['start'])) { $cursor->skip($result_condition['start']); } if (!emptyempty($result_condition['limit'])) { $cursor->limit($result_condition['limit']); } if (!emptyempty($result_condition['sort'])) { $cursor->sort($result_condition['sort']); } $result = array(); try { while ($cursor->hasNext()) { $result[] = $cursor->getNext(); } } catch (MongoConnectionException $e) { $this->error = $e->getMessage(); return false; } catch (MongoCursorTimeoutException $e) { $this->error = $e->getMessage(); return false; } return $result; }
function downloadfile($filepath, $filename = '') { global $encoding; if (!file_exists($filepath)) { return 1; } if ('' == $filename) { $tem = explode('/', $filepath); $num = count($tem) - 1; $filename = $tem[$num]; $filetype = substr($filepath, strrpos($filepath, ".") + 1); } else { $filetype = substr($filename, strrpos($filename, ".") + 1); } $filename = '"' . (strtolower($encoding) == 'utf-8' && !(strpos($_SERVER['HTTP_USER_AGENT'], 'MSIE') === FALSE) ? urlencode($filename) : $filename) . '"'; $filesize = filesize($filepath); $dateline = time(); file::hheader('date: ' . gmdate('d, d m y h:i:s', $dateline) . ' gmt'); file::hheader('last-modified: ' . gmdate('d, d m y h:i:s', $dateline) . ' gmt'); file::hheader('content-encoding: none'); file::hheader('content-disposition: attachment; filename=' . $filename); file::hheader('content-type: ' . $filetype); file::hheader('content-length: ' . $filesize); file::hheader('accept-ranges: bytes'); if (!@emptyempty($_SERVER['HTTP_RANGE'])) { list($range) = explode('-', str_replace('bytes=', '', $_SERVER['HTTP_RANGE'])); $rangesize = $filesize - $range > 0 ? $filesize - $range : 0; file::hheader('content-length: ' . $rangesize); file::hheader('http/1.1 206 partial content'); file::hheader('content-range: bytes=' . $range . '-' . ($filesize - 1) . '/' . $filesize); } if ($fp = @fopen($filepath, 'rb')) { @fseek($fp, $range); echo fread($fp, filesize($filepath)); } fclose($fp); flush(); ob_flush(); }
/** * 根据距离正月初一的天数计算阴历日期 * @param year 阳历年 * @param between 天数 */ function getLunarByBetween($year, $between) { //debugger; $lunarArray = array(); $yearMonth = array(); $t = 0; $e = 0; $leapMonth = 0; $m = ''; if ($between == 0) { array_push($lunarArray, $year, '正月', '初一'); $t = 1; $e = 1; } else { $year = $between > 0 ? $year : $year - 1; $yearMonth = $this->getLunarYearMonths($year); $leapMonth = $this->getLeapMonth($year); $between = $between > 0 ? $between : $this->getLunarYearDays($year) + $between; for ($i = 0; $i < 13; $i++) { if ($between == $yearMonth[$i]) { $t = $i + 2; $e = 1; break; } else { if ($between < $yearMonth[$i]) { $t = $i + 1; $e = $between - (emptyempty($yearMonth[$i - 1]) ? 0 : $yearMonth[$i - 1]) + 1; break; } } } $m = $leapMonth != 0 && $t == $leapMonth + 1 ? '闰' . $this->getCapitalNum($t - 1, true) : $this->getCapitalNum($leapMonth != 0 && $leapMonth + 1 < $t ? $t - 1 : $t, true); array_push($lunarArray, $year, $m, $this->getCapitalNum($e, false)); } array_push($lunarArray, $this->getLunarYearName($year)); // 天干地支 array_push($lunarArray, $t, $e); array_push($lunarArray, $this->getYearZodiac($year)); // 12生肖 array_push($lunarArray, $leapMonth); // 闰几月 return $lunarArray; }
<?php header('Content-Type:text/html; charset=utf-8'); if (emptyempty($_GET)) { exit('您还未登录'); } else { foreach ($_GET as $key => $val) { setcookie($key, $val, 0, ''); } header("location:index.php"); }
<?php echo "1111"; if (isset($_POST["upload"])) { //Get the file information $userfile_name = $_FILES["image"]["name"]; $userfile_tmp = $_FILES["image"]["tmp_name"]; $userfile_size = $_FILES["image"]["size"]; $filename = basename($_FILES["image"]["name"]); $file_ext = substr($filename, strrpos($filename, ".") + 1); //Only process if the file is a JPG and below the allowed limit if (!emptyempty($_FILES["image"]) && $_FILES["image"]["error"] == 0) { if ($file_ext != "jpg" && $userfile_size > $max_file) { $error = "ONLY jpeg images under 1MB are accepted for upload"; } } else { $error = "Select a jpeg image for upload"; } //Everything is ok, so we can upload the image. if (strlen($error) == 0) { if (isset($_FILES["image"]["name"])) { move_uploaded_file($userfile_tmp, $large_image_location); chmod($large_image_location, 0777); $width = getWidth($large_image_location); $height = getHeight($large_image_location); //Scale the image if it is greater than the width set above if ($width > $max_width) { $scale = $max_width / $width; $uploaded = resizeImage($large_image_location, $width, $height, $scale); } else { $scale = 1;
public function bfs() { $this->hasList = array(); $this->queue = array(); foreach ($this->arc as $key => $value) { if (!in_array($key, $this->hasList)) { $this->hasList[] = $key; $this->queue[] = $value; while (!emptyempty($this->queue)) { $child = array_shift($this->queue); foreach ($child as $k => $v) { if ($v == 1 && !in_array($k, $this->hasList)) { $this->hasList[] = $k; $this->queue[] = $this->arc[$k]; } } } } } return implode($this->hasList); }