Пример #1
0
 function Init($language, $type = "main")
 {
     if ($type == "admin") {
         if (!in_array($language, pfcI18N::GetAcceptedLanguage("admin"))) {
             $language = pfcI18N::GetDefaultLanguage();
         }
     }
     if (!in_array($language, pfcI18N::GetAcceptedLanguage())) {
         $language = pfcI18N::GetDefaultLanguage();
     }
     if ($type == "admin") {
         require_once dirname(__FILE__) . "/../i18n/" . $language . "/admin.php";
     } else {
         require_once dirname(__FILE__) . "/../i18n/" . $language . "/main.php";
     }
     $serverid = isset($GLOBALS['serverid']) ? $GLOBALS['serverid'] : 0;
     // serverid is used to avoid conflicts with external code using same 'i18n' key
     $GLOBALS[$serverid]['i18n'] = $GLOBALS['i18n'];
     // do not pass by reference because $GLOBALS['i18n'] is maybe used by unknown external code
     $GLOBALS["output_encoding"] = "UTF-8";
     // by default client/server communication is utf8 encoded
 }
Пример #2
0
 /**
  * printChat must be called somewhere in the page
  * it inserts necessary html which will receive chat's data
  * usage:
  * <code>
  *   <?php $chat->printChat(); ?>
  * </code>
  */
 function printChat($return = false)
 {
     $c =& pfcGlobalConfig::Instance();
     $u =& pfcUserConfig::Instance();
     $output = '';
     pfcI18N::SwitchOutputEncoding($c->output_encoding);
     $path = $c->getFilePathFromTheme('chat.js.tpl.php');
     $t = new pfcTemplate($path);
     $t->assignObject($u, "u");
     $t->assignObject($c, "c");
     $output .= $t->getOutput();
     pfcI18N::SwitchOutputEncoding();
     /*
     $output .= " // ]]>\n";
     $output .= "</script>\n";
     */
     if ($return) {
         return $output;
     } else {
         echo $output;
     }
 }
 /**
  * Initialize the phpfreechat configuration
  * this initialisation is done once at startup then it is stored into a session cache
  */
 function init()
 {
     $ok = true;
     // check the parameters types
     $array_params = $this->_params_type["array"];
     foreach ($array_params as $ap) {
         if (!is_array($this->{$ap})) {
             $this->errors[] = _pfc("'%s' parameter must be an array", $ap);
         }
     }
     $numerical_positive_params = $this->_params_type["positivenumeric"];
     foreach ($numerical_positive_params as $npp) {
         if (!is_int($this->{$npp}) || $this->{$npp} < 0) {
             $this->errors[] = _pfc("'%s' parameter must be a positive number", $npp);
         }
     }
     $boolean_params = $this->_params_type["bool"];
     foreach ($boolean_params as $bp) {
         if (!is_bool($this->{$bp})) {
             $this->errors[] = _pfc("'%s' parameter must be a boolean", $bp);
         }
     }
     $string_params = $this->_params_type["string"];
     foreach ($string_params as $sp) {
         if (!is_string($this->{$sp})) {
             $this->errors[] = _pfc("'%s' parameter must be a charatere string", $sp);
         }
     }
     if ($this->title == "") {
         $this->title = _pfc("My Chat");
     }
     // first of all, check the used functions
     $f_list["file_get_contents"] = _pfc("You need %s", "PHP 4 >= 4.3.0 or PHP 5");
     $err_session_x = "You need PHP 4 or PHP 5";
     $f_list["session_start"] = $err_session_x;
     $f_list["session_destroy"] = $err_session_x;
     $f_list["session_id"] = $err_session_x;
     $f_list["session_name"] = $err_session_x;
     $err_preg_x = _pfc("You need %s", "PHP 3 >= 3.0.9 or PHP 4 or PHP 5");
     $f_list["preg_match"] = $err_preg_x;
     $f_list["preg_replace"] = $err_preg_x;
     $f_list["preg_split"] = $err_preg_x;
     $err_ob_x = _pfc("You need %s", "PHP 4 or PHP 5");
     $f_list["ob_start"] = $err_ob_x;
     $f_list["ob_get_contents"] = $err_ob_x;
     $f_list["ob_end_clean"] = $err_ob_x;
     $f_list["get_object_vars"] = _pfc("You need %s", "PHP 4 or PHP 5");
     $this->errors = array_merge($this->errors, check_functions_exist($f_list));
     //    $this->errors = array_merge($this->errors, @test_writable_dir($this->data_public_path, "data_public_path"));
     $this->errors = array_merge($this->errors, @test_writable_dir($this->data_private_path, "data_private_path"));
     $this->errors = array_merge($this->errors, @test_writable_dir($this->data_private_path . "/cache", "data_private_path/cache"));
     // install the public directory content
     $dir = dirname(__FILE__) . "/../data/public/js";
     $dh = opendir($dir);
     while (false !== ($file = readdir($dh))) {
         $f_src = $dir . '/' . $file;
         $f_dst = $this->data_public_path . '/js/' . $file;
         if ($file == "." || $file == ".." || !is_file($f_src)) {
             continue;
         }
         // skip . and .. generic files
         // install js files only if the destination doesn't exists or if the destination timestamp is older than the source timestamp
         if (!file_exists($f_dst) || filemtime($f_dst) < filemtime($f_src)) {
             mkdir_r($this->data_public_path . '/js/');
             copy($f_src, $f_dst);
         }
         if (!file_exists($f_dst)) {
             $this->errors[] = _pfc("%s doesn't exist, data_public_path cannot be installed", $f_dst);
         }
     }
     closedir($dh);
     // ---
     // test client script
     // try to find the path into server configuration
     if ($this->client_script_path == '') {
         $this->client_script_path = pfc_GetScriptFilename();
     }
     if ($this->server_script_url == '' && $this->server_script_path == '') {
         $filetotest = $this->client_script_path;
         // do not take into account the url parameters
         if (preg_match("/(.*)\\?(.*)/", $filetotest, $res)) {
             $filetotest = $res[1];
         }
         if (!file_exists($filetotest)) {
             $this->errors[] = _pfc("%s doesn't exist", $filetotest);
         }
         $this->server_script_url = './' . basename($filetotest) . $this->_query_string;
     }
     // calculate datapublic url
     if ($this->data_public_url == "") {
         $this->data_public_url = pfc_RelativePath($this->client_script_path, $this->data_public_path);
     }
     if ($this->server_script_path == '') {
         $this->server_script_path = $this->client_script_path;
     }
     // ---
     // test server script
     if ($this->server_script_url == '') {
         $filetotest = $this->server_script_path;
         // do not take into account the url parameters
         if (preg_match("/(.*)\\?(.*)/", $this->server_script_path, $res)) {
             $filetotest = $res[1];
         }
         if (!file_exists($filetotest)) {
             $this->errors[] = _pfc("%s doesn't exist", $filetotest);
         }
         $this->server_script_url = pfc_RelativePath($this->client_script_path, $this->server_script_path) . '/' . basename($filetotest) . $this->_query_string;
     }
     // check if the theme_path parameter are correctly setup
     if ($this->theme_default_path == '' || !is_dir($this->theme_default_path)) {
         $this->theme_default_path = dirname(__FILE__) . '/../themes';
     }
     if ($this->theme_path == '' || !is_dir($this->theme_path)) {
         $this->theme_path = $this->theme_default_path;
     }
     // If the user didn't give any theme_default_url value,
     // copy the default theme resources in a public directory
     if ($this->theme_default_url == '') {
         mkdir_r($this->data_public_path . '/themes/default');
         if (!is_dir($this->data_public_path . '/themes/default')) {
             $this->errors[] = _pfc("cannot create %s", $this->data_public_path . '/themes/default');
         } else {
             $ret = copy_r(dirname(__FILE__) . '/../themes/default', $this->data_public_path . '/themes/default');
             if (!$ret) {
                 $this->errors[] = _pfc("cannot copy %s in %s", dirname(__FILE__) . '/../themes/default', $this->data_public_path . '/themes/default');
             }
         }
         $this->theme_default_url = $this->data_public_url . '/themes';
     }
     if ($this->theme_url == '') {
         mkdir_r($this->data_public_path . '/themes/' . $this->theme);
         if (!is_dir($this->data_public_path . '/themes/' . $this->theme)) {
             $this->errors[] = _pfc("cannot create %s", $this->data_public_path . '/themes/' . $this->theme);
         } else {
             $ret = copy_r($this->theme_path . '/' . $this->theme, $this->data_public_path . '/themes/' . $this->theme);
             if (!$ret) {
                 $this->errors[] = _pfc("cannot copy %s in %s", $this->theme_path . '/' . $this->theme, $this->data_public_path . '/themes/' . $this->theme);
             }
         }
         $this->theme_url = $this->theme_default_url;
     }
     // if the user do not have an existing prototype.js library, we use the embeded one
     if ($this->prototypejs_url == '') {
         $this->prototypejs_url = $this->data_public_url . '/js/prototype.js';
     }
     // ---
     // run specific container initialisation
     $ct =& pfcContainer::Instance();
     $ct_errors = $ct->init($this);
     $this->errors = array_merge($this->errors, $ct_errors);
     // check the language is known
     $lg_list = pfcI18N::GetAcceptedLanguage();
     if ($this->language != "" && !in_array($this->language, $lg_list)) {
         $this->errors[] = _pfc("'%s' parameter is not valid. Available values are : '%s'", "language", implode(", ", $lg_list));
     }
     // calculate the proxies chaine
     $this->proxies = array();
     foreach ($this->pre_proxies as $px) {
         if (!in_array($px, $this->skip_proxies) && !in_array($px, $this->proxies)) {
             $this->proxies[] = $px;
         }
     }
     foreach ($this->_sys_proxies as $px) {
         if (!in_array($px, $this->skip_proxies) && !in_array($px, $this->proxies)) {
             $this->proxies[] = $px;
         }
     }
     foreach ($this->post_proxies as $px) {
         if (!in_array($px, $this->skip_proxies) && !in_array($px, $this->proxies)) {
             $this->proxies[] = $px;
         }
     }
     // save the proxies path
     $this->proxies_path_default = dirname(__FILE__) . '/proxies';
     // check the customized proxies path
     if ($this->proxies_path != '' && !is_dir($this->proxies_path)) {
         $this->errors[] = _pfc("'%s' directory doesn't exist", $this->proxies_path);
     }
     if ($this->proxies_path == '') {
         $this->proxies_path = $this->proxies_path_default;
     }
     // save the commands path
     $this->cmd_path_default = dirname(__FILE__) . '/commands';
     if ($this->cmd_path == '') {
         $this->cmd_path = $this->cmd_path_default;
     }
     // load smileys from file
     $this->loadSmileyTheme();
     // load version number from file
     $this->version = trim(file_get_contents(dirname(__FILE__) . "/../version.txt"));
     $this->is_init = count($this->errors) == 0;
 }
Пример #4
0
echo _pfc("Administration");
?>
</h2>

  <div><h3><?php 
echo _pfc("Available Languages");
?>
</h3>
    <ul>
      <li><form action="<?php 
echo $_SERVER['PHP_SELF'];
?>
" method="post">
          <select name="lang">
        <?php 
$available_admin_lang = pfcI18N::GetAcceptedLanguage("admin");
for ($i = 0; $i < count($available_admin_lang); $i++) {
    if ($lang == $available_admin_lang[$i]) {
        $selected = "selected=\"selected\"";
    } else {
        $selected = "";
    }
    echo "<option value=\"{$available_admin_lang[$i]}\" {$selected}>{$available_admin_lang[$i]}</option>";
}
?>
          </select>
          <input type="submit" name="submit" value="Ok"/>
          </form>
      </li>
    </ul>
  </div>
Пример #5
0
<?php

# lang
require_once "../src/pfci18n.class.php";
require_once "inc.conf.php";
pfcI18N::Init($lang, "admin");
# htaccess class
require_once 'htaccess.class.php';
$ht = new htaccess();
# Activate Authentification
if (!empty($_GET['active'])) {
    if ($_GET['active'] == 1 && $ht->getNumberOfUsers() > 0) {
        $ht->printHtaccess();
    } elseif ($_GET['active'] == 1 && $ht->getNumberOfUsers() == 0) {
        $msg = _pfc("At least one user must be declare to activate authentication.");
        header('Location: ' . $_SERVER['PHP_SELF'] . '?msg=' . rawurlencode($msg));
        exit;
    } elseif ($_GET['active'] == 2 && file_exists($ht->get_file_Htaccess())) {
        $ht->delHtaccess();
    }
}
# Delete a user
if (!empty($_GET['del']) && !empty($_GET['username'])) {
    if ($ht->getNumberOfUsers() == 1) {
        $msg = _pfc("It is not possible to delete the last user.");
        header('Location: ' . $_SERVER['PHP_SELF'] . '?msg=' . rawurlencode($msg));
        exit;
    } else {
        $username = $_GET['username'];
        $ht->delUser($username);
        $groups = $ht->getGroupOfUser($username);
Пример #6
0
<?php

require_once dirname(__FILE__) . "/../src/pfci18n.class.php";
pfcI18N::UpdateMessageRessources();
Пример #7
0
 /**
  * printChat must be called somewhere in the page
  * it inserts necessary html which will receive chat's data
  * usage:
  * <code>
  *   <?php $chat->printChat(); ?>
  * </code>
  */
 function printChat($return = false)
 {
     $c =& pfcGlobalConfig::Instance();
     $u =& pfcUserConfig::Instance();
     $output = '';
     if (count($c->getErrors()) > 0) {
         $output .= "<p>phpFreeChat cannot be initialized, please correct these errors:</p><ul>";
         foreach ($c->getErrors() as $e) {
             $output .= "<li>" . $e . "</li>";
         }
         $output .= "</ul>";
     } else {
         pfcI18N::SwitchOutputEncoding($c->output_encoding);
         $path = $c->getFilePathFromTheme('chat.js.tpl.php');
         $t = new pfcTemplate($path);
         $t->assignObject($u, "u");
         $t->assignObject($c, "c");
         $output .= $t->getOutput();
         pfcI18N::SwitchOutputEncoding();
     }
     if ($return) {
         return $output;
     } else {
         echo $output;
     }
 }