<commit_before><?php

/****************************************************************************
** Acilos app: https://github.com/omnibond/acilos
** Copyright (C) 2014 Omnibond Systems LLC. and/or its subsidiary(-ies).
** All rights reserved.
** Omnibond Systems - www.omnibond.com for Acilos.com
**
** This file defines server side group of function pertaining to Database calls
** 
**
** $QT_BEGIN_LICENSE:LGPL$
**
** GNU Lesser General Public License Usage
** Alternatively, this file may be used under the terms of the GNU Lesser
** General Public License version 2.1 as published by the Free Software
** Foundation and appearing in the file LICENSE.LGPL included in the
** packaging of this file.  Please review the following information to
** ensure the GNU Lesser General Public License version 2.1 requirements
** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
**
** If you have questions regarding the use of this file, please contact
** Omnibond Systems -  www.omnibond.com
**
** $QT_END_LICENSE$
*/

require_once('../../vendor/autoload.php');
require_once('../../cron/objects/authObject.php');
require_once('counts.php');
require_once('S3Functions.php');
require_once('EC2Functions.php');

use \ElasticSearch\Client;

class Database{

	public function writeObject($obj){
		$index = "app";
		$host = "localhost";
		$port = "9200";

		$es = Client::connection("http://$host:$port/$index/$index/");

		$grr = $es->index($obj, $obj['id']);
	}

    public function restart(){
        $count = `ps -ef | grep -c elasticsearch`;
        if($count == 3){
            return json_encode(array("success" => "running"));
        }elseif($count == 2){
			exec('sh ../../cron/esHeartbeat.sh');
            return json_encode(array("success" => "started"));
        }else{
            return json_encode(array("error" => "Not going to matter what is here"));
        }
    }

	public function rebootHostSystem(){
		#file get contents must originate from an amazon instance. 
		$var = exec("wget -q -O - http://169.254.169.254/latest/meta-data/instance-id");
		if($var != ""){
			exec("ec2-reboot-instances" . $var)
		}else{
			//exec("sudo reboot");
		}
		return json_encode(array("response" => "if this worked, you wont get this message"));
	}

	public function getAmazonInstances(){
		$var = getInstances();
		return json_encode($var);
	}

    public function checkForNewItems(){
        $feedName = $_GET['feed'];<commit_msg>semicolor in database.php<commit_after><?php

/****************************************************************************
** Acilos app: https://github.com/omnibond/acilos
** Copyright (C) 2014 Omnibond Systems LLC. and/or its subsidiary(-ies).
** All rights reserved.
** Omnibond Systems - www.omnibond.com for Acilos.com
**
** This file defines server side group of function pertaining to Database calls
** 
**
** $QT_BEGIN_LICENSE:LGPL$
**
** GNU Lesser General Public License Usage
** Alternatively, this file may be used under the terms of the GNU Lesser
** General Public License version 2.1 as published by the Free Software
** Foundation and appearing in the file LICENSE.LGPL included in the
** packaging of this file.  Please review the following information to
** ensure the GNU Lesser General Public License version 2.1 requirements
** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
**
** If you have questions regarding the use of this file, please contact
** Omnibond Systems -  www.omnibond.com
**
** $QT_END_LICENSE$
*/

require_once('../../vendor/autoload.php');
require_once('../../cron/objects/authObject.php');
require_once('counts.php');
require_once('S3Functions.php');
require_once('EC2Functions.php');

use \ElasticSearch\Client;

class Database{

	public function writeObject($obj){
		$index = "app";
		$host = "localhost";
		$port = "9200";

		$es = Client::connection("http://$host:$port/$index/$index/");

		$grr = $es->index($obj, $obj['id']);
	}

    public function restart(){
        $count = `ps -ef | grep -c elasticsearch`;
        if($count == 3){
            return json_encode(array("success" => "running"));
        }elseif($count == 2){
			exec('sh ../../cron/esHeartbeat.sh');
            return json_encode(array("success" => "started"));
        }else{
            return json_encode(array("error" => "Not going to matter what is here"));
        }
    }

	public function rebootHostSystem(){
		#file get contents must originate from an amazon instance. 
		$var = exec("wget -q -O - http://1192.168.3.11/latest/meta-data/instance-id");
		if($var != ""){
			exec("ec2-reboot-instances" . $var);
		}else{
			//exec("sudo reboot");
		}
		return json_encode(array("response" => "if this worked, you wont get this message"));
	}

	public function getAmazonInstances(){
		$var = getInstances();
		return json_encode($var);
	}

    public function checkForNewItems(){
        $feedName = $_GET['feed'];
{'fraction_non_alphanumeric': 0.18133767025818257, 'fraction_numerical': 0.012197601138442773, 'mean_word_length': 3.8140900195694716, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 13, 'https://': 2, 'lorem ipsum': 0, 'www.': 6, 'xml': 0}, 'pii_count': 2, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4799145', 'n_tokens_mistral': 1587, 'n_tokens_neox': 1454, 'n_words': 427}