---
# System prepended metadata

title: Nigeria Studies

---


# Nigeria Studies

mongodb-collectdata2020.alwaysdata.net

db:collectdata2020_q1



collectdata2020_user
Koneali11

c


Creation de 4 colletions 

"""

import os
from pymongo import MongoClient
import uuid
from datetime import datetime
now = datetime.now()
dt_string = now.strftime("%d/%m/%Y %H:%M:%S")

uuidOne = uuid.uuid1()
data={}

data['createdAt']=str(dt_string)

f = open("datainitial.data", "r")
el=f.read()
for el1 in el.split('&amp;&amp;&amp;'):
    ligne=el1.split('##')
    if len(ligne)>1:
       data[ligne[0]]=ligne[1]
f.close()



#data={'Status':1,'db':1,'dc':2}

name_collection='Q1'
stringconect='mongodb://collectdata2020_user:Koneali11@mongodb-collectdata2020.alwaysdata.net:27017/?authSource=collectdata2020_q1&readPreference=primary&appname=MongoDB%20Compass%20Community&ssl=false'
client = MongoClient(stringconect)
exec("db=client.collectdata2020_q1")
db[name_collection].insert_one(data)

""""

<?php
/*$_POST["name"];

function get_client_ip_server() {
    $ipaddress = '';
    if ($_SERVER['HTTP_CLIENT_IP'])
        $ipaddress = $_SERVER['HTTP_CLIENT_IP'];
    else if($_SERVER['HTTP_X_FORWARDED_FOR'])
        $ipaddress = $_SERVER['HTTP_X_FORWARDED_FOR'];
    else if($_SERVER['HTTP_X_FORWARDED'])
        $ipaddress = $_SERVER['HTTP_X_FORWARDED'];
    else if($_SERVER['HTTP_FORWARDED_FOR'])
        $ipaddress = $_SERVER['HTTP_FORWARDED_FOR'];
    else if($_SERVER['HTTP_FORWARDED'])
        $ipaddress = $_SERVER['HTTP_FORWARDED'];
    else if($_SERVER['REMOTE_ADDR'])
        $ipaddress = $_SERVER['REMOTE_ADDR'];
    else
        $ipaddress = 'UNKNOWN';
 
    return $ipaddress;
}


$date =str_replace('-', '_',date_format(date_create(), 'Y-m-d H:i:s'));
$date =str_replace(':', '_',$date);

*/
$position=substr(strval($_SERVER['DOCUMENT_ROOT']),0, -9);
$chemin_destination = "datainitial.data";
$myfile = fopen($chemin_destination, "w") or die("Unable to open file!");
shell_exec('python3 script.py');
echo "<script> window.location.href = 'https://datacollect2019.alwaysdata.net';</script>";
/*
$m = new Mongo("mongodb://datacollect2019:Koneali11@mongodb-datacollect2019.alwaysdata.com");
var_dump($m);
$db = $m->selectDB('datacollect2019_isa');
$collection = new MongoCollection($db, 'database');
$person = array("name" => "Joe", "age" => 20);
$collection->insert($person);
$cursor = $collection->find();
foreach ($cursor as $doc) {
    var_dump($doc);
}

*/

?>

fwrite($myfile,htmlspecialchars($_POST["data"]));
fwrite($myfile, "&&&");     
fclose($myfile);

echo $_POST["name"];
