function __construct(knjdb $knjdb, $args) { $this->args = $args; $this->knjdb = $knjdb; require_once "knj/functions_knj_extensions.php"; knj_dl("sqlite3"); }
function __construct($args) { require_once "knj/functions_knj_extensions.php"; knj_dl(array("soap", "openssl", "xml")); $this->opts = $args; $this->soap_client = new SoapClient("https://www.bibob.dk/SmsSender.asmx?WSDL", array("verify_peer" => false, "allow_self_signed" => true)); }
function __construct(knjdb $knjdb, &$args){ $this->args = $args; $this->knjdb = $knjdb; require_once("knj/functions_knj_extensions.php"); knj_dl("mysqli"); }
function __construct($arr_opts) { require_once "knj/functions_knj_extensions.php"; knj_dl("ssh2"); require_once "knj/class_knj_ssh2.php"; $this->ssh = knj_ssh2::quickConnect($arr_opts["host"], $arr_opts["user"], $arr_opts["passwd"], $arr_opts["port"]); }
/** Loads a PHP-extension. */ function knj_dl($extension){ if (is_array($extension)){ foreach($extension AS $ext){ knj_dl($ext); } return true; } require_once "knj/functions_knj_os.php"; $pre = ""; $os = knj_os::getOS(); if (extension_loaded($extension)){ return true; } if ($extension == "sqlite" && !extension_loaded("php_pdo")){ knj_dl("pdo"); } if ($os["os"] == "windows"){ $pre = "php_"; $app = ".dll"; if ($extension == "glade" || $extension == "libglade"){ $extension = "gtk_libglade2"; }elseif($extension == "gd"){ $extension = "gd2"; } }else{ $app = ".so"; if ($extension == "gtk2"){ $pre = "php_"; } } if ($extension == "gtk2" && extension_loaded("php-gtk")){ return true; } if (!ini_get("enable_dl")){ throw new Exception("The option \"enable_dl\" is not enabled in \"php.ini\" - cant load extension."); } if (!dl($pre . $extension . $app)){ throw new Exception("Could not load the extension: " . $extension . "."); } return true; }
function __construct(&$knjdb, &$args) { $this->args = $args; $this->knjdb = $knjdb; require_once "knj/functions_knj_extensions.php"; knj_dl("pdo"); if ($args["dbtype"] == "sqlite3") { knj_dl("pdo_sqlite"); } elseif ($args["dbtype"] == "mysql") { knj_dl("pdo_mysql"); } elseif (!$this->args["pdostring"]) { throw new Exception("No valid db-type given and no pdostring given."); } }
function load($classname){ $class = strtolower($classname); if (array_key_exists($class, $this->classes)){ require_once($this->classes[$class]); } if (array_key_exists($class, $this->exts)){ require_once("knj/exts.php"); knj_dl($this->ext[$classname]); } if (array_key_exists($class, $this->knj)){ require_once("knj/" . $this->knj[$class] . ".php"); } }
/** Sets the db-type for escaping and other stuff... */ function sql_setDBType($dbtype){ global $functions_knj_sql; if ($dbtype == "mysql" || $dbtype == "sqlite" || $dbtype == "sqlite3"){ $functions_knj_sql["type"] = $dbtype; if ($dbtype == "sqlite" || $dbtype == "sqlite3"){ if (!function_exists("sqlite_escape_string")){ require_once("knj/functions_knj_extensions.php"); knj_dl("sqlite"); } }elseif($dbtype == "mysql"){ if (!function_exists("mysql_escape_string")){ require_once("knj/functions_knj_extensions.php"); knj_dl("mysql"); } } }else{ throw new Exception("Invalid type: " . $functions_knj_sql["type"]); } }
/** Sets options. */ function setOpts($arr){ if (!$this->opts["mode"] && !$arr["mode"]){ $arr["mode"] = "cbb"; } foreach($arr AS $key => $value){ if ($key == "mobilenumber" || $key == "password" || $key == "gnokiiexe" || $key == "gnokiiconf" || $key == "host" || $key == "port" || $key == "username"){ //do nothing. }elseif($key == "mode"){ if ($value == "bibob"){ require_once("knj/functions_knj_extensions.php"); knj_dl(array("soap", "openssl", "xml")); }elseif($value == "happii"){ require_once("knj/class_knj_httpbrowser.php"); $this->http = new knj_httpbrowser(); }elseif($value == "cbb"){ require_once("knj/class_knj_httpbrowser.php"); $this->http = new knj_httpbrowser(); }elseif($value == "gnokii"){ //valid. if (!$this->opts["gnokiiexe"]){ $this->opts["gnokiiexe"] = "/usr/bin/gnokii"; } if (!$this->opts["gnokiiconf"]){ $this->opts["gnokiiconf"] = "/etc/gnokiirc"; } }elseif($value == "knjsmsgateway"){ //valid. }else{ throw new Exception("Invalid value for \"mode\": \"" . $value . "\"."); } }else{ throw new Exception("Invalid option: " . $key); } $this->opts[$key] = $value; } }
<? require_once "knj/functions_knj_extensions.php"; if (!knj_dl("gd")){ die("Could not load the GD-extension.\n"); } /** This class allows the user the fairly easy make a tray-icon showing a percentage. */ class TrayPercent extends GtkStatusIcon{ private $pixbuf; //The last pixbuf used. private $height; /** The constructor of TrayPercent. */ function __construct(){ parent::__construct(); $this->height = 48; } /** Sets a new percentage in the tray. */ function setPercent($percs){ $spacing = 2; $spacing_bottom = 5; $width = ($spacing * 2) + (count($percs) * 7) + (count($percs) * 2); $img = ImageCreateTrueColor($width, $this->height); $transcolor = ImageColorTransparent($img); ImageFill($img, 0, 0, $transcolor); $color_border = ImageColorAllocate($img, 1, 1, 1);; $x = $spacing;
$renames[$file] = $file_new; } } foreach($renames AS $key => $value){ if (rename($folder . "/" . $key, $folder . "/" . $value)){ $this->tv_files->get_model()->append(array($value)); }else{ $this->tv_files->get_model()->append(array($key)); } } } } //Start program. require_once("knjphpframework/functions_knj_extensions.php"); require_once("knjphpframework/functions_knj_os.php"); require_once("knjphpframework/functions_treeview.php"); if (!knj_dl("gtk2")){ die("Could not load PHP-GTK2-module.\n"); } if (knj_os::getOS() == "windows"){ //Set Windows-skin if running Windows. Gtk::rc_parse("gtkrc"); } $win_main = new WinMain(); Gtk::main(); ?>
/** * Open a new connecting to a database. * * @param string $type The type of the database (mysql, pgsql, sqlite or access). * @param string $ip The IP og file-location of the database. */ function openConn($type, $ip, $port = "", $database = "", $username = null, $password = null, WinStatus $win_status = null){ if ($this->conn){ $this->CloseConn(); } $this->type_try = $type; if ($type == "mysql"){ if (!function_exists("mysql_connect") && !knj_dl("mysql")){ throw new Exception("Could not load the MySQL-extension."); } if (!$port){ $port = 3306; } $ip .= ":" . $port; //updating the status-window. if ($win_status){ $win_status->SetStatus(0, "Connecting...", true); } $this->conn = mysql_connect($ip, $username, $password, true); //If connection is not set, return false and unset connection. if (!$this->conn){ $this->lasterror = "MySQL connect error: " . mysql_error($this->conn); unset($this->conn); return false; } //updating the status-window. if ($win_status){ $win_status->SetStatus(0, "Selecting the database...", true); } //If a selection of the default database cant be made, close the connection and return false. if (!mysql_select_db($database, $this->conn)){ $this->lasterror = "MySQL db-select error: " . mysql_error($this->conn); mysql_close($this->conn); unset($this->conn); return false; } $this->type = "mysql"; }elseif($type == "pgsql"){ if (!$port){ $port = "5432"; } if (!$this->CheckConnection($ip, $port)){ $this->lasterror = "Could open a socket to " . $ip . ":" . $port . "."; return false; } $this->conn = pg_connect("host=" . $ip . " port=" . $port . " dbname=" . $database . " user="******" password="******"pgsql"; $this->pg_version = pg_version($this->conn); }elseif($type == "sqlite"){ if (!function_exists("sqlite_open") && !knj_dl("sqlite")){ throw new Exception("Could not load the SQLite-extension."); } $this->conn = sqlite_open($ip); if ($this->conn){ $this->type = "sqlite"; }else{ $this->lasterror = "The database (" . $ip . ") could not be read."; return false; } }elseif($type == "sqlite3"){ knj_dl("pdo"); knj_dl("pdo_sqlite"); try{ $this->conn = new PDO("sqlite:" . $ip); $this->type = "sqlite3"; }catch(Exception $e){ echo "Warning: " . $e->getMessage() . "\n"; $this->lasterror = $e->getMessage(); return false; } }elseif($type == "access"){ if (!file_exists($ip)){ $this->lasterror = "The file could not be found (" . $ip . ")"; return false; } $odbc = "Driver={Microsoft Access Driver (*.mdb)};Dbq=" . $ip . ";Uid=Admin;Pwd=;"; //$odbc = "DRIVER={Microsoft Access Driver (*.mdb)};\r\nDBQ=" . $ip . "\r\n"; //$odbc = "Driver={MDBToolsODBC};Database=" . $ip . "\r\n"; //$odbc = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" . $ip . ";"; $this->conn = odbc_connect($odbc, "Administrator", ""); if (!$this->conn){ return false; }else{ $this->type = "access"; } }else{ throw new Exception("Unsupported type: " . $this->type); } $this->sqlc->setOutputType($this->type); return true; }
/** Initilializes the chosen locales-module. */ function knjlocales_setmodule($domain, $dir, $module = "ext", $language = "auto"){ global $functions_knjlocales; $functions_knjlocales["dir"] = $dir; $functions_knjlocales["module"] = $module; if ($language == "auto"){ if (array_key_exists("HTTP_ACCEPT_LANGUAGE", $_SERVER) and $_SERVER["HTTP_ACCEPT_LANGUAGE"]){ $accept = $_SERVER["HTTP_ACCEPT_LANGUAGE"]; foreach(explode(",", $accept) AS $value){ $value = explode(";", $value); $language = $value[0]; break; } }elseif($_SERVER["LANG"]){ if (preg_match("/^([a-z]{2}_[A-Z]{2})/", $_SERVER["LANG"], $match)){ $language = $match[1]; }else{ //Language could not be matched - default english. $language = "en_GB"; } } if ($language == "da"){ $language = "da_DK"; }elseif($language == "de"){ $language = "de_DE"; }elseif($language == "en"){ $language = "en_GB"; } } $language = strtr($language, array( "-" => "_" )); if (preg_match("/^([A-z]{2})_([A-z]{2})$/", $language, $match)){ $language = strtolower($match[1]) . "_" . strtoupper($match[2]); } $functions_knjlocales["language"] = $language; if (!file_exists($dir)){ throw new exception("Dir does not exist: " . $dir); } if ($module == "php-gettext"){ require_once "php-gettext/gettext.inc"; $functions_knjlocales["module"] = "php-gettext"; _setlocale(LC_ALL, $language);// or die("Locales error 5\n"); _setlocale(LC_MESSAGES, $language);// or die("Locales error 6\n"); _bindtextdomain($domain, $dir); _bind_textdomain_codeset($domain, "UTF-8"); _textdomain($domain); }elseif($module == "ext"){ require_once "knj/functions_knj_extensions.php"; if (!knj_dl("gettext")){ throw new exception("gettext-module could not be loaded."); } $functions_knjlocales["module"] = "ext"; putenv("LANGUAGE=" . $language); putenv("LC_ALL=" . $language); putenv("LC_MESSAGE=" . $language); putenv("LANG=" . $language); $locales_language_real = $language . ".utf8"; setlocale(LC_ALL, $locales_language_real); setlocale(LC_MESSAGES, $locales_language_real); bindtextdomain($domain, $dir); bind_textdomain_codeset($domain, "UTF-8"); textdomain($domain); }else{ throw new exception("knjlocales (" . __FILE__ . ":" . __LINE__ . "): No such module: " . $module . "\n"); } }