public function getNowDate() { $this->load->library('lunar'); $lunar = new Lunar(); $month = $lunar->convertSolarToLunar(date('Y'), date('m'), date('d')); $weekArr = array("日", "一", "二", "三", "四", "五", "六"); $week = "星期" . $weekArr[date("w")]; return date('Y') . '年' . date('m') . '月' . date('d') . '日' . ' ' . $week . ' ' . $month[3] . '年 ' . $month[1] . $month[2]; }
function get($string) { $lunar = new Lunar(); $d = $lunar->convertSolarToLunar(date('Y'), date('m'), date('d')); $jr = $lunar->getFestival(date('Y-m-d')); $str = date('Y-m-d H:i:s') . "\n农历:" . $d[3] . '[' . $d[6] . ']年' . $d[1] . $d[2]; if (!empty($jr)) { $str .= "\n今天是:" . $jr; } return array('code' => 1, 'msg' => $str); }
/** * 单例模式 * @return Contact_Model */ public static function &instance() { if (!isset(self::$instance)) { // Create a new instance self::$instance = new Lunar(); } return self::$instance; }
$Sday = $days - $this->_SMDay[1]; } else { $Smonth = 1; $Sday = $days; } } else { $Syear = $year; for ($i = 1; $i <= 12; $i++) { if ($days > $this->GetSMon($Syear, $i)) { $days -= $this->GetSMon($Syear, $i); } else { $Smonth = $i; $Sday = $days; break; } } } return mktime(0, 0, 0, $Smonth, $Sday, $Syear); //$Sdate = $Syear."-".$Smonth."-".$Sday; //return $Sdate; } } $today = date("Y-m-d"); $lunar = new Lunar(); //公历转农历 $nl = date("Y-m-d", $lunar->S2L($today)); //农历转公历 $gl = date("Y-m-d", $lunar->L2S($nl)); echo "今天公历是:{$today}<br/>"; echo "转为农历是:{$nl}<br/>"; echo "转回公历是:{$gl}<br/>";
/** * 修改下次提醒时间 */ function setLastdate() { global $adb, $log; $log->debug("Entering setLastdate() method ..."); $query = "select memdaysid,memday940,memday1004,memday946 from ec_memdays \n\t\t\t\t\twhere deleted = 0 and memday946 < '{$nowdate}' "; $result = $adb->getList($query); $nowyear = date("Y"); $nowmonth = date("m"); $nowday = date("d"); $nowdate = date("Y-m-d"); foreach ($result as $row) { $memdaysid = $row["memdaysid"]; $dateval = $row["memday940"]; $calendar = $row["memday1004"]; $lastval = $row["memday946"]; if ($calendar == '公历') { $datearr = explode("-", $lastval); $year = $datearr[0] + 0; $month = $datearr[1] + 0; $days = $datearr[2] + 0; $lastdate = sprintf("%d-%02d-%02d", $year + 1, $month, $days); } else { $montharr = array("正月" => "1", "二月" => "2", "三月" => "3", "四月" => "4", "五月" => "5", "六月" => "6", "七月" => "7", "八月" => "8", "九月" => "9", "十月" => "10", "十一月" => "11", "腊月" => "12"); $daysarr = array("初一" => "1", "初二" => "2", "初三" => "3", "初四" => "4", "初五" => "5", "初六" => "6", "初七" => "7", "初八" => "8", "初九" => "9", "初十" => "10", "十一" => "11", "十二" => "12", "十三" => "13", "十四" => "14", "十五" => "15", "十六" => "16", "十七" => "17", "十八" => "18", "十九" => "19", "二十" => "20", "二十一" => "21", "二十二" => "22", "二十三" => "23", "二十四" => "24", "二十五" => "25", "二十六" => "26", "二十七" => "27", "二十八" => "28", "二十九" => "29", "三十" => "30"); $lastdatearr = explode(" ", $lastval); $year = $lastdatearr[0] + 0; $datearr = explode(" ", $dateval); $monthval = $montharr[$datearr[1]]; $daysval = $daysarr[$datearr[2]]; require_once 'modules/Memdays/Lunar.php'; $lunar = new Lunar(); //今年 $yeardate = sprintf("%d-%02d-%02d", $year, $monthval, $daysval); $gl = $lunar->L2S($yeardate); $lastdate = date("Y-m-d", $gl); if ($lastdate < $nowdate) { $yeardate = sprintf("%d-%02d-%02d", $year + 1, $monthval, $daysval); $gl = $lunar->L2S($yeardate); $lastdate = date("Y-m-d", $gl); } } $upquery = "update ec_memdays set memday946 = '{$lastdate}' where memdaysid = {$memdaysid} "; $adb->query($upquery); } $log->debug("Exiting setLastdate method ..."); }
public function birthday() { $this->logFileName = 'birthday'; //生日提醒锁 $cache = new Cache('remind_birthday'); if ($cache->get('lock')) { return false; } else { $cache->set('lock', true, 86000); } $zh2num = ['零' => 0, '一' => 1, '二' => 2, '三' => 3, '四' => 4, '五' => 5, '六' => 6, '七' => 7, '八' => 8, '九' => 9]; $lunar = new \Lunar(); $date = $lunar->convertSolarToLunar(date('Y'), date('m'), date('d')); $sql = "SELECT `sid`, `name`, `phone`, `mail`, `birthday` FROM `student`\n WHERE (`birthday` LIKE ? OR `birthday` LIKE ?)\n AND `sid` IN (SELECT `uid` FROM `user`)"; $arr = array('____' . date('md'), '____' . $date[1] . $date[2]); $users = Mysql::execute($sql, $arr); $group = new \Hnust\Analyse\Group(); foreach ($users as $user) { if (is_numeric($user['birthday'])) { $year = (int) substr($user['birthday'], 0, 4); } else { $year = 0; for ($i = 0; $i < 4; $i++) { $year *= 10; $year += $zh2num[mb_substr($user['birthday'], $i, 1, 'utf-8')]; } } //计算所属群组 $groups = ['Tick网络工作室']; $belong = $group->belong($user['sid']); foreach ($belong as $item) { if (!in_array($item['name'], $groups)) { $groups[] = $item['name']; } } $user['sms'] = array('name' => $user['name'], 'age' => (string) (date('Y') - $year), 'group' => implode('、', $groups), 'template' => 'SMS_7745798'); $this->remind($user, '生日快乐', '生日快乐', '', '0001'); } $this->record("=== 生日提醒执行完成 ==="); }
exit; } $sql = 'UPDATE ' . $GLOBALS['ecs']->table('users') . " SET eff_id={$effId} WHERE user_id={$userId}"; if ($GLOBALS['db']->query($sql)) { $sql = 'SELECT eff_name FROM ' . $GLOBALS['ecs']->table('effects') . " WHERE eff_id={$effId}"; echo $json->encode(array('code' => 1, 'msg' => $GLOBALS['db']->getOne($sql), 'ele' => $userId)); exit; } else { echo $json->encode(array('code' => 0, 'msg' => '出错啦,请稍后再试')); exit; } } elseif ($_REQUEST['act'] == 'calendar') { require '..\\includes\\cls_json.php'; require 'includes\\lunar.php'; $json = new JSON(); $lunar = new Lunar(); if ($_REQUEST['type'] == 2) { $nl = date("Y-m-d", $lunar->S2L($_REQUEST['birthday'])); echo $temp = $json->encode(array('type' => '农历:', 'date' => $nl)); } else { //$date = $lunar->convertLunarToSolar($date[0], $date[1], $date[2]); $gl = date("Y-m-d", $lunar->L2S($_REQUEST['birthday'])); die($json->encode(array('type' => '公历:', 'date' => $gl))); } } elseif ($_REQUEST['act'] == 'find_referrer') { $keyword = intval($_REQUEST['keywords']); $sql = 'SELECT user_id,user_name FROM ' . $GLOBALS['ecs']->table('users') . " WHERE home_phone LIKE '%{$keyword}%' OR mobile_phone='{$keyword}'"; if ($_SESSION['role_id'] > 0) { $sql .= " AND role_id={$_SESSION['role_id']} "; } $res = $GLOBALS['db']->getAll($sql);
//圣诞节(共5天) if ($xmas) { //圣诞帽 if ($config["ui-head"] != "N") { echo '<div id="newyear"><img id="lanternPoint" src="static/image/hat.png" alt="圣诞节快乐!" /></div>'; } //下雪花 if ($config["ui-snow"] != "N") { echo '<script src="source/snow/jsized.snow.min.js" type="text/javascript"></script><script type="text/javascript">createSnow("source/snow/", 60);</script>'; //积雪 echo '<div id="snow"></div>'; } } /***********************/ //农历春节(共30天) $lunar = new Lunar(); //得到今年春节的日期 $date = $lunar->getLar(date("Y") . '-12-31', 1); //15天 $day15 = 3600 * 24 * 10; //前后15天,共30天 if ($date - $day15 <= time() && $date + $day15 >= time()) { //圣诞帽 echo '<div id="newyear" class="spring"><img id="lanternPoint" src="static/images/spring.png" alt="农历春节!" /></div>'; } ?> <script type="text/javascript"> Mo.reader( function(){
<?php header('Access-Control-Allow-Origin: *'); header("Content-Type:text/javascript;charset=utf-8"); $lunar = new Lunar(); $year = date("Y"); $month = date("n"); $day = date("j"); $ldate = $lunar->convertSolarToLunar($year, $month, $day); echo 'lunar({"year":"' . $ldate[0] . '","month":"' . $ldate[1] . '","day":"' . $ldate[2] . '","zodiac":"' . $ldate[6] . '","sign":"' . $ldate[3] . '"})';
} }); } </script> </div> <!-- 循环展示提示语 --> <div class="row qiandao"> <div id="scrollDiv"> <ul> <?php $show_birthday = "select * from users"; $show_birthday_query = mysqli_query($con, $show_birthday); while ($show_birthday_array = mysqli_fetch_array($show_birthday_query)) { $date = date("Y-m-d"); if ($show_birthday_array['isnongli'] == 1) { $lunar = new Lunar(); $date = date("Y-m-d", $lunar->S2L($date)); } if (date("m-d", strtotime($date)) == date("m-d", strtotime($show_birthday_array['birthday']))) { echo "<li>今天是" . $show_birthday_array['name'] . "的" . $rili[$show_birthday_array['isnongli']] . "生日</li>"; } } ?> <li>当你的翅膀没了力量,激情衰退,实在是飞不动的时候,就飞了一半了</li> <li>每天叫你起床的不是闹钟,是梦想</li> </ul> </div> <style type="text/css"> ul,li{margin:0;padding:0} #scrollDiv{width:600px;height:25px;line-height:25px;overflow:hidden} #scrollDiv li{height:25px;padding-left:10px;}
if ($this->InterMonth != 13 and $this->InterMonth < $LMonth) { $day = $day + $this->InterMonthDays; } for ($i = 1; $i <= 12; $i++) { $day = $day - $this->SMDay[$i]; if ($day <= 0) { break; } } if ($day > 0) { $SYear = $SYear + 1; if ($this->isLeapYear($SYear)) { $this->SMDay[2] = 29; } for ($i = 1; $i <= 12; $i++) { $day = $day - $this->SMDay[$i]; if ($day <= 0) { break; } } } $day = $day + $this->SMDay[$i]; $SMonth = $i; $SDay = $day; $SolarArray = array('Y' => $SYear, 'M' => $SMonth, 'D' => $SDay); return $SolarArray; } } $lunar = new Lunar(); $result = $lunar->Solar2Lunar("2009", "7", "22"); print_r($result);
});'; $content .= '<div class="title">发表留言 <span class="gdate"><span name="post_link" data-id="0" class="mlink f_link">留言</span> | <span name="post_link" data-id="1" class="mlink f_link">投票</span></span></div><div class="lcontent">' . getcform() . '<form method="post" action="" class="btform" id="topicform1" style="display: none;"><table><tr><td>投票标题:</td><td><input name="vtitle" size="32" class="bt_input" rel="投票标题" /></td></tr><tr><td>有效天数:</td><td><input name="vday" size="32" value="0" />天(0或空为不限制)</td></tr><tr><td>投票类型:</td><td><input name="vtype" value="0" type="radio" checked="checked" />单选 <input name="vtype" value="1" type="radio" />多选(发布后不可编辑)</td></tr><tr><td colspan="2">投票选项:每一行为一个选项,发布后不可编辑<br/><textarea name="voption" rows="8" class="bt_input" rel="投票选项"></textarea></td></tr><tr><td colspan="2"><input type="submit" value="发布" class="button" /> <input value="取消" class="button" type="reset" /><input type="hidden" name="mid" value="1"/></td></tr></table></form></div>'; } $content .= '</div></div><div class="lmenu"><ul><li>欢迎您'; if ($c_log) { $s_dbg = sprintf('select id from %s where tid=%s and readed=1', $dbprefix . 'message', $_SESSION[$config['u_hash']]); $q_dbg = mysql_query($s_dbg) or die(''); $c_dbg = mysql_num_rows($q_dbg); mysql_free_result($q_dbg); $content .= ',' . $pn . ' <a href="?m=logout">退出</a><ol><li><a href="?m=message">短消息</a>' . ($c_dbg > 0 ? '(<span class="message_n">' . $c_dbg . '</span>)' : '') . '</li><li><a href="?m=profile">个人资料</a></li>' . ($pa == 9 ? '<li><a href="?m=setting">班级设置</a></li>' : '') . '</ol>'; } else { $content .= '<ol><li><a href="?m=login">登录留言</a></li></ol>'; } $content .= '</li>'; require_once 'lib/lunar.php'; $lunar = new Lunar(); for ($i = 0; $i < 5; $i++) { $ct = getftime(time() + 86400 * $i); $bdb[] = '(bir_m=' . date('n', $ct) . ' and bir_d=' . date('j', $ct) . ' and isnl=0)'; $nl = $lunar->S2L($ct); $bdb[] = '(bir_m=' . $nl[0] . ' and bir_d=' . $nl[1] . ' and isnl=1)'; } $nl_t = $lunar->S2L(getftime()); $s_dbu = sprintf('select id, name, isnl, bir_m, bir_d from %s where %s', $dbprefix . 'member', join(' or ', $bdb)); $q_dbu = mysql_query($s_dbu) or die(''); $r_dbu = mysql_fetch_assoc($q_dbu); if (mysql_num_rows($q_dbu) > 0) { $content .= '<li>生日榜<ol>'; do { $sr_c = $r_dbu['isnl'] > 0 ? $lunar->LMonName($r_dbu['bir_m']) . '月' . $lunar->LDayName($r_dbu['bir_d']) . '日' : '' . $r_dbu['bir_m'] . '月' . $r_dbu['bir_d'] . '日'; $content .= '<li>' . ($r_dbu['isnl'] == 1 && $r_dbu['bir_m'] == $nl_t[0] && $r_dbu['bir_d'] == $nl_t[1] || $r_dbu['isnl'] == 0 && $r_dbu['bir_m'] == date('n', getftime()) && $r_dbu['bir_d'] == date('j', getftime()) ? '<img src="images/cake.gif" alt="" title="生日快乐!" /> ' : '') . '<a href="?m=user&id=' . $r_dbu['id'] . '">' . $r_dbu['name'] . '</a> (<span title="生日:' . ($r_dbu['isnl'] > 0 ? '农历' : '') . $sr_c . '">' . $sr_c . '</span>)</li>';
<?php error_reporting(E_ERROR); ini_set('date.timezone', 'Asia/Shanghai'); header("Content-Type: text/html;charset=utf-8"); include "conn.php"; include_once "nongli.php"; if (!empty($_POST['birthday'])) { $classid = $_POST['classid']; $birthday = $_POST['birthday']; $isnongli = $_POST['isnongli']; if ($isnongli == 1) { $lunar = new Lunar(); $birthday = date("Y-m-d", $lunar->S2L($birthday)); } $select_user_sql = "select * from users where classid='{$classid}'"; $select_user_qurey = mysqli_query($con, $select_user_sql); $select_user_array = mysqli_fetch_array($select_user_qurey); if (!empty($select_user_array)) { $update_birthday = "update users set birthday='{$birthday}',isnongli='{$isnongli}' where classid='{$classid}';"; mysqli_query($con, $update_birthday); $data['shengri'] = "success"; echo json_encode($data); } else { $data['shengri'] = "nouser"; echo json_encode($data); } } else { echo "请用正确的方式访问"; }
<?php header("Content-Type:text/html;charset=utf-8"); require 'lunar.php'; $LIUREN = ["大安", "留连", "速喜", "赤口", "小吉", "空亡"]; $user_time = $_POST["user_time"]; $msg = $user_time . "<br/>"; function multiexplode($delimiters, $string) { $ready = str_replace($delimiters, $delimiters[0], $string); $launch = explode($delimiters[0], $ready); return $launch; } $timeArray = multiexplode(array("-", "T", ":", "+", " "), $user_time); $lunar = new Lunar(); $lunarDate = $lunar->convertSolarToLunar($timeArray[0], $timeArray[1], $timeArray[2]); if ($lunarDate[7] > 0) { if ($lunarDate[4] > $lunarDate[7]) { $lunarDate[4] = $lunarDate[4] - 1; } } $msg = $msg . $lunarDate[1] . $lunarDate[2] . "<br/>"; //echo "<br/>".$lunarDate[4].$lunarDate[5]."<br/>"; $mm = (int) $lunarDate[4]; if ($mm > 6) { $mmi = ($mm - 1) % 6; } else { $mmi = $mm - 1; } //echo $mmi.":".$LIUREN[$mmi]."月<br/>"; $dd = (int) $lunarDate[5];
public static function getMonthFirstday($year, $month) { $lu = new Lunar($year, $month, 1); if ($lu->weekday != 0) { $lu->getDiffDate(0 - $lu->weekday); } return $lu; }
$authority = " AND admin_id={$_SESSION['admin_id']}"; } date_default_timezone_set('Asia/Shanghai'); $arr = explode('-', date('Y-m-d')); $ld = new Lunar($arr[0], $arr[1], $arr[2]); $nl = $ld->display(); $sql = 'SELECT COUNT(user_id) FROM ' . $GLOBALS['ecs']->table('users') . " WHERE SUBSTR(birthday,6)='{$nl}' {$authority}"; $today_count = $GLOBALS['db']->getOne($sql); $smarty->assign('today_count', $today_count); //未来四天生日的顾客的数量 $now = ''; for ($i = 1; $i < 5; $i++) { $time = strtotime("now") + 24 * 60 * 60 * $i; $date = date('Y-m-d', $time); $arr = explode('-', $date); $ld = new Lunar($arr[0], $arr[1], $arr[2]); $nl = $ld->display(); $now = $now . ',\'' . $nl . '\''; } $now = ltrim($now, ','); $sql = 'SELECT COUNT(user_id) FROM ' . $GLOBALS['ecs']->table('users') . " WHERE (SUBSTR(birthday,6)) IN ({$now}) {$authority}"; $count_5 = $GLOBALS['db']->getOne($sql); $smarty->assign('count_5', $count_5); //END: 顾客生日统计 // $smarty->display('start.htm'); } elseif ($_REQUEST['act'] == 'main_api') { require_once ROOT_PATH . '/includes/lib_base.php'; $data = read_static_cache('api_str'); if ($data === false || API_TIME < date('Y-m-d H:i:s', time() - 43200)) { include_once ROOT_PATH . 'includes/cls_transport.php'; $ecs_version = VERSION;