Exemple #1
0
function phorum_get_language($lang)
{
    $path = "./include/lang/{$lang}.php";
    $PHORUM = array();
    $DEPRECATED = array();
    $keep_comment = '';
    if (!file_exists($path)) {
        trigger_error("Cannot locate language module in {$path}", E_USER_ERROR);
    }
    // Read the language file. Keep track of comments that
    // we want to keep (those starting with '##').
    $file = '';
    $fp = fopen($path, "r");
    if (!$fp) {
        trigger_error("Cannot read language file {$path}", E_USER_ERROR);
    }
    while ($line = fgets($fp)) {
        $file .= $line;
        if (substr($line, 0, 2) == '##') {
            $keep_comment .= $line;
        }
    }
    fclose($fp);
    // Split the contents of the language file into PHP tokens.
    $tokens = token_get_all($file);
    // Parse the PHP tokens.
    while (count($tokens)) {
        // Extract all variables. The rest is ignored.
        $token = token_shift($tokens);
        if (is_array($token)) {
            if ($token[0] == T_VARIABLE) {
                list($varname, $endedby) = token_get_string($tokens, $token[1]);
                if ($endedby != '=') {
                    break;
                }
                // We want only the assignments.
                // Peek at the following code, to see what type of variable we're
                // handling. Scalar or array.
                token_skip_whitespace($tokens);
                if ($tokens[0][0] == T_ARRAY) {
                    global $in_deprecated;
                    $in_deprecated = false;
                    // Handle opening bracket for the array.
                    token_shift($tokens);
                    token_skip_whitespace($tokens);
                    $token = token_shift($tokens);
                    if ($token != '(') {
                        trigger_error("{$path}: Expected array opening bracket for array " . htmlspecialchars($varname), E_USER_ERROR);
                    }
                    while (count($tokens)) {
                        // Get key
                        list($key, $endedby) = token_get_string($tokens);
                        if ($endedby != '=>') {
                            trigger_error("{$path}: Expected double arrow (=>) for key " . htmlspecialchars($key) . " in array " . htmlspecialchars($varname) . ", but got {$endedby}", E_USER_ERROR);
                        }
                        // Get value
                        list($val, $endedby) = token_get_string($tokens);
                        if ($endedby != ',' && $endedby != ')') {
                            trigger_error("{$path}: Expected ending comma or bracket for key " . htmlspecialchars($key) . " in array " . htmlspecialchars($varname) . ", but got {$endedby}", E_USER_ERROR);
                        }
                        // Put the data in the environment.
                        $fullvar = $varname . '[' . $key . ']';
                        eval("{$fullvar} = '" . urlencode($val) . "';");
                        // Keep track of data flagged deprecated.
                        if ($in_deprecated) {
                            eval("\$DEPRECATED[{$key}] = true;");
                        }
                        // Last key/value pair?
                        if ($endedby == ')') {
                            break;
                        }
                        token_skip_whitespace($tokens);
                        if ($tokens[0] == ')') {
                            array_shift($tokens);
                            break;
                        }
                    }
                } else {
                    list($varvalue, $endedby) = token_get_string($tokens);
                    eval("{$varname} = '" . urlencode($varvalue) . "';");
                }
            }
        }
    }
    if ($keep_comment == '') {
        $keep_comment = <<<HELP
## For adding information to the start of this language file,
## you can use comments starting with "##". Those comments will
## be kept intact when a new language file is generated by the
## language file maintenance software.
HELP;
    }
    // These aren't inside $PHORUM, but we put them there so we have
    // access to them later on.
    $PHORUM['STORE']['language_hide'] = $language_hide;
    $PHORUM['STORE']['language'] = $language;
    $PHORUM['STORE']['keep_comment'] = $keep_comment;
    $PHORUM['STORE']['DEPRECATED'] = $DEPRECATED;
    if (TOKEN_DEBUGGER) {
        phorum_api_dev_dump($PHORUM);
    }
    return $PHORUM;
}
Exemple #2
0
                if ($count == 50) {
                    $total += $count;
                    echo " {$total} from \"{$forumdata['name']}\"";
                    if ($CONVERT['lbr'] == "\n") {
                        // lets just go back on this line if we are on the console
                        echo "\r";
                    } else {
                        echo $CONVERT['lbr'];
                    }
                    flush();
                    $count = 0;
                }
                $count++;
            } else {
                print "Error in message: " . $CONVERT['lbr'];
                phorum_api_dev_dump($newmessage);
                print $CONVERT['lbr'];
            }
        }
        echo "{$CONVERT['lbr']}Updating forum-statistics: {$CONVERT['lbr']}";
        flush();
        $PHORUM['DB']->update_forum_stats(true);
        echo $CONVERT['lbr'];
        flush();
    }
}
unset($forums);
// storing the offsets of the forums
$PHORUM['DB']->update_settings(array("conversion_offsets" => $offsets));
if ($CONVERT['do_groups'] && count($CONVERT['groups'])) {
    // here we set the group-permissions
Exemple #3
0
/**
 * @deprecated Replaced by {@link phorum_api_dev_dump()}.
 */
function print_var($var, $admin_only = TRUE)
{
    require_once PHORUM_PATH . '/include/api/dev.php';
    return phorum_api_dev_dump($var, $admin_only);
}