50 lines
2.3 KiB
PHP
50 lines
2.3 KiB
PHP
<?
|
|
@session_start();
|
|
@error_reporting(7);
|
|
@ini_set('display_errors', true);
|
|
@ini_set('html_errors', false);
|
|
|
|
define('DATALIFEENGINE', true);
|
|
define( 'ROOT_DIR', substr( dirname( __FILE__ ), 0, -12 ) );
|
|
define( 'SYSTEM_DIR', ROOT_DIR . '/system' );
|
|
|
|
include SYSTEM_DIR.'/data/config.php';
|
|
require_once SYSTEM_DIR.'/classes/mysql.php';
|
|
require_once SYSTEM_DIR.'/data/dbconfig.php';
|
|
require_once SYSTEM_DIR.'/modules/functions.php';
|
|
require_once SYSTEM_DIR.'/modules/sitelogin.php';
|
|
|
|
if( !$is_logged ) die( "error" );
|
|
$news_id = intval( $_REQUEST['news_id'] );
|
|
if( !$news_id ) die( "error" );
|
|
|
|
$subscribe = $db->super_query("SELECT COUNT(*) as count FROM " . PREFIX . "_subscribe WHERE news_id=$news_id AND user_id=$member_id[user_id]");
|
|
if($subscribe['count'] == 0 ){
|
|
$salt = "abchefghjkmnpqrstuvwxyz0123456789";
|
|
srand( ( double ) microtime() * 1000000 );
|
|
$s_hash = "";
|
|
for($i = 0; $i < 5; $i ++) {$s_hash .= $salt{rand( 0, 33 )};}
|
|
$s_hash = md5($s_hash);
|
|
|
|
$db->query( "INSERT INTO " . PREFIX . "_subscribe (user_id, name, email, news_id, hash) values ('{$member_id['user_id']}', '{$member_id['name']}', '{$member_id['email']}', '{$news_id}', '{$s_hash}')" );
|
|
$buffer = "<a href=\"#\" onclick=\"comm_Subscribe('" . $news_id . "'); return false;\"/>Îòïèñàòüñÿ</a>";
|
|
} else {
|
|
$db->query( "DELETE FROM " . PREFIX . "_subscribe WHERE news_id=$news_id AND user_id=$member_id[user_id]");
|
|
$buffer = "<a href=\"#\" onclick=\"comm_Subscribe('" . $news_id . "'); return false;\"/>Ïîäïèñàòüñÿ</a>";
|
|
}
|
|
$db->close();
|
|
@header( "Content-type: text/html; charset=" . $config['charset'] );
|
|
echo $buffer;
|
|
|
|
/*case "unsubscribe" :
|
|
$_GET['post_id'] = intval ($_GET['post_id']);
|
|
$_GET['user_id'] = intval ($_GET['user_id']);
|
|
if ($_GET['post_id'] AND $_GET['user_id'] AND $_GET['hash']) {
|
|
$row = $db->super_query( "SELECT hash FROM " . PREFIX . "_subscribe WHERE news_id='{$_GET['post_id']}' AND user_id='{$_GET['user_id']}'" );
|
|
if ($row['hash'] AND $row['hash'] == $_GET['hash']) {
|
|
$db->query( "DELETE FROM " . PREFIX . "_subscribe WHERE news_id='{$_GET['post_id']}' AND user_id='{$_GET['user_id']}'" );
|
|
msgbox( $lang['all_info'], $lang['unsubscribe_ok']);
|
|
} else {msgbox( $lang['all_info'], $lang['unsubscribe_err']);}
|
|
} else {msgbox( $lang['all_info'], $lang['unsubscribe_err']);}
|
|
break;*/
|
|
?>
|