An Error Was Encountered
No database connection settings were found in the database config file.
/**
* Viele immer wieder benötigte Funktionen, nicht nur für Codeigniter
* @author: Robert Heine
* @copyright 2011, PIXELMECHANICS | Webproduktion
* @link www.pixelmechanics.de
* @version 2.0
*/
function calc_mittelwert($array) {
return array_sum($array) / count($array);
}
/**
* Wandelt das erste Zeichen eines Strings in einen Großbustaben um
* UTF-8 Ersatz für ucfirst()
*
**/
function mb_ucfirst($str){
$str[0] = mb_strtoupper($str[0]);
return $str;
}
/**
* Erstellt rekursiv Unterverzeichnisse.
* $path kann zB sein: "/uploads/groups/members/". All diese ordner werden erzeugt.
*
* @param unknown_type $path
*/
function mk_path($path) {
$segments = explode("/", $path);
$current_dir = ".";
foreach ($segments as $segment) {
if (empty($segment)) continue;
$current_dir .= "/$segment";
if (!is_dir($current_dir)) {
mkdir($current_dir, 0777);
// print "Ordner $current_dir angelegt
";
}
}
}
/**
* Stammt eigentlich aus dem alternativen url_helper.
* Fügt die Messages und Errors aus $ci->data["messages"] und $ci->data["errors"] in die Session-Flashvariablen ein,
* damit sie nach dem Redirect abgefragt werden können.
* Falls bereits Ausgaben gesendet wurden, erscheint eine Meldung mit dem Link und ein Javascript mit einer automatischen Weiterleitung (just in case...)
*
*
* @param unknown_type $uri
* @param unknown_type $method
* @param unknown_type $http_response_code
*/
function redirect($uri = '', $method = 'location', $http_response_code = 302) {
$CI =& get_instance();
if (isset($CI->data["messages"]) && !empty($CI->data["messages"])) $CI->session->set_flashdata("messages", $CI->data["messages"]);
if (isset($CI->data["errors"]) && !empty($CI->data["errors"])) $CI->session->set_flashdata("errors", $CI->data["errors"]);
if ( ! preg_match('#^https?://#i', $uri))
{
$uri = base_url().$uri;
}
// die($uri);
if (headers_sent()) {
print "
Headerdata has already been sent. This is no serious error. Just click here to continue: $uri"; print " "; } else { switch($method) { case 'refresh' : header("Refresh:0;url=".$uri); break; default : header("Location: ".$uri, TRUE, $http_response_code); break; } } exit; } /** * Entspricht die aktuelle IP-Adresse dem abzufragneden Parameter? * * @param unknown_type $ip * @return unknown */ function is_ip($ip) { return $_SERVER['REMOTE_ADDR']==$ip; } /** * Liefert das Land zu einer IP-Adresse * Provider 0 = getPos.de, Provider 1 = geobytes, 2=ipadressapi.com * * @param unknown_type $ip * @param unknown_type $provider * @param unknown_type $return_all * @return unknown */ function country_fromip($ip, $provider = 0, $return_all=false, &$debug = array()) { $return = false; // print "Testing: $ip"; if ($_SERVER['HTTP_HOST']=="pmserver") $ip = "95.88.142.69"; // Deutschland if ($_SERVER['REMOTE_ADDR']=="95.88.142.69") { // $ip = "295.88.142.69"; // Deutschland // $ip = "213.164.6.215"; // Österreich // $ip = "78.30.177.253"; // Serbien // $ip = "87.119.200.235"; // Schweiz // $ip = "222.108.40.148"; // Südkorea // $ip = "122.35.116.50"; // KR // $ip = "82.212.72.28"; // JO // $ip = "213.254.223.69"; // GR // $ip = "194.153.110.160"; // FRankreich // $ip = "62.72.121.183"; // Belgien // $ip = "98.129.126.138"; // US // return "SG"; // return "JO"; } /** * Methode: getPos */ if ($provider===0) { $url = "http://services.getpos.de/ip2loc.asmx/GetIPCountry?UserName=pixelmechanics&Password=20pm10&IPAddress=$ip"; $url = "http://services.getpos.de/clientObject.asmx/IPLocation?AccessId=5b4c4023-7543-43f2-b955-ca405133262e&IPAddress=$ip"; $tags = file_get_contents($url); $tags = html_entity_decode($tags); $xml = simplexml_load_string($tags); $debug["getPos"] = array($url); $code = $xml->Returncode.""; if (((int)$xml->Returncode."")==200) { $return = $xml->Countrycode.""; if ($return_all) $return = $xml; // ->getPos } else { if ($return_all) $return = $xml; // ->getPos $provider = 1; } $debug["getPos"][] = htmlspecialchars($tags); } /** * Methode: getPos2 */ if ($provider===0.5) { $url = "http://services.getpos.de/ip2loc.asmx/GetIPCountry?UserName=pixelmechanics&Password=20pm10&IPAddress=$ip"; $tags = file_get_contents($url); $tags = html_entity_decode($tags); $xml = simplexml_load_string($tags); $debug["getPos"] = array($url); if ($xml->getpos->returncode==104) { if ($return_all) $return = $xml; // ->getPos $provider = 1; } else { $cc = $xml->getpos->country->code.""; $return = $cc; if ($return_all) $return = $xml; // ->getPos } $debug["getPos"][] = htmlspecialchars($tags); } /** * METHODE http://www.hostip.info/use.html * @return: zu testen */ if ($provider===1) { $debug[] = "
".print_r($s, 1).""; if ($ret===false) print $return; else return $ret; } /** * Wenn Parameter 1 leer ist, wird Parameter 2 ausgegeben * * @param unknown_type $string * @param unknown_type $alt * @param unknown_type $return * @return unknown */ function emptyPrint($string, $alt, $return=false){ if (empty($string)) $return = $alt; else $return = $string; if ($return===false) print $return; else return $return; } /** * zB POST-Daten absichern. trim(htmlspecialchars()) * * @param unknown_type $s * @return unknown */ function secure($s){ return trim(htmlspecialchars($s)); } /** * Liefert den benutzten Browser zurück: IE, IE7, Firefox, Safari, usw * von http://www.php.net/manual/de/function.get-browser.php#101125 */ function getBrowser() { $u_agent = $_SERVER['HTTP_USER_AGENT']; $bname = 'Unknown'; $platform = 'Unknown'; $version= ""; //First get the platform? if (preg_match('/linux/i', $u_agent)) { $platform = 'linux'; } elseif (preg_match('/macintosh|mac os x/i', $u_agent)) { $platform = 'mac'; } elseif (preg_match('/windows|win32/i', $u_agent)) { $platform = 'windows'; } // Next get the name of the useragent yes seperately and for good reason if(preg_match('/MSIE/i',$u_agent) && !preg_match('/Opera/i',$u_agent)) { $bname = 'Internet Explorer'; $ub = "MSIE"; } elseif(preg_match('/Firefox/i',$u_agent)) { $bname = 'Mozilla Firefox'; $ub = "Firefox"; } elseif(preg_match('/Chrome/i',$u_agent)) { $bname = 'Google Chrome'; $ub = "Chrome"; } elseif(preg_match('/Safari/i',$u_agent)) { $bname = 'Apple Safari'; $ub = "Safari"; } elseif(preg_match('/Opera/i',$u_agent)) { $bname = 'Opera'; $ub = "Opera"; } elseif(preg_match('/Netscape/i',$u_agent)) { $bname = 'Netscape'; $ub = "Netscape"; } // finally get the correct version number $known = array('Version', $ub, 'other'); $pattern = '#(?
No database connection settings were found in the database config file.