Find this useful? Enter your email to receive occasional updates for securing PHP code.
Signing you up...
Thank you for signing up!
PHP Decode
<?php /** * - - * @author WEBOA <[email protected]> <[email protected]> * @crea..
Decoded Output download
<?php
/**
* - -
* @author WEBOA <[email protected]> <[email protected]>
* @created 2017-04-11 18:10:23
*/
namespace fw\module\media\model\base;
use fw\lib\core\modelBase;
use fw\lib\core\core;
use fw\lib\verify;
class article extends modelBase {
public function __construct() {
parent::__construct('media', true);
$this->table = 'oat_article';
}
/**
*
* @param $data
* @return array
*/
public function addArticle($data) {
if (!$this->db->insert($this->table, $data)) {
return returnVal('');
}
return returnVal('', true);
}
/**
* emoji
*/
public function userTextEncode($str) {
if (!is_string($str)) {
return $str;
}
if (!$str || $str == 'undefined') {
return '';
}
$text = json_encode($str); //unicode
$text = preg_replace_callback("/(\\\u[ed][0-9a-f]{3})/i", function ($str) {
return addslashes($str[0]);
}, $text); //emojiunicodedemoji\ud\ue
return json_decode($text);
}
/**
*
*/
public function userTextDecode($text) {
$text = preg_replace_callback("/(\\\u[ed][0-9a-f]{3})/i", function ($str) {
return addslashes($str[0]);
}, $text);
$text = stripcslashes($text);
$text = json_encode($text); //unicode
$text = preg_replace_callback('/\\\\\\\\/i', function ($text) {
return '\\';
}, $text); //
return json_decode($text);
}
/**
*
* @param $article_id
* @return array
*/
public function deleteArticle($article_id) {
if (!$articleData = $this->getArticle($article_id)) {
return returnVal(',');
}
if ($articleData['staff_id'] != getUserID() && !isSuper()) {
return returnVal('');
}
$this->db->beginTransaction();
//
if ($articleData['like_num'] > 0) {
if (!$this->db->query("update oat_account_detail set like_num = like_num - " . $articleData['like_num'] . " where staff_id = ?", array(getUserID()))) {
return returnVal('');
}
}
$array = array(
'article_id' => $article_id,
'valid_flag' => 0
);
if (!$this->db->update($this->table, 'article_id', $array)) {
return returnVal('');
}
$this->db->commit();
return returnVal('', true);
}
/**
*
* @param $article_id
* @return array
*/
public function getArticle($article_id) {
if (!$article_id) {
return false;
}
$data = $this->db->fetch("select * from " . $this->table . " where article_id = ? and valid_flag = 1", array($article_id));
if ($data) {
$data['the_content'] = $this->userTextDecode($data['the_content']);
}
return $data;
}
/**
*
* @param $data
* @return array
*/
public function markLike($data) {
if (!$articleData = $this->getArticle($data['article_id'])) {
return returnVal(',');
}
if ($articleData['valid_flag'] != 1) {
return returnVal('');
}
// ,,
if (!$this->checkArticlePur($data['staff_id'], $articleData['staff_id'])) {
return returnVal('');
}
//
if ($likeData = $this->db->fetch("select * from oat_article_like_detail where article_id = ? and staff_id = ?", array($data['article_id'], $data['staff_id']))) {
return returnVal(',');
}
//
$this->db->beginTransaction();
if (!$this->db->query("update oat_article set like_num = like_num + 1 where article_id = ?", array($data['article_id']))) {
return returnVal('');
}
if (!$this->db->insert("oat_article_like_detail", $data)) {
return returnVal('');
}
// ,
if (!$this->db->query("update oat_account_detail set like_num = like_num + 1 where staff_id = ?", array($articleData['staff_id']))) {
return returnVal('');
}
$reportData = $this->getMonthReport($articleData['staff_id'], date("Y-m"));
if ($reportData == -1) {
return returnVal('');
}
if ($reportData) {
if (!$this->db->query("update oat_like_num_report_month set like_num = like_num + 1 where staff_id = ? and the_month = ?", array($articleData['staff_id'], date("Y-m")))) {
return returnVal('2,');
}
} else {
$array = array(
'staff_id' => $articleData['staff_id'],
'the_month' => date("Y-m"),
'like_num' => 1
);
if (!$this->db->insert("oat_like_num_report_month", $array)) {
return returnVal(',');
}
}
//
$the_date = substr(date('Y-m-d w', strtotime('this week')), 0, 10);
$reportData = $this->getWeekReport($articleData['staff_id'], $the_date);
if ($reportData == -1) {
return returnVal('');
}
if ($reportData) {
if (!$this->db->query("update oat_like_num_report_week set like_num = like_num + 1 where staff_id = ? and the_date = ?", array($articleData['staff_id'], $the_date))) {
return returnVal('2,');
}
} else {
$array = array(
'staff_id' => $articleData['staff_id'],
'the_date' => $the_date,
'like_num' => 1
);
if (!$this->db->insert("oat_like_num_report_week", $array)) {
return returnVal(',');
}
}
$this->db->commit();
return returnVal('', true);
}
/**
*
* @param $staff_id
* @param $pre_staff_id
* @return bool
*/
public function checkArticlePur($staff_id, $pre_staff_id) {
if (!$this->db->fetch("select * from oat_focus_detail where staff_id = ? and pre_staff_id = ?", array($staff_id, $pre_staff_id))) {
return false;
}
return true;
}
/**
*
* @param $staff_id
* @param $month
* @return array
*/
public function getMonthReport($staff_id, $month) {
if (!$staff_id || !verify::isDate($month . '-01')) {
return -1;
}
$reportData = $this->db->fetch("select * from oat_like_num_report_month where staff_id = ? and the_month = ?", array($staff_id, $month));
if (!$reportData) {
return false;
}
return $reportData;
}
/**
*
* @param $staff_id
* @param $the_date
* @return array
*/
public function getWeekReport($staff_id, $the_date) {
if (!$staff_id || !verify::isDate($the_date)) {
return -1;
}
$reportData = $this->db->fetch("select * from oat_like_num_report_week where staff_id = ? and the_date = ?", array($staff_id, $the_date));
if (!$reportData) {
return false;
}
return $reportData;
}
/**
* ()
* @param $options
* @param $staff_id
* @return array
*/
public function getArticleList($options, $staff_id = 0) {
$offset = intval(max($options['offset'], 0));
$limit = intval(max($options['limit'], 10));
if ($staff_id) {
$tempStr = "a.staff_id = " . $staff_id;
} else {
if ($myFocusData = core::model('media_base_account')->getMyFocusList(getUserID())) {
$list = array_column($myFocusData, 'staff_id');
$list = implode(',', $list);
}
$list = ($list ? ($list . ",") : "") . getUserID();
$tempStr = "a.staff_id in (" . $list . ")";
}
$sql = "select a.*, b.user_nick, case when ifnull(c.staff_id, 0) > 0 then 1 else 0 end like_flag
from oat_article a left join oat_article_like_detail c on (a.article_id = c.article_id and c.staff_id = " . getUserID() . "), oat_account_detail b
where a.valid_flag = 1
and a.staff_id = b.staff_id and " . $tempStr;
$sql .= " order by a.created desc limit {$offset},{$limit}";
$data = $this->db->fetchAll($sql);
if ($data) {
foreach ($data as $k => $v) {
$data[$k]['created'] = date("Y-m-d H:i:s", $v['created']);
$data[$k]['the_content'] = $this->userTextDecode($v['the_content']);
}
}
return core::model('media_base_account')->formatAvatarList($data);
}
}
?>
Did this file decode correctly?
Original Code
<?php
/**
* - -
* @author WEBOA <[email protected]> <[email protected]>
* @created 2017-04-11 18:10:23
*/
namespace fw\module\media\model\base;
use fw\lib\core\modelBase;
use fw\lib\core\core;
use fw\lib\verify;
class article extends modelBase {
public function __construct() {
parent::__construct('media', true);
$this->table = 'oat_article';
}
/**
*
* @param $data
* @return array
*/
public function addArticle($data) {
if (!$this->db->insert($this->table, $data)) {
return returnVal('');
}
return returnVal('', true);
}
/**
* emoji
*/
public function userTextEncode($str) {
if (!is_string($str)) {
return $str;
}
if (!$str || $str == 'undefined') {
return '';
}
$text = json_encode($str); //unicode
$text = preg_replace_callback("/(\\\u[ed][0-9a-f]{3})/i", function ($str) {
return addslashes($str[0]);
}, $text); //emojiunicodedemoji\ud\ue
return json_decode($text);
}
/**
*
*/
public function userTextDecode($text) {
$text = preg_replace_callback("/(\\\u[ed][0-9a-f]{3})/i", function ($str) {
return addslashes($str[0]);
}, $text);
$text = stripcslashes($text);
$text = json_encode($text); //unicode
$text = preg_replace_callback('/\\\\\\\\/i', function ($text) {
return '\\';
}, $text); //
return json_decode($text);
}
/**
*
* @param $article_id
* @return array
*/
public function deleteArticle($article_id) {
if (!$articleData = $this->getArticle($article_id)) {
return returnVal(',');
}
if ($articleData['staff_id'] != getUserID() && !isSuper()) {
return returnVal('');
}
$this->db->beginTransaction();
//
if ($articleData['like_num'] > 0) {
if (!$this->db->query("update oat_account_detail set like_num = like_num - " . $articleData['like_num'] . " where staff_id = ?", array(getUserID()))) {
return returnVal('');
}
}
$array = array(
'article_id' => $article_id,
'valid_flag' => 0
);
if (!$this->db->update($this->table, 'article_id', $array)) {
return returnVal('');
}
$this->db->commit();
return returnVal('', true);
}
/**
*
* @param $article_id
* @return array
*/
public function getArticle($article_id) {
if (!$article_id) {
return false;
}
$data = $this->db->fetch("select * from " . $this->table . " where article_id = ? and valid_flag = 1", array($article_id));
if ($data) {
$data['the_content'] = $this->userTextDecode($data['the_content']);
}
return $data;
}
/**
*
* @param $data
* @return array
*/
public function markLike($data) {
if (!$articleData = $this->getArticle($data['article_id'])) {
return returnVal(',');
}
if ($articleData['valid_flag'] != 1) {
return returnVal('');
}
// ,,
if (!$this->checkArticlePur($data['staff_id'], $articleData['staff_id'])) {
return returnVal('');
}
//
if ($likeData = $this->db->fetch("select * from oat_article_like_detail where article_id = ? and staff_id = ?", array($data['article_id'], $data['staff_id']))) {
return returnVal(',');
}
//
$this->db->beginTransaction();
if (!$this->db->query("update oat_article set like_num = like_num + 1 where article_id = ?", array($data['article_id']))) {
return returnVal('');
}
if (!$this->db->insert("oat_article_like_detail", $data)) {
return returnVal('');
}
// ,
if (!$this->db->query("update oat_account_detail set like_num = like_num + 1 where staff_id = ?", array($articleData['staff_id']))) {
return returnVal('');
}
$reportData = $this->getMonthReport($articleData['staff_id'], date("Y-m"));
if ($reportData == -1) {
return returnVal('');
}
if ($reportData) {
if (!$this->db->query("update oat_like_num_report_month set like_num = like_num + 1 where staff_id = ? and the_month = ?", array($articleData['staff_id'], date("Y-m")))) {
return returnVal('2,');
}
} else {
$array = array(
'staff_id' => $articleData['staff_id'],
'the_month' => date("Y-m"),
'like_num' => 1
);
if (!$this->db->insert("oat_like_num_report_month", $array)) {
return returnVal(',');
}
}
//
$the_date = substr(date('Y-m-d w', strtotime('this week')), 0, 10);
$reportData = $this->getWeekReport($articleData['staff_id'], $the_date);
if ($reportData == -1) {
return returnVal('');
}
if ($reportData) {
if (!$this->db->query("update oat_like_num_report_week set like_num = like_num + 1 where staff_id = ? and the_date = ?", array($articleData['staff_id'], $the_date))) {
return returnVal('2,');
}
} else {
$array = array(
'staff_id' => $articleData['staff_id'],
'the_date' => $the_date,
'like_num' => 1
);
if (!$this->db->insert("oat_like_num_report_week", $array)) {
return returnVal(',');
}
}
$this->db->commit();
return returnVal('', true);
}
/**
*
* @param $staff_id
* @param $pre_staff_id
* @return bool
*/
public function checkArticlePur($staff_id, $pre_staff_id) {
if (!$this->db->fetch("select * from oat_focus_detail where staff_id = ? and pre_staff_id = ?", array($staff_id, $pre_staff_id))) {
return false;
}
return true;
}
/**
*
* @param $staff_id
* @param $month
* @return array
*/
public function getMonthReport($staff_id, $month) {
if (!$staff_id || !verify::isDate($month . '-01')) {
return -1;
}
$reportData = $this->db->fetch("select * from oat_like_num_report_month where staff_id = ? and the_month = ?", array($staff_id, $month));
if (!$reportData) {
return false;
}
return $reportData;
}
/**
*
* @param $staff_id
* @param $the_date
* @return array
*/
public function getWeekReport($staff_id, $the_date) {
if (!$staff_id || !verify::isDate($the_date)) {
return -1;
}
$reportData = $this->db->fetch("select * from oat_like_num_report_week where staff_id = ? and the_date = ?", array($staff_id, $the_date));
if (!$reportData) {
return false;
}
return $reportData;
}
/**
* ()
* @param $options
* @param $staff_id
* @return array
*/
public function getArticleList($options, $staff_id = 0) {
$offset = intval(max($options['offset'], 0));
$limit = intval(max($options['limit'], 10));
if ($staff_id) {
$tempStr = "a.staff_id = " . $staff_id;
} else {
if ($myFocusData = core::model('media_base_account')->getMyFocusList(getUserID())) {
$list = array_column($myFocusData, 'staff_id');
$list = implode(',', $list);
}
$list = ($list ? ($list . ",") : "") . getUserID();
$tempStr = "a.staff_id in (" . $list . ")";
}
$sql = "select a.*, b.user_nick, case when ifnull(c.staff_id, 0) > 0 then 1 else 0 end like_flag
from oat_article a left join oat_article_like_detail c on (a.article_id = c.article_id and c.staff_id = " . getUserID() . "), oat_account_detail b
where a.valid_flag = 1
and a.staff_id = b.staff_id and " . $tempStr;
$sql .= " order by a.created desc limit {$offset},{$limit}";
$data = $this->db->fetchAll($sql);
if ($data) {
foreach ($data as $k => $v) {
$data[$k]['created'] = date("Y-m-d H:i:s", $v['created']);
$data[$k]['the_content'] = $this->userTextDecode($v['the_content']);
}
}
return core::model('media_base_account')->formatAvatarList($data);
}
}
Function Calls
None |
Stats
MD5 | 69adcdb588df81527373de667f525b00 |
Eval Count | 0 |
Decode Time | 120 ms |