代码片段

js 获取 url 参数


var QueryString = function () {
    // This function is anonymous, is executed immediately and
    // the return value is assigned to QueryString!
    var query_string = {};
    var query = window.location.search.substring(1);
    var vars = query.split("&");
    for (var i = 0; i < vars.length; i++) {
        var pair = vars[i].split("=");
        // If first entry with this name
        if (typeof query_string[pair[0]] === "undefined") {
            query_string[pair[0]] = decodeURIComponent(pair[1]);
            // If second entry with this name

好玩的脚本


<?php
class command_base {
  private $php_path = '';
  function real_path() {
    if ($this->php_path != '') {
      return $this->php_path;
    }
    if (substr(strtolower(PHP_OS), 0, 3) == 'win') {
      $ini = ini_get_all();
      $path = $ini['extension_dir']['local_value'];
      $php_path = str_replace('\\', '/', $path);
      $php_path = str_replace(array('/ext/', '/ext'), array(
        '/',
        '/'
      ), $php_path);
      $real_path = $php_path . 'php.exe';
    }
    else {
      $real_path = PHP_BINDIR . '/php';
    }

js


<html>
<head>
  <script src = "../jquery.js"></script>

<script>
      $(document).ready(function () {
        $('ul li').click(function () {

          var index = $(this).index();
          var div = $('div .content').get(index);
          $(div).addClass('test');

        })
      })
  </script>
  </head>

<body>
<ul>
  <?php for ($i = 1; $i < 10; $i++): ?>
    <li><?php echo $i; ?></li>
  <?php endfor; ?>
</ul>
<div>

rules


{ "rules_210201320" : {
    "LABEL" : "210201320",
    "PLUGIN" : "reaction rule",
    "OWNER" : "rules",
    "REQUIRES" : [ "rules", "userpoints_rules", "wechat_messages" ],
    "ON" : { "wechat_messages_request_insert" : [] },
    "IF" : [
      { "entity_has_field" : {
          "entity" : [ "wechat-messages-request" ],
          "field" : "wechat_m_rt_text_content"
        }
      }
    ],
    "DO" : [
      { "entity_query" : {
          "USING" : {
            "type" : "wechat_user",
            "property" : "openid",

爬虫


<?php

function getAUrl($html) {
  $return = [];
  preg_match_all("/href=\"[\S]*\"/", $html, $temp);
  foreach ($temp[0] as $item) {
    $return[] = strrev(substr(strrev(substr($item, 6)), 1));
  }
  return $return;
}

function dangqianurl($url, $link) {
  if (stristr($url, $link)) {
    return TRUE;
  }
  else {
    return FALSE;
  }
}

function getContentCurl($url) {
  $ch = curl_init();
  curl_setopt($ch, CURLOPT_URL, $url);
  curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
  curl_setopt($ch, CURLOPT_HEADER, 0);
  $output = curl_exec($ch);

遍历文件夹


function searchDir($path) {
  $return = array();
  if (!is_dir($path)) {
    return $return;
  }
  $file_info = scandir($path);
  foreach ($file_info as $key => $name) {
    if ($name != '.' && $name != '..') {
      if (is_dir($path . '/' . $name)) {
        $return[$name] = searchDir($path . '/' . $name);
      }
      else {
        //$return[] = $name;
      }
    }
  }
  return $return;
}

function searchFile($path) {
  $return = array();
  if (!is_dir($path)) {
    return $return;
  }
  $file_info = scandir($path);

Snippets - 11/06/2014 - 11:36


  /*
  //drupal_explode_tags($tags);
  if ($options['query'] == $array = array_intersect_key($options['query'], $_GET)) {
    $query = array();
    foreach ($array as $key => $item) {
      $tags = drupal_explode_tags($item);
      if ($options['query'] == array_intersect($options['query'], $tags)) {

Snippets - 10/24/2014 - 15:29


<?php
/**
 * @file
 * Provides OSS SDK configuration form.
 */
/**
 * Settings form.
 */
function dicomapi_settings_form($form, &$form_state) {
  $form['required'] = array(
    '#type' => 'fieldset',
    '#title' => t('Dicom API Bin Info'),
  );
  $form['required']['dicomapi_bin'] = array(
    '#type' => 'textfield',
    '#title' => t('Dicom API Bin'),
    '#default_value' => variable_get('dicomapi_bin', ''),
    '#required' => TRUE,
  );
  $form['selected'] = array(
    '#type' => 'select',
    '#title' => t('Selected'),
    '#options' => array(