function requestAndDisplayCompany($company) { // echo $response; $companies = fetch('GET', "/v1/company-search?keywords=" . urlencode($company) . "&country-code=us&facet=location,us:0&hq-only=true&"); if ($companies === FALSE) { restart(); } else { ?> <html> <head> <title>Companies</title> </head> <body> <h1>Expires at: <?php date_default_timezone_set('America/Los_Angeles'); echo date('l jS \\of F Y h:i:s A', $_SESSION['expires_at']); ?> </h1> <br><br> <h1><?php echo $companies; ?> </h1> </body> </html> <?php } }
function reset_passwd() { global $account_id; $passwd = get_rand_passwd(8); $sql = "UPDATE `user` SET passwd = '{$passwd}' WHERE `id` = '{$account_id}'"; mysql_query($sql); restart(); return $passwd; }
/** * Script shutdown callback * * @return void */ function on_shutdown() { global $exit_status, $pid_file; switch ($exit_status) { case "error": outln("Server stopped unexpectedly, trying to restart."); restart(); break; case "restart": outln("Restarting ..."); @unlink($pid_file); outln("Server stopped."); restart(); break; default: outln("Server stopped."); @unlink($pid_file); break; } }
/** * \brief check to see if fossology is configured into apache. If not copy the * config file and configure it. Restart apache if configured. * * @param string $osType type of the os, e.g. Debian, Ubuntu, Red, Fedora * * @return boolean */ function configApache2($osType) { if (empty($osType)) { return FALSE; } switch ($osType) { case 'Ubuntu': case 'Debian': if (is_link('/etc/apache2/conf.d/fossology')) { break; } else { // copy config file, create sym link if (!copy('../dataFiles/pkginstall/fo-apache.conf', '/etc/fossology/fo-apache.conf')) { echo "FATAL!, Cannot configure fossology into apache2\n"; return FALSE; } if (!symlink('/etc/fossology/fo-apache.conf', '/etc/apache2/conf.d/fossology')) { echo "FATAL! Could not create symlink in /etc/apache2/conf.d/ for fossology\n"; return FALSE; } // restart apache so changes take effect if (!restart('apache2')) { echo "Erorr! Could not restart apache2, please restart by hand\n"; return FALSE; } } break; case 'Red': // copy config file, no symlink needed for redhat if (!copy('../dataFiles/pkginstall/fo-apache.conf', '/etc/httpd/conf.d/fossology.conf')) { echo "FATAL!, Cannot configure fossology into apache2\n"; return FALSE; } // restart apapche so changes take effect if (!restart('httpd')) { echo "Erorr! Could not restart httpd, please restart by hand\n"; return FALSE; } break; default: break; } return TRUE; }
include_once dirname(__FILE__) . '/ressources/class.squid.inc'; include_once dirname(__FILE__) . '/ressources/class.system.network.inc'; $GLOBALS["ARGVS"] = implode(" ", $argv); if ($argv[1] == "--stop") { $GLOBALS["OUTPUT"] = true; stop(); die; } if ($argv[1] == "--start") { $GLOBALS["OUTPUT"] = true; start(); die; } if ($argv[1] == "--restart") { $GLOBALS["OUTPUT"] = true; restart(); die; } if ($argv[1] == "--reload") { $GLOBALS["OUTPUT"] = true; reload(); die; } if ($argv[1] == "--build") { $GLOBALS["OUTPUT"] = true; build(); die; } if ($argv[1] == "--clean") { $GLOBALS["OUTPUT"] = true; cleanstorage();
/** * \brief config a debian based system to install fossology. * * copy postgres, php config files so that fossology can run. * * @param string $osType either Debian or Ubuntu * @param string $osVersion the particular version to install * * @return boolean */ function configDebian($osType, $osVersion) { if (empty($osType)) { return FALSE; } if (empty($osVersion)) { return FALSE; } // based on type read the appropriate ini file. //echo "DB:configD: osType is:$osType\n"; //echo "DB:configD: osversion is:$osVersion\n"; // can't check in pg_hba.conf as it shows HP's firewall settings, get it // internally // No need to update pg_hba.conf file //getPGhba('../dataFiles/pkginstall/debian/6/pg_hba.conf'); $debPath = '../dataFiles/pkginstall/debian/6/'; $psqlFiles = array($debPath . 'postgresql.conf'); switch ($osVersion) { case '6.0': echo "debianConfig got os version 6.0!\n"; // copy config files /* * Change the structure of data files: * e.g. debian/5/pg_hba..., etc, all files that go with this version * debian/6/pg_hba.... * and use a symlink for the 'codename' squeeze -> debian/6/ */ try { copyFiles($psqlFiles, "/etc/postgresql/8.4/main"); } catch (Exception $e) { echo "Failure: Could not copy postgres 8.4 config file\n"; } try { copyFiles($debPath . 'cli-php.ini', '/etc/php5/cli/php.ini'); } catch (Exception $e) { echo "Failure: Could not copy php.ini to /etc/php5/cli/php.ini\n"; return FALSE; } try { copyFiles($debPath . 'apache2-php.ini', '/etc/php5/apache2/php.ini'); } catch (Exception $e) { echo "Failure: Could not copy php.ini to /etc/php5/apache2/php.ini\n"; return FALSE; } break; case '10.04.3': case '11.04': case '11.10': try { copyFiles($psqlFiles, "/etc/postgresql/8.4/main"); } catch (Exception $e) { echo "Failure: Could not copy postgres 8.4 config file\n"; } try { copyFiles($debPath . 'cli-php.ini', '/etc/php5/cli/php.ini'); } catch (Exception $e) { echo "Failure: Could not copy php.ini to /etc/php5/cli/php.ini\n"; return FALSE; } try { copyFiles($debPath . 'apache2-php.ini', '/etc/php5/apache2/php.ini'); } catch (Exception $e) { echo "Failure: Could not copy php.ini to /etc/php5/apache2/php.ini\n"; return FALSE; } break; case '12.04.1': case '12.10': //postgresql-9.1 can't use 8.4 conf file /* try { copyFiles($psqlFiles, "/etc/postgresql/9.1/main"); } catch (Exception $e) { echo "Failure: Could not copy postgres 9.1 config file\n"; } */ try { copyFiles($debPath . 'cli-php.ini', '/etc/php5/cli/php.ini'); } catch (Exception $e) { echo "Failure: Could not copy php.ini to /etc/php5/cli/php.ini\n"; return FALSE; } try { copyFiles($debPath . 'apache2-php.ini', '/etc/php5/apache2/php.ini'); } catch (Exception $e) { echo "Failure: Could not copy php.ini to /etc/php5/apache2/php.ini\n"; return FALSE; } break; default: return FALSE; // unsupported debian version break; } // restart apache and postgres so changes take effect if (!restart('apache2')) { echo "Erorr! Could not restart apache2, please restart by hand\n"; return FALSE; } // Get the postrgres version so the correct file is used. $pName = 'postgresql'; if ($osVersion == '10.04.3') { $ver = findVerPsql(); //echo "DB: returned version is:$ver\n"; $pName = 'postgresql-' . $ver; } echo "DB pName is:{$pName}\n"; if (!restart($pName)) { echo "Erorr! Could not restart {$pName}, please restart by hand\n"; return FALSE; } return TRUE; }
function rotate() { $unix = new unix(); $pidfile = "/etc/artica-postfix/pids/" . basename(__FILE__) . "." . __FUNCTION__ . ".pid"; $TimeFile = "/etc/artica-postfix/pids/" . basename(__FILE__) . "." . __FUNCTION__ . ".time"; if ($GLOBALS["VERBOSE"]) { echo "TimeFile={$TimeFile}\n"; } $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()); $xtime = $unix->file_time_min($TimeFile); if (!$GLOBALS['VERBOSE']) { if ($xtime < 5) { return; } } @unlink($TimeFile, time()); @file_put_contents($TimeFile, time()); $q = new mysql(); $echo = $unix->find_program("echo"); if (!$q->DATABASE_EXISTS("bwmng")) { $q->CREATE_DATABASE("bwmng"); } if (!$q->DATABASE_EXISTS("bwmng", true)) { return; } @copy("/home/artica/bwm-ng/interfaces.csv", "/home/artica/bwm-ng/interfaces.csv." . time()); @unlink("/home/artica/bwm-ng/interfaces.csv"); $files = $unix->DirFiles("/home/artica/bwm-ng"); if (system_is_overloaded(__FILE__)) { if ($GLOBALS["VERBOSE"]) { echo "OVERLOADED !!!!\n"; } return; } while (list($filename, $notused) = each($files)) { if ($filename == "interfaces.csv") { continue; } $filepath = "/home/artica/bwm-ng/{$filename}"; $filetime = $unix->file_time_min($filepath); if ($filetime > 60) { @unlink($filepath); continue; } if ($GLOBALS["VERBOSE"]) { echo "Open {$filepath} {$filetime}mn\n"; } $row = 1; if (($handle = fopen($filepath, "r")) !== FALSE) { while (($data = fgetcsv($handle, 1000, ";")) !== FALSE) { $num = count($data); if ($num == 0) { continue; } $row++; $uniq_key = md5(serialize($data)); $Unix_Timestamp = $data[0]; if (!is_numeric($Unix_Timestamp)) { continue; } $Interface_Name = $data[1]; if (trim($Interface_Name) == null) { print_r($data); continue; } $BytesOut = intval($data[2]); $BytesIn = intval($data[3]); $BytesTotal = $data[4]; $PacketsOut = $data[5]; $PacketsIn = $data[6]; $PacketsTotal = $data[7]; if ($BytesOut == 0 && $BytesIn == 0) { continue; } $Date = date("Y-m-d H:i:s", $Unix_Timestamp); $tableT = date("YmdH", $Unix_Timestamp) . "_bwmrt"; if ($Interface_Name == "total") { $array_total[$tableT][] = "('{$uniq_key}','{$Date}','{$BytesOut}','{$BytesIn}')"; continue; } $table = date("YmdH", $Unix_Timestamp) . "_bwmrh"; $array_eths[$table][] = "('{$uniq_key}','{$Interface_Name}','{$Date}','{$BytesOut}','{$BytesIn}')"; } fclose($handle); if (system_is_overloaded(__FILE__)) { break; } } if ($GLOBALS["VERBOSE"]) { echo "{$filepath} CLOSED: " . count($array_eths) . " eths, " . count($array_total) . " total\n"; } if (array_to_interfaces($array_eths)) { if (array_to_total($array_total)) { if ($GLOBALS["VERBOSE"]) { echo "{$filepath} > DELETE\n"; } @unlink($filepath); } } else { @unlink($filepath); } $array_eths = array(); $array_total = array(); } restart(true); if (system_is_overloaded(__FILE__)) { if ($GLOBALS["VERBOSE"]) { echo "OVERLOADED !!!!\n"; } return; } build_days(); build_current_time(); }
function AutoInstall() { $unix = new unix(); $pidfile = "/etc/artica-postfix/pids/" . basename(__FILE__) . "." . __FUNCTION__ . ".pid"; $pidTime = "/etc/artica-postfix/pids/exec.ufdbcat.php.AutoInstall.time"; $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()); $TimeExec = $unix->file_time_min($pidTime); if ($TimeExec < 240) { if ($GLOBALS["OUTPUT"]) { echo "Starting......: " . date("H:i:s") . " [INIT]: {$GLOBALS["TITLENAME"]} {$TimeExec}, need 240mn\n"; } die; } @unlink($pidTime); @file_put_contents($pidTime, time()); include_once dirname(__FILE__) . "/ressources/class.ccurl.inc"; $curl = new ccurl("http://articatech.net/download/ufdbcat-x64-1.31.tar.gz"); $tempfile = $unix->TEMP_DIR() . "/ufdbcat-x64-1.31.tar.gz"; if (!$curl->GetFile($tempfile)) { squid_admin_mysql(0, "Unable to download http://articatech.net/download/ufdbcat-x64-1.31.tar.gz", null, __FILE__, __LINE__); return; } $tar = $unix->find_program("tar"); shell_exec("{$tar} xf {$tempfile} -C /"); if (!is_file("/etc/artica-postfix/UFDBCAT_INSTALLED")) { squid_admin_mysql(0, "Unable to install ufdbcat-x64-1.31.tar.gz package", null, __FILE__, __LINE__); return; } squid_admin_mysql(2, "Success installed Categories Service TCP/IP version", null, __FILE__, __LINE__); restart(true); }
function islighttpd_error_500() { $sock = new sockets(); $unix = new unix(); $unix = new unix(); $pidfile = "/etc/artica-postfix/pids/" . basename(__FILE__) . "." . __FUNCTION__ . ".pid"; $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]: Already Artica task running PID {$pid} since {$time}mn\n"; } return; } @file_put_contents($pidfile, getmypid()); $curl = $unix->find_program("curl"); if (!is_file($curl)) { return; } $LighttpdArticaListenIP = $sock->GET_INFO('LighttpdArticaListenIP'); $ArticaHttpsPort = 9000; $ArticaHttpUseSSL = 1; $ArticaHttpsPort = $sock->GET_INFO("ArticaHttpsPort"); $ArticaHttpUseSSL = $sock->GET_INFO("ArticaHttpUseSSL"); if (!is_numeric($ArticaHttpUseSSL)) { $ArticaHttpUseSSL = 1; } if (!is_numeric($ArticaHttpsPort)) { $ArticaHttpsPort = "9000"; } $EnableArticaFrontEndToNGninx = $sock->GET_INFO("EnableArticaFrontEndToNGninx"); if (!is_numeric($EnableArticaFrontEndToNGninx)) { $EnableArticaFrontEndToNGninx = 0; } $proto = "http"; if ($ArticaHttpUseSSL == 1) { $proto = "https"; } if ($LighttpdArticaListenIP != null) { $IPS = $unix->NETWORK_ALL_INTERFACES(true); if (!isset($IPS[$LighttpdArticaListenIP])) { $LighttpdArticaListenIP = null; } } if (strlen($LighttpdArticaListenIP) > 3) { $ips[$LighttpdArticaListenIP] = true; $uri = "{$proto}://{$LighttpdArticaListenIP}:{$ArticaHttpsPort}/logon.php"; } else { $ips = $unix->NETWORK_ALL_INTERFACES(true); unset($ips["127.0.0.1"]); } while (list($ipaddr, $line) = each($ips)) { $f = array(); $results = array(); $uri = "{$proto}://{$ipaddr}:{$ArticaHttpsPort}/logon.php"; $f[] = "{$curl} -I --connect-timeout 5"; $f[] = "--insecure"; $f[] = "--interface {$ipaddr}"; $f[] = "--url {$uri} 2>&1"; $cmdline = @implode(" ", $f); if ($GLOBALS['VERBOSE']) { echo "{$cmdline}\n"; } exec(@implode(" ", $f), $results); if ($GLOBALS['VERBOSE']) { echo count($results) . " rows\n"; } if (DetectError($results, "Artica Web Interface")) { if ($EnableArticaFrontEndToNGninx == 1) { shell_exec("/etc/init.d/nginx restart"); } else { restart(true); } } } $results = array(); if ($GLOBALS['VERBOSE']) { echo "done\n"; } }
function delete_databases() { $PossibleDirs[] = "/var/lib/ufdbartica"; $PossibleDirs[] = "/home/ufdbcat"; $PossibleDirs[] = "/var/lib/ftpunivtlse1fr"; $unix = new unix(); build_progress_delete("{delete} {databases}", 10); $rm = $unix->find_program("rm"); while (list($index, $Directory) = each($PossibleDirs)) { if (!is_dir($Directory)) { continue; } build_progress_delete("{delete} {$Directory}", 50); shell_exec("{$rm} -rf {$Directory}/"); } build_progress_delete("{reconfigure}", 80); $php = $unix->LOCATE_PHP5_BIN(); $files["/usr/share/artica-postfix/ressources/logs/ARTICA_DBS_STATUS_FULL.db"] = true; $files["/usr/share/artica-postfix/ressources/logs/web/cache/articatechdb.progress"] = true; $files["/usr/share/artica-postfix/ressources/logs/web/cache/toulouse.progress"] = true; $files["/usr/share/artica-postfix/ressources/logs/web/cache/webfilter-artica.progress"] = true; $files["/etc/artica-postfix/settings/Daemons/TLSEDbCloud"] = true; $files["/etc/artica-postfix/settings/Daemons/ArticaDbCloud"] = true; $files["/etc/artica-postfix/settings/Daemons/CurrentArticaDbCloud"] = true; $files["/etc/artica-postfix/settings/Daemons/CurrentTLSEDbCloud"] = true; $files["/usr/share/artica-postfix/ressources/logs/web/cache/webfilter-artica.progress"] = true; while (list($index, $Directory) = each($files)) { @unlink($index); } system("{$php} /usr/share/artica-postfix/exec.squidguard.php --build --force"); build_progress_delete("{restarting_service}", 90); system("/etc/init.d/ufdb restart --force"); restart(true); build_progress_delete("{done}", 100); }
function WIZARD_PROGRESS() { build_progress("{activate_the_service}", 5); $unix = new unix(); $sock = new sockets(); $sock->SET_INFO("EnableArticaHotSpot", 1); build_progress("{stopping_firewall}", 6); $sock->SET_INFO("FireHolEnable", 0); shell_exec("/usr/local/sbin/firehol stop"); $SquidHotSpotPort = intval($sock->GET_INFO("SquidHotSpotPort")); $ArticaHotSpotPort = intval($sock->GET_INFO("ArticaHotSpotPort")); $ArticaSSLHotSpotPort = $sock->GET_INFO("ArticaSSLHotSpotPort"); $ArticaSplashHotSpotPort = $sock->GET_INFO("ArticaSplashHotSpotPort"); $ArticaSplashHotSpotPortSSL = $sock->GET_INFO("ArticaSplashHotSpotPortSSL"); $ArticaSplashHotSpotCertificate = $sock->GET_INFO("ArticaSplashHotSpotCertificate"); $SquidHotSpotSSLPort = intval($sock->GET_INFO("SquidHotSpotSSLPort")); $WifiDogDebugLevel = intval($sock->GET_INFO("WifiDogDebugLevel")); $ArticaHotSpotInterface2 = $sock->GET_INFO("ArticaHotSpotInterface2"); $ArticaHotSpotEnableMIT = $sock->GET_INFO("ArticaHotSpotEnableMIT"); $ArticaHotSpotEnableProxy = $sock->GET_INFO("ArticaHotSpotEnableProxy"); if (!is_numeric($ArticaHotSpotEnableMIT)) { $ArticaHotSpotEnableMIT = 1; } if (!is_numeric($ArticaHotSpotEnableProxy)) { $ArticaHotSpotEnableProxy = 1; } if (!is_numeric($ArticaHotSpotPort)) { $ArticaHotSpotPort = 0; } if (!is_numeric($ArticaSplashHotSpotPort)) { $ArticaSplashHotSpotPort = 16080; } if (!is_numeric($ArticaSplashHotSpotPortSSL)) { $ArticaSplashHotSpotPortSSL = 16443; } $php = $unix->LOCATE_PHP5_BIN(); if ($ArticaHotSpotPort == 0) { $ArticaHotSpotPort = rand(38000, 64000); $sock->SET_INFO("ArticaHotSpotPort", $ArticaHotSpotPort); } if ($ArticaSSLHotSpotPort == 0) { $ArticaSSLHotSpotPort = rand(38500, 64000); $sock->SET_INFO("ArticaSSLHotSpotPort", $ArticaSSLHotSpotPort); } if ($SquidHotSpotPort == 0) { $SquidHotSpotPort = rand(40000, 64000); $sock->SET_INFO("SquidHotSpotPort", $SquidHotSpotPort); } if ($SquidHotSpotSSLPort == 0) { $SquidHotSpotSSLPort = rand(40500, 64000); $sock->SET_INFO("SquidHotSpotSSLPort", $SquidHotSpotSSLPort); } build_progress("{reconfigure_proxy_service}", 10); shell_exec("{$php} /usr/share/artica-postfix/exec/squid.php --build --force"); restart(true, true); }
include_once dirname(__FILE__) . '/framework/class.unix.inc'; include_once dirname(__FILE__) . '/framework/frame.class.inc'; include_once dirname(__FILE__) . '/framework/class.settings.inc'; include_once dirname(__FILE__) . "/ressources/class.resolv.conf.inc"; include_once dirname(__FILE__) . "/ressources/class.system.network.inc"; include_once dirname(__FILE__) . "/ressources/class.system.nics.inc"; include_once dirname(__FILE__) . "/framework/class.unix.inc"; include_once dirname(__FILE__) . "/framework/frame.class.inc"; include_once dirname(__FILE__) . "/ressources/class.os.system.inc"; include_once dirname(__FILE__) . "/ressources/class.tcpip.inc"; if ($argv[1] == "--menu") { menu(); exit; } if ($argv[1] == "--restart") { restart($argv[2]); exit; } if ($argv[1] == "--savenic") { savenic($argv[2]); exit; } if ($argv[1] == "--savedns") { savedns(); exit; } if ($argv[1] == "--reconfigure") { reconfigure(); exit; } if ($argv[1] == "--uuid") {
function reconfigure_progress() { $unix = new unix(); $php = $unix->LOCATE_PHP5_BIN(); $EnableSuricata = intval(@file_get_contents("/etc/artica-postfix/settings/Daemons/EnableSuricata")); if ($EnableSuricata == 1) { build_progress_reconfigure("{restarting} Suricata", 15); shell_exec("{$php} /usr/share/artica-postfix/exec.initslapd.php --suricata"); shell_exec("{$php} /usr/share/artica-postfix/exec.initslapd.php --barnyard2"); build_progress_reconfigure("{restarting} Suricata", 20); echo "Restarting service....\n"; restart(true); build_progress_reconfigure("{restarting} barnyard", 30); system("/etc/init.d/barnyard restart"); build_progress_reconfigure("{reconfigure} pulledpork", 40); pulledpork_conf(); build_progress_reconfigure("{reconfigure} pulledpork", 45); disablesid(); build_progress_reconfigure("{reconfigure} Dashboard", 50); suricata_dashboard(); pulledpork_run(); if (!installapt()) { build_progress_reconfigure("{reconfigure} {failed}", 110); return; } build_progress_reconfigure("{reconfigure} {done}", 100); } else { build_progress_reconfigure("{stopping} Suricata", 20); stop(true); build_progress_reconfigure("{stopping} barnyard", 30); system("/etc/init.d/barnyard stop"); build_progress_reconfigure("{stopping} tail", 40); system("/etc/init.d/suricata-tail stop"); build_progress_reconfigure("{stopping} {done}", 100); } }