forked from noncent/instagram-data-scraper
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Helper.php
executable file
·70 lines (64 loc) · 1.69 KB
/
Helper.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
70
<?php
/**
* @param array $data
*/
function pre($data = array())
{
echo '<pre>', print_r($data, true), '</pre>';
exit(4);
}
/**
* [error_404 description]
* @return [type] [description]
*/
function error_404()
{
exit("404: Request page not found");
}
/**
* Check if Server Supports htaccess
* @return boolean [description]
*/
function is_htaccess_enable()
{
// check if mode re_write enabled or not
if (!in_array('mod_rewrite', apache_get_modules()) || !isset($_SERVER['HTACCESS'])) {
return false;
} else {
return true;
}
}
function fetchInstaImages ($url)
{
// instagram only has jpeg images for now..
header("Content-type: image/jpeg");
readfile( $url );
}
/**
* Create log file with data
*
* @param [type] $file_name
* @param [type] $anything
* @return void
*/
function write_log($file_name, $anything)
{
global $config;
if ($config['logs'] === true) {
// first check if log folder exists
if (is_dir($config['log_folder']) && is_writable($config['log_folder'])) {
// log file name
if (!isset($file_name)) {
$file_name = $config['log_folder'] . "/" . $config['log_file_name'];
}
// catch each request data
file_put_contents($config['log_folder'] . "/" . $file_name, $anything, FILE_APPEND);
// separator
file_put_contents($config['log_folder'] . "/" . $file_name, PHP_EOL . str_repeat('+', 25) . PHP_EOL, FILE_APPEND);
} else {
// Make sure the log folder is writable
mkdir($config['log_folder']);
chmod($config['log_folder'], $config['file_folder_permission']);
}
}
}