/usr/share/libgda-5.0/php/gda-utils.php is in libgda-5.0-common 5.2.4-3.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 | <?php
function get_command_filename ($session_id)
{
//return session_save_path ()."/command.gda";
return session_save_path ()."/GDA".$session_id."Cpipe";
}
function get_reply_filename ($session_id)
{
//return session_save_path ()."/reply.gda";
return session_save_path ()."/GDA".$session_id."Rpipe";
}
function try_include ($file, $debug=false)
{
$array = explode (":", get_include_path ());
foreach ($array as $index => $path) {
if (file_exists ($path.DIRECTORY_SEPARATOR.$file)) {
include_once ($path.DIRECTORY_SEPARATOR.$file);
if ($debug)
echo "<b>Using PEAR MDB2:</b> ".$path.DIRECTORY_SEPARATOR.$file."\n";
return true;
}
}
return false;
}
function gda_add_hash ($key, $text)
{
if ($key == "")
return "NOHASH\n".$text;
else
return hmac ($key, $text)."\n".$text;
}
// Create an md5 HMAC
function hmac ($key, $data)
{
// RFC 2104 HMAC implementation for php.
// Creates an md5 HMAC.
// Eliminates the need to install mhash to compute a HMAC
// Hacked by Lance Rushing
$b = 64; // byte length for md5
if (strlen($key) > $b) {
$key = pack("H*",md5($key));
}
$key = str_pad($key, $b, chr(0x00));
$ipad = str_pad('', $b, chr(0x36));
$opad = str_pad('', $b, chr(0x5c));
$k_ipad = $key ^ $ipad ;
$k_opad = $key ^ $opad;
return md5($k_opad . pack("H*",md5($k_ipad . $data)));
}
// Generate a random character string
function rand_str($length = 32, $chars = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz1234567890')
{
// Length of character list
$chars_length = (strlen($chars) - 1);
// Start our string
$string = $chars{rand(0, $chars_length)};
// Generate random string
for ($i = 1; $i < $length; $i = strlen($string))
{
// Grab a random character from our list
$r = $chars{rand(0, $chars_length)};
// Make sure the same two characters don't appear next to each other
if ($r != $string{$i - 1}) $string .= $r;
}
// Return the string
return $string;
}
function mdb2_type_to_gtype ($mdb2type)
{
switch ($mdb2type) {
default:
case "text":
case "clob":
return "gchararray";
case "integer":
return "gint";
case "boolean":
return "boolean";
case "decimal":
return "GdaNumerical";
case "float":
return "gdouble";
case "date":
return "GDate";
case "time":
return "GdaTime";
case "timestamp":
return "GdaTimestamp";
case "blob":
return "GdaBinary";
}
}
/**
* Logging class:
* - contains lfile, lopen and lwrite methods
* - lfile sets path and name of log file
* - lwrite will write message to the log file
* - first call of the lwrite will open log file implicitly
* - message is written with the following format: hh:mm:ss (script name) message
*/
class Logging{
// define default log file
private $log_file = '/tmp/gdalog';
// define file pointer
private $fp = null;
// set log file (path and name)
public function lfile($path) {
$this->log_file = $path;
}
// write message to the log file
public function lwrite($message){
// if file pointer doesn't exist, then open log file
if (!$this->fp) $this->lopen();
// define script name
$script_name = pathinfo($_SERVER['PHP_SELF'], PATHINFO_FILENAME);
// define current time
$time = date('H:i:s');
// write current time, script name and message to the log file
fwrite($this->fp, "$time ($script_name) $message\n");
}
// open log file
private function lopen(){
// define log file path and name
$lfile = $this->log_file;
// define the current date (it will be appended to the log file name)
$today = date('Y-m-d');
// open log file for writing only; place the file pointer at the end of the file
// if the file does not exist, attempt to create it
$this->fp = fopen($lfile . '_' . $today, 'a') or exit("Can't open $lfile!");
}
}
/*
* Define this variable to enable logging
*/
//$log = new Logging();
?>
|