Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
2b5cef8
commit 527e0a3
Showing
3 changed files
with
45 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
<?php | ||
/** | ||
* Action for VOID Plugin | ||
* | ||
* @author AlanDecode | 熊猫小A | ||
*/ | ||
|
||
class VOID_Action extends Typecho_Widget implements Widget_Interface_Do | ||
{ | ||
/** | ||
* 点赞自增 | ||
*/ | ||
public function up(){ | ||
$db = Typecho_Db::get(); | ||
$cid=$this->request->filter('int')->cid; | ||
if($cid){ | ||
try { | ||
$row = $db->fetchRow($db->select('likes') | ||
->from('table.contents') | ||
->where('cid = ?', $cid)); | ||
$db->query($db->update('table.contents') | ||
->rows(array('likes' => (int)$row['likes']+1)) | ||
->where('cid = ?', $cid)); | ||
$this->response->throwJson("success"); | ||
} catch (Exception $ex) { | ||
echo $ex->getCode(); | ||
} | ||
} else { | ||
echo "error"; | ||
} | ||
} | ||
|
||
public function action(){ | ||
$this->on($this->request->is('up'))->up(); | ||
$this->response->goBack(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters