function comet()
{
    global $body;
    global $navigation;
    global $ts;
    $dy = "";
    $dn = "";
    $dy2 = "";
    $dn2 = "";
    if (defined('USE_COMET') && USE_COMET == 1) {
        $dy = "checked";
    } else {
        $dn = "checked";
    }
    if (defined('SAVE_LOGS') && SAVE_LOGS == 1) {
        $dy2 = "checked";
    } else {
        $dn2 = "checked";
    }
    $historylimit = COMET_HISTORY_LIMIT;
    $keya = KEY_A;
    $keyb = KEY_B;
    $keyc = KEY_C;
    $overlay = '';
    if (!checkCurl()) {
        $overlay = <<<EOD
\t\t\t<script>
\t\t\tjQuery('#rightcontent').before('<div id="overlaymain" style="position:relative"></div>');
\t\t\t\t\tvar overlay = \$('<div></div>')
\t\t\t\t\t\t.attr('id','overlay')
\t\t\t\t\t\t.css({
\t\t\t\t\t\t\t'position':'absolute',
\t\t\t\t\t\t\t'height':\$('#rightcontent').innerHeight(),
\t\t\t\t\t\t\t'width':\$('#rightcontent').innerWidth(),
\t\t\t\t\t\t\t'background-color':'#FFFFFF',
\t\t\t\t\t\t\t'opacity':'0.9',
\t\t\t\t\t\t\t'z-index':'99',
\t\t\t\t\t\t\t'right': '0',
\t\t\t\t\t\t\t'margin-left':'1px'
\t\t\t\t\t\t})
\t\t\t\t\t\t.appendTo('#overlaymain');
\t\t\t\t\t\t\$('<span>cURL extension is disabled on your server. Please contact your webhost to enable it.<br> cURL is required for CometService.</span>')
\t\t\t\t\t\t\t.css({'z-index':' 9999',
\t\t\t\t\t\t\t'color':'#000000',
\t\t\t\t\t\t\t'font-size':'15px',
\t\t\t\t\t\t\t'font-weight':'bold',
\t\t\t\t\t\t\t'display':'block',
\t\t\t\t\t\t\t'text-align':'center',
\t\t\t\t\t\t\t'margin':'auto',
\t\t\t\t\t\t\t'position':'absolute',
\t\t\t\t\t\t\t'width':'100%',
\t\t\t\t\t\t\t'top':'100px',
\t\t\t\t\t\t\t'right':' -87px'
\t\t\t\t\t\t}).appendTo('#overlaymain');
\t\t</script>
EOD;
    }
    $body = <<<EOD
\t{$navigation}
\t<form action="?module=settings&action=updatecomet&ts={$ts}" method="post">
\t<div id="rightcontent" style="float:left;width:720px;border-left:1px dotted #ccc;padding-left:20px;">
\t\t<h2>Comet Service</h2>
\t\t<h3>If you are using our hosted Comet service, please enter the details here</h3>

\t\t<div>
\t\t\t<div id="centernav">
\t\t\t\t<div class="title" style="width:200px">Use Comet Service?</div><div class="element"><input type="radio" name="dou" value="1" {$dy}>Yes <input type="radio" {$dn} name="dou" value="0" >No</div>
\t\t\t\t<div style="clear:both;padding:5px;"></div>
\t\t\t\t<div class="title" style="width:200px">Save Logs?</div><div class="element"><input type="radio" name="dou2" value="1" {$dy2}>Yes <input type="radio" {$dn2} name="dou2" value="0" >No</div>
\t\t\t\t<div style="clear:both;padding:5px;"></div>
\t\t\t\t<div class="title">History limit:</div><div class="element"><input type="text" class="inputbox" name="historylimit" value="{$historylimit}" required="true"/></div>
\t\t\t\t<div style="clear:both;padding:5px;"></div>
\t\t\t\t<div class="title">Key A:</div><div class="element"><input type="text" class="inputbox" name="keya" value="{$keya}" required="true"/></div>
\t\t\t\t<div style="clear:both;padding:5px;"></div>
\t\t\t\t<div class="title">Key B:</div><div class="element"><input type="text" class="inputbox" name="keyb" value="{$keyb}" required="true"/></div>
\t\t\t\t<div style="clear:both;padding:5px;"></div>
\t\t\t\t<div class="title">Key C:</div><div class="element"><input type="text" class="inputbox" name="keyc" value="{$keyc}" required="true"/></div>
\t\t\t\t<div style="clear:both;padding:5px;"></div>
\t\t\t\t
\t\t\t</div>
\t\t\t<div id="rightnav">
\t\t\t\t<h1>Warning</h1>
\t\t\t\t<ul id="modules_availablemodules">
\t\t\t\t\t<li>Make sure that you have subscribed to our service before enabling this service.</li>
\t\t\t\t\t<li>Remember to de-activate the chat history plugin.</li>
\t\t\t\t\t<li>If you face load issues after activating the service, simply switch off Save Logs feature.</li>
\t\t\t\t\t<li>After activation/de-activation be sure to clear your browser cache.</li>
 \t\t\t\t</ul>
\t\t\t</div>
\t\t</div>

\t\t<div style="clear:both;padding:7.5px;"></div>
\t\t<input type="submit" value="Update settings" class="button">&nbsp;&nbsp;or <a href="?module=settings&ts={$ts}">cancel</a>
\t</div>

\t<div style="clear:both"></div>
\t{$overlay}
EOD;
    template();
}
Example #2
0
function remoteUpload(array $d)
{
    global $config;
    if ($config["remoteupload"] != 1) {
        echo json_encode(array("status" => "ERROR", "message" => "No permission to remote upload files"));
    } elseif (!isset($d['method']) || !in_array($d['method'], array("curl", "file"))) {
        echo json_encode(array("status" => "error", "message" => "No valid method given"));
    } elseif ($d['method'] == "curl" && checkCurl() == false) {
        echo json_encode(array("status" => "ERROR", "message" => "cURL extention not installed. Please install the cURL extention to use remote file upload."));
    } elseif ($d['method'] == "curl" && checkCurl() == true) {
        $filename = isset($d['filename']) && $d['filename'] != "" ? $d['filename'] : "curl_" . uniqid();
        chDirIfNecessary($d['dir']);
        $ch = curl_init();
        if ($ch) {
            if (allowedFileName($filename) == false) {
                echo json_encode(array("status" => "ERROR", "message" => "This filename is not allowed due to the config."));
            } elseif (filter_var($d['url'], FILTER_VALIDATE_URL) === false) {
                echo json_encode(array("status" => "ERROR", "message" => "The passed URL is not valid"));
            } else {
                $fp = fopen($filename, "w");
                if ($fp) {
                    if (!curl_setopt($ch, CURLOPT_URL, $d['url']) || !curl_setopt($ch, CURLOPT_FILE, $fp) || !curl_setopt($ch, CURLOPT_HEADER, 0) || !curl_exec($ch)) {
                        echo json_encode(array("status" => "ERROR", "message" => "Failed to set options and execute cURL"));
                    } else {
                        echo json_encode(array("status" => "OK", "message" => "File sucessfully uploaded"));
                    }
                    curl_close($ch);
                    fclose($fp);
                } else {
                    echo json_encode(array("status" => "ERROR", "message" => "Failed to open file"));
                }
            }
        } else {
            echo json_encode(array("status" => "ERROR", "message" => "Failed to init cURL."));
        }
    } elseif ($d['method'] == 'file') {
        $filename = isset($d['filename']) && $d['filename'] != "" ? $d['filename'] : "curl_" . uniqid();
        chDirIfNecessary($d['dir']);
        try {
            file_put_contents($filename, file_get_contents($d['url']));
            echo json_encode(array("status" => "OK", "message" => "File successfully uploaded"));
        } catch (Exception $e) {
            echo json_encode(array("status" => "ERROR", "message" => $e->getMessage()));
        }
    } else {
        echo json_encode(array("status" => "error", "message" => "Corrupt parameter data"));
    }
}
Example #3
0
/**
 * Check solr connection.
 * WARNING: must not be called to often as it performs a SQL query (one call per minute would be fine).
 *
 * @return FALSE in case of failure and TRUE otherwise.
 */
function check_solr()
{
    global $databases;
    global $default_settings_solr;
    if (isset($default_settings_solr['environment']['solr'])) {
        $solr_url = $default_settings_solr['environment']['solr'];
    } else {
        if (isset($databases['default']['slave'])) {
            // retrieve Solr's information from MySQL slave
            $slave = $databases['default']['slave'][0];
            $db_connection = mysql_connect($slave['host'] . ':' . $slave['port'], $slave['username'], $slave['password']);
            if (!$db_connection) {
                return FALSE;
            }
            if (!mysql_select_db($slave['database'], $db_connection)) {
                mysql_close($db_connection);
                return FALSE;
            }
            $sql_request = 'SELECT url FROM apachesolr_environment LIMIT 1';
            $sql_request_result = mysql_query($sql_request, $db_connection);
            if (!sql_request_result) {
                mysql_close($db_connection);
                return FALSE;
            }
            $sql_request_result_data = mysql_fetch_assoc($sql_request_result);
            if (!sql_request_result_data) {
                mysql_close($db_connection);
                return FALSE;
            }
            $solr_url = $sql_request_result_data['url'];
            mysql_close($db_connection);
        }
    }
    if (isset($solr_url)) {
        if (!checkCurl($solr_url, 20)) {
            return FALSE;
        }
    } else {
        echo "No solr found<br/>";
    }
    return TRUE;
}
Example #4
0
function comet()
{
    global $body;
    global $navigation;
    global $ts;
    global $cometservice;
    $cometchecky = "";
    $cometcheckn = "";
    $isTypingy = "";
    $isTypingn = "";
    $cometselfhostedy = "";
    $cometselfhostedn = "";
    $messagereceipty = "";
    $messagereceiptn = "";
    if (defined('USE_COMET') && USE_COMET == 1) {
        $cometchecky = "checked";
    } else {
        $cometcheckn = "checked";
    }
    if (defined('IS_TYPING') && IS_TYPING == 1) {
        $isTypingy = "checked";
    } else {
        $isTypingn = "checked";
    }
    if (defined('MESSAGE_RECEIPT') && MESSAGE_RECEIPT == 1) {
        $messagereceipty = "checked";
    } else {
        $messagereceiptn = "checked";
    }
    if (USE_COMET == 1) {
        $cometservice = 'style="display:block"';
    } else {
        $cometservice = 'style="display:none"';
    }
    $keya = KEY_A;
    $keyb = KEY_B;
    $keyc = KEY_C;
    $transport = TRANSPORT;
    $server_url = CS_TEXTCHAT_SERVER;
    $cometserviceselfhosted = 0;
    if ($transport == 'cometservice-selfhosted') {
        $cometselfhostedy = "checked";
    } else {
        $cometselfhostedn = "checked";
    }
    $overlay = '';
    if (file_exists(dirname(dirname(__FILE__)) . DIRECTORY_SEPARATOR . 'transports' . DIRECTORY_SEPARATOR . 'cometservice-selfhosted' . DIRECTORY_SEPARATOR . 'comet.php')) {
        $cometserviceselfhosted = 1;
    }
    if (!checkCurl()) {
        $overlay = <<<EOD
\t\t\t<script>
\t\t\tjQuery('#rightcontent').before('<div id="overlaymain" style="position:relative"></div>');
\t\t\t\tvar overlay = \$('<div></div>')
\t\t\t\t\t.attr('id','overlay')
\t\t\t\t\t.css({
\t\t\t\t\t\t'position':'absolute',
\t\t\t\t\t\t'height':\$('#rightcontent').innerHeight(),
\t\t\t\t\t\t'width':\$('#rightcontent').innerWidth(),
\t\t\t\t\t\t'background-color':'#FFFFFF',
\t\t\t\t\t\t'opacity':'0.9',
\t\t\t\t\t\t'z-index':'99',
\t\t\t\t\t\t'right': '0',
\t\t\t\t\t\t'margin-left':'1px'
\t\t\t\t\t})
\t\t\t\t\t.appendTo('#overlaymain');
\t\t\t\t\t\$('<span>cURL extension is disabled on your server. Please contact your webhost to enable it.<br> cURL is required for CometService.</span>')
\t\t\t\t\t\t.css({'z-index':' 9999',
\t\t\t\t\t\t'color':'#000000',
\t\t\t\t\t\t'font-size':'15px',
\t\t\t\t\t\t'font-weight':'bold',
\t\t\t\t\t\t'display':'block',
\t\t\t\t\t\t'text-align':'center',
\t\t\t\t\t\t'margin':'auto',
\t\t\t\t\t\t'position':'absolute',
\t\t\t\t\t\t'width':'100%',
\t\t\t\t\t\t'top':'100px',
\t\t\t\t\t\t'right':' -87px'
\t\t\t\t\t}).appendTo('#overlaymain');

\t\t\t</script>
EOD;
    }
    $body = <<<EOD
\t{$navigation}
\t<form action="?module=settings&action=updatecomet&ts={$ts}" method="post">
\t<div id="rightcontent" style="float:left;width:720px;border-left:1px dotted #ccc;padding-left:20px;">
\t\t<h2>CometService</h2>
\t\t<h3>If you are using our hosted CometService, please enter the details here</h3>

\t\t<div>
\t\t\t<div id="centernav">
\t\t\t\t<div class="title" style="width:200px">Use Comet Service?</div><div class="element"><input id="cs1" class="comet" type="radio" name="dou" value="1" {$cometchecky}>Yes <input id="cs2" class="comet" type="radio" {$cometcheckn} name="dou" value="0" >No</div>
\t\t\t\t<div style="clear:both;padding:10px;"></div>
\t\t\t\t<div class="enabled_cs" {$cometservice}>
\t\t\t\t\t<div class="cckeys">
\t\t\t\t\t\t<div class="title">Key A:</div><div class="element"><input type="text" class="inputbox cometkeys" name="keya" value="{$keya}" required="true"/></div>
\t\t\t\t\t\t<div style="clear:both;padding:10px;"></div>
\t\t\t\t\t\t<div class="title">Key B:</div><div class="element"><input type="text" class="inputbox cometkeys" name="keyb" value="{$keyb}" required="true"/></div>
\t\t\t\t\t\t<div style="clear:both;padding:10px;"></div>
\t\t\t\t\t\t<div class="title">Key C:</div><div class="element"><input type="text" class="inputbox cometkeys" name="keyc" value="{$keyc}" required="true"/></div>
\t\t\t\t\t\t<div style="clear:both;padding:10px;"></div>
\t\t\t\t\t</div>
\t\t\t\t\t<div class="title" style="width:200px">Use isTyping Service?</div><div class="element"><input type="radio" name="typ" value="1" {$isTypingy}>Yes <input type="radio" {$isTypingn} name="typ" value="0" >No</div>
\t\t\t\t\t<div style="clear:both;padding:10px;"></div>
\t\t\t\t\t<div class="title" style="width:200px">Use message receipt service?</div><div class="element"><input type="radio" name="rec" value="1" {$messagereceipty}>Yes <input type="radio" {$messagereceiptn} name="rec" value="0" >No</div>
\t\t\t\t\t<div style="clear:both;padding:10px;"></div>
\t\t\t\t\t<div class="title cometserviceselfhosted" style="width:200px">Use SelfHosted Comet Service?</div><div class="element cometserviceselfhosted"><input type="radio" name="dos" value="1" {$cometselfhostedy}>Yes <input type="radio" {$cometselfhostedn} name="dos" value="0" >No</div>
\t\t\t\t\t<div style="clear:both;padding:10px;"></div>
\t\t\t\t\t<div class="serverurl_text"><div class="title">Server URL:</div><div class="element"><input type="text" class="inputbox" name="server_url" value="{$server_url}" placeholder="http://www.yoursite.com:portnumber" /></div></div>
\t\t\t\t</div>
\t\t\t</div>
\t\t\t<div id="rightnav">
\t\t\t\t<h1>Warning</h1>
\t\t\t\t<ul id="modules_availablemodules">
\t\t\t\t\t<li>Make sure that you have subscribed to our service before enabling this service.</li>
\t\t\t\t\t<li>After activation/de-activation be sure to clear your browser cache.</li>
\t\t\t\t\t<li class ="cometserviceselfhosted" style="word-break:break-word">Make sure you enter complete Server URL. For example: http://www.yoursite.com:portnumber </li>
 \t\t\t\t</ul>
\t\t\t</div>
\t\t</div>

\t\t<div style="clear:both;padding:7.5px;"></div>
\t\t<input type="submit" value="Update settings" class="button">&nbsp;&nbsp;or <a href="?module=settings&amp;ts={$ts}">cancel</a>
\t</div>

\t<div style="clear:both"></div>
\t<script>
\t\t\$(document).ready(function(){
\t\t\tvar cometenabled = \$("input:radio[name=dou]:checked").val();
\t\t\tif(cometenabled == 1){
\t\t\t\t\$('.enabled_cs').slideDown("fast");
\t\t\t}
\t\t\tvar cometserviceselfhosted = {$cometserviceselfhosted};
\t\t\tif(cometserviceselfhosted != 1){
\t\t\t\t\$('.cometserviceselfhosted').hide();
\t\t\t}
\t\t\t\$('input:radio[name=dou]').change(function(){
\t\t\t\tcometenabled = \$(this).val();
\t\t\t\tif(cometenabled == 1){
\t\t\t\t\t\$('.enabled_cs').slideDown("fast");
\t\t\t\t} else {
\t\t\t\t\t\$('.enabled_cs').slideUp("fast");
\t\t\t\t}
\t\t\t});
\t\t\tvar transport = '{$transport}';
\t\t\tif(transport == 'cometservice-selfhosted'){
\t\t\t\t\$('.serverurl_text').slideDown("fast");
\t\t\t\t\$('.cometkeys').removeAttr('required');
\t\t\t\t\$('.cckeys').hide();
\t\t\t}
\t\t\t\$('input:radio[name=dos]').change(function(){
\t\t\t\tselfhostedenabled = \$(this).val();
\t\t\t\tif(selfhostedenabled == 1){
\t\t\t\t\t\$('.serverurl_text').slideDown("fast");
\t\t\t\t\t\$('.cometkeys').removeAttr('required');
\t\t\t\t\t\$('.cckeys').slideUp("fast");
\t\t\t\t\t\$('input:text[name=server_url]').attr('required','true');
\t\t\t\t} else {
\t\t\t\t\t\$('.serverurl_text').slideUp("fast");
\t\t\t\t\t\$('.cckeys').slideDown("fast");
\t\t\t\t\t\$('.cometkeys').attr('required','true');
\t\t\t\t\t\$('input:text[name=server_url]').removeAttr('required');
\t\t\t\t}
\t\t\t});
\t\t\t\$("#leftnav").find('a').removeClass('active_setting');
\t\t\t\$("#cometservice_settings").addClass('active_setting');
\t\t});
\t</script>
\t{$overlay}
EOD;
    template();
}