bootstrap - alert

<style>
.alert{
    display: none;
    position: fixed;
    top: 1%;
    left: 45%;
    z-index: 999;
    border: 1px solid transparent;
    border-radius: 5px;
}
.alert-success {
    color: #3c763d;
    background-color: #dff0d8;
    border-color: #d6e9c6;
}
.alert-info {
    color: #31708f;
    background-color: #d9edf7;
    border-color: #bce8f1;
}
.alert-warning {
    color: #8a6b3b;
    background-color: #fcf8e3;
    border-color: #faebcc;
}
.alert-danger {
    color: #a94442;
    background-color: #f2dede;
    border-color: #ebccd1;
}
</style>
<script>
/*
 * .alert-success
 * .alert-info
 * .alert-warning
 * .alert-danger
 */
function alertShow(style, message){
    $('.alert').remove();
    $('<div>').appendTo('body').addClass('alert ' + style).html(message).show();
}
function alertHidden(time){
    $('.alert').delay(time).fadeOut();
}
</script>

  翻  牌  子

MYSQL - group_concat

group_actionid 表

groupid actionid groupname
g01 a01 下路
g02 a02 中路
g01 a03 下路
g01 a02 下路

actionid 表

actionid actionname displayname
a01 aixi 寒冰射手
a02 yasuo 疾风剑豪
a03 jinkesi 暴走萝莉

  翻  牌  子

PHP - 调用 webservice 接口 - php 5.4 以下

<?php
header('Content-Type:text/html; charset=utf-8');
require_once('nusoap.php');
$ip = $_REQUEST['ip'];
$func = $_REQUEST['func'];
$param = $_REQUEST['param'];
$namespace = $_REQUEST['namespace'];
$paras = json_decode(json_encode($param), true);
try{
    $client = new soapclient('http://'.$ip.'/xx/Webservice?wsdl', true);
    $client->soap_defencoding = 'UTF-8';
    $client->decode_utf8 = false;
    $client->xml_encoding = 'UTF-8';
    $result = $client->call($func, $paras, $namespace);
    print_r($result);
}catch(SoapFault $exception){
    print_r($exception);
}
?>

  翻  牌  子

PHP - 调用 webservice 接口 - php 5.4 以上

requestWsdl.php

<?php
header('content-type:text/html;charset=utf-8');
$ip = $_RESQUEST['ip'];
$function = $_REQUEST['function'];
$param = $_REQUEST['param'];
$res = new WSDL();
$res->getData($ip, $function, $param);
class WSDL{
    public function __construct(){
    }
    public function getData($ip, $function, $param = array()){
        try {
            $client = new SoapClient('http://' . $ip . '/xxx/Webservice?wsdl',
array('encoding' => 'UTF-8'));
            $result = $client->{$function}($param);
            $result = get_object_vars($result);
            print_r($result);
        } catch (SoapFault $exception) {
            print_r($exception);
        }
    }
    public function getFunctions($ip){
        $client = new SoapClient('http://' . $ip . '/xxx/Webservice?wsdl', 
array('encoding' => 'UTF-8'));
        $functions = $client->__getFunctions();
        print_r($functions);
    }
    public function getTypes($ip){
        $client = new SoapClient('http://' . $ip . '/xxx/Webservice?wsdl', array('encoding' => 'UTF-8'));
        $types = $client->__getTypes();
        print_r($types);
    }
}

  翻  牌  子

PHP - 递归无限级分类下的所有子集

<?php
/**
 * 递归无限级分类【先序遍历算】,获取任意节点下所有子孩子
 * @param array $arrCate 待排序的数组
 * @param int $parent_id 父级节点
 * @param int $level 层级数
 * @return array $arrTree 排序后的数组
 */
function getMenuTree($arrCat, $parent_id = 0, $level = 0)
{
    static  $arrTree = array(); //使用static代替global
    if( empty($arrCat)) {
        return FALSE;
    }
    $level++;
    foreach($arrCat as $key => $value)
    {
        if($value['parent_id' ] == $parent_id)
        {
            $value[ 'level'] = $level;
            $arrTree[] = $value;
            unset($arrCat[$key]); //注销当前节点数据,减少已无用的遍历
            getMenuTree($arrCat, $value[ 'id'], $level);
        }
    }
    return $arrTree;
}
/**
 * 测试数据
 */
$arrCate = array(  //待排序数组
    array( 'id'=>1, 'name' =>'顶级栏目一', 'parent_id'=>0),
    array( 'id'=>2, 'name' =>'顶级栏目二', 'parent_id'=>0),
    array( 'id'=>3, 'name' =>'栏目三', 'parent_id'=>1),
    array( 'id'=>4, 'name' =>'栏目四', 'parent_id'=>3),
    array( 'id'=>5, 'name' =>'栏目五', 'parent_id'=>4),
    array( 'id'=>6, 'name' =>'栏目六', 'parent_id'=>2)
);
header('Content-type:text/html; charset=utf-8'); //设置utf-8编码
echo '<pre>';
print_r(getMenuTree($arrCate, 0, 0));
echo '</pre>';
?>

  翻  牌  子

JS - 字符串指定位置添加元素

/* 
 * str1:原字符串
 * n:插入位置
 * str2:插入元素
 */
function insertStr(str1, n, str2){
    var s1 = '';
    var s2 = '';
    if(str1.length<n){
        return str1 + str2;
    }else{
        s1 = str1.substring(0, n);
        s2 = str1.substring(n, str1.length);
        return s1 + str2 + s2;
    }
}

JS - 字符串显示相应长度

/* 
 * str:字符串
 * num:显示位数
 */
function opStr(str, num){
    var str1 = str;
    var str2 = '';
    if(str1.length>num){
        str2 = str1.substring(0, num) + '..';
    }else{
    str2 = str1;
    }
    return str2;
}