-
Notifications
You must be signed in to change notification settings - Fork 8
/
Copy pathconfig.php
executable file
·70 lines (63 loc) · 1.81 KB
/
config.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
<?php
/**
* config class for storing constants
*/
class config {
//db config
protected $username = '';
protected $password = '';
protected $hostname = '';
protected $dbname = '';
public $db = '';
public $url= '';
public $resHtml = '';
public $channelName = '';
function __construct($channel_name){
require_once 'vendor/autoload.php';
$dotenv = new Dotenv\Dotenv(__DIR__);
$dotenv->load();
$this->hostname = getenv('DB_HOST');
$this->username = getenv('DB_USERNAME');
$this->password = getenv('DB_PASSWORD');
$this->dbname = getenv('DB_DATABASE');
$this->channelName = $channel_name;
$this->db = mysqli_connect($this->hostname,$this->username,$this->password,$this->dbname);
}
function http($url){
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
$data = curl_exec($ch);
curl_close($ch);
return $data;
}
function str_replace_gizmodization($str){
$data = str_replace('dainik','',$str);
$data = str_replace('Dainik','',$data);
$data = str_replace('bhaskar','',$data);
$data = str_replace('Bhaskar','',$data);
return $data."".$this->channelName." Channel. Subscribe to our channel ".$this->channelName." for latest updates";
}
}
/**
*
*/
class Processing extends config
{
public $save_to;
function __construct($channel_name,$save_to)
{
$this->save_to = $save_to;
parent::__construct($channel_name);
}
function processAllPost(){
$save_loc = $this->save_to;
$res = mysqli_query($this->db,"SELECT pid FROM dainik_bhasker WHERE processed=0");
while($data = mysqli_fetch_assoc($res)) {
$i = $data['pid'];
echo PHP_EOL." Processing post -> $i ".PHP_EOL;
exec("bash tts \"$save_loc/$i\" > /dev/null 2>&1 ");
}
}
}