-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathclsTwitterDB.php
84 lines (70 loc) · 1.54 KB
/
clsTwitterDB.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
71
72
73
74
75
76
77
78
79
80
81
82
83
84
<?php
require_once('config.php');
/**
* Description of clsTwitterDB
*
* @author andre
*/
class clsTwitterDB
{
private $server = SERVERDB;
private $user = USERDB;
private $pass = PASSDB;
private $con;
private $db = DB;
private $log = LOGDB;
private $text = "";
private $author = "";
private $contact_email = CONTACTEMAIL;
/* Database connection */
function __construct()
{
$this->con = @mysql_connect($this->server,$this->user,$this->pass) or die(mysql_error());
@mysql_select_db($this->db,$this->con);
}
function setText($text=null)
{
if($text)
{
$this->text = $text;
}
}
function setAuthor($author=null)
{
if($author)
{
$this->author = $author;
}
}
/* Insert twitter data on Log table */
function insert_log()
{
$query = "INSERT INTO tb_log (NM_USER) VALUES ('".$this->author."')";
mysql_query($query, $this->con) or die(mysql_error());
return false;
}
function split()
{
$tw_text = str_split($this->text, 135);
$total = count($tw_text);
foreach($tw_text as $id => $data)
{
$text[] = $data.'['.($id+1).'/'.$total.']';
}
$this->text = $text;
}
function tweet()
{
//If the admin need to log tweets
if($this->log)
{
$this->insert_log();
}
return $this->text;
}
function get_contact_email()
{
return $this->contact_email;
}
}
?>