Advertisement
Guest User

Untitled

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