Advertisement
Guest User

t

a guest
Mar 30th, 2016
145
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 187.93 KB | None | 0 0
  1. <?php
  2. // +------------------------------------------------------------------------+
  3. // | @author Deen Doughouz (DoughouzForest)
  4. // | @author_url 1: http://www.wowonder.com
  5. // | @author_url 2: http://codecanyon.net/user/doughouzforest
  6. // | @author_email: wowondersocial@gmail.com
  7. // +------------------------------------------------------------------------+
  8. // | WoWonder - The Ultimate Social Networking Platform
  9. // | Copyright (c) 2016 WoWonder. All rights reserved.
  10. // +------------------------------------------------------------------------+
  11. require 'assets/init.php';
  12. $f = '';
  13. $s = '';
  14. if (isset($_GET['f'])) {
  15. $f = Wo_Secure($_GET['f']);
  16. }
  17. if (isset($_GET['s'])) {
  18. $s = Wo_Secure($_GET['s']);
  19. }
  20. $data = array();
  21. if ($f == 'status_update') {
  22. $getir = mysql_query("select * from wo_posts where id='".$_GET["id"]."'");
  23. $getir = mysql_fetch_object($getir);
  24. if($getir->recipient_id==$user = $wo['user']['user_id'])
  25. {
  26. mysql_query("update wo_posts set status='1',time='".time()."' where id='".$getir->id."'");
  27. header("Location: ".$_SERVER["HTTP_REFERER"]."");
  28. }
  29. }
  30. if ($f == 'session_status') {
  31. if (Wo_IsLogged() === false) {
  32. $data = array(
  33. 'status' => 200
  34. );
  35. }
  36. header("Content-type: application/json");
  37. echo json_encode($data);
  38. exit();
  39. }
  40. if ($f == 'get_welcome_users') {
  41. $html = '';
  42. foreach (Wo_WelcomeUsers() as $wo['user']) {
  43. $html .= Wo_LoadPage('welcome/user-list');
  44. }
  45. $data = array(
  46. 'status' => 200,
  47. 'html' => $html
  48. );
  49. header("Content-type: application/json");
  50. echo json_encode($data);
  51. exit();
  52. }
  53. if ($f == 'contact_us') {
  54. if (empty($_POST['first_name']) || empty($_POST['last_name']) || empty($_POST['email']) || empty($_POST['message'])) {
  55. $errors[] = $error_icon . $wo['lang']['please_check_details'];
  56. } else if (!filter_var($_POST['email'], FILTER_VALIDATE_EMAIL)) {
  57. $errors[] = $error_icon . $wo['lang']['email_invalid_characters'];
  58. }
  59. if (empty($errors)) {
  60. $first_name = Wo_Secure($_POST['first_name']);
  61. $last_name = Wo_Secure($_POST['last_name']);
  62. $email = Wo_Secure($_POST['email']);
  63. $message = Wo_Secure($_POST['message']);
  64. $headers = "From: {$first_name} {$last_name} <{$email}>";
  65. $send_mail = @mail($wo['config']['siteEmail'], 'Contact us new message', $message, $headers);
  66. if ($send_mail) {
  67. $data = array(
  68. 'status' => 200,
  69. 'message' => $success_icon . $wo['lang']['email_sent']
  70. );
  71. } else {
  72. $errors[] = $error_icon . $wo['lang']['processing_error'];
  73. }
  74. }
  75. header("Content-type: application/json");
  76. if (!empty($errors)) {
  77. echo json_encode(array(
  78. 'errors' => $errors
  79. ));
  80. } else {
  81. echo json_encode($data);
  82. }
  83. exit();
  84. }
  85. if ($f == 'login') {
  86. if (isset($_POST['username']) && isset($_POST['password'])) {
  87. $username = Wo_Secure($_POST['username']);
  88. $password = Wo_Secure($_POST['password']);
  89. $result = Wo_Login($username, $password);
  90. if ($result === false) {
  91. $errors[] = $error_icon . $wo['lang']['incorrect_username_or_password_label'];
  92. } else if (Wo_UserInactive($_POST['username']) === true) {
  93. $errors[] = $error_icon . $wo['lang']['account_disbaled_contanct_admin_label'];
  94. } else if (Wo_UserActive($_POST['username']) === false) {
  95. $errors[] = $error_icon . $wo['lang']['account_not_active_label'];
  96. }
  97. if (empty($errors)) {
  98. $_SESSION['user_id'] = Wo_UserIdFromUsername($username);
  99. if (isset($_POST['rem'])) {
  100. setcookie('user_id', $_SESSION['user_id'], time() + 86000);
  101. }
  102. if (Wo_IsLogged() === true) {
  103. }
  104. $data = array(
  105. 'status' => 200
  106. );
  107. if (!empty($_POST['last_url'])) {
  108. $data['location'] = $_POST['last_url'];
  109. } else if (!empty($_POST['post_id']) && is_numeric($_POST['post_id'])) {
  110. $data['location'] = Wo_SeoLink('index.php?tab1=post&id=' . $_POST['post_id']);
  111. } else {
  112. $data['location'] = $wo['config']['site_url'];
  113. }
  114. }
  115. }
  116. header("Content-type: application/json");
  117. if (!empty($errors)) {
  118. echo json_encode(array(
  119. 'errors' => $errors
  120. ));
  121. } else {
  122. echo json_encode($data);
  123. }
  124. exit();
  125. }
  126. if ($f == 'register') {
  127. if (empty($_POST['email']) || empty($_POST['username']) || empty($_POST['password']) || empty($_POST['confirm_password'])) {
  128. $errors[] = $error_icon . $wo['lang']['please_check_details'];
  129. } else {
  130. $is_exist = Wo_IsNameExist($_POST['username'], 0);
  131. if (in_array(true, $is_exist)) {
  132. $errors[] = $error_icon . $wo['lang']['username_exists'];
  133. }
  134. if (in_array($_POST['username'], $wo['site_pages'])) {
  135. $errors[] = $error_icon . $wo['lang']['username_invalid_characters'];
  136. }
  137. if (strlen($_POST['username']) < 5 OR strlen($_POST['username']) > 32) {
  138. $errors[] = $error_icon . $wo['lang']['username_characters_length'];
  139. }
  140. if (!preg_match('/^[\w]+$/', $_POST['username'])) {
  141. $errors[] = $error_icon . $wo['lang']['username_invalid_characters'];
  142. }
  143. if (Wo_EmailExists($_POST['email']) === true) {
  144. $errors[] = $error_icon . $wo['lang']['email_exists'];
  145. }
  146. if (!filter_var($_POST['email'], FILTER_VALIDATE_EMAIL)) {
  147. $errors[] = $error_icon . $wo['lang']['email_invalid_characters'];
  148. }
  149. if (strlen($_POST['password']) < 6) {
  150. $errors[] = $error_icon . $wo['lang']['password_short'];
  151. }
  152. if ($_POST['password'] != $_POST['confirm_password']) {
  153. $errors[] = $error_icon . $wo['lang']['password_mismatch'];
  154. }
  155. if ($config['reCaptcha'] == 1) {
  156. if (!isset($_POST['g-recaptcha-response']) || empty($_POST['g-recaptcha-response'])) {
  157. $errors[] = $error_icon . $wo['lang']['reCaptcha_error'];
  158. }
  159. }
  160. $gender = 'male';
  161. if (!empty($_POST['gender'])) {
  162. if ($_POST['gender'] != 'male' && $_POST['gender'] != 'female') {
  163. $gender = 'male';
  164. } else {
  165. $gender = $_POST['gender'];
  166. }
  167. }
  168. }
  169. if (empty($errors)) {
  170. $activate = ($wo['config']['emailValidation'] == '1') ? '0' : '1';
  171. $re_data = array(
  172. 'email' => Wo_Secure($_POST['email']),
  173. 'username' => Wo_Secure($_POST['username']),
  174. 'password' => Wo_Secure($_POST['password']),
  175. 'email_code' => Wo_Secure(md5($_POST['username'])),
  176. 'src' => 'site',
  177. 'gender' => Wo_Secure($gender),
  178. 'lastseen' => time(),
  179. 'active' => Wo_Secure($activate)
  180. );
  181. $register = Wo_RegisterUser($re_data);
  182. if ($register === true) {
  183. if ($activate == 1) {
  184. $data = array(
  185. 'status' => 200,
  186. 'message' => $success_icon . $wo['lang']['successfully_joined_label']
  187. );
  188. if (!empty($_POST['last_url'])) {
  189. $data['location'] = $_POST['last_url'];
  190. } else if (!empty($_POST['post_id']) && is_numeric($_POST['post_id'])) {
  191. $data['location'] = Wo_SeoLink('index.php?tab1=post&id=' . $_POST['post_id']);
  192. } else {
  193. $data['location'] = $wo['config']['site_url'];
  194. }
  195. $login = Wo_Login($_POST['username'], $_POST['password']);
  196. if ($login === true) {
  197. $_SESSION['user_id'] = Wo_UserIdFromUsername($_POST['username']);
  198. }
  199. } else {
  200. $wo['user'] = $_POST;
  201. $body = Wo_LoadPage('emails/activate');
  202. $headers = "From: " . $config['siteName'] . " <" . $config['siteEmail'] . ">\r\n";
  203. $headers .= "Content-Type: text/html; charset=UTF-8\r\n";
  204. @mail($_POST['email'], $wo['lang']['account_activation'], $body, $headers);
  205. $errors[] = $wo['lang']['successfully_joined_verify_label'];
  206. }
  207. }
  208. }
  209. header("Content-type: application/json");
  210. if (isset($errors)) {
  211. echo json_encode(array(
  212. 'errors' => $errors
  213. ));
  214. } else {
  215. echo json_encode($data);
  216. }
  217. exit();
  218. }
  219. if ($f == 'recover') {
  220. if (empty($_POST['recoveremail'])) {
  221. $errors[] = $error_icon . $wo['lang']['please_check_details'];
  222. } else {
  223. if (!filter_var($_POST['recoveremail'], FILTER_VALIDATE_EMAIL)) {
  224. $errors[] = $error_icon . $wo['lang']['email_invalid_characters'];
  225. } else if (Wo_EmailExists($_POST['recoveremail']) === false) {
  226. $errors[] = $error_icon . $wo['lang']['email_not_found'];
  227. }
  228. }
  229. if (empty($errors)) {
  230. $user_recover_data = Wo_UserData(Wo_UserIdFromEmail($_POST['recoveremail']));
  231. $subject = $config['siteName'] . ' ' . $wo['lang']['password_rest_request'];
  232. $user_recover_data['link'] = Wo_SeoLink('index.php?tab1=welcome&tab2=password_reset&user_id=' . $user_recover_data['user_id'] . '_' . $user_recover_data['password']);
  233. $wo['recover'] = $user_recover_data;
  234. $body = Wo_LoadPage('emails/recover');
  235. $headers = "From: " . $config['siteName'] . " <" . $config['siteEmail'] . ">\r\n";
  236. $headers .= "Content-Type: text/html; charset=UTF-8\r\n";
  237. @mail($_POST['recoveremail'], $subject, $body, $headers);
  238. $data = array(
  239. 'status' => 200,
  240. 'message' => $success_icon . $wo['lang']['email_sent']
  241. );
  242. }
  243. header("Content-type: application/json");
  244. if (isset($errors)) {
  245. echo json_encode(array(
  246. 'errors' => $errors
  247. ));
  248. } else {
  249. echo json_encode($data);
  250. }
  251. exit();
  252. }
  253. if ($f == 'reset_password') {
  254. if (isset($_POST['id'])) {
  255. if (Wo_isValidPasswordResetToken($_POST['id']) === false) {
  256. $errors[] = $error_icon . $wo['lang']['invalid_token'];
  257. } elseif (empty($_POST['id'])) {
  258. $errors[] = $error_icon . $wo['lang']['processing_error'];
  259. } elseif (empty($_POST['password'])) {
  260. $errors[] = $error_icon . $wo['lang']['please_check_details'];
  261. } elseif (strlen($_POST['password']) < 5) {
  262. $errors[] = $error_icon . $wo['lang']['password_short'];
  263. }
  264. if (empty($errors)) {
  265. $user_id = explode("_", $_POST['id']);
  266. $password = Wo_Secure($_POST['password']);
  267. if (Wo_ResetPassword($user_id[0], $password) === true) {
  268. $_SESSION['user_id'] = $user_id[0];
  269. }
  270. $data = array(
  271. 'status' => 200,
  272. 'message' => $success_icon . $wo['lang']['password_changed'],
  273. 'location' => $wo['config']['site_url']
  274. );
  275. }
  276. }
  277. header("Content-type: application/json");
  278. if (isset($errors)) {
  279. echo json_encode(array(
  280. 'errors' => $errors
  281. ));
  282. } else {
  283. echo json_encode($data);
  284. }
  285. exit();
  286. }
  287. if ($f == "search") {
  288. $data = array(
  289. 'status' => 200,
  290. 'html' => ''
  291. );
  292. if ($s == 'recipients' AND Wo_IsLogged() === true && isset($_GET['query'])) {
  293. foreach (Wo_GetMessagesUsers($wo['user']['user_id'], $_GET['query']) as $wo['recipient']) {
  294. $data['html'] .= Wo_LoadPage('messages/messages-recipients-list');
  295. }
  296. }
  297. if ($s == 'normal' && isset($_GET['query'])) {
  298. foreach (Wo_GetSearch($_GET['query']) as $wo['result']) {
  299. $data['html'] .= Wo_LoadPage('header/search');
  300. }
  301. }
  302. if ($s == 'hash' && isset($_GET['query'])) {
  303. foreach (Wo_GetSerachHash($_GET['query']) as $wo['result']) {
  304. $data['html'] .= Wo_LoadPage('header/hashtags-result');
  305. }
  306. }
  307. if ($s == 'recent' && Wo_IsLogged() === true) {
  308. foreach (Wo_GetRecentSerachs() as $wo['result']) {
  309. $data['html'] .= Wo_LoadPage('header/search');
  310. }
  311. }
  312. header("Content-type: application/json");
  313. echo json_encode($data);
  314. exit();
  315. }
  316. if ($f == "get_search_filter") {
  317. $data = array(
  318. 'status' => 200,
  319. 'html' => ''
  320. );
  321. if (isset($_POST)) {
  322. foreach (Wo_GetSearchFilter($_POST) as $wo['result']) {
  323. $data['html'] .= Wo_LoadPage('search/result');
  324. }
  325. }
  326. header("Content-type: application/json");
  327. echo json_encode($data);
  328. exit();
  329. }
  330. if ($f == "update_announcement_views") {
  331. if (isset($_GET['id'])) {
  332. $UpdateAnnouncementViews = Wo_UpdateAnnouncementViews($_GET['id']);
  333. if ($UpdateAnnouncementViews === true) {
  334. $data = array(
  335. 'status' => 200
  336. );
  337. }
  338. }
  339. header("Content-type: application/json");
  340. echo json_encode($data);
  341. exit();
  342. }
  343. if ($f == 'get_more_hashtag_posts') {
  344. $html = '';
  345. if (isset($_POST['after_post_id'])) {
  346. $after_post_id = Wo_Secure($_POST['after_post_id']);
  347. foreach (Wo_GetHashtagPosts($_POST['hashtagName'], $after_post_id, 20) as $wo['story']) {
  348. $html .= Wo_LoadPage('story/content');
  349. }
  350. }
  351. $data = array(
  352. 'status' => 200,
  353. 'html' => $html
  354. );
  355. header("Content-type: application/json");
  356. echo json_encode($data);
  357. exit();
  358. }
  359. if (Wo_IsLogged() === false) {
  360. exit("Please login or signup to continue.");
  361. }
  362. if ($f == "get_more_following") {
  363. $html = '';
  364. if (isset($_GET['user_id']) && isset($_GET['after_last_id'])) {
  365. foreach (Wo_GetFollowing($_GET['user_id'], 'profile', 10, $_GET['after_last_id']) as $wo['UsersList']) {
  366. $html .= Wo_LoadPage('timeline/follow-list');
  367. }
  368. }
  369. $data = array(
  370. 'status' => 200,
  371. 'html' => $html
  372. );
  373. header("Content-type: application/json");
  374. echo json_encode($data);
  375. exit();
  376. }
  377. if ($f == "get_more_followers") {
  378. $html = '';
  379. if (isset($_GET['user_id']) && isset($_GET['after_last_id'])) {
  380. foreach (Wo_GetFollowers($_GET['user_id'], 'profile', 10, $_GET['after_last_id']) as $wo['UsersList']) {
  381. $html .= Wo_LoadPage('timeline/follow-list');
  382. }
  383. }
  384. $data = array(
  385. 'status' => 200,
  386. 'html' => $html
  387. );
  388. header("Content-type: application/json");
  389. echo json_encode($data);
  390. exit();
  391. }
  392. if ($f == 'check_username') {
  393. if (isset($_GET['username'])) {
  394. $usename = Wo_Secure($_GET['username']);
  395. if ($usename == $wo['user']['username']) {
  396. $data['status'] = 200;
  397. $data['message'] = $wo['lang']['available'];
  398. } else if (strlen($usename) < 5) {
  399. $data['status'] = 400;
  400. $data['message'] = $wo['lang']['too_short'];
  401. } else if (strlen($usename) > 32) {
  402. $data['status'] = 500;
  403. $data['message'] = $wo['lang']['too_long'];
  404. } else if (!preg_match('/^[\w]+$/', $_GET['username'])) {
  405. $data['status'] = 600;
  406. $data['message'] = $wo['lang']['username_invalid_characters_2'];
  407. } else {
  408. $is_exist = Wo_IsNameExist($_GET['username'], 0);
  409. if (in_array(true, $is_exist)) {
  410. $data['status'] = 300;
  411. $data['message'] = $wo['lang']['in_use'];
  412. } else {
  413. $data['status'] = 200;
  414. $data['message'] = $wo['lang']['available'];
  415. }
  416. }
  417. }
  418. header("Content-type: application/json");
  419. echo json_encode($data);
  420. exit();
  421. }
  422. if ($f == "update_general_settings") {
  423. if (isset($_POST)) {
  424. if (empty($_POST['username']) OR empty($_POST['email'])) {
  425. $errors[] = $error_icon . ' Please Check the fields.';
  426. } else {
  427. $Userdata = Wo_UserData($_POST['user_id']);
  428. $age_data = '0000-00-00';
  429. if (!empty($Userdata['user_id'])) {
  430. if ($_POST['email'] != $Userdata['email']) {
  431. if (Wo_EmailExists($_POST['email'])) {
  432. $errors[] = $error_icon . $wo['lang']['email_exists'];
  433. }
  434. }
  435. if ($_POST['username'] != $Userdata['username']) {
  436. $is_exist = Wo_IsNameExist($_POST['username'], 0);
  437. if (in_array(true, $is_exist)) {
  438. $errors[] = $error_icon . $wo['lang']['username_exists'];
  439. }
  440. }
  441. if (in_array($_POST['username'], $wo['site_pages'])) {
  442. $errors[] = $error_icon . $wo['lang']['username_invalid_characters'];
  443. }
  444. if (!filter_var($_POST['email'], FILTER_VALIDATE_EMAIL)) {
  445. $errors[] = $error_icon . $wo['lang']['email_invalid_characters'];
  446. }
  447. if (strlen($_POST['username']) < 5 || strlen($_POST['username']) > 32) {
  448. $errors[] = $error_icon . $wo['lang']['username_characters_length'];
  449. }
  450. if (!preg_match('/^[\w]+$/', $_POST['username'])) {
  451. $errors[] = $error_icon . $wo['lang']['username_invalid_characters'];
  452. }
  453. if (!empty($_POST['age_year']) || !empty($_POST['age_day']) || !empty($_POST['age_month'])) {
  454. if (empty($_POST['age_year']) || empty($_POST['age_day']) || empty($_POST['age_month'])) {
  455. $errors[] = $error_icon . $wo['lang']['please_choose_correct_date'];
  456. } else {
  457. $age_data = $_POST['age_year'] . '-' . $_POST['age_month'] . '-' . $_POST['age_day'];
  458. }
  459. }
  460. $active = $Userdata['active'];
  461. if (!empty($_POST['active'])) {
  462. if ($_POST['active'] == 'active') {
  463. $active = 1;
  464. } else {
  465. $active = 2;
  466. }
  467. if ($active == $Userdata['active']) {
  468. $active = $Userdata['active'];
  469. }
  470. }
  471. $type = $Userdata['admin'];
  472. if (!empty($_POST['type'])) {
  473. if ($_POST['type'] == 'admin') {
  474. $type = 1;
  475. } else {
  476. $type = 0;
  477. }
  478. if ($type == $Userdata['admin']) {
  479. $type = $Userdata['admin'];
  480. }
  481. }
  482. $gender = 'male';
  483. $gender_array = array(
  484. 'male',
  485. 'female'
  486. );
  487. if (!empty($_POST['gender'])) {
  488. if (in_array($_POST['gender'], $gender_array)) {
  489. $gender = $_POST['gender'];
  490. }
  491. }
  492. if (empty($errors)) {
  493. $Update_data = array(
  494. 'username' => $_POST['username'],
  495. 'email' => $_POST['email'],
  496. 'birthday' => $age_data,
  497. 'gender' => $gender,
  498. 'country_id' => $_POST['country'],
  499. 'active' => $active,
  500. 'admin' => $type
  501. );
  502. if (!empty($_POST['verified'])) {
  503. if ($_POST['verified'] == 'verified') {
  504. $Verification = 1;
  505. } else {
  506. $Verification = 0;
  507. }
  508. if ($Verification == $Userdata['verified']) {
  509. $Verification = $Userdata['verified'];
  510. }
  511. $Update_data['verified'] = $Verification;
  512. }
  513. if (Wo_UpdateUserData($_POST['user_id'], $Update_data)) {
  514. $data = array(
  515. 'status' => 200,
  516. 'message' => $success_icon . $wo['lang']['setting_updated'],
  517. 'username' => Wo_SeoLink('index.php?tab1=timeline&u=' . Wo_Secure($_POST['username']))
  518. );
  519. }
  520. }
  521. }
  522. }
  523. }
  524. header("Content-type: application/json");
  525. if (isset($errors)) {
  526. echo json_encode(array(
  527. 'errors' => $errors
  528. ));
  529. } else {
  530. echo json_encode($data);
  531. }
  532. exit();
  533. }
  534. if ($f == "update_privacy_settings") {
  535. if (isset($_POST['user_id'])) {
  536. $message_privacy = 0;
  537. $follow_privacy = 0;
  538. $post_privacy = 'ifollow';
  539. $showlastseen = 0;
  540. $confirm_followers = 0;
  541. $show_activities_privacy = 0;
  542. $status = 0;
  543. $visit_privacy = 0;
  544. $birth_privacy = 0;
  545. $array = array(
  546. '0',
  547. '1'
  548. );
  549. $array_2 = array(
  550. '0',
  551. '1',
  552. '2'
  553. );
  554. $array_two = array(
  555. 'everyone',
  556. 'ifollow',
  557. 'nobody'
  558. );
  559. if (!empty($_POST['post_privacy'])) {
  560. if (in_array($_POST['post_privacy'], $array_two)) {
  561. $post_privacy = $_POST['post_privacy'];
  562. }
  563. }
  564. if (!empty($_POST['confirm_followers'])) {
  565. if (in_array($_POST['confirm_followers'], $array)) {
  566. $confirm_followers = $_POST['confirm_followers'];
  567. }
  568. }
  569. if (!empty($_POST['follow_privacy'])) {
  570. if (in_array($_POST['follow_privacy'], $array)) {
  571. $follow_privacy = $_POST['follow_privacy'];
  572. }
  573. }
  574. if (!empty($_POST['show_activities_privacy'])) {
  575. if (in_array($_POST['show_activities_privacy'], $array)) {
  576. $show_activities_privacy = $_POST['show_activities_privacy'];
  577. }
  578. }
  579. if (!empty($_POST['showlastseen'])) {
  580. if (in_array($_POST['showlastseen'], $array)) {
  581. $showlastseen = $_POST['showlastseen'];
  582. }
  583. }
  584. if (!empty($_POST['message_privacy'])) {
  585. if (in_array($_POST['message_privacy'], $array)) {
  586. $message_privacy = $_POST['message_privacy'];
  587. }
  588. }
  589. if (!empty($_POST['status'])) {
  590. if (in_array($_POST['status'], $array)) {
  591. $status = $_POST['status'];
  592. }
  593. }
  594. if (!empty($_POST['visit_privacy'])) {
  595. if (in_array($_POST['visit_privacy'], $array)) {
  596. $visit_privacy = $_POST['visit_privacy'];
  597. }
  598. }
  599. if (!empty($_POST['birth_privacy'])) {
  600. if (in_array($_POST['birth_privacy'], $array_2)) {
  601. $birth_privacy = $_POST['birth_privacy'];
  602. }
  603. }
  604. $Update_data = array(
  605. 'message_privacy' => $message_privacy,
  606. 'follow_privacy' => $follow_privacy,
  607. 'post_privacy' => $post_privacy,
  608. 'showlastseen' => $showlastseen,
  609. 'confirm_followers' => $confirm_followers,
  610. 'show_activities_privacy' => $show_activities_privacy,
  611. 'visit_privacy' => $visit_privacy,
  612. 'birth_privacy' => $birth_privacy,
  613. 'status' => $status
  614. );
  615. if (Wo_UpdateUserData($_POST['user_id'], $Update_data)) {
  616. $data = array(
  617. 'status' => 200,
  618. 'message' => $success_icon . $wo['lang']['setting_updated']
  619. );
  620. }
  621. }
  622. header("Content-type: application/json");
  623. echo json_encode($data);
  624. exit();
  625. }
  626. if ($f == "update_email_settings") {
  627. if (isset($_POST['user_id'])) {
  628. $e_liked = 0;
  629. $e_shared = 0;
  630. $e_wondered = 0;
  631. $e_commented = 0;
  632. $e_followed = 0;
  633. $e_liked_page = 0;
  634. $e_visited = 0;
  635. $e_mentioned = 0;
  636. $e_joined_group = 0;
  637. $e_accepted = 0;
  638. $e_profile_wall_post = 0;
  639. $array = array(
  640. '0',
  641. '1'
  642. );
  643. if (!empty($_POST['e_liked'])) {
  644. if (in_array($_POST['e_liked'], $array)) {
  645. $e_liked = 1;
  646. }
  647. }
  648. if (!empty($_POST['e_shared'])) {
  649. if (in_array($_POST['e_shared'], $array)) {
  650. $e_shared = 1;
  651. }
  652. }
  653. if (!empty($_POST['e_wondered'])) {
  654. if (in_array($_POST['e_wondered'], $array)) {
  655. $e_wondered = 1;
  656. }
  657. }
  658. if (!empty($_POST['e_commented'])) {
  659. if (in_array($_POST['e_commented'], $array)) {
  660. $e_commented = 1;
  661. }
  662. }
  663. if (!empty($_POST['e_followed'])) {
  664. if (in_array($_POST['e_followed'], $array)) {
  665. $e_followed = 1;
  666. }
  667. }
  668. if (!empty($_POST['e_liked_page'])) {
  669. if (in_array($_POST['e_liked_page'], $array)) {
  670. $e_liked_page = 1;
  671. }
  672. }
  673. if (!empty($_POST['e_visited'])) {
  674. if (in_array($_POST['e_visited'], $array)) {
  675. $e_visited = 1;
  676. }
  677. }
  678. if (!empty($_POST['e_mentioned'])) {
  679. if (in_array($_POST['e_mentioned'], $array)) {
  680. $e_mentioned = 1;
  681. }
  682. }
  683. if (!empty($_POST['e_joined_group'])) {
  684. if (in_array($_POST['e_joined_group'], $array)) {
  685. $e_joined_group = 1;
  686. }
  687. }
  688. if (!empty($_POST['e_accepted'])) {
  689. if (in_array($_POST['e_accepted'], $array)) {
  690. $e_accepted = 1;
  691. }
  692. }
  693. if (!empty($_POST['e_profile_wall_post'])) {
  694. if (in_array($_POST['e_profile_wall_post'], $array)) {
  695. $e_profile_wall_post = 1;
  696. }
  697. }
  698. $Update_data = array(
  699. 'e_liked' => $e_liked,
  700. 'e_shared' => $e_shared,
  701. 'e_wondered' => $e_wondered,
  702. 'e_commented' => $e_commented,
  703. 'e_followed' => $e_followed,
  704. 'e_accepted' => $e_accepted,
  705. 'e_mentioned' => $e_mentioned,
  706. 'e_joined_group' => $e_joined_group,
  707. 'e_liked_page' => $e_liked_page,
  708. 'e_visited' => $e_visited,
  709. 'e_profile_wall_post' => $e_profile_wall_post
  710. );
  711. if (Wo_UpdateUserData($_POST['user_id'], $Update_data)) {
  712. $data = array(
  713. 'status' => 200,
  714. 'message' => $success_icon . $wo['lang']['setting_updated']
  715. );
  716. }
  717. }
  718. header("Content-type: application/json");
  719. echo json_encode($data);
  720. exit();
  721. }
  722. if ($f == 'update_new_logged_user_details') {
  723. if (empty($_POST['new_password']) || empty($_POST['username']) || empty($_POST['repeat_new_password'])) {
  724. $errors[] = $error_icon . $wo['lang']['please_check_details'];
  725. } else {
  726. if ($_POST['new_password'] != $_POST['repeat_new_password']) {
  727. $errors[] = $error_icon . $wo['lang']['password_mismatch'];
  728. }
  729. if (strlen($_POST['new_password']) < 6) {
  730. $errors[] = $error_icon . $wo['lang']['password_short'];
  731. }
  732. if (strlen($_POST['username']) > 32) {
  733. $errors[] = $error_icon . $wo['lang']['username_characters_length'];
  734. }
  735. if (strlen($_POST['username']) < 5) {
  736. $errors[] = $error_icon . $wo['lang']['username_characters_length'];
  737. }
  738. if (!preg_match('/^[\w]+$/', $_POST['username'])) {
  739. $errors[] = $error_icon . $wo['lang']['username_invalid_characters'];
  740. }
  741. if (Wo_UserExists($_POST['username']) === true) {
  742. $errors[] = $error_icon . $wo['lang']['username_exists'];
  743. }
  744. if (empty($errors)) {
  745. $Update_data = array(
  746. 'password' => md5($_POST['new_password']),
  747. 'username' => $_POST['username']
  748. );
  749. if (Wo_UpdateUserData($_POST['user_id'], $Update_data)) {
  750. $get_user = Wo_UserData($_POST['user_id']);
  751. $data = array(
  752. 'status' => 200,
  753. 'message' => $success_icon . $wo['lang']['setting_updated'],
  754. 'url' => $get_user['url']
  755. );
  756. }
  757. }
  758. }
  759. header("Content-type: application/json");
  760. if (isset($errors)) {
  761. echo json_encode(array(
  762. 'errors' => $errors
  763. ));
  764. } else {
  765. echo json_encode($data);
  766. }
  767. exit();
  768. }
  769. if ($f == "update_user_password") {
  770. if (isset($_POST['user_id'])) {
  771. $Userdata = Wo_UserData($_POST['user_id']);
  772. if (!empty($Userdata['user_id'])) {
  773. if ($_POST['user_id'] != $wo['user']['user_id']) {
  774. $_POST['current_password'] = 1;
  775. }
  776. if (empty($_POST['current_password']) OR empty($_POST['new_password']) OR empty($_POST['repeat_new_password'])) {
  777. $errors[] = $error_icon . $wo['lang']['please_check_details'];
  778. } else {
  779. if ($_POST['user_id'] == $wo['user']['user_id']) {
  780. if (md5($_POST['current_password']) != $Userdata['password']) {
  781. $errors[] = $error_icon . $wo['lang']['current_password_mismatch'];
  782. }
  783. }
  784. if ($_POST['new_password'] != $_POST['repeat_new_password']) {
  785. $errors[] = $error_icon . $wo['lang']['password_mismatch'];
  786. }
  787. if (strlen($_POST['new_password']) < 6) {
  788. $errors[] = $error_icon . $wo['lang']['password_short'];
  789. }
  790. if (empty($errors)) {
  791. $Update_data = array(
  792. 'password' => md5($_POST['new_password'])
  793. );
  794. if (Wo_UpdateUserData($_POST['user_id'], $Update_data)) {
  795. $data = array(
  796. 'status' => 200,
  797. 'message' => $success_icon . $wo['lang']['setting_updated']
  798. );
  799. }
  800. }
  801. }
  802. }
  803. }
  804. header("Content-type: application/json");
  805. if (isset($errors)) {
  806. echo json_encode(array(
  807. 'errors' => $errors
  808. ));
  809. } else {
  810. echo json_encode($data);
  811. }
  812. exit();
  813. }
  814. if ($f == "update_profile_setting") {
  815. if (isset($_POST['user_id'])) {
  816. $Userdata = Wo_UserData($_POST['user_id']);
  817. if (!empty($Userdata['user_id'])) {
  818. if (!empty($_POST['website'])) {
  819. if (!filter_var($_POST['website'], FILTER_VALIDATE_URL)) {
  820. $errors[] = $error_icon . $wo['lang']['website_invalid_characters'];
  821. }
  822. }
  823. if (!empty($_POST['working_link'])) {
  824. if (!filter_var($_POST['working_link'], FILTER_VALIDATE_URL)) {
  825. $errors[] = $error_icon . $wo['lang']['company_website_invalid'];
  826. }
  827. }
  828. if (!is_numeric($_POST['relationship']) || empty($_POST['relationship']) || $_POST['relationship'] > 4) {
  829. $_POST['relationship'] = '';
  830. }
  831. if (empty($errors)) {
  832. $Update_data = array(
  833. 'first_name' => $_POST['first_name'],
  834. 'last_name' => $_POST['last_name'],
  835. 'website' => $_POST['website'],
  836. 'about' => $_POST['about'],
  837. 'working' => $_POST['working'],
  838. 'working_link' => $_POST['working_link'],
  839. 'address' => $_POST['address'],
  840. 'school' => $_POST['school'],
  841. 'relationship_id' => $_POST['relationship']
  842. );
  843. if (Wo_UpdateUserData($_POST['user_id'], $Update_data)) {
  844. $data = array(
  845. 'status' => 200,
  846. 'first_name' => Wo_Secure($_POST['first_name']),
  847. 'last_name' => Wo_Secure($_POST['last_name']),
  848. 'message' => $success_icon . $wo['lang']['setting_updated']
  849. );
  850. }
  851. }
  852. }
  853. }
  854. header("Content-type: application/json");
  855. if (isset($errors)) {
  856. echo json_encode(array(
  857. 'errors' => $errors
  858. ));
  859. } else {
  860. echo json_encode($data);
  861. }
  862. exit();
  863. }
  864. if ($f == "update_socialinks_setting") {
  865. if (isset($_POST['user_id'])) {
  866. $Userdata = Wo_UserData($_POST['user_id']);
  867. if (!empty($Userdata['user_id'])) {
  868. if (empty($errors)) {
  869. $Update_data = array(
  870. 'facebook' => $_POST['facebook'],
  871. 'google' => $_POST['google'],
  872. 'linkedin' => $_POST['linkedin'],
  873. 'vk' => $_POST['vk'],
  874. 'instagram' => $_POST['instagram'],
  875. 'twitter' => $_POST['twitter']
  876. );
  877. if (Wo_UpdateUserData($_POST['user_id'], $Update_data)) {
  878. $data = array(
  879. 'status' => 200,
  880. 'message' => $success_icon . $wo['lang']['setting_updated']
  881. );
  882. }
  883. }
  884. }
  885. }
  886. header("Content-type: application/json");
  887. if (isset($errors)) {
  888. echo json_encode(array(
  889. 'errors' => $errors
  890. ));
  891. } else {
  892. echo json_encode($data);
  893. }
  894. exit();
  895. }
  896. if ($f == "update_images_setting") {
  897. if (isset($_POST['user_id'])) {
  898. $Userdata = Wo_UserData($_POST['user_id']);
  899. if (!empty($Userdata['user_id'])) {
  900. if (isset($_FILES['avatar']['name'])) {
  901. if (Wo_UploadImage($_FILES["avatar"]["tmp_name"], $_FILES['avatar']['name'], 'avatar', $_POST['user_id']) === true) {
  902. $Userdata = Wo_UserData($_POST['user_id']);
  903. }
  904. }
  905. if (isset($_FILES['cover']['name'])) {
  906. if (Wo_UploadImage($_FILES["cover"]["tmp_name"], $_FILES['cover']['name'], 'cover', $_POST['user_id']) === true) {
  907. $Userdata = Wo_UserData($_POST['user_id']);
  908. }
  909. }
  910. if (empty($errors)) {
  911. $Update_data = array(
  912. 'lastseen' => time()
  913. );
  914. if (Wo_UpdateUserData($_POST['user_id'], $Update_data)) {
  915. $userdata2 = Wo_UserData($_POST['user_id']);
  916. $data = array(
  917. 'status' => 200,
  918. 'message' => $success_icon . $wo['lang']['setting_updated'],
  919. 'cover' => $userdata2['cover'],
  920. 'avatar' => $userdata2['avatar']
  921. );
  922. }
  923. }
  924. }
  925. }
  926. header("Content-type: application/json");
  927. if (isset($errors)) {
  928. echo json_encode(array(
  929. 'errors' => $errors
  930. ));
  931. } else {
  932. echo json_encode($data);
  933. }
  934. exit();
  935. }
  936. if ($f == "update_design_setting") {
  937. if (isset($_POST['user_id'])) {
  938. $Userdata = Wo_UserData($_POST['user_id']);
  939. if (!empty($Userdata['user_id'])) {
  940. $background_image_status = 0;
  941. if (isset($_FILES['background_image']['name'])) {
  942. if (Wo_UploadImage($_FILES["background_image"]["tmp_name"], $_FILES['background_image']['name'], 'background_image', $_POST['user_id']) === true) {
  943. $background_image_status = 1;
  944. }
  945. }
  946. if (!empty($_POST['background_image_status'])) {
  947. if ($_POST['background_image_status'] == 'defualt') {
  948. $background_image_status = 0;
  949. } else if ($_POST['background_image_status'] == 'my_background') {
  950. $background_image_status = 1;
  951. } else {
  952. $background_image_status = 0;
  953. }
  954. }
  955. if (empty($errors)) {
  956. $Update_data = array(
  957. 'background_image_status' => $background_image_status
  958. );
  959. if (Wo_UpdateUserData($_POST['user_id'], $Update_data)) {
  960. $userdata2 = Wo_UserData($_POST['user_id']);
  961. $data = array(
  962. 'status' => 200,
  963. 'message' => $success_icon . $wo['lang']['setting_updated']
  964. );
  965. }
  966. }
  967. }
  968. }
  969. header("Content-type: application/json");
  970. if (isset($errors)) {
  971. echo json_encode(array(
  972. 'errors' => $errors
  973. ));
  974. } else {
  975. echo json_encode($data);
  976. }
  977. exit();
  978. }
  979. if ($f == 'update_user_avatar_picture') {
  980. if (isset($_FILES['avatar']['name'])) {
  981. if (Wo_UploadImage($_FILES["avatar"]["tmp_name"], $_FILES['avatar']['name'], 'avatar', $_POST['user_id']) === true) {
  982. $img = Wo_UserData($_POST['user_id']);
  983. $data = array(
  984. 'status' => 200,
  985. 'img' => $img['avatar'],
  986. 'img_or' => $img['avatar_org']
  987. );
  988. }
  989. }
  990. header("Content-type: application/json");
  991. echo json_encode($data);
  992. exit();
  993. }
  994. if ($f == 'update_user_cover_picture') {
  995. if (isset($_FILES['cover']['name'])) {
  996. if (Wo_UploadImage($_FILES["cover"]["tmp_name"], $_FILES['cover']['name'], 'cover', $_POST['user_id']) === true) {
  997. $img = Wo_UserData($_POST['user_id']);
  998. $data = array(
  999. 'status' => 200,
  1000. 'img' => $img['cover'],
  1001. 'cover_or' => $img['cover_org']
  1002. );
  1003. }
  1004. }
  1005. header("Content-type: application/json");
  1006. echo json_encode($data);
  1007. exit();
  1008. }
  1009. if ($f == 'set_admin_alert_cookie') {
  1010. setcookie('profileAlert', '1', time() + 86000);
  1011. }
  1012. if ($f == 'delete_user_account') {
  1013. if (isset($_POST['password'])) {
  1014. if (md5($_POST['password']) != $wo['user']['password']) {
  1015. $errors[] = $error_icon . $wo['lang']['current_password_mismatch'];
  1016. }
  1017. if (empty($errors)) {
  1018. if (Wo_DeleteUser($wo['user']['user_id']) === true) {
  1019. $data = array(
  1020. 'status' => 200,
  1021. 'message' => $success_icon . $wo['lang']['account_deleted'],
  1022. 'location' => Wo_SeoLink('index.php?tab1=logout')
  1023. );
  1024. }
  1025. }
  1026. }
  1027. header("Content-type: application/json");
  1028. if (isset($errors)) {
  1029. echo json_encode(array(
  1030. 'errors' => $errors
  1031. ));
  1032. } else {
  1033. echo json_encode($data);
  1034. }
  1035. exit();
  1036. }
  1037. if ($f == 'update_sidebar_users') {
  1038. $html = '';
  1039. foreach (Wo_UserSug(5) as $wo['UsersList']) {
  1040. $wo['UsersList']['user_name'] = $wo['UsersList']['name'];
  1041. if (!empty($wo['UsersList']['last_name'])) {
  1042. $wo['UsersList']['user_name'] = $wo['UsersList']['first_name'];
  1043. }
  1044. $html .= Wo_LoadPage('sidebar/sidebar-user-list');
  1045. }
  1046. $data = array(
  1047. 'status' => 200,
  1048. 'html' => $html
  1049. );
  1050. header("Content-type: application/json");
  1051. echo json_encode($data);
  1052. exit();
  1053. }
  1054. if ($f == 'update_sidebar_groups') {
  1055. $html = '';
  1056. foreach (Wo_GroupSug(5) as $wo['GroupList']) {
  1057. $html .= Wo_LoadPage('sidebar/sidebar-group-list');
  1058. }
  1059. $data = array(
  1060. 'status' => 200,
  1061. 'html' => $html
  1062. );
  1063. header("Content-type: application/json");
  1064. echo json_encode($data);
  1065. exit();
  1066. }
  1067. if ($f == 'follow_user') {
  1068. if (isset($_GET['following_id'])) {
  1069. if (Wo_IsFollowing($_GET['following_id'], $wo['user']['user_id']) === true || Wo_IsFollowRequested($_GET['following_id'], $wo['user']['user_id']) === true) {
  1070. if (Wo_DeleteFollow($_GET['following_id'], $wo['user']['user_id'])) {
  1071. $data = array(
  1072. 'status' => 200,
  1073. 'html' => Wo_GetFollowButton($_GET['following_id'])
  1074. );
  1075. }
  1076. } else {
  1077. if (Wo_RegisterFollow($_GET['following_id'], $wo['user']['user_id'])) {
  1078. $data = array(
  1079. 'status' => 200,
  1080. 'html' => Wo_GetFollowButton($_GET['following_id'])
  1081. );
  1082. }
  1083. }
  1084. }
  1085. header("Content-type: application/json");
  1086. echo json_encode($data);
  1087. exit();
  1088. }
  1089. if ($f == 'accept_follow_request') {
  1090. if (isset($_GET['following_id'])) {
  1091. if (Wo_AcceptFollowRequest($_GET['following_id'], $wo['user']['user_id'])) {
  1092. $data = array(
  1093. 'status' => 200,
  1094. 'html' => Wo_GetFollowButton($_GET['following_id'])
  1095. );
  1096. }
  1097. }
  1098. header("Content-type: application/json");
  1099. echo json_encode($data);
  1100. exit();
  1101. }
  1102. if ($f == 'delete_follow_request') {
  1103. if (isset($_GET['following_id'])) {
  1104. if (Wo_DeleteFollowRequest($_GET['following_id'], $wo['user']['user_id'])) {
  1105. $data = array(
  1106. 'status' => 200,
  1107. 'html' => Wo_GetFollowButton($_GET['following_id'])
  1108. );
  1109. }
  1110. }
  1111. header("Content-type: application/json");
  1112. echo json_encode($data);
  1113. exit();
  1114. }
  1115. if ($f == 'get_follow_requests') {
  1116. $data = array(
  1117. 'status' => 200,
  1118. 'html' => ''
  1119. );
  1120. $requests = Wo_GetFollowRequests();
  1121. if (count($requests) > 0) {
  1122. foreach ($requests as $wo['request']) {
  1123. $data['html'] .= Wo_LoadPage('header/follow-requests');
  1124. }
  1125. } else {
  1126. $data['message'] = $wo['lang']['no_new_requests'];
  1127. }
  1128. header("Content-type: application/json");
  1129. echo json_encode($data);
  1130. exit();
  1131. }
  1132. if ($f == 'get_notifications') {
  1133. $data = array(
  1134. 'status' => 200,
  1135. 'html' => ''
  1136. );
  1137. $notifications = Wo_GetNotifications();
  1138. if (count($notifications) > 0) {
  1139. foreach ($notifications as $wo['notification']) {
  1140. $data['html'] .= Wo_LoadPage('header/notifecation');
  1141. if ($wo['notification']['seen'] == 0) {
  1142. $query = "UPDATE " . T_NOTIFICATION . " SET `seen` = " . time() . " WHERE `id` = " . $wo['notification']['id'];
  1143. $sql_query = mysqli_query($sqlConnect, $query);
  1144. }
  1145. }
  1146. } else {
  1147. $data['message'] = $wo['lang']['no_new_notification'];
  1148. }
  1149. header("Content-type: application/json");
  1150. echo json_encode($data);
  1151. exit();
  1152. }
  1153. if ($f == 'update_data') {
  1154. $data['status'] = 200;
  1155. $data['notifications'] = Wo_CountNotifications(array(
  1156. 'unread' => true
  1157. ));
  1158. $data['html'] = '';
  1159. $notifications = Wo_GetNotifications(array(
  1160. 'type_2' => 'popunder'
  1161. ));
  1162. foreach ($notifications as $wo['notification']) {
  1163. $data['html'] .= Wo_LoadPage('header/notifecation');
  1164. if ($wo['notification']['seen'] == 0) {
  1165. $query = "UPDATE " . T_NOTIFICATION . " SET `seen_pop` = " . time() . " WHERE `id` = " . $wo['notification']['id'];
  1166. $sql_query = mysqli_query($sqlConnect, $query);
  1167. }
  1168. }
  1169. $data['messages'] = Wo_CountMessages(array(
  1170. 'new' => true
  1171. ), 'interval');
  1172. $data['followRequests'] = Wo_CountFollowRequests();
  1173. header("Content-type: application/json");
  1174. echo json_encode($data);
  1175. exit();
  1176. }
  1177. if ($f == 'update_lastseen') {
  1178. if (Wo_LastSeen($wo['user']['user_id']) === true) {
  1179. $data = array(
  1180. 'status' => 200
  1181. );
  1182. }
  1183. header("Content-type: application/json");
  1184. echo json_encode($data);
  1185. exit();
  1186. }
  1187. if ($f == 'messages') {
  1188. if ($s == 'get_user_messages') {
  1189. if (!empty($_GET['user_id']) AND is_numeric($_GET['user_id']) AND $_GET['user_id'] > 0) {
  1190. $html = '';
  1191. $user_id = $_GET['user_id'];
  1192. $can_replay = true;
  1193. $recipient = Wo_UserData($user_id);
  1194. $messages = Wo_GetMessages(array(
  1195. 'user_id' => $user_id
  1196. ));
  1197. if (!empty($recipient['user_id']) && $recipient['message_privacy'] == 1) {
  1198. if (Wo_IsFollowing($wo['user']['user_id'], $recipient['user_id']) === false) {
  1199. $can_replay = false;
  1200. }
  1201. }
  1202. foreach ($messages as $wo['message']) {
  1203. $html .= Wo_LoadPage('messages/messages-text-list');
  1204. }
  1205. $data = array(
  1206. 'status' => 200,
  1207. 'html' => $html,
  1208. 'can_replay' => $can_replay,
  1209. 'view_more_text' => $wo['lang']['view_more_messages']
  1210. );
  1211. }
  1212. header("Content-type: application/json");
  1213. echo json_encode($data);
  1214. exit();
  1215. }
  1216. if ($s == 'send_message') {
  1217. if (isset($_POST['user_id'])) {
  1218. $html = '';
  1219. $media = '';
  1220. $mediaFilename = '';
  1221. $mediaName = '';
  1222. if (isset($_FILES['sendMessageFile']['name'])) {
  1223. $fileInfo = array(
  1224. 'file' => $_FILES["sendMessageFile"]["tmp_name"],
  1225. 'name' => $_FILES['sendMessageFile']['name'],
  1226. 'size' => $_FILES["sendMessageFile"]["size"]
  1227. );
  1228. $media = Wo_ShareFile($fileInfo);
  1229. $mediaFilename = $media['filename'];
  1230. $mediaName = $media['name'];
  1231. }
  1232. $messages = Wo_RegisterMessage(array(
  1233. 'from_id' => Wo_Secure($wo['user']['user_id']),
  1234. 'to_id' => Wo_Secure($_POST['user_id']),
  1235. 'text' => Wo_Secure($_POST['textSendMessage']),
  1236. 'media' => Wo_Secure($mediaFilename),
  1237. 'mediaFileName' => Wo_Secure($mediaName),
  1238. 'time' => time()
  1239. ));
  1240. if ($messages > 0) {
  1241. $messages = Wo_GetMessages(array(
  1242. 'message_id' => $messages,
  1243. 'user_id' => $_POST['user_id']
  1244. ));
  1245. foreach ($messages as $wo['message']) {
  1246. $html .= Wo_LoadPage('messages/messages-text-list');
  1247. }
  1248. $data = array(
  1249. 'status' => 200,
  1250. 'html' => $html
  1251. );
  1252. }
  1253. }
  1254. header("Content-type: application/json");
  1255. echo json_encode($data);
  1256. exit();
  1257. }
  1258. if ($s == 'load_previous_messages') {
  1259. $html = '';
  1260. if (!empty($_GET['user_id']) && !empty($_GET['before_message_id'])) {
  1261. $user_id = Wo_Secure($_GET['user_id']);
  1262. $before_message_id = Wo_Secure($_GET['before_message_id']);
  1263. $messages = Wo_GetMessages(array(
  1264. 'user_id' => $user_id,
  1265. 'before_message_id' => $before_message_id
  1266. ));
  1267. if ($messages > 0) {
  1268. foreach ($messages as $wo['message']) {
  1269. $html .= Wo_LoadPage('messages/messages-text-list');
  1270. }
  1271. $data = array(
  1272. 'status' => 200,
  1273. 'html' => $html
  1274. );
  1275. }
  1276. }
  1277. header("Content-type: application/json");
  1278. echo json_encode($data);
  1279. exit();
  1280. }
  1281. if ($s == 'update_recipients') {
  1282. $html = '';
  1283. foreach (Wo_GetMessagesUsers($wo['user']['user_id'], '', '', '', 1) as $wo['recipient']) {
  1284. $html .= Wo_LoadPage('messages/messages-recipients-list');
  1285. }
  1286. $data = array(
  1287. 'status' => 200,
  1288. 'html' => $html
  1289. );
  1290. header("Content-type: application/json");
  1291. echo json_encode($data);
  1292. exit();
  1293. }
  1294. if ($s == 'get_new_messages') {
  1295. $html = '';
  1296. if (isset($_GET['user_id'])) {
  1297. $user_id = Wo_Secure($_GET['user_id']);
  1298. if (!empty($user_id)) {
  1299. $user_id = $_GET['user_id'];
  1300. $messages = Wo_GetMessages(array(
  1301. 'after_message_id' => $_GET['message_id'],
  1302. 'new' => true,
  1303. 'user_id' => $user_id
  1304. ));
  1305. if (count($messages) > 0) {
  1306. foreach ($messages as $wo['message']) {
  1307. $html .= Wo_LoadPage('messages/messages-text-list');
  1308. }
  1309. $data = array(
  1310. 'status' => 200,
  1311. 'html' => $html,
  1312. 'sender' => $wo['user']['user_id']
  1313. );
  1314. }
  1315. }
  1316. }
  1317. header("Content-type: application/json");
  1318. echo json_encode($data);
  1319. exit();
  1320. }
  1321. if ($s == 'delete_message') {
  1322. if (isset($_GET['message_id'])) {
  1323. $message_id = Wo_Secure($_GET['message_id']);
  1324. if (!empty($message_id) || is_numeric($message_id) || $message_id > 0) {
  1325. if (Wo_DeleteMessage($message_id) === true) {
  1326. $data = array(
  1327. 'status' => 200
  1328. );
  1329. }
  1330. }
  1331. }
  1332. header("Content-type: application/json");
  1333. echo json_encode($data);
  1334. exit();
  1335. }
  1336. if ($s == 'get_last_message_seen_status') {
  1337. if (isset($_GET['last_id'])) {
  1338. $message_id = Wo_Secure($_GET['last_id']);
  1339. if (!empty($message_id) || is_numeric($message_id) || $message_id > 0) {
  1340. $seen = Wo_SeenMessage($message_id);
  1341. if ($seen > 0) {
  1342. $data = array(
  1343. 'status' => 200,
  1344. 'time' => $seen['time'],
  1345. 'seen' => $seen['seen']
  1346. );
  1347. }
  1348. }
  1349. }
  1350. header("Content-type: application/json");
  1351. echo json_encode($data);
  1352. exit();
  1353. }
  1354. }
  1355. if ($f == 'admin_setting' AND Wo_IsAdmin($wo['user']['user_id']) === true) {
  1356. if ($s == 'update_social_login_setting') {
  1357. $googleLogin = 0;
  1358. $twitterLogin = 0;
  1359. $linkedinLogin = 0;
  1360. $facebookLogin = 0;
  1361. $VkontakteLogin = 0;
  1362. $InstagramLogin = 0;
  1363. if (!empty($_POST['googleLogin'])) {
  1364. $googleLogin = 1;
  1365. }
  1366. if (!empty($_POST['twitterLogin'])) {
  1367. $twitterLogin = 1;
  1368. }
  1369. if (!empty($_POST['linkedinLogin'])) {
  1370. $linkedinLogin = 1;
  1371. }
  1372. if (!empty($_POST['facebookLogin'])) {
  1373. $facebookLogin = 1;
  1374. }
  1375. if (!empty($_POST['VkontakteLogin'])) {
  1376. $VkontakteLogin = 1;
  1377. }
  1378. if (!empty($_POST['instagramLogin'])) {
  1379. $InstagramLogin = 1;
  1380. }
  1381. $facebookAppId = '';
  1382. $facebookAppKey = '';
  1383. if (!empty($_POST['facebookAppId'])) {
  1384. $facebookAppId = $_POST['facebookAppId'];
  1385. }
  1386. if (!empty($_POST['facebookAppKey'])) {
  1387. $facebookAppKey = $_POST['facebookAppKey'];
  1388. }
  1389. $googleAppId = '';
  1390. $googleAppKey = '';
  1391. if (!empty($_POST['googleAppId'])) {
  1392. $googleAppId = $_POST['googleAppId'];
  1393. }
  1394. if (!empty($_POST['googleAppKey'])) {
  1395. $googleAppKey = $_POST['googleAppKey'];
  1396. }
  1397. $twitterAppId = '';
  1398. $twitterAppKey = '';
  1399. if (!empty($_POST['twitterAppId'])) {
  1400. $twitterAppId = $_POST['twitterAppId'];
  1401. }
  1402. if (!empty($_POST['twitterAppKey'])) {
  1403. $twitterAppKey = $_POST['twitterAppKey'];
  1404. }
  1405. $linkedinAppId = '';
  1406. $linkedinAppKey = '';
  1407. if (!empty($_POST['linkedinAppId'])) {
  1408. $linkedinAppId = $_POST['linkedinAppId'];
  1409. }
  1410. if (!empty($_POST['linkedinAppKey'])) {
  1411. $linkedinAppKey = $_POST['linkedinAppKey'];
  1412. }
  1413. $VkontakteAppId = '';
  1414. $VkontakteAppKey = '';
  1415. if (!empty($_POST['VkontakteAppId'])) {
  1416. $VkontakteAppId = $_POST['VkontakteAppId'];
  1417. }
  1418. if (!empty($_POST['VkontakteAppKey'])) {
  1419. $VkontakteAppKey = $_POST['VkontakteAppKey'];
  1420. }
  1421. $instagramAppId = '';
  1422. $instagramAppkey = '';
  1423. if (!empty($_POST['instagramAppId'])) {
  1424. $instagramAppId = $_POST['instagramAppId'];
  1425. }
  1426. if (!empty($_POST['instagramAppkey'])) {
  1427. $instagramAppkey = $_POST['instagramAppkey'];
  1428. }
  1429. $AllLogin = ($googleLogin == '0' && $twitterLogin == '0' && $linkedinLogin == '0' && $facebookLogin == '0' && $VkontakteLogin == '0' && $InstagramLogin == '0') ? 0 : 1;
  1430. $saveSetting = false;
  1431. $data_array = array(
  1432. 'googleLogin' => $googleLogin,
  1433. 'twitterLogin' => $twitterLogin,
  1434. 'linkedinLogin' => $linkedinLogin,
  1435. 'facebookLogin' => $facebookLogin,
  1436. 'VkontakteLogin' => $VkontakteLogin,
  1437. 'instagramLogin' => $InstagramLogin,
  1438. 'AllLogin' => $AllLogin,
  1439. 'facebookAppId' => $facebookAppId,
  1440. 'facebookAppKey' => $facebookAppKey,
  1441. 'googleAppId' => $googleAppId,
  1442. 'googleAppKey' => $googleAppKey,
  1443. 'twitterAppId' => $twitterAppId,
  1444. 'twitterAppKey' => $twitterAppKey,
  1445. 'linkedinAppId' => $linkedinAppId,
  1446. 'linkedinAppKey' => $linkedinAppKey,
  1447. 'VkontakteAppId' => $VkontakteAppId,
  1448. 'VkontakteAppKey' => $VkontakteAppKey,
  1449. 'instagramAppId' => $instagramAppId,
  1450. 'instagramAppkey' => $instagramAppkey
  1451. );
  1452. foreach ($data_array as $key => $value) {
  1453. $saveSetting = Wo_SaveConfig($key, $value);
  1454. }
  1455. if ($saveSetting === true) {
  1456. $data['status'] = 200;
  1457. }
  1458. header("Content-type: application/json");
  1459. echo json_encode($data);
  1460. exit();
  1461. }
  1462. if ($s == 'update_general_setting') {
  1463. $saveSetting = false;
  1464. $cacheSystem = 0;
  1465. $chatSystem = 0;
  1466. $emailValidation = 0;
  1467. $emailNotification = 0;
  1468. $seoLink = 0;
  1469. $fileSharing = 0;
  1470. $useSeoFrindly = 0;
  1471. $message_seen = 0;
  1472. $message_typing = 0;
  1473. $user_lastseen = 0;
  1474. $deleteAccount = 0;
  1475. $profileVisit = 0;
  1476. $online_sidebar = 0;
  1477. if (!empty($_POST['cacheSystem'])) {
  1478. $cacheSystem = 1;
  1479. }
  1480. if (!empty($_POST['online_sidebar'])) {
  1481. $online_sidebar = 1;
  1482. }
  1483. if (!empty($_POST['chatSystem'])) {
  1484. $chatSystem = 1;
  1485. }
  1486. if (!empty($_POST['emailValidation'])) {
  1487. $emailValidation = 1;
  1488. }
  1489. if (!empty($_POST['emailNotification'])) {
  1490. $emailNotification = 1;
  1491. }
  1492. if (!empty($_POST['seoLink'])) {
  1493. $seoLink = 1;
  1494. }
  1495. if (!empty($_POST['fileSharing'])) {
  1496. $fileSharing = 1;
  1497. }
  1498. if (!empty($_POST['useSeoFrindly'])) {
  1499. $useSeoFrindly = 1;
  1500. }
  1501. if (!empty($_POST['message_seen'])) {
  1502. $message_seen = 1;
  1503. }
  1504. if (!empty($_POST['message_typing'])) {
  1505. $message_typing = 1;
  1506. }
  1507. if (!empty($_POST['user_lastseen'])) {
  1508. $user_lastseen = 1;
  1509. }
  1510. if (!empty($_POST['deleteAccount'])) {
  1511. $deleteAccount = 1;
  1512. }
  1513. if (!empty($_POST['profileVisit'])) {
  1514. $profileVisit = 1;
  1515. }
  1516. $saved_data = array(
  1517. 'cacheSystem' => $cacheSystem,
  1518. 'chatSystem' => $chatSystem,
  1519. 'emailValidation' => $emailValidation,
  1520. 'emailNotification' => $emailNotification,
  1521. 'seoLink' => $seoLink,
  1522. 'fileSharing' => $fileSharing,
  1523. 'useSeoFrindly' => $useSeoFrindly,
  1524. 'message_seen' => $message_seen,
  1525. 'message_typing' => $message_typing,
  1526. 'user_lastseen' => $user_lastseen,
  1527. 'deleteAccount' => $deleteAccount,
  1528. 'profileVisit' => $profileVisit,
  1529. 'online_sidebar' => $online_sidebar
  1530. );
  1531. foreach ($saved_data as $key => $value) {
  1532. $saveSetting = Wo_SaveConfig($key, $value);
  1533. }
  1534. if ($saveSetting === true) {
  1535. $data['status'] = 200;
  1536. }
  1537. header("Content-type: application/json");
  1538. echo json_encode($data);
  1539. exit();
  1540. }
  1541. if ($s == 'update_site_setting' && isset($_POST['siteName'])) {
  1542. $saveSetting = false;
  1543. if (!empty($_POST['reCaptcha'])) {
  1544. $_POST['reCaptcha'] = 1;
  1545. } else {
  1546. $_POST['reCaptcha'] = 0;
  1547. }
  1548. $delete_follow_table = 0;
  1549. if ($config['connectivitySystem'] == 1 && $_POST['connectivitySystem'] != 1) {
  1550. $delete_follow_table = 1;
  1551. } else if ($config['connectivitySystem'] != 1 && $_POST['connectivitySystem'] == 1) {
  1552. $delete_follow_table = 1;
  1553. }
  1554. foreach ($_POST as $key => $value) {
  1555. $saveSetting = Wo_SaveConfig($key, $value);
  1556. }
  1557. if ($saveSetting === true) {
  1558. if ($delete_follow_table == 1) {
  1559. mysqli_query($sqlConnect, "DELETE FROM " . T_FOLLOWERS);
  1560. mysqli_query($sqlConnect, "DELETE FROM " . T_NOTIFICATION . " WHERE type='following'");
  1561. }
  1562. $data['status'] = 200;
  1563. }
  1564. header("Content-type: application/json");
  1565. echo json_encode($data);
  1566. exit();
  1567. }
  1568. if ($s == 'update_design_setting' && isset($_POST['header_hover_border'])) {
  1569. $saveSetting = false;
  1570. if (isset($_FILES['logo']['name'])) {
  1571. $fileInfo = array(
  1572. 'file' => $_FILES["logo"]["tmp_name"],
  1573. 'name' => $_FILES['logo']['name'],
  1574. 'size' => $_FILES["logo"]["size"]
  1575. );
  1576. $media = Wo_UploadLogo($fileInfo);
  1577. }
  1578. foreach ($_POST as $key => $value) {
  1579. $saveSetting = Wo_SaveConfig($key, $value);
  1580. }
  1581. if ($saveSetting === true) {
  1582. $data['status'] = 200;
  1583. }
  1584. header("Content-type: application/json");
  1585. echo json_encode($data);
  1586. exit();
  1587. }
  1588. if ($s == 'update_reCaptcha_setting' && isset($_POST['reCaptcha'])) {
  1589. $saveSetting = false;
  1590. foreach ($_POST as $key => $value) {
  1591. $saveSetting = Wo_SaveConfig($key, $value);
  1592. }
  1593. if ($saveSetting === true) {
  1594. $data['status'] = 200;
  1595. }
  1596. header("Content-type: application/json");
  1597. echo json_encode($data);
  1598. exit();
  1599. }
  1600. if ($s == 'updateTheme' && isset($_POST['theme'])) {
  1601. $saveSetting = false;
  1602. foreach ($_POST as $key => $value) {
  1603. $saveSetting = Wo_SaveConfig($key, $value);
  1604. }
  1605. if ($saveSetting === true) {
  1606. $data['status'] = 200;
  1607. }
  1608. header("Content-type: application/json");
  1609. echo json_encode($data);
  1610. exit();
  1611. }
  1612. if ($s == 'delete_user' && isset($_GET['user_id'])) {
  1613. if (Wo_DeleteUser($_GET['user_id']) === true) {
  1614. $data['status'] = 200;
  1615. }
  1616. header("Content-type: application/json");
  1617. echo json_encode($data);
  1618. exit();
  1619. }
  1620. if ($s == 'delete_page' && isset($_GET['page_id'])) {
  1621. if (Wo_DeletePage($_GET['page_id']) === true) {
  1622. $data['status'] = 200;
  1623. }
  1624. header("Content-type: application/json");
  1625. echo json_encode($data);
  1626. exit();
  1627. }
  1628. if ($s == 'delete_group' && isset($_GET['group_id'])) {
  1629. if (Wo_DeleteGroup($_GET['group_id']) === true) {
  1630. $data['status'] = 200;
  1631. }
  1632. header("Content-type: application/json");
  1633. echo json_encode($data);
  1634. exit();
  1635. }
  1636. if ($s == 'filter_all_users') {
  1637. $html = '';
  1638. $after = (isset($_GET['after_user_id']) && is_numeric($_GET['after_user_id']) && $_GET['after_user_id'] > 0) ? $_GET['after_user_id'] : 0;
  1639. foreach (Wo_GetAllUsers(20, 'ManageUsers', $_POST, $after) as $wo['userlist']) {
  1640. $html .= Wo_LoadPage('admin/manage_users/users-list');
  1641. }
  1642. $data = array(
  1643. 'status' => 200,
  1644. 'html' => $html
  1645. );
  1646. header("Content-type: application/json");
  1647. echo json_encode($data);
  1648. exit();
  1649. }
  1650. if ($s == 'get_more_pages') {
  1651. $html = '';
  1652. $after = (isset($_GET['after_page_id']) && is_numeric($_GET['after_page_id']) && $_GET['after_page_id'] > 0) ? $_GET['after_page_id'] : 0;
  1653. foreach (Wo_GetAllPages(20, $after) as $wo['pagelist']) {
  1654. $html .= Wo_LoadPage('admin/manage_pages/pages-list');
  1655. }
  1656. $data = array(
  1657. 'status' => 200,
  1658. 'html' => $html
  1659. );
  1660. header("Content-type: application/json");
  1661. echo json_encode($data);
  1662. exit();
  1663. }
  1664. if ($s == 'get_more_groups') {
  1665. $html = '';
  1666. $after = (isset($_GET['after_group_id']) && is_numeric($_GET['after_group_id']) && $_GET['after_group_id'] > 0) ? $_GET['after_group_id'] : 0;
  1667. foreach (Wo_GetAllGroups(20, $after) as $wo['grouplist']) {
  1668. $html .= Wo_LoadPage('admin/manage_pages/groups-list');
  1669. }
  1670. $data = array(
  1671. 'status' => 200,
  1672. 'html' => $html
  1673. );
  1674. header("Content-type: application/json");
  1675. echo json_encode($data);
  1676. exit();
  1677. }
  1678. if ($s == 'clear_cache_folder') {
  1679. Wo_ClearCache();
  1680. $data = array(
  1681. 'status' => 200
  1682. );
  1683. header("Content-type: application/json");
  1684. echo json_encode($data);
  1685. exit();
  1686. }
  1687. if ($s == 'get_cache_folder_size') {
  1688. $html = Wo_SizeFormat(Wo_FolderSize('cache'));
  1689. $data = array(
  1690. 'status' => 200,
  1691. 'html' => $html
  1692. );
  1693. header("Content-type: application/json");
  1694. echo json_encode($data);
  1695. exit();
  1696. }
  1697. if ($s == 'update_users_setting' && isset($_POST['user_lastseen'])) {
  1698. $delete_follow_table = 0;
  1699. $saveSetting = false;
  1700. foreach ($_POST as $key => $value) {
  1701. $saveSetting = Wo_SaveConfig($key, $value);
  1702. }
  1703. if ($saveSetting === true) {
  1704. $data['status'] = 200;
  1705. }
  1706. header("Content-type: application/json");
  1707. echo json_encode($data);
  1708. exit();
  1709. }
  1710. if ($s == 'get_more_posts') {
  1711. $html = '';
  1712. $postsData = array(
  1713. 'limit' => 20,
  1714. 'after_post_id' => Wo_Secure($_GET['after_post_id'])
  1715. );
  1716. foreach (Wo_GetAllPosts($postsData) as $wo['story']) {
  1717. $html .= Wo_LoadPage('admin/manage_posts/posts-list');
  1718. }
  1719. $data = array(
  1720. 'status' => 200,
  1721. 'html' => $html
  1722. );
  1723. header("Content-type: application/json");
  1724. echo json_encode($data);
  1725. exit();
  1726. }
  1727. if ($s == 'delete_post') {
  1728. if (!empty($_POST['post_id'])) {
  1729. if (Wo_DeletePost($_POST['post_id']) === true) {
  1730. $data = array(
  1731. 'status' => 200
  1732. );
  1733. }
  1734. }
  1735. header("Content-type: application/json");
  1736. echo json_encode($data);
  1737. exit();
  1738. }
  1739. if ($s == 'update_google_analytics_code') {
  1740. if (isset($_POST['googleAnalytics'])) {
  1741. $saveSetting = false;
  1742. foreach ($_POST as $key => $value) {
  1743. $saveSetting = Wo_SaveConfig($key, $value);
  1744. }
  1745. if ($saveSetting === true) {
  1746. $data['status'] = 200;
  1747. }
  1748. }
  1749. header("Content-type: application/json");
  1750. echo json_encode($data);
  1751. exit();
  1752. }
  1753. if ($s == 'delete_reported_post') {
  1754. if (!empty($_GET['post_id'])) {
  1755. if (Wo_DeletePost($_GET['post_id']) === true) {
  1756. $deleteReport = Wo_DeleteReport($_GET['report_id']);
  1757. if ($deleteReport === true) {
  1758. $data = array(
  1759. 'status' => 200,
  1760. 'html' => Wo_CountUnseenReports()
  1761. );
  1762. }
  1763. }
  1764. }
  1765. header("Content-type: application/json");
  1766. echo json_encode($data);
  1767. exit();
  1768. }
  1769. if ($s == 'mark_as_safe') {
  1770. if (!empty($_GET['report_id'])) {
  1771. $deleteReport = Wo_DeleteReport($_GET['report_id']);
  1772. if ($deleteReport === true) {
  1773. $data = array(
  1774. 'status' => 200,
  1775. 'html' => Wo_CountUnseenReports()
  1776. );
  1777. }
  1778. }
  1779. header("Content-type: application/json");
  1780. echo json_encode($data);
  1781. exit();
  1782. }
  1783. if ($s == 'delete_verification') {
  1784. if (!empty($_GET['id'])) {
  1785. if (Wo_DeleteVerificationRequest($_GET['id']) === true) {
  1786. $data = array(
  1787. 'status' => 200
  1788. );
  1789. }
  1790. }
  1791. header("Content-type: application/json");
  1792. echo json_encode($data);
  1793. exit();
  1794. }
  1795. if ($s == 'delete_game') {
  1796. if (!empty($_GET['game_id'])) {
  1797. if (Wo_DeleteGame($_GET['game_id']) === true) {
  1798. $data = array(
  1799. 'status' => 200
  1800. );
  1801. }
  1802. }
  1803. header("Content-type: application/json");
  1804. echo json_encode($data);
  1805. exit();
  1806. }
  1807. if ($s == 'verify_user') {
  1808. if (!empty($_GET['id'])) {
  1809. $type = '';
  1810. if (!empty($_GET['type'])) {
  1811. $type = $_GET['type'];
  1812. }
  1813. if (Wo_VerifyUser($_GET['id'], $_GET['verification_id'], $type) === true) {
  1814. $data = array(
  1815. 'status' => 200
  1816. );
  1817. }
  1818. }
  1819. header("Content-type: application/json");
  1820. echo json_encode($data);
  1821. exit();
  1822. }
  1823. if ($s == 'send_mail_to_all_users') {
  1824. $isset_test = 'off';
  1825. if (empty($_POST['message']) || empty($_POST['subject'])) {
  1826. $send_errors = $error_icon . $wo['lang']['please_check_details'];
  1827. } else {
  1828. if (!empty($_POST['test_message'])) {
  1829. if ($_POST['test_message'] == 'on') {
  1830. $isset_test = 'on';
  1831. }
  1832. }
  1833. if ($isset_test == 'on') {
  1834. $headers = "From: " . $config['siteName'] . " <" . $config['siteEmail'] . ">\r\n";
  1835. $headers .= "Content-Type: text/html; charset=UTF-8\r\n";
  1836. @mail($wo['user']['email'], $_POST['subject'], $_POST['message'], $headers);
  1837. } else {
  1838. $users = Wo_GetAllUsers();
  1839. foreach ($users as $user) {
  1840. $headers = "From: " . $config['siteName'] . " <" . $config['siteEmail'] . ">\r\n";
  1841. $headers .= "Content-Type: text/html; charset=UTF-8\r\n";
  1842. @mail($user['email'], $_POST['subject'], $_POST['message'], $headers);
  1843. }
  1844. }
  1845. }
  1846. header("Content-type: application/json");
  1847. if (!empty($send_errors)) {
  1848. $send_errors_data = array(
  1849. 'status' => 400,
  1850. 'message' => $send_errors
  1851. );
  1852. echo json_encode($send_errors_data);
  1853. } else {
  1854. $data = array(
  1855. 'status' => 200
  1856. );
  1857. echo json_encode($data);
  1858. }
  1859. exit();
  1860. }
  1861. if ($s == 'add_new_announcement') {
  1862. if (!empty($_POST['announcement_text'])) {
  1863. $html = '';
  1864. $id = Wo_AddNewAnnouncement($_POST['announcement_text']);
  1865. if ($id > 0) {
  1866. $wo['activeAnnouncement'] = Wo_GetAnnouncement($id);
  1867. $html .= Wo_LoadPage('admin/announcement/active-list');
  1868. $data = array(
  1869. 'status' => 200,
  1870. 'text' => $html
  1871. );
  1872. }
  1873. }
  1874. header("Content-type: application/json");
  1875. echo json_encode($data);
  1876. exit();
  1877. }
  1878. if ($s == 'delete_announcement') {
  1879. if (!empty($_GET['id'])) {
  1880. $DeleteAnnouncement = Wo_DeleteAnnouncement($_GET['id']);
  1881. if ($DeleteAnnouncement === true) {
  1882. $data = array(
  1883. 'status' => 200
  1884. );
  1885. }
  1886. }
  1887. header("Content-type: application/json");
  1888. echo json_encode($data);
  1889. exit();
  1890. }
  1891. if ($s == 'disable_announcement') {
  1892. if (!empty($_GET['id'])) {
  1893. $html = '';
  1894. $DisableAnnouncement = Wo_DisableAnnouncement($_GET['id']);
  1895. if ($DisableAnnouncement === true) {
  1896. $wo['inactiveAnnouncement'] = Wo_GetAnnouncement($_GET['id']);
  1897. $html .= Wo_LoadPage('admin/announcement/inactive-list');
  1898. $data = array(
  1899. 'status' => 200,
  1900. 'html' => $html
  1901. );
  1902. }
  1903. }
  1904. header("Content-type: application/json");
  1905. echo json_encode($data);
  1906. exit();
  1907. }
  1908. if ($s == 'activate_announcement') {
  1909. if (!empty($_GET['id'])) {
  1910. $html = '';
  1911. $ActivateAnnouncement = Wo_ActivateAnnouncement($_GET['id']);
  1912. if ($ActivateAnnouncement === true) {
  1913. $wo['activeAnnouncement'] = Wo_GetAnnouncement($_GET['id']);
  1914. $html .= Wo_LoadPage('admin/announcement/active-list');
  1915. $data = array(
  1916. 'status' => 200,
  1917. 'html' => $html
  1918. );
  1919. }
  1920. }
  1921. header("Content-type: application/json");
  1922. echo json_encode($data);
  1923. exit();
  1924. }
  1925. if ($s == 'update_ads') {
  1926. if (!empty($_POST['type']) && !empty($_POST['code'])) {
  1927. $ad_data = array(
  1928. 'type' => $_POST['type'],
  1929. 'code' => $_POST['code']
  1930. );
  1931. if (Wo_UpdateAdsCode($ad_data)) {
  1932. $data = array(
  1933. 'status' => 200
  1934. );
  1935. }
  1936. }
  1937. header("Content-type: application/json");
  1938. echo json_encode($data);
  1939. exit();
  1940. }
  1941. if ($s == 'update_ads_status') {
  1942. if (!empty($_GET['type'])) {
  1943. if (Wo_UpdateAdActivation($_GET['type']) == 'active') {
  1944. $data = array(
  1945. 'status' => 200
  1946. );
  1947. } else {
  1948. $data = array(
  1949. 'status' => 300
  1950. );
  1951. }
  1952. }
  1953. header("Content-type: application/json");
  1954. echo json_encode($data);
  1955. exit();
  1956. }
  1957. }
  1958. if ($f == 'get_following_users') {
  1959. $html = '';
  1960. if (!empty($_GET['user_id'])) {
  1961. foreach (Wo_GetFollowing($_GET['user_id'], 'sidebar', 12) as $wo['UsersList']) {
  1962. $wo['UsersList']['user_name'] = $wo['UsersList']['name'];
  1963. if (!empty($wo['UsersList']['last_name'])) {
  1964. $wo['UsersList']['user_name'] = $wo['UsersList']['first_name'];
  1965. }
  1966. $html .= Wo_LoadPage('sidebar/profile-sidebar-user-list');
  1967. }
  1968. }
  1969. $data = array(
  1970. 'status' => 200,
  1971. 'html' => $html
  1972. );
  1973. header("Content-type: application/json");
  1974. echo json_encode($data);
  1975. exit();
  1976. }
  1977. if ($f == 'get_followers_users') {
  1978. $html = '';
  1979. if (!empty($_GET['user_id'])) {
  1980. foreach (Wo_GetFollowers($_GET['user_id'], 'sidebar', 12) as $wo['UsersList']) {
  1981. $wo['UsersList']['user_name'] = $wo['UsersList']['name'];
  1982. if (!empty($wo['UsersList']['last_name'])) {
  1983. $wo['UsersList']['user_name'] = $wo['UsersList']['first_name'];
  1984. }
  1985. $html .= Wo_LoadPage('sidebar/profile-sidebar-user-list');
  1986. }
  1987. }
  1988. $data = array(
  1989. 'status' => 200,
  1990. 'html' => $html
  1991. );
  1992. header("Content-type: application/json");
  1993. echo json_encode($data);
  1994. exit();
  1995. }
  1996. if ($f == 'posts') {
  1997. if ($s == 'fetch_url') {
  1998. if (isset($_POST["url"])) {
  1999. $get_url = $_POST["url"];
  2000. include_once("assets/import/simple_html_dom.inc.php");
  2001. $get_content = file_get_html($get_url);
  2002. foreach ($get_content->find('title') as $element) {
  2003. $page_title = $element->plaintext;
  2004. }
  2005. $page_body = $get_content->find("meta[name='description']", 0)->content;
  2006. $page_body = substr($page_body, 0, 250);
  2007. if ($page_body === false) {
  2008. $page_body = '';
  2009. }
  2010. $image_urls = array();
  2011. foreach ($get_content->find('img') as $element) {
  2012. if (!preg_match('/blank.(.*)/i', $element->src) && filter_var($element->src, FILTER_VALIDATE_URL)) {
  2013. $image_urls[] = $element->src;
  2014. }
  2015. }
  2016. $output = array(
  2017. 'title' => $page_title,
  2018. 'images' => $image_urls,
  2019. 'content' => $page_body,
  2020. 'url' => $_POST["url"]
  2021. );
  2022. echo json_encode($output);
  2023. exit();
  2024. }
  2025. }
  2026. if ($s == 'search_for_posts') {
  2027. $html = '';
  2028. if (!empty($_GET['search_query'])) {
  2029. $search_data = Wo_SearchForPosts($_GET['id'], $_GET['search_query'], 20, $_GET['type']);
  2030. if (count($search_data) == 0) {
  2031. $html = Wo_LoadPage('story/filter-no-stories-found');
  2032. } else {
  2033. foreach ($search_data as $wo['story']) {
  2034. $html .= Wo_LoadPage('story/content');
  2035. }
  2036. }
  2037. $data = array(
  2038. 'status' => 200,
  2039. 'html' => $html
  2040. );
  2041. }
  2042. header("Content-type: application/json");
  2043. echo json_encode($data);
  2044. exit();
  2045. }
  2046. if ($s == 'insert_new_post') {
  2047. $media = '';
  2048. $mediaFilename = '';
  2049. $mediaName = '';
  2050. $html = '';
  2051. $recipient_id = 0;
  2052. $page_id = 0;
  2053. $group_id = 0;
  2054. $image_array = array();
  2055. if (isset($_POST['recipient_id']) && !empty($_POST['recipient_id'])) {
  2056. $recipient_id = Wo_Secure($_POST['recipient_id']);
  2057. } else if (isset($_POST['page_id']) && !empty($_POST['page_id'])) {
  2058. $page_id = Wo_Secure($_POST['page_id']);
  2059. } else if (isset($_POST['group_id']) && !empty($_POST['group_id'])) {
  2060. $group_id = Wo_Secure($_POST['group_id']);
  2061. $group = Wo_GroupData($group_id);
  2062. if (!empty($group['id'])) {
  2063. if ($group['privacy'] == 1) {
  2064. $_POST['postPrivacy'] = 0;
  2065. } else if ($group['privacy'] == 2) {
  2066. $_POST['postPrivacy'] = 2;
  2067. }
  2068. }
  2069. }
  2070. if (isset($_FILES['postFile']['name'])) {
  2071. $fileInfo = array(
  2072. 'file' => $_FILES["postFile"]["tmp_name"],
  2073. 'name' => $_FILES['postFile']['name'],
  2074. 'size' => $_FILES["postFile"]["size"]
  2075. );
  2076. $media = Wo_ShareFile($fileInfo);
  2077. if (!empty($media)) {
  2078. $mediaFilename = $media['filename'];
  2079. $mediaName = $media['name'];
  2080. }
  2081. }
  2082. if (isset($_FILES['postVideo']['name']) && empty($mediaFilename)) {
  2083. $fileInfo = array(
  2084. 'file' => $_FILES["postVideo"]["tmp_name"],
  2085. 'name' => $_FILES['postVideo']['name'],
  2086. 'size' => $_FILES["postVideo"]["size"],
  2087. 'types' => 'mp4,m4v,webm,flv'
  2088. );
  2089. $media = Wo_ShareFile($fileInfo);
  2090. if (!empty($media)) {
  2091. $mediaFilename = $media['filename'];
  2092. $mediaName = $media['name'];
  2093. }
  2094. }
  2095. if (isset($_FILES['postMusic']['name']) && empty($mediaFilename)) {
  2096. $fileInfo = array(
  2097. 'file' => $_FILES["postMusic"]["tmp_name"],
  2098. 'name' => $_FILES['postMusic']['name'],
  2099. 'size' => $_FILES["postMusic"]["size"],
  2100. 'types' => 'mp3,wav'
  2101. );
  2102. $media = Wo_ShareFile($fileInfo);
  2103. if (!empty($media)) {
  2104. $mediaFilename = $media['filename'];
  2105. $mediaName = $media['name'];
  2106. }
  2107. }
  2108. $multi = 0;
  2109. if (isset($_FILES['postPhotos']['name']) && empty($mediaFilename) && empty($_POST['album_name'])) {
  2110. if (count($_FILES['postPhotos']['name']) == 1) {
  2111. $fileInfo = array(
  2112. 'file' => $_FILES["postPhotos"]["tmp_name"][0],
  2113. 'name' => $_FILES['postPhotos']['name'][0],
  2114. 'size' => $_FILES["postPhotos"]["size"][0]
  2115. );
  2116. $media = Wo_ShareFile($fileInfo);
  2117. if (!empty($media)) {
  2118. $mediaFilename = $media['filename'];
  2119. $mediaName = $media['name'];
  2120. }
  2121. } else {
  2122. $multi = 1;
  2123. }
  2124. }
  2125. if (empty($_POST['postPrivacy'])) {
  2126. $_POST['postPrivacy'] = 0;
  2127. }
  2128. $post_privacy = 0;
  2129. $privacy_array = array(
  2130. '0',
  2131. '1',
  2132. '2',
  2133. '3'
  2134. );
  2135. if (isset($_POST['postPrivacy'])) {
  2136. if (in_array($_POST['postPrivacy'], $privacy_array)) {
  2137. $post_privacy = $_POST['postPrivacy'];
  2138. }
  2139. }
  2140. $import_url_image = '';
  2141. $url_link = '';
  2142. $url_content = '';
  2143. $url_title = '';
  2144. if (!empty($_POST['url_link']) && !empty($_POST['url_title'])) {
  2145. $url_link = $_POST['url_link'];
  2146. $url_title = $_POST['url_title'];
  2147. if (!empty($_POST['url_content'])) {
  2148. $url_content = $_POST['url_content'];
  2149. }
  2150. if (!empty($_POST['url_image'])) {
  2151. $import_url_image = @Wo_ImportImageFromUrl($_POST['url_image']);
  2152. }
  2153. }
  2154. $post_text = '';
  2155. $post_map = '';
  2156. if (!empty($_POST['postText'])) {
  2157. $post_text = $_POST['postText'];
  2158. }
  2159. if (!empty($_POST['postMap'])) {
  2160. $post_map = $_POST['postMap'];
  2161. }
  2162. $album_name = '';
  2163. if (!empty($_POST['album_name'])) {
  2164. $album_name = $_POST['album_name'];
  2165. }
  2166. if (!isset($_FILES['postPhotos']['name'])) {
  2167. $album_name = '';
  2168. }
  2169. $traveling = '';
  2170. $watching = '';
  2171. $playing = '';
  2172. $listening = '';
  2173. $feeling = '';
  2174. if (!empty($_POST['feeling_type'])) {
  2175. $array_types = array(
  2176. 'feelings',
  2177. 'traveling',
  2178. 'watching',
  2179. 'playing',
  2180. 'listening'
  2181. );
  2182. if (in_array($_POST['feeling_type'], $array_types)) {
  2183. if ($_POST['feeling_type'] == 'feelings') {
  2184. if (!empty($_POST['feeling'])) {
  2185. if (array_key_exists($_POST['feeling'], $wo['feelingIcons'])) {
  2186. $feeling = $_POST['feeling'];
  2187. }
  2188. }
  2189. } else if ($_POST['feeling_type'] == 'traveling') {
  2190. if (!empty($_POST['feeling'])) {
  2191. $traveling = $_POST['feeling'];
  2192. }
  2193. } else if ($_POST['feeling_type'] == 'watching') {
  2194. if (!empty($_POST['feeling'])) {
  2195. $watching = $_POST['feeling'];
  2196. }
  2197. } else if ($_POST['feeling_type'] == 'playing') {
  2198. if (!empty($_POST['feeling'])) {
  2199. $playing = $_POST['feeling'];
  2200. }
  2201. } else if ($_POST['feeling_type'] == 'listening') {
  2202. if (!empty($_POST['feeling'])) {
  2203. $listening = $_POST['feeling'];
  2204. }
  2205. }
  2206. }
  2207. }
  2208. if (isset($_FILES['postPhotos']['name'])) {
  2209. $allowed = array(
  2210. 'gif',
  2211. 'png',
  2212. 'jpg',
  2213. 'jpeg'
  2214. );
  2215. for ($i = 0; $i < count($_FILES['postPhotos']['name']); $i++) {
  2216. $new_string = pathinfo($_FILES['postPhotos']['name'][$i]);
  2217. if (!in_array(strtolower($new_string['extension']), $allowed)) {
  2218. $errors[] = $error_icon . $wo['lang']['please_check_details'];
  2219. }
  2220. }
  2221. }
  2222. if (empty($errors)) {
  2223. if($recipient_id=="0")
  2224. {
  2225. $status = "1";
  2226. }
  2227. else
  2228. {
  2229. $status ="0";
  2230. }
  2231. $post_data = array(
  2232. 'user_id' => Wo_Secure($wo['user']['user_id']),
  2233. 'page_id' => Wo_Secure($page_id),
  2234. 'group_id' => Wo_Secure($group_id),
  2235. 'postText' => Wo_Secure($post_text),
  2236. 'recipient_id' => Wo_Secure($recipient_id),
  2237. 'postFile' => Wo_Secure($mediaFilename),
  2238. 'postFileName' => Wo_Secure($mediaName),
  2239. 'postMap' => Wo_Secure($post_map),
  2240. 'postPrivacy' => Wo_Secure($post_privacy),
  2241. 'postLinkTitle' => Wo_Secure($url_title),
  2242. 'postLinkContent' => Wo_Secure($url_content),
  2243. 'postLink' => Wo_Secure($url_link),
  2244. 'postLinkImage' => Wo_Secure($import_url_image),
  2245. 'album_name' => Wo_Secure($album_name),
  2246. 'multi_image' => Wo_Secure($multi),
  2247. 'postFeeling' => Wo_Secure($feeling),
  2248. 'postListening' => Wo_Secure($listening),
  2249. 'postPlaying' => Wo_Secure($playing),
  2250. 'postWatching' => Wo_Secure($watching),
  2251. 'status' => $status,
  2252. 'postTraveling' => Wo_Secure($traveling),
  2253. 'time' => time()
  2254. );
  2255. $id = Wo_RegisterPost($post_data);
  2256. if ($id) {
  2257. if (isset($_FILES['postPhotos']['name'])) {
  2258. if (count($_FILES['postPhotos']['name']) > 0) {
  2259. for ($i = 0; $i < count($_FILES['postPhotos']['name']); $i++) {
  2260. $fileInfo = array(
  2261. 'file' => $_FILES["postPhotos"]["tmp_name"][$i],
  2262. 'name' => $_FILES['postPhotos']['name'][$i],
  2263. 'size' => $_FILES["postPhotos"]["size"][$i],
  2264. 'types' => 'jpg,png,jpeg,gif'
  2265. );
  2266. $file = Wo_ShareFile($fileInfo, 1);
  2267. if (!empty($file)) {
  2268. $media_album = Wo_RegisterAlbumMedia($id, $file['filename']);
  2269. }
  2270. }
  2271. }
  2272. }
  2273. $wo['story'] = Wo_PostData($id);
  2274. $html .= Wo_LoadPage('story/content');
  2275. $data = array(
  2276. 'status' => 200,
  2277. 'html' => $html
  2278. );
  2279. }
  2280. }
  2281. header("Content-type: application/json");
  2282. echo json_encode($data);
  2283. exit();
  2284. }
  2285. if ($s == 'delete_post') {
  2286. if (!empty($_GET['post_id'])) {
  2287. if (Wo_DeletePost($_GET['post_id']) === true) {
  2288. $data = array(
  2289. 'status' => 200
  2290. );
  2291. }
  2292. }
  2293. header("Content-type: application/json");
  2294. echo json_encode($data);
  2295. exit();
  2296. }
  2297. if ($s == 'get_new_posts') {
  2298. if (!empty($_GET['before_post_id']) && isset($_GET['user_id'])) {
  2299. $html = '';
  2300. $postsData = array(
  2301. 'before_post_id' => $_GET['before_post_id'],
  2302. 'publisher_id' => $_GET['user_id']
  2303. );
  2304. foreach (Wo_GetPosts($postsData) as $wo['story']) {
  2305. $html .= Wo_LoadPage('story/ana-content');
  2306. }
  2307. $data = array(
  2308. 'status' => 200,
  2309. 'html' => $html
  2310. );
  2311. }
  2312. header("Content-type: application/json");
  2313. echo json_encode($data);
  2314. exit();
  2315. }
  2316. if ($s == 'load_more_posts') {
  2317. $html = '';
  2318. if (!empty($_GET['filter_by_more']) && !empty($_GET['after_post_id'])) {
  2319. $page_id = 0;
  2320. $group_id = 0;
  2321. $user_id = 0;
  2322. if (!empty($_GET['page_id']) && $_GET['page_id'] > 0) {
  2323. $page_id = Wo_Secure($_GET['page_id']);
  2324. }
  2325. if (!empty($_GET['group_id']) && $_GET['group_id'] > 0) {
  2326. $group_id = Wo_Secure($_GET['group_id']);
  2327. }
  2328. if (!empty($_GET['user_id']) && $_GET['user_id'] > 0) {
  2329. $user_id = Wo_Secure($_GET['user_id']);
  2330. }
  2331. $postsData = array(
  2332. 'filter_by' => Wo_Secure($_GET['filter_by_more']),
  2333. 'limit' => 5,
  2334. 'publisher_id' => $user_id,
  2335. 'group_id' => $group_id,
  2336. 'page_id' => $page_id,
  2337. 'after_post_id' => Wo_Secure($_GET['after_post_id'])
  2338. );
  2339. foreach (Wo_GetPosts($postsData) as $wo['story']) {
  2340. if($wo["story"]["testt"]=="1")
  2341. {
  2342. if($_GET['user_id']==$wo["story"]["user_id"])
  2343. {
  2344.  
  2345.  
  2346. }
  2347. else
  2348. {
  2349. $html .= Wo_LoadPage('story/ana-content');
  2350. }
  2351. }
  2352. else
  2353. {
  2354. $html .= Wo_LoadPage('story/ana-content');
  2355. }
  2356. }
  2357. if (empty($html)) {
  2358. $data = array(
  2359. 'status' => 300,
  2360. 'text' => $wo['lang']['no_more_posts']
  2361. );
  2362. } else {
  2363. $data = array(
  2364. 'status' => 200,
  2365. 'html' => $html
  2366. );
  2367. }
  2368. }
  2369. header("Content-type: application/json");
  2370. echo json_encode($data);
  2371. exit();
  2372. }
  2373. if ($s == 'edit_post') {
  2374. if (!empty($_POST['post_id']) && !empty($_POST['text'])) {
  2375. $updatePost = Wo_UpdatePost(array(
  2376. 'post_id' => $_POST['post_id'],
  2377. 'text' => $_POST['text']
  2378. ));
  2379. if (!empty($updatePost)) {
  2380. $data = array(
  2381. 'status' => 200,
  2382. 'html' => $updatePost
  2383. );
  2384. }
  2385. }
  2386. header("Content-type: application/json");
  2387. echo json_encode($data);
  2388. exit();
  2389. }
  2390. if ($s == "update_post_privacy") {
  2391. if (!empty($_GET['post_id']) && isset($_GET['privacy_type'])) {
  2392. $updatePost = Wo_UpdatePostPrivacy(array(
  2393. 'post_id' => Wo_Secure($_GET['post_id']),
  2394. 'privacy_type' => Wo_Secure($_GET['privacy_type'])
  2395. ));
  2396. if (isset($updatePost)) {
  2397. $data = array(
  2398. 'status' => 200,
  2399. 'privacy_type' => $updatePost
  2400. );
  2401. }
  2402. }
  2403. header("Content-type: application/json");
  2404. echo json_encode($data);
  2405. exit();
  2406. }
  2407. if ($s == 'register_like') {
  2408. if (!empty($_GET['post_id'])) {
  2409. if (Wo_AddLikes($_GET['post_id']) == 'unliked') {
  2410. $data = array(
  2411. 'status' => 300,
  2412. 'likes' => Wo_CountLikes($_GET['post_id']),
  2413. 'like_lang' => $wo['lang']['like']
  2414. );
  2415. } else {
  2416. $data = array(
  2417. 'status' => 200,
  2418. 'likes' => Wo_CountLikes($_GET['post_id']),
  2419. 'like_lang' => $wo['lang']['liked']
  2420. );
  2421.  
  2422. }
  2423. $data['dislike'] = 0;
  2424. if ($wo['config']['second_post_button'] == 'dislike') {
  2425. $data['dislike'] = 1;
  2426. $data['default_lang_like'] = $wo['lang']['like'];
  2427. $data['default_lang_dislike'] = $wo['lang']['dislike'];
  2428. }
  2429. }
  2430. header("Content-type: application/json");
  2431. echo json_encode($data);
  2432. exit();
  2433. }
  2434. if ($s == 'register_wonder') {
  2435. if (!empty($_GET['post_id'])) {
  2436. if (Wo_AddWonders($_GET['post_id']) == 'unwonder') {
  2437. $data = array(
  2438. 'status' => 300,
  2439. 'icon' => $wo['second_post_button_icon'],
  2440. 'wonders' => Wo_CountWonders($_GET['post_id'])
  2441. );
  2442. $data['wonder_lang'] = ($config['second_post_button'] == 'dislike') ? $wo['lang']['dislike'] : $wo['lang']['wonder'];
  2443. } else {
  2444. $data = array(
  2445. 'status' => 200,
  2446. 'icon' => $wo['second_post_button_icon'],
  2447. 'wonders' => Wo_CountWonders($_GET['post_id'])
  2448. );
  2449. $data['wonder_lang'] = ($config['second_post_button'] == 'dislike') ? $wo['lang']['disliked'] : $wo['lang']['wondered'];
  2450. }
  2451. $data['dislike'] = 0;
  2452. if ($wo['config']['second_post_button'] == 'dislike') {
  2453. $data['dislike'] = 1;
  2454. $data['default_lang_like'] = $wo['lang']['like'];
  2455. $data['default_lang_dislike'] = $wo['lang']['dislike'];
  2456. }
  2457. }
  2458. header("Content-type: application/json");
  2459. echo json_encode($data);
  2460. exit();
  2461. }
  2462. if ($s == 'register_share') {
  2463. if (!empty($_GET['post_id'])) {
  2464. if (Wo_AddShare($_GET['post_id']) == 'unshare') {
  2465. $data = array(
  2466. 'status' => 300,
  2467. 'shares' => Wo_CountShares($_GET['post_id'])
  2468. );
  2469. } else {
  2470. $data = array(
  2471. 'status' => 200,
  2472. 'shares' => Wo_CountShares($_GET['post_id'])
  2473. );
  2474. }
  2475. }
  2476. header("Content-type: application/json");
  2477. echo json_encode($data);
  2478. exit();
  2479. }
  2480. if ($s == 'register_comment') {
  2481. if (!empty($_POST['post_id']) && !empty($_POST['text'])) {
  2482. $html = '';
  2483. $page_id = '';
  2484. if (!empty($_POST['page_id'])) {
  2485. $page_id = $_POST['page_id'];
  2486. }
  2487. $C_Data = array(
  2488. 'user_id' => Wo_Secure($wo['user']['user_id']),
  2489. 'page_id' => Wo_Secure($page_id),
  2490. 'post_id' => Wo_Secure($_POST['post_id']),
  2491. 'text' => Wo_Secure($_POST['text']),
  2492. 'time' => time()
  2493. );
  2494. $R_Comment = Wo_RegisterPostComment($C_Data);
  2495. $wo['comment'] = Wo_GetPostComment($R_Comment);
  2496. $wo['story'] = Wo_PostData($_POST['post_id']);
  2497. if (!empty($wo['comment'])) {
  2498. $html = Wo_LoadPage('comment/content');
  2499. $data = array(
  2500. 'status' => 200,
  2501. 'html' => $html,
  2502. 'comments_num' => Wo_CountPostComment($_POST['post_id'])
  2503. );
  2504. }
  2505. }
  2506. header("Content-type: application/json");
  2507. echo json_encode($data);
  2508. exit();
  2509. }
  2510. if ($s == 'register_reply') {
  2511. if (!empty($_POST['comment_id']) && !empty($_POST['text'])) {
  2512. $html = '';
  2513. $page_id = '';
  2514. if (!empty($_POST['page_id'])) {
  2515. $page_id = $_POST['page_id'];
  2516. }
  2517. $C_Data = array(
  2518. 'user_id' => Wo_Secure($wo['user']['user_id']),
  2519. 'page_id' => Wo_Secure($page_id),
  2520. 'comment_id' => Wo_Secure($_POST['comment_id']),
  2521. 'text' => Wo_Secure($_POST['text']),
  2522. 'time' => time()
  2523. );
  2524. $R_Comment = Wo_RegisterCommentReply($C_Data);
  2525. $wo['reply'] = Wo_GetCommentReply($R_Comment);
  2526. if (!empty($wo['reply'])) {
  2527. $html = Wo_LoadPage('comment/replies-content');
  2528. $data = array(
  2529. 'status' => 200,
  2530. 'html' => $html,
  2531. 'replies_num' => Wo_CountCommentReplies($_POST['comment_id'])
  2532. );
  2533. }
  2534. }
  2535. header("Content-type: application/json");
  2536. echo json_encode($data);
  2537. exit();
  2538. }
  2539. if ($s == 'delete_comment') {
  2540. if (!empty($_GET['comment_id'])) {
  2541. $DeleteComment = Wo_DeletePostComment($_GET['comment_id']);
  2542. if ($DeleteComment === true) {
  2543. $data = array(
  2544. 'status' => 200
  2545. );
  2546. }
  2547. }
  2548. header("Content-type: application/json");
  2549. echo json_encode($data);
  2550. exit();
  2551. }
  2552. if ($s == 'delete_comment_reply') {
  2553. if (!empty($_GET['reply_id'])) {
  2554. $DeleteComment = Wo_DeletePostReplyComment($_GET['reply_id']);
  2555. if ($DeleteComment === true) {
  2556. $data = array(
  2557. 'status' => 200
  2558. );
  2559. }
  2560. }
  2561. header("Content-type: application/json");
  2562. echo json_encode($data);
  2563. exit();
  2564. }
  2565. if ($s == 'load_more_comments') {
  2566. if (!empty($_GET['post_id'])) {
  2567. $html = '';
  2568. $wo['story'] = Wo_PostData($_GET['post_id']);
  2569. foreach (Wo_GetPostComments($_GET['post_id'], Wo_CountPostComment($_GET['post_id'])) as $wo['comment']) {
  2570. $html .= Wo_LoadPage('comment/content');
  2571. }
  2572. $data = array(
  2573. 'status' => 200,
  2574. 'html' => $html
  2575. );
  2576. }
  2577. header("Content-type: application/json");
  2578. echo json_encode($data);
  2579. exit();
  2580. }
  2581. if ($s == 'load_more_replies') {
  2582. if (!empty($_GET['comment_id'])) {
  2583. $html = '';
  2584. foreach (Wo_GetCommentReplies($_GET['comment_id'], Wo_CountCommentReplies($_GET['comment_id'])) as $wo['reply']) {
  2585. $html .= Wo_LoadPage('comment/replies-content');
  2586. }
  2587. $data = array(
  2588. 'status' => 200,
  2589. 'html' => $html
  2590. );
  2591. }
  2592. header("Content-type: application/json");
  2593. echo json_encode($data);
  2594. exit();
  2595. }
  2596. if ($s == 'edit_comment') {
  2597. if (!empty($_POST['comment_id']) && !empty($_POST['text'])) {
  2598. $updateComment = Wo_UpdateComment(array(
  2599. 'comment_id' => $_POST['comment_id'],
  2600. 'text' => $_POST['text']
  2601. ));
  2602. if (!empty($updateComment)) {
  2603. $data = array(
  2604. 'status' => 200,
  2605. 'html' => $updateComment
  2606. );
  2607. }
  2608. }
  2609. header("Content-type: application/json");
  2610. echo json_encode($data);
  2611. exit();
  2612. }
  2613. if ($s == 'register_comment_like') {
  2614. if (!empty($_POST['comment_id'])) {
  2615. if (Wo_AddCommentLikes($_POST['comment_id'], $_POST['comment_text']) == 'unliked') {
  2616. $data = array(
  2617. 'status' => 300,
  2618. 'likes' => Wo_CountCommentLikes($_POST['comment_id'])
  2619. );
  2620. } else {
  2621. $data = array(
  2622. 'status' => 200,
  2623. 'likes' => Wo_CountCommentLikes($_POST['comment_id'])
  2624. );
  2625. }
  2626. $data['dislike'] = 0;
  2627. if ($wo['config']['second_post_button'] == 'dislike') {
  2628. $data['dislike'] = 1;
  2629. $data['wonders_c'] = Wo_CountCommentWonders($_POST['comment_id']);
  2630. }
  2631. }
  2632. header("Content-type: application/json");
  2633. echo json_encode($data);
  2634. exit();
  2635. }
  2636. if ($s == 'register_comment_wonder') {
  2637. if (!empty($_POST['comment_id'])) {
  2638. if (Wo_AddCommentWonders($_POST['comment_id'], $_POST['comment_text']) == 'unwonder') {
  2639. $data = array(
  2640. 'status' => 300,
  2641. 'icon' => $wo['second_post_button_icon'],
  2642. 'wonders' => Wo_CountCommentWonders($_POST['comment_id'])
  2643. );
  2644. } else {
  2645. $data = array(
  2646. 'status' => 200,
  2647. 'icon' => $wo['second_post_button_icon'],
  2648. 'wonders' => Wo_CountCommentWonders($_POST['comment_id'])
  2649. );
  2650. }
  2651. $data['dislike'] = 0;
  2652. if ($wo['config']['second_post_button'] == 'dislike') {
  2653. $data['dislike'] = 1;
  2654. $data['likes_c'] = Wo_CountCommentLikes($_POST['comment_id']);
  2655. }
  2656. }
  2657. header("Content-type: application/json");
  2658. echo json_encode($data);
  2659. exit();
  2660. }
  2661. if ($s == 'register_comment_reply_like') {
  2662. if (!empty($_POST['reply_id'])) {
  2663. if (Wo_AddCommentReplyLikes($_POST['reply_id'], $_POST['comment_text']) == 'unliked') {
  2664. $data = array(
  2665. 'status' => 300,
  2666. 'likes' => Wo_CountCommentReplyLikes($_POST['reply_id'])
  2667. );
  2668. } else {
  2669. $data = array(
  2670. 'status' => 200,
  2671. 'likes' => Wo_CountCommentReplyLikes($_POST['reply_id'])
  2672. );
  2673. }
  2674. $data['dislike'] = 0;
  2675. if ($wo['config']['second_post_button'] == 'dislike') {
  2676. $data['dislike'] = 1;
  2677. $data['wonders_r'] = Wo_CountCommentReplyWonders($_POST['reply_id']);
  2678. }
  2679. }
  2680. header("Content-type: application/json");
  2681. echo json_encode($data);
  2682. exit();
  2683. }
  2684. if ($s == 'register_comment_reply_wonder') {
  2685. if (!empty($_POST['reply_id'])) {
  2686. if (Wo_AddCommentReplyWonders($_POST['reply_id'], $_POST['comment_text']) == 'unwonder') {
  2687. $data = array(
  2688. 'status' => 300,
  2689. 'icon' => $wo['second_post_button_icon'],
  2690. 'wonders' => Wo_CountCommentReplyWonders($_POST['reply_id'])
  2691. );
  2692. } else {
  2693. $data = array(
  2694. 'status' => 200,
  2695. 'icon' => $wo['second_post_button_icon'],
  2696. 'wonders' => Wo_CountCommentReplyWonders($_POST['reply_id'])
  2697. );
  2698. }
  2699. $data['dislike'] = 0;
  2700. if ($wo['config']['second_post_button'] == 'dislike') {
  2701. $data['dislike'] = 1;
  2702. $data['likes_r'] = Wo_CountCommentReplyLikes($_POST['reply_id']);
  2703. }
  2704. }
  2705. header("Content-type: application/json");
  2706. echo json_encode($data);
  2707. exit();
  2708. }
  2709. if ($s == 'save_post') {
  2710. if (!empty($_GET['post_id'])) {
  2711. $post_data = array(
  2712. 'post_id' => $_GET['post_id']
  2713. );
  2714. if (Wo_SavePosts($post_data) == 'unsaved') {
  2715. $data = array(
  2716. 'status' => 300,
  2717. 'text' => $wo['lang']['save_post']
  2718. );
  2719. } else {
  2720. $data = array(
  2721. 'status' => 200,
  2722. 'text' => $wo['lang']['unsave_post']
  2723. );
  2724. }
  2725. }
  2726. header("Content-type: application/json");
  2727. echo json_encode($data);
  2728. exit();
  2729. }
  2730. if ($s == 'pin_post') {
  2731. if (!empty($_GET['post_id'])) {
  2732. $type = 'profile';
  2733. $id = 0;
  2734. if (!empty($_GET['type'])) {
  2735. $types_array = array(
  2736. 'profile',
  2737. 'page',
  2738. 'group'
  2739. );
  2740. if (in_array($_GET['type'], $types_array)) {
  2741. $type = $_GET['type'];
  2742. }
  2743. }
  2744. if (!empty($_GET['id']) && is_numeric($_GET['id'])) {
  2745. $id = $_GET['id'];
  2746. }
  2747. if (Wo_PinPost($_GET['post_id'], $type, $id) == 'unpin') {
  2748. $data = array(
  2749. 'status' => 300,
  2750. 'text' => $wo['lang']['pin_post']
  2751. );
  2752. } else {
  2753. $data = array(
  2754. 'status' => 200,
  2755. 'text' => $wo['lang']['unpin_post']
  2756. );
  2757. }
  2758. }
  2759. header("Content-type: application/json");
  2760. echo json_encode($data);
  2761. exit();
  2762. }
  2763. if ($s == 'report_post') {
  2764. if (!empty($_GET['post_id'])) {
  2765. $post_data = array(
  2766. 'post_id' => $_GET['post_id']
  2767. );
  2768. if (Wo_ReportPost($post_data) == 'unreport') {
  2769. $data = array(
  2770. 'status' => 300,
  2771. 'text' => $wo['lang']['report_post']
  2772. );
  2773. } else {
  2774. $data = array(
  2775. 'status' => 200,
  2776. 'text' => $wo['lang']['unreport_post']
  2777. );
  2778. }
  2779. }
  2780. header("Content-type: application/json");
  2781. echo json_encode($data);
  2782. exit();
  2783. }
  2784. if ($s == 'get_post_likes') {
  2785. if (!empty($_GET['post_id'])) {
  2786. $data = array(
  2787. 'status' => 200,
  2788. 'html' => ''
  2789. );
  2790. $likedUsers = Wo_GetPostLikes($_GET['post_id']);
  2791. if (count($likedUsers) > 0) {
  2792. foreach ($likedUsers as $wo['WondredLikedusers']) {
  2793. $data['html'] .= Wo_LoadPage('story/post-likes-wonders');
  2794. }
  2795. } else {
  2796. $data['message'] = $wo['lang']['no_likes'];
  2797. }
  2798. }
  2799. header("Content-type: application/json");
  2800. echo json_encode($data);
  2801. exit();
  2802. }
  2803. if ($s == 'get_post_wonders') {
  2804. if (!empty($_GET['post_id'])) {
  2805. $data = array(
  2806. 'status' => 200,
  2807. 'html' => ''
  2808. );
  2809. $WonderedUsers = Wo_GetPostWonders($_GET['post_id']);
  2810. if (count($WonderedUsers) > 0) {
  2811. foreach ($WonderedUsers as $wo['WondredLikedusers']) {
  2812. $data['html'] .= Wo_LoadPage('story/post-likes-wonders');
  2813. }
  2814. } else {
  2815. $data['message'] = ($config['second_post_button'] == 'dislike') ? $wo['lang']['no_dislikes'] : $wo['lang']['no_wonders'];
  2816. }
  2817. }
  2818. header("Content-type: application/json");
  2819. echo json_encode($data);
  2820. exit();
  2821. }
  2822. if ($s == 'filter_posts') {
  2823. if (!empty($_GET['filter_by']) && isset($_GET['id'])) {
  2824. $html = '';
  2825. $options = array(
  2826. 'filter_by' => Wo_Secure($_GET['filter_by'])
  2827. );
  2828. if (!empty($_GET['type'])) {
  2829. if ($_GET['type'] == 'page') {
  2830. $options['page_id'] = $_GET['id'];
  2831. } else if ($_GET['type'] == 'profile') {
  2832. $options['publisher_id'] = $_GET['id'];
  2833. } else if ($_GET['type'] == 'group') {
  2834. $options['group_id'] = $_GET['id'];
  2835. }
  2836. }
  2837. $stories = Wo_GetPosts($options);
  2838. if (count($stories) > 0) {
  2839. foreach ($stories as $wo['story']) {
  2840. $html .= Wo_LoadPage('story/content');
  2841. }
  2842. } else {
  2843. $html .= Wo_LoadPage('story/filter-no-stories-found');
  2844. }
  2845. $loadMoreText = '<i class="fa fa-chevron-circle-down progress-icon" data-icon="chevron-circle-down"></i> ' . $wo['lang']['load_more_posts'];
  2846. if (empty($stories)) {
  2847. $loadMoreText = $wo['lang']['no_more_posts'];
  2848. }
  2849. $data = array(
  2850. 'status' => 200,
  2851. 'html' => $html,
  2852. 'text' => $loadMoreText
  2853. );
  2854. }
  2855. header("Content-type: application/json");
  2856. echo json_encode($data);
  2857. exit();
  2858. }
  2859. }
  2860. if ($f == 'activities') {
  2861. if ($s == 'get_new_activities') {
  2862. if (!empty($_POST['before_activity_id'])) {
  2863. $html = '';
  2864. $activity = Wo_GetActivities(array(
  2865. 'before_activity_id' => Wo_Secure($_POST['before_activity_id'])
  2866. ));
  2867. foreach ($activity as $wo['activity']) {
  2868. $wo['activity']['unread'] = 'unread';
  2869. $html .= Wo_LoadPage('sidebar/activities-list');
  2870. }
  2871. $data = array(
  2872. 'status' => 200,
  2873. 'html' => $html
  2874. );
  2875. }
  2876. header("Content-type: application/json");
  2877. echo json_encode($data);
  2878. exit();
  2879. }
  2880. if ($s == 'get_more_activities') {
  2881. if (!empty($_POST['after_activity_id'])) {
  2882. $html = '';
  2883. foreach (Wo_GetActivities(array(
  2884. 'after_activity_id' => Wo_Secure($_POST['after_activity_id'])
  2885. )) as $wo['activity']) {
  2886. $html .= Wo_LoadPage('sidebar/activities-list');
  2887. }
  2888. $data = array(
  2889. 'status' => 200,
  2890. 'html' => $html
  2891. );
  2892. if (empty($html)) {
  2893. $data['message'] = $wo['lang']['no_more_actitivties'];
  2894. }
  2895. }
  2896. header("Content-type: application/json");
  2897. echo json_encode($data);
  2898. exit();
  2899. }
  2900. }
  2901. if ($f == 'chat') {
  2902. if ($s == 'count_online_users') {
  2903. $html = Wo_CountOnlineUsers();
  2904. $data = array(
  2905. 'status' => 200,
  2906. 'html' => $html
  2907. );
  2908. header("Content-type: application/json");
  2909. echo json_encode($data);
  2910. exit();
  2911. }
  2912. if ($s == 'chat_side') {
  2913. $online_users = '';
  2914. $offline_users = '';
  2915. $OnlineUsers = Wo_GetChatUsers('online');
  2916. $OfflineUsers = Wo_GetChatUsers('offline');
  2917. $count_chat = Wo_CountOnlineUsers();
  2918. foreach ($OnlineUsers as $wo['chatList']) {
  2919. $online_users .= Wo_LoadPage('chat/online-user');
  2920. }
  2921. foreach ($OfflineUsers as $wo['chatList']) {
  2922. $offline_users .= Wo_LoadPage('chat/offline-user');
  2923. }
  2924. $data = array(
  2925. 'status' => 200,
  2926. 'online_users' => $online_users,
  2927. 'offline_users' => $offline_users,
  2928. 'count_chat' => $count_chat
  2929. );
  2930. if (!empty($_GET['user_id'])) {
  2931. $user_id = Wo_Secure($_GET['user_id']);
  2932. if (!empty($user_id)) {
  2933. $user_id = $_GET['user_id'];
  2934. $status = Wo_IsOnline($user_id);
  2935. if ($status === true) {
  2936. $data['chat_user_tab'] = 200;
  2937. } else {
  2938. $data['chat_user_tab'] = 300;
  2939. }
  2940. }
  2941. }
  2942. $data['messages'] = 0;
  2943. if (!empty($_GET['user_id']) && isset($_GET['message_id'])) {
  2944. $html = '';
  2945. $user_id = Wo_Secure($_GET['user_id']);
  2946. if (!empty($user_id)) {
  2947. $user_id = $_GET['user_id'];
  2948. $messages = Wo_GetMessages(array(
  2949. 'after_message_id' => $_GET['message_id'],
  2950. 'new' => true,
  2951. 'user_id' => $user_id
  2952. ));
  2953. if (count($messages) > 0) {
  2954. foreach ($messages as $wo['chatMessage']) {
  2955. $messages_html .= Wo_LoadPage('chat/chat-list');
  2956. }
  2957. $data['chat_user_tab'] = 200;
  2958. $data['messages'] = 200;
  2959. $data['messages_html'] = $messages_html;
  2960. $data['receiver'] = 200;
  2961. $data['sender'] = 200;
  2962. }
  2963. }
  2964. }
  2965. $data['can_seen'] = 0;
  2966. if (!empty($_GET['last_id']) && $wo['config']['message_seen'] == 1) {
  2967. $message_id = Wo_Secure($_GET['last_id']);
  2968. if (!empty($message_id) || is_numeric($message_id) || $message_id > 0) {
  2969. $seen = Wo_SeenMessage($message_id);
  2970. if ($seen > 0) {
  2971. $data['can_seen'] = 1;
  2972. $data['time'] = $seen['time'];
  2973. $data['seen'] = $seen['seen'];
  2974. }
  2975. }
  2976. }
  2977. $data['is_typing'] = 0;
  2978. if (!empty($_GET['user_id']) && $wo['config']['message_typing'] == 1) {
  2979. $isTyping = Wo_IsTyping($_GET['user_id']);
  2980. if ($isTyping === true) {
  2981. $img = Wo_UserData($_GET['user_id']);
  2982. $data['is_typing'] = 200;
  2983. $data['img'] = $img['avatar'];
  2984. $data['typing'] = $wo['config']['theme_url'] . '/img/loading_dots.gif';
  2985. }
  2986. }
  2987. header("Content-type: application/json");
  2988. echo json_encode($data);
  2989. exit();
  2990. }
  2991. if ($s == 'is_recipient_typing') {
  2992.  
  2993. header("Content-type: application/json");
  2994. echo json_encode($data);
  2995. exit();
  2996. }
  2997. if ($s == 'recipient_is_typing') {
  2998. if (!empty($_GET['recipient_id'])) {
  2999. $isTyping = Wo_RegisterTyping($_GET['recipient_id'], 1);
  3000. if ($isTyping === true) {
  3001. $data = array(
  3002. 'status' => 200
  3003. );
  3004. }
  3005. }
  3006. header("Content-type: application/json");
  3007. echo json_encode($data);
  3008. exit();
  3009. }
  3010. if ($s == 'remove_typing') {
  3011. if (!empty($_GET['recipient_id'])) {
  3012. $isTyping = Wo_RegisterTyping($_GET['recipient_id'], 0);
  3013. if ($isTyping === true) {
  3014. $data = array(
  3015. 'status' => 200
  3016. );
  3017. }
  3018. }
  3019. header("Content-type: application/json");
  3020. echo json_encode($data);
  3021. exit();
  3022. }
  3023. if ($s == 'update_online_recipients') {
  3024. $html = '';
  3025. $OnlineUsers = Wo_GetChatUsers('online');
  3026. foreach ($OnlineUsers as $wo['chatList']) {
  3027. $html .= Wo_LoadPage('chat/online-user');
  3028. }
  3029. $data = array(
  3030. 'status' => 200,
  3031. 'html' => $html
  3032. );
  3033. header("Content-type: application/json");
  3034. echo json_encode($data);
  3035. exit();
  3036. }
  3037. if ($s == 'update_offline_recipients') {
  3038. $html = '';
  3039. $OfflineUsers = Wo_GetChatUsers('offline');
  3040. foreach ($OfflineUsers as $wo['chatList']) {
  3041. $html .= Wo_LoadPage('chat/offline-user');
  3042. }
  3043. $data = array(
  3044. 'status' => 200,
  3045. 'html' => $html
  3046. );
  3047. header("Content-type: application/json");
  3048. echo json_encode($data);
  3049. exit();
  3050. }
  3051. if ($s == 'search_for_recipients') {
  3052. if (!empty($_POST['search_query'])) {
  3053. $html = '';
  3054. $search = Wo_ChatSearchUsers($_POST['search_query']);
  3055. foreach ($search as $wo['chatList']) {
  3056. $html .= Wo_LoadPage('chat/search-result');
  3057. }
  3058. $data = array(
  3059. 'status' => 200,
  3060. 'html' => $html
  3061. );
  3062. }
  3063. header("Content-type: application/json");
  3064. echo json_encode($data);
  3065. exit();
  3066. }
  3067. if ($s == 'update_chat_status') {
  3068. if (!empty($_POST['status'])) {
  3069. $html = '';
  3070. $status = Wo_UpdateStatus($_POST['status']);
  3071. if ($status == 0) {
  3072. $data = array(
  3073. 'status' => $status
  3074. );
  3075. } else if ($status == 1) {
  3076. $data = array(
  3077. 'status' => $status
  3078. );
  3079. }
  3080. }
  3081. header("Content-type: application/json");
  3082. echo json_encode($data);
  3083. exit();
  3084. }
  3085. if ($s == 'load_chat_tab') {
  3086. if (!empty($_GET['recipient_id']) && is_numeric($_GET['recipient_id']) && $_GET['recipient_id'] > 0) {
  3087. $recipient_id = Wo_Secure($_GET['recipient_id']);
  3088. $recipient = Wo_UserData($recipient_id);
  3089. if (isset($recipient['user_id'])) {
  3090. $wo['chat']['recipient'] = $recipient;
  3091. $data = array(
  3092. 'status' => 200,
  3093. 'html' => Wo_LoadPage('chat/chat-tab')
  3094. );
  3095. $_SESSION['chat_id'] = $recipient['user_id'];
  3096. }
  3097. }
  3098. header("Content-type: application/json");
  3099. echo json_encode($data);
  3100. exit();
  3101. }
  3102. if ($s == 'load_chat_messages') {
  3103. if (!empty($_GET['recipient_id']) && is_numeric($_GET['recipient_id']) && $_GET['recipient_id'] > 0) {
  3104. $recipient_id = Wo_Secure($_GET['recipient_id']);
  3105. $html = '';
  3106. $messages = Wo_GetMessages(array(
  3107. 'user_id' => $recipient_id
  3108. ));
  3109. foreach ($messages as $wo['chatMessage']) {
  3110. $html .= Wo_LoadPage('chat/chat-list');
  3111. }
  3112. $data = array(
  3113. 'status' => 200,
  3114. 'messages' => $html
  3115. );
  3116. }
  3117. header("Content-type: application/json");
  3118. echo json_encode($data);
  3119. exit();
  3120. }
  3121. if ($s == 'open_tab') {
  3122. if (isset($_SESSION['open_chat'])) {
  3123. if ($_SESSION['open_chat'] == 1) {
  3124. $_SESSION['open_chat'] = 0;
  3125. } else if ($_SESSION['open_chat'] == 0) {
  3126. $_SESSION['open_chat'] = 1;
  3127. }
  3128. } else {
  3129. $_SESSION['open_chat'] = 1;
  3130. }
  3131. }
  3132. if ($s == 'send_message') {
  3133. if (!empty($_POST['user_id'])) {
  3134. $html = '';
  3135. $media = '';
  3136. $mediaFilename = '';
  3137. $mediaName = '';
  3138. if (isset($_FILES['sendMessageFile']['name'])) {
  3139. $fileInfo = array(
  3140. 'file' => $_FILES["sendMessageFile"]["tmp_name"],
  3141. 'name' => $_FILES['sendMessageFile']['name'],
  3142. 'size' => $_FILES["sendMessageFile"]["size"]
  3143. );
  3144. $media = Wo_ShareFile($fileInfo);
  3145. $mediaFilename = $media['filename'];
  3146. $mediaName = $media['name'];
  3147. }
  3148. $message_text = '';
  3149. if (!empty($_POST['textSendMessage'])) {
  3150. $message_text = $_POST['textSendMessage'];
  3151. }
  3152. $messages = Wo_RegisterMessage(array(
  3153. 'from_id' => Wo_Secure($wo['user']['user_id']),
  3154. 'to_id' => Wo_Secure($_POST['user_id']),
  3155. 'text' => Wo_Secure($message_text),
  3156. 'media' => Wo_Secure($mediaFilename),
  3157. 'mediaFileName' => Wo_Secure($mediaName),
  3158. 'time' => time()
  3159. ));
  3160. if ($messages > 0) {
  3161. $messages = Wo_GetMessages(array(
  3162. 'message_id' => $messages,
  3163. 'user_id' => $_POST['user_id']
  3164. ));
  3165. foreach ($messages as $wo['chatMessage']) {
  3166. $html .= Wo_LoadPage('chat/chat-list');
  3167. }
  3168. $data = array(
  3169. 'status' => 200,
  3170. 'html' => $html
  3171. );
  3172. }
  3173. }
  3174. header("Content-type: application/json");
  3175. echo json_encode($data);
  3176. exit();
  3177. }
  3178. if ($s == 'get_new_messages') {
  3179. if (!empty($_GET['user_id'])) {
  3180. $html = '';
  3181. $user_id = Wo_Secure($_GET['user_id']);
  3182. if (!empty($user_id)) {
  3183. $user_id = $_GET['user_id'];
  3184. $messages = Wo_GetMessages(array(
  3185. 'after_message_id' => $_GET['message_id'],
  3186. 'new' => true,
  3187. 'user_id' => $user_id
  3188. ));
  3189. if (count($messages) > 0) {
  3190. foreach ($messages as $wo['chatMessage']) {
  3191. $html .= Wo_LoadPage('chat/chat-list');
  3192. }
  3193. $data = array(
  3194. 'status' => 200,
  3195. 'html' => $html,
  3196. 'receiver' => $user_id,
  3197. 'sender' => $wo['user']['user_id']
  3198. );
  3199. }
  3200. }
  3201. }
  3202. header("Content-type: application/json");
  3203. echo json_encode($data);
  3204. exit();
  3205. }
  3206. if ($s == 'update_tab_status') {
  3207. $html = '';
  3208. if (!empty($_GET['user_id'])) {
  3209. $user_id = Wo_Secure($_GET['user_id']);
  3210. if (!empty($user_id)) {
  3211. $user_id = $_GET['user_id'];
  3212. $status = Wo_IsOnline($user_id);
  3213. if ($status === true) {
  3214. $data['status'] = 200;
  3215. } else {
  3216. $data['status'] = 300;
  3217. }
  3218. }
  3219. }
  3220. header("Content-type: application/json");
  3221. echo json_encode($data);
  3222. exit();
  3223. }
  3224. if ($s == 'close') {
  3225. if (isset($_SESSION['chat_id'])) {
  3226. unset($_SESSION['chat_id']);
  3227. }
  3228. if (!empty($_GET['recipient_id'])) {
  3229. $data = array(
  3230. 'url' => Wo_SeoLink('index.php?tab1=messages&user=' . $_GET['recipient_id'])
  3231. );
  3232. }
  3233. header("Content-type: application/json");
  3234. echo json_encode($data);
  3235. exit();
  3236. }
  3237. if ($s == 'is_chat_on') {
  3238. if (!empty($_GET['recipient_id'])) {
  3239. $data = array(
  3240. 'url' => Wo_SeoLink('index.php?tab1=messages&user=' . $_GET['recipient_id']),
  3241. 'chat' => $wo['config']['chatSystem']
  3242. );
  3243. }
  3244. header("Content-type: application/json");
  3245. echo json_encode($data);
  3246. exit();
  3247. }
  3248. }
  3249. if ($f == 'apps') {
  3250. if ($s == 'create_app') {
  3251. if (empty($_POST['app_name']) || empty($_POST['app_website_url']) || empty($_POST['app_description'])) {
  3252. $errors[] = $error_icon . $wo['lang']['please_check_details'];
  3253. }
  3254. if (!filter_var($_POST['app_website_url'], FILTER_VALIDATE_URL)) {
  3255. $errors[] = $error_icon . $wo['lang']['website_invalid_characters'];
  3256. }
  3257. if (empty($errors)) {
  3258. $re_app_data = array(
  3259. 'app_user_id' => Wo_Secure($wo['user']['user_id']),
  3260. 'app_name' => Wo_Secure($_POST['app_name']),
  3261. 'app_website_url' => Wo_Secure($_POST['app_website_url']),
  3262. 'app_description' => Wo_Secure($_POST['app_description'])
  3263. );
  3264. $app_id = Wo_RegisterApp($re_app_data);
  3265. if ($app_id != '') {
  3266. if (!empty($_FILES["app_avatar"]["name"])) {
  3267. Wo_UploadImage($_FILES["app_avatar"]["tmp_name"], $_FILES['app_avatar']['name'], 'app', $app_id);
  3268. }
  3269. $data = array(
  3270. 'status' => 200,
  3271. 'location' => Wo_SeoLink('index.php?tab1=app&app_id=' . $app_id)
  3272. );
  3273. }
  3274. }
  3275. header("Content-type: application/json");
  3276. if (isset($errors)) {
  3277. echo json_encode(array(
  3278. 'errors' => $errors
  3279. ));
  3280. } else {
  3281. echo json_encode($data);
  3282. }
  3283. exit();
  3284. }
  3285. if ($s == 'update_app') {
  3286. if (empty($_POST['app_name']) || empty($_POST['app_website_url']) || empty($_POST['app_description'])) {
  3287. $errors[] = $error_icon . $wo['lang']['please_check_details'];
  3288. }
  3289. if (!filter_var($_POST['app_website_url'], FILTER_VALIDATE_URL)) {
  3290. $errors[] = $error_icon . $wo['lang']['website_invalid_characters'];
  3291. }
  3292. if (empty($errors)) {
  3293. $app_id = $_POST['app_id'];
  3294. $re_app_data = array(
  3295. 'app_user_id' => Wo_Secure($wo['user']['user_id']),
  3296. 'app_name' => Wo_Secure($_POST['app_name']),
  3297. 'app_website_url' => Wo_Secure($_POST['app_website_url']),
  3298. 'app_description' => Wo_Secure($_POST['app_description'])
  3299. );
  3300. if (Wo_UpdateAppData($app_id, $re_app_data) === true) {
  3301. if (!empty($_FILES["app_avatar"]["name"])) {
  3302. Wo_UploadImage($_FILES["app_avatar"]["tmp_name"], $_FILES['app_avatar']['name'], 'app', $app_id);
  3303. }
  3304. $img = Wo_GetApp($app_id);
  3305. $data = array(
  3306. 'status' => 200,
  3307. 'message' => $wo['lang']['setting_updated'],
  3308. 'name' => $_POST['app_name'],
  3309. 'image' => $img['app_avatar']
  3310. );
  3311. }
  3312. }
  3313. header("Content-type: application/json");
  3314. if (isset($errors)) {
  3315. echo json_encode(array(
  3316. 'errors' => $errors
  3317. ));
  3318. } else {
  3319. echo json_encode($data);
  3320. }
  3321. exit();
  3322. }
  3323. if ($s == 'acceptPermissions') {
  3324. $acceptPermissions = Wo_AcceptPermissions($_GET['id']);
  3325. if ($acceptPermissions === true) {
  3326. $data = array(
  3327. 'status' => 200,
  3328. 'location' => $_GET['url']
  3329. );
  3330. }
  3331. header("Content-type: application/json");
  3332. echo json_encode($data);
  3333. exit();
  3334. }
  3335. }
  3336. if ($f == 'pages') {
  3337. if ($s == 'create_page') {
  3338. if (empty($_POST['page_name']) || empty($_POST['page_title'])) {
  3339. $errors[] = $error_icon . $wo['lang']['please_check_details'];
  3340. } else {
  3341. $is_exist = Wo_IsNameExist($_POST['page_name'], 0);
  3342. if (in_array(true, $is_exist)) {
  3343. $errors[] = $error_icon . $wo['lang']['page_name_exists'];
  3344. }
  3345. if (in_array($_POST['page_name'], $wo['site_pages'])) {
  3346. $errors[] = $error_icon . $wo['lang']['page_name_invalid_characters'];
  3347. }
  3348. if (strlen($_POST['page_name']) < 5 OR strlen($_POST['page_name']) > 32) {
  3349. $errors[] = $error_icon . $wo['lang']['page_name_characters_length'];
  3350. }
  3351. if (!preg_match('/^[\w]+$/', $_POST['page_name'])) {
  3352. $errors[] = $error_icon . $wo['lang']['page_name_invalid_characters'];
  3353. }
  3354. if (empty($_POST['page_category'])) {
  3355. $_POST['page_category'] = 1;
  3356. }
  3357. }
  3358. if (empty($errors)) {
  3359. $re_page_data = array(
  3360. 'page_name' => Wo_Secure($_POST['page_name']),
  3361. 'user_id' => Wo_Secure($wo['user']['user_id']),
  3362. 'page_title' => Wo_Secure($_POST['page_title']),
  3363. 'page_description' => Wo_Secure($_POST['page_description']),
  3364. 'page_category' => Wo_Secure($_POST['page_category']),
  3365. 'active' => '1'
  3366. );
  3367. $register_page = Wo_RegisterPage($re_page_data);
  3368. if ($register_page) {
  3369. $data = array(
  3370. 'status' => 200,
  3371. 'location' => Wo_SeoLink('index.php?tab1=timeline&u=' . Wo_Secure($_POST['page_name']))
  3372. );
  3373. }
  3374. }
  3375. header("Content-type: application/json");
  3376. if (isset($errors)) {
  3377. echo json_encode(array(
  3378. 'errors' => $errors
  3379. ));
  3380. } else {
  3381. echo json_encode($data);
  3382. }
  3383. exit();
  3384. }
  3385. if ($s == 'update_information_setting') {
  3386. if (!empty($_POST['page_id'])) {
  3387. $PageData = Wo_PageData($_POST['page_id']);
  3388. if (!empty($_POST['website'])) {
  3389. if (!filter_var($_POST['website'], FILTER_VALIDATE_URL)) {
  3390. $errors[] = $error_icon . $wo['lang']['website_invalid_characters'];
  3391. }
  3392. }
  3393. if (empty($errors)) {
  3394. $Update_data = array(
  3395. 'website' => $_POST['website'],
  3396. 'page_description' => $_POST['page_description'],
  3397. 'company' => $_POST['company'],
  3398. 'address' => $_POST['address'],
  3399. 'phone' => $_POST['phone']
  3400. );
  3401. if (Wo_UpdatePageData($_POST['page_id'], $Update_data)) {
  3402. $data = array(
  3403. 'status' => 200,
  3404. 'message' => $success_icon . $wo['lang']['setting_updated']
  3405. );
  3406. }
  3407. }
  3408. }
  3409. header("Content-type: application/json");
  3410. if (isset($errors)) {
  3411. echo json_encode(array(
  3412. 'errors' => $errors
  3413. ));
  3414. } else {
  3415. echo json_encode($data);
  3416. }
  3417. exit();
  3418. }
  3419. if ($s == 'update_sociallink_setting') {
  3420. if (!empty($_POST['page_id'])) {
  3421. $PageData = Wo_PageData($_POST['page_id']);
  3422. if (empty($errors)) {
  3423. $Update_data = array(
  3424. 'facebook' => $_POST['facebook'],
  3425. 'google' => $_POST['google'],
  3426. 'twitter' => $_POST['twitter'],
  3427. 'linkedin' => $_POST['linkedin'],
  3428. 'vk' => $_POST['vk']
  3429. );
  3430. if (Wo_UpdatePageData($_POST['page_id'], $Update_data)) {
  3431. $data = array(
  3432. 'status' => 200,
  3433. 'message' => $success_icon . $wo['lang']['setting_updated']
  3434. );
  3435. }
  3436. }
  3437. }
  3438. header("Content-type: application/json");
  3439. echo json_encode($data);
  3440. exit();
  3441. }
  3442. if ($s == 'update_images_setting') {
  3443. if (isset($_POST['page_id'])) {
  3444. $Userdata = Wo_PageData($_POST['page_id']);
  3445. if (!empty($Userdata['page_id'])) {
  3446. if (isset($_FILES['avatar']['name'])) {
  3447. if (Wo_UploadImage($_FILES["avatar"]["tmp_name"], $_FILES['avatar']['name'], 'avatar', $_POST['page_id'], 'page') === true) {
  3448. $page_data = Wo_PageData($_POST['page_id']);
  3449. }
  3450. }
  3451. if (isset($_FILES['cover']['name'])) {
  3452. if (Wo_UploadImage($_FILES["cover"]["tmp_name"], $_FILES['cover']['name'], 'cover', $_POST['page_id'], 'page') === true) {
  3453. $page_data = Wo_PageData($_POST['page_id']);
  3454. }
  3455. }
  3456. if (empty($errors)) {
  3457. $Update_data = array(
  3458. 'active' => '1'
  3459. );
  3460. if (Wo_UpdatePageData($_POST['page_id'], $Update_data)) {
  3461. $userdata2 = Wo_PageData($_POST['page_id']);
  3462. $data = array(
  3463. 'status' => 200,
  3464. 'message' => $success_icon . $wo['lang']['setting_updated'],
  3465. 'cover' => $userdata2['cover'],
  3466. 'avatar' => $userdata2['avatar']
  3467. );
  3468. }
  3469. }
  3470. }
  3471. }
  3472. header("Content-type: application/json");
  3473. if (isset($errors)) {
  3474. echo json_encode(array(
  3475. 'errors' => $errors
  3476. ));
  3477. } else {
  3478. echo json_encode($data);
  3479. }
  3480. }
  3481. if ($s == 'update_general_settings') {
  3482. if (!empty($_POST['page_id'])) {
  3483. $PageData = Wo_PageData($_POST['page_id']);
  3484. if (empty($_POST['page_name']) OR empty($_POST['page_category']) OR empty($_POST['page_title'])) {
  3485. $errors[] = $error_icon . $wo['lang']['please_check_details'];
  3486. } else {
  3487. if ($_POST['page_name'] != $PageData['page_name']) {
  3488. $is_exist = Wo_IsNameExist($_POST['page_name'], 0);
  3489. if (in_array(true, $is_exist)) {
  3490. $errors[] = $error_icon . $wo['lang']['page_name_exists'];
  3491. }
  3492. }
  3493. if (in_array($_POST['page_name'], $wo['site_pages'])) {
  3494. $errors[] = $error_icon . $wo['lang']['page_name_invalid_characters'];
  3495. }
  3496. if (strlen($_POST['page_name']) < 5 || strlen($_POST['page_name']) > 32) {
  3497. $errors[] = $error_icon . $wo['lang']['page_name_characters_length'];
  3498. }
  3499. if (!preg_match('/^[\w]+$/', $_POST['page_name'])) {
  3500. $errors[] = $error_icon . $wo['lang']['page_name_invalid_characters'];
  3501. }
  3502. if (empty($_POST['page_category'])) {
  3503. $_POST['page_category'] = 1;
  3504. }
  3505. $call_action_type = 0;
  3506. if (!empty($_POST['call_action_type'])) {
  3507. if (array_key_exists($_POST['call_action_type'], $wo['call_action'])) {
  3508. $call_action_type = $_POST['call_action_type'];
  3509. }
  3510. }
  3511. if (!empty($_POST['call_action_type_url'])) {
  3512. if (!filter_var($_POST['call_action_type_url'], FILTER_VALIDATE_URL)) {
  3513. $errors[] = $error_icon . $wo['lang']['call_action_type_url_invalid'];
  3514. }
  3515. }
  3516. if (empty($errors)) {
  3517. $Update_data = array(
  3518. 'page_name' => $_POST['page_name'],
  3519. 'page_title' => $_POST['page_title'],
  3520. 'page_category' => $_POST['page_category'],
  3521. 'call_action_type' => $call_action_type,
  3522. 'call_action_type_url' => $_POST['call_action_type_url']
  3523. );
  3524. $array = array(
  3525. 'verified' => 1,
  3526. 'notVerified' => 0
  3527. );
  3528. if (!empty($_POST['verified'])) {
  3529. if (array_key_exists($_POST['verified'], $array)) {
  3530. $Update_data['verified'] = $array[$_POST['verified']];
  3531. }
  3532. }
  3533. if (Wo_UpdatePageData($_POST['page_id'], $Update_data)) {
  3534. $data = array(
  3535. 'status' => 200,
  3536. 'message' => $success_icon . $wo['lang']['setting_updated']
  3537. );
  3538. }
  3539. }
  3540. }
  3541. }
  3542. header("Content-type: application/json");
  3543. if (isset($errors)) {
  3544. echo json_encode(array(
  3545. 'errors' => $errors
  3546. ));
  3547. } else {
  3548. echo json_encode($data);
  3549. }
  3550. exit();
  3551. }
  3552. if ($s == 'delete_page') {
  3553. if (!empty($_POST['page_id'])) {
  3554. if (md5($_POST['password']) != $wo['user']['password']) {
  3555. $errors[] = $error_icon . $wo['lang']['current_password_mismatch'];
  3556. }
  3557. if (empty($errors)) {
  3558. if (Wo_DeletePage($_POST['page_id']) === true) {
  3559. $data = array(
  3560. 'status' => 200,
  3561. 'message' => $success_icon . $wo['lang']['page_deleted'],
  3562. 'location' => Wo_SeoLink('index.php?tab1=pages')
  3563. );
  3564. }
  3565. }
  3566. }
  3567. header("Content-type: application/json");
  3568. if (isset($errors)) {
  3569. echo json_encode(array(
  3570. 'errors' => $errors
  3571. ));
  3572. } else {
  3573. echo json_encode($data);
  3574. }
  3575. exit();
  3576. }
  3577. if ($s == 'get_more_likes') {
  3578. $html = '';
  3579. if (isset($_GET['user_id']) && isset($_GET['after_last_id'])) {
  3580. foreach (Wo_GetLikes($_GET['user_id'], 'profile', 10, $_GET['after_last_id']) as $wo['PageList']) {
  3581. $html .= Wo_LoadPage('timeline/likes-list');
  3582. }
  3583. }
  3584. $data = array(
  3585. 'status' => 200,
  3586. 'html' => $html
  3587. );
  3588. header("Content-type: application/json");
  3589. echo json_encode($data);
  3590. exit();
  3591. }
  3592. if ($s == 'get_next_page') {
  3593. $html = '';
  3594. $page_id = (!empty($_GET['page_id'])) ? $_GET['page_id'] : 0;
  3595. foreach (Wo_PageSug(1, $page_id) as $wo['PageList']) {
  3596. $wo['PageList']['user_name'] = $wo['PageList']['name'];
  3597. $html = Wo_LoadPage('sidebar/sidebar-home-page-list');
  3598. }
  3599. $data = array(
  3600. 'status' => 200,
  3601. 'html' => $html
  3602. );
  3603. header("Content-type: application/json");
  3604. echo json_encode($data);
  3605. exit();
  3606. }
  3607. if ($s == 'get_likes') {
  3608. $html = '';
  3609. if (!empty($_GET['user_id'])) {
  3610. foreach (Wo_GetLikes($_GET['user_id'], 'sidebar', 12) as $wo['PageList']) {
  3611. $wo['PageList']['user_name'] = @substr($wo['PageList']['name'], 0, 10);
  3612. $html .= Wo_LoadPage('sidebar/sidebar-page-list');
  3613. }
  3614. $data = array(
  3615. 'status' => 200,
  3616. 'html' => $html
  3617. );
  3618. }
  3619. header("Content-type: application/json");
  3620. echo json_encode($data);
  3621. exit();
  3622. }
  3623. }
  3624. if ($f == 'like_page') {
  3625. if (!empty($_GET['page_id'])) {
  3626. if (Wo_IsPageLiked($_GET['page_id'], $wo['user']['user_id']) === true) {
  3627. if (Wo_DeletePageLike($_GET['page_id'], $wo['user']['user_id'])) {
  3628. $data = array(
  3629. 'status' => 200,
  3630. 'html' => Wo_GetLikeButton($_GET['page_id'])
  3631. );
  3632. }
  3633. } else {
  3634. if (Wo_RegisterPageLike($_GET['page_id'], $wo['user']['user_id'])) {
  3635. $data = array(
  3636. 'status' => 200,
  3637. 'html' => Wo_GetLikeButton($_GET['page_id'])
  3638. );
  3639. }
  3640. }
  3641. }
  3642. header("Content-type: application/json");
  3643. echo json_encode($data);
  3644. exit();
  3645. }
  3646. if ($f == 'check_pagename') {
  3647. if (isset($_GET['pagename'])) {
  3648. $pagename = Wo_Secure($_GET['pagename']);
  3649. $page_data = Wo_PageData(Wo_PageIdFromPagename($_GET['pagename']));
  3650. if ($pagename == $page_data['page_name']) {
  3651. $data['status'] = 200;
  3652. $data['message'] = $wo['lang']['available'];
  3653. } else if (strlen($pagename) < 5) {
  3654. $data['status'] = 400;
  3655. $data['message'] = $wo['lang']['too_short'];
  3656. } else if (strlen($pagename) > 32) {
  3657. $data['status'] = 500;
  3658. $data['message'] = $wo['lang']['too_long'];
  3659. } else if (!preg_match('/^[\w]+$/', $_GET['pagename'])) {
  3660. $data['status'] = 600;
  3661. $data['message'] = $wo['lang']['username_invalid_characters_2'];
  3662. } else {
  3663. $is_exist = Wo_IsNameExist($_GET['pagename'], 0);
  3664. if (in_array(true, $is_exist)) {
  3665. $data['status'] = 300;
  3666. $data['message'] = $wo['lang']['in_use'];
  3667. } else {
  3668. $data['status'] = 200;
  3669. $data['message'] = $wo['lang']['available'];
  3670. }
  3671. }
  3672. }
  3673. header("Content-type: application/json");
  3674. echo json_encode($data);
  3675. exit();
  3676. }
  3677. if ($f == 'check_groupname') {
  3678. if (isset($_GET['groupname'])) {
  3679. $group_name = Wo_Secure($_GET['groupname']);
  3680. $group_data = Wo_GroupData(Wo_GroupIdFromGroupname($_GET['groupname']));
  3681. if ($group_name == $group_data['group_name']) {
  3682. $data['status'] = 200;
  3683. $data['message'] = $wo['lang']['available'];
  3684. } else if (strlen($group_name) < 5) {
  3685. $data['status'] = 400;
  3686. $data['message'] = $wo['lang']['too_short'];
  3687. } else if (strlen($group_name) > 32) {
  3688. $data['status'] = 500;
  3689. $data['message'] = $wo['lang']['too_long'];
  3690. } else if (!preg_match('/^[\w]+$/', $_GET['groupname'])) {
  3691. $data['status'] = 600;
  3692. $data['message'] = $wo['lang']['username_invalid_characters_2'];
  3693. } else {
  3694. $is_exist = Wo_IsNameExist($_GET['groupname'], 0);
  3695. if (in_array(true, $is_exist)) {
  3696. $data['status'] = 300;
  3697. $data['message'] = $wo['lang']['in_use'];
  3698. } else {
  3699. $data['status'] = 200;
  3700. $data['message'] = $wo['lang']['available'];
  3701. }
  3702. }
  3703. }
  3704. header("Content-type: application/json");
  3705. echo json_encode($data);
  3706. exit();
  3707. }
  3708. if ($f == 'update_page_cover_picture') {
  3709. if (isset($_FILES['cover']['name']) && !empty($_POST['page_id'])) {
  3710. if (Wo_UploadImage($_FILES["cover"]["tmp_name"], $_FILES['cover']['name'], 'cover', $_POST['page_id'], 'page')) {
  3711. $img = Wo_PageData($_POST['page_id']);
  3712. $data = array(
  3713. 'status' => 200,
  3714. 'img' => $img['cover']
  3715. );
  3716. }
  3717. }
  3718. header("Content-type: application/json");
  3719. echo json_encode($data);
  3720. exit();
  3721. }
  3722. if ($f == 'update_page_avatar_picture') {
  3723. if (isset($_FILES['avatar']['name']) && !empty($_POST['page_id'])) {
  3724. if (Wo_UploadImage($_FILES["avatar"]["tmp_name"], $_FILES['avatar']['name'], 'avatar', $_POST['page_id'], 'page')) {
  3725. $img = Wo_PageData($_POST['page_id']);
  3726. $data = array(
  3727. 'status' => 200,
  3728. 'img' => $img['avatar']
  3729. );
  3730. }
  3731. }
  3732. header("Content-type: application/json");
  3733. echo json_encode($data);
  3734. exit();
  3735. }
  3736. if ($f == 'update_group_cover_picture') {
  3737. if (isset($_FILES['cover']['name']) && !empty($_POST['group_id'])) {
  3738. if (Wo_UploadImage($_FILES["cover"]["tmp_name"], $_FILES['cover']['name'], 'cover', $_POST['group_id'], 'group')) {
  3739. $img = Wo_GroupData($_POST['group_id']);
  3740. $data = array(
  3741. 'status' => 200,
  3742. 'img' => $img['cover']
  3743. );
  3744. }
  3745. }
  3746. header("Content-type: application/json");
  3747. echo json_encode($data);
  3748. exit();
  3749. }
  3750. if ($f == 'update_group_avatar_picture') {
  3751. if (isset($_FILES['avatar']['name']) && !empty($_POST['group_id'])) {
  3752. if (Wo_UploadImage($_FILES["avatar"]["tmp_name"], $_FILES['avatar']['name'], 'avatar', $_POST['group_id'], 'group')) {
  3753. $img = Wo_GroupData($_POST['group_id']);
  3754. $data = array(
  3755. 'status' => 200,
  3756. 'img' => $img['avatar']
  3757. );
  3758. }
  3759. }
  3760. header("Content-type: application/json");
  3761. echo json_encode($data);
  3762. exit();
  3763. }
  3764. if ($f == 'join_group') {
  3765. if (isset($_GET['group_id'])) {
  3766. if (Wo_IsGroupJoined($_GET['group_id']) === true || Wo_IsJoinRequested($_GET['group_id'], $wo['user']['user_id']) === true) {
  3767. if (Wo_LeaveGroup($_GET['group_id'], $wo['user']['user_id'])) {
  3768. $data = array(
  3769. 'status' => 200,
  3770. 'html' => Wo_GetJoinButton($_GET['group_id'])
  3771. );
  3772. }
  3773. } else {
  3774. if (Wo_RegisterGroupJoin($_GET['group_id'], $wo['user']['user_id'])) {
  3775. $data = array(
  3776. 'status' => 200,
  3777. 'html' => Wo_GetJoinButton($_GET['group_id'])
  3778. );
  3779. }
  3780. }
  3781. }
  3782. header("Content-type: application/json");
  3783. echo json_encode($data);
  3784. exit();
  3785. }
  3786. if ($f == 'request_verification') {
  3787. if (!empty($_GET['id']) && !empty($_GET['type'])) {
  3788. if (Wo_RequestVerification($_GET['id'], $_GET['type']) === true) {
  3789. $data = array(
  3790. 'status' => 200,
  3791. 'html' => Wo_GetVerificationButton($_GET['id'], $_GET['type'])
  3792. );
  3793. }
  3794. }
  3795. header("Content-type: application/json");
  3796. echo json_encode($data);
  3797. exit();
  3798. }
  3799. if ($f == 'delete_verification') {
  3800. if (!empty($_GET['id']) && !empty($_GET['type'])) {
  3801. if (Wo_DeleteVerification($_GET['id'], $_GET['type']) === true) {
  3802. $data = array(
  3803. 'status' => 200,
  3804. 'html' => Wo_GetVerificationButton($_GET['id'], $_GET['type'])
  3805. );
  3806. }
  3807. }
  3808. header("Content-type: application/json");
  3809. echo json_encode($data);
  3810. exit();
  3811. }
  3812. if ($f == 'remove_verification') {
  3813. if (!empty($_GET['id']) && !empty($_GET['type'])) {
  3814. if (Wo_RemoveVerificationRequest($_GET['id'], $_GET['type']) === true) {
  3815. $data = array(
  3816. 'status' => 200,
  3817. 'html' => Wo_GetVerificationButton($_GET['id'], $_GET['type'])
  3818. );
  3819. }
  3820. }
  3821. header("Content-type: application/json");
  3822. echo json_encode($data);
  3823. exit();
  3824. }
  3825. if ($f == 'popover') {
  3826. $html = '';
  3827. $array_types = array(
  3828. 'user',
  3829. 'page',
  3830. 'group'
  3831. );
  3832. if (!empty($_GET['id']) && !empty($_GET['type']) && in_array($_GET['type'], $array_types)) {
  3833. if ($_GET['type'] == 'page') {
  3834. $wo['popover'] = Wo_PageData($_GET['id']);
  3835. if (!empty($wo['popover'])) {
  3836. $html = Wo_LoadPage('popover/page-content');
  3837. }
  3838. } else if ($_GET['type'] == 'user') {
  3839.  
  3840.  
  3841. } else if ($_GET['type'] == 'group') {
  3842. $wo['popover'] = Wo_GroupData($_GET['id']);
  3843. if (!empty($wo['popover'])) {
  3844. $html = Wo_LoadPage('popover/group-content');
  3845. }
  3846. }
  3847. }
  3848. $data = array(
  3849. 'status' => 200,
  3850. 'html' => $html
  3851. );
  3852. header("Content-type: application/json");
  3853. echo json_encode($data);
  3854. exit();
  3855. }
  3856. if ($f == 'open_lightbox') {
  3857. $html = '';
  3858. if (!empty($_GET['post_id'])) {
  3859. $wo['story'] = Wo_PostData($_GET['post_id']);
  3860. if (!empty($wo['story'])) {
  3861. $html = Wo_LoadPage('lightbox/content');
  3862. }
  3863. }
  3864. $data = array(
  3865. 'status' => 200,
  3866. 'html' => $html
  3867. );
  3868. header("Content-type: application/json");
  3869. echo json_encode($data);
  3870. exit();
  3871. }
  3872. if ($f == 'open_album_lightbox') {
  3873. $html = '';
  3874. if (!empty($_GET['image_id'])) {
  3875. $data_image = array(
  3876. 'id' => $_GET['image_id']
  3877. );
  3878. $wo['image'] = Wo_AlbumImageData($data_image);
  3879. if (!empty($wo['image'])) {
  3880. $html = Wo_LoadPage('lightbox/album-content');
  3881. }
  3882. }
  3883. $data = array(
  3884. 'status' => 200,
  3885. 'html' => $html
  3886. );
  3887. header("Content-type: application/json");
  3888. echo json_encode($data);
  3889. exit();
  3890. }
  3891. if ($f == 'get_next_album_image') {
  3892. $html = '';
  3893. if (!empty($_GET['after_image_id'])) {
  3894. $data_image = array(
  3895. 'post_id' => $_GET['post_id'],
  3896. 'after_image_id' => $_GET['after_image_id']
  3897. );
  3898. $wo['image'] = Wo_AlbumImageData($data_image);
  3899. if (!empty($wo['image'])) {
  3900. $html = Wo_LoadPage('lightbox/album-content');
  3901. }
  3902. $data = array(
  3903. 'status' => 200,
  3904. 'html' => $html
  3905. );
  3906. }
  3907. header("Content-type: application/json");
  3908. echo json_encode($data);
  3909. exit();
  3910. }
  3911. if ($f == 'get_previous_album_image') {
  3912. $html = '';
  3913. if (!empty($_GET['before_image_id'])) {
  3914. $data_image = array(
  3915. 'post_id' => $_GET['post_id'],
  3916. 'before_image_id' => $_GET['before_image_id']
  3917. );
  3918. $wo['image'] = Wo_AlbumImageData($data_image);
  3919. if (!empty($wo['image'])) {
  3920. $html = Wo_LoadPage('lightbox/album-content');
  3921. }
  3922. $data = array(
  3923. 'status' => 200,
  3924. 'html' => $html
  3925. );
  3926. }
  3927. header("Content-type: application/json");
  3928. echo json_encode($data);
  3929. exit();
  3930. }
  3931. if ($f == 'open_multilightbox') {
  3932. $html = '';
  3933. if (!empty($_POST['url'])) {
  3934. $wo['lighbox']['url'] = $_POST['url'];
  3935. $html = Wo_LoadPage('lightbox/content-multi');
  3936. }
  3937. $data = array(
  3938. 'status' => 200,
  3939. 'html' => $html
  3940. );
  3941. header("Content-type: application/json");
  3942. echo json_encode($data);
  3943. exit();
  3944. }
  3945. if ($f == 'get_next_image') {
  3946. $html = '';
  3947. $postsData = array(
  3948. 'limit' => 1,
  3949. 'filter_by' => 'photos',
  3950. 'after_post_id' => Wo_Secure($_GET['post_id'])
  3951. );
  3952. if (!empty($_GET['type']) && !empty($_GET['id'])) {
  3953. if ($_GET['type'] == 'profile') {
  3954. $postsData['publisher_id'] = $_GET['id'];
  3955. } else if ($_GET['type'] == 'page') {
  3956. $postsData['page_id'] = $_GET['id'];
  3957. } else if ($_GET['type'] == 'group') {
  3958. $postsData['group_id'] = $_GET['id'];
  3959. }
  3960. }
  3961. foreach (Wo_GetPosts($postsData) as $wo['story']) {
  3962. $html .= Wo_LoadPage('lightbox/content');
  3963. }
  3964. $data = array(
  3965. 'status' => 200,
  3966. 'html' => $html
  3967. );
  3968. header("Content-type: application/json");
  3969. echo json_encode($data);
  3970. exit();
  3971. }
  3972. if ($f == 'get_previous_image') {
  3973. $html = '';
  3974. $postsData = array(
  3975. 'limit' => 1,
  3976. 'filter_by' => 'photos',
  3977. 'order' => 'ASC',
  3978. 'before_post_id' => Wo_Secure($_GET['post_id'])
  3979. );
  3980. if (!empty($_GET['type']) && !empty($_GET['id'])) {
  3981. if ($_GET['type'] == 'profile') {
  3982. $postsData['publisher_id'] = $_GET['id'];
  3983. } else if ($_GET['type'] == 'page') {
  3984. $postsData['page_id'] = $_GET['id'];
  3985. } else if ($_GET['type'] == 'group') {
  3986. $postsData['group_id'] = $_GET['id'];
  3987. }
  3988. }
  3989. foreach (Wo_GetPosts($postsData) as $wo['story']) {
  3990. $html .= Wo_LoadPage('lightbox/content');
  3991. }
  3992. $data = array(
  3993. 'status' => 200,
  3994. 'html' => $html
  3995. );
  3996. header("Content-type: application/json");
  3997. echo json_encode($data);
  3998. exit();
  3999. }
  4000. if ($f == 'groups') {
  4001. if ($s == 'create_group') {
  4002. if (empty($_POST['group_name']) || empty($_POST['group_title'])) {
  4003. $errors[] = $error_icon . $wo['lang']['please_check_details'];
  4004. } else {
  4005. $is_exist = Wo_IsNameExist($_POST['group_name'], 0);
  4006. if (in_array(true, $is_exist)) {
  4007. $errors[] = $error_icon . $wo['lang']['group_name_exists'];
  4008. }
  4009. if (in_array($_POST['group_name'], $wo['site_pages'])) {
  4010. $errors[] = $error_icon . $wo['lang']['group_name_invalid_characters'];
  4011. }
  4012. if (strlen($_POST['group_name']) < 5 OR strlen($_POST['group_name']) > 32) {
  4013. $errors[] = $error_icon . $wo['lang']['group_name_characters_length'];
  4014. }
  4015. if (!preg_match('/^[\w]+$/', $_POST['group_name'])) {
  4016. $errors[] = $error_icon . $wo['lang']['group_name_invalid_characters'];
  4017. }
  4018. if (empty($_POST['category'])) {
  4019. $_POST['category'] = 1;
  4020. }
  4021. }
  4022. if (empty($errors)) {
  4023. $re_group_data = array(
  4024. 'group_name' => Wo_Secure($_POST['group_name']),
  4025. 'user_id' => Wo_Secure($wo['user']['user_id']),
  4026. 'group_title' => Wo_Secure($_POST['group_title']),
  4027. 'about' => Wo_Secure($_POST['about']),
  4028. 'category' => Wo_Secure($_POST['category']),
  4029. 'active' => '1'
  4030. );
  4031. $register_group = Wo_RegisterGroup($re_group_data);
  4032. if ($register_group) {
  4033. $data = array(
  4034. 'status' => 200,
  4035. 'location' => Wo_SeoLink('index.php?tab1=timeline&u=' . Wo_Secure($_POST['group_name']))
  4036. );
  4037. }
  4038. }
  4039. header("Content-type: application/json");
  4040. if (isset($errors)) {
  4041. echo json_encode(array(
  4042. 'errors' => $errors
  4043. ));
  4044. } else {
  4045. echo json_encode($data);
  4046. }
  4047. exit();
  4048. }
  4049. if ($s == 'update_information_setting') {
  4050. if (!empty($_POST['page_id'])) {
  4051. $PageData = Wo_PageData($_POST['page_id']);
  4052. if (!empty($_POST['website'])) {
  4053. if (!filter_var($_POST['website'], FILTER_VALIDATE_URL)) {
  4054. $errors[] = $error_icon . $wo['lang']['website_invalid_characters'];
  4055. }
  4056. }
  4057. if (empty($errors)) {
  4058. $Update_data = array(
  4059. 'website' => $_POST['website'],
  4060. 'page_description' => $_POST['page_description'],
  4061. 'company' => $_POST['company'],
  4062. 'address' => $_POST['address'],
  4063. 'phone' => $_POST['phone']
  4064. );
  4065. if (Wo_UpdatePageData($_POST['page_id'], $Update_data)) {
  4066. $data = array(
  4067. 'status' => 200,
  4068. 'message' => $success_icon . $wo['lang']['setting_updated']
  4069. );
  4070. }
  4071. }
  4072. }
  4073. header("Content-type: application/json");
  4074. if (isset($errors)) {
  4075. echo json_encode(array(
  4076. 'errors' => $errors
  4077. ));
  4078. } else {
  4079. echo json_encode($data);
  4080. }
  4081. exit();
  4082. }
  4083. if ($s == 'update_privacy_setting') {
  4084. if (!empty($_POST['group_id'])) {
  4085. $PageData = Wo_PageData($_POST['group_id']);
  4086. $privacy = 1;
  4087. $join_privacy = 1;
  4088. $array = array(
  4089. 1,
  4090. 2
  4091. );
  4092. if (!empty($_POST['privacy'])) {
  4093. if (in_array($_POST['privacy'], $array)) {
  4094. $privacy = $_POST['privacy'];
  4095. }
  4096. }
  4097. if (!empty($_POST['join_privacy'])) {
  4098. if (in_array($_POST['join_privacy'], $array)) {
  4099. $join_privacy = $_POST['join_privacy'];
  4100. }
  4101. }
  4102. if (empty($errors)) {
  4103. $Update_data = array(
  4104. 'privacy' => $privacy,
  4105. 'join_privacy' => $join_privacy
  4106. );
  4107. if (Wo_UpdateGroupData($_POST['group_id'], $Update_data)) {
  4108. $data = array(
  4109. 'status' => 200,
  4110. 'message' => $success_icon . $wo['lang']['setting_updated']
  4111. );
  4112. }
  4113. }
  4114. }
  4115. header("Content-type: application/json");
  4116. echo json_encode($data);
  4117. exit();
  4118. }
  4119. if ($s == 'update_images_setting') {
  4120. if (isset($_POST['group_id'])) {
  4121. $Userdata = Wo_GroupData($_POST['group_id']);
  4122. if (!empty($Userdata['id'])) {
  4123. if (!empty($_FILES['avatar']['name'])) {
  4124. if (Wo_UploadImage($_FILES["avatar"]["tmp_name"], $_FILES['avatar']['name'], 'avatar', $_POST['group_id'], 'group') === true) {
  4125. $page_data = Wo_GroupData($_POST['group_id']);
  4126. }
  4127. }
  4128. if (!empty($_FILES['cover']['name'])) {
  4129. if (Wo_UploadImage($_FILES["cover"]["tmp_name"], $_FILES['cover']['name'], 'cover', $_POST['group_id'], 'group') === true) {
  4130. $page_data = Wo_GroupData($_POST['group_id']);
  4131. }
  4132. }
  4133. if (empty($errors)) {
  4134. $Update_data = array(
  4135. 'active' => '1'
  4136. );
  4137. if (Wo_UpdateGroupData($_POST['group_id'], $Update_data)) {
  4138. $userdata2 = Wo_GroupData($_POST['group_id']);
  4139. $data = array(
  4140. 'status' => 200,
  4141. 'message' => $success_icon . $wo['lang']['setting_updated'],
  4142. 'cover' => $userdata2['cover'],
  4143. 'avatar' => $userdata2['avatar']
  4144. );
  4145. }
  4146. }
  4147. }
  4148. }
  4149. header("Content-type: application/json");
  4150. if (isset($errors)) {
  4151. echo json_encode(array(
  4152. 'errors' => $errors
  4153. ));
  4154. } else {
  4155. echo json_encode($data);
  4156. }
  4157. }
  4158. if ($s == 'update_general_settings') {
  4159. if (!empty($_POST['group_id'])) {
  4160. $group_data = Wo_GroupData($_POST['group_id']);
  4161. if (empty($_POST['group_name']) OR empty($_POST['group_category']) OR empty($_POST['group_title'])) {
  4162. $errors[] = $error_icon . $wo['lang']['please_check_details'];
  4163. } else {
  4164. if ($_POST['group_name'] != $group_data['group_name']) {
  4165. $is_exist = Wo_IsNameExist($_POST['group_name'], 0);
  4166. if (in_array(true, $is_exist)) {
  4167. $errors[] = $error_icon . $wo['lang']['group_name_exists'];
  4168. }
  4169. }
  4170. if (in_array($_POST['group_name'], $wo['site_pages'])) {
  4171. $errors[] = $error_icon . $wo['lang']['group_name_invalid_characters'];
  4172. }
  4173. if (strlen($_POST['group_name']) < 5 || strlen($_POST['group_name']) > 32) {
  4174. $errors[] = $error_icon . $wo['lang']['group_name_characters_length'];
  4175. }
  4176. if (!preg_match('/^[\w]+$/', $_POST['group_name'])) {
  4177. $errors[] = $error_icon . $wo['lang']['group_name_invalid_characters'];
  4178. }
  4179. if (empty($_POST['group_category'])) {
  4180. $_POST['group_category'] = 1;
  4181. }
  4182. if (empty($errors)) {
  4183. $Update_data = array(
  4184. 'group_name' => $_POST['group_name'],
  4185. 'group_title' => $_POST['group_title'],
  4186. 'category' => $_POST['group_category'],
  4187. 'about' => $_POST['about']
  4188. );
  4189. if (Wo_UpdateGroupData($_POST['group_id'], $Update_data)) {
  4190. $data = array(
  4191. 'status' => 200,
  4192. 'message' => $success_icon . $wo['lang']['setting_updated']
  4193. );
  4194. }
  4195. }
  4196. }
  4197. }
  4198. header("Content-type: application/json");
  4199. if (isset($errors)) {
  4200. echo json_encode(array(
  4201. 'errors' => $errors
  4202. ));
  4203. } else {
  4204. echo json_encode($data);
  4205. }
  4206. exit();
  4207. }
  4208. if ($s == 'delete_group') {
  4209. if (!empty($_POST['group_id'])) {
  4210. if (md5($_POST['password']) != $wo['user']['password']) {
  4211. $errors[] = $error_icon . $wo['lang']['current_password_mismatch'];
  4212. }
  4213. if (empty($errors)) {
  4214. if (Wo_DeleteGroup($_POST['group_id']) === true) {
  4215. $data = array(
  4216. 'status' => 200,
  4217. 'message' => $success_icon . $wo['lang']['group_deleted'],
  4218. 'location' => Wo_SeoLink('index.php?tab1=groups')
  4219. );
  4220. }
  4221. }
  4222. }
  4223. header("Content-type: application/json");
  4224. if (isset($errors)) {
  4225. echo json_encode(array(
  4226. 'errors' => $errors
  4227. ));
  4228. } else {
  4229. echo json_encode($data);
  4230. }
  4231. exit();
  4232. }
  4233. if ($s == 'accept_request') {
  4234. if (isset($_GET['user_id']) && !empty($_GET['group_id'])) {
  4235. if (Wo_AcceptJoinRequest($_GET['user_id'], $_GET['group_id']) === true) {
  4236. $data = array(
  4237. 'status' => 200
  4238. );
  4239. }
  4240. }
  4241. header("Content-type: application/json");
  4242. echo json_encode($data);
  4243. exit();
  4244. }
  4245. if ($s == 'delete_request') {
  4246. if (isset($_GET['user_id']) && !empty($_GET['group_id'])) {
  4247. if (Wo_DeleteJoinRequest($_GET['user_id'], $_GET['group_id']) === true) {
  4248. $data = array(
  4249. 'status' => 200
  4250. );
  4251. }
  4252. }
  4253. header("Content-type: application/json");
  4254. echo json_encode($data);
  4255. exit();
  4256. }
  4257. if ($s == 'delete_joined_user') {
  4258. if (isset($_GET['user_id']) && !empty($_GET['group_id'])) {
  4259. if (Wo_LeaveGroup($_GET['group_id'], $_GET['user_id']) === true) {
  4260. $data = array(
  4261. 'status' => 200
  4262. );
  4263. }
  4264. }
  4265. header("Content-type: application/json");
  4266. echo json_encode($data);
  4267. exit();
  4268. }
  4269. }
  4270. if ($f == 'get_user_profile_image_post') {
  4271. if (!empty($_POST['image'])) {
  4272. $getUserImage = Wo_GetUserProfilePicture(Wo_Secure($_POST['image']));
  4273. if (!empty($getUserImage)) {
  4274. $data = array(
  4275. 'status' => 200,
  4276. 'post_id' => $getUserImage
  4277. );
  4278. }
  4279. }
  4280. header("Content-type: application/json");
  4281. echo json_encode($data);
  4282. exit();
  4283. }
  4284. if ($f == 'get_user_profile_cover_image_post') {
  4285. if (!empty($_POST['image'])) {
  4286. $getUserImage = Wo_GetUserProfilePicture(Wo_Secure($_POST['image']));
  4287. if (!empty($getUserImage)) {
  4288. $data = array(
  4289. 'status' => 200,
  4290. 'post_id' => $getUserImage
  4291. );
  4292. }
  4293. }
  4294. header("Content-type: application/json");
  4295. echo json_encode($data);
  4296. exit();
  4297. }
  4298. if ($f == 'register_recent_search') {
  4299. $array_type = array(
  4300. 'user',
  4301. 'page',
  4302. 'group'
  4303. );
  4304. if (!empty($_GET['id']) && !empty($_GET['type'])) {
  4305. if (in_array($_GET['type'], $array_type)) {
  4306. if ($_GET['type'] == 'user') {
  4307. $regsiter_recent = Wo_RegsiterRecent($_GET['id'], $_GET['type']);
  4308. $user = Wo_UserData($regsiter_recent);
  4309. } else if ($_GET['type'] == 'page') {
  4310. $regsiter_recent = Wo_RegsiterRecent($_GET['id'], $_GET['type']);
  4311. $user = Wo_PageData($regsiter_recent);
  4312. } else if ($_GET['type'] == 'group') {
  4313. $regsiter_recent = Wo_RegsiterRecent($_GET['id'], $_GET['type']);
  4314. $user = Wo_GroupData($regsiter_recent);
  4315. }
  4316. if (!empty($user['url'])) {
  4317. $data = array(
  4318. 'status' => 200,
  4319. 'href' => $user['url']
  4320. );
  4321. }
  4322. }
  4323. }
  4324. header("Content-type: application/json");
  4325. echo json_encode($data);
  4326. exit();
  4327. }
  4328. if ($f == 'clearChat') {
  4329. $clear = Wo_ClearRecent();
  4330. if ($clear === true) {
  4331. $data = array(
  4332. 'status' => 200
  4333. );
  4334. }
  4335. header("Content-type: application/json");
  4336. echo json_encode($data);
  4337. exit();
  4338. }
  4339. if ($f == 'album') {
  4340. if ($s == 'create_album') {
  4341. if (empty($_POST['album_name'])) {
  4342. $errors[] = $error_icon . $wo['lang']['please_check_details'];
  4343. } else if (empty($_FILES['postPhotos']['name'])) {
  4344. $errors[] = $error_icon . $wo['lang']['please_check_details'];
  4345. }
  4346. if (isset($_FILES['postPhotos']['name'])) {
  4347. $allowed = array(
  4348. 'gif',
  4349. 'png',
  4350. 'jpg',
  4351. 'jpeg'
  4352. );
  4353. for ($i = 0; $i < count($_FILES['postPhotos']['name']); $i++) {
  4354. $new_string = pathinfo($_FILES['postPhotos']['name'][$i]);
  4355. if (!in_array(strtolower($new_string['extension']), $allowed)) {
  4356. $errors[] = $error_icon . $wo['lang']['please_check_details'];
  4357. }
  4358. }
  4359. }
  4360. if (empty($errors)) {
  4361. $post_data = array(
  4362. 'user_id' => Wo_Secure($wo['user']['user_id']),
  4363. 'album_name' => Wo_Secure($_POST['album_name']),
  4364. 'postPrivacy' => Wo_Secure(0),
  4365. 'time' => time()
  4366. );
  4367. if (!empty($_POST['id'])) {
  4368. if (is_numeric($_POST['id'])) {
  4369. $post_data = array(
  4370. 'album_name' => Wo_Secure($_POST['album_name'])
  4371. );
  4372. $id = Wo_UpdatePostData($_POST['id'], $post_data);
  4373. }
  4374. } else {
  4375. $id = Wo_RegisterPost($post_data);
  4376. }
  4377. if (count($_FILES['postPhotos']['name']) > 0) {
  4378. for ($i = 0; $i < count($_FILES['postPhotos']['name']); $i++) {
  4379. $fileInfo = array(
  4380. 'file' => $_FILES["postPhotos"]["tmp_name"][$i],
  4381. 'name' => $_FILES['postPhotos']['name'][$i],
  4382. 'size' => $_FILES["postPhotos"]["size"][$i],
  4383. 'types' => 'jpg,png,jpeg,gif'
  4384. );
  4385. $file = Wo_ShareFile($fileInfo, 1);
  4386. if (!empty($file)) {
  4387. $media_album = Wo_RegisterAlbumMedia($id, $file['filename']);
  4388. }
  4389. }
  4390. }
  4391. $data = array(
  4392. 'status' => 200,
  4393. 'href' => Wo_SeoLink('index.php?tab1=post&id=' . $id)
  4394. );
  4395. }
  4396. header("Content-type: application/json");
  4397. if (isset($errors)) {
  4398. echo json_encode(array(
  4399. 'errors' => $errors
  4400. ));
  4401. } else {
  4402. echo json_encode($data);
  4403. }
  4404. exit();
  4405. }
  4406. }
  4407. if ($f == 'delete_album_image') {
  4408. if (!empty($_GET['post_id']) && !empty($_GET['id'])) {
  4409. if (Wo_DeleteImageFromAlbum($_GET['post_id'], $_GET['id']) === true) {
  4410. $data = array(
  4411. 'status' => 200
  4412. );
  4413. }
  4414. }
  4415. header("Content-type: application/json");
  4416. echo json_encode($data);
  4417. exit();
  4418. }
  4419. if ($f == 'register_page_invite') {
  4420. if (!empty($_GET['user_id']) && !empty($_GET['page_id'])) {
  4421. $register_invite = Wo_RegsiterInvite($_GET['user_id'], $_GET['page_id']);
  4422. if ($register_invite === true) {
  4423. $data = array(
  4424. 'status' => 200
  4425. );
  4426. }
  4427. }
  4428. header("Content-type: application/json");
  4429. echo json_encode($data);
  4430. exit();
  4431. }
  4432. if ($f == 'register_group_add') {
  4433. if (!empty($_GET['user_id']) && !empty($_GET['group_id'])) {
  4434. $register_add = Wo_RegsiterGroupAdd($_GET['user_id'], $_GET['group_id']);
  4435. if ($register_add === true) {
  4436. $data = array(
  4437. 'status' => 200
  4438. );
  4439. }
  4440. }
  4441. header("Content-type: application/json");
  4442. echo json_encode($data);
  4443. exit();
  4444. }
  4445. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement