Example #1
0
 function add_js($script = '')
 {
     /*
      *  if the paramter an array then pass
      * each element to the array again .
      * */
     if (is_array($script)) {
         foreach ($script as $item) {
             add_js($item);
         }
     } else {
         /* get full URL if script path
          * is local script
          * */
         $script = trim($script);
         $CI =& get_instance();
         if (is_local($script)) {
             $script = base_url() . $script;
         }
         // push script to vunsy JS array .
         if (!in_array($script, $CI->vunsy->js)) {
             array_push($CI->vunsy->js, $script);
         }
     }
 }
 public function testIsLocal()
 {
     // arrange
     $env = 'api-local';
     // act
     $result = is_local($env);
     // assert
     $this->assertEquals(true, $result);
 }
Example #3
0
 /**
  * Exception handler.
  *
  * @return void
  */
 public static final function handler()
 {
     return function (\Throwable $e) {
         // if not local no error display (so set & store option)
         if (!is_local()) {
             set_global('display_errors', ini_set('display_errors', '0'));
         }
         // will be catched in shutdown handler
         throw $e;
     };
 }
Example #4
0
 /**
  * Force Wordpress to know when a user is logged in or anonymous and 
  * accommodate the correct SSL and proxying. 
  */
 function remove_cms_from_admin_url($url, $forced = false)
 {
     global $blog_id;
     if (!is_local() && !is_admin() && empty($_SERVER['REMOTE_USER']) && $blog_id != 1 && !preg_match('/\\b(wp-admin|wp-login|\\/login)\\b/i', $_SERVER['REQUEST_URI']) && !is_user_logged_in() || $forced) {
         $url = str_replace('.edu/cms/', '.edu/', $url);
         $url = str_replace('https:', 'http:', $url);
         // relative urls
         if (strpos($url, 'http') === false) {
             $url = str_replace('/cms/', '/', $url);
         }
     }
     return $url;
 }
Example #5
0
 function add_js($script = '')
 {
     if (is_array($script)) {
         foreach ($script as $item) {
             add_js($item);
         }
     } else {
         $CI =& get_instance();
         if (is_local($script)) {
             $script = base_url() . $script;
         }
         if (!in_array($script, $CI->vunsy->js)) {
             array_push($CI->vunsy->js, $script);
         }
     }
 }
Example #6
0
function ps_ax($server)
{
    if (empty($server) || is_local($server)) {
        $data = shell_exec("ps axo user:30,pid,args");
    } else {
        $data = shell_exec("ssh {$server} ps axo user:30,pid,args");
    }
    $results = array();
    foreach (explode("\n", trim($data)) as $line) {
        $result = array();
        $result['user'] = trim(substr($line, 0, 30));
        $result['pid'] = intval(substr($line, 30, 35));
        $result['cmd'] = trim(substr($line, 36));
        $results[] = $result;
    }
    return $results;
}
Example #7
0
 function _view($page_name)
 {
     // this is only used internally
     $page = $this->Page->get_by_name($page_name);
     if (!$page) {
         return $this->_form("Unknown page: {$page_name}");
     }
     $feed = $this->Feed->get($page->feed_id);
     $feed_url = $feed->feed_url;
     // allow dynamic feed URLs
     if ($feed->id == 0) {
         if ($feed_url = $this->input->post('ext_feed_url')) {
             set_cookie(array('name' => 'ext_feed_url', 'value' => $feed_url, 'expire' => $this->config->item('cookie_lifetime')));
         } elseif (!($feed_url = $this->input->cookie('ext_feed_url'))) {
             $feed_url = 'http://feedvolley.com/recent';
         }
     }
     $html = $this->Page->get_html($page->id);
     $rss = $this->Feed->load($feed_url);
     $this->load->library('Tparser');
     $this->load->library('ThemeParser');
     $this->load->helper('edit_bar');
     $output = $this->themeparser->render($rss, $html, $page->title);
     // insert edit/duplicate bar
     $output = preg_replace('/(<body.*?>)/msi', '$1 ' . edit_bar($page, $this->User->has_code($page->admin_code)), $output);
     $output = preg_replace('/(<\\/body.*?>)/msi', google_analytics() . '$1', $output);
     // if local request --- this is currently pointless until a better is_local() is created
     if (is_local() && stripos($output, '<body>') === false) {
         $output = edit_bar($page, $this->User->has_code($page->admin_code)) . $output;
     }
     //	echo $output;
     // using a view, to enable caching
     $data['content'] = $output;
     $this->load->view('pages/render_page', $data);
     if (!$this->User->has_code($page->admin_code)) {
         $this->output->cache(3);
     }
 }
Example #8
0
 /**
  * Constructor.
  */
 private final function __construct(array $options = [])
 {
     // merge options
     $this->options = array_merge($this->options, $options);
     // store name
     $this->name = $this->options['name'];
     // check length
     if (!in_array($this->options['length'], $this->options['length_available'])) {
         $this->options['length'] = $this->options['length_default'];
     }
     // session is active?
     if (!$this->isStarted || session_status() != PHP_SESSION_ACTIVE) {
         // use hex hash
         // ini_set('session.session.hash_function', 1);
         // ini_set('session.hash_bits_per_character', 4);
         // if save path provided @tmp?
         if (is_local() && isset($this->options['save_path'])) {
             if (!is_dir($this->options['save_path'])) {
                 mkdir($this->options['save_path'], 0777, true);
                 chmod($this->options['save_path'], 0777);
             }
             ini_set('session.save_path', $this->options['save_path']);
             // set perms
             foreach (glob($this->options['save_path'] . '/*') as $file) {
                 chmod($file, 0777);
             }
         }
         // set defaults
         session_set_cookie_params((int) $this->options['lifetime'], (string) $this->options['path'], (string) $this->options['domain'], (bool) $this->options['secure'], (bool) $this->options['httponly']);
         // set session name
         session_name($this->name);
         // reset session data and start session
         $this->reset();
         $this->start();
     }
 }
Example #9
0
 public static function getConfig()
 {
     return array('host' => (is_local() ? 'http' : 'https') . '://' . $_SERVER['HTTP_HOST'], 'path' => '/auth/', 'debug' => false, 'callback_url' => '/auth/callback/', 'security_salt' => self::SECURITY_SALT, 'security_timeout' => '5 minutes', 'Strategy' => array('Facebook' => array('app_id' => FACEBOOK_APP_ID, 'app_secret' => FACEBOOK_APP_SECRET, 'scope' => 'email,user_friends', 'redirect_uri' => '{host}{path}?param=facebook&action=int_callback'), 'VKontakte' => array('app_id' => VK_APP_ID, 'app_secret' => VK_APP_SECRET, 'scope' => 'friends,email', 'redirect_uri' => '{host}{path}?param=vkontakte&action=int_callback'), 'Odnoklassniki' => array('app_id' => ODNOKLASSNIKI_APP_ID, 'app_public' => ODNOKLASSNIKI_APP_PUBLIC, 'app_secret' => ODNOKLASSNIKI_APP_SECRET, 'redirect_uri' => '{host}{path}?param=odnoklassniki&action=int_callback')));
 }
Example #10
0
<?php

/**
 * Created by PhpStorm.
 * User: william mcmillian
 * Date: 7/12/15
 * Time: 8:49 AM
 */
include './header.php';
$newTopicUrl = 'http://boards.endoftheinter.net/postmsg.php?tag=' . $request->tag;
$newTopicPage = HTTP_Get($newTopicUrl, $_SESSION['eticookie']);
if (is_local()) {
    $newTopicPage = file_get_contents('../test_data/test_new_topic.html');
}
$doc = new DOMDocument();
@$doc->loadHTML($newTopicPage);
$signature = $doc->getElementsByTagName('textarea')->item(1)->nodeValue;
$hiddenValue = $doc->getElementsByTagName('input')->item(2)->getAttribute('value');
$messageBody = $request->message;
$fields = array('title' => urlencode($request->title), 'message' => urlencode($messageBody . "\n" . $signature), 'h' => urlencode($hiddenValue), 'tag' => urlencode($request->tag), 'submit' => urlencode('Post Message'));
$newTopicUrl = 'http://boards.endoftheinter.net/postmsg.php';
$newTopic = HTTP_Post($newTopicUrl, $fields);
preg_match('~Location:.*?topic=(\\d+)~su', $newTopic, $topicIdMatch);
$newTopicId = $topicIdMatch[1];
if (is_local()) {
    $newTopicId = '98765';
}
$result = array();
$result['topicId'] = $newTopicId;
echo json_encode($result);
Example #11
0
function fixAttachUrl($url)
{
    if (is_local()) {
        return str_replace('//', '/', getRootUrl() . $url);
        //防止双斜杠的出现
    } else {
        return $url;
    }
}
#
#
#
#
#
#
# Get settings
require "../settings.php";
require "../core-settings.php";
require "../libs/ext.lib.php";
if (isset($_POST["key"])) {
    switch ($_POST["key"]) {
        case "method":
            if (strlen($_POST["accnum"]) == 0) {
                # redirect if not local supplier
                if (!is_local("customers", "cusnum", $_POST["cusid"])) {
                    // print "SpaceBar";
                    header("Location: bank-recpt-inv-int.php?cusid={$_POST['cusid']}");
                    exit;
                }
            }
            $OUTPUT = method($_POST["cusid"]);
            break;
        case "alloc":
            $OUTPUT = alloc($_POST);
            break;
        case "confirm":
            $OUTPUT = confirm($_POST);
            break;
        case "write":
            $OUTPUT = write($_POST);
Example #13
0
function _fatal($code = 404, $errfile = '', $errline = '', $errmsg = '', $errno = 0)
{
	sql_close();
	
	switch ($code)
	{
		case 504:
			echo '<b>PHP Notice</b>: in file <b>' . $errfile . '</b> on line <b>' . $errline . '</b>: <b>' . $errmsg . '</b><br>';
			break;
		case 505:
			echo '<b>Another Error</b>: in file <b>' . basename($errfile) . '</b> on line <b>' . $errline . '</b>: <b>' . $errmsg . '</b><br>';
			break;
		case 506:
			die('USER_ERROR: ' . $errmsg);
			break;
		default:
			$error_path = './style/server-error/%s.htm';
			
			switch ($errno)
			{
				case 2: $filepath = sprintf($error_path, 'no' . $errno); break;
				default: $filepath = sprintf($error_path, $code); break;
			}
			if (!@file_exists($filepath))
			{
				$filepath = sprintf($error_path, 'default');
			}
			
			$v_host = get_protocol() . get_host();
			
			// MySQL error
			if ($code == 507)
			{
				global $core;
				
				if (is_array($errmsg) && isset($errmsg['sql'])) {
					$errmsg = $errmsg['sql'];
				}
				
				$e_mysql = explode('///', $errmsg);
				$i_errmsg = str_replace(array("\n", "\t"), array('<br>', '&nbsp;&nbsp;&nbsp;'), implode('<br><br>', $e_mysql));
				$v_time = @date('r', time());
				
				$mail_extra = "From: info@nopticon.com\n" . "Return-Path: info@nopticon.com\nMessage-ID: <" . md5(uniqid(time())) . "@nopticon.com>\nMIME-Version: 1.0\nContent-type: text/html; charset=ISO-8859-1\nContent-transfer-encoding: 8bit\nDate: " . $v_time . "\nX-Priority: 2\nX-MSMail-Priority: High\n";
				$mail_to = (!empty($_SERVER['SERVER_ADMIN'])) ? $_SERVER['SERVER_ADMIN'] : '*****@*****.**';
				$mail_result = @mail($mail_to, 'MySQL: Error', preg_replace("#(?<!\r)\n#s", "\n", _page() . '<br />' . $v_time . '<br /><br />' . $i_errmsg), $mail_extra, '*****@*****.**');
				
				$errmsg = (is_local()) ? '<br><br>' . $i_errmsg : '';
			}
			
			$repl = array(
				array('{ERROR_LINE}', '{ERROR_FILE}', '{ERROR_MSG}', '{HTTP_HOST}', '{REQUEST_URL}'),
				array($errline, $errfile, $errmsg, $v_host . str_replace(basename($_SERVER['PHP_SELF']), '', $_SERVER['PHP_SELF']), $_SERVER['REQUEST_URI'])
			);
			
			header("HTTP/1.1 404 Not Found");
			header("Status: 404 Not Found");
			
			echo str_replace($repl[0], $repl[1], implode('', @file($filepath)));
			exit();
			break;
	}
	
	return;
}
Example #14
0
function loader_not_installed()
{
    $loader = get_loaderinfo();
    $sysinfo = get_sysinfo();
    $stype = get_request_parameter('stype');
    $manual_select = get_request_parameter('manual');
    if (!isset($stype)) {
        echo '<p>To use files that have been protected by the <a href="' . ENCODER_URL . '" target=encoder>ionCube PHP Encoder</a>, a component called the ionCube Loader must be installed.</p>';
    }
    if (!is_array($loader)) {
        if ($loader == ERROR_WINDOWS_64_BIT) {
            echo '<p>Loaders for 64-bit PHP on Windows are not currently available. However, if you <b>install and run 32-bit PHP</b> the corresponding 32-bit Loader for Windows should work.</p>';
            if ($sysinfo['THREAD_SAFE']) {
                echo '<li>Download one of the following archives of 32-bit Windows x86 Loaders:';
                $basename = LOADERS_PACKAGE_PREFIX . 'win_x86';
            } else {
                $basename = LOADERS_PACKAGE_PREFIX . 'win_nonts_x86';
                echo '<li>Download one of the following archives of 32-bit Windows non-TS x86 Loaders:';
            }
            echo make_archive_list($basename);
        } else {
            echo '<p>There may not be a Loader available for your type of system at the moment, however if you create a <a href="' . SUPPORT_SITE . '">support ticket</a> more advice and information may be available to assist. Please include the URL for this Wizard in your ticket.</p>';
        }
    } else {
        if (!is_supported_php_version()) {
            echo '<p>Your server is running PHP version ' . PHP_VERSION . ' and is
                    unsupported by ionCube Loaders.  Recommended PHP 4 versions are PHP 4.2 or higher, 
                    and PHP 5.1 or higher for PHP 5.</p>';
        } elseif (!$sysinfo['SUPPORTED_COMPILER']) {
            $supported_compilers = supported_win_compilers();
            $supported_compiler_string = join('/', $supported_compilers);
            echo '<p>At the current time the ionCube Loader requires PHP to be built with ' . $supported_compiler_string . '. Your PHP software has been built using ' . $sysinfo['PHP_COMPILER'] . '. Supported builds of PHP are available from <a href="http://windows.php.net/download/">PHP.net</a>.';
        } else {
            if (!in_array($stype, array('s', 'd', 'l'))) {
                if (!$manual_select && is_local()) {
                    local_install();
                } elseif (!$manual_select && !is_possibly_dedicated_or_local()) {
                    shared_server();
                } else {
                    echo server_selection_form();
                }
            } else {
                switch ($stype) {
                    case 's':
                        shared_server();
                        break;
                    case 'd':
                        dedicated_server();
                        break;
                    case 'l':
                        local_install();
                        break;
                }
            }
        }
    }
}
Example #15
0
/**
 * Compress.
 * @param  string $input
 * @return string
 */
function html_compress(string $input = null) : string
{
    if ($input === null) {
        return '';
    }
    // scripts
    $input = preg_replace_callback('~(<script>(.*?)</script>)~sm', function ($match) {
        $input = trim($match[2]);
        // line comments (protect http:// etc)
        if (is_local()) {
            $input = preg_replace('~(^|[^:])//([^\\r\\n]+)$~sm', '', $input);
        } else {
            $input = preg_replace('~(^|[^:])//.*?[\\r\\n]$~sm', '', $input);
        }
        // doc comments
        preg_match_all('~\\s*/[\\*]+(?:.*?)[\\*]/\\s*~sm', $input, $matchAll);
        foreach ($matchAll as $key => $value) {
            $input = str_replace($value, "\n\n", $input);
        }
        return sprintf('<script>%s</script>', trim($input));
    }, $input);
    // remove comments
    $input = preg_replace('~<!--[^-]\\s*(.*?)\\s*[^-]-->~sm', '', $input);
    // remove tabs
    $input = preg_replace('~^[\\t ]+~sm', '', $input);
    // remove tag spaces
    $input = preg_replace('~>\\s+<(/?)([\\w\\d-]+)~sm', '><\\1\\2', $input);
    // textarea \n problem
    $textareaTpl = '%{{{TEXTAREA}}}';
    $textareaCount = preg_match_all('~(<textarea(.*?)>(.*?)</textarea>)~sm', $input, $matchAll);
    // fix textareas
    if ($textareaCount) {
        foreach ($matchAll[0] as $match) {
            $input = str_replace($match, $textareaTpl, $input);
        }
    }
    // reduce white spaces
    $input = preg_replace('~\\s+~', ' ', $input);
    // fix textareas
    if ($textareaCount) {
        foreach ($matchAll[0] as $match) {
            $input = preg_replace("~{$textareaTpl}~", $match, $input, 1);
        }
    }
    return trim($input);
}
Example #16
0
 public function __construct()
 {
     $this->isTest = !is_release() || is_local();
 }
Example #17
0
 protected function sendFile()
 {
     header('X-Accel-Redirect: /bzqvzvyw/' . $this->filename);
     header('Content-Type:');
     if (is_local()) {
         //header('Content-Type: application/octet-stream');
         header('Content-Disposition: attachment; filename=' . basename($this->filename));
     }
     exit;
 }
Example #18
0
<?php

defined('IN_CMS') or die('No direct access allowed.');
is_local();
$otitle = title();
$title = trim($otitle) == "" ? "" : $otitle . " - ";
$title .= site_name();
?>
<!DOCTYPE HTML>
<html lang="en-US">
<head>
	<meta charset="UTF-8">
	<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
	<?php 
if (is_post()) {
    ?>
		<link rel="author" href="https://plus.google.com/107924709939978010057/posts">
	<?php 
}
?>
	<link rel="publisher" href="https://plus.google.com/107924709939978010057">
	<?php 
if (is_post()) {
    ?>
<meta name="buffer-text" content="<?php 
    echo $otitle;
    ?>
"><?php 
}
?>
	<title><?php 
#
#
#
#
#
#
# get settings
require "../settings.php";
require "../core-settings.php";
require "../libs/ext.lib.php";
require "bank-pay-supp-write.php";
if (isset($_POST["key"])) {
    switch ($_POST["key"]) {
        case "method":
            # redirect if not local supplier
            if (!is_local("suppliers", "supid", $_POST["supid"])) {
                // print "SpaceBar";
                header("Location: bank-pay-supp-int.php?supid={$_POST['supid']}");
                exit;
            }
            $OUTPUT = method($_POST["supid"]);
            break;
        case "alloc":
            $OUTPUT = alloc($_POST);
            break;
        case "confirm":
            if (isset($_POST["confirm"])) {
                $OUTPUT = confirm($_POST);
            } else {
                $OUTPUT = alloc($_POST);
            }
Example #20
0
<?php

error_reporting(E_ALL);
ini_set('display_errors', 'On');
//This script inserts the generated markup and JS into the DB on W? server and assigns it a token so that it can retrieved
function is_local()
{
    if ($_SERVER['HTTP_HOST'] == 'localhost' || substr($_SERVER['HTTP_HOST'], 0, 3) == '10.' || $_SERVER['HTTP_HOST'] == 'which-widgets-build.app.local' || substr($_SERVER['HTTP_HOST'], 0, 7) == '192.168') {
        return true;
    }
    return false;
}
$localEnv = is_local();
if ($localEnv) {
    //local
    define('DB_MAIN', '127.0.0.1|root|abc123|widgets');
} else {
    //live
    define('DB_MAIN', 'db.test.which-testing.co.uk|widget|SRTe89VG973R|widget');
}
// Connect to database db1
$db = new my_db(DB_MAIN);
//retrieve token
$token = $_GET['tkn'];
$rows = $db->fetchAll('SELECT * FROM embed WHERE token="' . $token . '"');
//get signup count from the tools
$count = file_get_contents("https://whichcouk.cp.bsd.net/utils/cons_counter/signup_counter.ajax.php?signup_form_id=" . $rows[0]->form_ID);
$count = $count + 10000;
$count = number_format($count);
//add signup count to the db rows returned
array_push($rows, array('signup' => $count));
Example #21
0
 /**
  * Log given message by level.
  *
  * @param  int   $level   Only available ALL, FAIL, WARN, INFO, DEBUG
  * @param  mixed $message
  * @return bool
  */
 public final function log(int $level, $message) : bool
 {
     // no log command
     if (!$level || ($level & $this->level) == 0) {
         return;
     }
     // ensure log directory
     $this->checkDirectory();
     // prepare message prepend
     $messageType = '';
     switch ($level) {
         case self::FAIL:
             $messageType = 'FAIL';
             break;
         case self::INFO:
             $messageType = 'INFO';
             break;
         case self::WARN:
             $messageType = 'WARN';
             break;
         case self::DEBUG:
             $messageType = 'DEBUG';
             break;
     }
     // prepare message date
     $messageDate = date('D, d M Y H:i:s O');
     // prepare filename
     $filename = sprintf('%s/%s.log', $this->directory, date($this->filenameFormat));
     // @tmp just for local
     if (is_local()) {
         chmod($filename, 0666);
     }
     // handle exception, object, array messages
     if ($message instanceof \Throwable) {
         $message = get_class($message) . " thrown in '" . $message->getFile() . ":" . $message->getLine() . "' with message '" . $message->getMessage() . "'.\n" . $message->getTraceAsString() . "\n";
     } elseif (is_array($message) || is_object($message)) {
         $message = json_encode($message);
     }
     // prepare message
     $message = sprintf("[%s] [%s] %s\n\n", $messageType, $messageDate, trim($message));
     return (bool) file_put_contents($filename, $message, LOCK_EX | FILE_APPEND);
 }
Example #22
0
 /**
  * Bug fix for the plugins that need site url. The plugin uses the default permalink
  *  of the post which contains /cms/. This function and filter removes /cms/ from
  *  the permalink.
  */
 function uw_remove_cms_from_plugin_permalinks($url)
 {
     return is_local() ? $url : str_replace('/cms/', '/', $url);
 }
function find_server_type($chosen_type = '', $type_must_be_chosen = false, $set_session = false)
{
    $server_type = SERVER_UNKNOWN;
    if (empty($chosen_type)) {
        if ($type_must_be_chosen) {
            $server_type = SERVER_UNKNOWN;
        } else {
            if (isset($_SESSION['server_type']) && $_SESSION['server_type'] != SERVER_UNKNOWN) {
                $server_type = $_SESSION['server_type'];
            } elseif (is_local()) {
                $server_type = SERVER_LOCAL;
            } elseif (!is_possibly_dedicated_or_local()) {
                $server_type = SERVER_SHARED;
            } else {
                $server_type = SERVER_UNKNOWN;
            }
        }
    } else {
        switch ($chosen_type) {
            case 's':
                $server_type = SERVER_SHARED;
                break;
            case 'd':
                $server_type = SERVER_DEDICATED;
                break;
            case 'l':
                $server_type = SERVER_LOCAL;
                break;
            default:
                $server_type = SERVER_UNKNOWN;
                break;
        }
    }
    if ($set_session) {
        $_SESSION['server_type'] = $server_type;
    }
    return $server_type;
}
Example #24
0
function getCredentials($user, $pass)
{
    //set POST variables
    $url = 'https://endoftheinter.net/';
    $fields = array('b' => urlencode($user), 'p' => urlencode($pass), 'r' => '');
    //url-ify the data for the POST
    $fields_string = '';
    foreach ($fields as $key => $value) {
        $fields_string .= $key . '=' . $value . '&';
    }
    $fields_string = rtrim($fields_string, '&');
    //echo $fields_string . '<br>';
    //open connection
    $ch = curl_init();
    //set the url, number of POST vars, POST data
    curl_setopt($ch, CURLOPT_URL, $url);
    curl_setopt($ch, CURLOPT_POST, count($fields));
    curl_setopt($ch, CURLOPT_POSTFIELDS, $fields_string);
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
    curl_setopt($ch, CURLOPT_HEADER, 1);
    curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
    curl_setopt($ch, CURLOPT_AUTOREFERER, false);
    //execute post
    $result = curl_exec($ch);
    //get cookies
    preg_match_all('/^Set-Cookie:\\s*([^\\r\\n]*)/mi', $result, $ms);
    $cookies = implode($ms[1], ';');
    $valid = strpos($cookies, 'userid') !== false;
    //echo $cookies;
    if ($valid) {
        $_SESSION['eticookie'] = $cookies;
    }
    if (is_local()) {
        $_SESSION['eticookie'] = 'asdf';
        $valid = true;
    }
    //close connection
    curl_close($ch);
    return $valid;
}
Example #25
0
function detect_node_type()
{
    global $conf_nodes;
    global $is_control_node, $is_compute_node, $is_storage_node, $is_svn_node, $storage_node_addr, $svn_node_addr;
    $is_control_node = $is_compute_node = $is_storage_node = $is_svn_node = false;
    $storage_node_addr = $svn_node_addr = "";
    foreach ($conf_nodes as $node) {
        if (is_local($node['address'])) {
            if (in_array("control", $node['type'])) {
                $is_control_node = true;
            }
            if (in_array("compute", $node['type'])) {
                $is_compute_node = true;
            }
            if (in_array("storage", $node['type'])) {
                $is_storage_node = true;
            }
            if (in_array("svn", $node['type'])) {
                $is_svn_node = true;
            }
        } else {
            if (in_array("storage", $node['type'])) {
                $storage_node_addr = $node['address'];
            }
            if (in_array("svn", $node['type'])) {
                $svn_node_addr = $node['address'];
            }
        }
    }
}
Example #26
0
function is_production()
{
    return !is_local() && !is_staging();
}
Example #27
0
require_once 'Mail/mimeDecode.php';
session_start();
require 'login.function.php';
ini_set("memory_limit", MEMORY_LIMIT);
if (!isset($_GET['id'])) {
    die('No input Message ID');
} else {
    $message_id = sanitizeInput($_GET['id']);
    // See if message is local
    dbconn();
    // required db link for mysql_real_escape_string
    $message_data = mysql_fetch_object(dbquery("SELECT hostname, DATE_FORMAT(date,'%Y%m%d') AS date FROM maillog WHERE id='" . mysql_real_escape_string($message_id) . "' AND " . $_SESSION["global_filter"]));
    if (!$message_data) {
        die("Message '" . $message_id . "' not found\n");
    }
    if (!is_local($message_data->hostname) || RPC_ONLY) {
        // Host is remote - use XML-RPC
        //$client = new xmlrpc_client(constant('RPC_RELATIVE_PATH').'/rpcserver.php', $host, 80);
        $input = new xmlrpcval($message_id);
        $parameters = array($input);
        $msg = new xmlrpcmsg('return_quarantined_file', $parameters);
        //$rsp = $client->send($msg);
        $rsp = xmlrpc_wrapper($message_data->hostname, $msg);
        if ($rsp->faultcode() == 0) {
            $response = php_xmlrpc_decode($rsp->value());
        } else {
            die("Error: " . $rsp->faultstring());
        }
        $file = base64_decode($response);
    } else {
        //build filename path
Example #28
0
/**
 * @param $list
 * @param $num
 * @param bool|false $rpc_only
 * @return string
 */
function quarantine_delete($list, $num, $rpc_only = false)
{
    if (!is_array($list) || !isset($list[0]['msgid'])) {
        return "Invalid argument";
    } else {
        $new = quarantine_list_items($list[0]['msgid']);
        $list =& $new;
    }
    if (!$rpc_only && is_local($list[0]['host'])) {
        foreach ($num as $key => $val) {
            if (@unlink($list[$val]['path'])) {
                $status[] = "Delete: deleted file " . $list[$val]['path'];
                dbquery("UPDATE maillog SET quarantined=NULL WHERE id='" . $list[$val]['msgid'] . "'");
                audit_log('Deleted file from quarantine: ' . $list[$val]['path']);
            } else {
                $status[] = "Delete: error deleting file " . $list[$val]['path'];
                global $error;
                $error = true;
            }
        }
        return join("\n", $status);
    } else {
        // Call by RPC
        debug("Calling quarantine_delete on " . $list[0]['host'] . " by XML-RPC");
        //$client = new xmlrpc_client(constant('RPC_RELATIVE_PATH').'/rpcserver.php',$list[0]['host'],80);
        // Convert input parameters
        foreach ($list as $list_array) {
            foreach ($list_array as $key => $val) {
                $list_struct[$key] = new xmlrpcval($val);
            }
            $list_output[] = new xmlrpcval($list_struct, 'struct');
        }
        foreach ($num as $key => $val) {
            $num_output[$key] = new xmlrpcval($val);
        }
        // Build input parameters
        $param1 = new xmlrpcval($list_output, 'array');
        $param2 = new xmlrpcval($num_output, 'array');
        $parameters = array($param1, $param2);
        $msg = new xmlrpcmsg('quarantine_delete', $parameters);
        $rsp = xmlrpc_wrapper($list[0]['host'], $msg);
        //$client->send($msg);
        if ($rsp->faultcode() == 0) {
            $response = php_xmlrpc_decode($rsp->value());
        } else {
            $response = "XML-RPC Error: " . $rsp->faultstring();
        }
        return $response . " (RPC)";
    }
}
Example #29
0
parse_additional_header($additional_header, $stc2, 'css');
//Парсим и добавляем js + выводим другие заголовки
echo parse_additional_header($additional_header, $stc2_js, 'js');
?>
        <?php 
$stc->addBem();
?>
        <?php 
//Адаптивность которую видимо можно выключать
if (@$_COOKIE['full_site_version'] != 1 && !isset($show_full_site_version) && @$_SESSION['pda'] == 1) {
    $stc->Add("/css/portable.css");
    $stc_js->Add("/scripts/portable.js");
}
//@todo: для Локала и Беты принудительно включаем
//адаптивность для всех чтобы было проще проверять верстку
if (is_local() || is_beta()) {
    $stc->Add("/css/portable.css");
    $stc_js->Add("/scripts/portable.js");
}
?>
        <?php 
$stc->Send();
?>
        <?php 
$stc2->Send();
?>
        
        <?php 
if (!defined('JS_BOTTOM')) {
    // Отображаем JS в хедере страниц @TODO: Убрать на всех страницах JS в нижнюю часть
    ?>
Example #30
0
 /**
  * Заполняет поля класса данными в зависимости от настроек
  */
 protected function init()
 {
     if ($this->is_test) {
         $this->url = is_local() ? self::URL_LOCAL : self::URL_TEST;
         $this->shops = $this->shops_test;
     } else {
         $this->url = self::URL_MAIN;
         $this->shops = $this->shops_main;
     }
     //Магазин и витрина поумолчанию
     $this->shopid = self::SHOPID_DEPOSIT;
     $this->scid = $this->shops[self::SHOPID_DEPOSIT];
 }