Вход Регистрация
Файл: WoWonder 1.2.1/Update Guide/v1.1/Script/requests.php
Строк: 2281
<?php
// +------------------------------------------------------------------------+
// | @author Deen Doughouz (WoWonder)
// | @author_url 1: http://www.wowonder.com
// | @author_url 2: http://codecanyon.net/user/wowondersocial
// | @author_email: deendoughouz@gmail.com   
// +------------------------------------------------------------------------+
// | WoWonder - A Social Networking Platform
// | Copyright (c) 2015 WoWonder. All rights reserved.
// +------------------------------------------------------------------------+
require 'assets/init.php';
// first request
$f '';
// secound request
$s '';
if (isset(
$_GET['f'])) {
      
$f Wo_Secure($_GET['f']);
}
if (isset(
$_GET['s'])) {
      
$s Wo_Secure($_GET['s']);
}
$data = array();
if (
$f == 'session_status') {
      if (
Wo_IsLogged() === false) {
            
$data = array(
                  
'status' => 200
            
);
      }
      
header("Content-type: application/json");
      echo 
json_encode($data);
      exit();
}
if (
$f == 'get_welcome_users') {
      
$html '';
      foreach (
Wo_WelcomeUsers() as $wo['user']) {
            
$html .= Wo_LoadPage('welcome/user-list');
      }
      
$data = array(
            
'status' => 200,
            
'html' => $html
      
);
      
header("Content-type: application/json");
      echo 
json_encode($data);
      exit();
}
if (
$f == 'contact_us') {
      if (empty(
$_POST['first_name']) || empty($_POST['last_name']) || empty($_POST['email']) || empty($_POST['message'])) {
            
$errors[] = $error_icon $wo['lang']['please_check_details'];
      } else if (!
filter_var($_POST['email'], FILTER_VALIDATE_EMAIL)) {
            
$errors[] = $error_icon $wo['lang']['email_invalid_characters'];
      }
      if (empty(
$errors)) {
            
$first_name Wo_Secure($_POST['first_name']);
            
$last_name  Wo_Secure($_POST['last_name']);
            
$email      Wo_Secure($_POST['email']);
            
$message    Wo_Secure($_POST['message']);
            
$headers    "From: {$first_name} {$last_name} <{$email}>";
            
$send_mail  = @mail($wo['config']['siteEmail'], 'Contact us new message'$message$headers);
            if (
$send_mail) {
                  
$data = array(
                        
'status' => 200,
                        
'message' => $success_icon $wo['lang']['email_sent']
                  );
            } else {
                  
$errors[] = $error_icon $wo['lang']['processing_error'];
            }
      }
      
header("Content-type: application/json");
      if (!empty(
$errors)) {
            echo 
json_encode(array(
                  
'errors' => $errors
            
));
      } else {
            echo 
json_encode($data);
      }
      exit();
}
if (
$f == 'login') {
      if (isset(
$_POST['username']) && isset($_POST['password'])) {
            
$username Wo_Secure($_POST['username']);
            
$password Wo_Secure($_POST['password']);
            
$result   Wo_Login($username$password);
            if (
$result === false) {
                  
$errors[] = $error_icon $wo['lang']['incorrect_username_or_password_label'];
            } else if (
Wo_UserInactive($_POST['username']) === true) {
                  
$errors[] = $error_icon $wo['lang']['account_disbaled_contanct_admin_label'];
            } else if (
Wo_UserActive($_POST['username']) === false) {
                  
$errors[] = $error_icon $wo['lang']['account_not_active_label'];
            }
            if (empty(
$errors)) {
                  
$_SESSION['user_id'] = Wo_UserIdFromUsername($username);
                  if (isset(
$_POST['rem'])) {
                        
setcookie('user_id'$_SESSION['user_id'], time() + 86000);
                  }
                  if (
Wo_IsLogged() === true) {
                        
//Wo_LastSeen($_SESSION['user_id'], 'first');
                  
}
                  
$data = array(
                        
'status' => 200
                  
);
                  if (!empty(
$_POST['last_url'])) {
                        
$data['location'] = $_POST['last_url'];
                  } else if (!empty(
$_POST['post_id']) && is_numeric($_POST['post_id'])) {
                        
$data['location'] = Wo_SeoLink('index.php?tab1=post&id=' $_POST['post_id']);
                  } else {
                        
$data['location'] = Wo_SeoLink('index.php?tab1=home');
                  }
            }
      }
      
header("Content-type: application/json");
      if (!empty(
$errors)) {
            echo 
json_encode(array(
                  
'errors' => $errors
            
));
      } else {
            echo 
json_encode($data);
      }
      exit();
}
if (
$f == 'register') {
      if (empty(
$_POST['email']) || empty($_POST['username']) || empty($_POST['password']) || empty($_POST['confirm_password'])) {
            
$errors[] = $error_icon $wo['lang']['please_check_details'];
      } else {
            if (
Wo_UserExists($_POST['username']) === true) {
                  
$errors[] = $error_icon $wo['lang']['username_exists'];
            }
            if (
strlen($_POST['username']) < OR strlen($_POST['username']) > 32) {
                  
$errors[] = $error_icon $wo['lang']['username_characters_length'];
            }
            if (!
preg_match('/^[w]+$/'$_POST['username'])) {
                  
$errors[] = $error_icon $wo['lang']['username_invalid_characters'];
            }
            if (
Wo_EmailExists($_POST['email']) === true) {
                  
$errors[] = $error_icon $wo['lang']['email_exists'];
            }
            if (!
filter_var($_POST['email'], FILTER_VALIDATE_EMAIL)) {
                  
$errors[] = $error_icon $wo['lang']['email_invalid_characters'];
            }
            if (
strlen($_POST['password']) < 6) {
                  
$errors[] = $error_icon $wo['lang']['password_short'];
            }
            if (
$_POST['password'] != $_POST['confirm_password']) {
                  
$errors[] = $error_icon $wo['lang']['password_mismatch'];
            }
            if (
$config['reCaptcha'] == 1) {
                  if (!isset(
$_POST['g-recaptcha-response']) || empty($_POST['g-recaptcha-response'])) {
                        
$errors[] = $error_icon $wo['lang']['reCaptcha_error'];
                  }
            }
            
$gender 'male';
            if (!empty(
$_POST['gender'])) {
                  if (
$_POST['gender'] != 'male' && $_POST['gender'] != 'female') {
                        
$gender 'male';
                  } else {
                        
$gender $_POST['gender'];
                  }
            }
      }
      if (empty(
$errors)) {
            
$activate = ($wo['config']['emailValidation'] == '1') ? '0' '1';
            
$re_data  = array(
                  
'email' => Wo_Secure($_POST['email']),
                  
'username' => Wo_Secure($_POST['username']),
                  
'password' => Wo_Secure($_POST['password']),
                  
'email_code' => Wo_Secure(md5($_POST['username'])),
                  
'src' => 'site',
                  
'gender' => Wo_Secure($gender),
                  
'lastseen' => time(),
                  
'active' => Wo_Secure($activate)
            );
            
$register Wo_RegisterUser($re_data);
            if (
$register === true) {
                  if (
$activate == 1) {
                        
$data = array(
                              
'status' => 200,
                              
'message' => $success_icon $wo['lang']['successfully_joined_label']
                        );
                        if (!empty(
$_POST['last_url'])) {
                              
$data['location'] = $_POST['last_url'];
                        } else if (!empty(
$_POST['post_id']) && is_numeric($_POST['post_id'])) {
                              
$data['location'] = Wo_SeoLink('index.php?tab1=post&id=' $_POST['post_id']);
                        } else {
                              
$data['location'] = Wo_SeoLink('index.php?tab1=home');
                        }
                        
$login Wo_Login($_POST['username'], $_POST['password']);
                        if (
$login === true) {
                              
$_SESSION['user_id'] = Wo_UserIdFromUsername($_POST['username']);
                        }
                  } else {
                        
$wo['user'] = $_POST;
                        
$body       Wo_LoadPage('emails/activate');
                        
$headers    "From: " $config['siteName'] . " <" $config['siteEmail'] . ">rn";
                        
$headers .= "Content-Type: text/html; charset=UTF-8rn";
                        @
mail($_POST['email'], $wo['lang']['account_activation'], $body$headers);
                        
$errors[] = $wo['lang']['successfully_joined_verify_label'];
                  }
            }
      }
      
header("Content-type: application/json");
      if (isset(
$errors)) {
            echo 
json_encode(array(
                  
'errors' => $errors
            
));
      } else {
            echo 
json_encode($data);
      }
      exit();
}
if (
$f == 'recover') {
      if (empty(
$_POST['recoveremail'])) {
            
$errors[] = $error_icon $wo['lang']['please_check_details'];
      } else {
            if (!
filter_var($_POST['recoveremail'], FILTER_VALIDATE_EMAIL)) {
                  
$errors[] = $error_icon $wo['lang']['email_invalid_characters'];
            } else if (
Wo_EmailExists($_POST['recoveremail']) === false) {
                  
$errors[] = $error_icon $wo['lang']['email_not_found'];
            }
      }
      if (empty(
$errors)) {
            
$user_recover_data         Wo_UserData(Wo_UserIdFromEmail($_POST['recoveremail']));
            
$subject                   $config['siteName'] . ' ' $wo['lang']['password_rest_request'];
            
$user_recover_data['link'] = Wo_SeoLink('index.php?tab1=welcome&tab2=password_reset&user_id=' $user_recover_data['user_id'] . '_' $user_recover_data['password']);
            
$wo['recover']             = $user_recover_data;
            
$body                      Wo_LoadPage('emails/recover');
            
$headers                   "From: " $config['siteName'] . " <" $config['siteEmail'] . ">rn";
            
$headers .= "Content-Type: text/html; charset=UTF-8rn";
            @
mail($_POST['recoveremail'], $subject$body$headers);
            
$data = array(
                  
'status' => 200,
                  
'message' => $success_icon $wo['lang']['email_sent']
            );
      }
      
header("Content-type: application/json");
      if (isset(
$errors)) {
            echo 
json_encode(array(
                  
'errors' => $errors
            
));
      } else {
            echo 
json_encode($data);
      }
      exit();
}
if (
$f == 'reset_password') {
      if (isset(
$_POST['id'])) {
            if (
Wo_isValidPasswordResetToken($_POST['id']) === false) {
                  
$errors[] = $error_icon $wo['lang']['invalid_token'];
            } elseif (empty(
$_POST['id'])) {
                  
$errors[] = $error_icon $wo['lang']['processing_error'];
            } elseif (empty(
$_POST['password'])) {
                  
$errors[] = $error_icon $wo['lang']['please_check_details'];
            } elseif (
strlen($_POST['password']) < 5) {
                  
$errors[] = $error_icon $wo['lang']['password_short'];
            }
            if (empty(
$errors)) {
                  
$user_id  explode("_"$_POST['id']);
                  
$password Wo_Secure($_POST['password']);
                  if (
Wo_ResetPassword($user_id[0], $password) === true) {
                        
$_SESSION['user_id'] = $user_id[0];
                  }
                  
$data = array(
                        
'status' => 200,
                        
'message' => $success_icon $wo['lang']['password_changed'],
                        
'location' => Wo_SeoLink('index.php?tab1=home')
                  );
            }
      }
      
header("Content-type: application/json");
      if (isset(
$errors)) {
            echo 
json_encode(array(
                  
'errors' => $errors
            
));
      } else {
            echo 
json_encode($data);
      }
      exit();
}
if (
$f == "search") {
      
$data = array(
            
'status' => 200,
            
'html' => ''
      
);
      if (
$s == 'recipients' AND Wo_IsLogged() === true && isset($_GET['query'])) {
            foreach (
Wo_GetMessagesUsers($wo['user']['user_id'], $_GET['query']) as $wo['recipient']) {
                  
$data['html'] .= Wo_LoadPage('messages/messages-recipients-list');
            }
      }
      if (
$s == 'normal' && isset($_GET['query'])) {
            foreach (
Wo_GetSearch($_GET['query']) as $wo['result']) {
                  
$data['html'] .= Wo_LoadPage('header/search');
            }
      }
      if (
$s == 'hash' && isset($_GET['query'])) {
            foreach (
Wo_GetSerachHash($_GET['query']) as $wo['result']) {
                  
$data['html'] .= Wo_LoadPage('header/hashtags-result');
            }
      }
      
header("Content-type: application/json");
      echo 
json_encode($data);
      exit();
}
if (
$f == "get_search_filter") {
      
$data = array(
            
'status' => 200,
            
'html' => ''
      
);
      if (isset(
$_POST)) {
            foreach (
Wo_GetSearchFilter($_POST) as $wo['result']) {
                  
$data['html'] .= Wo_LoadPage('search/result');
            }
      }
      
header("Content-type: application/json");
      echo 
json_encode($data);
      exit();
}
if (
$f == "update_announcement_views") {
      if (isset(
$_GET['id'])) {
            
$UpdateAnnouncementViews Wo_UpdateAnnouncementViews($_GET['id']);
            if (
$UpdateAnnouncementViews === true) {
                  
$data = array(
                        
'status' => 200
                  
);
            }
      }
      
header("Content-type: application/json");
      echo 
json_encode($data);
      exit();
}
if (
$f == 'get_more_hashtag_posts') {
      
$html '';
      if (isset(
$_POST['after_post_id'])) {
            
$after_post_id Wo_Secure($_POST['after_post_id']);
            foreach (
Wo_GetHashtagPosts($_POST['hashtagName'], $after_post_id20) as $wo['story']) {
                  
$html .= Wo_LoadPage('story/content');
            }
      }
      
$data = array(
            
'status' => 200,
            
'html' => $html
      
);
      
header("Content-type: application/json");
      echo 
json_encode($data);
      exit();
}
if (
Wo_IsLogged() === false) {
      exit(
"Please login or signup to continue.");
}
if (
$f == "get_more_following") {
      
$html '';
      if (isset(
$_GET['user_id']) && isset($_GET['after_last_id'])) {
            foreach (
Wo_GetFollowing($_GET['user_id'], 'profile'10$_GET['after_last_id']) as $wo['UsersList']) {
                  
$html .= Wo_LoadPage('timeline/follow-list');
            }
      }
      
$data = array(
            
'status' => 200,
            
'html' => $html
      
);
      
header("Content-type: application/json");
      echo 
json_encode($data);
      exit();
}
if (
$f == "get_more_followers") {
      
$html '';
      if (isset(
$_GET['user_id']) && isset($_GET['after_last_id'])) {
            foreach (
Wo_GetFollowers($_GET['user_id'], 'profile'10$_GET['after_last_id']) as $wo['UsersList']) {
                  
$html .= Wo_LoadPage('timeline/follow-list');
            }
      }
      
$data = array(
            
'status' => 200,
            
'html' => $html
      
);
      
header("Content-type: application/json");
      echo 
json_encode($data);
      exit();
}
if (
$f == 'check_username') {
      if (isset(
$_GET['username'])) {
            
$usename Wo_Secure($_GET['username']);
            if (
$usename == $wo['user']['username']) {
                  
$data['status']  = 200;
                  
$data['message'] = $wo['lang']['available'];
            } else if (
strlen($usename) < 5) {
                  
$data['status']  = 400;
                  
$data['message'] = $wo['lang']['too_short'];
            } else if (
strlen($usename) > 32) {
                  
$data['status']  = 500;
                  
$data['message'] = $wo['lang']['too_long'];
            } else if (!
preg_match('/^[w]+$/'$_GET['username'])) {
                  
$data['status']  = 600;
                  
$data['message'] = $wo['lang']['username_invalid_characters_2'];
            } else {
                  if (
Wo_UserExists($_GET['username']) === true) {
                        
$data['status']  = 300;
                        
$data['message'] = $wo['lang']['in_use'];
                  } else {
                        
$data['status']  = 200;
                        
$data['message'] = $wo['lang']['available'];
                  }
            }
      }
      
header("Content-type: application/json");
      echo 
json_encode($data);
      exit();
}
if (
$f == "update_general_settings") {
      if (isset(
$_POST)) {
            if (empty(
$_POST['username']) OR empty($_POST['email'])) {
                  
$errors[] = $error_icon ' Please Check the fields.';
            } else {
                  
$Userdata Wo_UserData($_POST['user_id']);
                  
$age_data '0000-00-00';
                  if (!empty(
$Userdata['user_id'])) {
                        if (
$_POST['email'] != $Userdata['email']) {
                              if (
Wo_EmailExists($_POST['email'])) {
                                    
$errors[] = $error_icon $wo['lang']['email_exists'];
                              }
                        }
                        if (
$_POST['username'] != $Userdata['username']) {
                              if (
Wo_UserExists($_POST['username'])) {
                                    
$errors[] = $error_icon $wo['lang']['username_exists'];
                              }
                        }
                        if (!
filter_var($_POST['email'], FILTER_VALIDATE_EMAIL)) {
                              
$errors[] = $error_icon $wo['lang']['email_invalid_characters'];
                        }
                        if (
strlen($_POST['username']) < || strlen($_POST['username']) > 32) {
                              
$errors[] = $error_icon $wo['lang']['username_characters_length'];
                        }
                        if (!
preg_match('/^[w]+$/'$_POST['username'])) {
                              
$errors[] = $error_icon $wo['lang']['username_invalid_characters'];
                        }
                        if (!empty(
$_POST['age_year']) || !empty($_POST['age_day']) || !empty($_POST['age_month'])) {
                              if (empty(
$_POST['age_year']) || empty($_POST['age_day']) || empty($_POST['age_month'])) {
                                    
$errors[] = $error_icon $wo['lang']['please_choose_correct_date'];
                              } else {
                                    
$age_data $_POST['age_year'] . '-' $_POST['age_month'] . '-' $_POST['age_day'];
                              }
                        }
                        if (empty(
$_POST['emailNotification'])) {
                              
$_POST['emailNotification'] = 0;
                        }
                        
$active $Userdata['active'];
                        if (!empty(
$_POST['active'])) {
                              if (
$_POST['active'] == 'active') {
                                    
$active 1;
                              } else {
                                    
$active 2;
                              }
                              if (
$active == $Userdata['active']) {
                                    
$active $Userdata['active'];
                              }
                        }
                        
$type $Userdata['admin'];
                        if (!empty(
$_POST['type'])) {
                              if (
$_POST['type'] == 'admin') {
                                    
$type 1;
                              } else {
                                    
$type 0;
                              }
                              if (
$type == $Userdata['admin']) {
                                    
$type $Userdata['admin'];
                              }
                        }
                        
$Verification $Userdata['verified'];
                        if (!empty(
$_POST['verified'])) {
                              if (
$_POST['verified'] == 'verified') {
                                    
$Verification 1;
                              } else {
                                    
$Verification 0;
                              }
                              if (
$Verification == $Userdata['verified']) {
                                    
$Verification $Userdata['verified'];
                              }
                        }
                        
$gender       'male';
                        
$gender_array = array(
                              
'male',
                              
'female'
                        
);
                        if (!empty(
$_POST['gender'])) {
                              if (
in_array($_POST['gender'], $gender_array)) {
                                    
$gender $_POST['gender'];
                              }
                        }
                        if (empty(
$errors)) {
                              
$Update_data = array(
                                    
'username' => Wo_Secure($_POST['username']),
                                    
'email' => Wo_Secure($_POST['email']),
                                    
'birthday' => Wo_Secure($age_data),
                                    
'gender' => Wo_Secure($gender),
                                    
'country_id' => Wo_Secure($_POST['country']),
                                    
'emailNotification' => Wo_Secure($_POST['emailNotification']),
                                    
'active' => Wo_Secure($active),
                                    
'admin' => Wo_Secure($type),
                                    
'verified' => Wo_Secure($Verification)
                              );
                              if (
Wo_UpdateUserData($_POST['user_id'], $Update_data)) {
                                    
$data = array(
                                          
'status' => 200,
                                          
'message' => $success_icon $wo['lang']['setting_updated'],
                                          
'username' => Wo_SeoLink('index.php?tab1=timeline&u=' Wo_Secure($_POST['username']))
                                    );
                              }
                        }
                  }
            }
      }
      
header("Content-type: application/json");
      if (isset(
$errors)) {
            echo 
json_encode(array(
                  
'errors' => $errors
            
));
      } else {
            echo 
json_encode($data);
      }
      exit();
}
if (
$f == "update_privacy_settings") {
      if (isset(
$_POST['post_privacy'])) {
            
$message_privacy         0;
            
$follow_privacy          0;
            
$post_privacy            'ifollow';
            
$showlastseen            0;
            
$confirm_followers       0;
            
$show_activities_privacy 0;
            
$status                  0;
            
$array                   = array(
                  
'0',
                  
'1'
            
);
            
$array_two               = array(
                  
'everyone',
                  
'ifollow',
                  
'nobody'
            
);
            if (!empty(
$_POST['post_privacy'])) {
                  if (
in_array($_POST['post_privacy'], $array_two)) {
                        
$post_privacy $_POST['post_privacy'];
                  }
            }
            if (!empty(
$_POST['confirm_followers'])) {
                  if (
in_array($_POST['confirm_followers'], $array)) {
                        
$confirm_followers $_POST['confirm_followers'];
                  }
            }
            if (!empty(
$_POST['follow_privacy'])) {
                  if (
in_array($_POST['follow_privacy'], $array)) {
                        
$follow_privacy $_POST['follow_privacy'];
                  }
            }
            if (!empty(
$_POST['show_activities_privacy'])) {
                  if (
in_array($_POST['show_activities_privacy'], $array)) {
                        
$show_activities_privacy $_POST['show_activities_privacy'];
                  }
            }
            if (!empty(
$_POST['showlastseen'])) {
                  if (
in_array($_POST['showlastseen'], $array)) {
                        
$showlastseen $_POST['showlastseen'];
                  }
            }
            if (!empty(
$_POST['message_privacy'])) {
                  if (
in_array($_POST['message_privacy'], $array)) {
                        
$message_privacy $_POST['message_privacy'];
                  }
            }
            if (!empty(
$_POST['status'])) {
                  if (
in_array($_POST['status'], $array)) {
                        
$status $_POST['status'];
                  }
            }
            
$Update_data = array(
                  
'message_privacy' => $message_privacy,
                  
'follow_privacy' => $follow_privacy,
                  
'post_privacy' => $post_privacy,
                  
'showlastseen' => $showlastseen,
                  
'confirm_followers' => $confirm_followers,
                  
'show_activities_privacy' => $show_activities_privacy,
                  
'status' => $status
            
);
            if (
Wo_UpdateUserData($_POST['user_id'], $Update_data)) {
                  
$data = array(
                        
'status' => 200,
                        
'message' => $success_icon $wo['lang']['setting_updated']
                  );
            }
      }
      
header("Content-type: application/json");
      echo 
json_encode($data);
      exit();
}
if (
$f == 'update_new_logged_user_details') {
      if (empty(
$_POST['new_password']) || empty($_POST['username']) || empty($_POST['repeat_new_password'])) {
            
$errors[] = $error_icon $wo['lang']['please_check_details'];
      } else {
            if (
$_POST['new_password'] != $_POST['repeat_new_password']) {
                  
$errors[] = $error_icon $wo['lang']['password_mismatch'];
            }
            if (
strlen($_POST['new_password']) < 6) {
                  
$errors[] = $error_icon $wo['lang']['password_short'];
            }
            if (
strlen($_POST['username']) > 32) {
                  
$errors[] = $error_icon $wo['lang']['username_characters_length'];
            }
            if (
strlen($_POST['username']) < 5) {
                  
$errors[] = $error_icon $wo['lang']['username_characters_length'];
            }
            if (!
preg_match('/^[w]+$/'$_POST['username'])) {
                  
$errors[] = $error_icon $wo['lang']['username_invalid_characters'];
            }
            if (
Wo_UserExists($_POST['username']) === true) {
                  
$errors[] = $error_icon $wo['lang']['username_exists'];
            }
            if (empty(
$errors)) {
                  
$Update_data = array(
                        
'password' => md5($_POST['new_password']),
                        
'username' => $_POST['username']
                  );
                  if (
Wo_UpdateUserData($_POST['user_id'], $Update_data)) {
                        
$get_user Wo_UserData($_POST['user_id']);
                        
$data     = array(
                              
'status' => 200,
                              
'message' => $success_icon $wo['lang']['setting_updated'],
                              
'url' => $get_user['url']
                        );
                  }
            }
      }
      
header("Content-type: application/json");
      if (isset(
$errors)) {
            echo 
json_encode(array(
                  
'errors' => $errors
            
));
      } else {
            echo 
json_encode($data);
      }
      exit();
}
if (
$f == "update_user_password") {
      if (isset(
$_POST['user_id'])) {
            
$Userdata Wo_UserData($_POST['user_id']);
            if (!empty(
$Userdata['user_id'])) {
                  if (
$_POST['user_id'] != $wo['user']['user_id']) {
                        
$_POST['current_password'] = 1;
                  }
                  if (empty(
$_POST['current_password']) OR empty($_POST['new_password']) OR empty($_POST['repeat_new_password'])) {
                        
$errors[] = $error_icon $wo['lang']['please_check_details'];
                  } else {
                        if (
$_POST['user_id'] == $wo['user']['user_id']) {
                              if (
md5($_POST['current_password']) != $Userdata['password']) {
                                    
$errors[] = $error_icon $wo['lang']['current_password_mismatch'];
                              }
                        }
                        if (
$_POST['new_password'] != $_POST['repeat_new_password']) {
                              
$errors[] = $error_icon $wo['lang']['password_mismatch'];
                        }
                        if (
strlen($_POST['new_password']) < 6) {
                              
$errors[] = $error_icon $wo['lang']['password_short'];
                        }
                        if (empty(
$errors)) {
                              
$Update_data = array(
                                    
'password' => md5($_POST['new_password'])
                              );
                              if (
Wo_UpdateUserData($_POST['user_id'], $Update_data)) {
                                    
$data = array(
                                          
'status' => 200,
                                          
'message' => $success_icon $wo['lang']['setting_updated']
                                    );
                              }
                        }
                  }
            }
      }
      
header("Content-type: application/json");
      if (isset(
$errors)) {
            echo 
json_encode(array(
                  
'errors' => $errors
            
));
      } else {
            echo 
json_encode($data);
      }
      exit();
}
if (
$f == "update_profile_setting") {
      if (isset(
$_POST['user_id'])) {
            
$Userdata Wo_UserData($_POST['user_id']);
            if (!empty(
$Userdata['user_id'])) {
                  if (!empty(
$_POST['website'])) {
                        if (!
filter_var($_POST['website'], FILTER_VALIDATE_URL)) {
                              
$errors[] = $error_icon $wo['lang']['website_invalid_characters'];
                        }
                  }
                  if (!empty(
$_POST['working_link'])) {
                        if (!
filter_var($_POST['working_link'], FILTER_VALIDATE_URL)) {
                              
$errors[] = $error_icon 'Company website is invalid';
                        }
                  }
                  if (isset(
$_FILES['avatar']['name'])) {
                        if (
Wo_UploadImage($_FILES["avatar"]["tmp_name"], $_FILES['avatar']['name'], 'avatar'$_POST['user_id']) === true) {
                              
$Userdata Wo_UserData($_POST['user_id']);
                        }
                  }
                  if (isset(
$_FILES['cover']['name'])) {
                        if (
Wo_UploadImage($_FILES["cover"]["tmp_name"], $_FILES['cover']['name'], 'cover'$_POST['user_id']) === true) {
                              
$Userdata Wo_UserData($_POST['user_id']);
                        }
                  }
                  
$background_image_status 0;
                  if (isset(
$_FILES['background_image']['name'])) {
                        if (
Wo_UploadImage($_FILES["background_image"]["tmp_name"], $_FILES['background_image']['name'], 'background_image'$_POST['user_id']) === true) {
                              
$background_image_status 1;
                        }
                  }
                  if (!empty(
$_POST['background_image_status'])) {
                        if (
$_POST['background_image_status'] == 'defualt') {
                              
$background_image_status 0;
                        } else if (
$_POST['background_image_status'] == 'my_background') {
                              
$background_image_status 1;
                        } else {
                              
$background_image_status 0;
                        }
                  }
                  if (!
is_numeric($_POST['relationship']) || empty($_POST['relationship']) || $_POST['relationship'] > 4) {
                        
$_POST['relationship'] = '';
                  }
                  if (empty(
$errors)) {
                        
$Update_data = array(
                              
'first_name' => $_POST['first_name'],
                              
'last_name' => $_POST['last_name'],
                              
'facebook' => $_POST['facebook'],
                              
'website' => $_POST['website'],
                              
'google' => $_POST['google'],
                              
'about' => $_POST['about'],
                              
'twitter' => $_POST['twitter'],
                              
'linkedin' => $_POST['linkedin'],
                              
'vk' => $_POST['vk'],
                              
'working' => $_POST['working'],
                              
'working_link' => $_POST['working_link'],
                              
'address' => $_POST['address'],
                              
'relationship_id' => $_POST['relationship'],
                              
'background_image_status' => $background_image_status
                        
);
                        if (
Wo_UpdateUserData($_POST['user_id'], $Update_data)) {
                              
$data = array(
                                    
'status' => 200,
                                    
'first_name' => Wo_Secure($_POST['first_name']),
                                    
'last_name' => Wo_Secure($_POST['last_name']),
                                    
'message' => $success_icon $wo['lang']['setting_updated'],
                                    
'img' => $Userdata['avatar'],
                                    
'cover' => $Userdata['cover']
                              );
                        }
                  }
            }
      }
      
header("Content-type: application/json");
      if (isset(
$errors)) {
            echo 
json_encode(array(
                  
'errors' => $errors
            
));
      } else {
            echo 
json_encode($data);
      }
      exit();
}
if (
$f == 'update_user_avatar_picture') {
      if (isset(
$_FILES['avatar']['name'])) {
            if (
Wo_UploadImage($_FILES["avatar"]["tmp_name"], $_FILES['avatar']['name'], 'avatar'$_POST['user_id']) === true) {
                  
$img  Wo_UserData($_POST['user_id']);
                  
$data = array(
                        
'status' => 200,
                        
'img' => $img['avatar']
                  );
            }
      }
      
header("Content-type: application/json");
      echo 
json_encode($data);
      exit();
}
if (
$f == 'update_user_cover_picture') {
      if (isset(
$_FILES['cover']['name'])) {
            if (
Wo_UploadImage($_FILES["cover"]["tmp_name"], $_FILES['cover']['name'], 'cover'$_POST['user_id']) === true) {
                  
$img  Wo_UserData($_POST['user_id']);
                  
$data = array(
                        
'status' => 200,
                        
'img' => $img['cover']
                  );
            }
      }
      
header("Content-type: application/json");
      echo 
json_encode($data);
      exit();
}
if (
$f == 'set_admin_alert_cookie') {
      
setcookie('profileAlert''1'time() + 86000);
}
if (
$f == 'delete_user_account') {
      if (isset(
$_POST['password'])) {
            if (
md5($_POST['password']) != $wo['user']['password']) {
                  
$errors[] = $error_icon $wo['lang']['current_password_mismatch'];
            }
            if (empty(
$errors)) {
                  if (
Wo_DeleteUser($wo['user']['user_id']) === true) {
                        
$data = array(
                              
'status' => 200,
                              
'message' => $success_icon $wo['lang']['account_deleted'],
                              
'location' => Wo_SeoLink('index.php?tab1=logout')
                        );
                  }
            }
      }
      
header("Content-type: application/json");
      if (isset(
$errors)) {
            echo 
json_encode(array(
                  
'errors' => $errors
            
));
      } else {
            echo 
json_encode($data);
      }
      exit();
}
if (
$f == 'update_sidebar_users') {
      
$html '';
      foreach (
Wo_UserSug(5) as $wo['UsersList']) {
            
$wo['UsersList']['user_name'] = $wo['UsersList']['name'];
            if (!empty(
$wo['UsersList']['last_name'])) {
                  
$wo['UsersList']['user_name'] = $wo['UsersList']['first_name'];
            }
            
$html .= Wo_LoadPage('sidebar/sidebar-user-list');
      }
      
$data = array(
            
'status' => 200,
            
'html' => $html
      
);
      
header("Content-type: application/json");
      echo 
json_encode($data);
      exit();
}
if (
$f == 'follow_user') {
      if (isset(
$_GET['following_id'])) {
            if (
Wo_IsFollowing($_GET['following_id'], $wo['user']['user_id']) === true || Wo_IsFollowRequested($_GET['following_id'], $wo['user']['user_id']) === true) {
                  if (
Wo_DeleteFollow($_GET['following_id'], $wo['user']['user_id'])) {
                        
$data = array(
                              
'status' => 200,
                              
'html' => Wo_GetFollowButton($_GET['following_id'])
                        );
                  }
            } else {
                  if (
Wo_RegisterFollow($_GET['following_id'], $wo['user']['user_id'])) {
                        
$data = array(
                              
'status' => 200,
                              
'html' => Wo_GetFollowButton($_GET['following_id'])
                        );
                  }
            }
      }
      
header("Content-type: application/json");
      echo 
json_encode($data);
      exit();
}
if (
$f == 'accept_follow_request') {
      if (isset(
$_GET['following_id'])) {
            if (
Wo_AcceptFollowRequest($_GET['following_id'], $wo['user']['user_id'])) {
                  
$data = array(
                        
'status' => 200,
                        
'html' => Wo_GetFollowButton($_GET['following_id'])
                  );
            }
      }
      
header("Content-type: application/json");
      echo 
json_encode($data);
      exit();
}
if (
$f == 'delete_follow_request') {
      if (isset(
$_GET['following_id'])) {
            if (
Wo_DeleteFollowRequest($_GET['following_id'], $wo['user']['user_id'])) {
                  
$data = array(
                        
'status' => 200,
                        
'html' => Wo_GetFollowButton($_GET['following_id'])
                  );
            }
      }
      
header("Content-type: application/json");
      echo 
json_encode($data);
      exit();
}
if (
$f == 'get_follow_requests') {
      
$data     = array(
            
'status' => 200,
            
'html' => ''
      
);
      
$requests Wo_GetFollowRequests();
      if (
count($requests) > 0) {
            foreach (
$requests as $wo['request']) {
                  
$data['html'] .= Wo_LoadPage('header/follow-requests');
            }
      } else {
            
$data['message'] = $wo['lang']['no_new_requests'];
      }
      
header("Content-type: application/json");
      echo 
json_encode($data);
      exit();
}
if (
$f == 'get_notifications') {
      
$data          = array(
            
'status' => 200,
            
'html' => ''
      
);
      
$notifications Wo_GetNotifications();
      if (
count($notifications) > 0) {
            foreach (
$notifications as $wo['notification']) {
                  
$data['html'] .= Wo_LoadPage('header/notifecation');
                  if (
$wo['notification']['seen'] == 0) {
                        
$query     "UPDATE " T_NOTIFICATION " SET `seen` = " time() . " WHERE `id` = " $wo['notification']['id'];
                        
$sql_query mysqli_query($sqlConnect$query);
                  }
            }
      } else {
            
$data['message'] = $wo['lang']['no_new_notification'];
      }
      
header("Content-type: application/json");
      echo 
json_encode($data);
      exit();
}
if (
$f == 'send_interval') {
      
$data['status']         = 200;
      
$data['notifications']  = Wo_CountNotifications(array(
            
'unread' => true
      
));
      
$data['messages']       = Wo_CountMessages(array(
            
'new' => true
      
), 'interval');
      
$data['followRequests'] = Wo_CountFollowRequests();
      
header("Content-type: application/json");
      echo 
json_encode($data);
      exit();
}
if (
$f == 'update_lastseen') {
      if (
Wo_LastSeen($wo['user']['user_id']) === true) {
            
$data = array(
                  
'status' => 200
            
);
      }
      
header("Content-type: application/json");
      echo 
json_encode($data);
      exit();
}
if (
$f == 'messages') {
      if (
$s == 'get_user_messages') {
            if (!empty(
$_GET['user_id']) AND is_numeric($_GET['user_id']) AND $_GET['user_id'] > 0) {
                  
$html       '';
                  
$user_id    $_GET['user_id'];
                  
$can_replay true;
                  
$recipient  Wo_UserData($user_id);
                  
$messages   Wo_GetMessages(array(
                        
'user_id' => $user_id
                  
));
                  if (!empty(
$recipient['user_id']) && $recipient['message_privacy'] == 1) {
                        if (
Wo_IsFollowing($wo['user']['user_id'], $recipient['user_id']) === false) {
                              
$can_replay false;
                        }
                  }
                  foreach (
$messages as $wo['message']) {
                        
$html .= Wo_LoadPage('messages/messages-text-list');
                  }
                  
$data = array(
                        
'status' => 200,
                        
'html' => $html,
                        
'can_replay' => $can_replay,
                        
'view_more_text' => $wo['lang']['view_more_messages']
                  );
            }
            
header("Content-type: application/json");
            echo 
json_encode($data);
            exit();
      }
      if (
$s == 'send_message') {
            if (isset(
$_POST['user_id'])) {
                  
$html          '';
                  
$media         '';
                  
$mediaFilename '';
                  
$mediaName     '';
                  if (isset(
$_FILES['sendMessageFile']['name'])) {
                        
$fileInfo      = array(
                              
'file' => $_FILES["sendMessageFile"]["tmp_name"],
                              
'name' => $_FILES['sendMessageFile']['name'],
                              
'size' => $_FILES["sendMessageFile"]["size"]
                        );
                        
$media         Wo_ShareFile($fileInfo);
                        
$mediaFilename $media['filename'];
                        
$mediaName     $media['name'];
                  }
                  
$messages Wo_RegisterMessage(array(
                        
'from_id' => Wo_Secure($wo['user']['user_id']),
                        
'to_id' => Wo_Secure($_POST['user_id']),
                        
'text' => Wo_Secure($_POST['textSendMessage']),
                        
'media' => Wo_Secure($mediaFilename),
                        
'mediaFileName' => Wo_Secure($mediaName),
                        
'time' => time()
                  ));
                  if (
$messages 0) {
                        
$messages Wo_GetMessages(array(
                              
'message_id' => $messages,
                              
'user_id' => $_POST['user_id']
                        ));
                        foreach (
$messages as $wo['message']) {
                              
$html .= Wo_LoadPage('messages/messages-text-list');
                        }
                        
$data = array(
                              
'status' => 200,
                              
'html' => $html
                        
);
                  }
            }
            
header("Content-type: application/json");
            echo 
json_encode($data);
            exit();
      }
      if (
$s == 'load_previous_messages') {
            
$html '';
            if (!empty(
$_GET['user_id']) && !empty($_GET['before_message_id'])) {
                  
$user_id           Wo_Secure($_GET['user_id']);
                  
$before_message_id Wo_Secure($_GET['before_message_id']);
                  
$messages          Wo_GetMessages(array(
                        
'user_id' => $user_id,
                        
'before_message_id' => $before_message_id
                  
));
                  if (
$messages 0) {
                        foreach (
$messages as $wo['message']) {
                              
$html .= Wo_LoadPage('messages/messages-text-list');
                        }
                        
$data = array(
                              
'status' => 200,
                              
'html' => $html
                        
);
                  }
            }
            
header("Content-type: application/json");
            echo 
json_encode($data);
            exit();
      }
      if (
$s == 'update_recipients') {
            
$html '';
            foreach (
Wo_GetMessagesUsers($wo['user']['user_id'], ''''''1) as $wo['recipient']) {
                  
$html .= Wo_LoadPage('messages/messages-recipients-list');
            }
            
$data = array(
                  
'status' => 200,
                  
'html' => $html
            
);
            
header("Content-type: application/json");
            echo 
json_encode($data);
            exit();
      }
      if (
$s == 'get_new_messages') {
            
$html '';
            if (isset(
$_GET['user_id'])) {
                  
$user_id Wo_Secure($_GET['user_id']);
                  if (!empty(
$user_id)) {
                        
$user_id  $_GET['user_id'];
                        
$messages Wo_GetMessages(array(
                              
'after_message_id' => $_GET['message_id'],
                              
'new' => true,
                              
'user_id' => $user_id
                        
));
                        if (
count($messages) > 0) {
                              foreach (
$messages as $wo['message']) {
                                    
$html .= Wo_LoadPage('messages/messages-text-list');
                              }
                              
$data = array(
                                    
'status' => 200,
                                    
'html' => $html,
                                    
'sender' => $wo['user']['user_id']
                              );
                        }
                  }
            }
            
header("Content-type: application/json");
            echo 
json_encode($data);
            exit();
      }
      if (
$s == 'delete_message') {
            if (isset(
$_GET['message_id'])) {
                  
$message_id Wo_Secure($_GET['message_id']);
                  if (!empty(
$message_id) || is_numeric($message_id) || $message_id 0) {
                        if (
Wo_DeleteMessage($message_id) === true) {
                              
$data = array(
                                    
'status' => 200
                              
);
                        }
                  }
            }
            
header("Content-type: application/json");
            echo 
json_encode($data);
            exit();
      }
      if (
$s == 'get_last_message_seen_status') {
            if (isset(
$_GET['last_id'])) {
                  
$message_id Wo_Secure($_GET['last_id']);
                  if (!empty(
$message_id) || is_numeric($message_id) || $message_id 0) {
                        
$seen Wo_SeenMessage($message_id);
                        if (
$seen 0) {
                              
$data = array(
                                    
'status' => 200,
                                    
'time' => $seen['time'],
                                    
'seen' => $seen['seen']
                              );
                        }
                  }
            }
            
header("Content-type: application/json");
            echo 
json_encode($data);
            exit();
      }
}
// ***************************************** //
// Admin Functions //
if ($f == 'admin_setting' AND Wo_IsAdmin($wo['user']['user_id']) === true) {
      if (
$s == 'update_social_login_setting' && isset($_POST['googleLogin'])) {
            
$googleLogin     Wo_Secure($_POST['googleLogin']);
            
$facebookLogin   Wo_Secure($_POST['facebookLogin']);
            
$twitterLogin    Wo_Secure($_POST['twitterLogin']);
            
$linkedinLogin   Wo_Secure($_POST['linkedinLogin']);
            
$VkontakteLogin  Wo_Secure($_POST['VkontakteLogin']);
            
$facebookAppId   Wo_Secure($_POST['facebookAppId']);
            
$facebookAppKey  Wo_Secure($_POST['facebookAppKey']);
            
$googleAppId     Wo_Secure($_POST['googleAppId']);
            
$googleAppKey    Wo_Secure($_POST['googleAppKey']);
            
$twitterAppId    Wo_Secure($_POST['twitterAppId']);
            
$twitterAppKey   Wo_Secure($_POST['twitterAppKey']);
            
$linkedinAppId   Wo_Secure($_POST['linkedinAppId']);
            
$linkedinAppKey  Wo_Secure($_POST['linkedinAppKey']);
            
$VkontakteAppId  Wo_Secure($_POST['VkontakteAppId']);
            
$VkontakteAppKey Wo_Secure($_POST['VkontakteAppKey']);
            
$AllLogin        = ($googleLogin == '0' && $facebookLogin == '0' && $twitterLogin == '0' && $linkedinLogin == '0' && $VkontakteLogin == '0') ? 1;
            
$file_content    '<?php

$config['
AllLogin']  = ' $AllLogin ';
$config['
googleLogin']     = ' $googleLogin ';
$config['
facebookLogin']   = ' $facebookLogin ';
$config['
twitterLogin']    = ' $twitterLogin ';
$config['
linkedinLogin']   = ' $linkedinLogin ';
$config['
VkontakteLogin']  = ' $VkontakteLogin ';

$config['
facebookAppId']  = "' $facebookAppId '";
$config['
facebookAppKey'] = "' $facebookAppKey '";

$config['
googleAppId']    = "' $googleAppId '";
$config['
googleAppKey']   = "' $googleAppKey '";

$config['
twitterAppId']   = "' $twitterAppId '";
$config['
twitterAppKey']  = "' $twitterAppKey '";

$config['
linkedinAppId']  = "' $linkedinAppId '";
$config['
linkedinAppKey'] = "' $linkedinAppKey '";

$config['
VkontakteAppId']  = "' $VkontakteAppId '";
$config['
VkontakteAppKey'] = "' $VkontakteAppKey '";

?>'
;
            
$saveSetting     = @file_put_contents('assets/siteSetting/api-config.php'$file_content);
            if (
$saveSetting) {
                  
$data['status'] = 200;
            }
            
header("Content-type: application/json");
            echo 
json_encode($data);
            exit();
      }
      if (
$s == 'update_on_off_setting' && isset($_POST['emailValidation'])) {
            
$emailValidation   Wo_Secure($_POST['emailValidation']);
            
$emailNotification Wo_Secure($_POST['emailNotification']);
            
$fileSharing       Wo_Secure($_POST['fileSharing']);
            
$seoLink           Wo_Secure($_POST['seoLink']);
            
$cacheSystem       Wo_Secure($_POST['cacheSystem']);
            
$chatSystem        Wo_Secure($_POST['chatSystem']);
            
$useSeoFrindly     Wo_Secure($_POST['useSeoFrindly']);
            
$file_content      '<?php
$config['
emailValidation']  = ' $emailValidation ';
$config['
emailNotification'] = ' $emailNotification ';
$config['
fileSharing']    = ' $fileSharing ';
$config['
seoLink']    = ' $seoLink ';
$config['
cacheSystem']    = ' $cacheSystem ';
$config['
chatSystem']    = ' $chatSystem ';
$config['
useSeoFrindly']    = ' $useSeoFrindly ';
?>'
;
            
$saveSetting       = @file_put_contents('assets/siteSetting/onOff.config.php'$file_content);
            if (
$saveSetting) {
                  
$data['status'] = 200;
            }
            
header("Content-type: application/json");
            echo 
json_encode($data);
            exit();
      }
      if (
$s == 'update_site_information' && isset($_POST['siteName'])) {
            
$siteName     Wo_Secure($_POST['siteName']);
            
$siteTitle    Wo_Secure($_POST['siteTitle']);
            
$siteKeywords Wo_Secure($_POST['siteKeywords']);
            
$siteDesc     Wo_Secure($_POST['siteDesc']);
            
$siteEmail    Wo_Secure($_POST['siteEmail']);
            
$siteLang     Wo_Secure($_POST['siteLang']);
            
$file_content '<?php
$config['
siteName']  = "' $siteName '";
$config['
siteTitle']    = "' $siteTitle '";
$config['
siteKeywords']  = "' $siteKeywords '";
$config['
siteDesc']   = "' $siteDesc '";
$config['
siteEmail']  = "' $siteEmail '";
$config['
defualtLang'] = "' $siteLang '";
?>'
;
            
$saveSetting  = @file_put_contents('assets/siteSetting/siteSetting.config.php'$file_content);
            if (
$saveSetting) {
                  
$data['status'] = 200;
            }
            
header("Content-type: application/json");
            echo 
json_encode($data);
            exit();
      }
      if (
$s == 'update_reCaptcha_setting' && isset($_POST['reCaptcha'])) {
            
$reCaptcha    Wo_Secure($_POST['reCaptcha']);
            
$reCaptchaKey Wo_Secure($_POST['reCaptchaKey']);
            
$file_content '<?php
$config['
reCaptcha']  = "' $reCaptcha '";
$config['
reCaptchaKey']    = "' $reCaptchaKey '";
?>'
;
            
$saveSetting  = @file_put_contents('assets/siteSetting/reCaptcha.config.php'$file_content);
            if (
$saveSetting) {
                  
$data['status'] = 200;
            }
            
header("Content-type: application/json");
            echo 
json_encode($data);
            exit();
      }
      if (
$s == 'updateTheme' && isset($_POST['theme'])) {
            
$theme        Wo_Secure($_POST['theme']);
            
$file_content '<?php $config['theme'] = "' $theme '"; ?>';
            
$saveSetting  = @file_put_contents('assets/siteSetting/theme.config.php'$file_content);
            if (
$saveSetting) {
                  
$data['status'] = 200;
            }
            
header("Content-type: application/json");
            echo 
json_encode($data);
            exit();
      }
      if (
$s == 'delete_user' && isset($_GET['user_id'])) {
            if (
Wo_DeleteUser($_GET['user_id']) === true) {
                  
$data['status'] = 200;
            }
            
header("Content-type: application/json");
            echo 
json_encode($data);
            exit();
      }
      if (
$s == 'delete_page' && isset($_GET['page_id'])) {
            if (
Wo_DeletePage($_GET['page_id']) === true) {
                  
$data['status'] = 200;
            }
            
header("Content-type: application/json");
            echo 
json_encode($data);
            exit();
      }
      if (
$s == 'filter_all_users') {
            
$html  '';
            
$after = (isset($_GET['after_user_id']) && is_numeric($_GET['after_user_id']) && $_GET['after_user_id'] > 0) ? $_GET['after_user_id'] : 0;
            foreach (
Wo_GetAllUsers(20'ManageUsers'$_POST$after) as $wo['userlist']) {
                  
$html .= Wo_LoadPage('admin/manage_users/users-list');
            }
            
$data = array(
                  
'status' => 200,
                  
'html' => $html
            
);
            
header("Content-type: application/json");
            echo 
json_encode($data);
            exit();
      }
      if (
$s == 'get_more_pages') {
            
$html  '';
            
$after = (isset($_GET['after_page_id']) && is_numeric($_GET['after_page_id']) && $_GET['after_page_id'] > 0) ? $_GET['after_page_id'] : 0;
            foreach (
Wo_GetAllPages(20$after) as $wo['pagelist']) {
                  
$html .= Wo_LoadPage('admin/manage_pages/pages-list');
            }
            
$data = array(
                  
'status' => 200,
                  
'html' => $html
            
);
            
header("Content-type: application/json");
            echo 
json_encode($data);
            exit();
      }
      if (
$s == 'clear_cache_folder') {
            
Wo_ClearCache();
            
$data = array(
                  
'status' => 200
            
);
            
header("Content-type: application/json");
            echo 
json_encode($data);
            exit();
      }
      if (
$s == 'get_cache_folder_size') {
            
$html Wo_SizeFormat(Wo_FolderSize('cache'));
            
$data = array(
                  
'status' => 200,
                  
'html' => $html
            
);
            
header("Content-type: application/json");
            echo 
json_encode($data);
            exit();
      }
      if (
$s == 'update_users_setting' && isset($_POST['user_lastseen'])) {
            
$user_lastseen       Wo_Secure($_POST['user_lastseen']);
            
$age                 Wo_Secure($_POST['age']);
            
$deleteAccount       Wo_Secure($_POST['deleteAccount']);
            
$maxUpload           Wo_Secure($_POST['maxUpload']);
            
$maxCharacters       Wo_Secure($_POST['maxCharacters']);
            
$allowedExtenstion   Wo_Secure($_POST['allowedExtenstion']);
            
$connectivitySystem  Wo_Secure($_POST['connectivitySystem']);
            
$profileVisit        Wo_Secure($_POST['profileVisit']);
            
$message_seen        Wo_Secure($_POST['message_seen']);
            
$message_typing      Wo_Secure($_POST['message_typing']);
            
$google_map_api      Wo_Secure($_POST['google_map_api']);
            
$censored_words      Wo_Secure($_POST['censored_words'], 0);
            
$delete_follow_table 0;
            if (
$config['connectivitySystem'] == && $connectivitySystem != 1) {
                  
$delete_follow_table 1;
            } else if (
$config['connectivitySystem'] != && $connectivitySystem == 1) {
                  
$delete_follow_table 1;
            }
            if (
is_numeric($user_lastseen) && is_numeric($age) && $user_lastseen && $age 2) {
                  
$file_content '<?php
$config['
user_lastseen']  = ' $user_lastseen ';
$config['
age']    = ' $age ';
$config['
deleteAccount']    = ' $deleteAccount ';
$config['
connectivitySystem']    = ' $connectivitySystem ';
$config['
profileVisit'] = "' $profileVisit '";
$config['
maxUpload']    = ' $maxUpload ';
$config['
maxCharacters']    = ' $maxCharacters ';
$config['
message_seen']    = ' $message_seen ';
$config['
message_typing']    = ' $message_typing ';
$config['
google_map_api']    = "' $google_map_api '";
$config['
allowedExtenstion'] = "' $allowedExtenstion '";
$config['
censored_words'] = "' $censored_words '";
?>'
;
                  
$saveSetting  = @file_put_contents('assets/siteSetting/userSetting.config.php'$file_content);
                  if (
$saveSetting) {
                        if (
$delete_follow_table == 1) {
                              
mysqli_query($sqlConnect"DELETE FROM " T_FOLLOWERS);
                              
mysqli_query($sqlConnect"DELETE FROM " T_NOTIFICATION " WHERE type='following'");
                        }
                        
$data['status'] = 200;
                  }
            }
            
header("Content-type: application/json");
            echo 
json_encode($data);
            exit();
      }
      if (
$s == 'get_more_posts') {
            
$html      '';
            
$postsData = array(
                  
'limit' => 20,
                  
'after_post_id' => Wo_Secure($_GET['after_post_id'])
            );
            foreach (
Wo_GetAllPosts($postsData) as $wo['story']) {
                  
$html .= Wo_LoadPage('admin/manage_posts/posts-list');
            }
            
$data = array(
                  
'status' => 200,
                  
'html' => $html
            
);
            
header("Content-type: application/json");
            echo 
json_encode($data);
            exit();
      }
      if (
$s == 'delete_post') {
            if (!empty(
$_POST['post_id'])) {
                  if (
Wo_DeletePost($_POST['post_id']) === true) {
                        
$data = array(
                              
'status' => 200
                        
);
                  }
            }
            
header("Content-type: application/json");
            echo 
json_encode($data);
            exit();
      }
      if (
$s == 'update_google_analytics_code') {
            if (!empty(
$_POST['GoogleAnalytics'])) {
                  
$GoogleAnalytics htmlspecialchars($_POST['GoogleAnalytics']);
                  
$file_content    '<?php
$config['
googleAnalytics']  = "' $GoogleAnalytics '";
?>'
;
                  
$saveSetting     = @file_put_contents('assets/siteSetting/googleAnalytics.config.php'$file_content);
                  if (
$saveSetting) {
                        
$data['status'] = 200;
                  }
            }
            
header("Content-type: application/json");
            echo 
json_encode($data);
            exit();
      }
      if (
$s == 'delete_reported_post') {
            if (!empty(
$_GET['post_id'])) {
                  if (
Wo_DeletePost($_GET['post_id']) === true) {
                        
$deleteReport Wo_DeleteReport($_GET['report_id']);
                        if (
$deleteReport === true) {
                              
$data = array(
                                    
'status' => 200,
                                    
'html' => Wo_CountUnseenReports()
                              );
                        }
                  }
            }
            
header("Content-type: application/json");
            echo 
json_encode($data);
            exit();
      }
      if (
$s == 'mark_as_safe') {
            if (!empty(
$_GET['report_id'])) {
                  
$deleteReport Wo_DeleteReport($_GET['report_id']);
                  if (
$deleteReport === true) {
                        
$data = array(
                              
'status' => 200,
                              
'html' => Wo_CountUnseenReports()
                        );
                  }
            }
            
header("Content-type: application/json");
            echo 
json_encode($data);
            exit();
      }
      if (
$s == 'send_mail_to_all_users') {
            
$isset_test 'off';
            if (empty(
$_POST['message']) || empty($_POST['subject'])) {
                  
$send_errors $error_icon $wo['lang']['please_check_details'];
            } else {
                  if (!empty(
$_POST['test_message'])) {
                        if (
$_POST['test_message'] == 'on') {
                              
$isset_test 'on';
                        }
                  }
                  if (
$isset_test == 'on') {
                        
$headers "From: " $config['siteName'] . " <" $config['siteEmail'] . ">rn";
                        
$headers .= "Content-Type: text/html; charset=UTF-8rn";
                        @
mail($wo['user']['email'], $_POST['subject'], $_POST['message'], $headers);
                  } else {
                        
$users Wo_GetAllUsers();
                        foreach (
$users as $user) {
                              
$headers "From: " $config['siteName'] . " <" $config['siteEmail'] . ">rn";
                              
$headers .= "Content-Type: text/html; charset=UTF-8rn";
                              @
mail($user['email'], $_POST['subject'], $_POST['message'], $headers);
                        }
                  }
            }
            
header("Content-type: application/json");
            if (!empty(
$send_errors)) {
                  
$send_errors_data = array(
                        
'status' => 400,
                        
'message' => $send_errors
                  
);
                  echo 
json_encode($send_errors_data);
            } else {
                  
$data = array(
                        
'status' => 200
                  
);
                  echo 
json_encode($data);
            }
            exit();
      }
      if (
$s == 'add_new_announcement') {
            if (!empty(
$_POST['announcement_text'])) {
                  
$html '';
                  
$id   Wo_AddNewAnnouncement($_POST['announcement_text']);
                  if (
$id 0) {
                        
$wo['activeAnnouncement'] = Wo_GetAnnouncement($id);
                        
$html .= Wo_LoadPage('admin/announcement/active-list');
                        
$data = array(
                              
'status' => 200,
                              
'text' => $html
                        
);
                  }
            }
            
header("Content-type: application/json");
            echo 
json_encode($data);
            exit();
      }
      if (
$s == 'delete_announcement') {
            if (!empty(
$_GET['id'])) {
                  
$DeleteAnnouncement Wo_DeleteAnnouncement($_GET['id']);
                  if (
$DeleteAnnouncement === true) {
                        
$data = array(
                              
'status' => 200
                        
);
                  }
            }
            
header("Content-type: application/json");
            echo 
json_encode($data);
            exit();
      }
      if (
$s == 'disable_announcement') {
            if (!empty(
$_GET['id'])) {
                  
$html                '';
                  
$DisableAnnouncement Wo_DisableAnnouncement($_GET['id']);
                  if (
$DisableAnnouncement === true) {
                        
$wo['inactiveAnnouncement'] = Wo_GetAnnouncement($_GET['id']);
                        
$html .= Wo_LoadPage('admin/announcement/inactive-list');
                        
$data = array(
                              
'status' => 200,
                              
'html' => $html
                        
);
                  }
            }
            
header("Content-type: application/json");
            echo 
json_encode($data);
            exit();
      }
      if (
$s == 'activate_announcement') {
            if (!empty(
$_GET['id'])) {
                  
$html                 '';
                  
$ActivateAnnouncement Wo_ActivateAnnouncement($_GET['id']);
                  if (
$ActivateAnnouncement === true) {
                        
$wo['activeAnnouncement'] = Wo_GetAnnouncement($_GET['id']);
                        
$html .= Wo_LoadPage('admin/announcement/active-list');
                        
$data = array(
                              
'status' => 200,
                              
'html' => $html
                        
);
                  }
            }
            
header("Content-type: application/json");
            echo 
json_encode($data);
            exit();
      }
      if (
$s == 'update_ads') {
            if (!empty(
$_POST['type']) && !empty($_POST['code'])) {
                  
$ad_data = array(
                        
'type' => $_POST['type'],
                        
'code' => $_POST['code']
                  );
                  if (
Wo_UpdateAdsCode($ad_data)) {
                        
$data = array(
                              
'status' => 200
                        
);
                  }
            }
            
header("Content-type: application/json");
            echo 
json_encode($data);
            exit();
      }
      if (
$s == 'update_ads_status') {
            if (!empty(
$_GET['type'])) {
                  if (
Wo_UpdateAdActivation($_GET['type']) == 'active') {
                        
$data = array(
                              
'status' => 200
                        
);
                  } else {
                        
$data = array(
                              
'status' => 300
                        
);
                  }
            }
            
header("Content-type: application/json");
            echo 
json_encode($data);
            exit();
      }
}
if (
$f == 'get_following_users') {
      
$html '';
      if (!empty(
$_GET['user_id'])) {
            foreach (
Wo_GetFollowing($_GET['user_id'], 'sidebar'12) as $wo['UsersList']) {
                  
$wo['UsersList']['user_name'] = $wo['UsersList']['name'];
                  if (!empty(
$wo['UsersList']['last_name'])) {
                        
$wo['UsersList']['user_name'] = $wo['UsersList']['first_name'];
                  }
                  
$html .= Wo_LoadPage('sidebar/profile-sidebar-user-list');
            }
      }
      
$data = array(
            
'status' => 200,
            
'html' => $html
      
);
      
header("Content-type: application/json");
      echo 
json_encode($data);
      exit();
}
if (
$f == 'get_followers_users') {
      
$html '';
      if (!empty(
$_GET['user_id'])) {
            foreach (
Wo_GetFollowers($_GET['user_id'], 'sidebar'12) as $wo['UsersList']) {
                  
$wo['UsersList']['user_name'] = $wo['UsersList']['name'];
                  if (!empty(
$wo['UsersList']['last_name'])) {
                        
$wo['UsersList']['user_name'] = $wo['UsersList']['first_name'];
                  }
                  
$html .= Wo_LoadPage('sidebar/profile-sidebar-user-list');
            }
      }
      
$data = array(
            
'status' => 200,
            
'html' => $html
      
);
      
header("Content-type: application/json");
      echo 
json_encode($data);
      exit();
}
if (
$f == 'posts') {
      if (
$s == 'fetch_url') {
            if (isset(
$_POST["url"])) {
                  
$get_url $_POST["url"];
                  include_once(
"assets/import/simple_html_dom.inc.php");
                  
$get_content file_get_html($get_url);
                  foreach (
$get_content->find('title') as $element) {
                        
$page_title $element->plaintext;
                  }
                  
$page_body $get_content->find("meta[name='description']"0)->content;
                  
$page_body substr($page_body0250);
                  if (
$page_body === false) {
                        
$page_body '';
                  }
                  
$image_urls = array();
                  foreach (
$get_content->find('img') as $element) {
                        if (!
preg_match('/blank.(.*)/i'$element->src) && filter_var($element->srcFILTER_VALIDATE_URL)) {
                              
$image_urls[] = $element->src;
                        }
                  }
                  
$output = array(
                        
'title' => $page_title,
                        
'images' => $image_urls,
                        
'content' => $page_body,
                        
'url' => $_POST["url"]
                  );
                  echo 
json_encode($output);
                  exit();
            }
      }
      if (
$s == 'search_for_posts') {
            
$html '';
            if (!empty(
$_GET['search_query'])) {
                  
$search_data Wo_SearchForPosts($_GET['id'], $_GET['search_query'], 20$_GET['type']);
                  if (
count($search_data) == 0) {
                        
$html Wo_LoadPage('story/filter-no-stories-found');
                  } else {
                        foreach (
$search_data as $wo['story']) {
                              
$html .= Wo_LoadPage('story/content');
                        }
                  }
                  
$data = array(
                        
'status' => 200,
                        
'html' => $html
                  
);
            }
            
header("Content-type: application/json");
            echo 
json_encode($data);
            exit();
      }
      if (
$s == 'insert_new_post') {
            
$media         '';
            
$mediaFilename '';
            
$mediaName     '';
            
$html          '';
            
$recipient_id  0;
            
$page_id       0;
            if (isset(
$_POST['recipient_id']) && !empty($_POST['recipient_id'])) {
                  
$recipient_id Wo_Secure($_POST['recipient_id']);
            }
            if (isset(
$_POST['page_id']) && !empty($_POST['page_id'])) {
                  
$page_id Wo_Secure($_POST['page_id']);
            }
            if (isset(
$_FILES['postFile']['name'])) {
                  
$fileInfo = array(
                        
'file' => $_FILES["postFile"]["tmp_name"],
                        
'name' => $_FILES['postFile']['name'],
                        
'size' => $_FILES["postFile"]["size"]
                  );
                  
$media    Wo_ShareFile($fileInfo);
                  if (!empty(
$media)) {
                        
$mediaFilename $media['filename'];
                        
$mediaName     $media['name'];
                  }
            }
            if (empty(
$_POST['postPrivacy'])) {
                  
$_POST['postPrivacy'] = 0;
            }
            
$post_privacy  0;
            
$privacy_array = array(
                  
'0',
                  
'1',
                  
'2',
                  
'3'
            
);
            if (isset(
$_POST['postPrivacy'])) {
                  if (
in_array($_POST['postPrivacy'], $privacy_array)) {
                        
$post_privacy $_POST['postPrivacy'];
                  }
            }
            
$import_url_image '';
            
$url_link         '';
            
$url_content      '';
            
$url_title        '';
            if (!empty(
$_POST['url_link']) && !empty($_POST['url_title'])) {
                  
$url_link  $_POST['url_link'];
                  
$url_title $_POST['url_title'];
                  if (!empty(
$_POST['url_content'])) {
                        
$url_content $_POST['url_content'];
                  }
                  if (!empty(
$_POST['url_image'])) {
                        
$import_url_image = @Wo_ImportImageFromUrl($_POST['url_image']);
                  }
            }
            
$post_text       '';
            
$post_video      '';
            
$post_soundcloud '';
            
$post_map        '';
            
$post_vine       '';
            if (!empty(
$_POST['postText'])) {
                  
$post_text $_POST['postText'];
            }
            if (!empty(
$_POST['postVideo'])) {
                  
$post_video $_POST['postVideo'];
            }
            if (!empty(
$_POST['postSoundCloud'])) {
                  
$post_soundcloud $_POST['postSoundCloud'];
            }
            if (!empty(
$_POST['postMap'])) {
                  
$post_map $_POST['postMap'];
            }
            
$post_data = array(
                  
'user_id' => Wo_Secure($wo['user']['user_id']),
                  
'page_id' => $page_id,
                  
'postText' => Wo_Secure($post_text),
                  
'recipient_id' => $recipient_id,
                  
'postFile' => Wo_Secure($mediaFilename),
                  
'postFileName' => Wo_Secure($mediaName),
                  
'postSoundCloud' => Wo_Secure($post_soundcloud),
                  
'postMap' => Wo_Secure($post_map),
                  
'postPrivacy' => Wo_Secure($post_privacy),
                  
'postLinkTitle' => Wo_Secure($url_title),
                  
'postLinkContent' => Wo_Secure($url_content),
                  
'postLink' => Wo_Secure($url_link),
                  
'postLinkImage' => Wo_Secure($import_url_image),
                  
'time' => time()
            );
            
$id        Wo_RegisterPost($post_data$post_video);
            if (
$id) {
                  
$wo['story'] = Wo_PostData($id);
                  
$html .= Wo_LoadPage('story/content');
                  
$data = array(
                        
'status' => 200,
                        
'html' => $html
                  
);
            }
            
header("Content-type: application/json");
            echo 
json_encode($data);
            exit();
      }
      if (
$s == 'delete_post') {
            if (!empty(
$_GET['post_id'])) {
                  if (
Wo_DeletePost($_GET['post_id']) === true) {
                        
$data = array(
                              
'status' => 200
                        
);
                  }
            }
            
header("Content-type: application/json");
            echo 
json_encode($data);
            exit();
      }
      if (
$s == 'get_new_posts') {
            if (!empty(
$_GET['before_post_id']) && !empty($_GET['user_id'])) {
                  
$html      '';
                  
$postsData = array(
                        
'before_post_id' => $_GET['before_post_id'],
                        
'publisher_id' => $_GET['user_id']
                  );
                  foreach (
Wo_GetPosts($postsData) as $wo['story']) {
                        
$html .= Wo_LoadPage('story/content');
                  }
                  
$data = array(
                        
'status' => 200,
                        
'html' => $html
                  
);
            }
            
header("Content-type: application/json");
            echo 
json_encode($data);
            exit();
      }
      if (
$s == 'load_more_posts') {
            
$html '';
            if (!empty(
$_GET['filter_by_more']) && !empty($_GET['after_post_id'])) {
                  
$page_id   = (!empty($_GET['page_id']) && $_GET['page_id'] > 0) ? $_GET['page_id'] : 0;
                  
$postsData = array(
                        
'filter_by' => Wo_Secure($_GET['filter_by_more']),
                        
'limit' => 15,
                        
'publisher_id' => Wo_Secure($_GET['user_id']),
                        
'page_id' => $page_id,
                        
'after_post_id' => Wo_Secure($_GET['after_post_id'])
                  );
                  foreach (
Wo_GetPosts($postsData) as $wo['story']) {
                        
$html .= Wo_LoadPage('story/content');
                  }
                  if (empty(
$html)) {
                        
$data = array(
                              
'status' => 300,
                              
'text' => $wo['lang']['no_more_posts']
                        );
                  } else {
                        
$data = array(
                              
'status' => 200,
                              
'html' => $html
                        
);
                  }
            }
            
header("Content-type: application/json");
            echo 
json_encode($data);
            exit();
      }
      if (
$s == 'edit_post') {
            if (!empty(
$_POST['post_id']) && !empty($_POST['text'])) {
                  
$updatePost Wo_UpdatePost(array(
                        
'post_id' => $_POST['post_id'],
                        
'text' => $_POST['text']
                  ));
                  if (!empty(
$updatePost)) {
                        
$data = array(
                              
'status' => 200,
                              
'html' => $updatePost
                        
);
                  }
            }
            
header("Content-type: application/json");
            echo 
json_encode($data);
            exit();
      }
      if (
$s == "update_post_privacy") {
            if (!empty(
$_GET['post_id']) && isset($_GET['privacy_type'])) {
                  
$updatePost Wo_UpdatePostPrivacy(array(
                        
'post_id' => Wo_Secure($_GET['post_id']),
                        
'privacy_type' => Wo_Secure($_GET['privacy_type'])
                  ));
                  if (isset(
$updatePost)) {
                        
$data = array(
                              
'status' => 200,
                              
'privacy_type' => $updatePost
                        
);
                  }
            }
            
header("Content-type: application/json");
            echo 
json_encode($data);
            exit();
      }
      if (
$s == 'register_like') {
            if (!empty(
$_GET['post_id'])) {
                  if (
Wo_AddLikes($_GET['post_id']) == 'unliked') {
                        
$data = array(
                              
'status' => 300,
                              
'likes' => Wo_CountLikes($_GET['post_id'])
                        );
                  } else {
                        
$data = array(
                              
'status' => 200,
                              
'likes' => Wo_CountLikes($_GET['post_id'])
                        );
                  }
            }
            
header("Content-type: application/json");
            echo 
json_encode($data);
            exit();
      }
      if (
$s == 'register_wonder') {
            if (!empty(
$_GET['post_id'])) {
                  if (
Wo_AddWonders($_GET['post_id']) == 'unwonder') {
                        
$data = array(
                              
'status' => 300,
                              
'wonders' => Wo_CountWonders($_GET['post_id'])
                        );
                  } else {
                        
$data = array(
                              
'status' => 200,
                              
'wonders' => Wo_CountWonders($_GET['post_id'])
                        );
                  }
            }
            
header("Content-type: application/json");
            echo 
json_encode($data);
            exit();
      }
      if (
$s == 'register_share') {
            if (!empty(
$_GET['post_id'])) {
                  if (
Wo_AddShare($_GET['post_id']) == 'unshare') {
                        
$data = array(
                              
'status' => 300,
                              
'shares' => Wo_CountShares($_GET['post_id'])
                        );
                  } else {
                        
$data = array(
                              
'status' => 200,
                              
'shares' => Wo_CountShares($_GET['post_id'])
                        );
                  }
            }
            
header("Content-type: application/json");
            echo 
json_encode($data);
            exit();
      }
      if (
$s == 'register_comment') {
            if (!empty(
$_POST['post_id']) && !empty($_POST['text'])) {
                  
$html    '';
                  
$page_id '';
                  if (!empty(
$_POST['page_id'])) {
                        
$page_id $_POST['page_id'];
                  }
                  
$C_Data        = array(
                        
'user_id' => Wo_Secure($wo['user']['user_id']),
                        
'page_id' => Wo_Secure($page_id),
                        
'post_id' => Wo_Secure($_POST['post_id']),
                        
'text' => Wo_Secure($_POST['text']),
                        
'time' => time()
                  );
                  
$R_Comment     Wo_RegisterPostComment($C_Data);
                  
$wo['comment'] = Wo_GetPostComment($R_Comment);
                  if (!empty(
$wo['comment'])) {
                        
$html Wo_LoadPage('comment/content');
                        
$data = array(
                              
'status' => 200,
                              
'html' => $html,
                              
'comments_num' => Wo_CountPostComment($_POST['post_id'])
                        );
                  }
            }
            
header("Content-type: application/json");
            echo 
json_encode($data);
            exit();
      }
      if (
$s == 'delete_comment') {
            if (!empty(
$_GET['comment_id'])) {
                  
$DeleteComment Wo_DeletePostComment($_GET['comment_id']);
                  if (
$DeleteComment === true) {
                        
$data = array(
                              
'status' => 200
                        
);
                  }
            }
            
header("Content-type: application/json");
            echo 
json_encode($data);
            exit();
      }
      if (
$s == 'load_more_comments') {
            if (!empty(
$_GET['post_id'])) {
                  
$html '';
                  foreach (
Wo_GetPostComments($_GET['post_id'], Wo_CountPostComment($_GET['post_id'])) as $wo['comment']) {
                        
$html .= Wo_LoadPage('comment/content');
                  }
                  
$data = array(
                        
'status' => 200,
                        
'html' => $html
                  
);
            }
            
header("Content-type: application/json");
            echo 
json_encode($data);
            exit();
      }
      if (
$s == 'edit_comment') {
            if (!empty(
$_POST['comment_id']) && !empty($_POST['text'])) {
                  
$updateComment Wo_UpdateComment(array(
                        
'comment_id' => $_POST['comment_id'],
                        
'text' => $_POST['text']
                  ));
                  if (!empty(
$updateComment)) {
                        
$data = array(
                              
'status' => 200,
                              
'html' => $updateComment
                        
);
                  }
            }
            
header("Content-type: application/json");
            echo 
json_encode($data);
            exit();
      }
      if (
$s == 'register_comment_like') {
            if (!empty(
$_POST['comment_id']) && !empty($_POST['comment_text'])) {
                  if (
Wo_AddCommentLikes($_POST['comment_id'], $_POST['comment_text']) == 'unliked') {
                        
$data = array(
                              
'status' => 300,
                              
'likes' => Wo_CountCommentLikes($_POST['comment_id'])
                        );
                  } else {
                        
$data = array(
                              
'status' => 200,
                              
'likes' => Wo_CountCommentLikes($_POST['comment_id'])
                        );
                  }
            }
            
header("Content-type: application/json");
            echo 
json_encode($data);
            exit();
      }
      if (
$s == 'register_comment_wonder') {
            if (!empty(
$_POST['comment_id']) && !empty($_POST['comment_text'])) {
                  if (
Wo_AddCommentWonders($_POST['comment_id'], $_POST['comment_text']) == 'unwonder') {
                        
$data = array(
                              
'status' => 300,
                              
'wonders' => Wo_CountCommentWonders($_POST['comment_id'])
                        );
                  } else {
                        
$data = array(
                              
'status' => 200,
                              
'wonders' => Wo_CountCommentWonders($_POST['comment_id'])
                        );
                  }
            }
            
header("Content-type: application/json");
            echo 
json_encode($data);
            exit();
      }
      if (
$s == 'save_post') {
            if (!empty(
$_GET['post_id'])) {
                  
$post_data = array(
                        
'post_id' => $_GET['post_id']
                  );
                  if (
Wo_SavePosts($post_data) == 'unsaved') {
                        
$data = array(
                              
'status' => 300,
                              
'text' => $wo['lang']['save_post']
                        );
                  } else {
                        
$data = array(
                              
'status' => 200,
                              
'text' => $wo['lang']['unsave_post']
                        );
                  }
            }
            
header("Content-type: application/json");
            echo 
json_encode($data);
            exit();
      }
      if (
$s == 'pin_post') {
            if (!empty(
$_GET['post_id'])) {
                  
$type    = (!empty($_GET['page'])) ? 'page' '';
                  
$page_id = (!empty($_GET['page_id'])) ? $_GET['page_id'] : '';
                  if (
Wo_PinPost($_GET['post_id'], $type$page_id) == 'unpin') {
                        
$data = array(
                              
'status' => 300,
                              
'text' => $wo['lang']['pin_post']
                        );
                  } else {
                        
$data = array(
                              
'status' => 200,
                              
'text' => $wo['lang']['unpin_post']
                        );
                  }
            }
            
header("Content-type: application/json");
            echo 
json_encode($data);
            exit();
      }
      if (
$s == 'report_post') {
            if (!empty(
$_GET['post_id'])) {
                  
$post_data = array(
                        
'post_id' => $_GET['post_id']
                  );
                  if (
Wo_ReportPost($post_data) == 'unreport') {
                        
$data = array(
                              
'status' => 300,
                              
'text' => $wo['lang']['unreport_post']
                        );
                  } else {
                        
$data = array(
                              
'status' => 200,
                              
'text' => $wo['lang']['report_post']
                        );
                  }
            }
            
header("Content-type: application/json");
            echo 
json_encode($data);
            exit();
      }
      if (
$s == 'get_post_likes') {
            if (!empty(
$_GET['post_id'])) {
                  
$data       = array(
                        
'status' => 200,
                        
'html' => ''
                  
);
                  
$likedUsers Wo_GetPostLikes($_GET['post_id']);
                  if (
count($likedUsers) > 0) {
                        foreach (
$likedUsers as $wo['WondredLikedusers']) {
                              
$data['html'] .= Wo_LoadPage('story/post-likes-wonders');
                        }
                  } else {
                        
$data['message'] = $wo['lang']['no_likes'];
                  }
            }
            
header("Content-type: application/json");
            echo 
json_encode($data);
            exit();
      }
      if (
$s == 'get_post_wonders') {
            if (!empty(
$_GET['post_id'])) {
                  
$data          = array(
                        
'status' => 200,
                        
'html' => ''
                  
);
                  
$WonderedUsers Wo_GetPostWonders($_GET['post_id']);
                  if (
count($WonderedUsers) > 0) {
                        foreach (
$WonderedUsers as $wo['WondredLikedusers']) {
                              
$data['html'] .= Wo_LoadPage('story/post-likes-wonders');
                        }
                  } else {
                        
$data['message'] = $wo['lang']['no_wonders'];
                  }
            }
            
header("Content-type: application/json");
            echo 
json_encode($data);
            exit();
      }
      if (
$s == 'filter_posts') {
            if (!empty(
$_GET['filter_by']) && isset($_GET['user_id'])) {
                  
$html    '';
                  
$options = array(
                        
'filter_by' => Wo_Secure($_GET['filter_by'])
                  );
                  
$stories Wo_GetPosts();
                  if (!empty(
$_GET['page'])) {
                        if (
$_GET['page'] == 'true') {
                              
$options['page_id'] = $_GET['user_id'];
                        } else {
                              
$options['publisher_id'] = $_GET['user_id'];
                        }
                  }
                  
$stories Wo_GetPosts($options);
                  if (
count($stories) > 0) {
                        foreach (
$stories as $wo['story']) {
                              
$html .= Wo_LoadPage('story/content');
                        }
                  } else {
                        
$html .= Wo_LoadPage('story/filter-no-stories-found');
                  }
                  
$loadMoreText '<i class="fa fa-chevron-circle-down progress-icon" data-icon="chevron-circle-down"></i> ' $wo['lang']['load_more_posts'];
                  if (empty(
$stories)) {
                        
$loadMoreText $wo['lang']['no_more_posts'];
                  }
                  
$data = array(
                        
'status' => 200,
                        
'html' => $html,
                        
'text' => $loadMoreText
                  
);
            }
            
header("Content-type: application/json");
            echo 
json_encode($data);
            exit();
      }
}
if (
$f == 'activities') {
      if (
$s == 'get_new_activities') {
            if (!empty(
$_POST['before_activity_id'])) {
                  
$html     '';
                  
$activity Wo_GetActivities(array(
                        
'before_activity_id' => Wo_Secure($_POST['before_activity_id'])
                  ));
                  foreach (
$activity as $wo['activity']) {
                        
$wo['activity']['unread'] = 'unread';
                        
$html .= Wo_LoadPage('sidebar/activities-list');
                  }
                  
$data = array(
                        
'status' => 200,
                        
'html' => $html
                  
);
            }
            
header("Content-type: application/json");
            echo 
json_encode($data);
            exit();
      }
      if (
$s == 'get_more_activities') {
            if (!empty(
$_POST['after_activity_id'])) {
                  
$html '';
                  foreach (
Wo_GetActivities(array(
                        
'after_activity_id' => Wo_Secure($_POST['after_activity_id'])
                  )) as 
$wo['activity']) {
                        
// $wo['activity']['unread'] = 'unread';
                        
$html .= Wo_LoadPage('sidebar/activities-list');
                  }
                  
$data = array(
                        
'status' => 200,
                        
'html' => $html
                  
);
                  if (empty(
$html)) {
                        
$data['message'] = $wo['lang']['no_more_actitivties'];
                  }
            }
            
header("Content-type: application/json");
            echo 
json_encode($data);
            exit();
      }
}
if (
$f == 'chat') {
      if (
$s == 'count_online_users') {
            
$html Wo_CountOnlineUsers();
            
$data = array(
                  
'status' => 200,
                  
'html' => $html
            
);
            
header("Content-type: application/json");
            echo 
json_encode($data);
            exit();
      }
      if (
$s == 'is_recipient_typing') {
            if (!empty(
$_GET['recipient_id'])) {
                  
$isTyping Wo_IsTyping($_GET['recipient_id']);
                  if (
$isTyping === true) {
                        
$img  Wo_UserData($_GET['recipient_id']);
                        
$data = array(
                              
'status' => 200,
                              
'img' => $img['avatar'],
                              
'typing' => $wo['config']['theme_url'] . '/img/loading_dots.gif'
                        
);
                  }
            }
            
header("Content-type: application/json");
            echo 
json_encode($data);
            exit();
      }
      if (
$s == 'recipient_is_typing') {
            if (!empty(
$_GET['recipient_id'])) {
                  
$isTyping Wo_RegisterTyping($_GET['recipient_id'], 1);
                  if (
$isTyping === true) {
                        
$data = array(
                              
'status' => 200
                        
);
                  }
            }
            
header("Content-type: application/json");
            echo 
json_encode($data);
            exit();
      }
      if (
$s == 'remove_typing') {
            if (!empty(
$_GET['recipient_id'])) {
                  
$isTyping Wo_RegisterTyping($_GET['recipient_id'], 0);
                  if (
$isTyping === true) {
                        
$data = array(
                              
'status' => 200
                        
);
                  }
            }
            
header("Content-type: application/json");
            echo 
json_encode($data);
            exit();
      }
      if (
$s == 'update_online_recipients') {
            
$html        '';
            
$OnlineUsers Wo_GetChatUsers('online');
            foreach (
$OnlineUsers as $wo['chatList']) {
                  
$html .= Wo_LoadPage('chat/online-user');
            }
            
$data = array(
                  
'status' => 200,
                  
'html' => $html
            
);
            
header("Content-type: application/json");
            echo 
json_encode($data);
            exit();
      }
      if (
$s == 'update_offline_recipients') {
            
$html         '';
            
$OfflineUsers Wo_GetChatUsers('offline');
            foreach (
$OfflineUsers as $wo['chatList']) {
                  
$html .= Wo_LoadPage('chat/offline-user');
            }
            
$data = array(
                  
'status' => 200,
                  
'html' => $html
            
);
            
header("Content-type: application/json");
            echo 
json_encode($data);
            exit();
      }
      if (
$s == 'search_for_recipients') {
            if (!empty(
$_POST['search_query'])) {
                  
$html   '';
                  
$search Wo_ChatSearchUsers($_POST['search_query']);
                  foreach (
$search as $wo['chatList']) {
                        
$html .= Wo_LoadPage('chat/search-result');
                  }
                  
$data = array(
                        
'status' => 200,
                        
'html' => $html
                  
);
            }
            
header("Content-type: application/json");
            echo 
json_encode($data);
            exit();
      }
      if (
$s == 'update_chat_status') {
            if (!empty(
$_POST['status'])) {
                  
$html   '';
                  
$status Wo_UpdateStatus($_POST['status']);
                  if (
$status == 0) {
                        
$data = array(
                              
'status' => $status
                        
);
                  } else if (
$status == 1) {
                        
$data = array(
                              
'status' => $status
                        
);
                  }
            }
            
header("Content-type: application/json");
            echo 
json_encode($data);
            exit();
      }
      if (
$s == 'load_chat_tab') {
            if (!empty(
$_GET['recipient_id']) && is_numeric($_GET['recipient_id']) && $_GET['recipient_id'] > 0) {
                  
$recipient_id Wo_Secure($_GET['recipient_id']);
                  
$recipient    Wo_UserData($recipient_id);
                  if (isset(
$recipient['user_id'])) {
                        
$wo['chat']['recipient'] = $recipient;
                        
$data                    = array(
                              
'status' => 200,
                              
'html' => Wo_LoadPage('chat/chat-tab')
                        );
                        
$_SESSION['chat_id']     = $recipient['user_id'];
                  }
            }
            
header("Content-type: application/json");
            echo 
json_encode($data);
            exit();
      }
      if (
$s == 'load_chat_messages') {
            if (!empty(
$_GET['recipient_id']) && is_numeric($_GET['recipient_id']) && $_GET['recipient_id'] > 0) {
                  
$recipient_id Wo_Secure($_GET['recipient_id']);
                  
$html         '';
                  
$messages     Wo_GetMessages(array(
                        
'user_id' => $recipient_id
                  
));
                  foreach (
$messages as $wo['chatMessage']) {
                        
$html .= Wo_LoadPage('chat/chat-list');
                  }
                  
$data = array(
                        
'status' => 200,
                        
'messages' => $html
                  
);
            }
            
header("Content-type: application/json");
            echo 
json_encode($data);
            exit();
      }
      if (
$s == 'open_tab') {
            if (isset(
$_SESSION['open_chat'])) {
                  if (
$_SESSION['open_chat'] == 1) {
                        
$_SESSION['open_chat'] = 0;
                  } else if (
$_SESSION['open_chat'] == 0) {
                        
$_SESSION['open_chat'] = 1;
                  }
            } else {
                  
$_SESSION['open_chat'] = 1;
            }
      }
      if (
$s == 'send_message') {
            if (!empty(
$_POST['user_id'])) {
                  
$html          '';
                  
$media         '';
                  
$mediaFilename '';
                  
$mediaName     '';
                  if (isset(
$_FILES['sendMessageFile']['name'])) {
                        
$fileInfo      = array(
                              
'file' => $_FILES["sendMessageFile"]["tmp_name"],
                              
'name' => $_FILES['sendMessageFile']['name'],
                              
'size' => $_FILES["sendMessageFile"]["size"]
                        );
                        
$media         Wo_ShareFile($fileInfo);
                        
$mediaFilename $media['filename'];
                        
$mediaName     $media['name'];
                  }
                  
$message_text '';
                  if (!empty(
$_POST['textSendMessage'])) {
                        
$message_text $_POST['textSendMessage'];
                  }
                  
$messages Wo_RegisterMessage(array(
                        
'from_id' => Wo_Secure($wo['user']['user_id']),
                        
'to_id' => Wo_Secure($_POST['user_id']),
                        
'text' => Wo_Secure($message_text),
                        
'media' => Wo_Secure($mediaFilename),
                        
'mediaFileName' => Wo_Secure($mediaName),
                        
'time' => time()
                  ));
                  if (
$messages 0) {
                        
$messages Wo_GetMessages(array(
                              
'message_id' => $messages,
                              
'user_id' => $_POST['user_id']
                        ));
                        foreach (
$messages as $wo['chatMessage']) {
                              
$html .= Wo_LoadPage('chat/chat-list');
                        }
                        
$data = array(
                              
'status' => 200,
                              
'html' => $html
                        
);
                  }
            }
            
header("Content-type: application/json");
            echo 
json_encode($data);
            exit();
      }
      if (
$s == 'get_new_messages') {
            if (!empty(
$_GET['user_id'])) {
                  
$html    '';
                  
$user_id Wo_Secure($_GET['user_id']);
                  if (!empty(
$user_id)) {
                        
$user_id  $_GET['user_id'];
                        
$messages Wo_GetMessages(array(
                              
'after_message_id' => $_GET['message_id'],
                              
'new' => true,
                              
'user_id' => $user_id
                        
));
                        if (
count($messages) > 0) {
                              foreach (
$messages as $wo['chatMessage']) {
                                    
$html .= Wo_LoadPage('chat/chat-list');
                              }
                              
$data = array(
                                    
'status' => 200,
                                    
'html' => $html,
                                    
'receiver' => $user_id,
                                    
'sender' => $wo['user']['user_id']
                              );
                        }
                  }
            }
            
header("Content-type: application/json");
            echo 
json_encode($data);
            exit();
      }
      if (
$s == 'update_tab_status') {
            
$html '';
            if (!empty(
$_GET['user_id'])) {
                  
$user_id Wo_Secure($_GET['user_id']);
                  if (!empty(
$user_id)) {
                        
$user_id $_GET['user_id'];
                        
$status  Wo_IsOnline($user_id);
                        if (
$status === true) {
                              
$data['status'] = 200;
                        } else {
                              
$data['status'] = 300;
                        }
                  }
            }
            
header("Content-type: application/json");
            echo 
json_encode($data);
            exit();
      }
      if (
$s == 'close') {
            if (isset(
$_SESSION['chat_id'])) {
                  unset(
$_SESSION['chat_id']);
            }
            if (!empty(
$_GET['recipient_id'])) {
                  
$data = array(
                        
'url' => Wo_SeoLink('index.php?tab1=messages&user=' $_GET['recipient_id'])
                  );
            }
            
header("Content-type: application/json");
            echo 
json_encode($data);
            exit();
      }
      if (
$s == 'is_chat_on') {
            if (!empty(
$_GET['recipient_id'])) {
                  
$data = array(
                        
'url' => Wo_SeoLink('index.php?tab1=messages&user=' $_GET['recipient_id']),
                        
'chat' => $wo['config']['chatSystem']
                  );
            }
            
header("Content-type: application/json");
            echo 
json_encode($data);
            exit();
      }
}
if (
$f == 'apps') {
      if (
$s == 'create_app') {
            if (empty(
$_POST['app_name']) || empty($_POST['app_website_url']) || empty($_POST['app_description'])) {
                  
$errors[] = $error_icon $wo['lang']['please_check_details'];
            }
            if (!
filter_var($_POST['app_website_url'], FILTER_VALIDATE_URL)) {
                  
$errors[] = $error_icon $wo['lang']['website_invalid_characters'];
            }
            if (empty(
$errors)) {
                  
$re_app_data = array(
                        
'app_user_id' => Wo_Secure($wo['user']['user_id']),
                        
'app_name' => Wo_Secure($_POST['app_name']),
                        
'app_website_url' => Wo_Secure($_POST['app_website_url']),
                        
'app_description' => Wo_Secure($_POST['app_description'])
                  );
                  
$app_id      Wo_RegisterApp($re_app_data);
                  if (
$app_id != '') {
                        if (!empty(
$_FILES["app_avatar"]["name"])) {
                              
Wo_UploadImage($_FILES["app_avatar"]["tmp_name"], $_FILES['app_avatar']['name'], 'app'$app_id);
                        }
                        
$data = array(
                              
'status' => 200,
                              
'location' => Wo_SeoLink('index.php?tab1=app&app_id=' $app_id)
                        );
                  }
            }
            
header("Content-type: application/json");
            if (isset(
$errors)) {
                  echo 
json_encode(array(
                        
'errors' => $errors
                  
));
            } else {
                  echo 
json_encode($data);
            }
            exit();
      }
      if (
$s == 'update_app') {
            if (empty(
$_POST['app_name']) || empty($_POST['app_website_url']) || empty($_POST['app_description'])) {
                  
$errors[] = $error_icon $wo['lang']['please_check_details'];
            }
            if (!
filter_var($_POST['app_website_url'], FILTER_VALIDATE_URL)) {
                  
$errors[] = $error_icon $wo['lang']['website_invalid_characters'];
            }
            if (empty(
$errors)) {
                  
$app_id      $_POST['app_id'];
                  
$re_app_data = array(
                        
'app_user_id' => Wo_Secure($wo['user']['user_id']),
                        
'app_name' => Wo_Secure($_POST['app_name']),
                        
'app_website_url' => Wo_Secure($_POST['app_website_url']),
                        
'app_description' => Wo_Secure($_POST['app_description'])
                  );
                  if (
Wo_UpdateAppData($app_id$re_app_data) === true) {
                        if (!empty(
$_FILES["app_avatar"]["name"])) {
                              
Wo_UploadImage($_FILES["app_avatar"]["tmp_name"], $_FILES['app_avatar']['name'], 'app'$app_id);
                        }
                        
$img  Wo_GetApp($app_id);
                        
$data = array(
                              
'status' => 200,
                              
'message' => $wo['lang']['setting_updated'],
                              
'name' => $_POST['app_name'],
                              
'image' => $img['app_avatar']
                        );
                  }
            }
            
header("Content-type: application/json");
            if (isset(
$errors)) {
                  echo 
json_encode(array(
                        
'errors' => $errors
                  
));
            } else {
                  echo 
json_encode($data);
            }
            exit();
      }
      if (
$s == 'acceptPermissions') {
            
$acceptPermissions Wo_AcceptPermissions($_GET['id']);
            if (
$acceptPermissions === true) {
                  
$data = array(
                        
'status' => 200,
                        
'location' => $_GET['url']
                  );
            }
            
header("Content-type: application/json");
            echo 
json_encode($data);
            exit();
      }
}
if (
$f == 'pages') {
      if (
$s == 'create_page') {
            if (empty(
$_POST['page_name']) || empty($_POST['page_title'])) {
                  
$errors[] = $error_icon $wo['lang']['please_check_details'];
            } else {
                  if (
Wo_PageExists($_POST['page_name']) === true) {
                        
$errors[] = $error_icon $wo['lang']['page_name_exists'];
                  }
                  if (
strlen($_POST['page_name']) < OR strlen($_POST['page_name']) > 32) {
                        
$errors[] = $error_icon $wo['lang']['page_name_characters_length'];
                  }
                  if (!
preg_match('/^[w]+$/'$_POST['page_name'])) {
                        
$errors[] = $error_icon $wo['lang']['page_name_invalid_characters'];
                  }
                  if (empty(
$_POST['page_category'])) {
                        
$_POST['page_category'] = 1;
                  }
            }
            if (empty(
$errors)) {
                  
$re_page_data  = array(
                        
'page_name' => Wo_Secure($_POST['page_name']),
                        
'user_id' => Wo_Secure($wo['user']['user_id']),
                        
'page_title' => Wo_Secure($_POST['page_title']),
                        
'page_description' => Wo_Secure($_POST['page_description']),
                        
'page_category' => Wo_Secure($_POST['page_category']),
                        
'active' => '1'
                  
);
                  
$register_page Wo_RegisterPage($re_page_data);
                  if (
$register_page) {
                        
$data = array(
                              
'status' => 200,
                              
'location' => Wo_SeoLink('index.php?tab1=page&p=' Wo_Secure($_POST['page_name']))
                        );
                  }
            }
            
header("Content-type: application/json");
            if (isset(
$errors)) {
                  echo 
json_encode(array(
                        
'errors' => $errors
                  
));
            } else {
                  echo 
json_encode($data);
            }
            exit();
      }
      if (
$s == 'update_information_setting') {
            if (!empty(
$_POST['page_id'])) {
                  
$PageData Wo_PageData($_POST['page_id']);
                  if (!empty(
$_POST['website'])) {
                        if (!
filter_var($_POST['website'], FILTER_VALIDATE_URL)) {
                              
$errors[] = $error_icon $wo['lang']['website_invalid_characters'];
                        }
                  }
                  if (empty(
$errors)) {
                        
$Update_data = array(
                              
'facebook' => $_POST['facebook'],
                              
'website' => $_POST['website'],
                              
'google' => $_POST['google'],
                              
'page_description' => $_POST['page_description'],
                              
'twitter' => $_POST['twitter'],
                              
'linkedin' => $_POST['linkedin'],
                              
'vk' => $_POST['vk'],
                              
'company' => $_POST['company'],
                              
'address' => $_POST['address'],
                              
'phone' => $_POST['phone']
                        );
                        if (
Wo_UpdatePageData($_POST['page_id'], $Update_data)) {
                              
$data = array(
                                    
'status' => 200,
                                    
'message' => $success_icon $wo['lang']['setting_updated']
                              );
                        }
                  }
            }
            
header("Content-type: application/json");
            if (isset(
$errors)) {
                  echo 
json_encode(array(
                        
'errors' => $errors
                  
));
            } else {
                  echo 
json_encode($data);
            }
            exit();
      }
      if (
$s == 'update_general_settings') {
            if (!empty(
$_POST['page_id'])) {
                  
$PageData Wo_PageData($_POST['page_id']);
                  if (empty(
$_POST['page_name']) OR empty($_POST['page_category']) OR empty($_POST['page_title'])) {
                        
$errors[] = $error_icon ' Please Check the fields.';
                  } else {
                        if (
$_POST['page_name'] != $PageData['page_name']) {
                              if (
Wo_PageExists($_POST['page_name'])) {
                                    
$errors[] = $error_icon $wo['lang']['page_name_exists'];
                              }
                        }
                        if (
strlen($_POST['page_name']) < || strlen($_POST['page_name']) > 32) {
                              
$errors[] = $error_icon $wo['lang']['page_name_characters_length'];
                        }
                        if (!
preg_match('/^[w]+$/'$_POST['page_name'])) {
                              
$errors[] = $error_icon $wo['lang']['page_name_invalid_characters'];
                        }
                        if (empty(
$_POST['page_category'])) {
                              
$_POST['page_category'] = 1;
                        }
                        
$array    = array(
                              
'verified' => 1,
                              
'notVerified' => 0
                        
);
                        
$verified 0;
                        if (!empty(
$_POST['verified'])) {
                              if (
array_key_exists($_POST['verified'], $array)) {
                                    
$verified $array[$_POST['verified']];
                              }
                        }
                        if (empty(
$errors)) {
                              
$Update_data = array(
                                    
'page_name' => $_POST['page_name'],
                                    
'page_title' => $_POST['page_title'],
                                    
'page_category' => $_POST['page_category'],
                                    
'verified' => $verified
                              
);
                              if (
Wo_UpdatePageData($_POST['page_id'], $Update_data)) {
                                    
$data = array(
                                          
'status' => 200,
                                          
'message' => $success_icon $wo['lang']['setting_updated']
                                    );
                              }
                        }
                  }
            }
            
header("Content-type: application/json");
            if (isset(
$errors)) {
                  echo 
json_encode(array(
                        
'errors' => $errors
                  
));
            } else {
                  echo 
json_encode($data);
            }
            exit();
      }
      if (
$s == 'delete_page') {
            if (!empty(
$_POST['page_id'])) {
                  if (
md5($_POST['password']) != $wo['user']['password']) {
                        
$errors[] = $error_icon $wo['lang']['current_password_mismatch'];
                  }
                  if (empty(
$errors)) {
                        if (
Wo_DeletePage($_POST['page_id']) === true) {
                              
$data = array(
                                    
'status' => 200,
                                    
'message' => $success_icon ' Page deleted successfully',
                                    
'location' => Wo_SeoLink('index.php?tab1=pages')
                              );
                        }
                  }
            }
            
header("Content-type: application/json");
            if (isset(
$errors)) {
                  echo 
json_encode(array(
                        
'errors' => $errors
                  
));
            } else {
                  echo 
json_encode($data);
            }
            exit();
      }
      if (
$s == 'get_more_likes') {
            
$html '';
            if (isset(
$_GET['user_id']) && isset($_GET['after_last_id'])) {
                  foreach (
Wo_GetLikes($_GET['user_id'], 'profile'10$_GET['after_last_id']) as $wo['PageList']) {
                        
$html .= Wo_LoadPage('timeline/likes-list');
                  }
            }
            
$data = array(
                  
'status' => 200,
                  
'html' => $html
            
);
            
header("Content-type: application/json");
            echo 
json_encode($data);
            exit();
      }
      if (
$s == 'get_next_page') {
            
$html    '';
            
$page_id = (!empty($_GET['page_id'])) ? $_GET['page_id'] : 0;
            foreach (
Wo_PageSug(1$page_id) as $wo['PageList']) {
                  
$wo['PageList']['user_name'] = $wo['PageList']['name'];
                  
$html                        Wo_LoadPage('sidebar/sidebar-home-page-list');
            }
            
$data = array(
                  
'status' => 200,
                  
'html' => $html
            
);
            
header("Content-type: application/json");
            echo 
json_encode($data);
            exit();
      }
      if (
$s == 'get_likes') {
            
$html '';
            if (!empty(
$_GET['user_id'])) {
                  foreach (
Wo_GetLikes($_GET['user_id'], 'sidebar'12) as $wo['PageList']) {
                        
$wo['PageList']['user_name'] = @substr($wo['PageList']['name'], 010);
                        
$html .= Wo_LoadPage('sidebar/sidebar-page-list');
                  }
                  
$data = array(
                        
'status' => 200,
                        
'html' => $html
                  
);
            }
            
header("Content-type: application/json");
            echo 
json_encode($data);
            exit();
      }
}
if (
$f == 'like_page') {
      if (!empty(
$_GET['page_id'])) {
            if (
Wo_IsPageLiked($_GET['page_id'], $wo['user']['user_id']) === true) {
                  if (
Wo_DeletePageLike($_GET['page_id'], $wo['user']['user_id'])) {
                        
$data = array(
                              
'status' => 200,
                              
'html' => Wo_GetLikeButton($_GET['page_id'])
                        );
                  }
            } else {
                  if (
Wo_RegisterPageLike($_GET['page_id'], $wo['user']['user_id'])) {
                        
$data = array(
                              
'status' => 200,
                              
'html' => Wo_GetLikeButton($_GET['page_id'])
                        );
                  }
            }
      }
      
header("Content-type: application/json");
      echo 
json_encode($data);
      exit();
}
if (
$f == 'check_pagename') {
      if (isset(
$_GET['pagename'])) {
            
$pagename  Wo_Secure($_GET['pagename']);
            
$page_data Wo_PageData(Wo_PageIdFromPagename($_GET['pagename']));
            if (
$pagename == $page_data['page_name']) {
                  
$data['status']  = 200;
                  
$data['message'] = $wo['lang']['available'];
            } else if (
strlen($pagename) < 5) {
                  
$data['status']  = 400;
                  
$data['message'] = $wo['lang']['too_short'];
            } else if (
strlen($pagename) > 32) {
                  
$data['status']  = 500;
                  
$data['message'] = $wo['lang']['too_long'];
            } else if (!
preg_match('/^[w]+$/'$_GET['pagename'])) {
                  
$data['status']  = 600;
                  
$data['message'] = $wo['lang']['username_invalid_characters_2'];
            } else {
                  if (
Wo_PageExists($_GET['pagename']) === true) {
                        
$data['status']  = 300;
                        
$data['message'] = $wo['lang']['in_use'];
                  } else {
                        
$data['status']  = 200;
                        
$data['message'] = $wo['lang']['available'];
                  }
            }
      }
      
header("Content-type: application/json");
      echo 
json_encode($data);
      exit();
}
if (
$f == 'update_page_cover_picture') {
      if (isset(
$_FILES['cover']['name'])) {
            if (
Wo_UploadImage($_FILES["cover"]["tmp_name"], $_FILES['cover']['name'], 'cover'$_POST['page_id'], 'page')) {
                  
$img  Wo_PageData($_POST['page_id']);
                  
$data = array(
                        
'status' => 200,
                        
'img' => $img['cover']
                  );
            }
      }
      
header("Content-type: application/json");
      echo 
json_encode($data);
      exit();
}
if (
$f == 'update_page_avatar_picture') {
      if (isset(
$_FILES['avatar']['name'])) {
            if (
Wo_UploadImage($_FILES["avatar"]["tmp_name"], $_FILES['avatar']['name'], 'avatar'$_POST['page_id'], 'page')) {
                  
$img  Wo_PageData($_POST['page_id']);
                  
$data = array(
                        
'status' => 200,
                        
'img' => $img['avatar']
                  );
            }
      }
      
header("Content-type: application/json");
      echo 
json_encode($data);
      exit();
}
?>
Онлайн: 3
Реклама