utilities.inc.php

来自「股票监视器是一个简单的实用工具」· PHP 代码 · 共 92 行

PHP
92
字号
<?php/** PHP STOCK TRACKER* -----------------* A multi-user utility for creating and managing stock* watchlists and historical analysis.* Copyright (C) 2005 Joshua Eldridge (joshuae74@hotmail.com)*** This program is free software; you can redistribute it and/or modify* it under the terms of the GNU General Public License as published by* the Free Software Foundation; either version 2 of the License, or* (at your option) any later version.** This program is distributed in the hope that it will be useful,* but WITHOUT ANY WARRANTY; without even the implied warranty of* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the* GNU General Public License for more details.** You should have received a copy of the GNU General Public License* along with this program; if not, write to the Free Software* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA** See the COPYING file for full details.*/function getConn($db = 'DEFAULTDB') {  global $DBCONF;  $myDb = NewADOConnection($DBCONF[$db]['DB_TYPE']);  $myDb->PConnect($DBCONF[$db]['SERVER'],$DBCONF[$db]['USER'],$DBCONF[$db]['PASS'],$DBCONF[$db]['DB']);  //$myDb->debug = true;  return $myDb;}function closeConn(&$conn) {  $conn->Close();}function cacheQuery($sql,$time) {  global $ADODB_CACHE_DIR;  $myDb = getConn();  $result = $myDb->CacheGetAssoc($time,$sql);  return $result;}function getCleanVar(&$ary, $index) {  if (isset($ary[$index])) {    return trim($ary[$index]);  } else {    return '';  }}// This function will return an array of values // based on the key (index) of a multi-dimensional array// Will probably break depending on the "depth" of the array// Right now it only handles one level deepfunction getSingleArray($multi_array, $index) {  foreach($multi_array as $single) {    $single_array[] = $single[$index];  }  return $single_array;}/* checkSecurePostI've encountered some problems with this not returning truewhen an index.php page is posted to itself, but when replacedby Apache (ie; http://www.domain.com/ -- not http://www.domain.com/index.php*/function checkSecurePost() {  $referer = $_SERVER['HTTP_REFERER'];  $local_path = "http://" . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'];  if ( $_SERVER['QUERY_STRING'] != "") {    $local_path . "?" . $_SERVER['QUERY_STRING'];  }  if ( ( $referer == $local_path ) && ( $_SERVER['REQUEST_METHOD'] == "POST" ) ) {    return true;  } else {    return false;  }}function checkSecureGet() {  $check = strpos( $_SERVER['HTTP_REFERER'], $_SERVER['SERVER_NAME'] );  if ( $check !== false ) {    return true;  } else {    return true;  }}?>

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?