Server : LiteSpeed
System : Linux terra.hostitbro.com 5.14.0-611.54.3.el9_7.x86_64 #1 SMP PREEMPT_DYNAMIC Thu May 7 16:31:24 EDT 2026 x86_64
User : outerorb ( 1091)
PHP Version : 8.1.34
Disable Function : mail
Directory :  /home2/outerorb/crm.outerorbittech.com/application/controllers/api/

📁 Create New:
⬆️ Upload File:
Current Dir [ Writable ] Root [ Writable ]


OR Upload from URL:
URL: Save as:

📄 File: Register.php

Path: /home2/outerorb/crm.outerorbittech.com/application/controllers/api/Register.php

Size: 21.57 KB

Permissions: 0664

<?php defined('BASEPATH') or exit('No direct script access allowed');

require APPPATH . 'libraries/REST_Controller.php';
header('Access-Control-Allow-Origin: *');

class Register extends REST_Controller
{
  function __construct()
  {
    parent::__construct();
    $this->load->helper('sms');
  }
  public function register_post()
  {
    $data = $this->input->post();
    if (!empty($data)) {

      $this->db->where('email', $data['email']);
      $this->db->or_where('mobile', $data['mobile']);
      $user = $this->db->get('register')->row_array();
      if (empty($user)) {
        $result = $this->Api_model->register($data);
        if ($result == true) {
          $this->response(['status' => true, 'message' => 'Registered Successfully'], REST_Controller::HTTP_OK);
        } else {
          $this->response([
            'status' => false,
            'message' => 'Not Done'
          ], REST_Controller::HTTP_OK);
        }
      } else {
        $this->response([
          'status' => false,
          'message' => 'You are Already Registered'
        ], REST_Controller::HTTP_OK);
      }
    } else {
      $this->response([
        'status' => false,
        'message' => 'Please Provide Complete Information'
      ], REST_Controller::HTTP_OK);
    }
  }
  public function login_post()
  {
    $data = $this->input->post();
    if (!empty($data)) {
      $us = $this->Api_model->add_login($data);
      if ($us == true) {
        if ($us['image'] != '') {
          $image = $us['image'];
        } else {
          $image = '';
        }
        $this->response([
          'status' => true, 'userid' => $us['id'], 'token' => $us['token'], 'reg_id' => $us['reg_id'], 'name' => $us['name'], 'username' => $us['username'], 'email' => $us['email'], 'image' => $image, 'mobile' => $us['mobile'], 'message' => 'Login successfully'
        ], REST_Controller::HTTP_OK);
      } else {
        $this->response([
          'status' => false,
          'message' => 'Invalid Login'
        ], REST_Controller::HTTP_OK);
      }
    } else {
      $this->response([
        'status' => false,
        'message' => 'Please Enter User name and Password'
      ], REST_Controller::HTTP_OK);
    }
  }
  public function varify_device_post()
  {
    $data = $this->input->post();
    if (!empty($data)) {
      $result = $this->Api_model->device_varify($data);
      if ($result == true) {
        $this->response([
          'status' => true,
        ], REST_Controller::HTTP_OK);
      } else {
        $this->response([
          'status' => false,
        ], REST_Controller::HTTP_OK);
      }
    } else {
      $this->response([
        'status' => false,
        'message' => 'Missing Data'
      ], REST_Controller::HTTP_OK);
    }
  }
  public function posts_post()
  {
    $data = $this->input->post();
    if (!empty($data)) {
      $user = $this->db->get_where('register', array('id' => $data['user_id'], 'status' => 1))->row_array();
      if (!empty($user)) {

        $result = $this->Api_model->save_post($data);
        if ($result == true) {
          $this->response('Post Add Successfully', REST_Controller::HTTP_OK);
        } else {
          $this->response(
            'Not Done',
            REST_Controller::HTTP_OK
          );
        }
      } else {
        $this->response(
          'You are Not Registered',
          REST_Controller::HTTP_OK
        );
      }
    } else {
      $this->response(
        'Please Provide Complete Information',
        REST_Controller::HTTP_OK
      );
    }
  }
  public function like_post()
  {
    $data = $this->input->post();
    if (!empty($data)) {
      $user = $this->db->get_where('register', array('id' => $data['user_id'], 'status' => 1))->row_array();
      if (!empty($user)) {
        $result = $this->Api_model->save_like($data);
        if ($result == true) {
          if ($result['status'] == 1) {
            $msg = 'like';
          } elseif ($result['status'] == 0) {
            $msg = 'Dislike';
          }
          $this->response(['status' => true, 'message' => $msg], REST_Controller::HTTP_OK);
        } else {
          $this->response([
            'status' => false,
            'message' => 'Not Done'
          ], REST_Controller::HTTP_OK);
        }
      } else {
        $this->response([
          'status' => false,
          'message' => 'You are Not Registered'
        ], REST_Controller::HTTP_OK);
      }
    } else {
      $this->response([
        'status' => false,
        'message' => 'Please Provide Complete Information'
      ], REST_Controller::HTTP_OK);
    }
  }
  public function myposts_post()
  {
    $data = $this->input->post();
    if (!empty($data)) {
      $user = $this->db->get_where('register', array('id' => $data['user_id'], 'status' => 1))->row_array();
      if (!empty($user)) {
        $result = $this->Api_model->myposts($data);
        if ($result == true) {
          foreach ($result as $rs) {
            $us_data = $this->db->get_where('register', array('id' => $rs['user_id'], 'status' => 1))->row_array();
            if ($rs['title'] != '') {
              $title = json_decode($rs['title']);
            } else {
              $title = '';
            }
            if ($rs['image'] != '') {
              $image = $rs['image'];
            } else {
              $image = '';
            }
            if ($rs['description'] != '') {
              $desc = json_decode($rs['description']);
            } else {
              $desc = '';
            }
            $ar[] = array(
              'userid' => $rs['user_id'], 'title' => $title, 'name' => $us_data['name'], 'username' => $us_data['username'], 'image' => $image, 'desciption' => $desc, 'status' => $rs['status'], 'created_at' => $rs['created_at'], 'type' => $rs['type']
            );
          }
          $this->response(['status' => true, 'data' => $ar], REST_Controller::HTTP_OK);
        } else {
          $this->response([
            'status' => false,
            'message' => 'No Data'
          ], REST_Controller::HTTP_OK);
        }
      } else {
        $this->response([
          'status' => false,
          'message' => 'You are Not Registered'
        ], REST_Controller::HTTP_OK);
      }
    } else {
      $this->response([
        'status' => false,
        'message' => 'Please Provide Complete Information'
      ], REST_Controller::HTTP_OK);
    }
  }
  public function comment_post()
  {
    $data = $this->input->post();
    if (!empty($data)) {
      $user = $this->db->get_where('register', array('id' => $data['user_id'], 'status' => 1))->row_array();
      if (!empty($user)) {
        $result = $this->Api_model->save_comment($data);
        if ($result == true) {
          $this->response([
            'status' => true, 'message' => 'comment Added Successfully'
          ], REST_Controller::HTTP_OK);
        } else {
          $this->response([
            'status' => false, 'message' => 'Not Done'
          ], REST_Controller::HTTP_OK);
        }
      } else {
        $this->response([
          'status' => false,
          'message' => 'You Are not Registered'
        ], REST_Controller::HTTP_OK);
      }
    } else {
      $this->response([
        'status' => false,
        'message' => 'Missing Data'
      ], REST_Controller::HTTP_OK);
    }
  }
  public function total_comment_post()
  {
    $data = $this->input->post();
    if (!empty($data['post_id'])) {
      $cmnt = $this->Api_model->total_comment($data);
      $result = $cmnt['result'];
      $total = $cmnt['total'];
      if (!empty($result)) {
        foreach ($result as $rs) {
          $user = $this->db->get_where('register', array('id' => $rs['user_id'], 'status' => 1))->row_array();
          if ($user['name'] != '') {
            $name = $user['name'];
          } else {
            $name = '';
          }
          if ($user['image'] != '') {
            $image = $user['image'];
          } else {
            $image = '';
          }
          $username = $user['username'];

          $ar[] = array(
            'name' => $name, 'username' => $username, 'image' => $image, 'message' => $rs['message'], 'created_at' => $rs['created_at'], 'status' => $rs['status']
          );
        }
        $this->response([
          'status' => true, 'data' => $ar, 'total' => $total
        ], REST_Controller::HTTP_OK);
      } else {
        $this->response([
          'status' => false, 'message' => 'Not Done'
        ], REST_Controller::HTTP_OK);
      }
    } else {
      $this->response([
        'status' => false, 'message' => 'Missing Data'
      ], REST_Controller::HTTP_OK);
    }
  }
  public function postviews_post()
  {
    $data = $this->input->post();
    if (!empty($data['user_id'] && $data['post_id'])) {
      $user = $this->db->get_where('register', array('id' => $data['user_id'], 'status' => 1))->row_array();
      if (!empty($user)) {
        $result = $this->Api_model->save_postviews($data);
        if ($result == true) {
          $this->response([
            'status' => true, 'message' => ' Views Add Successfully'
          ], REST_Controller::HTTP_OK);
        } else {
          $this->response([
            'status' => false, 'message' => 'Not Done'
          ], REST_Controller::HTTP_OK);
        }
      } else {
        $this->response([
          'status' => false,
          'message' => 'You Are not Registered'
        ], REST_Controller::HTTP_OK);
      }
    } else {
      $this->response([
        'status' => false,
        'message' => 'Missing Data'
      ], REST_Controller::HTTP_OK);
    }
  }
  public function total_like_post()
  {
    $data = $this->input->post();
    if (!empty($data['post_id'])) {
      $cmnt = $this->Api_model->total_like($data);
      $result = $cmnt['result'];
      $total = $cmnt['total'];
      $num =  $this->Master_model->thousandsCurrencyFormat($total);
      if (!empty($result)) {
        foreach ($result as $rs) {
          $user = $this->db->get_where('register', array('id' => $rs['user_id'], 'status' => 1))->row_array();
          if ($user['name'] != '') {
            $name = $user['name'];
          } else {
            $name = '';
          }
          if ($user['image'] != '') {
            $image = $user['image'];
          } else {
            $image = '';
          }
          $username = $user['username'];

          $ar[] = array(
            'name' => $name, 'username' => $username, 'image' => $image, 'created_at' => $rs['created_at'], 'status' => $rs['status']
          );
        }
        $this->response([
          'status' => true, 'data' => $ar, 'total' => $num
        ], REST_Controller::HTTP_OK);
      } else {
        $this->response([
          'status' => false, 'message' => 'Not Done'
        ], REST_Controller::HTTP_OK);
      }
    } else {
      $this->response([
        'status' => false, 'message' => 'Missing Data'
      ], REST_Controller::HTTP_OK);
    }
  }
  public function download_posts_post()
  {
    $data = $this->input->post();
    if (!empty($data['user_id'] && $data['post_id'])) {
      $user = $this->db->get_where('register', array('id' => $data['user_id'], 'status' => 1))->row_array();
      if (!empty($user)) {
        $result = $this->Api_model->download_posts($data);
        if ($result == true) {
          $this->response([
            'status' => true, 'message' => 'download Successfully'
          ], REST_Controller::HTTP_OK);
        } else {
          $this->response([
            'status' => false, 'message' => 'Not Done'
          ], REST_Controller::HTTP_OK);
        }
      } else {
        $this->response([
          'status' => false,
          'message' => 'You Are not Registered'
        ], REST_Controller::HTTP_OK);
      }
    } else {
      $this->response([
        'status' => false,
        'message' => 'Missing Data'
      ], REST_Controller::HTTP_OK);
    }
  }
  public function follow_request_post()
  {
    $data = $this->input->post();
    if (!empty($data['follow_id'] && $data['requested_id'])) {
      $user = $this->db->get_where('register', array('id' => $data['follow_id'], 'status' => 1))->row_array();
      if (!empty($user)) {
        $result = $this->Api_model->follow_request($data);
        if ($result == true) {
          $this->response([
            'status' => true, 'message' => 'Your Request Save Successfully'
          ], REST_Controller::HTTP_OK);
        } else {
          $this->response([
            'status' => false, 'message' => 'Not Done'
          ], REST_Controller::HTTP_OK);
        }
      } else {
        $this->response([
          'status' => false,
          'message' => 'Not Registered'
        ], REST_Controller::HTTP_OK);
      }
    } else {
      $this->response([
        'status' => false,
        'message' => 'Missing Data'
      ], REST_Controller::HTTP_OK);
    }
  }

  public function accept_request_post()
  {
    $data = $this->input->post();
    if (!empty($data['follow_id'] && $data['requested_id'])) {
      $user = $this->db->get_where('register', array('id' => $data['requested_id'], 'status' => 1))->row_array();
      if (!empty($user)) {
        $result = $this->Api_model->accept_request($data);
        if ($result == true) {
          $this->response([
            'status' => true, 'message' => 'Request Accepted'
          ], REST_Controller::HTTP_OK);
        } else {
          $this->response([
            'status' => false, 'message' => 'No Request'
          ], REST_Controller::HTTP_OK);
        }
      } else {
        $this->response([
          'status' => false,
          'message' => 'Not Registered'
        ], REST_Controller::HTTP_OK);
      }
    } else {
      $this->response([
        'status' => false,
        'message' => 'Missing Data'
      ], REST_Controller::HTTP_OK);
    }
  }

  public function homeposts_post()
  {
    $data = $this->input->post();
    if (!empty($data)) {
      $user = $this->db->get_where('register', array('id' => $data['user_id'], 'status' => 1))->row_array();
      if (!empty($user)) {
        $result = $this->Api_model->homeposts($data);
        if ($result == true) {
          $post = $result['post'];
          foreach ($post as $rs) {
            $us_data = $this->db->get_where('register', array('id' => $rs['user_id'], 'status' => 1))->row_array();
            if ($rs['title'] != '') {
              $title = json_decode($rs['title']);
            } else {
              $title = '';
            }
            if ($rs['image'] != '') {
              $image = $rs['image'];
            } else {
              $image = '';
            }
            if ($rs['description'] != '') {
              $desc = json_decode($rs['description']);
            } else {
              $desc = '';
            }
            $like = $this->Master_model->count_like($rs['id']);
            $lk =  $this->Master_model->thousandsCurrencyFormat($like);
            $comment = $this->Master_model->count_comment($rs['id']);
            $cmnt =  $this->Master_model->thousandsCurrencyFormat($comment);
            $views = $this->Master_model->count_views($rs['id']);
            $view =  $this->Master_model->thousandsCurrencyFormat($views);
            $dwnload = $this->Master_model->count_views($rs['id']);
            $download =  $this->Master_model->thousandsCurrencyFormat($dwnload);
            $ar[] = array(
              'id' => $rs['id'], 'userid' => $rs['user_id'], 'name' => $us_data['name'], 'username' => $us_data['username'], 'profile_pic' => $us_data['image'], 'title' => $title, 'image' => $image, 'desciption' => $desc, 'status' => $rs['status'], 'created_at' => $rs['created_at'], 'type' => $rs['type'],
              'like' => $lk, 'views' => $view, 'comment' => $cmnt, 'download' => $download
            );
          }
          $this->response(['status' => true, 'data' => $ar, 'nextpage' => $result['nextpage']], REST_Controller::HTTP_OK);
        } else {
          $this->response([
            'status' => false,

            'message' => 'Not Found'
          ], REST_Controller::HTTP_OK);
        }
      } else {
        $this->response([
          'status' => false,
          'message' => 'You are Not Registered'
        ], REST_Controller::HTTP_OK);
      }
    } else {
      $this->response([
        'status' => false,
        'message' => 'Please Provide Complete Information'
      ], REST_Controller::HTTP_OK);
    }
  }

  public function total_views_post()
  {
    $data = $this->input->post();
    if (!empty($data['post_id'] && $data['user_id'])) {
      $user = $this->db->get_where('register', array('id' => $data['user_id'], 'status' => 1))->row_array();
      if (!empty($user)) {
        $views = $this->Api_model->total_views($data);
        $result = $views['result'];
        $total = $views['total'];
        $num =  $this->Master_model->thousandsCurrencyFormat($total);
        if ($result == true) {
          $this->response([
            'status' => true, 'total' => $num
          ], REST_Controller::HTTP_OK);
        } else {
          $this->response([
            'status' => false, 'message' => 'No Data'
          ], REST_Controller::HTTP_OK);
        }
      } else {
        $this->response([
          'status' => false,
          'message' => 'Not Registered'
        ], REST_Controller::HTTP_OK);
      }
    } else {
      $this->response([
        'status' => false,
        'message' => 'Missing Data'
      ], REST_Controller::HTTP_OK);
    }
  }
  public function mobile_post()
  {
    $data = $this->input->post();
    if (!empty($data['mobile'] && $data['message'])) {
      $count = strlen($data['mobile']);
      if ($count == 10) {
        $user = $this->db->get_where('register', array('mobile' => $data['mobile'], 'status' => 1))->row_array();
        if (empty($user)) {
          //$mobile = $this->Api_model->save_mobile($data);
          $sms['mobile'] = $data['mobile'];
          $sms['message'] = $data['mobile'];
          $send =  send_sms($sms);
          if ($send == true) {
            $this->response([
              'status' => true, 'message' => 'OTP Send Successfully'
            ], REST_Controller::HTTP_OK);
          } else {
            $this->response([
              'status' => false, 'message' => 'Invalid Mobile Number'
            ], REST_Controller::HTTP_OK);
          }
        } else {
          $this->response([
            'status' => false, 'message' => 'This mobile Number is Already Exist'
          ], REST_Controller::HTTP_OK);
        }
      } else {
        $this->response([
          'status' => false, 'message' => 'Mobile Number Should be 10 digit'
        ], REST_Controller::HTTP_OK);
      }
    } else {
      $this->response([
        'status' => false,
        'message' => 'Empty Value'
      ], REST_Controller::HTTP_OK);
    }
  }
  public function blockuser_post()
  {
    $data = $this->input->post();
    if (!empty($data['block_id'] && $data['blocked_id'])) {
      $user = $this->db->get_where('block', array('id' => $data['block'], 'status' => 1))->row_array();
      if (!empty($user)) {
        $result = $this->Api_model->block_user($data);
        if ($result == true) {
          $this->response([
            'status' => true, 'message' => 'Blocked User'
          ], REST_Controller::HTTP_OK);
        } else {
          $this->response([
            'status' => false, 'message' => 'Try Again'
          ], REST_Controller::HTTP_OK);
        }
      } else {
        $this->response([
          'status' => false,
          'message' => 'Not Registered'
        ], REST_Controller::HTTP_OK);
      }
    } else {
      $this->response([
        'status' => false,
        'message' => 'Missing Data'
      ], REST_Controller::HTTP_OK);
    }
  }
  public function resetpassword_post()
  {
    $data = $this->input->post();
    if (!empty($data['mobile'] && $data['message'])) {
      $user = $this->db->get_where('register', array('mobile' => $data['mobile']))->row_array();
      if (!empty($user)) {
        $result = $this->Api_model->reset_pass($data);
        if ($result == true) {
          $this->response([
            'status' => true, 'message' => 'Otp Send Successfully', 'email' => $user['email'], 'password' => $user['password']
          ], REST_Controller::HTTP_OK);
        } else {
          $this->response([
            'status' => false, 'message' => 'Try Again'
          ], REST_Controller::HTTP_OK);
        }
      } else {
        $this->response([
          'status' => false,
          'message' => 'Invalid Mobile Number'
        ], REST_Controller::HTTP_OK);
      }
    } else {
      $this->response([
        'status' => false,
        'message' => 'Missing Data'
      ], REST_Controller::HTTP_OK);
    }
  }

  public function update_password_post()
  {
    $data = $this->input->post();
    if (!empty($data['mobile'] && $data['old_pass'] && $data['new_pass'])) {
      $add = $this->db->get_where('register', array('mobile' => $data['mobile']))->row_array();
      if (!empty($add)) {
        $pass =  $this->db->get_where('register', array('password' => $data['old_pass'],'mobile' => $data['mobile']))->row_array();
        if (!empty($pass)) {
          $msg = $this->Api_model->update_pass($data);
          if ($msg == true) {
            $this->response([
              'status' => True,
              'message' => 'Password Reset successfully'
            ], REST_Controller::HTTP_OK);
          } else {
            $this->response([
              'status' => false,
              'message' => 'Please Try Again!'
            ], REST_Controller::HTTP_OK);
          }
        } else {
          $this->response([
            'status' => false,
            'message' => 'Invalid Password'
          ], REST_Controller::HTTP_OK);
        }
      } else {
        $this->response([
          'status' => false,
          'message' => 'Invalid User'
        ], REST_Controller::HTTP_OK);
      }
    } else {
      $this->response([
        'status' => false,
        'message' => 'Misssing Data'
      ], REST_Controller::HTTP_OK);
    }
  }
}

← Back to Directory Edit File 🔒 Chmod

WP File Manager