Beispiel #1
0
 function InitInstance($id = -1, $virtual = false)
 {
     $this->id = $id;
     $this->_virtual = $virtual;
     $q = db_select('service', array('*'), "`id` = {$id}");
     if (db_affected() <= 0) {
         $this->id = 0;
     } else {
         $r = db_row($q);
         $this->UnserializeSettings($r['settings']);
     }
     if (!$virtual) {
         content_url_var_push_global('action');
         content_url_var_push_global('id');
         editor_add_function('Управление сервисом', 'Editor_RSSManage');
         editor_add_function('Разделы', 'Editor_ContentManage');
     }
     if ($this->id > 0) {
         // Id>0 so the service has been created
         $url = content_url_get_full();
         if (preg_match('/^' . prepare_pattern(config_get('document-root')) . '[(\\/)|(\\/index.php)]?(\\?(.*))?$/si', $url)) {
             global $CORE;
             $CORE->PAGE->SetRSS($this->settings['title'], config_get('http-document-root') . '/rss.php');
         }
     }
 }
Beispiel #2
0
 function setvars($s)
 {
     global $VARS;
     if (!$VARS) {
         $VARS = array('document-root' => config_get('document-root'));
     }
     foreach ($VARS as $k => $v) {
         $s = preg_replace('/\\${' . prepare_pattern($k) . '}/', $v, $s);
     }
     return $s;
 }
Beispiel #3
0
 function WT_validate_ipc_link($link)
 {
     $a = urldecode($link);
     $root = config_get('document-root');
     if (preg_match('/^' . prepare_pattern($root) . '\\/tester\\/\\?ipc/', $a)) {
         $cmd = __wt_ipc_get_arg($a, 'ipc');
         if ($cmd == 'get_problem_desc') {
             $r = __wt_ipc_get_arg($a, 'backlink');
             return urlencode($root . '/tester/?page=problems&act=view&id=' . __wt_ipc_get_arg($a, 'id') . ($r != '' ? '&redirect=' . $r : ''));
         }
         return '';
     }
     return $link;
 }
Beispiel #4
0
 function iframe_accept_images($val)
 {
     $root_patt = prepare_pattern(config_get('http-document-root'));
     $val = preg_replace("'(<img[\\/\\!]*?[^<>]*?)(ilo-full-src\\s*=\\s*\"?[\\w\\:\\+\\-\\/\\%\\\$\\#\\.\\,]*\"?)([^<>]*?>)'si", '\\1\\3', $val);
     $val = preg_replace("'(<img[\\/\\!]*?[^<>]*?)(src\\s*=\\s*\"?{$root_patt}([\\w\\+\\-\\:\\/\\%\\\$\\#\\.\\,]*)\"?)([^<>]*?>)'si", '\\1src="\\3"\\4', $val);
     $images = iframe_get_images($val);
     $files = iframe_get_files($val);
     $f = combine_arrays($images, $files);
     for ($i = 0, $n = count($f); $i < $n; $i++) {
         $storage = manage_storage_by_dir(dirname($f[$i]));
         if ($storage) {
             $storage->AcceptFile(filename($f[$i]));
         }
     }
     $val = preg_replace("'(<img[\\/\\!]*?[^<>]*?)(src\\s*=\\s*\"?\\/([\\w\\+\\-\\:\\/\\%\$\\#\\.\\,]*)\"?)([^<>]*?>)'si", '\\1src="${document-root}/\\3"\\4', $val);
     return $val;
 }
Beispiel #5
0
 function content_recursive_move($src, $dst)
 {
     $dir = opendir($src);
     $oldUp = content_get_up_to_root($src) . 'globals.php';
     $newUp = content_get_up_to_root($dst) . 'globals.php';
     if (!file_exists($dst)) {
         mkdir($dst);
         chmod($dst, 0775);
     }
     while (($file = readdir($dir)) != false) {
         if ($file != '..' && $file != '.') {
             if (is_dir($src . "/{$file}")) {
                 content_recursive_move($src . "/{$file}", $dst . "/{$file}");
             } else {
                 $data = get_file($src . "/{$file}");
                 if ($file == 'index.php') {
                     $data = preg_replace('/\'' . prepare_pattern($oldUp) . '\'/', "'{$newUp}'", $data);
                 }
                 create_file($dst . "/{$file}", $data);
             }
         }
     }
 }
Beispiel #6
0
 function SetVars($content)
 {
     $content = preg_replace('/\\${information}/', stencil_info($this->information), $content);
     $content = setvars($content);
     foreach ($this->vars as $k => $v) {
         $content = preg_replace('/\\${' . prepare_pattern($k) . '}/', $v, $content);
     }
     $content = deecranvars($content);
     return $content;
 }
Beispiel #7
0
 function nav_inside($url)
 {
     $url = preg_replace('/\\/+$/', '', $url);
     if ($url == '') {
         $url = '/';
     }
     $url = preg_replace('/\\/+/', '/', $url);
     $dir = get_cur_dir();
     if (!preg_match('/^' . prepare_pattern($url) . '/', $dir)) {
         return -1;
     }
     if ($url != '/') {
         $difference = preg_replace('/^' . prepare_pattern($url) . '/', '', $dir);
     } else {
         $difference = $url;
     }
     $difference = preg_replace('/\\/+$/', '', $difference);
     if ($difference == '') {
         return 0;
         // full entry
     }
     if ($difference[0] != '/') {
         return -1;
     }
     $entries = 0;
     for ($i = 0; $i < strlen($difference); $i++) {
         if ($difference[$i] == '/') {
             $entries++;
         }
     }
     return $entries;
 }
Beispiel #8
0
 *
 * Copyright (c) 2008-2009 Sergey I. Sharybin <*****@*****.**>
 *
 * This program can be distributed under the terms of the GNU GPL.
 * See the file COPYING.
 */
if ($PHP_SELF != '') {
    print 'HACKERS?';
    die;
}
global $login, $passwd, $redirect;
$authorized = false;
if (trim($login) != '') {
    if (user_authorize(stripslashes($login), stripslashes($passwd))) {
        $authorized = true;
        if ($redirect == '' || !preg_match('/' . prepare_pattern(config_get('document-root')) . '\\/tester/', $redirect)) {
            redirect('..');
        } else {
            redirect();
        }
    }
}
if (!$authorized) {
    add_body_handler('onload', 'getElementById ("login").focus');
    ?>
<div id="navigator">Вход в систему</div>
<form action=".?redirect=<?php 
    echo urlencode($redirect);
    ?>
" method="POST">
  <div class="form" style="width: 460px; margin-left: 40px;">
Beispiel #9
0
 */
global $IFACE;
if ($IFACE != "SPAWNING NEW IFACE" || $_GET['IFACE'] != '') {
    print 'HACKERS?';
    die;
}
if ($_configSet_included_ != '#configSet_Included#') {
    $_configSet_included_ = '#configSet_Included#';
    config_set('proto', $_SERVER['HTTPS'] != '' ? 'https' : 'http');
    // Major version of php
    config_set('php-version', preg_replace('/^([0-9]).*/', '\\1', phpversion()));
    config_set('check-database', true);
    config_set('character-set', 'utf-8');
    config_set('internal-charset', 'utf-8');
    config_set('site-root', preg_replace('/\\/$/', '', $_SERVER['DOCUMENT_ROOT']));
    $tmp = preg_replace('/^' . prepare_pattern(config_get('site-root')) . '/', '', $DOCUMENT_ROOT);
    config_set('document-root', $tmp);
    config_set('data-file', 'data.php');
    config_set('wiki-index', 'data.php');
    config_set('http-host', $_SERVER['HTTP_HOST']);
    config_set('http-document-root', config_get('proto') . '://' . $_SERVER['HTTP_HOST'] . $tmp);
    config_set('db-host', 'localhost');
    config_set('db-user', 'root');
    config_set('db-password', '');
    config_set('db-codepage', 'utf8');
    config_set('db-name', 'gate');
    config_set('storage-root', '/storage');
    config_set('storage-digits', 4);
    config_set('storage-lifetime', 30 * 60);
    config_set('storage-enc', $DOCUMENT_ROOT . '/storage/enc');
    config_set('http-storage-enc', config_get('http-document-root') . '/storage/enc');
Beispiel #10
0
 function manage_storage_by_dir($dir)
 {
     $root_patt = prepare_pattern(config_get('storage-root'));
     if (!preg_match('/' . $root_patt . '/', $dir)) {
         return null;
     }
     $dir = preg_replace('/' . $root_patt . '/', '', $dir);
     $id = db_field_value('storage', 'id', '`path`="' . addslashes($dir) . '"');
     if ($id > 0) {
         $storage = new CStorage();
         $storage->Init($id);
         return $storage;
     }
     return null;
 }