Exemple #1
0
function verifyPath($path)
{
    if (!checkPath($path)) {
        echo getErrorRes("Access to {$path} is denied") . ' ' . $path;
        exit;
    }
}
 public function uploadFile()
 {
     $negocio = Negocio::find(Input::get('negocio_id'));
     $anioMes = strftime("%Y%m", strtotime($negocio->created_at));
     if (Input::hasFile('file')) {
         $file = Input::file('file');
         $extension = $file->getClientOriginalExtension();
         $name = $file->getClientOriginalName();
         $filename = md5(date("Ymdhis"));
         if ($extension == 'jpg' || $extension == 'png' || $extension == 'jpeg') {
             $SimplePath = checkPath($anioMes, $negocio->id, 3);
             // 3 = imagenes
             $path = public_path() . '/' . $SimplePath;
             $image = Image::make(Input::file('file')->getRealPath());
             $image->fit(1280, 480);
             //3x
             $filename3x = $filename . '@3x.' . $extension;
             $image->save($path . '/' . $filename3x);
             $image->fit(640, 240);
             //2x
             $filename2x = $filename . '@2x.' . $extension;
             $image->save($path . '/' . $filename2x);
             $image->fit(320, 120);
             //1x
             $filename1x = $filename . '.' . $extension;
             $image->save($path . '/' . $filename1x);
             $imagenNegocio = new Imagen();
             $imagenNegocio->imagen = $anioMes . '/' . $negocio->id . '/imagenes/' . $filename1x;
             $imagenNegocio->save();
             if ($negocio->imagenes()->save($imagenNegocio)) {
                 return Response::json(["response" => "ok", "img" => $anioMes . '/' . $negocio->id . '/imagenes/' . $filename1x]);
             } else {
                 return Response::json(["response" => "error"]);
             }
         }
     } else {
         return Response::json(["response" => "error"]);
     }
 }
checkFile("_conf/httpd-vhosts.conf", "Required file is missing from your configuration source");
checkFile("_conf/php.ini", "Required file is missing from your configuration source");
checkFile("_conf/my.cnf", "Required file is missing from your configuration source");
checkFile("_conf/apache.conf", "Required file is missing from your configuration source");
// TODO: create .bash_profile if it does not exist
// Has not been tested
checkFileOrCreate("~/.bash_profile", "_conf/bash_profile.start");
checkPath("~/Sites");
command("sudo mkdir /srv");
command("sudo ln -s ~/Sites /srv/sites");
checkPath("~/Sites/apache");
// mysql paths
checkPath("/opt/local/var/run/mysql56", "sudo");
checkPath("/opt/local/var/db/mysql56", "sudo");
checkPath("/opt/local/etc/mysql56", "sudo");
checkPath("/opt/local/share/mysql56", "sudo");
// continue with setup
output("\nInstalling software");
// make sure correct version of Xcode is selected
command("sudo xcode-select -switch /Applications/Xcode.app/Contents/Developer/");
// update macports
command("sudo port selfupdate");
command("sudo port install mysql56-server");
command("sudo port install php55 +apache2 +mysql56-server +pear php55-apache2handler");
command("sudo port install php55-mysql");
command("sudo port install php55-openssl");
command("sudo port install php55-mbstring");
command("sudo port install php55-curl");
command("sudo port install php55-zip");
command("sudo port install php55-imagick");
command("sudo port install php55-memcached");
Exemple #4
0
/**
*   @desc Замеряет размер указанного объекта
*   @return
*/
function folderSize($basePath)
{
    $fs = DAO::getInstance('fs');
    // проверяем путь на доступ
    $szBasePath = toCanonical(realpath(FILE_PATH . $basePath));
    $szErrorMessage = checkPath($szBasePath);
    if (empty($szErrorMessage)) {
        $nSize = $fs->getSize(toCanonical($szBasePath));
    } else {
        $nSize = 0;
    }
    $aResult = array('error' => $szErrorMessage, 'size' => $nSize);
    return $aResult;
}
 function feedbackUpload()
 {
     $id = $this->_get('id', 'img_url');
     $dir = $this->_get('path', '');
     if (!checkPath($dir)) {
         $dir = 'user';
     }
     $ids = $this->_get('ids', 0);
     if (!$id) {
         showError('参数错误');
     }
     $upload_img_type = chop(str_replace('|', ',', C('upload', 'attach_type')), "|");
     $upload_img_type .= ',' . str_replace('|', ',', C('upload', 'pic_type'));
     $this->assign(array('upload_img_type' => $upload_img_type, 'id' => $id, 'ids' => $ids, 'dir' => $dir));
     $this->display('index');
 }
function copy_dir($src, $dest)
{
    static $max;
    if (!isset($max)) {
        $max = 0;
    }
    $max++;
    if ($max > 25) {
        return false;
    }
    checkPath($dest);
    $handle = opendir($src);
    $C = 0;
    while (false !== ($file = readdir($handle)) && $C++ < 100) {
        if ($file == '.' || $file == '..') {
            continue;
        }
        if (is_dir($src . '/' . $file)) {
            copy_dir($src . '/' . $file, $dest . '/' . $file);
        } else {
            copy($src . '/' . $file, $dest . '/' . $file);
        }
    }
    if ($C >= 100) {
        print "{$src}, {$dest}<br>";
    }
    @closedir($handle);
}
Exemple #7
0
<?php

use Extasy\CMS;
require_once dirname(__FILE__) . '/_lib/loader.php';
$fs = DAO::getInstance('fs');
?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML id="document">
<?php 
if (isset($_POST['basepath']) && !empty($_FILES['file']) && is_uploaded_file($_FILES['file']['tmp_name'])) {
    $szPath = toCanonical(realpath(FILE_PATH . $_POST['basepath']));
    $szErrorMessage = checkPath($szPath);
    if (empty($szErrorMessage)) {
        $fs->upload('file', $szPath . str_replace(' ', '', $_FILES['file']['name']));
        $fs->chmod($szPath . str_replace(' ', '', $_FILES['file']['name']), 0777);
        ?>
<HEAD>
<TITLE> New Document </TITLE>
<META NAME="Generator" CONTENT="EditPlus">
<META NAME="Author" CONTENT="">
<META NAME="Keywords" CONTENT="">
<META NAME="Description" CONTENT="">
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
</HEAD>
<BODY BGCOLOR=#EEEEEE >
	<script>
	if (window.parent.ii != null)
	{
		window.parent.ii.inClosePopup();
	}
	
Exemple #8
0
    $action = $_GET['action'];
} else {
    exit('{"status":"error","data":{"error":"No Action Specified"}}');
}
//////////////////////////////////////////////////////////////////
// Ensure Project Has Been Loaded
//////////////////////////////////////////////////////////////////
if (!isset($_SESSION['project'])) {
    $_GET['action'] = 'get_current';
    $_GET['no_return'] = 'true';
    require_once '../project/controller.php';
}
//////////////////////////////////////////////////////////////////
// Security Check
//////////////////////////////////////////////////////////////////
if (!checkPath($_GET['path'])) {
    die('{"status":"error","message":"Invalid Path"}');
}
//////////////////////////////////////////////////////////////////
// Define Root
//////////////////////////////////////////////////////////////////
$_GET['root'] = WORKSPACE;
//////////////////////////////////////////////////////////////////
// Handle Action
//////////////////////////////////////////////////////////////////
$Filemanager = new Filemanager($_GET, $_POST, $_FILES);
$Filemanager->project = @$_SESSION['project']['path'];
switch ($action) {
    case 'index':
        $Filemanager->index();
        break;
 static function run()
 {
     $sys = C('System');
     if ($sys['path_mod'] == 3 && isHave($_GET['s']) && !isHave($_SERVER['PATH_INFO'])) {
         $_SERVER['PATH_INFO'] = $_GET['s'];
     }
     if (isHave($_SERVER['PATH_INFO'])) {
         $pathinfo = explode($sys['delimiter'], $_SERVER['PATH_INFO']);
         $count = count($pathinfo);
         if ($count) {
             if (strExists($pathinfo[0], $sys['delimiter'])) {
                 $pathinfo[0] = trim($pathinfo[0], $sys['delimiter']);
                 array_unshift($pathinfo, '');
             }
             $count = $count - 1;
             if (empty($pathinfo[$count - 1])) {
                 unset($pathinfo[$count - 1]);
             }
             if (!empty($sys['postfix']) && strExists($pathinfo[$count], $sys['postfix'])) {
                 $pathinfo[$count] = strtr($pathinfo[$count], array($sys['postfix'] => ''));
             }
             if (isHave($pathinfo[1]) && $pathinfo[1] != $sys['default_group'] && $sys['group_list'] && in_array($pathinfo[1], $sys['group_list'])) {
                 $_GET['g'] = $pathinfo[1];
                 if (isHave($pathinfo[2])) {
                     $_GET['c'] = $pathinfo[2];
                 }
                 if (isHave($pathinfo[3])) {
                     $_GET['m'] = $pathinfo[3];
                 }
                 $goIndex = 4;
             } else {
                 if (isHave($pathinfo[1])) {
                     $_GET['c'] = $pathinfo[1];
                 }
                 if (isHave($pathinfo[2])) {
                     $_GET['m'] = $pathinfo[2];
                 }
                 $goIndex = 3;
             }
             if ($count > $goIndex) {
                 for ($foo = $goIndex; $foo < $count; $foo += 2) {
                     $_GET[$pathinfo[$foo]] = $pathinfo[$foo + 1];
                 }
             }
         }
     }
     $_GET['c'] = isHave($_GET['c']) ? trim($_GET['c']) : $sys['c'];
     $_GET['m'] = isHave($_GET['m']) ? trim($_GET['m']) : $sys['m'];
     $_GET['g'] = isHave($_GET['g']) ? trim($_GET['g']) : $sys['default_group'];
     define('GROUP_NAME', $_GET['g']);
     define('ACTION_NAME', $_GET['c']);
     define('MODEL_NAME', $_GET['m']);
     $GLOBALS['System']['g'] = GROUP_NAME;
     $GLOBALS['System']['c'] = ACTION_NAME;
     $GLOBALS['System']['m'] = MODEL_NAME;
     $c = ACTION_NAME . 'Action';
     $path = APP_PATH . 'lib/action/' . (GROUP_NAME == 'index' || !GROUP_NAME ? 'index/' : GROUP_NAME . '/') . $c . '.class.php';
     if (checkPath($c) && is_file($path)) {
         if (isHave($sys['autoload_action'])) {
             foreach ($sys['autoload_action'] as $key => $val) {
                 if (!is_string($key) || $key == GROUP_NAME) {
                     if (!is_array($val)) {
                         $val = array($val);
                     }
                     foreach ($val as $v) {
                         if (!$key || $key == 'index') {
                             $key = 'index/';
                         } else {
                             $key .= '/';
                         }
                         $autoPath = APP_PATH . 'lib/action/' . $key . $v . 'Action.class.php';
                         if (is_file($autoPath)) {
                             include $autoPath;
                         } else {
                             showError('自动加载控制器:' . $v . '不存在');
                         }
                     }
                 }
             }
         }
         include $path;
         $control = '';
         if (class_exists($c)) {
             $control = new $c();
         }
         if (checkPath(MODEL_NAME) && method_exists($control, MODEL_NAME)) {
             return $control->{$_GET}['m']();
         } elseif (method_exists($control, '_empty')) {
             return $control->_empty();
         } elseif (method_exists($control, '_error')) {
             return $control->_error();
         } else {
             showError('模型 ' . htmlspecialchars(strip_tags(MODEL_NAME)) . ' 不存在');
         }
     }
     showError('控制器 ' . htmlspecialchars(strip_tags(ACTION_NAME)) . ' 不存在');
 }
Exemple #10
0
        } else {
            $Project->path = $_GET['project_name'];
        }
        // Git Clone?
        if (!empty($_GET['git_repo'])) {
            $Project->gitrepo = $_GET['git_repo'];
            $Project->gitbranch = $_GET['git_branch'];
        }
        $Project->Create();
    }
}
//////////////////////////////////////////////////////////////////
// Rename Project
//////////////////////////////////////////////////////////////////
if ($_GET['action'] == 'rename') {
    if (!checkPath($_GET['project_path'])) {
        die(formatJSEND("error", "No Access"));
    }
    $Project->path = $_GET['project_path'];
    $Project->Rename();
}
//////////////////////////////////////////////////////////////////
// Delete Project
//////////////////////////////////////////////////////////////////
if ($_GET['action'] == 'delete') {
    if (checkAccess()) {
        $Project->path = $_GET['project_path'];
        $Project->Delete();
    }
}
//////////////////////////////////////////////////////////////////
                            }
                        } else {
                            //mail('*****@*****.**','xxxxxx 404 no uid',$cur_path);
                        }
                    }
                } else {
                    //mail('*****@*****.**','xxxxxx 404',$cur_path);
                }
            }
        } else {
            //mail('*****@*****.**','xxxxxx 404',$cur_path);
        }
    }
}
$cur_path = $_SERVER['REQUEST_URI'];
checkPath($cur_path);
?>
<!DOCTYPE html>
<html lang="en">
<head>
<title>404 Page Not Found</title>
<style type="text/css">

::selection{ background-color: #E13300; color: white; }
::moz-selection{ background-color: #E13300; color: white; }
::webkit-selection{ background-color: #E13300; color: white; }

body {
	background-color: #fff;
	margin: 40px;
	font: 13px/20px normal Helvetica, Arial, sans-serif;
function D($classname = '')
{
    static $_Dmodel = array();
    static $_DmodelAutoLoad = array();
    //自动加载模型
    $sys = C('system', 'autoload_model');
    if (!$_DmodelAutoLoad && isHave($sys)) {
        foreach ($sys as $val) {
            $path = APP_PATH . 'lib/model/' . $val . 'Model.class.php';
            if (is_file($path)) {
                include $path;
                $_DmodelAutoLoad[$val] = true;
            } else {
                showError('自动加载模型:' . $val . '不存在');
            }
        }
    }
    if (!empty($classname)) {
        if (isset($_Dmodel[$classname])) {
            return $_Dmodel[$classname];
        }
        $path = APP_PATH . 'lib/model/' . $classname . 'Model.class.php';
        if (is_file($path)) {
            load('model');
            if (!isset($_DmodelAutoLoad[$classname])) {
                include $path;
            }
            $class = $classname . 'Model';
            if (checkPath($classname) && class_exists($class)) {
                $_Dmodel[$classname] = new $class();
                return $_Dmodel[$classname];
            }
        }
    }
    return M($classname);
}
Exemple #13
0
/**
 * Build the js if necessary
 *
 */
function R3BuildJS($force = false)
{
    global $auth, $jsPacker;
    $appCode = strtolower(APPLICATION_CODE);
    $jsDestPath = R3_UPLOAD_DATA_DIR . strtolower(R3EcoGisHelper::getCurrentDomainName()) . "/js/";
    $masterFileName = "{$jsDestPath}{$appCode}_all.js";
    if (!$force) {
        $rebuild = !file_exists($masterFileName);
        if (!$rebuild) {
            $compiledAge = filemtime($masterFileName);
            $files = $jsPacker['JS_files'];
            if (isset($jsPacker['files'])) {
                foreach ($jsPacker['files'] as $name => $fileGroup) {
                    $name = str_replace('<LANG>', R3Locale::getLanguageCode(), $name);
                    if (!file_exists("{$jsDestPath}{$name}")) {
                        $rebuild = true;
                        ezcLog::getInstance()->log("JavaScript file \"{$jsDestPath}{$name}\" not found. Rebuild necessary", ezcLog::DEBUG);
                        break;
                    }
                    foreach ($fileGroup as $file) {
                        $files[] = $file;
                    }
                }
            }
            foreach ($files as $file) {
                $file = str_replace('<LANG>', R3Locale::getLanguageCode(), $file);
                if (filemtime(R3_WEB_JS_DIR . $file) > $compiledAge) {
                    // Complie needed
                    $rebuild = true;
                    break;
                }
            }
        }
    }
    if ($force || $rebuild) {
        checkPath(dirname($masterFileName), true, true);
        // Non packed files
        if (isset($jsPacker['files'])) {
            foreach ($jsPacker['files'] as $name => $fileGroup) {
                $script = '';
                foreach ($fileGroup as $file) {
                    $file = str_replace('<LANG>', R3Locale::getLanguageCode(), $file);
                    $script .= "/*** " . basename($file) . " ***/\n\n\n" . file_get_contents(R3_WEB_JS_DIR . $file) . "\n\n\n";
                }
                $name = str_replace('<LANG>', R3Locale::getLanguageCode(), dirname($masterFileName) . '/' . $name);
                ezcLog::getInstance()->log("JavaScript rebuild for \"{$name}\"", ezcLog::DEBUG);
                file_put_contents($name, $script);
            }
        }
        require_once R3_LIB_DIR . 'class.JavaScriptPacker.php';
        $script = '';
        $funcList = array();
        foreach ($jsPacker['JS_files'] as $file) {
            $data = file_get_contents(R3_WEB_JS_DIR . $file);
            $script .= "{$data}\n\n\n";
            // Check function averride!
            foreach (explode("\n", $data) as $lineNo => $line) {
                if (substr($line, 0, 9) == 'function ' && ($p = strpos($line, '(')) !== false) {
                    $name = trim(substr($line, 9, $p - 9));
                    if (isset($funcList[$name])) {
                        echo "<b>Warning</b>: JavaScript function \"{$name}\" in file {$file}:{$lineNo} already declared in file {$funcList[$name]['file']}:{$funcList[$name]['line']}.<br />\n";
                    }
                    $funcList[$name] = array('file' => $file, 'line' => $lineNo);
                }
            }
        }
        if (!isset($jsPacker['minify_output'])) {
            ezcLog::getInstance()->log("JavaScript rebuild for \"{$masterFileName}\"", ezcLog::DEBUG);
            file_put_contents($masterFileName, $script);
        } else {
            $packer = new JavaScriptPacker($script, $jsPacker['minify_output'] ? 'Normal' : 'None', true, false);
            $packed = $packer->pack();
            ezcLog::getInstance()->log("JavaScript rebuild for \"{$masterFileName}\"", ezcLog::DEBUG);
            file_put_contents($masterFileName, $packed);
        }
    }
}
Exemple #14
0
function start_session($updateUserFormatsStylesTypesPermissions)
{
    global $databaseBaseURL;
    // these variables are defined in 'ini.inc.php'
    global $defaultMainFields;
    global $filesBaseDir;
    global $filesBaseURL;
    global $loginEmail;
    global $loginUserID;
    global $loginFirstName;
    global $loginLastName;
    global $abbrevInstitution;
    global $lastLogin;
    global $referer;
    // '$referer' is made globally available from within this function
    global $connection;
    // Initialize the session:
    if (!isset($_SESSION["sessionID"])) {
        // Ensure that cookies are enabled:
        if (ini_get('session.use_cookies') == 0) {
            // if 'session.use_cookies' is OFF for the current directory
            ini_set('session.use_cookies', 1);
        }
        // enable storage of sessions within cookies
        session_start();
        $sessionID = session_id();
        // get the current session ID
        if (!empty($sessionID)) {
            saveSessionVariable("sessionID", $sessionID);
        }
    }
    // Set the system's locale information:
    list($systemLocaleCollate, $systemLocaleCType) = setSystemLocale();
    // Set the default timezone used by all date/time functions
    // Note: The 'date_default_timezone_set/date_default_timezone_get' functions are available since PHP 5.1.0
    if (function_exists("date_default_timezone_set") && function_exists("date_default_timezone_get")) {
        @date_default_timezone_set(@date_default_timezone_get());
    }
    // NOTE: Upon first connection to the MySQL server, function 'connectToMySQLDatabase()' will query the
    //       MySQL server for the MySQL version and save it to a session variable
    // Extract session variables (only necessary if register globals is OFF!):
    if (isset($_SESSION['loginEmail'])) {
        $loginEmail = $_SESSION['loginEmail'];
        $loginUserID = $_SESSION['loginUserID'];
        $loginFirstName = $_SESSION['loginFirstName'];
        $loginLastName = $_SESSION['loginLastName'];
        $abbrevInstitution = $_SESSION['abbrevInstitution'];
        $lastLogin = $_SESSION['lastLogin'];
    } elseif ($updateUserFormatsStylesTypesPermissions) {
        // If the user isn't logged in we set the available export formats, citation styles, document types and permissions to
        // the defaults which are specified in the 'formats', 'styles', 'types' and 'user_permissions' tables for 'user_id = 0'.
        // (a 'user_id' of zero is used within these tables to indicate the default settings if the user isn't logged in)
        // NOTE: As an exception, for anyone who isn't logged in, we don't load the default number of records from option
        //       'records_per_page' in table 'user_options', but instead use the value given in variable '$defaultNumberOfRecords'
        //       in 'ini.inc.php'. Similarly, if the user isn't logged in, the list of "main fields" is taken from variable
        //       '$defaultMainFields' in 'ini.inc.php' and not from option 'main_fields' in table 'user_options. Same holds true
        //       for variable '$autoCompleteUserInput' vs. option 'show_auto_completions'.
        // Get all export formats that were selected by the admin to be visible if a user isn't logged in
        // and (if some formats were found) save them as semicolon-delimited string to the session variable 'user_export_formats':
        getVisibleUserFormatsStylesTypes(0, "format", "export");
        // Get all citation formats that were selected by the admin to be visible if a user isn't logged in
        // and (if some formats were found) save them as semicolon-delimited string to the session variable 'user_cite_formats':
        getVisibleUserFormatsStylesTypes(0, "format", "cite");
        // Get all citation styles that were selected by the admin to be visible if a user isn't logged in
        // and (if some styles were found) save them as semicolon-delimited string to the session variable 'user_styles':
        getVisibleUserFormatsStylesTypes(0, "style", "");
        // Get all document types that were selected by the admin to be visible if a user isn't logged in
        // and (if some types were found) save them as semicolon-delimited string to the session variable 'user_types':
        getVisibleUserFormatsStylesTypes(0, "type", "");
        // Get the user permissions for the current user
        // and save all allowed user actions as semicolon-delimited string to the session variable 'user_permissions':
        getPermissions(0, "user", true);
        // Get the default view for the current user
        // and save it to the session variable 'userDefaultView':
        getDefaultView(0);
        // Get the default number of records per page preferred by the current user
        // and save it to the session variable 'userRecordsPerPage':
        getDefaultNumberOfRecords(0);
        // Get the user's preference for displaying auto-completions
        // and save it to the session variable 'userAutoCompletions':
        getPrefAutoCompletions(0);
        // Get the list of "main fields" for the current user
        // and save the list of fields as comma-delimited string to the session variable 'userMainFields':
        getMainFields(0);
    } else {
        // The scripts 'error.php', 'install.php' & 'update.php' use 'start_session(false);' so that they execute without errors
        // when there isn't any database yet. However, function 'buildQuickSearchElements()' (which builds the "Quick Search" form
        // in the page header) requires the session variable 'userMainFields' to be present. So we take the list of "main fields"
        // directly from the global variable '$defaultMainFields' and save it as session variable (we cannot use function
        // 'getMainFields()' here since this would require database access):
        if (!isset($_SESSION['userMainFields'])) {
            saveSessionVariable("userMainFields", $defaultMainFields);
        }
    }
    // Set the referrer:
    if (isset($_REQUEST['referer']) and !empty($_REQUEST['referer'])) {
        $referer = $_REQUEST['referer'];
    } elseif (isset($_SESSION['referer']) and !empty($_SESSION['referer'])) {
        $referer = $_SESSION['referer'];
        // get the referring URL from the superglobal '$_SESSION' variable (if any)
        deleteSessionVariable("referer");
    } elseif (isset($_SERVER['HTTP_REFERER']) and !empty($_SERVER['HTTP_REFERER'])) {
        $referer = $_SERVER['HTTP_REFERER'];
    } else {
        // as an example, the referrer won't be set if a user clicked on a URL of type 'show.php?record=12345' within an email announcement
        $referer = "index.php";
    }
    // if all other attempts fail, we'll re-direct to the main page
    // Verify important variables from 'ini.inc.php':
    // - Ensure that the given paths/URLs end with a slash:
    $databaseBaseURL = checkPath($databaseBaseURL, "URL");
    $filesBaseDir = checkPath($filesBaseDir);
    $filesBaseURL = checkPath($filesBaseURL, "URL");
}
Exemple #15
0
function internationalizeFile($sFilepath)
{
    global $dOptions;
    $s = "";
    $sKey = "";
    $sValue = "";
    $sPre = "";
    $sPost = "";
    $sInLine = "";
    $sOutLine = array();
    $iLineNr = 0;
    $iPos = 0;
    $iEndPos = 0;
    $iMarkerLen = strlen(MARKER);
    $sOutFolder = "";
    $sOutFilepath = "";
    $inFile = 0;
    $f = 0;
    $iLang = 0;
    $aOutFiles = array();
    $sIntFilepath = $sFilepath . "." . INT_EXT;
    _log("Working on {$sFilepath}", 1);
    echo ".";
    flush();
    // progress indicator
    if (file_exists($sIntFilepath)) {
        // internationalze it
        parseIntFile($sIntFilepath, $dTransDict);
        // print_r($dOptions);
        // print_r($dTransDict);
        $inFile = @fopen($sFilepath, "r");
        if (!$inFile) {
            error("Could not open {$sFilename}", true);
        }
        foreach ($dOptions[OPTIONS_DESTINATIONS] as $s) {
            $sOutFolder = odPath_sCombine($s, odPath_sParent($sFilepath));
            odPath_createPath($sOutFolder);
            $sOutFilepath = odPath_sCombine($sOutFolder, odPath_sFilename($sFilepath));
            checkPath($sOutFilepath);
            $f = @fopen($sOutFilepath, "w");
            if (!$f) {
                error("Could not write to {$sOutFilepath}", true);
            }
            $aOutFiles[] = $f;
        }
        while (!feof($inFile)) {
            $sInLine = fgets($inFile);
            $iLineNr++;
            $iLang = 0;
            foreach ($aOutFiles as $f) {
                $sOutLine = $sInLine;
                while (($iPos = strpos($sOutLine, MARKER, $iPos)) !== false) {
                    $iEndPos = strpos($sOutLine, MARKER, $iPos + 1);
                    if ($iEndPos === false) {
                        error("Marker error - no closing marker in {$sFilepath} at line {$iLineNr}", true);
                    }
                    $sKey = substr($sOutLine, $iPos + $iMarkerLen, $iEndPos - $iPos - $iMarkerLen);
                    $sPre = substr($sOutLine, 0, $iPos);
                    $sPost = substr($sOutLine, $iEndPos + $iMarkerLen);
                    $sValue = "Unkown key: {$sKey}";
                    if (!isset($dTransDict[$sKey])) {
                        error("Unkown key {$sKey} in line {$iLineNr} of {$sFilepath}", false);
                    } else {
                        if (!isset($dTransDict[$sKey][$iLang])) {
                            error("Language count missmatch for key {$sKey} in line {$iLineNr} of {$sFilepath}", false);
                        } else {
                            $sValue = $dTransDict[$sKey][$iLang];
                        }
                    }
                    $sOutLine = $sPre . $sValue . $sPost;
                }
                fwrite($f, $sOutLine);
                $iLang++;
            }
        }
        @fclose($inFile);
        foreach ($aOutFiles as $f) {
            @fclose($f);
        }
    } else {
        // just copy it
        foreach ($dOptions[OPTIONS_DESTINATIONS] as $s) {
            $sOutFolder = odPath_sCombine($s, odPath_sParent($sFilepath));
            odPath_createPath($sOutFolder);
            $sOutFilepath = odPath_sCombine($sOutFolder, odPath_sFilename($sFilepath));
            checkPath($sOutFilepath);
            _log("Copying {$sFilepath} to {$sOutFilepath}", 1);
            if (!@copy($sFilepath, $sOutFilepath)) {
                error("Copying {$sFilepath} to {$sOutFilepath} didn't work");
            }
        }
    }
}
Exemple #16
0
    showDefaultPage();
    exit(0);
} else {
    if ($step == 1) {
        header("Content-type:text/html;charset=UTF-8");
        showLicense();
        exit(0);
    } else {
        if ($step == 2) {
            header("Content-type:text/html;charset=UTF-8");
            showFileConfig();
            exit(0);
        } else {
            if ($step == 3) {
                header("Content-type:text/html;charset=UTF-8");
                checkPath();
                exit(0);
            } else {
                if ($step == 4) {
                    header("Content-type:text/html;charset=UTF-8");
                    showDatabase();
                    exit(0);
                } else {
                    if ($step == 5) {
                        header("Content-type:text/html;charset=UTF-8");
                        checkDatabase();
                        exit(0);
                    } else {
                        if ($step == 6) {
                            header("Content-type:text/html;charset=UTF-8");
                            complete();