'.' and $dirname <> '..') {
if (!is_dir($dirname)) {
if (mkdir($dirname, 777, true))
echo "\ndirectory is made: ($dirname)\n";
else
"\nerror occured while making directory: ($dirname)\n";
}
}
}
if (!function_exists("print_r2")) {
function print_r2($array)
{
if (is_array($array))
return "
";
return $res;
/*
ic ice (recursive) yapmak icin,
en basa, if(!is_array($ar)) return $ar;
$res.="
".print_r3(key($ar))."
".print_r3($val)."
";
*/
}
}
if (!function_exists("andle")) {
function andle($s1, $s2)
{ //iki string'in andlenmi halini bulur. bir bosa "and" kullanlmaz. delphiden aldim..:)
if ($s1 == '')
$s1 = $s2;
elseif ($s2 <> '')
$s1 = $s1 . ' and ' . $s2;
return $s1;
}
}
function to_array($ar)
{ # convert a variable to array if it is not already,
if (is_array($ar))
return $ar; # if array, dont do anything
if (!$ar)
return array(); # bos ise, bos array dondur.
if (!is_array($ar))
return array($ar); # array olmayan bir degisken ise, arraya dondur ve return et.
return "(arraya cevirme yapilamadi.)"; # hicbiri degilse hata var zaten.
}
function array_merge2($ar1, $ar2)
{
return array_merge(to_array($ar1), to_array($ar2));
}
if (!function_exists("writeoutput")) {
function writeoutput($file, $string, $mode = "w", $log = true)
{
mymkdir(dirname($file)); # auto make the dir of filename
if (!($fp = fopen($file, $mode))) {
echo "hata: dosya acilamadi: $file (writeoutput) !";
return false;
}
if (!fputs($fp, $string . "\n")) {
fclose($fp);
echo "hata: dosyaya yazilamadi: $file (writeoutput) !";
return false;
}
fclose($fp);
if ($log)
echo "\n" . basename(__FILE__) . ": file written successfully: $file, mode:$mode \n";
return true;
}
}
if (!function_exists("writeoutput2")) {
function writeoutput2($file, $string, $mode = "w", $debug = true)
{
$file = removeDoubleSlash($file);
if ($debug) {
echo "\n" . __FUNCTION__ . ":*** Writing to file ($file) the contents:\n\n$string\n\n";
}
mymkdir(dirname($file)); # auto make the dir of filename
if (!($fp = fopen($file, $mode))) {
echo "hata: dosya acilamadi: $file (writeoutput) !";
return false;
}
if (!fputs($fp, $string . "\n")) {
fclose($fp);
echo "hata: dosyaya yazilamadi: $file (writeoutput) !";
return false;
}
fclose($fp);
return true;
}
}
if (!function_exists("alanlarial")) {
function alanlarial($db2, $tablo)
{ // adodb de calsyor.
foreach ($db2->MetaColumnNames($tablo) as $alan)
$alanlar[] = $alan;
return $alanlar;
}
}
if (!function_exists("strop")) {
function strop($str, $bas, $son)
{
return $bas . $str . $son;
}
}
if (!function_exists("arrayop")) {
function arrayop($arr, $op)
{
foreach ($arr as $ar)
$ret[] = $op($ar, "{", "}");
return $ret;
}
}
if (!function_exists("executeprog2")) {
function executeprog2($prog)
{ // echoes output.
passthru($prog, $val);
return ($val == 0);
}
}
if (!function_exists('executeProg3')) {
function executeProg3($prog, $echooutput = False)
{
# executes program and return output
if ($echooutput)
echo "\n" . __FUNCTION__ . ": executing: ($prog)\n";
exec($prog, $topcmd);
if (!is_array($topcmd))
return "";
foreach ($topcmd as $t)
$topoutput .= $t . "\n";
$out = trim($topoutput);
if ($echooutput and ($out <> ''))
echo "\n$out\n";
return $out;
}
}
if (!function_exists("executeprog")) {
function executeprog($prog)
{ // does not echo output. only return it.
$fp = popen("$prog", 'r');
if (!$fp) {
return " Cannot Execute: $prog " . __FUNCTION__;
}
$read = fread($fp, 8192);
pclose($fp);
return $read;
}
}
if (!function_exists('degiskenal')) {
function degiskenal($degiskenler)
{
$alansayisi = count($degiskenler);
for ($i = 0; $i < $alansayisi; $i++) {
global ${$degiskenler[$i]};
if ($_POST[$degiskenler[$i]] <> "")
${$degiskenler[$i]} = $_POST[$degiskenler[$i]];
else
${$degiskenler[$i]} = $_GET[$degiskenler[$i]];
$degerler[] = ${$degiskenler[$i]};
}
;
return $degerler;
}
}
if (!function_exists('replacelineinfile')) {
function replacelineinfile($find, $replace, $where, $addifnotexists = false)
{
// edit a line starting with $find, to edit especially conf files..
debugecho("\nreplaceline: ($find -> $replace) in ($where) \n ");
$bulundu = false;
$filearr = @file($where);
//if($find=='$dbrootpass=') print_r($filearr);
if (!$filearr) {
echo "cannot open file... returning...\n";
return false;
} //else print_r($file);
$len = strlen($find);
$newfile = array();
foreach ($filearr as $line) {
$line = trim($line) . "\n";
$sub = substr($line, 0, $len);
if ($sub == $find) {
$line = $replace . "\n";
$bulundu = true;
}
$newfile[] = $line;
}
if ($addifnotexists and !$bulundu) {
echo "Line not found, adding at end: ($replace)\n";
$newfile[] = $replace;
}
return arraytofile($where, $newfile);
}
function replaceOrAddLineInFile($find, $replace, $where)
{
return replacelineinfile($find, $replace, $where, true);
}
}
if (!function_exists("addifnotexists")) {
function addifnotexists($what, $where)
{
debugecho("\naddifnotexists: ($what) -> ($where) \n ", 4);
#bekle(__FUNCTION__." basliyor..");
$what .= "\n";
$filearr = @file($where);
if (!$filearr) {
echo "cannot open file, trying to setup: ($where)\n";
$fp = fopen($where, 'w');
fclose($fp);
$filearr = file($where);
} //else print_r($file);
if (array_search($what, $filearr) === false) {
echo "dosyada bulamadı ekliyor: $where -> $what \n";
$filearr[] = $what;
arraytofile($where, $filearr);
} else {
//echo "buldu... sorun yok. \n";
// already found, so, do not add
}
#bekle(__FUNCTION__." bitti...");
}
}
if (!function_exists("removeifexists")) {
function removeifexists($what, $where)
{
debugecho("\nremoveifexists: ($what) -> ($where) \n ", 4);
$filearr = @file($where);
if (!$filearr) {
echo "cannot open file, trying to setup: ($where)\n";
$fp = fopen($where, 'w');
fclose($fp);
$filearr = file($where);
}
if (is_array($filearr) && count($filearr) > 0) {
$newFileArr = array();
foreach ($filearr as $line) {
if (!startsWith($line, $what)) {
$newFileArr[] = $line;
}
}
if (is_array($newFileArr) && count($newFileArr) > 0) {
arraytofile($where, $newFileArr);
}
}
}
}
if (!function_exists('getlocalip')) {
function getlocalip($interface = 'eth0')
{
global $localip;
$ipline = exec("ifconfig | grep -Eo 'inet (addr:)?([0-9]*\.){3}[0-9]*' | grep -Eo '([0-9]*\.){3}[0-9]*' | head -1");
if (!isset($ipline) || empty($ipline)) {
$ipline = "127.0.0.1";
}
$localip = $ipline;
return $ipline;
}
}
if (!function_exists("debugecho")) {
function debugecho($str, $level = 0)
{
$currentlevel = 4;
if ($level >= $currentlevel)
echo $str;
}
}
if (!function_exists("arraytofile")) {
function arraytofile($file, $lines)
{
$new_content = join('', $lines);
$fp = fopen($file, 'w');
$write = fwrite($fp, $new_content);
fclose($fp);
}
}
function inputform5ForTableConfig($tableConfig, $addArray, $isAdmin = false)
{
// $isAdmin can be used in combo with another parameter in an input array to determine if a field should be enabled for administrators or disabled for non-administators including resellers.
// It's an optional parameter that can be used to limit things further during form construction depending on which user submitted the request to build a form, so to speak
// You have to tell this function how to use it, as it really doesn't have any purpose other than being a value you can use should you need it.
# written for compatibility with inputform5 general function.
# convert a table config (like in start of classapp.php, 'subdomainstable'=>array....) to an array that is acceptable by function inputform5 and call inputform5
$fields = $tableConfig['insertfields'];
$fields2 = array();
$say = count($fields);
for ($i = 0; $i < $say; $i++) {
if (is_array($fields[$i]))
$newitem = $fields[$i]; # accept fields both arrays and non-arrays
else
$newitem = array($fields[$i]);
if ($tableConfig['insertfieldlabels'][$i] <> '')
$newitem['lefttext'] = $tableConfig['insertfieldlabels'][$i];
$fields2[] = $newitem;
}
#$out.="Say:$say, insertFields".print_r2($fields).print_r2($fields2);
$fields2 = array_merge($fields2, $addArray);
#$out.=print_r2($fields2);
return $out . inputform5($fields2, '', $isAdmin);
}
function inputform5($alanlar, $action = '', $isAdmin = false)
{
// $isAdmin can be used in combo with another parameter in an input array to determine if a field should be enabled for administrators or disabled for non-administators including resellers.
// It's an optional parameter that can be used to limit things further during form construction depending on which user submitted the request to build a form, so to speak
// You have to tell this function how to use it, as it really doesn't have any purpose other than being a value you can use should you need it.
global $debuglevel, $output;
/*
* general purpose input form generator. examples below.
*
sadece echo yapmaz.
degistirildi. artik textarea gosterebiliyor.
$res.="alanlar:".print_r2($alan);
$res.="degerler:".print_r2($deger);
*/
if (!is_array($alanlar))
$alanlar = array($alanlar); # convert to array if not , i.e, you dont need to use an array if you only has one input element,
$alanlar[] = array('_insert', 'tip' => 'hidden', 'varsayilan' => '1');
$alansayisi = count($alanlar);
$res .= "
";
return $res;
/* this function is very flexible, cok esnek yani... ingilizce yazdik diye yanlis anlasilmasin, anadoluda yazildi bu...;)
* example usages:
* echo inputform5('name') # displays only an input form with field name
* echo inputform5(array('name','surname')) # input form with name, surname
* echo inputform5(array(array('name','varsayilan'=>'defaultname'),'surname')) # using default value
* etc...
*/
}
function inputelement2($alan, $isAdmin = false)
{
// $isAdmin can be used in combo with another parameter in an input array to determine if a field should be enabled for administrators or disabled for non-administators including resellers.
// It's an optional parameter that can be used to limit things further during form construction depending on which user submitted the request to build a form, so to speak
// You have to tell this function how to use it, as it really doesn't have any purpose other than being a value you can use should you need it.
if (!is_array($alan))
$alan = array($alan); # convert to array if not
$solyazi = $alan['solyazi'] . $alan['lefttext'];
$alanadi = $alan['alanadi'] . $alan['name'];
$alantipi = $alan['tip'] . $alan['type'];
$sagyazi = $alan['sagyazi'] . $alan['righttext'];
// CSS Class for row
$cssclass = $alan['cssclass'];
if (!isset($cssclass) || empty($cssclass)) {
$cssclass = "";
}
$cols = $alan['cols'];
$rows = $alan['rows'];
$cols = ($cols == "" ? 40 : $cols);
$rows = ($rows == "" ? 10 : $rows);
if (!$alantipi or $alantipi == '')
$alantipi = $alan[1]; # second array element is field type
if (!$alantipi or $alantipi == '')
$alantipi = 'text';
if ($alanadi == '')
$alanadi = $alan[0]; # fieldname is the first element, if not defined as 'alanadi'=>'fieldname_example'
// Left text handling
if (!$solyazi and !in_array($alantipi, array('hidden', 'comment', 'submit'))) {
$solyazi = ucwords($alanadi);
$lastCharacter = substr($solyazi, -1);
if ($lastCharacter != ":") {
// Append a Colon
$solyazi = $solyazi . ":";
}
} else if ($solyazi && !in_array($alantipi, array('hidden', 'comment', 'submit'))) {
if (strpos($solyazi, ' ') != false) {
$wordsInLeftText = explode(' ', $solyazi);
if (count($wordsInLeftText) <= 5) {
$solyazi = ucwords($solyazi);
}
}
$lastCharacter = substr($solyazi, -1);
if ($lastCharacter != ":" && (!isset($alan['skip-ending-colon']) || $alan['skip-ending-colon'] != true)) {
// Append a Colon
$solyazi = $solyazi . ":";
}
} else if (in_array($alantipi, array('hidden', 'comment', 'submit'))) {
$solyazi = "";
}
if ($alantipi == 'comment')
$span = " colspan=3 "; # no 3 columns for comment type
$varsayilan = $alan['varsayilan'];
if (!$varsayilan)
$varsayilan = $alan['default'];
if (!$varsayilan and $alan['value'] <> '')
$varsayilan = $alan['value'];
if (!$varsayilan and $alan['deger'] <> '')
$varsayilan = $alan['deger']; # ister varsayilan, ister value, ister deger de, gine de calisir..
if ($deger == '')
$deger = $value = $varsayilan;
if ($alan['readonly'] <> '')
$readonly = 'readonly="yes"';
$res .= "
";
if ($span == '')
$res .= $solyazi . "
\n
"; # no need to a new td if there is a col span
switch ($alantipi) {
case 'password_with_generate':
#$alantipi='password';
#$alantipi='text';
/* Password generator by cs4fun.lv */
$res .= "
$sagyazi
\n";
break;
/* END Password generator by cs4fun.lv */
case 'comment':
$res .= "$varsayilan\n";
break;
case 'hidden&text':
$res .= "$varsayilan\n";
break;
case 'password':
case 'text':
case 'hidden':
$res .= "\n";
break;
case 'textarea':
$res .= " \n";
break;
case 'checkbox':
if ($alan['checked'])
$checked = "checked=" . $alan['checked'];
else
$checked = '';
if ($alan['disabled'] == 'disabled' || (!empty($alan['requires_admin']) && ($alan['requires_admin'] == true) && !$isAdmin))
$disabledInput = "disabled";
else
$disabledInput = '';
if ($deger == '')
$deger = $alanadi;
$res .= "" . $alan['secenekyazisi'] . "\n";
break;
case 'radio':
foreach ($alan['secenekler'] as $deger2 => $yazi2)
$res .= "$yazi2 ";
$res .= "";
/*
echo print_r2($alan);
echo " (varsayilan:$varsayilan) ";
*/
break;
case 'select':
$res .= "\n";
break;
case 'fileupload':
$res .= "\n
\n";
break;
case 'submit':
if ($deger == "No/Yes") { // Special no yes confirm case
$res .= "\n \n";
} else {
$res .= "\n\n";
}
break;
default:
$res .= "\n";
}
if ($span == '' and $alantipi <> 'password_with_generate')
$res .= "
$sagyazi
";
#$res.="
($alantipi)
\n";
$res .= "\n";
return $res;
}
if (!function_exists("tablobaslikyaz")) {
function tablobaslikyaz($alan, $baslik, $extra)
{ // tablolistelede kullanilmak icin yazildi.
$tr = "