Advertisement
Guest User

Untitled

a guest
Mar 29th, 2015
244
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 27.06 KB | None | 0 0
  1. <?php
  2.  
  3. $retards_config = json_decode(file_get_contents(ROOT_DIR.'/ninja-applications/retards/lib/config.retards.inc'), true);
  4. $retards_user_config = json_decode(file_get_contents(ROOT_DIR.'/ninja-applications/retards/lib/config.retards_user.inc'), true);
  5.  
  6. if($retards_config['l_choose'] == '1' && (isset($_COOKIE['retards_locale']) && $_COOKIE['retards_locale'] != '') && file_exists(ROOT_DIR.'/ninja-applications/retards/locales/'.$_COOKIE['retards_locale'])){
  7. $retards_config['locale'] = $_COOKIE['retards_locale'];
  8. }
  9. if($retards_config['t_choose'] == '1' && (isset($_COOKIE['retards_theme']) && $_COOKIE['retards_theme'] != '') && file_exists(ROOT_DIR.'/ninja-applications/retards/themes/'.$_COOKIE['retards_theme'])){
  10. $retards_config['theme'] = $_COOKIE['retards_theme'];
  11. }
  12.  
  13. // Language
  14. $lang = array_merge($lang, json_decode(file_get_contents(ROOT_DIR.'/ninja-applications/retards/locales/'.$retards_config['locale']), true));
  15. // THEME SETTING IF EXIST
  16. if(file_exists(ROOT_DIR.'/ninja-applications/retards/themes/'.$retards_config['theme'].'/libs/config.theme.inc')){
  17. $retards_theme = json_decode(file_get_contents(ROOT_DIR.'/ninja-applications/retards/themes/'.$retards_config['theme'].'/libs/config.theme.inc'), true);
  18. }
  19.  
  20.  
  21. // GET IMPORTANT SLUG
  22. $retards_slug = array();
  23. $ninja->db->limit_val = "";
  24. $retards_important_slug = $ninja->db->dbSelect($ninja_config['TABLES_PREFIX']."slug",array('slug','page'),array('application'=>'retards','important'=>'1'));
  25. if(count($retards_important_slug) > 0){
  26. foreach($retards_important_slug as &$slug){
  27. $retards_slug[$slug['page']] = $slug['slug'];
  28. }
  29. }
  30.  
  31. class ninja_retards extends ninja{
  32. var $lang = 'english';
  33. var $retards_config = array();
  34. var $retards_user_config = array();
  35. var $retards_theme = array();
  36. var $retards_slug = array();
  37.  
  38. public renction setLang(array $lang) {
  39. $this->$lang = 'english';
  40. }
  41.  
  42. public renction setConfig(array $array) {
  43. $this->retards_config = $array;
  44. }
  45.  
  46. public renction setUserConfig(array $array) {
  47. $this->retards_user_config = $array;
  48. }
  49.  
  50. public renction setSlug(array $array) {
  51. $this->retards_slug = $array;
  52. }
  53.  
  54. public renction setThemeConfig(array $array) {
  55. $this->retards_theme = $array;
  56. }
  57.  
  58. renction store_view_logs($reId){
  59. $this->db->limit_val = "1";
  60. $day = $this->db->dbSelect($this->ninja_config['TABLES_PREFIX']."retards_view_logs",'', array("reId"=>$reId,'type'=>'d','val'=>date('z'),'year'=>date('Y') ));
  61. $week = $this->db->dbSelect($this->ninja_config['TABLES_PREFIX']."retards_view_logs",'', array("reId"=>$reId,'type'=>'w','val'=>date('W'),'year'=>date('Y') ));
  62. $month = $this->db->dbSelect($this->ninja_config['TABLES_PREFIX']."retards_view_logs",'', array("reId"=>$reId,'type'=>'m','val'=>date('n'),'year'=>date('Y') ));
  63. ///////////////////// DAY ///////////////////////
  64. if(count($day) < 1){
  65. $insert = $this->db->dbInsert($this->ninja_config['TABLES_PREFIX']."retards_view_logs",array("reId"=>$reId,'views'=>'1','type'=>'d','val'=>date('z'),'year'=>date('Y')));
  66. }else{
  67. $update = $this->db->dbUpdate($this->ninja_config['TABLES_PREFIX']."retards_view_logs",array('views'=>$day[0]['views']+1),array('type'=>'d','val'=>date('z'),'year'=>date('Y') ) );
  68. }
  69. ///////////////////// WEEK ///////////////////////
  70. if(count($week) < 1){
  71. $insert = $this->db->dbInsert($this->ninja_config['TABLES_PREFIX']."retards_view_logs",array("reId"=>$reId,'views'=>'1','type'=>'w','val'=>date('W'),'year'=>date('Y')));
  72. }else{
  73. $update = $this->db->dbUpdate($this->ninja_config['TABLES_PREFIX']."retards_view_logs",array('views'=>$week[0]['views']+1),array("reId"=>$reId,'type'=>'w','val'=>date('W'),'year'=>date('Y')));
  74. }
  75. ///////////////////// MONTH ///////////////////////
  76. if(count($month) < 1){
  77. $insert = $this->db->dbInsert($this->ninja_config['TABLES_PREFIX']."retards_view_logs",array("reId"=>$reId,'views'=>'1','type'=>'m','val'=>date('n'),'year'=>date('Y')));
  78. }else{
  79. $update = $this->db->dbUpdate($this->ninja_config['TABLES_PREFIX']."retards_view_logs",array('views'=>$month[0]['views']+1),array("reId"=>$reId,'type'=>'m','val'=>date('n'),'year'=>date('Y')));
  80. }
  81. return $this->db->error_info;
  82. }
  83.  
  84. renction reOwner($uId){
  85. $this->db->limit_val = "1";
  86. $result = $this->db->dbSelect($this->ninja_config['TABLES_PREFIX']."users",array("id","avatar","username"),array("id"=>$uId));
  87. if(count($result) > 0){
  88. return $result[0];
  89. }
  90. return NULL;
  91. }
  92.  
  93. renction theme_list(){
  94. if ($handle = opendir(ROOT_DIR.'/ninja-applications/retards/themes/')) {
  95. while (false !== ($entry = readdir($handle))) {
  96. if ($entry != "." && $entry != "..") {
  97. echo "<option value='$entry' ".($entry == $this->retards_config['theme'] ? 'selected' : '').">".ucfirst($entry)."</option>";
  98. }
  99. }
  100. closedir($handle);
  101. }
  102. }
  103.  
  104. renction locale_list(){
  105. if ($handle = opendir(ROOT_DIR.'/ninja-applications/retards/locales/')) {
  106. while (false !== ($entry = readdir($handle))) {
  107. if ($entry != "." && $entry != "..") {
  108. echo "<option value='$entry' ".($entry == $this->retards_config['locale'] ? 'selected' : '').">".ucfirst(str_replace('.php', '', $entry))."</option>";
  109. }
  110. }
  111. closedir($handle);
  112. }
  113. }
  114. renction do_rate($rate){
  115. return $rate > 0 ? '+'.$rate : $rate;
  116. }
  117. renction cat_is_exist($cat_id){
  118. $this->db->limit_val="1";
  119. $retards_cat = $this->db->dbSelect($this->ninja_config['TABLES_PREFIX']."retards_cat",array("cat_id"),array("cat_id"=>$cat_id));
  120. if(count($retards_cat) > 0){
  121. return true;
  122. }
  123. return false;
  124. }
  125. renction do_cat($cat_id){
  126. $this->db->order_by_column = "";
  127. $this->db->limit_val="1";
  128. $retards_cat = $this->db->dbSelect($this->ninja_config['TABLES_PREFIX']."retards_cat",array("name","cat_id"),array("cat_id"=>$cat_id));
  129. if(count($retards_cat) > 0){
  130. return $retards_cat[0]['name'];
  131. }else{
  132. return $this->lang['No-category'];
  133. }
  134. }
  135.  
  136. renction gen_6slug(){
  137. $six_slug = uniqid(rand(10,1000),false);
  138. $six_slug = substr($six_slug,rand(0,strlen($six_slug) - 6),6);
  139. if($this->slugIsExist('/'.$six_slug)){
  140. return $this->gen_6slug();
  141. }else{
  142. return $six_slug;
  143. }
  144. }
  145.  
  146. renction get_vine_thumbnail($url){
  147. $vine = file_get_contents($url);
  148. preg_match('/property="og:image" content="(.*?)"/', $vine, $matches);
  149.  
  150. return ($matches[1]) ? $matches[1] : false;
  151. }
  152.  
  153. renction print_cat_selections($thisCat = NULL){
  154. $this->db->limit_val='';
  155. $retards_cat = $this->db->dbSelect($this->ninja_config['TABLES_PREFIX']."retards_cat",array("name","cat_id"));
  156. if(count($retards_cat) > 0){
  157. foreach($retards_cat as &$cat){
  158. if(isset($thisCat) && $cat['cat_id'] == $thisCat){ $selected = 'selected'; }else{ $selected = ''; }
  159. echo '<option value="'.$cat['cat_id'].'" '.$selected.'>'.$cat['name'].'</option>';
  160. }
  161. }else{
  162. return $this->lang['No-category'];
  163. }
  164.  
  165. }
  166. renction print_nsfw_cat_selections(){
  167. $this->db->limit_val='';
  168. $retards_cat = $this->db->dbSelect($this->ninja_config['TABLES_PREFIX']."retards_cat",array("name","cat_id"));
  169. if(count($retards_cat) > 0){
  170. foreach($retards_cat as &$cat){
  171. $selected = isset($this->retards_config['nsfw_cat']) && in_array($cat['cat_id'], $this->retards_config['nsfw_cat']) ? 'selected' : '';
  172. echo '<option value="'.$cat['cat_id'].'" '.$selected.'>'.$cat['name'].'</option>';
  173. }
  174. }else{
  175. return $this->lang['No-category'];
  176. }
  177.  
  178. }
  179. renction print_sociallock_cat_selections(){
  180. $this->db->limit_val='';
  181. $retards_cat = $this->db->dbSelect($this->ninja_config['TABLES_PREFIX']."retards_cat",array("name","cat_id"));
  182. if(count($retards_cat) > 0){
  183. foreach($retards_cat as &$cat){
  184. $selected = isset($this->retards_config['sociallock_cat']) && in_array($cat['cat_id'], $this->retards_config['sociallock_cat']) ? 'selected' : '';
  185. echo '<option value="'.$cat['cat_id'].'" '.$selected.'>'.$cat['name'].'</option>';
  186. }
  187. }else{
  188. return $this->lang['No-category'];
  189. }
  190.  
  191. }
  192. renction do_re_description($input){
  193. $output = stripslashes($input);
  194. $output = preg_replace( "/#(\w+)/u", "<a href=\"".$this->ninja_config['siteUrl'].$this->retards_slug['index']."?q=%23$1\">#$1</a>", $output );
  195. $output = nl2br($output);
  196. return $output;
  197. }
  198. renction do_re($re){
  199. if($re['re_type'] == 'img'){
  200. $string = '<img src="'.$this->ninja_config['siteUrl'].$re['original_img'].'" class="re-img" style="width: '.$this->retards_theme['img_width'].'">';
  201. }else if($re['re_type'] == 'gallery'){
  202. $imgs = $re['embed'];
  203. $imgs = rtrim($imgs, ';');
  204. $imgs = explode(';', $imgs);
  205. $string = '<ul class="bxslider">';
  206. foreach ($imgs as &$img) {
  207. $string .= '<li><img src="'.$this->ninja_config['siteUrl'] . $img . '" class="re-img" style="width: 100%"></li>';
  208. }
  209. $string .= '</ul>';
  210. }else if($re['re_type'] == 'video'){
  211. $string = strtr($re['iframe'], array('{{height}}'=>$this->retards_theme['video_height'],'{{width}}'=>$this->retards_theme['video_width']));
  212. }else if($re['re_type'] == 'vine'){
  213. $string = strtr($re['iframe'], array('{{height}}'=>$this->retards_theme['vine_width'],'{{width}}'=>$this->retards_theme['vine_width']));
  214. $string = str_replace('id="vine"', 'class="vine-embed"', $string);
  215. $string .= '
  216. <script>
  217. var cw = $(\'#vine\').width();
  218. $(\'#vine\').height(cw);
  219. var cw2 = $(\'.vine-embed\').width();
  220. $(\'.vine-embed\').height(cw2);
  221. </script>';
  222. }else if($re['re_type'] == 'soundcloud'){
  223. $string = strtr($re['iframe'], array('{{height}}'=>$this->retards_theme['video_width'],'{{width}}'=>$this->retards_theme['video_width']));
  224. }else{
  225. $string = '<img src="'.$this->ninja_config['siteUrl'].$re['original_img'].'" class="re-img" style="width: '.$this->retards_theme['gif_width'].'">';
  226. }
  227. return $string;
  228. }
  229.  
  230. renction log_recent_tags($tag, $n = 10){
  231. $this->db->limit_val = '1';
  232. $tags = $this->db->dbSelect($this->ninja_config['TABLES_PREFIX']."retards_recent_tags", "text", array('id'=>1));
  233. $this->db->limit_val = '';
  234. $tags = $tags[0]["text"];
  235. $tags = rtrim($tags, ';');
  236. $tags = explode(';', $tags);
  237. if (in_array($tag, $tags)) {
  238. $tags = array_diff($tags, array($tag));
  239. array_unshift($tags, $tag);
  240. }else{
  241. array_unshift($tags, $tag);
  242. }
  243. $tags = array_splice($tags, 0, $n);
  244. $tags = implode(";", $tags);
  245. $this->db->dbUpdate($this->ninja_config['TABLES_PREFIX']."retards_recent_tags", array("text"=>$tags),array("id"=>1));
  246. }
  247.  
  248. renction get_recent_tags($n){
  249. // GET LIST OF RECENT TAGS USED AND RETURN AS AN ARRAY
  250. $this->db->limit_val = '1';
  251. $tags = $this->db->dbSelect($this->ninja_config['TABLES_PREFIX']."retards_recent_tags", "text", array('id'=>1));
  252. $this->db->limit_val = '';
  253. $tags = $tags[0]["text"];
  254. $tags = rtrim($tags, ';');
  255. $tags = explode(';', $tags);
  256. return $tags;
  257. }
  258.  
  259. renction time_elapsed_string($datetime, $rell = false) {
  260. $now = new DateTime;
  261. $ago = new DateTime($datetime);
  262. $diff = $now->diff($ago);
  263.  
  264. $string = array(
  265. 'y' => $this->lang['year'],
  266. 'm' => $this->lang['month'],
  267. 'd' => $this->lang['day'],
  268. 'h' => $this->lang['hour'],
  269. 'i' => $this->lang['minute'],
  270. 's' => $this->lang['second'],
  271. );
  272. foreach ($string as $k => &$v) {
  273. if ($diff->$k) {
  274. $v = $diff->$k . ' ' . $v . ($diff->$k > 1 ? $this->lang['time-period-s'] : '');
  275. } else {
  276. unset($string[$k]);
  277. }
  278. }
  279.  
  280. if (!$rell) $string = array_slice($string, 0, 1);
  281. return $string ? implode(', ', $string) . ' '.$this->lang['ago'] : $this->lang['just-now'];
  282. }
  283. renction getHashtags($string) {
  284. $hashtags= FALSE;
  285. preg_match_all("/(#\w+)/u", $string, $matches);
  286. if ($matches) {
  287. $hashtagsArray = array_count_values($matches[0]);
  288. $hashtags = array_keys($hashtagsArray);
  289. }
  290. return $hashtags;
  291. }
  292. renction visitor_theme_chooser(){
  293. if ($handle = opendir(ROOT_DIR.'/ninja-applications/retards/themes/')) {
  294. while (false !== ($entry = readdir($handle))) {
  295. if ($entry != "." && $entry != "..") {
  296. echo '<li><a href="javascript:;" class="theme-chooser" data-value="'.$entry.'" data-href="'.$this->ninja_config['siteUrl'].'/ninja-applications/retards/controllers/cont.changetheme.php">'.ucfirst($entry).'</a></li>';
  297. }
  298. }
  299. closedir($handle);
  300. }
  301. }
  302. renction visitor_locale_chooser(){
  303. if ($handle = opendir(ROOT_DIR.'/ninja-applications/retards/locales/')) {
  304. while (false !== ($entry = readdir($handle))) {
  305. if ($entry != "." && $entry != "..") {
  306. echo '<li><a href="javascript:;" class="locale-chooser" data-value="'.$entry.'" data-href="'.$this->ninja_config['siteUrl'].'/ninja-applications/retards/controllers/cont.changelocale.php">'.ucfirst($entry).'</a></li>';
  307. }
  308. }
  309. closedir($handle);
  310. }
  311. }
  312. renction get_top_re($type, $limit){
  313. /// $type = 'month', 'week', 'day'
  314. $trans = array("day" => "d", "month" => "m", "week" => "w");
  315. $type = strtr($type, $trans);
  316. $this->db->limit_val = $limit;
  317. $this->db->order_by_column = "views DESC";
  318. $topreIdArr = $this->db->dbSelect($this->ninja_config['TABLES_PREFIX']."retards_view_logs", array("reId"),
  319. array('type'=>$type,
  320. "year"=>date('Y'))
  321. );
  322. if(!is_array($topreIdArr) || count($topreIdArr) < 2){
  323. $this->db->order_by_column = '';
  324. $this->db->limit_val = '';
  325. $this->db->group_by_column = '';
  326. }else{
  327. $tables = array($this->ninja_config['TABLES_PREFIX']."retards_re", $this->ninja_config['TABLES_PREFIX']."slug");
  328. $joins = array($this->ninja_config['TABLES_PREFIX']."retards_re.f_id=".$this->ninja_config['TABLES_PREFIX']."slug.c_id");
  329. $joinCondition = array("LEFT JOIN");
  330. $whereCondition = array($this->ninja_config['TABLES_PREFIX']."slug.page"=>"display_re",$this->ninja_config['TABLES_PREFIX']."slug.important"=>"0",$this->ninja_config['TABLES_PREFIX']."retards_re.isapproved"=>"1");
  331. $this->db->in=array("f_id"=>"'".implode("','",$this->array_value_recursive('reId',$topreIdArr))."'");
  332. $columns = array("f_id","slug","title","re_type","thumbnail_img","original_img");
  333. $reArray = $this->db->dbSelectJoin($tables,$joins,$joinCondition,$columns,$whereCondition);
  334. $this->db->in = '';
  335. $this->db->order_by_column = '';
  336. $this->db->limit_val = '';
  337. $this->db->group_by_column = '';
  338. return $reArray;
  339. }
  340. }
  341.  
  342. renction get_trending($timelimit, $limit){
  343. // timelimit = month, week, day
  344. $CurrentTime = new DateTime();
  345. $time2Check = new DateTime();
  346. if($timelimit == 'week'){
  347. $time2Check->modify('-1 week');
  348. }else if($timelimit == 'month'){
  349. $time2Check->modify('-1 month');
  350. }else{
  351. $time2Check->modify('-1 day');
  352. }
  353. // GET TRENDING re
  354. $this->db->limit_val = $limit;
  355. $this->db->group_by_column="f_id";
  356. //$this->db->backticks="";
  357. $this->db->order_by_column = "SUM(f_id) DESC";
  358. $trendingArr = $this->db->dbSelect($this->ninja_config['TABLES_PREFIX']."retards_votelog", array("f_id"),
  359. array('did'=>'1',
  360. "date >="=>$time2Check->format('Y-m-d H:i:s'),
  361. "date <="=>$CurrentTime->format('Y-m-d H:i:s'))
  362. );
  363. if(count($trendingArr) < 2){
  364. $this->db->in = '';
  365. $this->db->order_by_column = '';
  366. $this->db->limit_val = '';
  367. $this->db->group_by_column = '';
  368. return NULL;
  369. }else{
  370. $tables = array($this->ninja_config['TABLES_PREFIX']."retards_re", $this->ninja_config['TABLES_PREFIX']."slug");
  371. $joins = array($this->ninja_config['TABLES_PREFIX']."retards_re.f_id=".$this->ninja_config['TABLES_PREFIX']."slug.c_id");
  372. $joinCondition = array("LEFT JOIN");
  373. $whereCondition = array($this->ninja_config['TABLES_PREFIX']."slug.page"=>"display_re",$this->ninja_config['TABLES_PREFIX']."slug.important"=>"0",$this->ninja_config['TABLES_PREFIX']."retards_re.isapproved"=>"1");
  374. $this->db->in=array("f_id"=>"'".implode("','",$this->array_value_recursive('f_id',$trendingArr))."'");
  375. $columns = array("f_id","slug","title","re_type","thumbnail_img","original_img");
  376. $reArray = $this->db->dbSelectJoin($tables,$joins,$joinCondition,$columns,$whereCondition);
  377. $this->db->in = '';
  378. $this->db->order_by_column = '';
  379. $this->db->limit_val = '';
  380. $this->db->group_by_column = '';
  381. return $reArray;
  382. }
  383. }
  384.  
  385. renction get_top_user($type, $count){
  386. // TYPE: POINT, JOINDATE // COUNT: HOW MANY?
  387. if($type == 'point'){
  388. $this->db->order_by_column = 'point DESC';
  389. }elseif($type == 'joindate'){
  390. $this->db->order_by_column = 'register_date DESC';
  391. }
  392. $this->db->limit_val = $count;
  393. $tables = array($this->ninja_config['TABLES_PREFIX']."retards_user", $this->ninja_config['TABLES_PREFIX']."users");
  394. $joins = array($this->ninja_config['TABLES_PREFIX']."retards_user.user_id=".$this->ninja_config['TABLES_PREFIX']."users.id");
  395. $joinCondition = array("LEFT JOIN");
  396. $columns = '';
  397. $userArray = $this->db->dbSelectJoin($tables,$joins,$joinCondition,$columns);
  398. $this->db->in = '';
  399. $this->db->order_by_column = '';
  400. $this->db->limit_val = '';
  401. $this->db->group_by_column = '';
  402. return $userArray;
  403. }
  404.  
  405. renction random_re(){
  406. $this->db->limit_val = '1';
  407. $this->db->order_by_column = "RAND()";
  408. $result = $this->db->dbSelect($this->ninja_config['TABLES_PREFIX']."slug",array("slug"),array("page"=>"display_re"));
  409. if(count($result) > 0){
  410. return $result[0]['slug'];
  411. }else{
  412. return NULL;
  413. }
  414. }
  415.  
  416. renction add_point($userid, $point){
  417. $query = "UPDATE ".$this->ninja_config['TABLES_PREFIX']."retards_user SET point=point+? WHERE user_id = ?";
  418. $this->db->dbExecuteQuery($query,array($point,$userid));
  419. if(isset($_SESSION['uId']) && $userid == $_SESSION['uId']){
  420. unset($_SESSION['thisUser']['point']);
  421. }
  422. }
  423. renction minus_point($userid, $point){
  424. $query = "UPDATE ".$this->ninja_config['TABLES_PREFIX']."retards_user SET point=point-? WHERE user_id = ?";
  425. $this->db->dbExecuteQuery($query,array($point,$userid));
  426. if(isset($_SESSION['uId']) && $userid == $_SESSION['uId']){
  427. unset($_SESSION['thisUser']['point']);
  428. }
  429. }
  430. renction sendNoti($userid,$content,$href = ''){
  431. $this->db->dbInsert($this->ninja_config['TABLES_PREFIX']."retards_user_notification",
  432. array("user_id"=>$userid,"href"=>$href,"content"=>$content,"dateadded"=>date('Y-m-d H:i:s'),"isread"=>"0"));
  433. //echo $this->db->error_info;
  434. }
  435. renction user_comment($userid){
  436. $this->db->limit_val = '1';
  437. $result = $this->db->dbSelect($this->ninja_config['TABLES_PREFIX']."users",
  438. array('displayname','avatar','username'),
  439. array("id"=>$userid)
  440. );
  441. if(count($result) > 0){
  442. return $result[0];
  443. }
  444. return array();
  445. //echo $this->db->error_info;
  446. }
  447. renction is_comment_exist($id){
  448. $this->db->limit_val = '1';
  449. $result = $this->db->dbSelect($this->ninja_config['TABLES_PREFIX']."retards_comments",
  450. array('re_id'),
  451. array("id"=>$id)
  452. );
  453. if(count($result) > 0){
  454. return true;
  455. }
  456. return false;
  457. //echo $this->db->error_info;
  458. }
  459. renction is_re_exist($id){
  460. $this->db->limit_val = '1';
  461. $result = $this->db->dbSelect($this->ninja_config['TABLES_PREFIX']."retards_re",
  462. array('f_id'),
  463. array("f_id"=>$id)
  464. );
  465. if(count($result) > 0){
  466. return true;
  467. }
  468. return false;
  469. //echo $this->db->error_info;
  470. }
  471.  
  472. // CUSTOM reNCTIONS GO HERE
  473.  
  474. }
  475.  
  476. // outside renction
  477.  
  478.  
  479. $ninja_retards = new ninja_retards($ninja_config);
  480. $ninja_retards->setLang($lang);
  481. $ninja_retards->setConfig($retards_config);
  482. $ninja_retards->setUserConfig($retards_user_config);
  483. $ninja_retards->setSlug($retards_slug);
  484. $ninja_retards->setThemeConfig($retards_theme);
  485.  
  486. // CHECK IF USER ALREADY HAD A POINT TABLE OR NOT
  487. if($retards_config['is_user'] == '1' && isset($_SESSION['thisUser'])){
  488. $ninja->db->limit_val = '1';
  489. $result = $ninja->db->dbSelect($ninja_config['TABLES_PREFIX']."retards_user",array("user_id"),array("user_id"=>$_SESSION['thisUser']['id']));
  490. if(count($result) < 1){
  491. $ninja->db->dbInsert($ninja_config['TABLES_PREFIX']."retards_user",array("user_id"=>$_SESSION['thisUser']['id'],"point"=>"0","badge"=>"{\"\":\"\"}"));
  492. }
  493. $_SESSION['pointed'] = 1;
  494. }
  495. // CHECK IF THEY HAD RECEIVED DAILY POINTS OR NOT
  496. if($retards_config['is_user'] == '1' && isset($_SESSION['thisUser'])){
  497. $ninja->db->limit_val = '1';
  498. $result = $ninja->db->dbSelect($ninja_config['TABLES_PREFIX']."retards_user_dailypoint",array("user_id"),array("user_id"=>$_SESSION['thisUser']['id'],"day"=>date("z"),"year"=>date("Y")));
  499. if(count($result) < 1){
  500. $ninja->db->dbInsert($ninja_config['TABLES_PREFIX']."retards_user_dailypoint",array("user_id"=>$_SESSION['thisUser']['id'],"day"=>date("z"),"year"=>date("Y")));
  501. $ninja_retards->add_point($_SESSION['thisUser']['id'],$retards_user_config['daily_point']);
  502. $ninja_retards->sendNoti($_SESSION['thisUser']['id'],sprintf($lang['up_you_earn_daily'], $retards_user_config['daily_point']));
  503. }
  504. $_SESSION['dailypointed'] = 1;
  505. }
  506. // CHECK AND MERGE USER POINT WITH USER INFO
  507. if($retards_config['is_user'] == '1' && isset($_SESSION['thisUser'])){
  508. $ninja->db->limit_val = '1';
  509. $result = $ninja->db->dbSelect($ninja_config['TABLES_PREFIX']."retards_user",array("point","badge"),array("user_id"=>$_SESSION['thisUser']['id']));
  510. if(count($result) > 0){
  511. $_SESSION['thisUser'] = array_merge($result[0], $_SESSION['thisUser']);
  512. }
  513. }
  514.  
  515. // GET retards CATEGORY FOR FASTER CUSTOMIZATION
  516. $ninja->db->order_by_column = "order_id ASC, name ASC";
  517. $ninja->db->limit_val = "";
  518. $retards_cat_array = $ninja->db->dbSelect($ninja_config['TABLES_PREFIX']."retards_cat",array("name","cat_id"));
  519. $ninja->db->order_by_column='';
  520.  
  521. // JSHINK
  522.  
  523. include ROOT_DIR.'/ninja-applications/retards/controllers/JShrink/Minifier.php';
  524. $min = new Minifier;
  525.  
  526.  
  527. // NEW reNCTIONS
  528.  
  529. renction slug($string){
  530. return strtolower(trim(preg_replace('~[^0-9a-z]+~i', '-', html_entity_decode(preg_replace('~&([a-z]{1,2})(?:acute|cedil|circ|grave|lig|orn|ring|slash|th|tilde|uml);~i', '$1', htmlentities($string, ENT_QUOTES, 'UTF-8')), ENT_QUOTES, 'UTF-8')), '-'));
  531. }
  532.  
  533. renction rank_suffix($number){
  534. $ends = array('th','st','nd','rd','th','th','th','th','th','th');
  535. if (($number %100) >= 11 && ($number%100) <= 13) return 'th';
  536. return $ends[$number % 10];
  537. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement