Server IP : 108.163.255.210 / Your IP : 3.135.209.20 Web Server : Apache System : Linux blossom.urlnameserver.com 3.10.0-1160.80.1.el7.x86_64 #1 SMP Tue Nov 8 15:48:59 UTC 2022 x86_64 User : ( 1172) PHP Version : 7.2.34 Disable Function : eval,escapeshellarg,proc_close,proc_get_status,proc_nice,proc_open,symlink,system,pcntl_exec,getrusage,chown,chgp,closelog,openlog,syslog,define_syslog_variables,php_ini_loaded_file,getservbyname,getservbyport,posix_getgid,posix_getgrgid,proc_terminate,pfsockopen,apache_child_terminate,posix_mkfifo,posix_setpgid,posix_setuid,hypot,pg_host,pos,posix_access,posix_getcwd,posix_getservbyname,myshellexec,getpid,posix_getsid,posix_isatty,posix_kill,posix_mknod,posix_setgid,posix_setsid,posix_setuid,posix_times,posix_uname,ps_fill,posix_getpwuid,global,ini_restore,zip_open,zip_read,rar_open,bzopen,bzread,bzwrite,apache_get_modules,apache_get_version,phpversionphpinfo,php_ini_scanned_files,get_current_user,disk_total_space,diskfreespace,leak,imap_list,hypo,filedump,safe_mode,getmygid,apache_getenv,apache_setenv,bzread,bzwrite,bzopen,phpini,higlight_file,dos_conv,get_cwd,er_log,cmd,e_name,vdir,get_dir,only_read,ftok,ftpexec,posix_getpwnam,mysql_list_dbs,disk_free_space,session_save_path,confirm_phpdoc_compiled,zip_entry_rea,php_u,psockopen,crack_opendict,crack_getlastmessage,crack_closedict,crack_check,fpassthru,posix_get_last_error,posix_getlogin,posix_getgroups,posix_strerror,posix_getrlimit,posix_getpgrp,posix_getgrnam,pos,dl MySQL : OFF | cURL : ON | WGET : ON | Perl : ON | Python : ON | Sudo : ON | Pkexec : ON Directory : /home/unilinki/www/Intellilead/api/ |
Upload File : |
<?php function getDB() { $dbhost="localhost"; $dbuser="aetholq5_intelli"; $dbpass="intel@2017$#"; $dbname="aetholq5_intellilead"; $dbConnection = new PDO("mysql:host=$dbhost;dbname=$dbname", $dbuser, $dbpass); $dbConnection->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); return $dbConnection; } require_once './include/DbHandler.php'; require_once './include/FCM.php'; require './libs/Slim/Slim.php'; \Slim\Slim::registerAutoloader(); $app = new \Slim\Slim(); $app->response->headers->set('Content-Type', 'application/json'); // User id from db - Global Variable $user_id = NULL; define('LEAD_ASSIGNED','1'); define('LEAD_CONVERTED','2'); /** * ----------- METHODS WITHOUT AUTHENTICATION --------------------------------- */ /** * User Registration * url - /register * method - POST * params - name, email, password */ $app->post('/register', function() use ($app) { // check for required params verifyRequiredParams(array('name', 'email', 'password')); $response = array(); // reading post params $name = $app->request->post('name'); $email = $app->request->post('email'); $password = $app->request->post('password'); // validating email address //validateEmail($email); $db = new DbHandler(); $res = $db->createUser($name, $email, $password); if ($res == USER_CREATED_SUCCESSFULLY) { $response["error"] = false; $response["message"] = "You are successfully registered"; } else if ($res == USER_CREATE_FAILED) { $response["error"] = true; $response["message"] = "Oops! An error occurred while registereing"; } else if ($res == USER_ALREADY_EXISTED) { $response["error"] = true; $response["message"] = "Sorry, this email already existed"; } // echo json response echoRespnse(201, $response); }); /** * User Login * url - /login * method - POST * params - username, password */ $app->post('/login', function() use ($app) { // check for required params verifyRequiredParams(array('username', 'password')); // reading post params $username = $app->request()->post('username'); $password = $app->request()->post('password'); $response = array(); $db = new DbHandler(); // check for correct username and password if ($db->checkUserLogin($username, $password)) { // get the user by email $user = $db->getUserByUsername($username); if ($user != NULL) { $response["error"] = false; $response['name'] = $user['name']; $response['email'] = $user['email_id']; $response['role_id'] = $user['role_id']; $response['rep_head'] = $user['rep_head']; $response['user_id'] = $user['user_id']; $response['status'] = $user['status']; $response['image'] = $user['image']; $response['designation'] = $user['designation']; $response['user_type'] = $user['user_type']; $response['dept_id'] = $user['dept_id']; $response['company_id'] = $user['company_id']; $response['last_login'] = $user['last_login']; } else { // unknown error occurred $response['error'] = true; $response['message'] = "An error occurred. Please try again"; } } else { // user credentials are wrong $response['error'] = true; $response['message'] = 'Login failed. Incorrect credentials'; } echoRespnse(200, $response); }); /** * User List By ID * url - /login * method - GET * params - user_id */ $app->get('/user/:user_id+', function ($user_id) { $user = array(); $db = new DbHandler(); // fetch User $user = $db->getUserById($user_id); if (!empty($user['user'])) { $user['error'] = false; $user['message'] = 'User List Success'; } else { // unknown error occurred $user['error'] = true; $user['message'] = "User not found"; } echoRespnse(200, $user); }); /** * Lead details by lead id * url - /lead/lead_id * method - GET * params - lead_id */ $app->get('/lead/:lead_id+', function ($lead_id) { $lead = array(); $db = new DbHandler(); // fetch User $lead = $db->getLeadById($lead_id); if (!empty($lead['lead'])) { $lead['error'] = false; $lead['message'] = 'Lead List Success'; } else { // unknown error occurred $lead['error'] = true; $lead['message'] = "Lead not found"; } echoRespnse(200, $lead); }); /** * Lead details by lead id * url - /leads/ * method - GET * params - lead_id */ $app->get('/leads', function () { $leads = array(); $db = new DbHandler(); // fetch User $leads = $db->getLead(); if (!empty($leads['leads'])) { $leads['error'] = false; $leads['message'] = 'Leads List Success'; } else { // unknown error occurred $leads['error'] = true; $leads['message'] = "Lead not found"; } echoRespnse(200, $leads); }); /** * UnAssigned Sales Lead List by user id * url - /getSalesAssignLead/company_id/role_id/user_id * method - GET * params - cid,role,user_id */ $app->get('/getSalesAssignLead/:cid/:role/:user_id(/:status)+', function ($cid,$role=0,$user_id, $status = 0 ) { $SaleLead = array(); $db = new DbHandler(); // fetch User if($status=='1'){ //manage_sales_leads.php $SaleLead['SalesAssignedLead'] = $db->getSalesLeadByUserId($cid,$role,$user_id); }else if($status=='2'){ //view_sales_leads.php $SaleLead['SalesAssignedLead'] = $db->getAssignedSalesLeadByUserId($cid,$role,$user_id); }else{ //view_assign_sales_leads.php $SaleLead['SalesAssignedLead'] = $db->viewAssignedSalesLeadByUserId($cid,$user_id); } if (!empty($SaleLead['SalesAssignedLead'])) { $SaleLead['error'] = false; $SaleLead['message'] = 'Lead List Success'; } else { // unknown error occurred $SaleLead['error'] = true; $SaleLead['message'] = "Lead not found"; } echoRespnse(200, $SaleLead); }); /** * List of Users for Assigned Sales Lead * url - /getUsersForAssignLead/company_id/role_id/user_id * method - GET * params - cid,role,user_id */ $app->get('/getUsersForAssignLead/:cid/:role/:user_id', function ($cid,$role,$user_id) { $SaleLead = array(); $db = new DbHandler(); // fetch User $SaleLead['SalesUserforAssign'] = $db->getSalesUserforAssign($cid,$role,$user_id); if (!empty($SaleLead['SalesUserforAssign'])) { $SaleLead['error'] = false; $SaleLead['message'] = 'User List for assign lead Success'; } else { // unknown error occurred $SaleLead['error'] = true; $SaleLead['message'] = "User List for assign not found"; } echoRespnse(200, $SaleLead); }); $app->get('/archive(/:year(/:month(/:day)))+', function ($year = 2010, $month = 12, $day = 05){ echo sprintf('%s-%s-%s', $year, $month, $day); }); /** * Lead details by lead id * url - /history * method - GET * params - lead_id */ $app->get('/history/:cid/:lead_id', function ($lead_id,$cid) { $lead = array(); $db = new DbHandler(); // fetch User $lead = $db->getLeadHistoryById($lead_id,$cid); if (!empty($lead['lead_history'])) { $lead['error'] = false; $lead['message'] = 'Lead History Success'; } else { // unknown error occurred $lead['error'] = true; $lead['message'] = "Lead History not found"; } echoRespnse(200, $lead); }); /** * Lead details by User id * url - /Userhistory * method - GET * params - cid,user_id,lead_status,follow_time,datetime */ $app->get('/Userhistory/:cid/:user_id/:lead_status/:follow_time/:datetime', function ($cid,$user_id,$lead_status,$follow_time,$datetime) { $lead = array(); $db = new DbHandler(); // fetch User $lead = $db->getLeadHistoryByUserId($cid,$user_id,$lead_status,$follow_time,$datetime); if (!empty($lead['lead_history'])) { $lead['error'] = false; $lead['message'] = 'Lead History Success'; } else { // unknown error occurred $lead['error'] = true; $lead['message'] = "Lead History not found"; } echoRespnse(200, $lead); }); /** * Assign Sales Leads * url - /AssignSalesLeads * method - POST * params - cid,lead_id,role,userid,curr_userid,user_role_id */ $app->post('/AssignSalesLeads', function() use ($app) { // check for required params verifyRequiredParams(array('role', 'userid','curr_user_id')); // reading post params $cid = $app->request()->post('cid'); $role = $app->request()->post('role'); $user_id = $app->request()->post('userid'); $curr_userid = $app->request()->post('curr_user_id'); $lead_ids = $app->request()->post('lead_id'); $user_role_id = $app->request()->post('user_role_id'); //Assign Sales Leads $result = array(); $db = new DbHandler(); $result['message'] = $db->AssignSalesLead($cid,$curr_userid,$role,$user_id,$user_role_id,$lead_ids); $total_leads = count($lead_ids); $fcmSender = new FCMSender(); $token = $db->getTokenByUserid($user_id); $UserName = $db->getUserNameById($curr_userid); $data = array( 'type' => LEAD_ASSIGNED, 'desc' => $total_leads.' New leads is assigned to you by '.$UserName, 'title' => 'New lead assign' ); if (!empty($result)) { $result['error'] = false; $fcmSender->sendMessage($token, $data); } else { // unknown error occurred $result['error'] = true; } echoRespnse(200, $result); }); /** * Action for Sales Leads Done * url - /SalesLeadDone * method - POST * params - cid,userid,remarks,product,lead_status,lead_id,datetime,long,lat */ $app->post('/SalesLeadDone', function() use ($app) { // check for required params //verifyRequiredParams(array('remarks','lead_id','lead_status')); // reading post params $cid = $app->request()->post('cid'); $user_id = $app->request()->post('userid'); $remarks = $app->request()->post('remarks'); $product = $app->request()->post('product'); $lead_status = $app->request()->post('lead_status'); $lead_id = $app->request()->post('lead_id'); $lead_done = $app->request()->post('lead_done'); $datetime = date('Y-m-d H:i:s', time()); $long = $app->request()->post('long'); $lat = $app->request()->post('lat'); //Assign Sales Leads $result = array(); $db = new DbHandler(); //print_r($_POST); die; $result['message'] = $db->SalesLeadsDone($cid,$user_id,$remarks,$product,$lead_status,$lead_id,$datetime,$lead_done=1,$long,$lat); $lead = $db->getLeadById($lead_id); $name = $lead['name']; $lead_code = $lead['lead_code']; $fcmSender = new FCMSender(); $token = $db->getTokenByUserid($user_id); $UserName = $db->getUserNameById($user_id); $data = array( 'type' => LEAD_CONVERTED, 'desc' => $lead_code.' '.$name.' is marked as Converted by '.$UserName, 'title' => 'Lead Converted' ); if (!empty($result)) { $result['error'] = false; if($lead_status=='11'){ $fcmSender->sendMessage($token, $data); } } else { // unknown error occurred $result['error'] = true; } echoRespnse(200, $result); }); /** * Reassign Sales Leads * url - /ReassignSalesLeads * method - POST * params - lead_id,remark,userid,curr_userid */ $app->post('/ReassignSalesLeads', function() use ($app) { // check for required params verifyRequiredParams(array('remark', 'userid','curr_user_id')); // reading post params $cid = $app->request()->post('cid'); $remark = $app->request()->post('remark'); $user_id = $app->request()->post('userid'); $curr_userid = $app->request()->post('curr_user_id'); $lead_id = $app->request()->post('lead_id'); //Assign Sales Leads $result = array(); $db = new DbHandler(); $result['message'] = $db->ReassignSalesLead($cid,$curr_userid,$remark,$user_id,$lead_id); $total_leads = '1'; $fcmSender = new FCMSender(); $token = $db->getTokenByUserid($user_id); $UserName = $db->getUserNameById($curr_userid); $data = array( 'type' => LEAD_ASSIGNED, 'desc' => $total_leads.' New leads is assigned to you by '.$UserName, 'title' => 'New lead assign' ); if (!empty($result)) { $result['error'] = false; $fcmSender->sendMessage($token, $data); } else { // unknown error occurred $result['error'] = true; } echoRespnse(200, $result); }); /** * Action for Sales Leads * url - /ActionSalesLeads * method - POST * params - cid,userid,remarks,product,lead_status,lead_cat,lead_id,datetime,met_loc,tml */ $app->post('/ActionSalesLeads', function() use ($app) { // check for required params verifyRequiredParams(array('remarks','lead_id','lead_status')); // reading post params $cid = $app->request()->post('cid'); $user_id = $app->request()->post('userid'); $remarks = $app->request()->post('remarks'); $product = $app->request()->post('product'); $lead_status = $app->request()->post('lead_status'); $lead_cat = $app->request()->post('lead_cat'); $lead_id = $app->request()->post('lead_id'); $datetime = $app->request()->post('datetime'); $met_loc = $app->request()->post('met_loc'); $tml = $app->request()->post('tml'); $long = $app->request()->post('long'); $lat = $app->request()->post('lat'); //Assign Sales Leads $result = array(); $db = new DbHandler(); //print_r($_POST); die; $result['message'] = $db->ActionSalesLeads($cid,$user_id,$remarks,$product,$lead_status,$lead_cat,$lead_id,$datetime,$met_loc,$tml,$long,$lat); $lead = $db->getLeadById($lead_id); $name = $lead['name']; $lead_code = $lead['lead_code']; $fcmSender = new FCMSender(); $token = $db->getTokenByUserid($user_id); $UserName = $db->getUserNameById($user_id); $data = array( 'type' => LEAD_CONVERTED, 'desc' => $lead_code.' '.$name.' is marked as Converted by '.$UserName, 'title' => 'Lead Converted' ); if (!empty($result)) { $result['error'] = false; if($lead_status=='11'){ $fcmSender->sendMessage($token, $data); } } else { // unknown error occurred $result['error'] = true; } echoRespnse(200, $result); }); /** * Add Self Lead By User * url - /AddLead * method - POST * params - cid,role_id,user_id,rep_head,project_name,lead_status,source,name,email,mobile,phone,city,country,status,tsr,tol,msg,plan_to_buy,contacted_by,msg_date,interested,budget,high_lead,pref_loc,look_for,subject,other_detail */ $app->post('/AddLead', function() use ($app) { // reading post params $cid = $app->request()->post('cid'); $user_id = $app->request()->post('user_id'); $rep_head = $app->request()->post('rep_head'); $role = $app->request()->post('role_id'); $project_name = $app->request()->post('project_name'); $lead_status = $app->request()->post('lead_status'); $source = $app->request()->post('source'); $name = $app->request()->post('name'); $email = $app->request()->post('email'); $mobile = $app->request()->post('mobile'); $phone = $app->request()->post('phone'); $city = $app->request()->post('city'); $country = $app->request()->post('country'); $status = $app->request()->post('status'); $tol = $app->request()->post('tol'); $tsr = $app->request()->post('tsr'); $msg = $app->request()->post('msg'); $plan_to_buy = $app->request()->post('plan_to_buy'); $contacted_by = $app->request()->post('contacted_by'); $msg_date = $app->request()->post('msg_date'); $interested = $app->request()->post('interested'); $budget = $app->request()->post('budget'); $high_lead = $app->request()->post('high_lead'); $pref_loc = $app->request()->post('pref_loc'); $look_for = $app->request()->post('look_for'); $subject = $app->request()->post('subject'); $other_detail = $app->request()->post('other_detail'); //Assign Sales Leads $result = array(); $db = new DbHandler(); //print_r($_POST); die; $result['message'] = $db->ActionAddLead($cid,$role,$user_id,$rep_head,$project_name,$lead_status,$source,$name,$email,$mobile,$phone,$city,$country,$status,$tsr,$tol,$msg,$plan_to_buy,$contacted_by,$msg_date,$interested,$budget,$high_lead,$pref_loc,$look_for,$subject,$other_detail); if (!empty($result)) { $result['error'] = false; } else { // unknown error occurred $result['error'] = true; } echoRespnse(200, $result); }); /** * Delete Leads * url - /DeleteLead * method - POST * params - cid,userid,lead_id */ $app->post('/DeleteLead', function() use ($app) { // check for required params verifyRequiredParams(array('cid','lead_id','userid')); // reading post params $cid = $app->request()->post('cid'); $user_id = $app->request()->post('userid'); $lead_id = $app->request()->post('lead_id'); //Assign Sales Leads $result = array(); $db = new DbHandler(); $result['message'] = $db->DeleteLead($cid,$user_id,$lead_id); if (!empty($result)) { $result['error'] = false; } else { // unknown error occurred $result['error'] = true; } echoRespnse(200, $result); }); /** * Product List details by company id * url - /ProductList/ * method - GET * params - cid */ $app->get('/ProductList/:cid', function ($cid) { $ProductList = array(); $db = new DbHandler(); // fetch User $ProductList['products'] = $db->getProductList($cid); if (!empty($ProductList)) { $ProductList['error'] = false; $ProductList['message'] = 'Product List Success'; } else { // unknown error occurred $ProductList['error'] = true; $ProductList['message'] = "Product LIst not found"; } echoRespnse(200, $ProductList); }); /** * Project List details by company id * url - /ProjectList/ * method - GET * params - cid */ $app->get('/ProjectList/:cid', function ($cid) { $ProjectList = array(); $db = new DbHandler(); // fetch User $ProjectList['projects'] = $db->getProjectList($cid); if (!empty($ProjectList)) { $ProjectList['error'] = false; $ProjectList['message'] = 'Project List Success'; } else { // unknown error occurred $ProjectList['error'] = true; $ProjectList['message'] = "Project LIst not found"; } echoRespnse(200, $ProjectList); }); /** * Lead Category List details by company id * url - /LeadCatList/ * method - GET * params - cid */ $app->get('/LeadCatList(/:cid)', function ($cid=0) { $LeadCatList = array(); $db = new DbHandler(); // fetch User $LeadCatList['leadCategory'] = $db->getLeadCatList($cid); if (!empty($LeadCatList)) { $LeadCatList['error'] = false; $LeadCatList['message'] = 'Lead Category List Success'; } else { // unknown error occurred $LeadCatList['error'] = true; $LeadCatList['message'] = "Lead Category LIst not found"; } echoRespnse(200, $LeadCatList); }); $app->post('/books', function () { //Create book print_r($_POST); }); /** * Verifying required params posted or not */ function verifyRequiredParams($required_fields) { $error = false; $error_fields = ""; $request_params = array(); $request_params = $_REQUEST; // Handling PUT request params if ($_SERVER['REQUEST_METHOD'] == 'PUT') { $app = \Slim\Slim::getInstance(); parse_str($app->request()->getBody(), $request_params); } foreach ($required_fields as $field) { if (!isset($request_params[$field]) || strlen(trim($request_params[$field])) <= 0) { $error = true; $error_fields .= $field . ', '; } } if ($error) { // Required field(s) are missing or empty // echo error json and stop the app $response = array(); $app = \Slim\Slim::getInstance(); $response["error"] = true; $response["message"] = 'Required field(s) ' . substr($error_fields, 0, -2) . ' is missing or empty'; echoRespnse(400, $response); $app->stop(); } } /** * Update User token * url - /updateUsersTokenAPI/ * method - POST * params - userid,token */ $app->post('/updateUsersTokenAPI', function() use ($app) { // reading post params $user_id = $app->request()->post('userid'); $token = $app->request()->post('token'); //Update Users Token $UpdateUserToken = array(); $db = new DbHandler(); // fetch User $UpdateUserToken['userToken'] = $db->updateUsersToken($user_id,$token); if (!empty($UpdateUserToken)) { $UpdateUserToken['error'] = false; $UpdateUserToken['message'] = 'User Token Update.'; } else { // unknown error occurred $UpdateUserToken['error'] = true; $UpdateUserToken['message'] = "User Token not Update."; } echoRespnse(200, $UpdateUserToken); }); /** * Update User Password * url - /updateUsersTokenAPI/ * method - POST * params - userid,pass,oldpass */ $app->post('/updateUserPassAPI', function() use ($app) { // reading post params $user_id = $app->request()->post('userid'); $pass = $app->request()->post('pass'); $oldpass = $app->request()->post('oldpass'); //print_r($_POST); //Update Users Password $UpdateUserPass = array(); $db = new DbHandler(); // fetch User $UpdateUserPass['userPass'] = $db->updateUsersPass($user_id,$pass,$oldpass); if (!empty($UpdateUserPass)) { $UpdateUserPass['error'] = false; } else { // unknown error occurred $UpdateUserPass['error'] = true; } echoRespnse(200, $UpdateUserPass); }); /** * Update User Data * url - /updateUserDataAPI/ * method - POST * params - userid,pass,oldpass */ $app->post('/updateUserDataAPI', function() use ($app) { // reading post params $user_id = $app->request()->post('userid'); $mobile = $app->request()->post('mobile'); $image = $app->request()->post('image'); print_r($_POST); //Update Users Token $updateUsersData = array(); $db = new DbHandler(); // fetch User $updateUsersData['userData'] = $db->updateUsersData($user_id,$mobile,$image); if (!empty($updateUsersData)) { $updateUsersData['error'] = false; } else { // unknown error occurred $updateUsersData['error'] = true; } echoRespnse(200, $updateUsersData); }); $app->post('/FCMTEST', function() use ($app) { $fcmSender = new FCMSender(); $db = new DbHandler(); // reading post params $user_id = $app->request()->post('userid'); //$token = $app->request()->post('token'); $token = $db->getTokenByUserid($user_id); $UserName = $db->getUserNameById($user_id); //print_r($token); print_r($UserName); $data = array( 'body' => 'Body Of Notification', 'title' => 'Title Of Notification' ); $fcmSender->sendMessage($token, $data); }); /** * Validating email address */ function validateEmail($email) { $app = \Slim\Slim::getInstance(); if (!filter_var($email, FILTER_VALIDATE_EMAIL)) { $response["error"] = true; $response["message"] = 'Email address is not valid'; echoRespnse(400, $response); $app->stop(); } } /** * Echoing json response to client * @param String $status_code Http response code * @param Int $response Json response */ function echoRespnse($status_code, $response) { $app = \Slim\Slim::getInstance(); // Http response code $app->status($status_code); // setting response content type to json $app->contentType('application/json'); echo json_encode($response); } $app->run(); ?>