[slbackup-commit] CVS update: slbackup-php/src functions.php
index.php
finnarne-guest at alioth.debian.org
finnarne-guest at alioth.debian.org
Thu Apr 12 13:23:57 UTC 2007
User: finnarne-guest
Date: 07/04/12 13:23:57
Modified: src index.php
Added: src functions.php
Log:
copied some functionality from lwat src/functions.php
Try to load config using loadconfig
Revision Changes Path
1.4 +4 -5 slbackup-php/src/index.php
Index: index.php
===================================================================
RCS file: /cvsroot/slbackup/slbackup-php/src/index.php,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- index.php 12 Apr 2007 13:10:58 -0000 1.3
+++ index.php 12 Apr 2007 13:23:57 -0000 1.4
@@ -1,5 +1,7 @@
<?php
+require_once ('functions.php') ;
+
function readcron ($passwd) {
global $backuphost, $backupuser, $backupcron, $ssh_options, $ssh_askpass ;
@@ -157,11 +159,8 @@
}
# Define some variables to easier change configuration during development
-$backuphost="localhost" ;
-$backupuser="root" ;
-$backupconf="/etc/slbackup/slbackup.conf" ;
-$backupcron="/etc/cron.d/slbackup" ;
-$ssh_options="-o StrictHostKeyChecking=no" ;
+loadConfig () ;
+
# fetch script to use whith passing the ssh-password
$ssh_askpass = sprintf ("%s/script/mypass.sh",
dirname (dirname ($_SERVER["SCRIPT_FILENAME"])));
1.1 slbackup-php/src/functions.php
Index: functions.php
===================================================================
<?php
/*
slbackup-php, an administration tool for slbackup
Copyright (C) 2007 Finn-Arne Johansen <faj at bzz.no> BzzWare AS, Norway
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.,
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
function loadConfig () {
global $backuphost, $backupuser, $backupconf, $backupcron, $ssh_options ;
@include_once ("/etc/slbackup/config.php") ;
if (empty ($smarty_templ)) $smarty_templ = $_COOKIE ['smarty_templ'] ;
if (empty ($smarty_compile)) $smarty_compile = $_COOKIE ['smarty_compile'] ;
if (empty ($backuphost)) $backuphost="backup" ;
if (empty ($backupuser)) $backupuser="root" ;
if (empty ($backupconf)) $backupconf="/etc/slbackup/slbackup.conf" ;
if (empty ($backupcron)) $backupcron="/etc/cron.d/slbackup" ;
if (empty ($ssh_options)) $ssh_options="-o StrictHostKeyChecking=no" ;
if (empty ($smarty_templ)) {
$smarty_templ = realpath ("../templates") ;
setcookie ('smarty_templ', $smarty_templ) ;
}
if (empty ($smarty_compile)) {
$smarty_compile = "/var/spool/slbackup-php" ;
if (! is_dir ($smarty_compile))
$smarty_compile = "/var/tmp" ;
setcookie ('smarty_compile', $smarty_compile) ;
}
}
function loadLocale () {
$found_locale = $_COOKIE['locale'] ;
if ($found_locale == "" && $handle = @opendir ('../locales')) {
$all_locales = array () ;
while (false !== ($file = readdir ($handle))) {
if (is_dir ('../locales/' . $file . '/LC_MESSAGES')) {
$all_locales = array_merge ($all_locales, array ($file)) ;
}
}
closedir ($handle) ;
$lang_accept = array () ;
$lang_accept = explode (",", $_SERVER['HTTP_ACCEPT_LANGUAGE']);
for ($i = 0 ; $i < count ($lang_accept) ; $i++ ) {
$lang_accept[$i] = split(";", $lang_accept[$i]) ;
$lang_accept[$i] = $lang_accept[$i][0] ;
}
if (!empty($lang_accept[0]))
foreach ($lang_accept as $lang) {
if (!isset ($locale_exact)) {
foreach ($all_locales as $locales) {
if ($locales == $lang)
$locale_exact = $lang ;
elseif (!isset ($locale_match)) {
if (strpos ($locales, $lang) === 0)
$locale_match = $locales ;
}
}
}
}
if (isset ($locale_exact))
$found_locale=$locale_exact ;
elseif (isset ($locale_match))
$found_locale=$locale_match ;
if (isset ($found_locale))
setcookie ( 'locale', $found_locale) ;
unset ($all_locales, $lang_accept, $locale_match, $locale_exact, $lang, $locales) ;
}
if (isset ($found_locale)) {
$locale = setlocale (LC_ALL, $found_locale) ;
if (empty($locale))
setlocale (LC_ALL, $found_locale . ".UTF8");
bindtextdomain ("slbackup-php", "../locales/");
bind_textdomain_codeset ("slbackup-php", "UTF-8");
textdomain ("slbackup-php");
}
header('Content-Type: text/html; charset=UTF-8') ;
}
function xorstring ($key, $xor) {
$keylen=strlen ($key) ;
if (! $keylen) return "" ;
$newstr="" ;
$index=0 ;
$keyindex = $index ;
while ($index < strlen ($xor)) {
$newstr .= chr(ord($xor[$index]) ^ ord ($key[$keyindex])) ;
$index ++ ;
$keyindex= $index % $keylen ;
}
if ($keyindex == 0) {
$last=strpos ($newstr, chr(0));
if ($last === false) {
return $newstr ;
}
return(substr ($newstr, 0, $last)) ;
}
while ($keyindex != 0) {
$newstr .= $key[$keyindex] ;
$index ++ ;
$keyindex= $index % $keylen ;
}
return ($newstr) ;
}
function debug ($mixed) {
echo "<pre>\n" ;
print_r ($mixed);
echo "\n</pre>\n" ;
}
?>
More information about the slbackup-commit
mailing list