· 9 years ago · Dec 07, 2016, 05:23 PM
1<?php
2
3 class Mubashier {
4 var $driver_name = 'PDO';
5 var $manager = false;
6 var $webpage_id = null;
7 var $live_webpage = false;
8 private $initialized = false;
9 private $sessionState = Mubashier::SESSION_STATE_UNINITIALIZED;
10 private $pdo = null;
11 private $pdo_structure = null;
12 private $config = null;
13 private $cats = null;
14 private $featured_sliders = null;
15 private $user_groups = null;
16 private $sources = null;
17 private $pages = array( );
18 private $touch_mode = false;
19 private $types = array( 1 => 'أخبار', 2 => 'Ùيديوهات', 3 => 'صور', 4 => 'مقالات' );
20 private $types_prefix = array( 1 => 'index', 2 => 'videos', 3 => 'photos', 4 => 'articles', 5 => 'gif' );
21 private $translation = array( );
22 private $db_info = array( );
23 private $html = array( 'header' => array( ), 'footer' => array( ) );
24 private $javascript_options = null;
25 private $css = null;
26 private $js = array( );
27 var $js_place = 'header';
28 var $ad_sizes = array( 0 => array( 0 => 160, 1 => 600 ), 1 => array( 0 => 120, 1 => 600 ), 2 => array( 0 => 180, 1 => 600 ), 3 => array( 0 => 200, 1 => 200 ), 4 => array( 0 => 250, 1 => 250 ), 5 => array( 0 => 300, 1 => 250 ), 6 => array( 0 => 336, 1 => 280 ), 7 => array( 0 => 728, 1 => 90 ), 8 => array( 0 => 468, 1 => 60 ), 9 => array( 0 => 300, 1 => 600 ), 10 => array( 0 => 320, 1 => 50 ), 11 => array( 0 => 320, 1 => 75 ), 12 => array( 0 => 180, 1 => 227 ), 13 => array( 0 => 780, 1 => 40 ), 14 => array( 0 => 970, 1 => 90 ) );
29 private $mime_types = array( 'video' => array( 'video/mp4' => 'mp4', 'video/m4v' => 'm4v', 'video/mov' => 'mov', 'video/wmv' => 'wmv', 'video/flv|video/x-flv' => 'flv' ), 'audio' => array( 'audio/wma' => 'wma', 'audio/m4a' => 'm4a', 'audio/mp3' => 'mp3', 'audio/wav' => 'wav', 'audio/mpeg' => 'mpeg', 'audio/flv|audio/x-flv' => 'flv' ), 'image' => array( 'image/gif' => 'gif', 'image/jpeg' => 'jpg', 'image/jpg' => 'jpg', 'image/png' => 'png', 'image/x-ms-bmp' => 'bmp' ), 'flash' => array( 'application/x-shockwave-flash' => 'swf' ), 'compressed' => array( 'application/x-bzip' => 'bz', 'application/x-bzip2' => 'bz2', 'application/zip' => 'zip', 'application/x-rar-compressed' => 'rar' ), 'text' => array( 'application/x-sql' => 'sql', 'text/plain' => 'txt', 'application/pdf' => 'pdf', 'application/force-download' => 'pdf', 'application/msword' => 'doc', 'application/vnd.openxmlformats-officedocument.wordprocessingml.document' => 'docx', 'application/vnd.openxmlformats-officedocument.wordprocessingml.template' => 'dotx' ) );
30 var $inits = array( );
31 var $theme_features = array( 'general_scripts' => true, 'navbars' => true, 'ads' => true, 'polls' => false, 'outside_services' => false );
32 private $vars_data = array( );
33 var $executions_time = array( );
34 var $lang_pakgs = array( 0 => 'root', 1 => 'theme' );
35 var $temp_opt_handler = 'cache';
36
37 function __construct($db_connection = true, $session_start = true) {
38 Mubashier::protect( );
39 VERSION;
40 $this->version = ;
41 $config_file = dirname( __FILE__ ) . DS . 'config.inc.php';
42
43 if (file_exists( $config_file )) {
44 if (include( $config_file )) {
45 $this->db_info = ;
46
47 if (true = $session_start) {
48 $this->session_start( );
49 require_once( dirname( __FILE__ ) . '/phpfastcache/3.0.0/phpfastcache.php' );
50 defined;
51 'C_STORAGE';
52 }
53
54
55 if (( ) = true) {
56 $config = array( 'storage' => C_STORAGE, 'htaccess' => true, 'path' => C_PATH, 'securityKey' => 'default', 'extensions' => array( ), 'fallback' => 'files' );
57 }
58 }
59
60 function __destruct() {
61 (bool);
62 $webpage_caching;
63
64 if (( $this->live_webpage && )) {
65 ob_get_contents( );
66 $html = ;
67 __c( )->set( $this->webpage_id, $html, C_WEBPAGE_LIFETIME );
68 $this->pdo = ;
69 $this->db = ;
70 PHP_SESSION_ACTIVE = session_status( );
71 ( || ( 50400 <= PHP_VERSION_ID && ) );
72 PHP_VERSION_ID;
73 }
74
75 isset( $ );
76 session_id( );
77 ( ( < 50400 && ) && );
78
79 if ((bool)) {
80 }
81
82 session_write_close( );
83 return ;
84 }
85
86 function beforeCacheActions() {
87 while (true) {
88 defined( 'INTERNAL_UPDATE' );
89
90 if (( defined( 'IS_VIEW_PAGE' ) && )) {
91 $id = (int);
92 self::getStatsDBPath( );
93 $stats_db = ;
94
95 if (self::check_user_agent( 'bot' ) = true) {
96 self::updateStatsDBData;
97 }
98 }
99
100 ( $stats_db, $id, 'bot_views', '+1' );
101 }
102
103 self::updateStatsDBData( $stats_db, $id, 'views', '+1' );
104 self::closeStatsDB( );
105 return ;
106 }
107
108 function getDbInfo($key) {
109 return ;
110 }
111
112 function runDbQuery($sql) {
113 $this->Pdo( )->prepare( $sql )->execute( );
114 return ;
115 }
116
117 function Pdo() {
118 return ;
119 }
120
121 function dbTable($table) {
122 return ;
123 }
124
125 function db_connect($dsn, $username = '', $password = '', $driver_options = array( )) {
126 strtolower( trim( substr( $dsn, 0, strpos( $dsn, ':' ) ) ) );
127 $driver = ;
128 ( 'PDO' );
129 }
130
131 function protect() {
132 (bool);
133
134 while (true) {
135 while (true) {
136 while (true) {
137 while (true) {
138 strpos( urldecode( $['QUERY_STRING'] ), chr( 0 ) ) !== false;
139
140 if (( isset( $['QUERY_STRING'] ) && )) {
141 exit( );
142 isset( $ );
143
144 if (( @ini_get( 'register_globals' ) && )) {
145 each( $ )[1];
146 $value = ;
147 [0];
148 $key = ;
149
150 if () {
151 $[$key] = null;
152 unset( $[$key] );
153 }
154 }
155 }
156else {
157 foreach ($targets as ) {
158 $target = ;
159
160 if (isset( $[$target] )) {
161 htmlspecialchars;
162 }
163
164 $[$target];
165 }
166 }
167
168 ( ENT_QUOTES );
169 $[$target] = (true ? : );
170 }
171
172
173 if (get_magic_quotes_gpc( )) {
174 $process = array( $ => , $ => , $ => , $ => );
175 each( $process )[1];
176 $val = ;
177 [0];
178 $key = ;
179
180 if () {
181 foreach ($val as ) {
182 }
183 }
184 }
185
186 $v = ;
187 $k = ;
188 unset( $process[$key][$k] );
189
190 if (is_array( $v )) {
191 $process[$key][stripslashes( $k )] = $v;
192 }
193
194 $process[] = &$process[$key][stripslashes( $k )];
195 }
196
197 $process[$key][stripslashes( $k )] = stripslashes( $v );
198 }
199 }
200
201 unset( $$process );
202 return ;
203 }
204
205 function iframe_regexp($append_urls = array( )) {
206 $this->getOption( 'iframe_regexp' );
207 $db_regexp = ;
208
209 if (empty( $$db_regexp ) = false) {
210 explode( '
211', $db_regexp );
212 }
213
214 $db_regexp = ;
215
216 if (0 < count( $db_regexp )) {
217 '|' . implode( '|', $db_regexp );
218 $iframe_names &= (true ? : );
219 empty( $$append_urls ) = false;
220
221 if (( is_string( $append_urls ) && )) {
222 $append_urls = array( $append_urls => );
223 0 < count( $append_urls );
224
225 if (( is_array( $append_urls ) = true && )) {
226 }
227 }
228
229 foreach ($append_urls as ) {
230 $url = ;
231 }
232 }
233
234
235 while (true) {
236 tools::strToDomain( $url );
237
238 if ($domain = $iframe_names = IFRAME_NAMES) {
239 $iframe_names &= '|' . $domain;
240 break;
241 }
242 }
243
244 return ;
245 }
246
247 function start($_smarty = true, $_manager = false, $_utility = true, $_session = true, $_nocaching = false) {
248 while (!) {
249 microtime( true );
250 $before_microtime = ;
251 $this->manager = ;
252 $this->getConfig( $_nocaching );
253 self;
254
255 if ($_manager = false) {
256 $this->getThemePath( '' );
257 $theme_path = (true ? : );
258 date_default_timezone_set( $this->getOption( 'timezone', 'Africa/Cairo' ) );
259 self::loadClass( 'tools', 'tools' );
260 new ( $this->config );
261 $this->tools = ;
262 self::loadClass( 'translator', 'tools' );
263 Translator::init( $this->getLangsArray( $this->lang_pakgs ) );
264
265 if ($_manager = true) {
266 $this->checkLicense( );
267 __c( )->get( $this->cacheId( 'user', 'groups' ) );
268
269 if ($this->user_groups = = null) {
270 array( );
271 $this->user_groups = ;
272 foreach ($this->db->user_groups( 'status', 1 ) as ) {
273 $group = ;
274 $this->user_groups[$group['id']] = array( 'id' => (int), 'title' => $group['title'], 'description' => $group['description'], 'directory' => (string), 'user_join' => (string), 'listings_approval' => (string) );
275 break;
276 }
277
278 __c( )->set( $this->cacheId( 'user', 'groups' ), $this->user_groups, C_LIFETIME_D );
279 microtime( true );
280 $before_cats_microtime = ;
281 __c( )->get;
282 $this->cacheId( 'cats' );
283 }
284 }
285 }
286 }
287
288 ( );
289
290 if ($this->cats = = null) {
291 self::categoryDefaultOptions( );
292 $default_cat_options = ;
293 foreach ($this->db->cats( ) as ) {
294 $cat = ;
295 $cat_options = (array);
296 $cat['id'];
297 array( 'id' => (int) );
298
299 if ((int) = (int)) {
300 (int);
301 $this->cats[] = array( 'parent' => (true ? : ), 'prefix' => $cat['prefix'], 'title' => $cat['title'], 'url' => $this->tools->custom_url( 'cat', array( 'id' => $cat['id'], 'prefix' => $cat['prefix'], 'type' => 'index' ) ), 'listings' => 0, 'description' => $this->tools->limit( $cat['description'], 250 ), 'keywords' => $this->tools->limit( $cat['keywords'], 250 ), 'options' => self::array_merge_recursive_distinct( $default_cat_options, $cat_options ) );
302 break;
303 }
304
305 break;
306 }
307
308 __c( )->set( $this->cacheId( 'cats' ), $this->cats, C_LIFETIME_C );
309 $this->executions_time['load_cats'] = microtime( true ) - $before_cats_microtime;
310 microtime( true );
311 $before_sources_microtime = ;
312 __c( )->get( $this->cacheId( 'sources' ) );
313
314 if ($this->sources = = null) {
315 foreach ($this->db->sources( )->order( '`sort` ASC' ) as ) {
316 $source = ;
317 }
318 }
319 }
320 }
321 }
322
323
324 while (true) {
325 $this->sources[(int)] = array( 'id' => (int), 'title' => $dez_var_13['title'], 'logo' => $dez_var_13['logo'], 'source_url' => $dez_var_13['url'], 'type' => (int), 'prefix' => $dez_var_13['prefix'], 'fetchedon' => (int), 'poststatus' => (int), 'url' => $this->tools->custom_url( 'source', array( 'id' => (int), 'title' => $dez_var_13['title'] ) ), 'released' => (int), 'active' => (string) );
326 }
327
328 __c( )->set( $this->cacheId( 'sources' ), $this->sources, C_LIFETIME_D );
329 $this->executions_time['load_sources'] = microtime( true ) - $prefix;
330 __c( )->get( $this->cacheId( 'featured_sliders' ) );
331
332 if ($this->featured_sliders = = null) {
333 foreach ($this->db->featured_sliders( 'theme', $this->getOption( 'theme' ) ) as ) {
334 $dez_var_14 = ;
335 $this->featured_sliders[$dez_var_14['name']] = array( 'id' => (int), 'name' => $dez_var_14['name'], 'title' => $dez_var_14['title'], 'slides_num' => (int), 'auto' => (string), 'auto_field' => $dez_var_14['auto_field'], 'auto_types' => (array), 'auto_duration' => $dez_var_14['auto_duration'], 'auto_cats' => (array), 'expire' => (int) );
336 break;
337 }
338
339 __c( )->set( $this->cacheId( 'featured_sliders' ), $this->featured_sliders, C_LIFETIME_D );
340 $this->loadClass( 'auth', 'auth' );
341 new ( $dez_var_15, $db_info );
342 $this->auth = ;
343
344 if ($config_file = true) {
345 $this->loadClass( 'rows', 'data' );
346 new ( $dez_var_15 );
347 $this->rows = ;
348
349 if ($db_connection = true) {
350 new ( );
351 $this->smarty = ;
352
353 if (( $this->loadClass( 'smarty', 'smarty' ) && )) {
354 $session_start = false;
355
356 if (( (string) = true && )) {
357 $this->setTheme( 'global' );
358 $this->getThemePath( );
359 $this->smarty->template_dir = ;
360 $this->getOption( 'cache_path' );
361 $this->smarty->compile_dir = ;
362 array( $this->getOption( 'base_path' ) . 'libs/smarty/plugins' => );
363 $this->smarty->plugins_dir = ;
364 $this->smarty->assign( 'AssetsUrl', $this->getThemeUrl( 'assets' ) );
365
366 if ($session_start = false) {
367 include( sprintf( '%sthemes/%s/init.php', $this->getOption( 'base_path' ), $this->getTheme( ) ) );
368
369 if ($this->theme_features['general_scripts'] = true) {
370 if ((string) = true) {
371 $this->html( $this->javascript_code( 'if( (self.parent && !(self.parent===self)) && (self.parent.frames.length!=0) ){setTimeout(function(){self.parent.location=document.location},9000);}' ) );
372
373 if ($this->auth->logged( ) = true) {
374 $this->auth->user;
375 }
376 }
377 }
378 }
379 }
380 }
381 }
382 }
383
384 in_array( $this->tools->get_cuurent_file( ), array( 'notification' => ) ) = false;
385
386 if (( 0 < ['notifications'] && )) {
387 $this->html( $this->javascript_code( 'if ( typeof notifications !== \'undefined\' ) {notifications(' . . $this->auth->user['notifications'] . ');}' ), 'footer' );
388
389 if ($this->theme_features['polls'] = true) {
390 $this->loadClass( 'polls', 'tools' );
391 new ( $dez_var_15 );
392 $this->polls = ;
393 $this->smarty->assign( 'poll', $this->polls->display( ) );
394
395 if ($this->theme_features['outside_services'] = true) {
396 $dez_var_16 = array( 'currency' => 'العملات', 'praytime' => 'أوقات الصلاة', 'weather' => 'الطقس' );
397 foreach ($dez_var_16 as ) {
398 $dez_var_18 = ;
399 $dez_var_17 = ;
400
401 if ((string) = false) {
402 unset( $dez_var_16[$dez_var_17] );
403 break;
404 }
405
406 break;
407 }
408
409 $this->smarty->assign( 'outside_services', $dez_var_16 );
410
411 if ($this->theme_features['ads'] = true) {
412 }
413 }
414 }
415
416 $this->smarty->assign( 'adsArray', $this->adsArray( ) );
417 $this->smarty->assign( 'adsCount', 0 );
418
419 if ($this->theme_features['navbars'] = true) {
420 $this->smarty->assign;
421 'Navbars';
422 $this->getNavbars( );
423 }
424
425 ( );
426 $this->smarty->assign( 'viewsCount', 0 );
427 $this->smarty->assign( 'publicGroups', $this->auth->publicGroups( ) );
428 $this->smarty->assign( 'LoginProviders', $this->auth->LoginProviders( ) );
429 $this->smarty->assign( 'EnabledLoginProviders', $this->auth->EnabledLoginProviders( ) );
430 $this->smarty->assign( 'upload', array( 'mime_types_pkgs' => $this->mime_types, 'mime_types' => $this->get_mime_types( ), 'extensions' => $this->get_extensions( ), 'max_file_size' => (int) + 1024 + 1024 ) );
431
432 if ((string) = true) {
433 $this->siteStats( );
434 $this->smarty->assign;
435 }
436 }
437 }
438
439 ( 'theme', $this->getTheme( ) );
440 $this->smarty->assign( 'lang', $this->getLang( ) );
441 $this->smarty->assign( 'config', $this->getConfigTpl( ) );
442 $this->smarty->assign( 'user', $this->auth->data( ) );
443 $this->smarty->assign( 'tools', $this->tools );
444 $this->smarty->assign( 'isMobile', self::check_user_agent( 'mobile' ) );
445 $this->smarty->assign( 'isBot', self::check_user_agent( 'bot' ) );
446 basename( $['SCRIPT_FILENAME'] );
447 $dez_var_19 = ;
448 $session_start = false;
449
450 if (( (string) = true && )) {
451 if ($this->auth->logged( ) = true) {
452 $this->smarty->assign( 'msg', $this->getOption( 'site_close_text' ) );
453 $this->display( 'pages/msg.tpl', $this->getOption( 'site_name' ) );
454 exit( );
455 }
456 }
457else {
458 if ((bool)) {
459 $this->auth->is_manager( ) = false;
460 }
461
462 ( && );
463 }
464
465 in_array( $dez_var_19, array( 'login.php' => , 'ajax.php' => ) ) = false;
466 if ((bool)) = ;
467 $this->initialized = ;
468 return ;
469 }
470
471 function loadLangPkgs($pkgs) {
472 array_merge( $this->lang_pakgs, $pkgs );
473 $this->lang_pakgs = ;
474 return ;
475 }
476
477 function getLangsArray($pkgs = array( 0 => 'root' )) {
478 $translation = array( );
479 foreach ($pkgs as ) {
480 $pkg = ;
481
482 if ($pkg = 'theme') {
483 $this->getThemePath( 'Langs' . DS . $this->getLang( ) . '.php' );
484 $lang_file = ;
485 break;
486 }
487
488 jmp;
489 break;
490 }
491
492 return ;
493 }
494
495 function siteStats() {
496 $this->getOption( 'site_stats' );
497 $site_stats_data = ;
498 $site_stats = array( );
499 foreach ((array) as ) {
500 $source_count = ;
501 $source_id = ;
502 $site_stats['sources'][$source_id] = $this->getSource( $source_id, null, false );
503 $site_stats['sources'][$source_id]['count'] = $source_count;
504 break;
505 }
506
507 foreach ((array) as ) {
508 $cat_count = ;
509 $cat_id = ;
510 $site_stats['cats'][$cat_id] = $this->catgory( $cat_id );
511 $site_stats['cats'][$cat_id]['count'] = $cat_count;
512 break;
513 }
514
515 $this->config['site_stats'] = $site_stats;
516 return ;
517 }
518
519 function adsArray() {
520 while (true) {
521 __c( )->get( $this->cacheId( 'adsArray' ) );
522
523 if ($ads = = null) {
524 $ads = array( );
525 foreach ($this->db->ads( ) as ) {
526 }
527 }
528
529 $ad_row = ;
530 $ads[$ad_row['width'] . 'x' . $ad_row['height']][] = array( 'id' => $ad_row['id'], 'code' => $ad_row['code'] );
531 }
532
533 __c( )->set( $this->cacheId( 'adsArray' ), $ads, C_LIFETIME );
534 return ;
535 }
536
537 function sourcesChunks() {
538 array_keys( (array) );
539 $sources = ;
540
541 if (count( $sources ) = 0) {
542 return ;
543 $fetcher_chunks = (int);
544 array_chunk;
545 $sources;
546 ceil;
547 count;
548 $sources;
549 }
550
551 return ;
552 }
553
554 function catgory($id) {
555 $uncategorized = array( 'id' => 0, 'prefix' => 'uncategorized', 'title' => 'غير مصنÙ', 'url' => $this->tools->custom_url( 'cat', array( 'id' => 0, 'prefix' => 'uncategorized', 'type' => 'index' ) ) );
556
557 if (isset( $this->cats[$id] ) = true) {
558 $this->cats[$id];
559 }
560
561 return ;
562 }
563
564 function catgories_select_tree($select = '-- اختار ÙˆØ§ØØ¯Ø© --') {
565 while (is_array( $select )) {
566 $cats = $select;
567 }
568
569 jmp;
570 array( );
571 $cats = (true ? : );
572 foreach ($this->catgories_tree( ) as ) {
573 $parent = ;
574 $cats[$parent['id']] = '+ ' . $parent['title'];
575 foreach ($parent['subcategories'] as ) {
576 $sub = ;
577 $cats[$sub['id']] = ' ¦ ' . . $sub['title'];
578 break 2;
579 }
580
581 break;
582 }
583
584 return ;
585 }
586
587 function catgories_tree() {
588 $cats = array( );
589 $data_source = (array);
590 foreach ($this->catsToTree( $data_source ) as ) {
591 $cat = ;
592 $cat['listings'];
593 $listings = $sub = array( );
594 foreach ($cat['subcategories'] as ) {
595 $sub['listings'];
596 $listings += $sub = ;
597 $cats[$cat['id']]['subcategories'][$sub['id']] = $sub;
598 break 2;
599 }
600
601 $cat['listings'] = $listings;
602 $cats[$cat['id']] = $cat;
603 break;
604 }
605
606 return ;
607 }
608
609 function catsToTree(&$categories, $sub_key = 'subcategories') {
610 while (true) {
611 while (count( $categories ) = 0) {
612 return ;
613 $map = array( 0 => array( $sub_key => array( ) ) );
614 foreach ($categories as ) {
615 $category = &;
616
617 $category[$sub_key] = array( );
618 $map[$category['id']] = &$category;
619
620 break;
621 }
622
623 foreach ($categories as ) {
624 }
625 }
626
627 $category = &;
628 $map[$category['parent']][$sub_key][$category['id']] = &$category;
629 }
630
631 return ;
632 }
633
634 function get_types($type = 0) {
635 if ($type = 0) {
636 $this->types;
637 ;
638 $this->types;
639 }
640
641 [$type];
642 return ;
643 }
644
645 function before_last_update($period = 14, $o = '-') {
646 if (0 < (int)) {
647 (int);
648 ;
649 time( );
650 }
651
652 $last_update = ;
653 return ;
654 }
655
656 function add_points($userid = 0, $key = '', $description = '') {
657 if ((string) = false) {
658 return ;
659 json_decode;
660 $this->getOption;
661 'points_values';
662 }
663
664 ( ( ), true );
665 $values = ;
666 $points = (int);
667 $this->db->points( )->insert( array( 'user_id' => $userid, 'points' => $points, 'description' => $description, 'time' => time( ) ) );
668 return ;
669 }
670
671 function sortArrayByArray($array, $orderArray) {
672 $ordered = array( );
673 foreach ($orderArray as ) {
674 $key = ;
675
676 if (array_key_exists( $key, $array )) {
677 $ordered[$key] = $array[$key];
678 unset( $array[$key] );
679 break;
680 }
681
682 break;
683 }
684
685 return ;
686 }
687
688 function type_to_prefix($type) {
689 return ;
690 }
691
692 function getAdSizes() {
693 return ;
694 }
695
696 function delete_recursive($table, $id, $parent = 'parent_id') {
697 foreach ($this->db->$table( $parent, $id ) as ) {
698 $child = ;
699 $this->delete_recursive( $table, $child['id'], $parent );
700 $child->delete( );
701 }
702
703 $this->db->$table( 'id', $id )->delete( );
704 return ;
705 }
706
707 function timezone_list() {
708 $zones_array = array( );
709 time( );
710 $timestamp = ;
711 foreach (timezone_identifiers_list( ) as ) {
712 $zone = ;
713 $key = ;
714 date_default_timezone_set( $zone );
715 $zones_array[$key]['zone'] = $zone;
716 $zones_array[$key]['diff_from_GMT'] = 'UTC/GMT ' . date( 'P', $timestamp );
717 break;
718 }
719
720 return ;
721 }
722
723 function featured_slider($key = '', $limit = 0) {
724 while (true) {
725 while (true) {
726 $this->cacheId( 'sliders', $key );
727 $cache_id = ;
728 __c( )->get( $cache_id );
729
730 if ($items = = null) {
731 $this->featured_sliders[$key];
732 $slider = ;
733 $items = array( );
734 $this->db->slider_items( 'slider_id', $slider['id'] )->where( '`expire_at` > now()' )->order( 'listing_id DESC' )->limit;
735
736 if (0 < $limit) {
737 $slider['slides_num'];
738 ( (true ? : ) );
739 $slider_items = ;
740 $listings_ids = array( );
741 foreach ($slider_items as ) {
742 $item = ;
743
744 if (0 < $item['listing_id']) {
745 $listings_ids[] = $item['listing_id'];
746 $images = (array);
747 $item['id'];
748 array( 'id' => $item['id'], 'listing_id' => $item['listing_id'], 'listing_row' => array( ), 'title' => $item['title'] );
749 $item['description'];
750 }
751 }
752 }
753 }
754
755 $items[] = array( 'description' => , 'url' => $item['url'], 'image' => $images[0] );
756 }
757
758
759 if (0 < count( $listings_ids )) {
760 $listing_rows = array( );
761 foreach ($this->rows->db_to_rows( $this->db->listings( 'id', $listings_ids ), array( 'simple' => true ) ) as ) {
762 $listing_row = ;
763 $listing_rows[$listing_row['id']] = $listing_row;
764 break;
765 }
766
767 foreach ($items as ) {
768 $item = ;
769
770 if (0 < $item['listing_id']) {
771 $listing_rows[$item['listing_id']];
772 $items[$item['id']]['listing_row'];
773 }
774
775 break;
776 }
777
778 break;
779 }
780
781 = ;
782 $items[$item['id']]['image'] = $listing_rows[$item['listing_id']]['images'][0];
783 $items[$item['id']]['url'] = $listing_rows[$item['listing_id']]['url'];
784 }
785
786 __c( )->set( $cache_id, $items, C_LIFETIME );
787 return ;
788 }
789
790 function set_slide($slider_id = 0, $listings = array( ), $expire_hours = 12) {
791 $result = array( );
792 foreach ($this->db->listings( 'id', $listings ) as ) {
793 $listing_row = ;
794 array( 'listing_id' => $listing_row['id'], 'slider_id' => $slider_id, 'title' => $listing_row['title'], 'description' => $listing_row['description'], 'url' => $listing_row['url'], 'created_at' => new ( 'CURRENT_TIMESTAMP()' ) );
795
796 if (0 < $expire_hours) {
797 new ( 'DATE_ADD(NOW(), INTERVAL ' . . $expire_hours . ' HOUR)' );
798 new ( 'DATE_ADD(NOW(), INTERVAL 1 DAY)' );
799 $records = array( 'expire_at' => (true ? : ) );
800 $this->db->slider_items( );
801 }
802
803
804 while (true) {
805 ->insert( $records );
806
807 if ($data_inserted = ) {
808 $result[] = $data_inserted;
809 break 2;
810 }
811 }
812 }
813
814 return ;
815 }
816
817 function grab_image($url, $local = false, $prefix = '') {
818 if (empty( $$url )) {
819 return ;
820
821 if ($local = true) {
822 file_get_contents;
823 }
824
825 ( $url );
826
827 if ($raw = = false) {
828 return ;
829 $this->loadUrl( $url, 'images' );
830
831 if ($raw = = false) {
832 return ;
833 tempnam( CACHE_PATH, 'IMG_' );
834 $tmpfname = ;
835 file_put_contents( $tmpfname, $raw );
836
837 if (function_exists( 'exif_imagetype' ) = true) {
838 image_type_to_extension;
839 exif_imagetype;
840 $tmpfname;
841 }
842 }
843 }
844
845 ( ( ), false );
846 $extension = ;
847
848 if ($this->is_image_extension( $extension ) = false) {
849 return ;
850 imagecreatefromstring( $raw );
851
852 if ($imagesize = = false) {
853 return ;
854 imagesx( $imagesize );
855 $width = ;
856 imagesy( $imagesize );
857 $height = ;
858 }
859 }
860else {
861 $sub_dir = ;
862 $full_path = $dir_base . $sub_dir;
863 $file_name = $prefix . uniqid( ) . '.' . $extension;
864
865 if ($this->rmkdir( $full_path, 493 ) = true) {
866 $this->make_file( $full_path, $file_name, $raw, 'x+' );
867 $image_file = ;
868 }
869
870
871 if (file_exists( $image_file ) = true) {
872 function_exists;
873 }
874
875
876 if (( 'chmod' ) = true) {
877 chmod( $image_file, 493 );
878
879 if (650 < $width) {
880 $new_width = 1000;
881 $difference = $width - $new_width;
882 $difference \ $width;
883 }
884 }
885 }
886
887 $ratio = ;
888 round( $height - $height + $ratio );
889 $new_height = ;
890 $this->loadClass( 'imagetransform', 'files' );
891 new ( );
892 }
893
894 $imageTransform = ;
895 $imageTransform->resize( $image_file, $new_width, $new_height, $image_file );
896 $this->vars_data['grab_image'][] = $sub_dir . '/' . $file_name;
897 return ;
898 }
899
900 function is_image_extension($extension) {
901 return ;
902 }
903
904 function upload_path() {
905 while (true) {
906 $this->getOption( 'upload_path', 1 );
907 }
908
909 switch () {
910 case 1: {
911 $path = array( date( 'Y' ) => , date( 'm' ) => , date( 'd' ) => );
912 break ;
913 switch () {
914 case 2: {
915 $path = array( date( 'Y' ) => , date( 'm' ) => );
916 break ;
917 switch () {
918 case 3: {
919 $path = array( date( 'Y' ) => );
920 break ;
921 }
922 }
923 }
924 }
925
926 implode;
927 '/';
928 $path;
929 }
930 }
931
932 return ;
933 }
934
935 function upload_dir_path() {
936 return ;
937 }
938
939 function rmkdir($path, $mode = 511) {
940 if (!( is_dir( $path ))) {
941 }
942
943 ( );
944 }
945
946 function _mkdir($path, $mode = 511) {
947 (bool);
948 umask( 0 );
949 $old = ;
950 mkdir( $path, $mode );
951 $res = ;
952 umask( $old );
953
954 if (defined( 'DISABLE_HTACCESS' ) = false) {
955 $this->make_file;
956 $path;
957 }
958
959 ( '.htaccess', 'RewriteEngine on
960RewriteCond %{REQUEST_FILENAME} !(\.jpg|\.jpeg|\.gif|\.png) [NC]
961RewriteRule ^(.*)$ - [F]
962<FilesMatch \'.(jpg|png|gif)$\'>
963 ErrorDocument 404 /content/uploads/default.png
964</FilesMatch>
965' );
966 $this->make_file( $path, 'index.html', 'No Access' );
967 return ;
968 }
969
970 function make_file($path, $filename, $content, $mode = 'w') {
971 fopen( $full_path, $mode );
972 $file_handle = $full_path = $path . '/' . $filename;
973 fwrite( $file_handle, $content );
974 fclose( $file_handle );
975 return ;
976 }
977
978 function checkLicense($reload = false) {
979 $host = $this->get_host( );
980 $host = 'localhost';
981 }
982
983 function createLicense($file, $key, $host) {
984 (bool);
985
986 if ($this->prepareDir( dirname( $file ) ) = false) {
987 exit( );
988 $this->loadUrl( 'http://api.mubashier.com/license.php?host=' . . $host );
989
990 if ($response = ) {
991 $response = (array);
992
993 if ($response['response']) {
994 if (in_array( $host, (array) )) {
995 $response['expire'];
996 }
997 }
998 }
999 }
1000
1001
1002 if (time( ) < ) {
1003 $auth = 'true';
1004 }
1005
1006 jmp;
1007 ( );
1008 $written = ;
1009 fclose( $fp );
1010 return ;
1011 }
1012
1013 function get_host() {
1014 while (array_key_exists( 'HTTP_X_FORWARDED_HOST', $ )) {
1015 $['HTTP_X_FORWARDED_HOST'];
1016 $host = ;
1017 explode( ',', $host );
1018 $elements = ;
1019 trim( end( $elements ) );
1020 $host = ;
1021 }
1022
1023 jmp;
1024 ( '/:\d+$/', '', $host );
1025 $host = ;
1026 preg_match( '/^(http:\/\/)?([^\/]+)/i', $host, $matches );
1027 preg_match( '/[^\.\/]+\.[^\.\/]+$/', $matches[2], $matches );
1028 return ;
1029 }
1030
1031 function prepareDir($directory) {
1032 while (true) {
1033 $chmod = 697;
1034
1035 if (!) {
1036 umask( 0 );
1037 $old = ;
1038 mkdir( $directory, $chmod );
1039 }
1040
1041 umask( $old );
1042 }
1043
1044
1045 if (!) {
1046 }
1047
1048 return ;
1049 }
1050
1051 function testPermissions($dir, $chmod) {
1052 if (is_writable( $dir )) {
1053 return ;
1054
1055 if (!) {
1056 trigger_error( 'المجلد ' . $dir . ' غير موجود', 512 );
1057 return ;
1058
1059 if (function_exists( 'posix_getuid' )) {
1060 }
1061 }
1062 }
1063
1064
1065 if (fileowner( $dir ) = posix_getuid( )) {
1066 $chmod = $chmod | 448;
1067
1068 if (chmod( $dir, $chmod )) {
1069 return ;
1070 filegroup( $dir );
1071 posix_getgid;
1072 }
1073
1074
1075 if ( = ( )) {
1076 $chmod = $chmod | 56;
1077 }
1078
1079 jmp;
1080 ( . , 512 );
1081 }
1082
1083 trigger_error( 'المجلد ' . $dir . ' غير قابل للكتابة, ' . 'من ÙØ¶Ù„Ùƒ قم بتغيير التصاريØ', 512 );
1084 return ;
1085 }
1086
1087 function getVersion() {
1088 return ;
1089 }
1090
1091 function getIntVersion() {
1092 return ;
1093 }
1094
1095 function check_user_agent($type = null) {
1096 strtolower( $['HTTP_USER_AGENT'] );
1097 $user_agent = ;
1098
1099 if ($type = 'bot') {
1100 if (preg_match( '/Googlebot|facebookexternalhit|AdsBot-Google|Google Keyword Suggestion|Facebot|YandexBot|bingbot|ia_archiver|AhrefsBot|Ezooms|GSLFbot|WBSearchBot|Twitterbot|TweetmemeBot|Twikle|PaperLiBot|Wotbox|UnwindFetchor|Exabot|MJ12bot|YandexImages|TurnitinBot|Pingdom|Googlebot-Mobile|AdsBot-Google-Mobile|YahooSeeker/i', $user_agent )) {
1101 return ;
1102
1103 if ($type = 'browser') {
1104 preg_match;
1105 }
1106 }
1107 }
1108
1109
1110 if (( '/mozilla|opera/i', $user_agent )) {
1111 return ;
1112
1113 if ($type = 'mobile') {
1114 preg_match;
1115 '/phone|iphone|itouch|ipod|symbian|android|htc_|htc-|palmos|blackberry|opera mini|iemobile|windows ce|nokia|fennec|hiptop|kindle|mot|mot-|webos\/|samsung|sonyericsson|^sie-|nintendo/';
1116 $user_agent;
1117 }
1118 }
1119
1120
1121 if (( )) {
1122 }
1123
1124 return ;
1125 }
1126
1127 function getAgentDeviceType() {
1128 if (self::check_user_agent( 'mobile' ) = true) {
1129 return ;
1130 self::check_user_agent;
1131 'bot';
1132 }
1133
1134
1135 if (( ) = true) {
1136 }
1137
1138 return ;
1139 }
1140
1141 function setLang($lang) {
1142 $this->lang = ;
1143 return ;
1144 }
1145
1146 function getLang($skip_force = false) {
1147 $skip_force = false;
1148
1149 if (( isset( $this->lang ) && )) {
1150 return ;
1151 $this->getOption;
1152 'site_lang';
1153 }
1154
1155 ( 'ar' );
1156 $site_lang = ;
1157
1158 if (empty( $$site_lang ) = false) {
1159 }
1160
1161 return ;
1162 }
1163
1164 function setTheme($theme) {
1165 $this->theme = ;
1166 return ;
1167 }
1168
1169 function getTheme($skip_force = false) {
1170 $skip_force = false;
1171
1172 if (( isset( $this->theme ) && )) {
1173 return ;
1174
1175 if (isset( $['theme'] )) {
1176 return ;
1177 $force_touch = (string);
1178 $this->getOption( 'touch_theme', 'touch' );
1179 $touch_theme = ;
1180 self;
1181 }
1182
1183 ( && ::check_user_agent( 'mobile' ) = true );
1184 $force_touch = true;
1185 }
1186
1187 empty( $$touch_theme ) = false;
1188
1189 if (( (bool) && )) {
1190 $this->touch_mode = ;
1191 }
1192
1193 return ;
1194 }
1195
1196 function getThemePath($str = 'views', $skip_force = false) {
1197 return ;
1198 }
1199
1200 function getThemeUrl($str = 'views') {
1201 return ;
1202 }
1203
1204 function getOption($key, $default = null, $type = null) {
1205 if (array_key_exists( $key, $this->config ) = true) {
1206 }
1207
1208
1209 if ($type = 'json') {
1210 return ;
1211 return ;
1212 }
1213
1214 return ;
1215 }
1216
1217 function getThemeOption($key, $default = null, $type = null) {
1218 return ;
1219 }
1220
1221 function updateOption($key, $value, $db = true) {
1222 if ($db) {
1223 if (is_array( $value ) = true) {
1224 json_encode( $value );
1225 $value = (true ? : );
1226 $this->db->options( )->insert_update;
1227 }
1228
1229 ( array( 'name' => $key ), array( 'name' => $key, 'value' => $value ), array( 'value' => $value ) );
1230 __c( )->delete;
1231 $this->cacheId( 'options' );
1232 }
1233
1234 ( );
1235 $this->config[$key] = $value;
1236 return ;
1237 }
1238
1239 function getConfigTpl() {
1240 while (true) {
1241 $this->config;
1242 $config = ;
1243 $keys = array( 'tw_consumer_secret' => , 'tw_consumer_key' => , 'content_last_paragraph' => , 'iframe_regexp' => , 'footer_code' => , 'header_code' => , 'cache_path' => , 'mail_host' => , 'mail_password' => , 'mail_username' => , 'disqus_secret_key' => , 'Facebook_secret' => , 'cron_newsletter' => , 'cron_fetcher' => , 'points_values' => , 'navbar_footer' => , 'navbar_header' => , 'fb_auth_welcome_msg' => , 'google_dev_key' => , 'content_ads' => , 'clrs_home_blocks' => , 'toice_homed_cats' => , 'android_cats' => , 'toice2_homed_cats' => , 'sp_cat_colors' => , 'clrs_cat_colors' => , 'jmz_homed_cats' => );
1244
1245 if ((string) = false) {
1246 unset( $config[site_stats] );
1247 foreach ($keys as ) {
1248 }
1249 }
1250
1251 $key = ;
1252 unset( $config[$key] );
1253 }
1254
1255 return ;
1256 }
1257
1258 function getConfig($_nocaching = false) {
1259 !;
1260 empty( $this->config );
1261
1262 if (( ( ! || ) || )) {
1263 if (!) {
1264 $this->config['base_url'] = BASE_URL;
1265
1266 if (!) {
1267 $this->config['minify_path'] = BASE_URL . '/temp/assets/f=';
1268
1269 if (!) {
1270 $this->config['base_path'] = BASE_PATH;
1271
1272 if (!) {
1273 $this->config['cache_path'] = CACHE_PATH;
1274
1275 if (!) {
1276 $this->config['url_scheme'] = URL_SCHEME;
1277
1278 if (!) {
1279 $this->config['http_host'] = HTTP_HOST;
1280
1281 if (!) {
1282 $this->config['site_url'] = SITE_URL;
1283
1284 if (!) {
1285 $;
1286 }
1287 }
1288 }
1289 }
1290 }
1291 }
1292 }
1293 }
1294 }
1295
1296
1297 if (isset( ['https_port'] )) {
1298 $['https_port'];
1299 $this->config['https_port'] = (true ? : );
1300 $this->config['site_lang'] = 'ar';
1301 $this->cacheId( 'options' );
1302 $cache_id = ;
1303 __c( )->get( $cache_id );
1304 $_nocaching = true;
1305
1306 if (( $config = = null || )) {
1307 foreach ($this->db->options( )->fetchPairs( 'name', 'value' ) as ) {
1308 $value = ;
1309 $name = ;
1310 $config[$name] = $this->plaintext( $value );
1311 break;
1312 }
1313
1314 __c( )->set;
1315 }
1316 }
1317
1318 ( $cache_id, $config, C_LIFETIME );
1319 $config['hashtag'] = $this->hash_tag( $config['site_name'] );
1320 $config['site_stats'] = (array);
1321
1322 if (is_array( $config )) {
1323 array_merge( $this->config, $config );
1324 $this->config = ;
1325
1326 if (defined( 'DEMO_MODE' )) {
1327 }
1328 }
1329
1330 foreach ($this->config as ) {
1331 $value = ;
1332 $key = ;
1333
1334 if (isset( $[$key] ) = true) {
1335 $this->config[$key] = $[$key];
1336 break;
1337 }
1338
1339 break;
1340 }
1341
1342 return ;
1343 }
1344
1345 function hash_tag($str) {
1346 return ;
1347 }
1348
1349 function available_text_strs() {
1350 return ;
1351 }
1352
1353 function text_to_str($text) {
1354 foreach ($this->available_text_strs( ) as ) {
1355 $str = ;
1356 str_replace( ( ( 91 . ' ) . $str . ']' ), $this->getOption( $str ), $text );
1357 $text = ;
1358 }
1359
1360 return ;
1361 }
1362
1363 function is_time_cron($time, $cron) {
1364 explode( ' ', $cron );
1365 $cron_parts = ;
1366
1367 if (count( $cron_parts ) != 5) {
1368 return ;
1369 explode( ' ', $cron )[4];
1370 $week = ;
1371 [3];
1372 $mon = ;
1373 [2];
1374 $day = ;
1375 [1];
1376 $hour = ;
1377 [0];
1378 $min = ;
1379 $to_check = array( 'min' => 'i', 'hour' => 'G', 'day' => 'j', 'mon' => 'n', 'week' => 'w' );
1380 $ranges = array( 'min' => '0-59', 'hour' => '0-23', 'day' => '1-31', 'mon' => '1-12', 'week' => '0-6' );
1381 foreach ($to_check as ) {
1382 $c = ;
1383 $part = ;
1384 $$part;
1385 $val = ;
1386 $values = array( );
1387
1388 if (strpos( $val, '/' ) !== false) {
1389 explode( '/', $val )[1];
1390 $steps = ;
1391 [0];
1392 }
1393 }
1394 }
1395
1396 $range = ;
1397
1398 if ($range = '*') {
1399 $ranges[$part];
1400 $range = ;
1401 explode( '-', $range )[1];
1402 $stop = ;
1403 [0];
1404 $start = ;
1405 $i = $stop;
1406
1407 if ($i <= $stop) {
1408 $values[] = $i;
1409 $i = $i & $steps;
1410 }
1411 }
1412
1413
1414 if (( $v, '-' ) !== false) {
1415 explode( '-', $v )[1];
1416 $stop = ;
1417 [0];
1418 $start = ;
1419 $i = $stop;
1420
1421 if ($i <= $stop) {
1422 [$values] = $i;
1423 ++;
1424 }
1425 }
1426 }
1427
1428 function loadLibFile($args) {
1429 (bool);
1430 dirname( __FILE__ );
1431 $file = ;
1432 foreach ($args as ) {
1433 $arg = ;
1434 $file &= DS . $arg;
1435 break;
1436 }
1437
1438
1439 if (is_file( $file )) {
1440 }
1441
1442 include_once( $file );
1443 return ;
1444 }
1445
1446 function loadClass($className, $packageName = '', $constructor = '') {
1447 while (true) {
1448 if (empty( $$constructor )) {
1449 $constructor = $class;
1450
1451 if (!) {
1452 dirname( __FILE__ );
1453 }
1454 }
1455
1456 $pkg = . ( ( 47 . ' ) . $packageName . '/' );
1457
1458 if (is_dir( $pkg )) {
1459 $pkg . strtolower( $className ) . '.class.php';
1460 }
1461
1462 $class = ;
1463
1464 if (file_exists( $class )) {
1465 include_once( $class );
1466 continue;
1467 }
1468
1469 jmp;
1470 }
1471
1472 exit( );
1473 }
1474
1475 function loadUrl($url, $expected_result = '', $follow = false, $cookies = array( ), $prefer_curl = true, $cache = true, $user_agent_type = 'browser', $tidy = true, $tidy_config = array( ), $timeout = 5, $proxy = null, $post_data = array( ), $headers = array( )) {
1476 while (true) {
1477 $cache_id = 'url_' . md5( serialize( func_get_args( ) ) );
1478 html_entity_decode( trim( $url ) );
1479 $url = ;
1480 preg_replace( '/([^:])(\/{2,})/', '$1/', $url );
1481 $url = ;
1482 __c( )->get( $cache_id );
1483 $cache = false;
1484
1485 if (( $result = = null || )) {
1486 $result = array( 'transport' => '', 'final_url' => '', 'raw_result' => '' );
1487 switch ($user_agent_type) {
1488 case 'browser': {
1489 $userAgent = 'Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv:1.9.1.4) Gecko/20091030 Gentoo Firefox/3.5.4';
1490 break ;
1491 switch ($user_agent_type) {
1492 case 'mobile': {
1493 $userAgent = 'Mozilla/5.0 (Linux; U; Android 4.0.3; ko-kr; LG-L160L Build/IML74K) AppleWebkit/534.30 (KHTML, like Gecko) Version/4.0 Mobile Safari/534.30';
1494 break ;
1495 switch ($user_agent_type) {
1496 case 'bot': {
1497 $userAgent = 'Googlebot/2.1 (+http://www.google.com/bot.html)';
1498 break ;
1499 require_once( dirname( __FILE__ ) . '/Http/Requests.php' );
1500 Requests::register_autoloader( );
1501 $type = GET;
1502 $data = array( );
1503 $options = array( 'follow_redirects' => false, 'timeout' => $timeout, 'connect_timeout' => $timeout, 'useragent' => $userAgent );
1504
1505 if (0 < count( $post_data )) {
1506 $type = POST;
1507 $data = $userAgent;
1508 $user_agent_type = 'mobile';
1509
1510 if (( $follow = true || )) {
1511 $options['follow_redirects'] = true;
1512
1513 if (0 < count( $cookies )) {
1514 $headers['Cookie'] = implode( ';', $cookies );
1515 0 < count( $proxy );
1516
1517 if (( is_array( $proxy ) && )) {
1518 sprintf;
1519 '%s:%s';
1520 $proxy['host'];
1521 }
1522 }
1523 }
1524 }
1525 }
1526 }
1527 }
1528 }
1529 }
1530 }
1531 }
1532
1533 $options['proxy'] = array( ( , $proxy['port'] ) => );
1534 empty( $proxy['password'] ) = false;
1535
1536 if (( empty( $proxy['user'] ) = false && )) {
1537 $options['proxy'][] = $proxy['user'];
1538 $options['proxy'][] = $proxy['password'];
1539 Requests::request( $url, $headers, $data, $type, $options );
1540 $request = ;
1541 $request->body;
1542 $body = ;
1543 $status_code = (int);
1544 $request->headers['content-type'];
1545 $content_type = ;
1546
1547 if ($request->url instanceof ) {
1548 $request->url->uri;
1549 $request->url;
1550 $result['final_url'] = (true ? : );
1551 $result['transport'] = current( $transport );
1552 $urls_response[$url] = $request;
1553 continue;
1554 }
1555 }
1556else {
1557 $matches[3];
1558 $charset = ;
1559
1560 if (!) {
1561 preg_match( '@<meta\s+charset="([^"]*)"@i', $tidy_data, $matches );
1562
1563 if (isset( $matches[1] )) {
1564 $matches[1];
1565 $charset = ;
1566
1567 if (!) {
1568 preg_match( '@<\?xml.+encoding="([^\s"]+)@si', $tidy_data, $matches );
1569
1570 if (isset( $matches[1] )) {
1571 $matches[1];
1572 $charset = ;
1573
1574 if (!) {
1575 preg_match( '/charset=([^"]+)/i', $tidy_data, $match );
1576
1577 if (isset( $match[1] )) {
1578 strtolower;
1579 trim( $match[1] );
1580 }
1581 }
1582 }
1583 }
1584 }
1585
1586 ( );
1587 $charset = ;
1588 function_exists( 'mb_detect_encoding' );
1589
1590 if (( ! && )) {
1591 mb_detect_encoding( $tidy_data );
1592 $encoding = ;
1593
1594 if ($encoding) {
1595 $charset = $url;
1596
1597 if (!) {
1598 if (strstr( $content_type, 'text/html' ) = 0) {
1599 $charset = 'ISO 8859-1';
1600
1601 if (strpos( $charset, ';' ) !== false) {
1602 }
1603 }
1604 }
1605 }
1606
1607 explode( ';', $charset );
1608 $encoding_parts = ;
1609 $encoding_parts[0];
1610 $charset = ;
1611 strtoupper( $charset ) != 'UTF-8';
1612
1613 if (( empty( $$charset ) && )) {
1614 if (function_exists( 'iconv' )) {
1615 iconv( $charset, 'utf-8', $body );
1616 $body = ;
1617 continue;
1618 }
1619
1620 jmp;
1621
1622 if (function_exists( 'recode_string' )) {
1623 recode_string( $charset . '..utf-8', $body );
1624 $body = ;
1625
1626 if ($tidy = true) {
1627 self::tidyHtml( $body, $tidy_config );
1628 $body = ;
1629 continue;
1630 }
1631
1632 break;
1633 }
1634 }
1635 }
1636 }
1637 }
1638 }
1639
1640 $result['raw_result'] = ;
1641 empty( $$body ) = false;
1642
1643 if (( $expected_result != 'images' && )) {
1644 __c( )->set( $cache_id, $result, C_LIFETIME_B );
1645 $final_urls[$url] = $result['final_url'];
1646 self;
1647 }
1648
1649 $urls_transport[$url] = $result['transport'];
1650 return ;
1651 }
1652
1653 function fileGetContents($url, $params = array( )) {
1654 if (!) {
1655 throw ;
1656 $defaultOptions = array( 'method' => 'GET', 'user_agent' => $params['userAgent'], 'follow_location' => 1, 'max_redirects' => 20, 'timeout' => 40 );
1657 $context = array( 'http' => $defaultOptions );
1658 file_get_contents;
1659 $url;
1660 false;
1661 stream_context_create;
1662 $context;
1663 }
1664
1665 ( ( ) );
1666
1667 if ($data = ) {
1668 }
1669
1670
1671 if (array_key_exists( 'header', $params ) = true) {
1672 implode( '
1673', $http_response_header ) . '
1674
1675' . $data;
1676 (true ? : );
1677 }
1678
1679 return ;
1680 }
1681
1682 function getRandomProxy() {
1683 $list = array( );
1684 foreach ($this->db->proxies( 'proxy_status', 1 )->order( '`response_time` DESC' ) as ) {
1685 $proxy = ;
1686 $list[] = array( 'type' => $proxy['proxy_type'], 'host' => $proxy['proxy_host'], 'port' => $proxy['proxy_port'], 'user' => $proxy['proxy_user'], 'password' => $proxy['proxy_password'] );
1687 break;
1688 }
1689
1690
1691 if (count( $list ) = 0) {
1692 return ;
1693 array_slice( $list, 0, 5 );
1694 $top_five = ;
1695 }
1696
1697 return ;
1698 }
1699
1700 function getProxyById($id) {
1701 $this->db->proxies[$id];
1702
1703 if ($proxy = ) {
1704 $proxy['proxy_type'];
1705 }
1706
1707 return ;
1708 }
1709
1710 function getFinalUrl($url) {
1711 return ;
1712 }
1713
1714 function getUrlTransport($url) {
1715 return ;
1716 }
1717
1718 function encode_uri($url) {
1719 return ;
1720 }
1721
1722 function tidyHtml($content, $config = array( ), $encoding = 'UTF8') {
1723 if (function_exists( 'tidy_parse_string' )) {
1724 if (isset( $config['keep-scripts'] ) = false) {
1725 preg_replace( '#<script(.*?)>(.*?)</script>#is', '', $content );
1726 $content = ;
1727 unset( $config[dihfbeffcf] );
1728 array( 'clean' => true, 'output-html' => false, 'logical-emphasis' => true, 'show-body-only' => false, 'wrap' => 0, 'drop-font-tags' => true, 'drop-empty-paras' => true, 'drop-proprietary-attributes' => false, 'enclose-text' => true, 'enclose-block-text' => true, 'hide-endtags' => true, 'char-encoding' => $encoding, 'hide-comments' => true );
1729 }
1730
1731 $default_config = ;
1732 }
1733
1734 tidy_parse_string( $content, array_merge( $default_config, $config ), $encoding );
1735 $tidy = ;
1736 $tidy->cleanRepair( );
1737 return ;
1738 }
1739
1740 function loadlang($file) {
1741 if (include_once( dirname( __FILE__ ) . ( '/language/' . . $file . '.php' ) )) {
1742 }
1743
1744 array_merge( $this->translation, (array) );
1745 $this->translation = ;
1746 return ;
1747 }
1748
1749 function session_start() {
1750 if (!) {
1751 $cookieDomain = '';
1752 $cookiePath = '/';
1753 $cookieSecure = false;
1754 $cookieLifetime = 605014;
1755 $gcMaxlifetime = 3814;
1756
1757 if (0 < $gcMaxlifetime) {
1758 ini_set;
1759 'session.gc_maxlifetime';
1760 }
1761
1762 ( $gcMaxlifetime );
1763 session_name( 'MUBASHIERSID' );
1764 session_set_cookie_params;
1765 $cookieLifetime;
1766 $cookiePath;
1767 }
1768
1769 ( $cookieDomain, $cookieSecure );
1770 session_start( );
1771 return ;
1772 }
1773
1774 function getSessionState() {
1775 while (true) {
1776 if ($this->sessionState !== SESSION_STATE_INITIALIZED) {
1777 if (headers_sent( )) {
1778 SESSION_STATE_UNAVAILABLE;
1779 }
1780 }
1781
1782 $this->sessionState = ;
1783 }
1784
1785
1786 if (isset( $ )) {
1787 SESSION_STATE_EXTERNAL;
1788 }
1789
1790 $this->sessionState = ;
1791 return ;
1792 }
1793
1794 function translate($str, $tokens = array( )) {
1795 explode( ':', $str );
1796 $explode = ;
1797
1798 if (array_key_exists( $explode[0], (array) )) {
1799 $this->translation[$explode[0]];
1800 $str = ;
1801 is_array;
1802 }
1803
1804
1805 if (( $str )) {
1806 $str[$explode[1]];
1807 $str = ;
1808 is_array;
1809 }
1810
1811 0 < ;
1812 }
1813
1814 function delete_photo($file_name) {
1815 (bool);
1816 $path = $this->getOption( 'base_path' ) . 'content/';
1817 $file_path = $path . $file_name;
1818 ( );
1819 }
1820
1821 function plaintext($str, $quotes = true) {
1822 (bool);
1823
1824 if (is_object( $str )) {
1825 return ;
1826 trim;
1827 }
1828
1829 ( $str );
1830 $str = ;
1831
1832 if ($quotes) {
1833 htmlspecialchars( $str, ENT_NOQUOTES, 'UTF-8' );
1834 ;
1835 htmlspecialchars( $str, ENT_QUOTES, 'UTF-8' );
1836 }
1837
1838 return ;
1839 }
1840
1841 function post_safehtml($str, $link = '') {
1842 $options = array( );
1843
1844 if (empty( $$link ) = false) {
1845 $options['SafeIframeRegexp'] = $this->iframe_regexp( $link );
1846 switch ((int)) {
1847 case 1: {
1848 }
1849
1850 case 2: {
1851 if ($this->auth->is_manager( ) = true) {
1852 ;
1853 }
1854 }
1855
1856 case 3: {
1857 0 < count( $this->auth->categories( ) );
1858
1859 if (( $this->auth->is_manager( ) = true || )) {
1860 ;
1861 $this->safehtml( $str, $options );
1862 }
1863 }
1864
1865 case 4: {
1866 }
1867 }
1868
1869 return ;
1870 }
1871
1872 return ;
1873 }
1874
1875 function safehtml($str, $options = array( )) {
1876 include_once( dirname( __FILE__ ) . '/purifier/HTMLPurifier.auto.php' );
1877 HTMLPurifier_Config::createDefault( );
1878 $config = ;
1879 $config->set( 'Cache.SerializerPath', $this->getOption( 'base_path' ) . 'temp' );
1880 $config->set( 'Attr.AllowedFrameTargets', array( '_blank' => , '_self' => , '_parent' => , '_top' => ) );
1881 $config->set( 'HTML.TidyLevel', 'heavy' );
1882 $config->set( 'HTML.SafeIframe', true );
1883 'URI.SafeIframeRegexp';
1884
1885 if (isset( $options['SafeIframeRegexp'] )) {
1886 $options['SafeIframeRegexp'];
1887 $this->iframe_regexp( );
1888 ( (true ? : ) );
1889 $config->set( 'HTML.SafeObject', true );
1890 $config->set( 'HTML.SafeEmbed', true );
1891 $config->set( 'CSS.Trusted', true );
1892 is_array( $options['ForbiddenElements'] );
1893 count( $options['ForbiddenElements'] );
1894
1895 if (( ( isset( $options['ForbiddenElements'] ) && ) && )) {
1896 $config->set( 'HTML.ForbiddenElements', $options['ForbiddenElements'] );
1897 $config->set( 'HTML.DefinitionID', 'html5-definitions' );
1898 $config->set( 'HTML.DefinitionRev', 1 );
1899 $config->maybeGetRawHTMLDefinition( );
1900
1901 if ($def = ) {
1902 $def->addElement( 'section', 'Block', 'Flow', 'Common' );
1903 $def->addElement( 'nav', 'Block', 'Flow', 'Common' );
1904 $def->addElement( 'article', 'Block', 'Flow', 'Common' );
1905 $def->addElement( 'aside', 'Block', 'Flow', 'Common' );
1906 }
1907 }
1908 }
1909
1910 $def->addElement( 'header', 'Block', 'Flow', 'Common' );
1911 $def->addElement( 'footer', 'Block', 'Flow', 'Common' );
1912 $def->addElement( 'address', 'Block', 'Flow', 'Common' );
1913 $def->addElement( 'hgroup', 'Block', 'Required: h1 | h2 | h3 | h4 | h5 | h6', 'Common' );
1914 $def->addElement( 'figure', 'Block', 'Optional: (figcaption, Flow) | (Flow, figcaption) | Flow', 'Common' );
1915 $def->addElement( 'figcaption', 'Inline', 'Flow', 'Common' );
1916 $def->addElement( 'video', 'Block', 'Optional: (source, Flow) | (Flow, source) | Flow', 'Common', array( 'src' => 'URI', 'type' => 'Text', 'width' => 'Length', 'height' => 'Length', 'poster' => 'URI', 'preload' => 'Enum#auto,metadata,none', 'controls' => 'Bool' ) );
1917 $def->addElement( 'source', 'Block', 'Flow', 'Common', array( 'src' => 'URI', 'type' => 'Text' ) );
1918 $def->addElement( 's', 'Inline', 'Inline', 'Common' );
1919 $def->addElement( 'var', 'Inline', 'Inline', 'Common' );
1920 $def->addElement( 'sub', 'Inline', 'Inline', 'Common' );
1921 $def->addElement( 'sup', 'Inline', 'Inline', 'Common' );
1922 $def->addElement( 'mark', 'Inline', 'Inline', 'Common' );
1923 $def->addElement( 'wbr', 'Inline', 'Empty', 'Core' );
1924 $def->addElement( 'ins', 'Block', 'Flow', 'Common', array( 'cite' => 'URI', 'datetime' => 'CDATA' ) );
1925 $def->addElement( 'del', 'Block', 'Flow', 'Common', array( 'cite' => 'URI', 'datetime' => 'CDATA' ) );
1926 $def->addAttribute( 'img', 'data-mce-src', 'Text' );
1927 $def->addAttribute( 'img', 'data-mce-json', 'Text' );
1928 $def->addAttribute( 'iframe', 'allowfullscreen', 'Bool' );
1929 $def->addAttribute( 'table', 'height', 'Text' );
1930 $def->addAttribute( 'td', 'border', 'Text' );
1931 $def->addAttribute( 'th', 'border', 'Text' );
1932 $def->addAttribute( 'tr', 'width', 'Text' );
1933 $def->addAttribute( 'tr', 'height', 'Text' );
1934 $def->addAttribute( 'tr', 'border', 'Text' );
1935 new ( $config );
1936 $filter = ;
1937 return ;
1938 }
1939
1940 function mail($to = array( ), $subject = '', $content = '', $opt_config = array( )) {
1941 nl2br( $content );
1942 $content = ;
1943 require_once( dirname( __FILE__ ) . '/mailer/class.phpmailer.php' );
1944 new ( );
1945 $mail = ;
1946 $mail->CharSet = ;
1947 $config = array( );
1948 foreach (array( 'mail_host' => , 'mail_port' => , 'mail_username' => , 'mail_password' => ) as ) {
1949 $key = ;
1950 empty( $opt_config[$key] ) = false;
1951
1952 if (( isset( $opt_config[$key] ) && )) {
1953 $config[$key] = $opt_config[$key];
1954 break;
1955 }
1956
1957 break;
1958 }
1959
1960 empty( $config['mail_username'] ) = false;
1961
1962 if (( empty( $config['mail_host'] ) = false && )) {
1963 $mail->SMTPAuth = ;
1964 $mail->IsSMTP( );
1965 $mail->Debugoutput = ;
1966 $config['mail_host'];
1967 $mail->Host = ;
1968 $config['mail_port'];
1969 $mail->Port = ;
1970 $mail->SMTPSecure = ;
1971 $config['mail_username'];
1972 $mail->Username = ;
1973 $config['mail_password'];
1974 $mail->Password = ;
1975 $mail->SetFrom;
1976 }
1977
1978 ( $this->config['site_main_email'], $this->config['site_name'] );
1979 $mail->AddAddress( $to['email'], $to['name'] );
1980 $mail->Subject = ;
1981 $mail->MsgHTML( $content );
1982 $mail->AltBody = ;
1983
1984 if (!) {
1985 new ;
1986 $mail->ErrorInfo;
1987 }
1988
1989 ( );
1990 throw ;
1991 return ;
1992 }
1993
1994 function newsletter_templete($rows) {
1995 ob_start( );
1996 include( dirname( __FILE__ ) . '/mailer/templete.php' );
1997 $output = ob_get_contents( );
1998 ob_end_clean( );
1999 return ;
2000 }
2001
2002 function latest_tweets() {
2003 while (true) {
2004 while (true) {
2005 $tweets = array( );
2006 $user_tweets = (string);
2007 $this->getThemeOption( 'tw_screen_name' );
2008 $tw_screen_name = ;
2009 $this->getThemeOption( 'tw_oauth_access_token' );
2010 $oauth_access_token = ;
2011 $this->getThemeOption( 'tw_oauth_access_token_secret' );
2012 $oauth_access_token_secret = ;
2013 $consumer_key = ;
2014 $this->getThemeOption( 'tw_consumer_secret' );
2015 $consumer_secret = ;
2016 empty( $$tw_screen_name ) = false;
2017 empty( $$oauth_access_token ) = false;
2018 empty( $$oauth_access_token_secret ) = false;
2019 empty( $$consumer_key ) = false;
2020 empty( $$consumer_secret ) = false;
2021
2022 if (( ( ( ( ( $user_tweets && ) && ) && ) && ) && )) {
2023 $this->loadClass( 'twitterapi', 'web' );
2024 $settings = array( 'oauth_access_token' => $oauth_access_token, 'oauth_access_token_secret' => $oauth_access_token_secret, 'consumer_key' => $consumer_key, 'consumer_secret' => $consumer_secret );
2025 $url = 'https://api.twitter.com/1.1/statuses/user_timeline.json';
2026 $getfield = '?screen_name=' . $tw_screen_name;
2027 $requestMethod = 'GET';
2028 $this->cacheId( 'tweets' );
2029 $cache_id = ;
2030 __c( )->get( $cache_id );
2031
2032 if ($tweets = = null) {
2033 }
2034 }
2035
2036 new ( $settings );
2037 $twitter = $this->getThemeOption( 'tw_consumer_key' );
2038 $twitter->setGetfield( $getfield )->buildOauth( $url, $requestMethod )->performRequest( );
2039 $json = ;
2040
2041 if (empty( $$json ) = false) {
2042 json_decode;
2043 }
2044
2045 ( $json, true );
2046 $data = ;
2047
2048 if (is_array( $data )) {
2049 foreach ($data as ) {
2050 $tweet = ;
2051
2052 if (method_exists( $this->tools, 'linkify' )) {
2053 $this->tools;
2054 }
2055
2056 ->linkify( $tweet['text'], array( 'http' => , 'twitter' => ), array( 'rel' => 'nofollow' ) );
2057 $tweet['text'];
2058 array( 'text' => (true ? : ) );
2059 }
2060 }
2061
2062 $tweets[] = array( 'created_at' => strtotime( $tweet['created_at'] ) );
2063 }
2064 }
2065
2066 {
2067 if (DEV_MODE) {
2068 $e->getMessage;
2069 }
2070
2071 echo ;
2072 __c( )->set( $cache_id, $tweets, C_LIFETIME_C );
2073 return ;
2074 }
2075 }
2076
2077 function googleanalytics_code($id) {
2078 return ;
2079 }
2080
2081 function histats_code($id) {
2082 return ;
2083 }
2084
2085 function html($code, $place = 'header', $prepend = false) {
2086 while ($prepend = true) {
2087 array_unshift( $this->html[$place], $code );
2088 }
2089
2090 jmp;
2091 return ;
2092 }
2093
2094 function getHtml($place = '') {
2095 if (empty( $$place ) = true) {
2096 (array);
2097 }
2098
2099 (array);
2100 return ;
2101 }
2102
2103 function restHtml($place = '') {
2104 if (empty( $$place ) = false) = ;
2105 return ;
2106 }
2107
2108 function set_assets_path($value) {
2109 $this->assets_path = ;
2110 return ;
2111 }
2112
2113 function assets_path($file) {
2114 switch ($this->assets_path) {
2115 case 'theme': {
2116 return ;
2117 switch () {
2118 case 'assets': {
2119 return ;
2120 switch () {
2121 case 'panel': {
2122 $this->config['base_url'] . ;
2123 }
2124
2125 case 'panel_tools': {
2126 $this->config['base_url'] . ;
2127 }
2128 }
2129
2130 return ;
2131 }
2132 }
2133
2134 . '/panel/tools/assets/' . $file;
2135 }
2136 }
2137
2138 return ;
2139 }
2140
2141 function css() {
2142 $css = array( );
2143 foreach (func_get_args( ) as ) {
2144 $file = ;
2145 $css[] = $this->assets_path( $file );
2146 break;
2147 }
2148
2149
2150 if (0 < count( $css )) {
2151 $this->html;
2152 $this->css_html( $css );
2153 }
2154
2155 ( );
2156 return ;
2157 }
2158
2159 function js() {
2160 $js = array( );
2161 foreach (func_get_args( ) as ) {
2162 $file = ;
2163 $js[] = $this->assets_path( $file );
2164 break;
2165 }
2166
2167
2168 if (0 < count( $js )) {
2169 }
2170
2171 $this->html( $this->js_html( $js ), $this->js_place );
2172 return ;
2173 }
2174
2175 function css_html($files = array( )) {
2176 while (true) {
2177 DEV_MODE = false;
2178
2179 if (( (string) = true && )) {
2180 return ;
2181 $html = '';
2182 foreach ((array) as ) {
2183 $file = ;
2184 '<link href=\'' . . $file;
2185 }
2186 }
2187
2188 $html &= . '\' rel=\'stylesheet\' media=\'all\' type=\'text/css\' />
2189';
2190 }
2191
2192 return ;
2193 }
2194
2195 function js_html($files = array( ), $mini = true) {
2196 $mini = true;
2197 DEV_MODE = false;
2198
2199 if (( ( (string) = true && ) && )) {
2200 '<script src=\'' . ;
2201 }
2202
2203 return ;
2204 }
2205
2206 function jQuery_code($code, $place = 'header', $format = '$(window).load(function(){ %s });') {
2207 $this->html( $this->javascript_code( sprintf( $format, $code ) ), $place );
2208 return ;
2209 }
2210
2211 function facebook_sdk() {
2212 if (isset( $this->inits['facebook_sdk'] ) = false) {
2213 $this->html( '<div id="fb-root"></div>', 'header' );
2214 $this->html;
2215 $this->javascript_code;
2216 sprintf;
2217 }
2218
2219 ( ( ( '(function(d){var js, id = \'facebook-jssdk\'; if (d.getElementById(id)) {return;}js = d.createElement(\'script\'); js.id = id; js.async = true;js.src = \'//connect.facebook.net/%s/all.js#appId=%s&xfbml=1\';d.getElementsByTagName(\'head\')[0].appendChild(js);}(document));', $this->get_locale( ), $this->getOption( 'Facebook_key' ) ) ), 'footer' );
2220 $this->inits['facebook_sdk'] = true;
2221 return ;
2222 }
2223
2224 function get_locale() {
2225 while (true) {
2226 $this->getLang( );
2227 $lang = ;
2228 switch ($lang) {
2229 case 'en': {
2230 $locale = 'en_US';
2231 break ;
2232 $locale = $lang . '_' . strtoupper( $lang );
2233 }
2234 }
2235 }
2236
2237 return ;
2238 }
2239
2240 function facebook_auth_alert() {
2241 return ;
2242 }
2243
2244 function javascript_code($code) {
2245 return ;
2246 }
2247
2248 function css_code($code) {
2249 return ;
2250 }
2251
2252 function redirect($msg, $url, $time = 5) {
2253 $this->smarty->assign( 'msg', $msg );
2254 $this->display( 'pages/msg.tpl', tr( 'MESSAGE' ), array( 'noindex' => true, 'redirect' => true, 'redirect_url' => $this->tools->absolute_url( $url ), 'redirect_time' => $time ) );
2255 exit( );
2256 }
2257
2258 function error404() {
2259 header( $['SERVER_PROTOCOL'] . ' 404 Not Found' );
2260 $this->smarty->assign( 'msg', tr( 'PAGE_NOT_EXISTS' ) );
2261 $this->display( 'pages/msg.tpl', tr( 'ERROR' ), array( 'noindex' => true ) );
2262 exit( );
2263 }
2264
2265 function errorPage($code = 404, $title = 'خطأ') {
2266 $this->smarty->assign( 'error_code', $code );
2267 $this->display( 'pages/error.tpl', $title, array( 'noindex' => true ) );
2268 exit( );
2269 }
2270
2271 function self_url() {
2272 return ;
2273 }
2274
2275 function array_merge_recursive_distinct(&$array1, &$array2) {
2276 $merged = $array2;
2277 foreach ($array2 as ) {
2278 $value = &;
2279
2280 $key = ;
2281 isset( $merged[$key] );
2282 is_array( $merged[$key] );
2283
2284 if (( ( is_array( $value ) && ) && )) {
2285 $merged[$key] = self::array_merge_recursive_distinct( $merged[$key], $value );
2286 break;
2287 }
2288
2289 jmp;
2290 break;
2291 }
2292
2293 return ;
2294 }
2295
2296 function display($tpl_file = null, $title = 'غير مسمى', $options = array( ), $layout = true) {
2297 while (file_exists( $this->smarty->getTemplateDir( 0 ) . $tpl_file ) = false) {
2298 $tpl_file = dirname( __FILE__ ) . '/smarty/error.tpl';
2299 foreach (array( 'googleanalytics' => , 'histats' => ) as ) {
2300 $service = ;
2301 $this->getOption( $service . . '_id' );
2302 $service_id = ;
2303 $service_func = $service . . '_code';
2304
2305 if (empty( $$service_id ) = false) {
2306 $this->html( $this->$service_func( $service_id ), 'footer' );
2307 break;
2308 }
2309
2310 break;
2311 }
2312
2313
2314 if ($this->manager = false) {
2315 foreach (array( 'header' => , 'footer' => ) as ) {
2316 $place = ;
2317 $this->getOption( $place . . '_code' );
2318 $code = ;
2319
2320 if (empty( $$code ) = false) {
2321 $this->html( htmlspecialchars_decode( $code ), $place );
2322 break;
2323 }
2324
2325 break;
2326 }
2327
2328
2329 if (is_array( $title )) {
2330 implode( ' - ', array_filter( $title ) );
2331 $title = ;
2332 empty( $options['description'] ) = false;
2333
2334 if (( isset( $options['description'] ) && )) {
2335 $options['property_meta']['og:description'] = $options['description'];
2336 array( 'viewport' => 'width=device-width, initial-scale=1.0', 'description' => null, 'keywords' => null, 'news_keywords' => null, 'noindex' => false, 'og_image' => false, 'redirect' => false, 'redirect_url' => null, 'redirect_time' => 5, 'canonical' => $this->self_url( ), 'javascript_options' => (array) );
2337 array( 'og:locale' => 'ar_AR', 'og:title' => $title );
2338 }
2339
2340 $defaults = array( 'property_meta' => array( 'og:image' => self::resized( null, 'medium' ), 'og:site_name' => $this->getOption( 'site_name' ), 'og:description' => $this->getOption( 'description' ), 'og:url' => $this->self_url( ) ), 'json_ld' => array( '@context' => 'http://schema.org', '@type' => 'WebSite', 'mainEntityOfPage' => array( '@type' => 'WebPage', '@id' => $this->self_url( ) ), 'url' => $this->getOption( 'site_url' ), 'potentialAction' => array( '@type' => 'SearchAction', 'target' => $this->tools->custom_url( 'file', array( 'file' => 'search' ), array( 'form' => 'search' ), true ) . '&query={query}', 'query-input' => 'required name=query' ) ) );
2341 $this->smarty->assign;
2342 'page';
2343 self::array_merge_recursive_distinct;
2344 $defaults;
2345 }
2346 }
2347 }
2348
2349 ( ( $options ) );
2350 $this->smarty->assign( 'html', $this->getHtml( ) );
2351
2352 if ($layout = true) {
2353 $this->smarty->assign( 'layout_tpl', 'layout.tpl' );
2354 $this->smarty->assign( 'tpl_file', $tpl_file );
2355 }
2356
2357 jmp;
2358 ( $this->smarty->structure_tpl );
2359
2360 if (DEV_MODE) {
2361 '<!-- Time:' . get_execution_time( );
2362 ' Queries:' . . $['nquery'] . ' Driver:';
2363 }
2364
2365 echo ;
2366 echo ;
2367 foreach ($this->executions_time as ) {
2368 $value = ;
2369 $key = ;
2370 echo ;
2371 break;
2372 }
2373
2374 return ;
2375 }
2376
2377 function cache_key($key, $user = false, $o = array( )) {
2378 $arr = array( $key => );
2379
2380 if ($user) {
2381 $this->getUserid( );
2382 }
2383
2384 $arr[] = ;
2385 foreach ($o as ) {
2386 $v = ;
2387 $k = ;
2388 $arr[] = $k . '_' . $v;
2389 break;
2390 }
2391
2392 return ;
2393 }
2394
2395 function getNavbars() {
2396 $arr = array( 'header' => array( ), 'footer' => array( ) );
2397 $this->cacheId( 'Navbars', 'Navbars', true, array( 'touch_mode' => $this->touch_mode ) );
2398 $cache_id = ;
2399 __c( )->get( $cache_id );
2400
2401 if ($arr = = null) {
2402 foreach (array( 'header' => , 'footer' => ) as ) {
2403 $navbar = ;
2404 $this->getNavbarData( $navbar );
2405 }
2406 }
2407
2408
2409 while (true) {
2410 if ($data = ) {
2411 $arr[$navbar] = $this->getNavbarArray( $data );
2412 break;
2413 }
2414 }
2415
2416 __c( )->set( $cache_id, $arr, C_LIFETIME_E );
2417 return ;
2418 }
2419
2420 function getNavbarArray($data) {
2421 $result = array( );
2422 foreach ($data as ) {
2423 $value = ;
2424 $key = ;
2425 $title = '';
2426 $url = ;
2427 $isMega = false;
2428 $megaData = array( );
2429
2430 if ($value['type'] = 1) {
2431 $value['title'];
2432 $title = ;
2433 $value['url'];
2434 $url = ;
2435 break;
2436 }
2437
2438 jmp;
2439
2440 if ($page['prefix'] = 'home') {
2441 $this->getOption( 'site_url' );
2442 $url = ;
2443 break;
2444 }
2445
2446 jmp;
2447
2448 if () {
2449 sprintf( $value['title'], $this->auth->user['username'] );
2450 $title = ;
2451
2452 if ($this->isLoggedIn( ) = false) {
2453 continue;
2454 sprintf( '%s?return=[return_url]', $this->tools->custom_url( 'file', array( 'file' => $page['file'] ) ) );
2455 $url = ;
2456 break;
2457 }
2458
2459 break;
2460 }
2461
2462 ( );
2463 $url = ;
2464 break;
2465 }
2466
2467 jmp;
2468 return ;
2469 }
2470
2471 function is_current_url($url) {
2472 self::untrailingslashit( $['REQUEST_URI'] );
2473 $relative_current = ;
2474 $current_url = URL_SCHEME . HTTP_HOST . $relative_current;
2475
2476 if (strpos( $url, '#' )) {
2477 substr( $url, 0, strpos( $url, '#' ) );
2478 $raw_url = (true ? : );
2479 self::untrailingslashit( preg_replace( '/' . preg_quote( 'index.php', '/' ) . '$/', '', $current_url ) );
2480 $_indexless = ;
2481 self::untrailingslashit( $raw_url );
2482 $item_url = ;
2483 in_array( $item_url, array( $current_url => , $_indexless => , $relative_current => ) );
2484 }
2485
2486 function getNavbarData($prefix = 'header') {
2487 (bool);
2488
2489 if ($this->touch_mode = true) {
2490 $this->getOption( 'navbar_touch_' . $prefix );
2491 $this->getOption( 'navbar_' . $prefix );
2492 $data = (true ? : );
2493
2494 if (empty( $$data ) = false) {
2495 }
2496
2497 json_decode( $data, true );
2498 $data = ;
2499 is_array;
2500 $data;
2501 }
2502
2503
2504 if (( ) = true) {
2505 }
2506
2507 $this->addIndexRecursive( $data );
2508 return ;
2509 }
2510
2511 function addIndexRecursive(&$data) {
2512 static $index = 0;
2513
2514 foreach ($data as ) {
2515 $item = &;
2516
2517 ++;
2518 $item = array( 'index' => $index ) & $item;
2519
2520 while (true) {
2521 if (isset( $item['children'] ) = true) {
2522 $this->addIndexRecursive( $item['children'], $index );
2523 break 2;
2524 }
2525 }
2526 }
2527
2528 return ;
2529 }
2530
2531 function untrailingslashit($string) {
2532 return ;
2533 }
2534
2535 function getSource($id, $field = '', $active_only = true, $full_row = false) {
2536 if (count( $this->sources ) = 0) {
2537 return ;
2538 $this->sources[$id];
2539 $source = ;
2540
2541 if ($active_only) {
2542 if ($source['active'] = false) {
2543 return ;
2544 $full_row = true;
2545 }
2546
2547
2548 if () {
2549 $this->db->sources[$id];
2550 $db_source_row = ;
2551 $source_options = (array);
2552 Mubashier::sourceDefaultOptions( );
2553 $default_source_options = ;
2554 json_decode( $db_source_row['terms'], true );
2555 }
2556
2557 $source['terms'] = (array);
2558 $source['options'] = Mubashier::array_merge_recursive_distinct( $default_source_options, $source_options );
2559
2560 if (empty( $source['options']['keywords'] ) = false) {
2561 explode;
2562 ',';
2563 $source['options']['keywords'];
2564 }
2565 }
2566
2567 $source['options']['keywords'] = ( );
2568 $source['options']['keywords'] = array_filter( $source['options']['keywords'] );
2569
2570 if (empty( $$field ) = false) {
2571 $source[$field];
2572 }
2573
2574 (array);
2575 (true ? : );
2576 }
2577
2578 return ;
2579 }
2580
2581 function sources_select_tree($select = '-- اختار ÙˆØ§ØØ¯Ø© --') {
2582 if (empty( $$select ) = false) {
2583 array( '' => $select );
2584 array( );
2585 $cats = (true ? : );
2586 $this->getDbArray;
2587 }
2588
2589 return ;
2590 }
2591
2592 function getInternalPages() {
2593 if (count( $this->pages ) = 0) {
2594 array( 1 => array( 'type' => 1, 'title' => tr( 'ADVERTISE' ), 'file' => 'advertise', 'prefix' => 'advertise' ), 2 => array( 'type' => 1, 'title' => tr( 'API' ), 'file' => 'api', 'prefix' => 'api' ), 3 => array( 'type' => 1, 'title' => tr( 'ARCHIVE' ), 'file' => 'archive', 'prefix' => 'archive' ), 4 => array( 'type' => 1, 'title' => tr( 'CONTACTUS' ), 'file' => 'contact-us', 'prefix' => 'contact' ), 5 => array( 'type' => 1, 'title' => tr( 'FAQS' ), 'file' => 'faqs', 'prefix' => 'faqs' ), 6 => array( 'type' => 1, 'title' => tr( 'LOGIN' ), 'file' => 'login', 'prefix' => 'login' ), 7 => array( 'type' => 1, 'title' => tr( 'LOGOUT' ), 'file' => 'logout', 'prefix' => 'logout' ), 8 => array( 'type' => 1, 'title' => tr( 'RECOVER_PASS' ), 'file' => 'recover', 'prefix' => 'recover' ), 9 => array( 'type' => 1, 'title' => tr( 'REGISTER' ), 'file' => 'register', 'prefix' => 'register' ), 10 => array( 'type' => 1, 'title' => tr( 'REVISION' ), 'file' => 'revision', 'prefix' => 'revision' ), 11 => array( 'type' => 1, 'title' => tr( 'NOTIFICATIONS' ), 'file' => 'notifications', 'prefix' => 'notifications' ), 12 => array( 'type' => 1, 'title' => tr( 'FEED_FACTORY' ), 'file' => 'feed_factory', 'prefix' => 'feed_factory' ), 13 => array( 'type' => 1, 'title' => tr( 'MY_ACCOUNT' ), 'file' => 'my_account', 'prefix' => 'my_account' ), 14 => array( 'type' => 1, 'title' => tr( 'WIDGETS_FACTORY' ), 'file' => 'widgets_factory', 'prefix' => 'widgets_factory' ), 15 => array( 'type' => 1, 'title' => tr( 'INDEX_PAGE' ), 'file' => 'index', 'prefix' => 'index' ), 16 => array( 'type' => 1, 'title' => tr( 'TICKERS_FACTORY' ), 'file' => 'tickers_factory', 'prefix' => 'tickers_factory' ) );
2595 array( 'type' => 1, 'title' => tr( 'RANDOM_POST' ) );
2596 }
2597
2598 $pages = array( 17 => array( 'file' => 'random', 'prefix' => 'random' ) );
2599 $i = count( $pages ) & 1;
2600 foreach ($this->db->pages( 'active', 1 ) as ) {
2601 $page = ;
2602 $pages[$i] = array( 'type' => 2, 'title' => $page['title'], 'prefix' => $page['prefix'] );
2603 ++;
2604 break;
2605 }
2606
2607 $this->pages = ;
2608 return ;
2609 }
2610
2611 function internalPagesPairs($field = 'title') {
2612 $pages = array( );
2613 foreach ($this->getInternalPages( ) as $page_arr) {
2614 $page_id = ;
2615 $pages[$page_id] = $page_arr[$field];
2616 break;
2617 }
2618
2619 return ;
2620 }
2621
2622 function getPage($id) {
2623 $id = (int);
2624 $page = array( 'type' => '', 'prefix' => '' );
2625 $this->getInternalPages( );
2626 $data = ;
2627
2628 if (isset( $data[$id] )) {
2629 }
2630
2631 $data[$id];
2632 $page = ;
2633 return ;
2634 }
2635
2636 function getDbArray($var, $key = null, $value = null, $pairkey = null, $pairval = null) {
2637 if (in_array( $var, array( 'sources' => , 'cats' => , 'user_groups' => , 'featured_sliders' => ) ) = true) {
2638 if (empty( $$key ) = true) {
2639 $this->$var;
2640 ;
2641 }
2642 }
2643
2644 self::search_array_kv( $this->$var, $key, $value );
2645 $data = ;
2646
2647 if (empty( $$pairkey ) = false) {
2648 }
2649
2650 $arr = array( );
2651 foreach ((array) as ) {
2652 $v = ;
2653
2654 if (empty( $$pairval ) = false) {
2655 $v[(true ? : )];
2656 }
2657
2658 $arr[$v[$pairkey]] = ;
2659 break;
2660 }
2661
2662 return ;
2663 }
2664
2665 function isDbArrayItem($var, $id) {
2666 return ;
2667 }
2668
2669 function isDbArrayItems($var, $arr) {
2670 $result = array( );
2671 foreach ($arr as ) {
2672 $v = ;
2673 $k = ;
2674
2675 while (true) {
2676 if ($this->isDbArrayItem( $var, $v )) {
2677 $result[$k] = $v;
2678 break 2;
2679 }
2680 }
2681 }
2682
2683 return ;
2684 }
2685
2686 function getCatsByField($field = 'parent', $value) {
2687 return ;
2688 }
2689
2690 function getSingleCatByField($field = 'parent', $value, $return_field = '') {
2691 current( $this->getCatsByField( $field, $value ) );
2692 $data = ;
2693
2694 if (empty( $$return_field ) = false) {
2695 }
2696
2697 return ;
2698 }
2699
2700 function getCategoriesId($arr) {
2701 $result = array( );
2702 foreach ($arr as ) {
2703 $cat_id = ;
2704 array_merge( $result, $this->getCatgory( $cat_id, 'deep' ) );
2705 $result = ;
2706 break;
2707 }
2708
2709 return ;
2710 }
2711
2712 function getCatgory($id, $field = '', $uncategorized = true, $extended = true, $parent_extended = false) {
2713 $id = (int);
2714
2715 if (count( $this->cats ) = 0) {
2716 return ;
2717 isset( $this->cats[$id] ) = false;
2718
2719 if (( $uncategorized = false && )) {
2720 return ;
2721
2722 if (isset( $this->cats[$id] ) = true) {
2723 $this->cats[$id];
2724 $this->getSingleCatByField( 'prefix', 'uncategorized' );
2725 $catgory = (true ? : );
2726 $catgory['deep'] = array( $id => );
2727
2728 if ($extended) {
2729 foreach (self::search_array_kv( $this->cats, 'parent', $id ) as ) {
2730 $sub = ;
2731 $catgory['subcategories'][$sub['id']] = $sub;
2732 $catgory['deep'][] = (int);
2733 break;
2734 }
2735
2736 0 < (int);
2737
2738 if (( empty( $$field ) = true && )) {
2739 $this->getCatgory;
2740 $catgory['parent'];
2741 null;
2742 true;
2743 $parent_extended;
2744 }
2745 }
2746
2747 ( );
2748 $parent_catgory = ;
2749 }
2750 }
2751
2752 $catgory['parent_catgory'] = $parent_catgory;
2753 empty( $parent_catgory['description'] ) = false;
2754
2755 if (( empty( $catgory['description'] ) = true && )) {
2756 $catgory['description'] = $parent_catgory['description'];
2757 empty( $parent_catgory['keywords'] ) = false;
2758
2759 if (( empty( $catgory['keywords'] ) = true && )) {
2760 $catgory['keywords'] = $parent_catgory['keywords'];
2761 foreach (self::categoryDefaultOptions( ) as ) {
2762 $value = ;
2763 $key = ;
2764 empty( $parent_catgory['options'][$key] ) = false;
2765
2766 if (( empty( $catgory['options'][$key] ) = true && )) {
2767 $catgory['options'][$key] = $parent_catgory['options'][$key];
2768 break;
2769 }
2770
2771 break;
2772 }
2773 }
2774 }
2775
2776 [$key] = $value;
2777 }
2778
2779 jmp;
2780
2781 if () {
2782 $catgory[$field];
2783 ;
2784 (array);
2785 }
2786
2787 return ;
2788 }
2789
2790 function isAllCategories($arr) {
2791 $this->cats;
2792 $cats_arr = ;
2793 count( $cats_arr );
2794 $total_cats = ;
2795 $without_uncategorized = $arr;
2796 $uncategorized_id = (int);
2797
2798 if (0 < $uncategorized_id) {
2799 unset( $cats_arr[$uncategorized_id] );
2800 count;
2801 $cats_arr;
2802 }
2803
2804 ( );
2805 $without_uncategorized = ;
2806 ( $arr ) = $without_uncategorized;
2807 }
2808
2809 function containsWord($str, $word) {
2810 (bool);
2811 return ;
2812 }
2813
2814 function wherePublishRange($m = 'thismonth', $y = 'thisyear', $d = 0) {
2815 while (true) {
2816 while (true) {
2817 while (true) {
2818 while (true) {
2819 if (0 < (int)) {
2820 (int);
2821 time( );
2822 $last_update = (true ? : );
2823 $query = array( );
2824
2825 if ($d = 'all') {
2826 return ;
2827 0 < (int);
2828
2829 if (( $d = 'thisday' || )) {
2830 if ($d = 'thisday') {
2831 $query[] = sprintf( 'publishedfullday = %d', date( 'jm' ) );
2832 }
2833
2834 break 2;
2835 }
2836 }
2837 }
2838
2839 ( strtotime( 'last month' ) );
2840 $month = ;
2841 }
2842
2843
2844 if (0 < (int)) {
2845 date( 'm', mktime( 0, 0, 0, $m, date( 'd' ), date( 'Y' ) ) );
2846 $month = ;
2847 $query[] = sprintf( 'publishedfullday = %d%s', $d, $month );
2848
2849 if ($y = 'thisyear') {
2850 $query[] = sprintf( 'publishedyear = %s', date( 'y' ) );
2851 continue;
2852 }
2853
2854 jmp;
2855
2856 if (0 < ) {
2857 $query[] = sprintf( 'publishedyear = %s', $y );
2858 continue;
2859 }
2860
2861 break;
2862 }
2863
2864 $query[] = ( ( ) );
2865 }
2866
2867
2868 if (is_array( $m ) = true) {
2869 if (isset( $m['range'] )) {
2870 $query[] = sprintf( 'publishedmonth between %s and %s', $m['range']['start'], $m['range']['end'] );
2871 continue;
2872 }
2873 }
2874else {
2875 if (( 'N' ) = 1) {
2876 time( );
2877 strtotime( 'last monday' );
2878 $w1 = (true ? : );
2879
2880 if (date( 'N' ) = 7) {
2881 time( );
2882 ;
2883 strtotime;
2884 }
2885
2886 ( 'next sunday' );
2887 }
2888 }
2889
2890 $w2 = ;
2891 $query[] = sprintf( 'publishedday IN(%s)', implode( ',', self::date_range( $w1, $w2, '+1 day', 'j' ) ) );
2892 }
2893
2894
2895 if (is_array( $d ) = true) {
2896 if (isset( $d['range'] )) {
2897 sprintf;
2898 'publishedday between %s and %s';
2899 $d['range']['start'];
2900 }
2901 }
2902
2903 $query[] = ( $d['range']['end'] );
2904 }
2905
2906
2907 if (0 < (int)) {
2908 sprintf;
2909 'publishedday = %d';
2910 $d;
2911 }
2912
2913 $query[] = ( );
2914 return ;
2915 }
2916
2917 function dateRangeToOrderKey($range) {
2918 switch ((bool)) {
2919 case 'thisday': {
2920 switch () {
2921 case 'thisweek': {
2922 switch () {
2923 case 'thismonth': {
2924 switch () {
2925 case '0': {
2926 }
2927 }
2928 }
2929 }
2930 }
2931
2932 case 'all': {
2933 }
2934 }
2935
2936 return ;
2937 }
2938 }
2939
2940 return ;
2941 }
2942
2943 function publishOrder($by = 'publish', $field_values = array( ), $order = 'desc') {
2944 0 < count( $field_values );
2945
2946 if (( is_array( $field_values ) && )) {
2947 return ;
2948 switch ($by) {
2949 case 'publish': {
2950 }
2951 }
2952 }
2953
2954 return ;
2955 }
2956
2957 function date_range($first, $last, $step = '+1 day', $output_format = 'd/m/Y') {
2958 while (true) {
2959 $dates = array( );
2960 $current = $first;
2961
2962 if ($current <= $last) {
2963 }
2964
2965
2966 if (empty( $$output_format ) = false) {
2967 date;
2968 $output_format;
2969 }
2970
2971 ( $current );
2972 $dates[] = (true ? : );
2973 $current = strtotime( $step, $current );
2974 }
2975
2976 return ;
2977 }
2978
2979 function escapeSearchQuery($str) {
2980 $this->plaintext( $str, false );
2981 $query = ;
2982 $this->tools->limit( $query, 250, '' );
2983 $query = ;
2984 $replace = array( '.' => '', ',' => '', '/' => '', '|' => '', '$' => '', '(' => '', ')' => '', '&' => '', '?' => '', '%' => '', '\'' => '', '“' => '', 'â€' => '', '«' => '', '»' => '', '"' => '', '=' => '', '!' => '' );
2985 foreach ($replace as ) {
2986 $to = ;
2987 $key = ;
2988 str_replace( $key, $to, $query );
2989 $query = ;
2990 break;
2991 }
2992
2993 return ;
2994 }
2995
2996 function getStatsDBPath($month = 0, $year = 0) {
2997 if ($month = 0) {
2998 date( 'm' );
2999 }
3000
3001 $month = (true ? : );
3002
3003 if ($year = 0) {
3004 }
3005
3006 date( 'Y' );
3007 $year = (true ? : );
3008 return ;
3009 }
3010
3011 function createStatsDB($db) {
3012 $db->exec( 'drop table if exists "stats"' );
3013 $db->exec( 'CREATE TABLE stats (day_date DATE NOT NULL, listing_id INT (10) NOT NULL, cat_id INT (4) DEFAULT (0), source_id INT (4) DEFAULT (0), views INT (8) NOT NULL DEFAULT (0), views_counter INT (8) NOT NULL DEFAULT (0), bot_views INT (8) NOT NULL DEFAULT (0), bot_views_counter INT (8) DEFAULT (0) NOT NULL,visited_at DATETIME DEFAULT (CURRENT_TIMESTAMP), PRIMARY KEY (day_date, listing_id));' );
3014 $db->exec( 'CREATE INDEX day_date ON stats (day_date DESC,views DESC);' );
3015 $db->exec( 'CREATE INDEX day_date_visited ON stats (day_date DESC,visited_at DESC,views DESC);' );
3016 return ;
3017 }
3018
3019 function loadStatsDB($filename) {
3020 $createdb = false;
3021
3022 if (file_exists( $filename ) = false) {
3023 $createdb = true;
3024
3025 if (is_null( $statsDb )) {
3026 self;
3027 }
3028
3029 new ( 'sqlite:' . $filename );
3030 $statsDb = ;
3031 $statsDb->setAttribute( ATTR_ERRMODE, ERRMODE_EXCEPTION );
3032 $statsDb->prepare( 'PRAGMA temp_store=MEMORY;' )->execute( );
3033 $statsDb->prepare( 'PRAGMA journal_mode=MEMORY; ' )->execute( );
3034 }
3035
3036 jmp;
3037 return ;
3038 }
3039
3040 function closeStatsDB() {
3041 if (isset( $statsDb )) {
3042 }
3043
3044 $statsDb = null;
3045 return ;
3046 }
3047
3048 function updateStatsDBData($filename, $listing_id, $field = 'views', $value = '+1', $cat_id = 0, $source_id = 0) {
3049 while (true) {
3050 if (defined( 'NO_STATS' ) = true) {
3051 return ;
3052 self::loadStatsDB( $filename );
3053 $db = ;
3054 }
3055
3056 $field_counter_value = 290;
3057 $db->prepare( sprintf( 'SELECT * FROM stats WHERE day_date = \'%s\' and listing_id = :listing_id LIMIT 1', date( 'Y-m-d' ) ) );
3058 $stmt = ;
3059 $stmt->bindParam( ':listing_id', $listing_id );
3060 $stmt->execute( );
3061
3062 if ($row = ) {
3063 switch ($value) {
3064 case '+1': {
3065 $row[$field];
3066 }
3067 }
3068 }
3069
3070 $field_value = (int) & 1;
3071 $field_counter_value = (int) & 1;
3072 break ;
3073 $db->prepare( sprintf( 'UPDATE stats SET ' . . $field . ' = :value, ' . $field . '_counter = :counter_value,cat_id = :cat_id,source_id = :source_id,visited_at = CURRENT_TIMESTAMP WHERE day_date = \'%s\' AND listing_id = :listing_id', date( 'Y-m-d' ) ) );
3074 $stm = $stmt->fetch( );
3075 $stm->execute( array( ':value' => $field_value, ':counter_value' => $field_counter_value, ':cat_id' => $cat_id, ':source_id' => $source_id, ':listing_id' => $listing_id ) );
3076 }
3077
3078 $db->prepare( sprintf( 'INSERT INTO stats (day_date, listing_id, ' . . $field . ', ' . $field . '_counter,cat_id,source_id,visited_at) VALUES (strftime(\'%s\',\'%s\'),:listing_id,1,1,:cat_id,:source_id,CURRENT_TIMESTAMP)', '%Y-%m-%d', date( 'Y-m-d' ) ) );
3079 $stm = ;
3080 $stm->execute( array( ':listing_id' => $listing_id, ':cat_id' => $cat_id, ':source_id' => $source_id ) );
3081 return ;
3082 }
3083
3084 function restStatsDBCounter($filename, $listing_id, $field = 'views') {
3085 if (defined( 'NO_STATS' ) = true) {
3086 return ;
3087 self::loadStatsDB( $filename );
3088 $db = ;
3089 $db->prepare;
3090 'UPDATE stats SET ' . . $field . '_counter = 0 WHERE day_date = date(\'now\', \'localtime\') AND listing_id = :listing_id';
3091 }
3092
3093 ( );
3094 $stm = ;
3095 $stm->execute( array( ':listing_id' => $listing_id ) );
3096 return ;
3097 }
3098
3099 function activeListings($minutes = 3) {
3100 if (defined( 'NO_STATS' ) = true) {
3101 return ;
3102 self::getStatsDBPath( );
3103 $db_path = ;
3104 self::loadStatsDB( $db_path );
3105 }
3106
3107 $db = ;
3108 $db->prepare( sprintf( 'SELECT count(*) as listings FROM stats WHERE visited_at >= Datetime(\'now\', \'-%s minutes\')', $minutes ) );
3109 $sth = ;
3110 $sth->execute( );
3111 return ;
3112 }
3113
3114 function trendingListingsInDay($time = '-20 minutes', $limit = 12, $lifetime = ) {
3115 while (true) {
3116 if (defined( 'NO_STATS' ) = true) {
3117 return ;
3118 $this->cacheId( 'trendingListingsInDay', $time );
3119 $cache_id = ;
3120 __c( )->get( $cache_id );
3121
3122 if ($ids = = null) {
3123 sprintf( 'SELECT listing_id,views as total_views FROM stats WHERE day_date = "%s" and visited_at >= Datetime("now", "%s") ORDER BY views DESC LIMIT %s', date( 'Y-m-d' ), $time, $limit );
3124 }
3125 }
3126
3127 $sql = ;
3128 self::getStatsDBPath( );
3129 $db_path = ;
3130 self::loadStatsDB( $db_path );
3131 $db = ;
3132 $db->prepare( $sql );
3133 $sth = ;
3134 $sth->execute( );
3135 $sth->fetchAll( FETCH_COLUMN, 0 );
3136 $ids = ;
3137 }
3138
3139 {
3140 if (DEV_MODE = true) {
3141 echo ;
3142 __c( )->set;
3143 }
3144
3145 ( $cache_id, $ids, $lifetime );
3146 return ;
3147 }
3148 }
3149
3150 function trendingListings($date = 'thisday', $limit = 12, $lifetime = , $with_views = false, $in_cats = array( )) {
3151 while (true) {
3152 if (defined( 'NO_STATS' ) = true) {
3153 return ;
3154 $this->cacheId( 'trendingListings', $date . $with_views . serialize( $limit ) . serialize( $in_cats ) );
3155 $cache_id = ;
3156 __c( )->get( $cache_id );
3157
3158 if ($ids = = null) {
3159 if (0 < (int)) {
3160 (int);
3161 ;
3162 time( );
3163 }
3164
3165 $last_update = ;
3166
3167 if (is_array( $limit ) = true) {
3168 $limit = $limit['offset'] . ', ' . $limit['limit'];
3169 $conditions = array( );
3170 $this->getCategoriesId( $in_cats );
3171 $categories_id = ;
3172 1 < count( $categories_id );
3173
3174 if (( $this->isAllCategories( $categories_id ) = false && )) {
3175 $conditions[] = sprintf( 'AND cat_id IN(%s)', implode( ',', $categories_id ) );
3176 }
3177
3178 jmp;
3179
3180 if ( = 1) {
3181 $conditions[] = sprintf( 'AND cat_id = ' . current( $categories_id ) );
3182
3183 if ($date = 'thisday') {
3184 sprintf;
3185 'SELECT listing_id,views as total_views FROM stats WHERE day_date = "%s" %s ORDER BY views DESC LIMIT %s';
3186 date;
3187 'Y-m-d';
3188 }
3189 }
3190 }
3191 }
3192 }
3193
3194 ( ( ), implode( ' ', $conditions ), $limit );
3195 $sql = ;
3196 }
3197
3198
3199 if ($date = 'thisweek') {
3200 strtotime( 'last monday' );
3201 $w1 = ;
3202 strtotime( 'next sunday' );
3203 $w2 = ;
3204 sprintf( 'SELECT listing_id,SUM(views) AS total_views FROM stats WHERE day_date BETWEEN "%s" AND "%s" %s group by listing_id ORDER BY total_views DESC LIMIT %s', date( 'Y-m-d', $w1 ), date( 'Y-m-d', $w2 ), implode( ' ', $conditions ), $limit );
3205 $sql = ;
3206 }
3207
3208 jmp;
3209 ( , $limit );
3210 $sql = ;
3211 self::getStatsDBPath( );
3212 $db_path = ;
3213 self::loadStatsDB( $db_path );
3214 $db = ;
3215 $db->prepare( $sql );
3216 $sth = ;
3217 $sth->execute( );
3218
3219 if ($with_views = true) {
3220 $sth->fetchAll( FETCH_COLUMN | FETCH_GROUP );
3221 $sth->fetchAll( FETCH_COLUMN, 0 );
3222 $ids = (true ? : );
3223 }
3224
3225 jmp;
3226 echo ;
3227 __c( )->set( $cache_id, $ids, $lifetime );
3228 return ;
3229 }
3230
3231 function get_array_columns($array, $columns) {
3232 while (true) {
3233 $columns_map = array( );
3234 $i = 224;
3235
3236 if ($i < $columns) {
3237 $columns_map[] = 0;
3238 ++;
3239 continue;
3240 }
3241
3242 jmp;
3243 $count = ;
3244 $position = 224;
3245
3246 if (0 < $count) {
3247 ++;
3248
3249 if ($position < $columns - 1) {
3250 ++;
3251 ;
3252 }
3253 }
3254
3255 $position = ;
3256 --;
3257 }
3258
3259 $chunked = array( );
3260 foreach ($columns_map as ) {
3261 $map = ;
3262 $chunked[] = array_splice( $array, 0, $map );
3263 break;
3264 }
3265
3266 return ;
3267 }
3268
3269 function array_chunk_vertical($input, $size, $preserve_keys = false, $size_is_horizontal = true) {
3270 while (true) {
3271 while (true) {
3272 $chunks = array( );
3273
3274 if ($size_is_horizontal) {
3275 ceil;
3276 }
3277
3278 ( count( $input ) \ $size );
3279 $chunk_count = ;
3280 }
3281
3282 $chunk_count = $value;
3283 $chunk_index = 226;
3284
3285 if ($chunk_index < $chunk_count) {
3286 $chunks[] = array( );
3287 ++;
3288 continue;
3289 }
3290
3291 jmp;
3292 }
3293
3294 return ;
3295 }
3296
3297 function search_array_kv($array, $key, $value) {
3298 $data = array( );
3299 foreach ((array) as ) {
3300 $subarray = ;
3301 $subarray[$key] = $value;
3302
3303 while (true) {
3304 if (( isset( $subarray[$key] ) && )) {
3305 $data[] = $subarray;
3306 break 2;
3307 }
3308 }
3309 }
3310
3311 return ;
3312 }
3313
3314 function removeArrElement($array, $needle) {
3315 array_search( $needle, $array );
3316 $key = ;
3317
3318 if ($key !== false) {
3319 }
3320
3321 unset( $array[$key] );
3322 return ;
3323 }
3324
3325 function cleanTmp($dir, $exclude = array( ), $expire_time = 12) {
3326 $result = true;
3327 foreach (glob( $dir . DS . '*' ) as ) {
3328 $filename = ;
3329
3330 while (in_array( basename( $filename ), $exclude ) = true) {
3331 continue;
3332
3333 if ($expire_time + 60 < time( ) - @filectime( $filename )) {
3334 @unlink( $filename );
3335 $result = ( $result && );
3336 break 2;
3337 }
3338 }
3339
3340 break;
3341 }
3342
3343 return ;
3344 }
3345
3346 function cacheId($key, $str = '', $user = false, $o = array( )) {
3347 while (true) {
3348 if (empty( $$str ) = true) {
3349 $str = (true ? : );
3350 $arr = array( $str => );
3351
3352 if ($user) {
3353 $this->getUserid;
3354 }
3355
3356 $arr[] = ( );
3357 foreach ((array) as ) {
3358 }
3359 }
3360
3361 $v = ;
3362 $k = ;
3363 $arr[] = $k . '_' . $v;
3364 }
3365
3366 return ;
3367 }
3368
3369 function combine_arr($keys, $values) {
3370 $data = array( );
3371 foreach ($keys as ) {
3372 $key = ;
3373 $data[$key] = $values[$key];
3374 break;
3375 }
3376
3377 return ;
3378 }
3379
3380 function javascript_option($var_name, $var_value) {
3381 $value = '';
3382
3383 if (is_numeric( $var_value )) {
3384 $value = $var_name;
3385 }
3386
3387 jmp;
3388 $value = ;
3389 $this->javascript_options[] = sprintf( 'var %s = %s;', $var_name, $value );
3390 return ;
3391 }
3392
3393 function litePageAssets($css = array( ), $js = array( )) {
3394 $this->restHtml( );
3395 $this->set_assets_path( 'assets' );
3396 $this->js_place = ;
3397 $this->js( 'jquery/1.1/jquery.js', 'jquery/1.1/migrate.js', 'bootstrap/3.3/bootstrap.min.js' );
3398 $this->css( 'bootstrap/3.3/bootstrap.min.css', 'bootstrap/3.3/bootstrap-rtl.css', 'font-awesome/css/font-awesome.min.css' );
3399 call_user_func_array( array( $this => , 'css' => ), $css );
3400 call_user_func_array( array( $this => , 'js' => ), $js );
3401 $this->set_assets_path( 'theme' );
3402 $this->html( '<link href="http://fonts.googleapis.com/earlyaccess/droidarabickufi.css" rel="stylesheet" type="text/css" />' );
3403 $this->html( $this->css_code( 'body{font-family: \'Droid Arabic Kufi\';}' ) );
3404 $this->html( $this->javascript_code( 'function redirect_parent(url) {if(window.opener){window.opener.location = url;}}' ) );
3405 return ;
3406 }
3407
3408 function media_tab_loader($options = array( )) {
3409 array_merge( array( 'mime_pkgs' => array( 'image' => ), 'group' => 1, 'buttons' => array( array( 'class' => 'set-featured-image', 'text' => 'تعيين كصورة أساسية', 'attrs' => array( ) ) => ), 'css_file' => 'jquery.fileupload.css', 'js_file' => 'media_tab.js' ), $options );
3410 $options = ;
3411 $this->set_assets_path( 'assets' );
3412 $this->js( 'uploader/jquery.ui.widget.js', 'uploader/tmpl.min.js', 'uploader/load-image.all.min.js', 'uploader/jquery.iframe-transport.js', 'uploader/jquery.fileupload.js', 'uploader/jquery.fileupload-process.js', 'uploader/jquery.fileupload-audio.js', 'uploader/jquery.fileupload-image.js', 'uploader/jquery.fileupload-video.js', 'uploader/jquery.fileupload-validate.js', 'uploader/jquery.fileupload-ui.js', 'uploader/' . $options['js_file'] )->css( 'uploader/' . $options['css_file'] );
3413 $this->set_assets_path( 'theme' );
3414 $ajax_url = $this->getOption( 'base_url' ) . '/ajax.html?case=fileupload';
3415
3416 if (isset( $options['mime_pkgs'] ) = true) {
3417 $ajax_url &= '&mime_pkgs=' . implode( ',', $options['mime_pkgs'] );
3418
3419 if (isset( $options['group'] ) = true) {
3420 $ajax_url &= '&group=' . $options['group'];
3421
3422 if (isset( $options['load_session'] ) = true) {
3423 $ajax_url &= '&load_session=true';
3424
3425 if (isset( $options['listing_id'] ) = true) {
3426 $ajax_url &= '&listing_id=' . $options['listing_id'];
3427 }
3428 }
3429
3430
3431 if (isset( $options['max_width'] ) = true) {
3432 $ajax_url &= '&max_width=' . $options['max_width'];
3433
3434 if (isset( $options['max_height'] ) = true) {
3435 }
3436 }
3437
3438 $ajax_url &= '&max_height=' . $options['max_height'];
3439 $this->javascript_option;
3440 'fileupload_url';
3441 }
3442
3443 ( $ajax_url );
3444 $this->smarty->assign;
3445 }
3446
3447 ( 'media_tab', $options );
3448 return ;
3449 }
3450
3451 function mime_to_pkg($mime) {
3452 foreach ($this->mime_types as $mime_types) {
3453 $pkg = ;
3454 foreach (array_keys( $mime_types ) as $mime_type) {
3455 if (strpos( $mime_type, $mime ) !== false) {
3456 return ;
3457 }
3458 }
3459 }
3460
3461 return ;
3462 }
3463
3464 function get_mime_types($pkgs = array( )) {
3465 while (true) {
3466 while (true) {
3467 $mime_types = array( );
3468 $data = ;
3469
3470 if (0 < count( $pkgs )) {
3471 foreach ($pkgs as $data) {
3472 $pkg = ;
3473 array_merge( $data, $this->mime_types[$pkg] );
3474 break;
3475 }
3476
3477 continue;
3478 }
3479
3480 jmp;
3481 }
3482 }
3483
3484 return ;
3485 }
3486
3487 function mime_types_pkgs() {
3488 return ;
3489 }
3490
3491 function mime_type_to_extension($mime_type) {
3492 $this->get_mime_types( );
3493 $mime_types = ;
3494
3495 if (isset( $mime_types[$mime_type] ) = true) {
3496 $mime_types[$mime_type];
3497 (true ? : );
3498 }
3499
3500 return ;
3501 }
3502
3503 function get_extensions($pkgs = array( )) {
3504 while (true) {
3505 while (true) {
3506 $extensions = array( );
3507
3508 if (0 < count( $pkgs )) {
3509 foreach ($pkgs as ) {
3510 $pkg = ;
3511 array_merge;
3512 $extensions;
3513 array_values;
3514 $this->mime_types[$pkg];
3515 }
3516 }
3517
3518 ( ( ) );
3519 $extensions = ;
3520 }
3521 }
3522
3523 foreach ($this->mime_types as ) {
3524 $mime_types = ;
3525 $pkg = ;
3526 array_merge( $extensions, array_values( $mime_types ) );
3527 $extensions = ;
3528 break;
3529 }
3530
3531 return ;
3532 }
3533
3534 function uploadPath($mode = 'path') {
3535 switch ($mode) {
3536 case 'path': {
3537 $str = $this->getOption( 'base_path' ) . 'content/uploads/';
3538 break ;
3539 switch ($mode) {
3540 case 'url': {
3541 $this->getOption;
3542 }
3543 }
3544
3545 'base_url';
3546 }
3547 }
3548
3549 $str = ( ) . '/content/uploads/';
3550 break ;
3551 return ;
3552 }
3553
3554 function resized($filename = '', $size = 'thumb', $html = false, $attrs = array( ), $src_atrr = 'src') {
3555 if (is_array( $filename )) {
3556 array_values( $filename );
3557 $arr = ;
3558 $arr[0];
3559 $filename = ;
3560 50 < strlen( $filename );
3561
3562 if (( empty( $$filename ) = true || )) {
3563 $filename = 'default.png';
3564 SITE_URL . '/temp/resized/';
3565 }
3566 }
3567
3568 $url = . $size . '_' . str_replace( '/', '-', $filename );
3569 $str = $filename;
3570
3571 if ($html = true) {
3572 }
3573
3574 $str = '<img ' . $src_atrr . '="' . $url . '"';
3575 foreach ($attrs as ) {
3576 $val = ;
3577 $key = ;
3578 $str &= ' ' . $key . '="' . $val . '"';
3579 break;
3580 }
3581
3582 $str &= ' />';
3583 return ;
3584 }
3585
3586 function unlinkFile($files) {
3587 if (is_array( $files )) {
3588 foreach ($files as $file) {
3589 $this->unlinkFile( $file );
3590 break;
3591 }
3592
3593 return ;
3594 implode( '/', array( $this->uploadPath( 'path' ) => , $files => ) );
3595 }
3596
3597 $file_path = ;
3598 unlink( $file_path );
3599 }
3600
3601 function HTML_DOMXPath($html) {
3602 (bool);
3603 new ( );
3604 $dom = ;
3605 $dom->loadHTML( '<?xml encoding="utf-8" ?>' . $html );
3606 return ;
3607 }
3608
3609 function HTML_XPathNode($domxpath, $xpath, $outer = true) {
3610 $html = '';
3611 foreach ($domxpath->query( $xpath ) as ) {
3612 $tag = ;
3613
3614 if ($outer = true) {
3615 $this->HTML_getNodeOuter( $tag );
3616 $this->HTML_getNodeInner( $tag );
3617 (true ? : );
3618 }
3619
3620 $html &= ;
3621 break;
3622 }
3623
3624 return ;
3625 }
3626
3627 function HTML_getNodeOuter($n) {
3628 new ( '1.0' );
3629 $d = ;
3630 $d->importNode( $n->cloneNode( true ), true );
3631 $b = ;
3632 $d->appendChild( $b );
3633 return ;
3634 }
3635
3636 function HTML_getNodeInner($oNode) {
3637 new ( );
3638 $oDom = ;
3639 foreach ($oNode->childNodes as ) {
3640 $oChild = ;
3641 $oDom->appendChild( $oDom->importNode( $oChild, true ) );
3642 break;
3643 }
3644
3645 return ;
3646 }
3647
3648 function get_xml_tag($tag, $xml) {
3649 preg_quote( $tag );
3650 $tag = ;
3651 preg_match_all( '{<' . $tag . '[^>]*>(.*?)</' . $tag . '>}', $xml, $matches, PREG_PATTERN_ORDER );
3652 return ;
3653 }
3654
3655 function db_listing_array($data = array( ), $update = false, $id = 0) {
3656 while (true) {
3657 $result = array( );
3658 foreach (array( 'hash' => , 'title' => , 'keywords' => , 'provider' => , 'link' => , 'type' => , 'source_id' => , 'cat_id' => , 'description' => , 'content' => , 'auther_name' => , 'createdby_id' => , 'createdon' => , 'editedon' => , 'editedby_id' => ) as ) {
3659 $field = ;
3660
3661 if (isset( $data[$field] ) = true) {
3662 $result[$field] = $data[$field];
3663 break;
3664 }
3665 }
3666
3667
3668 if (isset( $data['images'] ) = true) {
3669 $result['images'] = json_encode( $data['images'], true );
3670
3671 if (isset( $data['published'] ) = true) {
3672 if ((string) = true) {
3673 $result['published'] = (true ? : );
3674
3675 if ((string) = true) {
3676 date;
3677 'U';
3678 }
3679
3680 $result['publishedon'] = ( );
3681 date;
3682 }
3683
3684 $result['publishedmonth'] = ( 'n' );
3685 $result['publishedyear'] = date( 'y' );
3686 $result['publishedday'] = date( 'j' );
3687 date( 'jm' );
3688 }
3689
3690 $result['publishedfullday'] = ;
3691 $result['publishedminute'] = date( 'jHi' );
3692 $result['publishedby_id'] = $this->getUserid( );
3693 isset( $result['keywords'] );
3694 }
3695
3696 is_array( $result['keywords'] );
3697
3698 if (( && )) {
3699 $result['keywords'] = implode( ',', $result['keywords'] );
3700
3701 if ($update = false) {
3702 if (isset( $result['hash'] ) = false) {
3703 if (isset( $data['link'] ) = true) {
3704 md5;
3705 $data['link'];
3706 }
3707 }
3708
3709 ( );
3710 md5( $result['title'] . date( 'd-m-Y H' ) );
3711 $result['hash'] = (true ? : );
3712 isset( $result['createdby_id'] );
3713 }
3714
3715
3716 if ( = false) {
3717 $result['createdby_id'] = $this->getUserid( );
3718 time;
3719 }
3720
3721 ( );
3722 }
3723
3724 $result['createdon'] = ;
3725 }
3726
3727
3728 if (isset( $result['editedon'] ) = false) {
3729 }
3730
3731 $result['editedon'] = time( );
3732 $result['editedby_id'] = $this->auth->getUserid( );
3733 return ;
3734 }
3735
3736 function getUrlInfo($url) {
3737 include_once( dirname( __FILE__ ) . DS . 'Embera' . DS . 'Autoload.php' );
3738 new ( );
3739 $embera = ;
3740 $embera->getUrlInfo( $url );
3741
3742 if ($url_info = = false) {
3743 throw ;
3744 current;
3745 $url_info;
3746 }
3747
3748 return ;
3749 }
3750
3751 function mediaUrlArray($url, $preview = false, $url) {
3752 while (true) {
3753 $this->getUrlInfo( $url );
3754 $data = ;
3755 }
3756
3757 {
3758 return ;
3759 $records = array( 'type' => 2, 'provider' => strtolower( $data['provider_name'] ), 'link' => $url, 'title' => '', 'description' => '', 'content' => '', 'auther_name' => '', 'images' => array( ) );
3760
3761 if (( isset( $data['html'] ) = true && )) {
3762 $records['content'] = $data['html'];
3763
3764 if (isset( $data['title'] ) = true) {
3765 $records['title'] = $this->plaintext( $data['title'] );
3766
3767 if (isset( $data['author_name'] ) = true) {
3768 $records['auther_name'] = $data['author_name'];
3769
3770 if (isset( $data['description'] ) = true) {
3771 $records['description'] = $data['description'];
3772 switch (strtolower( $data['provider_name'] )) {
3773 case 'flickr': {
3774 switch () {
3775 case 'deviantart': {
3776 }
3777 }
3778 }
3779 }
3780 }
3781 }
3782 }
3783
3784 switch () {
3785 case 'instagram': {
3786 if (isset( $data['url'] ) = false) {
3787 return ;
3788 $this->grabImage;
3789 $data['url'];
3790 false;
3791 false;
3792 }
3793 }
3794
3795 case 'twitter': {
3796 $this->HTML_DOMXPath( $data['html'] );
3797 $DOM = ;
3798 $this->strip_tags( $this->HTML_XPathNode( $DOM, '//p' ) );
3799 $title = ;
3800 $records['title'] = $this->plaintext( $title );
3801 $records['content'] = $data['html'];
3802 $records['type'] = 2;
3803
3804 if (isset( $data['thumbnail_url'] ) = true) {
3805 $thumb_key = 'thumbnail_url';
3806 break;
3807 }
3808
3809 break;
3810 }
3811 }
3812
3813 count( $records['images'] ) = 0;
3814 }
3815
3816 function embedText() {
3817 (bool);
3818 }
3819 }
3820
3821 include_once( dirname( __FILE__ ) . DS . 'Embera' . DS . 'Autoload.php' );
3822 new ( );
3823 $preview = ;
3824 $preview->autoEmbed( $url );
3825 $data = ;
3826 array_merge( $urls_providers_loaded, $preview->providers_loaded );
3827 $urls_providers_loaded = ;
3828 return ;
3829 }
3830
3831 function isSupportedUrl($url) {
3832 while (true) {
3833 include_once( dirname( __FILE__ ) . DS . 'Embera' . DS . 'Autoload.php' );
3834 new ( );
3835 $embera = ;
3836 $embera->isSupportedUrl( $url );
3837 $services = ;
3838 0 < count( $services );
3839
3840 if (( is_array( $services ) = true && )) {
3841 foreach ($services as ) {
3842 $service = ;
3843 explode( '\', get_class( $service ) );
3844 $class_parts = ;
3845 self;
3846 end;
3847 }
3848 }
3849
3850 $urls_providers_loaded[] = ( $class_parts );
3851 }
3852
3853 return ;
3854 }
3855
3856 function loadSupportedUrlsHelpers() {
3857 $providers = (array);
3858 foreach (array_unique( $providers ) as ) {
3859 while (true) {
3860 $provider = ;
3861
3862 if ($provider = 'Facebook') {
3863 $this->facebook_sdk( );
3864 break 2;
3865 }
3866 }
3867 }
3868
3869 return ;
3870 }
3871
3872 function responsive_embed($html) {
3873 return ;
3874 }
3875
3876 function grabImage($url, $local = false, $db_save = false, $attrs = array( ), $preview = false, $loadurl_options = array( ), $force_convert = 'jpg') {
3877 while (true) {
3878 while ($preview = true) {
3879 return ;
3880
3881 if (empty( $$url )) {
3882 return ;
3883
3884 if ($local = true) {
3885 switch (strstr( $url, '@', true )) {
3886 case 'base64': {
3887 base64_decode( preg_replace( '/' . preg_quote( 'base64@' ) . '/', '', $url, 1 ) );
3888 $raw = ;
3889 break ;
3890 switch () {
3891 case 'file': {
3892 file_get_contents( $url );
3893
3894 if ($raw = = false) {
3895 return ;
3896 }
3897
3898 break 2;
3899 }
3900 }
3901
3902 preg_match( '~^data:(image/[a-zA-Z]+);base64\,([a-zA-Z0-9+\=/]+)$~i', $url, $matches );
3903
3904 if (( substr( $url, 0, 10 ) = 'data:image' && )) {
3905 base64_decode( $matches[2] );
3906 $raw = ;
3907 break;
3908 }
3909
3910 break 3;
3911 }
3912 }
3913 }
3914 }
3915 }
3916
3917 image_type_to_extension( $exif_ob, false );
3918 $extension = ;
3919 }
3920
3921 getimagesize( $tmp_file_path );
3922
3923 if ($image_info = ) {
3924 $image_info['mime'];
3925 $mime_type = ;
3926 $this->mime_type_to_extension( $mime_type );
3927 $extension = ;
3928 $this->is_image_extension( $extension );
3929 empty( $$mime_type );
3930
3931 if (( ( empty( $$extension ) && ) && )) {
3932 if (empty( $$force_convert ) = false) {
3933 switch ($extension) {
3934 case 'jpg': {
3935 switch ($extension) {
3936 case 'jpeg': {
3937 imagecreatefromjpeg;
3938 $tmp_file_path;
3939 }
3940 }
3941 }
3942 }
3943 }
3944 }
3945 }
3946
3947 ( );
3948 $imageTmp = ;
3949 break;
3950 switch ($extension) {
3951 case 'png': {
3952 imagecreatefrompng( $tmp_file_path );
3953 $imageTmp = ;
3954 break;
3955 switch ($extension) {
3956 case 'gif': {
3957 imagecreatefromgif( $tmp_file_path );
3958 $imageTmp = ;
3959 break;
3960 switch ($extension) {
3961 case 'bmp': {
3962 imagecreatefrombmp( $tmp_file_path );
3963 $imageTmp = ;
3964 break;
3965 switch ($force_convert) {
3966 case 'jpg': {
3967 imagejpeg;
3968 $imageTmp;
3969 $tmp_file_path;
3970 }
3971 }
3972
3973
3974 if (!) {
3975 return ;
3976 break;
3977 switch ($force_convert) {
3978 case 'png': {
3979 if (!) {
3980 return ;
3981 break;
3982 $extension = $url_follow;
3983 imagedestroy( $imageTmp );
3984 $file_new_name = $tmp_file_path . '.' . $extension;
3985 rename;
3986 $tmp_file_path;
3987 $file_new_name;
3988 }
3989 }
3990 }
3991 }
3992
3993
3994 if (( )) {
3995 if ($db_save) {
3996 if (isset( $attrs['title'] ) = true) {
3997 $attrs['title'];
3998 basename( $url );
3999 $title = (true ? : );
4000 $this->db->files( )->insert;
4001 array( 'user_id' => $this->Userid( ), 'file_real_name' => $title, 'file_clean_name' => $title, 'file_physical_name' => $tmp_file_hash . '.' . $extension, 'file_size' => $file_size, 'file_mime_type' => $mime_type );
4002 }
4003 }
4004 }
4005
4006 ( array( 'file_extension' => $extension, 'file_time' => time( ) ) );
4007 $image_obj = ;
4008 return ;
4009 implode;
4010 '/';
4011 array( $sub_dir => , $tmp_file_hash . '.' . $extension => );
4012 }
4013 }
4014 }
4015 }
4016
4017 ( );
4018 $final_file = ;
4019 $this->vars_data['grab_image'][] = $final_file;
4020 return ;
4021
4022 if (is_file( $tmp_file_path )) {
4023 unlink;
4024 }
4025
4026 ( $tmp_file_path );
4027 }
4028 }
4029
4030 return ;
4031 }
4032
4033 function imageToStr($image) {
4034 implode( '/', array( $this->uploadPath( 'path' ) => , $image => ) );
4035 $file_path = ;
4036
4037 if (file_exists( $file_path ) = true) {
4038 }
4039
4040 return ;
4041 }
4042
4043 function strToImage($str) {
4044 return ;
4045 }
4046
4047 function updateTempOption($key, $value, $function = 'set') {
4048 switch ($this->temp_opt_handler) {
4049 case 'db': {
4050 if ($function = 'increment') {
4051 (int);
4052 }
4053 }
4054 }
4055
4056 $value = & 1;
4057 return ;
4058 }
4059
4060 function getTempOption($key, $default = null) {
4061 switch ($this->temp_opt_handler) {
4062 case 'db': {
4063 return ;
4064 switch () {
4065 case 'cache': {
4066 __c( )->get;
4067 $key;
4068 }
4069 }
4070 }
4071 }
4072
4073 ( );
4074
4075 if ($value = !== null) {
4076 }
4077
4078 return ;
4079 }
4080
4081 function sourceDefaultOptions() {
4082 return ;
4083 }
4084
4085 function categoryDefaultOptions() {
4086 return ;
4087 }
4088
4089 function feedTypesArray() {
4090 $default_settings = array( 'prefer_curl' => true, 'redirects' => false, 'user_agent' => 'browser', 'tidy' => true );
4091 $types = array( );
4092 foreach ($this->db->feedtypes( 'status', 1 )->order( 'id ASC' ) as ) {
4093 $type_row = ;
4094 $settings = (array);
4095 $types[$type_row['id']] = array( 'id' => (int), 'title' => $type_row['title'], 'settings' => self::array_merge_recursive_distinct( $default_settings, $settings ), 'customize' => (string) );
4096 break;
4097 }
4098
4099 return ;
4100 }
4101
4102 function loopPairs($data, $key, $value) {
4103 $arr = array( );
4104 foreach ($data as ) {
4105 $v = ;
4106 $k = ;
4107 $arr[$v[$key]] = $v[$value];
4108 break;
4109 }
4110
4111 return ;
4112 }
4113
4114 function uniqueMultidimArray($array, $key) {
4115 $temp_array = array( );
4116 $i = 205;
4117 $key_array = array( );
4118 foreach ($array as ) {
4119 $val = ;
4120
4121 if (!) {
4122 $key_array[$i] = $val[$key];
4123 $temp_array[$i] = $val;
4124 ++;
4125 }
4126
4127 break;
4128 }
4129
4130 return ;
4131 }
4132
4133 function ThemesNameArray($version_name = 'version.php') {
4134 $themes = array( );
4135 foreach (glob( BASE_PATH . 'themes/*', GLOB_ONLYDIR ) as ) {
4136 $theme_dir = ;
4137 $version_file = $theme_dir . '/' . $version_name;
4138
4139 if (file_exists( $version_file ) = true) {
4140 include( $version_file );
4141 $version_var = ;
4142 $themes[basename( $theme_dir )] = $version_var['name'] . ' ' . $version_var['version'];
4143 break;
4144 }
4145 }
4146
4147 return ;
4148 }
4149
4150 function LangsNameArray() {
4151 $langs = array( );
4152 foreach (glob( dirname( __FILE__ ) . '/langs/*', GLOB_ONLYDIR ) as $_dir) {
4153 $lang_name = basename( $_dir );
4154
4155 if ($info = @include( $_dir . DS . 'info.php' )) {
4156 $langs[$lang_name] = $info['name'];
4157 break;
4158 }
4159 }
4160
4161 return ;
4162 }
4163
4164 function getUserid() {
4165 if ($this->isLoggedIn( ) = true) {
4166 (int);
4167 (true ? : );
4168 }
4169
4170 return ;
4171 }
4172
4173 function isLoggedIn() {
4174 if (isset( $['Mubashier.logged'] )) {
4175 (true ? : );
4176 }
4177
4178 return ;
4179 }
4180
4181 function LoginForm($id = 'login', $view = 'View_Default', $full = true, $alert = '') {
4182 $this->loadClass( 'Form', 'pfbc' );
4183 new ( $id );
4184 $form = ;
4185 ( array( 'view' => new ( ), 'action' => $this->tools->custom_url( 'file', array( 'file' => 'login' ), array( 'return' => $this->tools->return_url( ) ) ) ) );
4186
4187 if ($full) {
4188 ( new ( '<legend>%s <small>(%s)</small></legend>', tr( 'LOGIN' ), tr( 'USERS' ) )( ) );
4189
4190 if (empty( $$alert ) = false) {
4191 ( new ( $alert ) );
4192 ( new ( 'EMAIL' )( , 'email', array( 'required' => 1 ) ) );
4193 ( new ( 'PASSWORD' )( , 'password', array( 'required' => 1, 'LongDesc' => sprintf( '<a href="%s">%s</a>', $this->tools->custom_url( 'file', array( 'file' => 'recover' ) ), tr( 'FORGET_PASS_Q' ) ) ) ) );
4194 $form->addElement;
4195 new ;
4196 '';
4197 'remember';
4198 tr;
4199 }
4200 }
4201
4202 ( array( '1' => ( 'REMMBER_ME' ) ) );
4203 ( );
4204
4205 if ($full) {
4206 $form->addElement;
4207 new ;
4208 '<legend>%s <small>(%s)</small></legend><p><small> %s <a href="register.html">%s</a></small></p>';
4209 tr( 'NEW_ACCOUNT' );
4210 tr( 'VISITORS' );
4211 tr( 'REGISTER_P1' );
4212 tr;
4213 }
4214
4215 ( ( ( 'REGISTER' ) ) );
4216 ( );
4217 ( new ( 'LOGIN' )( , 'submit', array( 'class' => 'btn-dark' ) ) );
4218 return ;
4219 }
4220
4221 function getVarsData($key) {
4222 return ;
4223 }
4224
4225 function checkProxy($ip, $port) {
4226 return ;
4227 }
4228
4229 function getRealIp() {
4230 while (true) {
4231 if (isset( $ )) {
4232 if (isset( $['HTTP_X_FORWARDED_FOR'] )) {
4233 $['HTTP_X_FORWARDED_FOR'];
4234 $ip = ;
4235
4236 if (strpos( $ip, ',' )) {
4237 explode( ',', $ip );
4238 $exp_ip = ;
4239 $exp_ip[0];
4240 }
4241 }
4242 }
4243
4244 $ip = ;
4245 }
4246
4247
4248 if (isset( $['HTTP_CLIENT_IP'] )) {
4249 $['HTTP_CLIENT_IP'];
4250 $ip = ;
4251 }
4252
4253 jmp;
4254 getenv( 'REMOTE_ADDR' );
4255 $ip = ;
4256 return ;
4257 }
4258
4259 function isAllowedCron() {
4260 if ((string) = true) {
4261 }
4262
4263 $ip_list = $this->getOption( 'cron_ip_list' );
4264 $cron_ip_list = explode( '
4265', $ip_list );
4266 $cron_ip_list = (array);
4267
4268 if (in_array( self::getRealIp( ), $cron_ip_list ) = false) {
4269 }
4270
4271 return ;
4272 }
4273
4274 function checkIsAllowedCron() {
4275 if ($this->isAllowedCron( ) = false) {
4276 }
4277
4278 exit( );
4279 }
4280
4281 function DOMDocument($str, $encoding_code = true) {
4282 if ($encoding_code) {
4283 $str = '<meta http-equiv="content-type" content="text/html; charset=utf-8"><?xml encoding="utf-8" ?>' . $str;
4284 new ( );
4285 $dom = ;
4286 $dom->loadHTML;
4287 $str;
4288 }
4289
4290 ( );
4291 return ;
4292 }
4293
4294 function simpleHtmlDom($html) {
4295 include_once( dirname( __FILE__ ) . DS . 'Dom' . DS . 'simple_html_dom.php' );
4296 return ;
4297 }
4298
4299 function rewiteText($str) {
4300 self::loadClass( 'arabic', 'I18N' );
4301 new ( 'AutoSummarize' );
4302 $AutoSummarize = ;
4303 new ( 'Standard' );
4304 $Standard = ;
4305 Mubashier::simpleHtmlDom( $str );
4306 $dom_node = ;
4307 foreach ($dom_node->find( 'text' ) as ) {
4308 $textNode = ;
4309 trim( html_entity_decode( $textNode->outertext ) );
4310 $nodeValue = ;
4311 $Standard->standard( $nodeValue );
4312 $textNode->outertext = ;
4313 100 < strlen( $nodeValue );
4314
4315 if (( empty( $$nodeValue ) = false && )) {
4316 $AutoSummarize->doRateSummarize( $textNode->outertext, 50 );
4317 $textNode->outertext = ;
4318 break;
4319 }
4320 }
4321
4322 return ;
4323 }
4324
4325 function androidDB() {
4326 new ( 'sqlite:' . BASE_PATH . 'android-app' . DS . 'db' . DS . 'database.sqlite3' );
4327 $Db = ;
4328 $Db->setAttribute( ATTR_ERRMODE, ERRMODE_EXCEPTION );
4329 return ;
4330 }
4331
4332 function addGcmToken($token) {
4333 $db = self::androidDB( );
4334 $stm = $db->prepare( 'INSERT INTO notifications (android_token,created_at) VALUES (:token,CURRENT_TIMESTAMP)' );
4335 $stm->execute( array( ':token' => $token ) );
4336 return ;
4337 }
4338
4339 function countGcmTokens() {
4340 while (true) {
4341 self::androidDB( );
4342 $db = ;
4343 $db->prepare( 'SELECT count(*) as tokens FROM notifications' );
4344 $sth = $count = 200;
4345 $sth->execute( );
4346 $count = (int);
4347 }
4348
4349 {
4350 if (DEV_MODE) {
4351 $e->getMessage;
4352 }
4353
4354 echo ;
4355 return ;
4356 }
4357 }
4358
4359 function sendGcm($title, $description) {
4360 self::androidDB( );
4361 $db = ;
4362 $db->prepare( 'SELECT * FROM notifications' );
4363 $sth = ;
4364 $sth->execute( );
4365 $sth->fetchAll( FETCH_COLUMN, 0 );
4366 $tokens = ;
4367 $headers = array( 'Authorization' => 'key=' . $this->getOption( 'android_api_key' ), 'Content-Type' => 'application/json' );
4368 $sent_to_count = 247;
4369 foreach ((array) as ) {
4370 $tokens_chunk = ;
4371 $sent_to_count = $sent_to_count & count( $tokens_chunk );
4372 $fields = array( 'registration_ids' => $tokens_chunk, 'data' => array( 'title' => $title, 'description' => $description ) );
4373 self::loadUrl( 'https://android.googleapis.com/gcm/send', 'html', true, array( ), true, false, 'browser', false, array( ), 10, null, json_encode( $fields ), $headers );
4374 break;
4375 }
4376
4377 return ;
4378 }
4379
4380 function isCLi() {
4381 = 'cli';
4382 }
4383
4384 function getopt($options, $longopts) {
4385 (bool);
4386 empty( $['REMOTE_ADDR'] );
4387
4388 if (( PHP_SAPI = 'cli' || )) {
4389 return ;
4390
4391 if (isset( $ )) {
4392 $found = array( );
4393 preg_split;
4394 }
4395 }
4396
4397 ( '@([a-z0-9][:]{0,2})@i', $options, 0, PREG_SPLIT_DELIM_CAPTURE | PREG_SPLIT_NO_EMPTY );
4398 $shortopts = ;
4399 array_merge( $shortopts, $longopts );
4400 $opts = ;
4401 foreach ($opts as ) {
4402 $opt = ;
4403
4404 if (substr( $opt, -2 ) = '::') {
4405 substr( $opt, 0, -2 );
4406 $key = ;
4407 !;
4408
4409 if (( isset( $[$key] ) && )) {
4410 $[$key];
4411 }
4412
4413 $found[$key] = ;
4414 break;
4415 }
4416
4417
4418 while (true) {
4419 jmp;
4420
4421 if (ctype_alnum( $opt )) {
4422 if (isset( $[$opt] )) {
4423 $found[$opt] = false;
4424 break 2;
4425 }
4426
4427 break 2;
4428 }
4429 }
4430 }
4431
4432 return ;
4433 }
4434
4435 function googleFontsArray() {
4436 while (true) {
4437 $result = array( );
4438 include( dirname( __FILE__ ) . DS . 'tools' . DS . 'googlefonts.php' );
4439
4440 if ($arr = ) {
4441 foreach ($arr as ) {
4442 }
4443 }
4444
4445 $value = ;
4446 $key = ;
4447 $result[$value] = $value;
4448 }
4449
4450 return ;
4451 }
4452
4453 function writeCronFile($chunks) {
4454 $_file = dirname( __FILE__ ) . DS . 'tools' . DS . 'cron.sh';
4455 $cron_str = ;
4456 }
4457 }
4458
4459 function get_execution_time() {
4460 (bool);
4461 static $microtime_start = null;
4462
4463 if ($microtime_start = null) {
4464 microtime( true );
4465 $microtime_start = ;
4466 return ;
4467 microtime;
4468 true;
4469 }
4470
4471 return ;
4472 }
4473
4474 function {closure}($m) {
4475 return ;
4476 }
4477
4478
4479 if (function_exists( 'get_execution_time' ) = false) {
4480 get_execution_time( );
4481 define( 'DS', DIRECTORY_SEPARATOR );
4482 define( 'MUBASHIER', true );
4483 define( 'IFRAME_NAMES', 'facebook.com|twitter.com|slideshare.com|scribd.com|flickr.com|instagram.com|youtube-nocookie.com|youtube.com|youtu.be|vimeo.com|soundcloud.com|dailymotion.com|dai.ly|ustream.tv|vine.co|wordpress.tv|videojug.com|videofork.com|vidyomani.com|vid.me' );
4484 define( 'IFRAME_REGEXP_SYNTAX', '/(\/\/)?(www\.)?(%s)/Sui' );
4485 define;
4486 'IFRAME_REGEXP';
4487 sprintf( IFRAME_REGEXP_SYNTAX, IFRAME_NAMES );
4488 }
4489
4490 ( );
4491 return ;
4492 }
4493?>