本文整理汇总了PHP中ccurl::get方法的典型用法代码示例。如果您正苦于以下问题:PHP ccurl::get方法的具体用法?PHP ccurl::get怎么用?PHP ccurl::get使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ccurl
的用法示例。
在下文中一共展示了ccurl::get方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: Connect
function Connect($server, $port, $user, $pass)
{
writelogs("synchronize {$server}:{$port}", __FUNCTION__, __FILE__, __LINE__);
$sync = new articaSMTPSync();
$ldap = new clladp();
$http = new httpd();
$array = $sync->GetUsers();
$field = base64_encode(serialize($array));
$cred["user"] = $user;
$cred["pass"] = $pass;
$curl = new ccurl("https://{$server}:{$port}/exec.smtp.export.users.php");
$curl->parms["credentials"] = base64_encode(serialize($cred));
$curl->parms["users"] = $field;
$curl->parms["local_port"] = $http->https_port;
$curl->parms["mycred"] = base64_encode(serialize(array($ldap->ldap_admin, $ldap->ldap_password)));
if (!$curl->get()) {
writelogs("synchronize {$server}:{$port} failed", __FUNCTION__, __FILE__, __LINE__);
}
if (preg_match("#<datas>(.+?)</datas>#is", $curl->data, $re)) {
$array = unserialize(base64_decode($re[1]));
$sync->import($array, "{$server}:{$port}");
$sock = new sockets();
$sock->getFrameWork("cmd.php?postfix-transport-maps=yes");
}
}
示例2: GetCategory
function GetCategory($source, $dest)
{
for ($i = 1; $i < 13; $i++) {
echo "Checking page number {$i}\n";
$curl = new ccurl("http://cacaweb.com/category/{$source}/page/{$i}");
$curl->NoHTTP_POST = true;
$curl->UserAgent = "Mozilla/5.0 (X11; Ubuntu; Linux i686; rv:10.0) Gecko/20100101 Firefox/10.0";
$curl->FollowLocation = true;
if (!$curl->get()) {
echo $curl->error . "\n";
return;
}
CheckWebsites($curl->data, $dest);
}
}
示例3: ping
function ping($hostid)
{
$mefile = basename(__FILE__);
$GLOBALS["CLASS_UNIX"] = new unix();
$GLOBALS["CLASS_UNIX"]->events("{$mefile}:: blackboxes({$hostid})", "/var/log/stats-appliance.log");
$black = new blackboxes($hostid);
$ssluri = $black->ssluri . "/nodes.listener.php";
$nossluri = $black->sslnouri . "/nodes.listener.php";
if ($GLOBALS["VERBOSE"]) {
echo "Try {$ssluri}\n";
}
$GLOBALS["CLASS_UNIX"]->events("{$mefile}:: {$ssluri}", "/var/log/stats-appliance.log");
$curl = new ccurl($ssluri);
$curl->parms["PING-ORDERS"] = true;
if ($GLOBALS["VERBOSE"]) {
$curl->parms["VERBOSE"] = true;
}
$curl->noproxyload = true;
if ($GLOBALS["VERBOSE"]) {
echo "Sending PING-ORDERS\n";
}
if (!$curl->get()) {
$ssluri = $nossluri;
$GLOBALS["CLASS_UNIX"]->events("{$mefile}:: {$ssluri}", "/var/log/stats-appliance.log");
if ($GLOBALS["VERBOSE"]) {
echo "error `{$ssluri}` {$curl->error}, trying http\n";
}
$curl = new ccurl($nossluri);
$curl->noproxyload = true;
$curl->parms["PING-ORDERS"] = true;
if (!$curl->get()) {
ufdbguard_admin_events("{$mefile}:: Failed to send ping to {$black->hostname} with Error:`{$curl->error}`", __FUNCTION__, __FILE__, __LINE__, "communicate");
return;
}
}
if ($GLOBALS["VERBOSE"]) {
echo $curl->data;
}
if (preg_match("#SUCCESS<#s", $curl->data)) {
$GLOBALS["CLASS_UNIX"]->events("Success to send ping to {$black->hostname}", "/var/log/stats-appliance.log");
ufdbguard_admin_events("{$mefile}:: Success to send ping to {$black->hostname}", __FUNCTION__, __FILE__, __LINE__, "communicate");
}
}
示例4: ImportNets
function ImportNets()
{
$sock = new sockets();
$ini = new Bs_IniHandler();
$ini->loadString($sock->GET_INFO("ComputersImportArtica"));
if (!is_array($ini->_params)) {
writelogs("No artica masters defined", __FUNCTION__, __FILE__, __LINE__);
die;
}
if (count($ini->_params) == 0) {
writelogs("No artica masters defined", __FUNCTION__, __FILE__, __LINE__);
die;
}
while (list($ip, $array) = each($ini->_params)) {
if (trim($ip) == null) {
continue;
}
$curl = new ccurl("https://{$ip}:{$array["port"]}/exec.import-networks.php");
while (list($key, $value) = each($array)) {
$curl->parms[$key] = $value;
}
$curl->get();
$datas = $curl->data;
if (trim($datas) == null) {
continue;
}
$md5 = md5($datas);
import_vpn_remotes_sites($datas);
if (!$GLOBALS["FORCE"]) {
if ($array["md5"] != $md5) {
ImportDatas($datas);
}
} else {
ImportDatas($datas);
}
$ini->_params[$ip]["md5"] = $md5;
}
reset($ini->_params);
$ini->saveFile("/etc/artica-postfix/settings/Daemons/ComputersImportArtica");
}
示例5: Save
function Save()
{
include_once dirname(__FILE__) . "/ressources/class.ccurl.inc";
$sock = new sockets();
$tpl = new templates();
$curl = new ccurl();
$proto = "http";
$StatsServervame = $_POST["StatsServervame"];
$StatsServerPort = $_POST["StatsServerPort"];
$StatsServerSSL = $_POST["StatsServerSSL"];
if ($StatsServerSSL == 1) {
$proto = "https";
}
$EnableRemoteSyslogStatsAppliance = $_POST["EnableRemoteSyslogStatsAppliance"];
$uri = "{$proto}://{$StatsServervame}:{$StatsServerPort}/nodes.listener.php";
if ($EnableRemoteSyslogStatsAppliance == 1) {
writelogs("{$uri}", __FUNCTION__, __FILE__, __LINE__);
$curl = new ccurl($uri);
$curl->parms["OPENSYSLOG"] = 1;
if (!$curl->get()) {
echo "Error " . $tpl->_ENGINE_parse_body($curl->error);
return;
}
if (strpos($curl->data, "<RESULTS>OK</RESULTS>") == 0) {
echo "Error Protocol error or bad version on remote server\n";
return;
}
}
$sock->SET_INFO("EnableRemoteSyslogStatsAppliance", $EnableRemoteSyslogStatsAppliance);
$RemoteSyslogAppliance["SSL"] = $_POST["StatsServerSSL"];
$RemoteSyslogAppliance["PORT"] = $_POST["StatsServerPort"];
$RemoteSyslogAppliance["SERVER"] = $_POST["StatsServervame"];
$sock->SaveConfigFile(base64_encode(serialize($RemoteSyslogAppliance)), "RemoteSyslogAppliance");
$sock->getFrameWork("cmd.php?syslog-client-mode=yes");
$sock->getFrameWork("squid.php?compile-schedules-reste=yes");
$sock->getFrameWork("squid.php?squid-reconfigure=yes");
}
示例6: RefreshIndex
function RefreshIndex()
{
$unix = new unix();
$nice = EXEC_NICE();
$sock = new sockets();
$users = new usersMenus();
$nohup = $unix->find_program("nohup");
$php = $unix->LOCATE_PHP5_BIN();
$wget = $unix->find_program("wget");
$SYSTEMID = $unix->GetUniqueID();
if ($SYSTEMID == null) {
build_progress("System ID is Null !!!", 5);
return;
}
build_progress_index("Register server...", 10);
build_progress("Register server...", 10);
shell_exec("{$nohup} {$nice} {$php} /usr/share/artica-postfix/exec.web-community-filter.php --register-lic >/dev/null 2>&1 &");
if ($SYSTEMID == null) {
build_progress_index("No system ID, force...", 15);
build_progress("No system ID, force", 15);
shell_exec("{$nice} /usr/share/artica-postfix/bin/artica-update -refresh-index --force >/dev/null 2>&1");
return;
}
$xMEM_TOTAL_INSTALLEE = $users->MEM_TOTAL_INSTALLEE;
$CPU_NUMBER = $users->CPU_NUMBER;
$LinuxDistributionFullName = $users->LinuxDistriFullName;
if ($LinuxDistributionFullName == null) {
$LinuxDistributionFullName = "Linux Default";
}
$ARTICA_VERSION = GetCurrentVersion();
$hostname = $unix->hostname_g();
$CheckUserCount = CheckUserCount();
$RebootAfterArticaUpgrade = $sock->GET_INFO("RebootAfterArticaUpgrade");
if (!is_numeric($RebootAfterArticaUpgrade)) {
$RebootAfterArticaUpgrade = 0;
}
$EnableScheduleUpdates = $sock->GET_INFO("EnableScheduleUpdates");
$ArticaUpdateIntervalAllways = intval($sock->GET_INFO("EnableScheduleUpdates"));
if (!is_numeric($EnableScheduleUpdates)) {
$EnableScheduleUpdates = 0;
}
$ArticaAutoUpateOfficial = $sock->GET_INFO("ArticaAutoUpateOfficial");
$ArticaAutoUpateNightly = intval($sock->GET_INFO("ArticaAutoUpateNightly"));
$ArticaUpdateIntervalAllways = intval($sock->GET_INFO("ArticaUpdateIntervalAllways"));
$OfficialArticaUri = $sock->GET_INFO("OfficialArticaUri");
if (!is_numeric($ArticaAutoUpateOfficial)) {
$ArticaAutoUpateOfficial = 1;
}
if ($OfficialArticaUri == null) {
$OfficialArticaUri = "http://articatech.net/artica.update.php";
}
$uri = $OfficialArticaUri;
$dmidecode = @file_get_contents("/etc/artica-postfix/dmidecode.cache.url");
@unlink($GLOBALS["MasterIndexFile"]);
$tarballs_file = "/usr/share/artica-postfix/ressources/logs/web/tarballs.cache";
echo "Starting......: " . date("H:i:s") . " CPU NUMBER: {$CPU_NUMBER}\n";
echo "Starting......: " . date("H:i:s") . " Hostname..: {$hostname}\n";
echo "Starting......: " . date("H:i:s") . " Artica ver: {$ARTICA_VERSION}\n";
echo "Starting......: " . date("H:i:s") . " Users.....: {$CheckUserCount}\n";
build_progress_index("Configuration done...", 15);
build_progress("Configuration done", 15);
$DATA["UUID"] = $SYSTEMID;
$DATA["MEM"] = $xMEM_TOTAL_INSTALLEE;
$DATA["CPU"] = $CPU_NUMBER;
$DATA["LINUX"] = $LinuxDistributionFullName;
$DATA["VERSION"] = $ARTICA_VERSION;
$DATA["HOSTNAME"] = $hostname;
$DATA["USERS"] = $CheckUserCount;
$DATA["DMICODE"] = $dmidecode;
build_progress_index("Check repositories...", 20);
build_progress("Check repositories", 20);
$MAIN_URI = $unix->MAIN_URI();
echo "Starting......: " . date("H:i:s") . " Main URI..: {$MAIN_URI}\n";
$md5string = @md5_file($GLOBALS["MasterIndexFile"]);
build_progress_index("Get Index...", 25);
build_progress("Get Index...", 25);
echo "Starting......: " . date("H:i:s") . " Update index file..\n";
$curl = new ccurl($OfficialArticaUri);
$curl->parms["datas"] = base64_encode(serialize($DATA));
if (!$curl->get()) {
echo "Last detected error: {$curl->error}\n";
build_progress_index("Get Index...{failed}", 110);
build_progress("Get Index file !! FAILED !!", 110);
_artica_update_event(0, "Unable to download index file with error {$curl->error_num}, {$curl->error}", null, __FILE__, __LINE__);
return false;
}
@unlink("/etc/artica-postfix/settings/Daemons/ArticaUpdateRepos");
build_progress_index("Parse Index from repository", 40);
build_progress("Parse Index from repository", 40);
if (preg_match("#<ERROR>(.+?)</ERROR>#is", $curl->data, $re)) {
echo "{$re[1]} !! FAILED !!\n";
build_progress_index("Corrupted index from repository !! FAILED !!", 110);
build_progress("Corrupted index from repository !! FAILED !!", 110);
return;
}
if (!preg_match("#<CONTENT>(.+?)</CONTENT>#is", $curl->data, $re)) {
echo "Corrupted index from repository !! FAILED !!\n";
build_progress_index("Corrupted index from repository !! FAILED !!", 110);
build_progress("Corrupted index from repository !! FAILED !!", 110);
return;
//.........这里部分代码省略.........
示例7: save_ssl
function save_ssl()
{
$sock = new sockets();
if (isset($_POST["UfdbUseArticaClient"])) {
$sock->SET_INFO("UfdbUseArticaClient", $_POST["UfdbUseArticaClient"]);
}
if (isset($_POST["UfdbgclientSockTimeOut"])) {
$sock->SET_INFO("UfdbgclientSockTimeOut", $_POST["UfdbgclientSockTimeOut"]);
}
if (isset($_POST["UfdbgclientMaxSockTimeOut"])) {
$sock->SET_INFO("UfdbgclientMaxSockTimeOut", $_POST["UfdbgclientMaxSockTimeOut"]);
}
if (isset($_POST["SquidGuardRedirectBehavior"])) {
$sock->SET_INFO("SquidGuardRedirectBehavior", $_POST["SquidGuardRedirectBehavior"]);
}
if (isset($_POST["SquidGuardRedirectHTTPCode"])) {
$sock->SET_INFO("SquidGuardRedirectHTTPCode", $_POST["SquidGuardRedirectHTTPCode"]);
}
if (isset($_POST["SquidGuardUseRefreshDomainList"])) {
$sock->SET_INFO("SquidGuardUseRefreshDomainList", $_POST["SquidGuardUseRefreshDomainList"]);
}
if (isset($_POST["UseRemoteUfdbguardService"])) {
$sock->SET_INFO('UseRemoteUfdbguardService', $_POST["UseRemoteUfdbguardService"]);
if ($_POST["UseRemoteUfdbguardService"] == 1) {
$remote_server = $_POST["remote_server"];
$remote_port = $_POST["remote_port"];
if (!is_numeric($remote_port)) {
$remote_port = 3977;
$_POST["remote_port"] = 3977;
}
if (@fsockopen($remote_server, 9000, $errno, $errstr, 1)) {
$uri = "https://{$remote_server}:9000/nodes.listener.php?ufdbguardport={$remote_port}";
$curl = new ccurl($uri);
$curl->NoHTTP_POST = true;
if (!$curl->get()) {
}
}
if (!@fsockopen($remote_server, $remote_port, $errno, $errstr, 1)) {
echo "{$remote_server}:{$remote_port}\nError: {$errno} {$errstr}\n";
}
}
}
if (isset($_POST["UfdbGuardThreads"])) {
writelogs("SET_INFO UfdbGuardThreads= {$_POST["UfdbGuardThreads"]}", __FUNCTION__, __FILE__, __LINE__);
$sock->SET_INFO('UfdbGuardThreads', $_POST["UfdbGuardThreads"]);
}
if (isset($_POST["ufdbguardReloadTTL"])) {
writelogs("SET_INFO ufdbguardReloadTTL= {$_POST["ufdbguardReloadTTL"]}", __FUNCTION__, __FILE__, __LINE__);
$sock->SET_INFO('ufdbguardReloadTTL', $_POST["ufdbguardReloadTTL"]);
}
if (isset($_POST["EnableGoogleSafeSearch"])) {
writelogs("SET_INFO EnableGoogleSafeSearch= {$_POST["EnableGoogleSafeSearch"]}", __FUNCTION__, __FILE__, __LINE__);
$sock->SET_INFO('EnableGoogleSafeSearch', $_POST["EnableGoogleSafeSearch"]);
}
if (isset($_POST["UfdbDatabasesInMemory"])) {
writelogs("SET_INFO UfdbDatabasesInMemory= {$_POST["UfdbDatabasesInMemory"]}", __FUNCTION__, __FILE__, __LINE__);
$sock->SET_INFO('UfdbDatabasesInMemory', $_POST["UfdbDatabasesInMemory"]);
}
$datas = unserialize(base64_decode($sock->GET_INFO("ufdbguardConfig")));
while (list($key, $line) = each($_POST)) {
writelogs("SAVE {$key} = {$line}", __FUNCTION__, __FILE__, __LINE__);
$datas[$key] = $line;
}
$sock->SaveConfigFile(base64_encode(serialize($datas)), "ufdbguardConfig");
$sock->getFrameWork("cmd.php?reload-squidguard=yes");
}
示例8: RefreshIndex
function RefreshIndex()
{
$unix = new unix();
$nice = EXEC_NICE();
$sock = new sockets();
$users = new usersMenus();
$nohup = $unix->find_program("nohup");
$php = $unix->LOCATE_PHP5_BIN();
$wget = $unix->find_program("wget");
$SYSTEMID = $unix->GetUniqueID();
if ($SYSTEMID == null) {
build_progress("System ID is Null !!!", 5);
return;
}
build_progress("Register server...", 10);
shell_exec("{$nohup} {$nice} {$php} /usr/share/artica-postfix/exec.web-community-filter.php --register-lic >/dev/null 2>&1 &");
if ($SYSTEMID == null) {
build_progress("No system ID, force", 15);
shell_exec("{$nice} /usr/share/artica-postfix/bin/artica-update -refresh-index --force >/dev/null 2>&1");
return;
}
$xMEM_TOTAL_INSTALLEE = $users->MEM_TOTAL_INSTALLEE;
$CPU_NUMBER = $users->CPU_NUMBER;
$LinuxDistributionFullName = $users->LinuxDistriFullName;
if ($LinuxDistributionFullName == null) {
$LinuxDistributionFullName = "Linux Default";
}
$ARTICA_VERSION = GetCurrentVersion();
$hostname = $unix->hostname_g();
$CheckUserCount = CheckUserCount();
$dmidecode = @file_get_contents("/etc/artica-postfix/dmidecode.cache.url");
$uriplus = "{$SYSTEMID};{$xMEM_TOTAL_INSTALLEE};{$CPU_NUMBER};{$LinuxDistributionFullName};{$ARTICA_VERSION};{$hostname};{$CheckUserCount};{$dmidecode}";
$uriplus = urlencode($uriplus);
@unlink($GLOBALS["MasterIndexFile"]);
$tarballs_file = "/usr/share/artica-postfix/ressources/logs/web/tarballs.cache";
echo "Starting......: " . date("H:i:s") . " CPU NUMBER: {$CPU_NUMBER}\n";
echo "Starting......: " . date("H:i:s") . " Hostname..: {$hostname}\n";
echo "Starting......: " . date("H:i:s") . " Artica ver: {$ARTICA_VERSION}\n";
echo "Starting......: " . date("H:i:s") . " Users.....: {$CheckUserCount}\n";
build_progress("Configuration done", 15);
$ini = new iniFrameWork();
$ini->loadFile('/etc/artica-postfix/artica-update.conf');
if (trim($ini->_params["AUTOUPDATE"]["uri"]) == null) {
$ini->_params["AUTOUPDATE"]["uri"] = "http://www.articatech.net/auto.update.php";
}
if (!isset($ini->_params["AUTOUPDATE"]["enabled"])) {
$ini->_params["AUTOUPDATE"]["enabled"] = "yes";
}
if ($ini->_params["AUTOUPDATE"]["enabled"] == null) {
$ini->_params["AUTOUPDATE"]["enabled"] = "yes";
}
if (!is_numeric(trim($ini->_params["AUTOUPDATE"]["CheckEveryMinutes"]))) {
$ini->_params["AUTOUPDATE"]["CheckEveryMinutes"] = 60;
}
$uri = $ini->_params["AUTOUPDATE"]["uri"];
$arrayURI = parse_url($uri);
build_progress("Check repositories", 20);
$MAIN_URI = $unix->MAIN_URI();
echo "Starting......: " . date("H:i:s") . " Main URI..: {$MAIN_URI}\n";
$md5string = @md5_file($GLOBALS["MasterIndexFile"]);
build_progress("Get TarBalls...", 25);
echo "Starting......: " . date("H:i:s") . " Update tarballs..\n";
$curl = new ccurl("{$MAIN_URI}/tarballs.php?time=" . time());
@unlink($tarballs_file);
$curl->NoHTTP_POST = true;
if (!$curl->GetFile($tarballs_file)) {
build_progress("Get TarBalls !! FAILED !!", 30);
_artica_update_event(0, "Unable to download tarballs file with error {$curl->error_num}, {$curl->error}", null, __FILE__, __LINE__);
@unlink($tarballs_file);
}
build_progress("Ping repositories...", 35);
@chmod($tarballs_file, 0755);
echo "Starting......: " . date("H:i:s") . " dmidecode = " . strlen($dmidecode) . " bytes\n";
echo "Starting......: " . date("H:i:s") . " Updating repository information..\n";
$curl = new ccurl("{$MAIN_URI}/routers.inject.php?time=" . time());
$curl->NoHTTP_POST = true;
$curl->get();
build_progress("Retreive index from repository", 40);
$curl = new ccurl("{$uri}?time=" . time() . "&datas={$uriplus}");
$curl->NoHTTP_POST = true;
$curl->forceCache = true;
echo "Starting......: " . date("H:i:s") . " Downloading collection using Interface: `{$curl->interface}`\n";
echo "Starting......: " . date("H:i:s") . " Using \"{$GLOBALS["MasterIndexFile"]}\"\n";
echo "Starting......: " . date("H:i:s") . " Timeout set to \"{$curl->Timeout}s\"\n";
if (!$curl->GetFile($GLOBALS["MasterIndexFile"])) {
build_progress("Retreive index from repository !! FAILED !!", 100);
if (!$GLOBALS["NOT_FORCE_PROXY"]) {
echo "Starting......: " . date("H:i:s") . " FATAL: Unable to download index file, try in direct mode\n";
$GLOBALS["NOT_FORCE_PROXY"] = true;
return RefreshIndex();
}
echo "Starting......: " . date("H:i:s") . " FATAL: {$GLOBALS["MasterIndexFile"]} " . @filesize($GLOBALS["MasterIndexFile"]) . " bytes\n";
echo "Starting......: " . date("H:i:s") . " FATAL: Unable to download index file with error {$curl->error_num}, {$curl->error}\n";
_artica_update_event(0, "Unable to download index file with error {$curl->error_num}, {$curl->error}", null, __FILE__, __LINE__);
exec("{$nice} /usr/share/artica-postfix/bin/artica-update -refresh-index 2>&1", $results);
while (list($num, $ligne) = each($dirs)) {
echo "Starting......: " . date("H:i:s") . " {$ligne}\n";
}
return;
}
//.........这里部分代码省略.........
示例9: peer_infos
function peer_infos(){
include_once("ressources/class.ccurl.inc");
$squid=new squidbee();
$sock=new sockets();
$SquidMgrListenPort=trim($sock->GET_INFO("SquidMgrListenPort"));
if( !is_numeric($SquidMgrListenPort) OR ($SquidMgrListenPort==0) ){
$listenport=$squid->listen_port;
}else{
$listenport=$SquidMgrListenPort;
}
$uri="http://127.0.0.1:$listenport/squid-internal-mgr/peer_select";
if($GLOBALS["VERBOSE"]){echo "<li> curl -> $uri</li>";}
$curl=new ccurl("http://127.0.0.1:$squid->listen_port/squid-internal-mgr/peer_select");
$curl->NoHTTP_POST=true;
$curl->ArticaProxyServerEnabled="no";
$curl->CURLOPT_NOPROXY="127.0.0.1";
$curl->ArticaProxyServerEnabled=="no";
$curl->interface="127.0.0.1";
$curl->Timeout=5;
$curl->UseDirect=true;
$curl->get();
if($GLOBALS["VERBOSE"]){echo "<li> ". strlen( $curl->data)."</li>";}
$datas=explode("\n", $curl->data);
while (list ($index, $line) = each ($datas)){
if(preg_match("#peer digest from\s+(.+)#", $line,$re)){$serv=$re[1];}
if(preg_match("#needed:\s+(.+?),\s+usable:\s+(.+?),\s+requested:\s+(.+)#", $line,$re)){
$ARR[$serv]["needed"]=$re[1];
$ARR[$serv]["usable"]=$re[2];
$ARR[$serv]["requested"]=$re[3];
}
if(preg_match("#requests sent: ([0-9]+), volume: (.+)#",$line,$re)){
$ARR[$serv]["RQSENT"]=$re[1];
$ARR[$serv]["VOL"]=$re[2];
}
}
return $ARR;
}
示例10: exunlink
function exunlink()
{
$unix = new unix();
$sock = new sockets();
$net = new networking();
$WgetBindIpAddress = $sock->GET_INFO("WgetBindIpAddress");
$MAIN = unserialize(base64_decode($sock->GET_INFO("HASettings")));
$eth = $MAIN["eth"];
$t = time();
if (!is_numeric($MAIN["SLAVE_SSL"])) {
$MAIN["SLAVE_SSL"] = 1;
}
$proto = "http";
if ($MAIN["SLAVE_SSL"] == 1) {
$proto = "https";
}
$MAIN = unserialize(base64_decode($sock->GET_INFO("HASettings")));
$eth = $MAIN["eth"];
$nic = new system_nic($eth);
$MAIN["BALANCE_IP"] = $MAIN["first_ipaddr"];
$SEND_SETTING = base64_encode(serialize($MAIN));
$uri = "{$proto}://{$MAIN["SLAVE"]}:{$MAIN["SLAVE_PORT"]}/nodes.listener.php?ucarp2-remove={$SEND_SETTING}&continue=true";
build_progress("Notify {$MAIN["SLAVE"]}", 20);
$curl = new ccurl($uri, true, $WgetBindIpAddress, true);
$curl->NoHTTP_POST = true;
if (!$curl->get()) {
echo "{$curl->error}\n";
debug_curl($curl->CURL_ALL_INFOS);
build_progress("{reboot_networks} {$MAIN["SLAVE"]}:{$MAIN["SLAVE_PORT"]} {failed}", 110);
return;
}
if (!preg_match("#<RESULTS>(.+?)</RESULTS>#is", $curl->data, $re)) {
echo "Please verify that both servers must have the same Artica version\n";
build_progress("{reboot_networks} {$MAIN["SLAVE"]}:{$MAIN["SLAVE_PORT"]} {protocol_error}", 110);
return;
}
$array = unserialize(base64_decode($re[1]));
if ($array["ERROR"]) {
echo "{$array["ERROR_SHOW"]}\n";
build_progress("{reboot_networks} {$MAIN["SLAVE"]}:{$MAIN["SLAVE_PORT"]} {failed}", 110);
return;
}
build_progress("{please_wait_reconfigure_network}", 80);
$nic = new system_nic($eth);
$nic->ucarp_enabled = 0;
$nic->ucarp_vip = null;
$nic->ucarp_vid = 0;
$nic->ucarp_master = 0;
$nic->NoReboot = true;
if (isset($MAIN["first_ipaddr"])) {
if ($MAIN["first_ipaddr"] != null) {
$nic->IPADDR = $MAIN["first_ipaddr"];
}
}
if (!$nic->SaveNic()) {
echo "Unable to save local settings\n";
build_progress("{saving_local_parameters} {failed}", 110);
return;
}
//please_wait_reconfigure_network
$sock->SET_INFO("HASettings", base64_encode(serialize(array())));
build_progress("{reboot_networks}", 75);
$php = $unix->LOCATE_PHP5_BIN();
system("{$php} /usr/share/artica-postfix/exec.virtuals-ip.php --build --force");
build_progress("{reboot_networks}", 80);
squid_admin_mysql(0, "Rebooting Network", null, __FILE__, __LINE__);
system("/etc/init.d/artica-ifup --script=exec.failover.php/" . __FUNCTION__);
build_progress("{starting_service}", 90);
system("/etc/init.d/artica-failover stop");
sleep(3);
build_progress("{done}", 100);
}
示例11: notify_remote_proxys
function notify_remote_proxys()
{
include_once dirname(__FILE__) . "/ressources/class.ccurl.inc";
$q = new mysql_squid_builder();
$sql = "SELECT * FROM squidservers";
$results = $q->QUERY_SQL($sql);
while ($ligne = mysql_fetch_array($results, MYSQL_ASSOC)) {
$server = $ligne["ipaddr"];
$port = $ligne["port"];
if (!is_numeric($port)) {
continue;
}
$refix = "https";
$uri = "{$refix}://{$server}:{$port}/squid.stats.listener.php";
writelogs($uri, __FUNCTION__, __FILE__, __LINE__);
$curl = new ccurl($uri, true);
$curl->parms["CHANGE_CONFIG"] = "FILTERS";
if (!$curl->get()) {
squidstatsApplianceEvents("{$server}:{$port}", "FAILED Notify change it`s configuration {$curl->error}");
continue;
}
if (preg_match("#<ANSWER>OK</ANSWER>#is", $curl->data)) {
squidstatsApplianceEvents("{$server}:{$port}", "SUCCESS to notify change it`s configuration");
continue;
}
squidstatsApplianceEvents("{$server}:{$port}", "FAILED Notify change it`s configuration {$curl->data}");
}
}
示例12: AddArticaAgent
function AddArticaAgent(){
$tpl=new templates();
$sock=new sockets();
$pattern=$_POST["AddArticaAgent"];
$ip=$pattern;
if(preg_match("#(.+?):([0-9]+)#", $pattern,$re)){$ip=$re[1];$port=$re[2];}
if(!is_numeric($port)){$port=9001;}
include_once(dirname(__FILE__)."/ressources/class.ccurl.inc");
$ArticaHttpsPort=$sock->GET_INFO("ArticaHttpsPort");
$ArticaHttpUseSSL=$sock->GET_INFO("ArticaHttpUseSSL");
if(!is_numeric($ArticaHttpUseSSL)){$ArticaHttpUseSSL=1;}
if(!is_numeric($ArticaHttpsPort)){$ArticaHttpsPort="9000";}
$time=date('Y-m-d H:i:s');
if(preg_match("#^[0-9]+\.[0-9]+\.[0-9]+\.[0-9]+#", $ip)){
$hostname=gethostbyaddr($ip);
}else{
$hostname=$ip;
$ip=gethostbyname($hostname);
}
$q=new mysql_blackbox();
$q->CheckTables();
$sql="INSERT IGNORE INTO `nodes` (ipaddress,hostname,port,laststatus) VALUES ('$ip','$hostname','$port','$time')";
$q->QUERY_SQL($sql);
if(!$q->ok){echo $q->mysql_error;return;}
if($q->last_id==0){
echo "Unable to get Last ID\n";return;
}
$curl=new ccurl("http://$ip:$port/listener.php");
$curl->parms["REGISTER"]="yes";
$curl->parms["SSL"]=$ArticaHttpUseSSL;
$curl->parms["PORT"]=$ArticaHttpsPort;
$curl->parms["NODE_ID"]=$q->last_id;
if(!$curl->get()){echo $tpl->javascript_parse_text("{$curl->error}")."\nhttp://$ip:$port";return;}
if(!preg_match("#<SUCCESS>#is", $curl->data)){echo $tpl->javascript_parse_text("{failed} `http://$ip:$port`");return;}
}
示例13: TESTCONNECTION
function TESTCONNECTION($force = false)
{
$sock = new sockets();
$unix = new unix();
if ($GLOBALS["FORCE"]) {
$force = true;
}
$TimeFile = "/etc/artica-postfix/pids/" . basename(__FILE__) . "." . __FUNCTION__ . ".time";
$pidfile = "/etc/artica-postfix/pids/" . basename(__FILE__) . "." . __FUNCTION__ . ".pid";
if ($GLOBALS["VERBOSE"]) {
echo "{$TimeFile}\n";
}
if (!$force) {
$pid = $unix->get_pid_from_file($pidfile);
if ($unix->process_exists($pid, basename(__FILE__))) {
$time = $unix->PROCCESS_TIME_MIN($pid);
if ($GLOBALS["OUTPUT"]) {
echo "Starting......: " . date("H:i:s") . " [INIT]: {$GLOBALS["TITLENAME"]}: Already Artica task running PID {$pid} since {$time}mn\n";
}
return;
}
}
@file_put_contents($pidfile, getmypid());
$TimeEx = $unix->file_time_min($TimeFile);
if (!$force) {
if ($TimeEx < 5) {
die;
}
@unlink($TimeFile);
@file_put_contents($TimeFile, time());
}
$ArticaHotSpotInterface = $sock->GET_INFO("ArticaHotSpotInterface");
if ($ArticaHotSpotInterface == null) {
$ArticaHotSpotInterface = "eth0";
}
$NETWORK_ALL_INTERFACES = $unix->NETWORK_ALL_INTERFACES();
$IPADDR = $NETWORK_ALL_INTERFACES[$ArticaHotSpotInterface]["IPADDR"];
$ArticaHotSpotPort = intval($sock->GET_INFO("ArticaHotSpotPort"));
$uri = "http://{$IPADDR}:{$ArticaHotSpotPort}/wifidog/status";
$curl = new ccurl($uri, true, $IPADDR, true);
$curl->NoHTTP_POST = true;
$curl->Timeout = 5;
$curl->interface = $IPADDR;
if (!$curl->get()) {
if (!$GLOBALS["NO_RESTART"]) {
hotspot_admin_mysql(0, "Checking HotSpot service failed [action=restart]", $curl->errors, __FILE__, __LINE__);
$GLOBALS["RECOVER"] = true;
stop(true);
start(true);
}
}
$f = explode("\n", $curl->data);
while (list($num, $line) = each($f)) {
$line = trim($line);
if (preg_match("#IP:\\s+([0-9\\.]+)\\s+MAC:\\s+(.+)#", $line, $re)) {
$MAC = trim(strtolower($re[2]));
$IP = trim($re[1]);
continue;
}
if (preg_match("#Token:\\s+(.+)#", $line, $re)) {
$ARRAY["SESSIONS"][$MAC] = trim($re[1]);
}
if ($line == null) {
continue;
}
if (preg_match("#Uptime:\\s+(.+)#", $line, $re)) {
$ARRAY["UPTIME"] = trim($re[1]);
continue;
}
if (preg_match("#Internet Connectivity:\\s+(.+)#", $line, $re)) {
$ARRAY["INTERNET"] = trim($re[1]);
continue;
}
if (preg_match("#Clients served this session:\\s+([0-9]+)#", $line, $re)) {
$ARRAY["CLIENTS"] = trim($re[1]);
continue;
}
if (preg_match("#([0-9]+)\\s+clients connected#", $line, $re)) {
$ARRAY["CLIENTS"] = trim($re[1]);
continue;
}
if ($GLOBALS["VERBOSE"]) {
echo "No Match {$line}\n";
}
}
$ARRAY["TIME"] = time();
if ($GLOBALS["VERBOSE"]) {
print_r($ARRAY);
}
@mkdir("/usr/share/artica/postfix/ressources/logs/web", 0755, true);
file_put_contents("/usr/share/artica/postfix/ressources/logs/web/wifidog.status", serialize($ARRAY));
chmod("/usr/share/artica/postfix/ressources/logs/web/wifidog.status", 0755);
return $ARRAY;
}
示例14: replic_host
function replic_host($servername)
{
$t = time();
$unix = new unix();
$free = new freeweb($servername);
$instanceid = $free->mysql_instance_id;
$localdatabase = $free->mysql_database;
if (!isset($free->Params["ROUNDCUBE"]["ENABLE_REPLIC"])) {
if ($GLOBALS["VERBOSE"]) {
echo "{$servername}: ROUNDCUBE/ENABLE_REPLIC no set\n";
}
return null;
}
if ($free->Params["ROUNDCUBE"]["ENABLE_REPLIC"] == 0) {
if ($GLOBALS["VERBOSE"]) {
echo "{$servername}: ROUNDCUBE/ENABLE_REPLIC set to disabled\n";
}
return null;
}
$ARTICA_PORT = $free->Params["ROUNDCUBE"]["ARTICA_PORT"];
$ARTICA_ADMIN = $free->Params["ROUNDCUBE"]["ARTICA_ADMIN"];
$ARTICA_PASSWORD = $free->Params["ROUNDCUBE"]["ARTICA_PASSWORD"];
$ARTICA_HOST = $free->Params["ROUNDCUBE"]["ARTICA_HOST"];
$ARTICA_RMWEB = $free->Params["ROUNDCUBE"]["ARTICA_RMWEB"];
if ($GLOBALS["VERBOSE"]) {
echo "Send order to get database dump {$ARTICA_HOST}:{$ARTICA_PORT}\n";
}
$auth = array("username" => $ARTICA_ADMIN, "password" => md5($ARTICA_PASSWORD));
$auth = base64_encode(serialize($auth));
$curl = new ccurl("https://{$ARTICA_HOST}:{$ARTICA_PORT}/exec.gluster.php");
$curl->noproxyload = true;
$curl->parms["AUTH"] = $auth;
$curl->parms["RDCUBE-REPLIC"] = $ARTICA_RMWEB;
if (!$curl->get()) {
if ($GLOBALS["VERBOSE"]) {
echo "Error replicate roundcube to {$ARTICA_HOST}:{$ARTICA_PORT} with error {$curl->error}\n";
}
system_admin_events("Error replicate roundcube to {$ARTICA_HOST}:{$ARTICA_PORT} with error {$curl->error}", __FUNCTION__, __FILE__, __LINE__, "roundcube");
return;
}
preg_match("#<INFOS>(.*?)</INFOS>#is", $curl->data, $re);
if ($GLOBALS["VERBOSE"]) {
echo "{$curl->data}\n";
}
if (!preg_match("#<FILENAME>(.*?)</FILENAME>#is", $curl->data, $re)) {
preg_match("#<ERROR>(.*?)</ERROR>#is", $curl->data, $re);
if ($GLOBALS["VERBOSE"]) {
echo "Error replicate roundcube to {$ARTICA_HOST}:{$ARTICA_PORT} with error {$re[1]}\n";
}
system_admin_events("Error replicate roundcube to {$ARTICA_HOST}:{$ARTICA_PORT} with error {$re[1]}", __FUNCTION__, __FILE__, __LINE__, "roundcube");
return;
}
$filepath = $re[1];
$filename = basename($filepath);
$curl = new ccurl("https://{$ARTICA_HOST}:{$ARTICA_PORT}/{$filepath}");
if (!$curl->GetFile("/tmp/{$filename}")) {
if ($GLOBALS["VERBOSE"]) {
echo "Error get roundcube database from {$filepath} with error {$curl->error}\n";
}
system_admin_events("Error get roundcube database from {$filepath} with error {$curl->error}", __FUNCTION__, __FILE__, __LINE__, "roundcube");
return;
}
$filesize = $unix->file_size("/tmp/{$filename}");
if ($GLOBALS["VERBOSE"]) {
echo "Downloading {$filename} done with {$filesize} bytes\n";
}
if (!$unix->uncompress("/tmp/{$filename}", "/tmp/{$filename}.sql")) {
@unlink("/tmp/{$filename}");
if ($GLOBALS["VERBOSE"]) {
echo "Error uncompress {$filepath}\n";
}
system_admin_events("Error uncompress {$filepath}", __FUNCTION__, __FILE__, __LINE__, "roundcube");
return;
}
@unlink("/tmp/{$filename}");
$mysqlbin = $unix->find_program("mysql");
if ($instanceid > 0) {
$q = new mysql_multi($instance_id);
if ($q->mysql_password != null) {
$password = " --password={$q->mysql_password} ";
}
$cmdline = "{$mysqlbin} --batch --force --user={$q->mysql_admin}{$password} --socket={$q->SocketPath} --database={$localdatabase} </tmp/{$filename}.sql 2>&1";
} else {
$q = new mysql();
if ($q->mysql_server == "127.0.0.1") {
$servcmd = " --socket=/var/run/mysqld/mysqld.sock ";
} else {
$servcmd = " --host={$q->mysql_server} --port={$q->mysql_port} ";
}
if ($q->mysql_password != null) {
$password = " --password={$q->mysql_password} ";
}
$cmdline = "{$mysqlbin} --batch --force --user={$q->mysql_admin}{$password} {$servcmd} --database={$localdatabase} </tmp/{$filename}.sql 2>&1";
}
if ($GLOBALS["VERBOSE"]) {
echo $cmdline . "\n";
}
shell_exec($cmdline);
$took = $unix->distanceOfTimeInWords($t, time(), true);
system_admin_events("Success import from {$filename} to {$localdatabase} took {$took}", __FUNCTION__, __FILE__, __LINE__, "roundcube");
//.........这里部分代码省略.........
示例15: add_node
function add_node()
{
$sock = new sockets();
$ArticaMetaAddNewServ = unserialize($sock->GET_INFO("ArticaMetaAddNewServ"));
$ArticaMetaHost = $ArticaMetaAddNewServ["ArticaMetaHost"];
$ArticaMetaPort = $ArticaMetaAddNewServ["ArticaMetaPort"];
$ArticaMetaUsername = $ArticaMetaAddNewServ["ArticaMetaUsername"];
$ArticaMetaPassword = $ArticaMetaAddNewServ["ArticaMetaPassword"];
$change_uuid = $ArticaMetaAddNewServ["change_uuid"];
echo "ArticaMetaHost.........: {$ArticaMetaHost}\n";
echo "ArticaMetaPort.........: {$ArticaMetaPort}\n";
echo "ArticaMetaUsername.....: {$ArticaMetaUsername}\n";
echo "Testing authentication...\n";
add_node_progress("Authenticate to {$ArticaMetaHost}:{$ArticaMetaPort}", 10);
$array["username"] = $ArticaMetaUsername;
$array["password"] = $ArticaMetaPassword;
$ident = urlencode(base64_encode(serialize($array)));
$curl = new ccurl("https://{$ArticaMetaHost}:{$ArticaMetaPort}/artica.meta.listener.php?test-local-ident={$ident}");
$curl->NoHTTP_POST = true;
$curl->NoLocalProxy();
$curl->Timeout = 120;
if (!$curl->get()) {
echo @implode("\n", $curl->errors);
add_node_progress("{$curl->error}", 110);
die;
}
if (!preg_match("#<ARTICA_META>(.+?)</ARTICA_META>#is", $curl->data, $re)) {
echo "Expected <ARTICA_META>Someting...</ARTICA_META>";
add_node_progress("Communication: {failed}", 110);
die;
}
if ($re[1] != "SUCCESS") {
add_node_progress("Authenticate: {failed}", 110);
die;
}
echo "Testing authentication - success -...\n";
if ($change_uuid == 1) {
echo "Ask to remote server to change UUID...\n";
add_node_progress("{change_uuid}", 20);
$curl = new ccurl("https://{$ArticaMetaHost}:{$ArticaMetaPort}/artica.meta.listener.php?local-ident={$ident}&chuuid=yes");
$curl->NoHTTP_POST = true;
$curl->NoLocalProxy();
$curl->Timeout = 120;
if (!$curl->get()) {
echo @implode("\n", $curl->errors);
add_node_progress("{$curl->error}", 110);
die;
}
if (!preg_match("#<ARTICA_META>(.+?):(.+?)</ARTICA_META>#is", $curl->data, $re)) {
add_node_progress("{change_uuid}: Communication: {failed}", 110);
die;
}
add_node_progress("{change_uuid}:{$re[2]} {success}", 25);
echo "Ask to remote server to change UUID - success -...\n";
}
echo "Ask UUID to remote server...\n";
add_node_progress("{uuid}:", 30);
$curl = new ccurl("https://{$ArticaMetaHost}:{$ArticaMetaPort}/artica.meta.listener.php?local-ident={$ident}&GetYourUUID=yes");
$curl->NoHTTP_POST = true;
$curl->NoLocalProxy();
$curl->Timeout = 120;
if (!$curl->get()) {
echo @implode("\n", $curl->errors);
add_node_progress("{$curl->error}", 110);
die;
}
if (!preg_match("#<ARTICA_META>(.+?):(.+?)</ARTICA_META>#is", $curl->data, $re)) {
add_node_progress("{uuid}: Communication: {failed}", 110);
die;
}
$RESULT = $re[1];
$uuid = $re[2];
echo "UUID results:\n---------------------------------------------\n{$uuid}\n{$RESULT}\n---------------------------------------------\n";
if ($RESULT == "SUCCESS") {
add_node_progress("{uuid}: {$uuid} {success}", 35);
} else {
add_node_progress("{uuid}: {failed}", 110);
return;
}
echo "Ask to remote server to register to Artica Meta server ...\n";
add_node_progress("{order}: -> {register}", 50);
$ArticaMetaServerUsername = $sock->GET_INFO("ArticaMetaServerUsername");
$ArticaMetaServerPassword = $sock->GET_INFO("ArticaMetaServerPassword");
$ArticaMetaAddNewServ["ArticaMetaUsername"] = $ArticaMetaServerUsername;
$ArticaMetaAddNewServ["ArticaMetaPassword"] = $ArticaMetaServerPassword;
if ($GLOBALS["VERBOSE"]) {
$verbosed = "&verbose=yes";
}
$ArticaMetaAddNewServ_enc = urlencode(base64_encode(serialize($ArticaMetaAddNewServ)));
$curl = new ccurl("https://{$ArticaMetaHost}:{$ArticaMetaPort}/artica.meta.listener.php?local-ident={$ident}®isterby={$ArticaMetaAddNewServ_enc}{$verbosed}");
$curl->NoHTTP_POST = true;
$curl->NoLocalProxy();
$curl->Timeout = 120;
if (!$curl->get()) {
echo @implode("\n", $curl->errors);
add_node_progress("{$curl->error}", 110);
die;
}
if ($GLOBALS["VERBOSE"]) {
echo "***********************************\n{$curl->data}\n***********************************\n";
//.........这里部分代码省略.........