Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- /*
- ustvari mysql tabelo:
- CREATE TABLE IF NOT EXISTS `impm` (
- `id` int(11) NOT NULL AUTO_INCREMENT,
- `pmid` int(11) NOT NULL,
- `pmtime` varchar(32) NOT NULL,
- KEY `id` (`id`)
- ) DEFAULT CHARSET=utf8
- prilozi simple_html_dom.php (http://simplehtmldom.sourceforge.net/)
- http://sourceforge.net/projects/simplehtmldom/files/simplehtmldom/1.11/simplehtmldom_1_11.zip/download
- */
- //config//
- $DBhost = "localhost";
- $DBusername = "";
- $DBpassword = "";
- $DBname = "";
- $IMuser = "";
- $IMpass = "";
- $demail = "";
- //end config//
- include('simple_html_dom.php');
- mysql_connect($DBhost, $DBusername, $DBpassword) or die(mysql_error());
- mysql_select_db($DBname) or die(mysql_error());
- $pmsindb = mysql_query("SELECT * FROM `impm`");
- while ($row = mysql_fetch_assoc($pmsindb)) {
- $allpmsids[] = $row['pmid'];
- $allpmtimes[$row['pmid']] = $row['pmtime'];
- }
- function send_email($title, $demail){
- $subject = "IM forum - Novo zasebno sporočilo: ".$title;
- $message = "Prejel si novo sporočilo na IM forumu. http://www.internetmojster.com/zs/";
- "Reply-To: ".$demail." \r\n" .
- "X-Mailer: PHP/" . phpversion();
- mail($demail, $subject, $message, $headers);
- }
- $ch = curl_init();
- curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE);
- curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE);
- curl_setopt($ch, CURLOPT_COOKIESESSION, TRUE);
- curl_setopt($ch, CURLOPT_HEADER, 0);
- curl_setopt($ch, CURLOPT_COOKIEFILE, "cookiefile.txt");
- curl_setopt($ch, CURLOPT_COOKIEJAR, "cookiefile.txt");
- curl_setopt($ch, CURLOPT_COOKIE, session_name() . '=' . session_id());
- curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
- curl_setopt($ch, CURLOPT_URL, 'http://www.internetmojster.com/?xajax=auth%2Flogin&xajaxr=1295878324505&xajaxargs[]=%3Cxjxquery%3E%3Cq%3Euname%3D'.$IMuser.'%26pwd%3D'.$IMpass.'%26remember%3Don%3C%2Fq%3E%3C%2Fxjxquery%3E');
- $login_return = (string)curl_exec($ch);
- $is_logged_in = strpos($login_return, "Prijava je bila uspešna!");
- if($is_logged_in == false){
- print ("Prijava v IM ni uspela.");
- } else {
- curl_setopt($ch, CURLOPT_URL, 'http://www.internetmojster.com/zs/');
- $zspage = curl_exec($ch);
- $zshtml = str_get_html($zspage);
- $i=0;
- foreach($zshtml->find('td[class=icon first new]') as $unread){
- $strhtml = $unread->parent();
- foreach($strhtml->find('.ts') as $e2){
- $hashtimes[] = hash('md5', (string)$e2->innertext);
- }
- foreach($strhtml->find('.big') as $e){
- $title = $e->innertext;
- $id_arr = explode("/", $e->href);
- if (!in_array($id_arr[2], $allpmsids)){ //nov pm, dodaj
- $query = mysql_query("INSERT INTO `impm` (`pmid`, `pmtime`) VALUES (".intval($id_arr[2]).", '".$hashtimes[$i]."')");
- send_email($title, $demail);
- } else if ($allpmtimes[intval($id_arr[2])] != $hashtimes[$i]){ //"star" zelen pm, glej ce je nov time
- $query = mysql_query("UPDATE `impm` SET `pmtime` = '".$hashtimes[$i]."' WHERE `pmid` = ".intval($id_arr[2]));
- send_email($title, $demail);
- }
- }
- $i++;
- }
- }
- mysql_close();
- curl_close($ch);
Advertisement
Add Comment
Please, Sign In to add comment