예제 #1
0
 /**
  *发送私信并保存到数据库
  */
 public function sendPM()
 {
     if (isUserLogin()) {
         if (IS_AJAX) {
             $receiverId = I('receiverId');
             //收信人ID
             $content = I('content');
             $time = time();
             $senderId = session('userId');
             if ($receiverId != null && $receiverId != $senderId) {
                 $data['pm_sender_id'] = $senderId;
                 $data['pm_receiver_id'] = $receiverId;
                 $data['pm_content'] = $content;
                 $data['pm_time'] = $time;
                 $data1['rm_receiver_id'] = $receiverId;
                 $data1['rm_sender_id'] = $senderId;
                 $data1['rm_content'] = $content;
                 $data1['rm_time'] = $time;
                 if (M('primessage')->add($data) && M('rcemessage')->add($data1)) {
                     $this->ajaxReturn(array('status' => 1), 'json');
                 }
             } else {
                 $this->ajaxReturn(array('status' => 0), 'json');
             }
         } else {
             $this->ajaxReturn(array('status' => 0), 'json');
         }
     } else {
         $this->ajaxReturn(array('status' => 0), 'json');
     }
 }
예제 #2
0
 public function doUploadType()
 {
     if (!isUserLogin()) {
         $this->error('请先登录', U('Login/login'));
     } else {
         if (I('getInfo') != null) {
             if (is_numeric(I('getInfo'))) {
                 $isbn = I('getInfo');
                 $bookInfo = isbn($isbn);
                 if ($bookInfo != null) {
                     session('isbn', $bookInfo['isbn']);
                     $this->assign('bookInfo', $bookInfo)->display('isbn');
                 } else {
                     $this->error('获取图书信息失败');
                 }
             } else {
                 $str = I('getInfo');
                 if (!empty($str)) {
                     $bookAddress = array('https://api.douban.com/v2/book/search?q=', $str);
                     //将固定网址和搜索字符串存入数组
                     $book_href = implode("", $bookAddress);
                     //合并字符串
                     $handle = fopen($book_href, "rb");
                     //打开文件(豆瓣会返回json)
                     $content = "";
                     while (!feof($handle)) {
                         $content .= fread($handle, 100000);
                     }
                     fclose($handle);
                     $content = json_decode($content);
                     //JSON 格式的字符串进行解码
                     $herfStr = '';
                     $isbnStr = '';
                     foreach ($content->books as $book) {
                         $bookAddress = array('http://book.douban.com/subject/', $book->id);
                         $book_href = implode("", $bookAddress);
                         //合并字符串
                         // echo str_replace("mpic", "lpic",$book->image);
                         //$book->publisher,$book->title,$book_href
                         $herfStr = $herfStr . str_replace("mpic", "lpic", $book->image) . "^^";
                         $isbnStr = $isbnStr . $book->isbn13 . "^^";
                     }
                     $data = explode('^^', $herfStr);
                     array_pop($data);
                     $isbnData = explode('^^', $isbnStr);
                     array_pop($isbnData);
                     $this->assign('dbbook', $data);
                     $this->assign('dbisbn', $isbnData);
                     $this->display('selectbook');
                 }
             }
         } else {
             $this->redirect('UploadType/uploadType');
         }
     }
 }
예제 #3
0
 /**
  * 去检查是否有权限进行图书的操作
  * @param $bookId
  * @param $userId
  * @return bool
  */
 private function checkOperation($bookId, $userId)
 {
     if (isUserLogin()) {
         $where['book_id'] = $bookId;
         $where['user_id'] = $userId;
         if (M('book')->field('book_id')->where($where)->select()) {
             return true;
         } else {
             return false;
         }
     }
     return false;
 }
예제 #4
0
 public function _before_index()
 {
     session('viewTime', time());
     //设置浏览时间标志
     session('viewFlag', '1');
     //设置浏览标志
     if (isUserLogin()) {
         session('browseFlag', 1);
         //如果已经登录则设置浏览推荐标志
         session('borwseTime', time());
     }
     $newBook = M('book')->field('book_id,book_pic,book_name,book_price,book_pub_time')->order('book_pub_time desc')->limit(10)->select();
     $popularBook = M('book')->field('book_id,book_pic,book_name,book_price,book_view')->order('book_view desc')->limit(10)->select();
     if (!empty($newBook) && !empty($popularBook)) {
         $this->assign('newBook', $newBook);
         $this->assign('popularBook', $popularBook);
     }
 }
예제 #5
0
 public function _initialize()
 {
     if (isUserLogin()) {
         session('userId', cookie('userId'));
         session('userName', cookie('userName'));
         $this->assign('userName', cookie('userName'));
     } else {
         if (session('?name') && session('?userId')) {
             $this->assign('userName', session('userName'));
         } else {
             $this->assign('userName', '');
         }
     }
     $userId = session('userId');
     $where['pm_receiver_id'] = $userId;
     $where['pm_status'] = 0;
     if (M('primessage')->field('pm_receiver_id,pm_status')->where($where)->select()) {
         $this->assign('primessage', '');
     }
 }
예제 #6
0
function smarty_insert_menu_bar($params,&$smarty){
	$current =  $smarty->getTemplateVars('menu_current');
	if(!$current){
		$current = 'TAB_HOME';
	}
	
	if($current=='TAB_HOME'){
		$tab_home = '<li><a href="index.php"  title="Home" class="current">Home</a></li>';
	}else{
		$tab_home = '<li><a href="index.php"  title="Home">Home</a></li>';
	}
	
	if(!isUserLogin()){
		return '<ul id="menu">'.$tab_home.'</ul>';
	}
	
	if($current=='TAB_UPLOAD'){
		$tab_upload = '<li><a href="upload.php"  title="Upload" class="current">Upload</a></li>';
	}else{
		$tab_upload = '<li><a href="upload.php"  title="Upload">Upload</a></li>';
	}
	
	if($current=='TAB_MYBOOKS'){
		$tab_mybook = '<li><a href="mybooks.php"  title="My Books" class="current">My Books</a></li>';
	}else{
		$tab_mybook = '<li><a href="mybooks.php"  title="My Books">My Books</a></li>';
	}
	
	if($current=='TAB_PROFILE'){
		$tab_profile = '<li><a href="profile.php"  title="Profile" class="current">Profile</a></li>';
	}else{
		$tab_profile = '<li><a href="profile.php"  title="Profile">Profile</a></li>';
	}
	
	$tab_admin = '<li><a href="admin/index.php"  title="Admin">Admin</a></li>';

	$html = '<ul id="menu">'.$tab_home.$tab_upload.$tab_mybook.$tab_profile.'</ul>';
	return $html;
}
예제 #7
0
 static function getPerms()
 {
     $perms = 0;
     if (isUserLogin()) {
         $perms |= AUTH_USER;
     } else {
         if (isAdminLogin()) {
             $perms |= AUTH_ADMIN;
         } else {
             if (isEmpLogin()) {
                 $perms |= AUTH_EMP;
             }
         }
     }
     if (isset($GLOBALS["TEST_MODE"])) {
         $perms |= AUTH_TEST_MODE;
     }
     if (isset($GLOBALS["MOCK_MODE"])) {
         $perms |= AUTH_MOCK_MODE;
     }
     return $perms;
 }
예제 #8
0
 /**
  *将我发给他的和他发给我的全部删除掉
  */
 public function deleteGroupPM()
 {
     $userId = I('userId');
     if (isUserLogin()) {
         $where1['pm_sender_id'] = session('userId');
         $where1['pm_receiver_id'] = $userId;
         $where2['rm_receiver_id'] = session('userId');
         $where2['rm_sender_id'] = $userId;
         //删除发出的私信和接收到的私信
         if (M('primessage')->where($where1)->delete() && M('rcemessage')->where($where2)->delete()) {
             echo "删除成功";
         } else {
             echo "删除失败";
         }
     } else {
         echo "无权删除";
     }
 }
예제 #9
0
파일: function.php 프로젝트: songwanfu/Book
/**
 *检查是否有权限去查看私信
 * @param $id
 * @return bool
 */
function isRightToSeePM($id)
{
    if (isUserLogin()) {
        if ($id == session('userId')) {
            return true;
        } else {
            return false;
        }
    } else {
        return false;
    }
}
예제 #10
0
 public function deleteFabu()
 {
     if (isUserLogin()) {
         if (IS_AJAX) {
             $bookId = I('bookId');
             $userId = session('userId');
             if ($this->isRightToDelBook($bookId, $userId)) {
                 if (M('book')->where(array('book_id' => $bookId))->delete()) {
                     M('collection')->where(array('book_id' => $bookId))->delete();
                     //删除收藏本书的记录
                     $this->ajaxReturn(array('status' => true), 'json');
                     //删除成功返回1
                 } else {
                     $this->ajaxReturn(array('status' => false), 'json');
                     //删除失败返回1
                 }
             } else {
                 $this->ajaxReturn(array('status' => false), 'json');
                 //删除失败返回0
             }
         }
         $this->ajaxReturn(array('status' => false), 'json');
         //删除失败返回0
     }
     $this->ajaxReturn(array('status' => false), 'json');
     //删除失败返回0
 }
예제 #11
0
파일: footer.php 프로젝트: jjonline/J4
<div class="scrollTop">
	<button class="fa fa-angle-double-up fadeUp" title="回顶部"><i class="icon-eject icon-white"></i></button>
</div>
<?php 
echo $footer_info;
/*统计代码建议不要开启显示图标、统计数据之类的设置;开启后会扰乱布局结构*/
?>
<script type='text/javascript'>
prettyPrint();
window._info = {
  // 'maxWidth':<?php 
echo _g('max_width');
?>
,
  'isLogin':<?php 
echo isUserLogin() ? "true,\r\n" : "false,\r\n";
?>
  'logid':<?php 
echo !empty($logid) ? $logid : 'null';
?>
,
  'url':'<?php 
echo BLOG_URL;
?>
',
<?php 
$Config = isVerfy();
foreach ($Config as $key => $value) {
    echo "  '" . $key . "':" . $value . ",\r\n";
}
?>
예제 #12
0
파일: header.php 프로젝트: new79den/photo
<head>
	<meta charset="UTF-8">
	<title>Document</title>
	<link rel="stylesheet" href="css/style.css">
	<?php 
include_once 'inc/libs.php';
?>
</head>
<body>
	<div class="menu">
		<div class="containMenu ind">
			<ul>
				<li><a href="login.php"><?php 
if (isUserLogin()) {
    echo "Exit";
} else {
    echo "Login";
}
?>
</a></li>
				<?php 
if (isUserLogin()) {
    ?>
				<li><a href="addphoto.php">Add photo</a></li>
				<li><a href="index.php">my photos</a></li>
				<?php 
}
?>
			</ul>
		</div>
	</div>
예제 #13
0
파일: functions.php 프로젝트: jjonline/J4
/**
 * @des 前台微语界面输出发布微语框
 * @param null
 * @return string
 */
function showTwiter()
{
    if (!isUserLogin()) {
        return '';
    }
    //尚未登录直接返回
    //默认采用后台上传的头像图片 后台未上传图片或被删除 使用gravatar头像
    global $CACHE;
    $Usr = $CACHE->readCache('user');
    $Gravatar = BLOG_URL . $Usr[1]['avatar'];
    if (!$Usr[1]['avatar']) {
        $Gravatar = J_getGravatar($Usr[1]['mail'], 100);
    }
    $Token = LoginAuth::genToken();
    $BLOG_URL = BLOG_URL;
    $gav = '<div class="addTwiterContainer"><div class="addTwiterAvatar"><img src="' . $Gravatar . '" title="' . $Usr[1]['name'] . '"></div>';
    $addView = <<<STR
\t<div class="addTwiterContent">
\t\t<form method="post" action="{$BLOG_URL}admin/twitter.php?action=post" class="addTwiterForm">
\t\t\t<input name="token" id="token" value="{$Token}" type="hidden" />
\t\t\t<p class="addTwiterInput"><textarea id="addTwiter" title="来点碎碎念吧~" placeholder="来点碎碎念吧~" name="t"></textarea></p>
\t\t\t<p class="AddTwiterSubmit"><button type="submit" name="submit" class="sub_btn addTwiterBtn"><i class="fa fa-check-circle-o"></i> 发布微语</button><span class="addTwiterInfo">Ctrl+Enter快速提交</span></p>
\t\t</form>
\t</div>
\t</div>
STR;
    return $gav . $addView;
}
예제 #14
0
파일: download.php 프로젝트: 9px/BookShare
<?php
	require_once 'util.php';
	require_once 'db_helper.php';
	
	if(!isUserLogin()){
		redirect('login.php');
	}
	
	
	$db = getDBInstance();
	$id = $_REQUEST['id'];
		
	$download_book = getDownloadBook($db, $_SESSION['user']->id, $id);
	$book = $db->get_row("select * from books where id=$id");
	if($download_book){
		download($book->name,$book->path);
	}else{
		$new_point = $_SESSION['user']->points - $book->points;	
		if($new_point < 0){
			message('Your points is not enough to download this book!');
			redirect("book.php?id=$id");
		}
		//minus the user's points
		updateUserPoints($db, $_SESSION['user']->id, $book->points*-1);
		$_SESSION['user']->points = $new_point;
		
		//add the download history	
		addDownloadHistory($db, $_SESSION['user']->id, $id, $book->points);
			
		//update the book's download times
		addDownloadTime($db,$id);