function do_embed_lazy($html = '') { if (is_exit() || empty($html)) { return $html; } $patern_ifr = '/<\\s*iframe\\s+(?<attr>[^>]*)/i'; if (preg_match($patern_ifr, $html, $ifr)) { $attr_arr = parse_attr($ifr['attr']); if (!$attr_arr || empty($attr_arr['src']) || LAZY_PLACEHOLDER === $attr_arr['src'] || !empty($attr_arr['data-src'])) { return $html; } if (array_key_exists('class', $attr_arr)) { $attr_arr['class'] = do_class($attr_arr['class']); } else { $attr_arr['class'] = LAZY_CLASS; } $attr_arr['data-src'] = $attr_arr['src']; $attr_arr['src'] = LAZY_PLACEHOLDER; $html = str_replace($ifr['attr'], trim(attributes_to_string($attr_arr)), $html); get_assets(); } return $html; }
/** * 数据库类型 * @param null $type * @param $DBinfo */ private function DbType($type = null, $DBinfo) { if ($type && $DBinfo) { switch ($type) { case 'mysql': $this->_db = new Mysql($DBinfo); break; case 'pdo_mysql': $this->_db = new LinkPdoMysql($DBinfo); break; default: is_exit("数据库连接类型没有选择"); break; } } else { is_exit("数据库连接类型没有选择"); } }
echo "none"; } else { echo "block"; } } function is_exit() { global $game_name, $nochrome; if ($nochrome == "true" && $game_name == null) { //echo "</br> set game name also with nochrome=true</br>"; return true; } else { return false; } } if (is_exit()) { header("HTTP/1.1 400 Bad Request"); echo "<p><h4> nochrome=true requires a game name as parameter</h4></p></br>"; exit(1); } if (!isset($game_name)) { if (isset($_GET['gameid'])) { include_once 'gameidMap.php'; define('TTL', 30 * 60); //cache expiry time for apc is 30min $key = "gameid"; $gameidArray = apc_fetch($key, $success); if ($success) { } else { $gameidArray = getGameMapping($server_cfg); apc_add($key, $gameidArray, TTL);
/** * 判断目录是否存在,如果不存在就创建 * * @param unknown $path */ function is_dirName($dirName) { // 设置总目录 if (!is_dir($dirName) || !is_writeable($dirName)) { if (!mkdir($dirName, 0777)) { is_exit($dirName . lang('is_dir')); } } }