@@ -24,97 +24,97 @@ discard block |
||
| 24 | 24 | |
| 25 | 25 | //Parse user and rates array which we got in cdr xml |
| 26 | 26 | function parse_rates_array($xml_rate, $constant_array, $logger) { |
| 27 | - $rates_array = array(); |
|
| 27 | + $rates_array = array(); |
|
| 28 | 28 | |
| 29 | - //decode string using urldecode |
|
| 30 | - $xml_rate = urldecode($xml_rate); |
|
| 31 | - $xml_rate_array = explode("||", $xml_rate); |
|
| 29 | + //decode string using urldecode |
|
| 30 | + $xml_rate = urldecode($xml_rate); |
|
| 31 | + $xml_rate_array = explode("||", $xml_rate); |
|
| 32 | 32 | |
| 33 | - foreach ($xml_rate_array as $rate_key => $rate_value) { |
|
| 34 | - $rates_array = explode("|", $rate_value); |
|
| 33 | + foreach ($xml_rate_array as $rate_key => $rate_value) { |
|
| 34 | + $rates_array = explode("|", $rate_value); |
|
| 35 | 35 | |
| 36 | - $user_id_param = $rates_array[count($rates_array) - 1]; |
|
| 37 | - $user_id = (substr($user_id_param, 0, 3) == 'UID') ? substr($user_id_param, 3) : 0; |
|
| 36 | + $user_id_param = $rates_array[count($rates_array) - 1]; |
|
| 37 | + $user_id = (substr($user_id_param, 0, 3) == 'UID') ? substr($user_id_param, 3) : 0; |
|
| 38 | 38 | |
| 39 | - foreach ($rates_array as $key => $value) { |
|
| 40 | - $rates_array_info[$user_id][$constant_array[substr($value, 0, 3)]] = substr($value, 3); |
|
| 41 | - } |
|
| 42 | - } |
|
| 43 | - return $rates_array_info; |
|
| 39 | + foreach ($rates_array as $key => $value) { |
|
| 40 | + $rates_array_info[$user_id][$constant_array[substr($value, 0, 3)]] = substr($value, 3); |
|
| 41 | + } |
|
| 42 | + } |
|
| 43 | + return $rates_array_info; |
|
| 44 | 44 | } |
| 45 | 45 | |
| 46 | 46 | //Process package |
| 47 | 47 | function process_package($xml_cdr, $user_id, $rates_array, $logger, $db) { |
| 48 | - $duration = $xml_cdr->variables->duration; |
|
| 49 | - $xml_cdr->variables->package_id = 0; |
|
| 50 | - $flag = false; |
|
| 51 | - if ($duration > 0 && $xml_cdr->variables->call_direction == 'outbound') { |
|
| 52 | - $destination_number = $xml_cdr->variables->effective_destination_number; |
|
| 53 | - |
|
| 54 | - $number_len = strlen($destination_number); |
|
| 55 | - $number_loop_str = '('; |
|
| 56 | - while ($number_len > 0) { |
|
| 57 | - $number_loop_str .= " code='".substr($destination_number, 0, $number_len)."' OR "; |
|
| 58 | - $number_len -= 1; |
|
| 59 | - } |
|
| 60 | - $number_loop_str .= " code='--')"; |
|
| 61 | - |
|
| 62 | - $query = "SELECT A.id as package_id,code,includedseconds FROM tbl_package AS A ,tbl_package_codes AS B WHERE ".$number_loop_str." AND B.package_id = A.id AND A.ratecard_id=".$rates_array['ratecard_id']." AND A.status=0 AND A.is_del=0 ORDER BY length(code) DESC"; |
|
| 63 | - $logger->log("Package Query : ".$query); |
|
| 64 | - $res_package = $db->run($query); |
|
| 65 | - |
|
| 66 | - foreach ($res_package as $res_package_key => $package_info) { |
|
| 67 | - if (isset($package_info['package_id'])) { |
|
| 68 | - $query = "SELECT SUM(used_seconds) as used_seconds FROM tbl_package_usage WHERE code=".$package_info['code']." AND package_id=".$package_info['package_id']." AND user_id=".$user_id; |
|
| 69 | - $logger->log("Package usage Query : ".$query); |
|
| 70 | - $res_pkg_usg = $db->run($query); |
|
| 71 | - $package_usage_info = $res_pkg_usg[0]; |
|
| 72 | - |
|
| 73 | - $used_seconds = (isset($package_usage_info['used_seconds'])) ? $package_usage_info['used_seconds'] : 0; |
|
| 74 | - |
|
| 75 | - $logger->log("Included seconds : ".$package_info['includedseconds'].", Used seconds : ".$used_seconds); |
|
| 76 | - if ($package_info['includedseconds'] > $used_seconds) { |
|
| 77 | - $remaining_seconds = $package_info['includedseconds'] - ($duration + $used_seconds); |
|
| 78 | - if ($remaining_seconds > 0) { |
|
| 79 | - $dud_sec = $duration; |
|
| 80 | - $duration = 0; |
|
| 81 | - } else { |
|
| 82 | - $dud_sec = $duration - abs($remaining_seconds); |
|
| 83 | - $duration = abs($remaining_seconds); |
|
| 84 | - } |
|
| 85 | - $flag = true; |
|
| 86 | - $xml_cdr->variables->package_id = $package_info['package_id']; |
|
| 87 | - |
|
| 88 | - $query = "INSERT INTO tbl_package_usage (package_id,user_id,code,used_seconds) VALUES (".$package_info['package_id'].",".$user_id.",'".$package_info['code']."',".$dud_sec.") ON DUPLICATE KEY UPDATE used_seconds=used_seconds+".$dud_sec; |
|
| 89 | - $logger->log("Package Usage Query : ".$query); |
|
| 90 | - $db->run($query); |
|
| 91 | - |
|
| 92 | - break; |
|
| 93 | - } |
|
| 94 | - } |
|
| 95 | - } |
|
| 96 | - } |
|
| 97 | - return array($duration, $flag); |
|
| 48 | + $duration = $xml_cdr->variables->duration; |
|
| 49 | + $xml_cdr->variables->package_id = 0; |
|
| 50 | + $flag = false; |
|
| 51 | + if ($duration > 0 && $xml_cdr->variables->call_direction == 'outbound') { |
|
| 52 | + $destination_number = $xml_cdr->variables->effective_destination_number; |
|
| 53 | + |
|
| 54 | + $number_len = strlen($destination_number); |
|
| 55 | + $number_loop_str = '('; |
|
| 56 | + while ($number_len > 0) { |
|
| 57 | + $number_loop_str .= " code='".substr($destination_number, 0, $number_len)."' OR "; |
|
| 58 | + $number_len -= 1; |
|
| 59 | + } |
|
| 60 | + $number_loop_str .= " code='--')"; |
|
| 61 | + |
|
| 62 | + $query = "SELECT A.id as package_id,code,includedseconds FROM tbl_package AS A ,tbl_package_codes AS B WHERE ".$number_loop_str." AND B.package_id = A.id AND A.ratecard_id=".$rates_array['ratecard_id']." AND A.status=0 AND A.is_del=0 ORDER BY length(code) DESC"; |
|
| 63 | + $logger->log("Package Query : ".$query); |
|
| 64 | + $res_package = $db->run($query); |
|
| 65 | + |
|
| 66 | + foreach ($res_package as $res_package_key => $package_info) { |
|
| 67 | + if (isset($package_info['package_id'])) { |
|
| 68 | + $query = "SELECT SUM(used_seconds) as used_seconds FROM tbl_package_usage WHERE code=".$package_info['code']." AND package_id=".$package_info['package_id']." AND user_id=".$user_id; |
|
| 69 | + $logger->log("Package usage Query : ".$query); |
|
| 70 | + $res_pkg_usg = $db->run($query); |
|
| 71 | + $package_usage_info = $res_pkg_usg[0]; |
|
| 72 | + |
|
| 73 | + $used_seconds = (isset($package_usage_info['used_seconds'])) ? $package_usage_info['used_seconds'] : 0; |
|
| 74 | + |
|
| 75 | + $logger->log("Included seconds : ".$package_info['includedseconds'].", Used seconds : ".$used_seconds); |
|
| 76 | + if ($package_info['includedseconds'] > $used_seconds) { |
|
| 77 | + $remaining_seconds = $package_info['includedseconds'] - ($duration + $used_seconds); |
|
| 78 | + if ($remaining_seconds > 0) { |
|
| 79 | + $dud_sec = $duration; |
|
| 80 | + $duration = 0; |
|
| 81 | + } else { |
|
| 82 | + $dud_sec = $duration - abs($remaining_seconds); |
|
| 83 | + $duration = abs($remaining_seconds); |
|
| 84 | + } |
|
| 85 | + $flag = true; |
|
| 86 | + $xml_cdr->variables->package_id = $package_info['package_id']; |
|
| 87 | + |
|
| 88 | + $query = "INSERT INTO tbl_package_usage (package_id,user_id,code,used_seconds) VALUES (".$package_info['package_id'].",".$user_id.",'".$package_info['code']."',".$dud_sec.") ON DUPLICATE KEY UPDATE used_seconds=used_seconds+".$dud_sec; |
|
| 89 | + $logger->log("Package Usage Query : ".$query); |
|
| 90 | + $db->run($query); |
|
| 91 | + |
|
| 92 | + break; |
|
| 93 | + } |
|
| 94 | + } |
|
| 95 | + } |
|
| 96 | + } |
|
| 97 | + return array($duration, $flag); |
|
| 98 | 98 | } |
| 99 | 99 | |
| 100 | 100 | //Process user/vendor cdr |
| 101 | 101 | function do_cdr_process($xml_cdr, $debit, $cost, $vendor_cost, $rates_array, $parent_id = 0, $parent_rates, $carrier_rates_array, $logger, $db) { |
| 102 | - $query_string = "'".$xml_cdr->variables->uuid."','".$xml_cdr->variables->user_id."','".$xml_cdr->variables->entity_id."','".urldecode($xml_cdr->variables->effective_caller_id_name)."','".$xml_cdr->variables->effective_caller_id_number."','".$xml_cdr->variables->effective_destination_number."',".$xml_cdr->variables->duration.",'".$xml_cdr->variables->carrier_id."','".$xml_cdr->callflow[0]->caller_profile->originatee->originatee_caller_profile->network_addr."','".$xml_cdr->variables->sip_contact_host."','".$xml_cdr->variables->hangup_cause."','".urldecode($xml_cdr->variables->start_stamp)."',".$debit.",".$cost.",'".$xml_cdr->variables->vendor_id."',".$vendor_cost.",".$rates_array['ratecard_id'].",".$xml_cdr->variables->package_id.",'".$rates_array['code']."','".$rates_array['destination']."','".$rates_array['cost']."','".$parent_id."','".@$parent_rates['code']."','".@$parent_rates['destination']."','".@$parent_rates['cost']."','".@$carrier_rates_array['code']."','".@$carrier_rates_array['destination']."','".@$carrier_rates_array['cost']."','".$xml_cdr->variables->call_direction."','".urldecode($xml_cdr->variables->profile_start_stamp)."','".urldecode($xml_cdr->variables->answer_stamp)."','".urldecode($xml_cdr->variables->bridge_stamp)."','".urldecode($xml_cdr->variables->progress_stamp)."','".urldecode($xml_cdr->variables->progress_media_stamp)."','".urldecode($xml_cdr->variables->end_stamp)."',".$xml_cdr->variables->billmsec.",".$xml_cdr->variables->answermsec.",".$xml_cdr->variables->waitmsec.",".$xml_cdr->variables->progress_mediamsec.",".$xml_cdr->variables->flow_billmsec; |
|
| 102 | + $query_string = "'".$xml_cdr->variables->uuid."','".$xml_cdr->variables->user_id."','".$xml_cdr->variables->entity_id."','".urldecode($xml_cdr->variables->effective_caller_id_name)."','".$xml_cdr->variables->effective_caller_id_number."','".$xml_cdr->variables->effective_destination_number."',".$xml_cdr->variables->duration.",'".$xml_cdr->variables->carrier_id."','".$xml_cdr->callflow[0]->caller_profile->originatee->originatee_caller_profile->network_addr."','".$xml_cdr->variables->sip_contact_host."','".$xml_cdr->variables->hangup_cause."','".urldecode($xml_cdr->variables->start_stamp)."',".$debit.",".$cost.",'".$xml_cdr->variables->vendor_id."',".$vendor_cost.",".$rates_array['ratecard_id'].",".$xml_cdr->variables->package_id.",'".$rates_array['code']."','".$rates_array['destination']."','".$rates_array['cost']."','".$parent_id."','".@$parent_rates['code']."','".@$parent_rates['destination']."','".@$parent_rates['cost']."','".@$carrier_rates_array['code']."','".@$carrier_rates_array['destination']."','".@$carrier_rates_array['cost']."','".$xml_cdr->variables->call_direction."','".urldecode($xml_cdr->variables->profile_start_stamp)."','".urldecode($xml_cdr->variables->answer_stamp)."','".urldecode($xml_cdr->variables->bridge_stamp)."','".urldecode($xml_cdr->variables->progress_stamp)."','".urldecode($xml_cdr->variables->progress_media_stamp)."','".urldecode($xml_cdr->variables->end_stamp)."',".$xml_cdr->variables->billmsec.",".$xml_cdr->variables->answermsec.",".$xml_cdr->variables->waitmsec.",".$xml_cdr->variables->progress_mediamsec.",".$xml_cdr->variables->flow_billmsec; |
|
| 103 | 103 | |
| 104 | - $query = "INSERT INTO tbl_cdrs (uniqueid,user_id,entity_id,callerid_name,callerid_number,dstnum,duration,carrier_id,carrierip,callerip,disposition,start_stamp,debit,cost,vendor_id,vendor_cost,ratecard_id,package_id,rate_code,rate_code_destination,rate_cost,parent_id,parent_code,parent_code_destination,parent_cost,carrier_code,carrier_code_destination ,carrier_cost,call_direction,profile_start_stamp,answer_stamp,bridge_stamp,progress_stamp,progress_media_stamp,end_stamp,billmsec,answermsec,waitmsec,progress_mediamsec,flow_billmsec) values ($query_string)"; |
|
| 104 | + $query = "INSERT INTO tbl_cdrs (uniqueid,user_id,entity_id,callerid_name,callerid_number,dstnum,duration,carrier_id,carrierip,callerip,disposition,start_stamp,debit,cost,vendor_id,vendor_cost,ratecard_id,package_id,rate_code,rate_code_destination,rate_cost,parent_id,parent_code,parent_code_destination,parent_cost,carrier_code,carrier_code_destination ,carrier_cost,call_direction,profile_start_stamp,answer_stamp,bridge_stamp,progress_stamp,progress_media_stamp,end_stamp,billmsec,answermsec,waitmsec,progress_mediamsec,flow_billmsec) values ($query_string)"; |
|
| 105 | 105 | |
| 106 | - $logger->log("CDR Query : ".$query); |
|
| 107 | - $db->run($query); |
|
| 106 | + $logger->log("CDR Query : ".$query); |
|
| 107 | + $db->run($query); |
|
| 108 | 108 | } |
| 109 | 109 | |
| 110 | 110 | //Process reseller cdr |
| 111 | 111 | function do_reseller_cdr_process($xml_cdr, $debit, $cost, $rates_array, $parent_id = 0, $parent_rates, $logger, $db) { |
| 112 | - $query_string = "'".$xml_cdr->variables->uuid."','".$xml_cdr->variables->user_id."','".urldecode($xml_cdr->variables->effective_caller_id_name)."','".$xml_cdr->variables->effective_caller_id_number."','".$xml_cdr->variables->effective_destination_number."',".$xml_cdr->variables->duration.",'".$xml_cdr->variables->hangup_cause."','".urldecode($xml_cdr->variables->start_stamp)."',".$debit.",".$cost.",".$rates_array['ratecard_id'].",".$xml_cdr->variables->package_id.",'".$rates_array['code']."','".$rates_array['destination']."','".$rates_array['cost']."','".$parent_id."','".@$parent_rates['code']."','".@$parent_rates['destination']."','".@$parent_rates['cost']."','".$xml_cdr->variables->call_direction."'"; |
|
| 112 | + $query_string = "'".$xml_cdr->variables->uuid."','".$xml_cdr->variables->user_id."','".urldecode($xml_cdr->variables->effective_caller_id_name)."','".$xml_cdr->variables->effective_caller_id_number."','".$xml_cdr->variables->effective_destination_number."',".$xml_cdr->variables->duration.",'".$xml_cdr->variables->hangup_cause."','".urldecode($xml_cdr->variables->start_stamp)."',".$debit.",".$cost.",".$rates_array['ratecard_id'].",".$xml_cdr->variables->package_id.",'".$rates_array['code']."','".$rates_array['destination']."','".$rates_array['cost']."','".$parent_id."','".@$parent_rates['code']."','".@$parent_rates['destination']."','".@$parent_rates['cost']."','".$xml_cdr->variables->call_direction."'"; |
|
| 113 | 113 | |
| 114 | - $query = "INSERT INTO tbl_cdrs_reseller (uniqueid,reseller_id,callerid_name,callerid_number,dstnum,duration,disposition,start_stamp,debit,cost,ratecard_id,package_id,rate_code,rate_code_destination,rate_cost,parent_id,parent_code,parent_code_destination,parent_cost,call_direction) values ($query_string)"; |
|
| 114 | + $query = "INSERT INTO tbl_cdrs_reseller (uniqueid,reseller_id,callerid_name,callerid_number,dstnum,duration,disposition,start_stamp,debit,cost,ratecard_id,package_id,rate_code,rate_code_destination,rate_cost,parent_id,parent_code,parent_code_destination,parent_cost,call_direction) values ($query_string)"; |
|
| 115 | 115 | |
| 116 | - $logger->log("CDR Query : ".$query); |
|
| 117 | - $db->run($query); |
|
| 116 | + $logger->log("CDR Query : ".$query); |
|
| 117 | + $db->run($query); |
|
| 118 | 118 | } |
| 119 | 119 | |
| 120 | 120 | //Update user balance |
@@ -122,19 +122,19 @@ discard block |
||
| 122 | 122 | * @param integer $entity_id |
| 123 | 123 | */ |
| 124 | 124 | function update_balance($user_id, $amount, $entity_id, $logger, $db) { |
| 125 | - if ($amount > 0) { |
|
| 126 | - $math_sign = ($entity_id == 0 || $entity_id == 1) ? '-' : '+'; |
|
| 127 | - $query = "UPDATE tbl_users SET credit=credit$math_sign".$amount." WHERE id=".$user_id; |
|
| 128 | - $logger->log("Balance update : ".$query); |
|
| 129 | - $db->run($query); |
|
| 130 | - } |
|
| 125 | + if ($amount > 0) { |
|
| 126 | + $math_sign = ($entity_id == 0 || $entity_id == 1) ? '-' : '+'; |
|
| 127 | + $query = "UPDATE tbl_users SET credit=credit$math_sign".$amount." WHERE id=".$user_id; |
|
| 128 | + $logger->log("Balance update : ".$query); |
|
| 129 | + $db->run($query); |
|
| 130 | + } |
|
| 131 | 131 | } |
| 132 | 132 | |
| 133 | 133 | //Get user info |
| 134 | 134 | function get_user_info($parent_id, $db) { |
| 135 | - $query = "SELECT * FROM tbl_users WHERE id=".$parent_id; |
|
| 136 | - $res_user = $db->run($query); |
|
| 137 | - return $res_user[0]; |
|
| 135 | + $query = "SELECT * FROM tbl_users WHERE id=".$parent_id; |
|
| 136 | + $res_user = $db->run($query); |
|
| 137 | + return $res_user[0]; |
|
| 138 | 138 | } |
| 139 | 139 | |
| 140 | 140 | ?> |
@@ -23,61 +23,61 @@ |
||
| 23 | 23 | |
| 24 | 24 | class db extends PDO { |
| 25 | 25 | |
| 26 | - private $error; |
|
| 27 | - private $sql; |
|
| 28 | - private $bind; |
|
| 29 | - private $errorCallbackFunction; |
|
| 30 | - private $errorMsgFormat; |
|
| 26 | + private $error; |
|
| 27 | + private $sql; |
|
| 28 | + private $bind; |
|
| 29 | + private $errorCallbackFunction; |
|
| 30 | + private $errorMsgFormat; |
|
| 31 | 31 | |
| 32 | - public function __construct($dsn = "", $user = "", $passwd = "") { |
|
| 32 | + public function __construct($dsn = "", $user = "", $passwd = "") { |
|
| 33 | 33 | |
| 34 | - $config = parse_ini_file("/var/lib/astpp/astpp-config.conf"); |
|
| 34 | + $config = parse_ini_file("/var/lib/astpp/astpp-config.conf"); |
|
| 35 | 35 | |
| 36 | - $options = array( |
|
| 37 | - PDO::ATTR_PERSISTENT => true, |
|
| 38 | - PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION |
|
| 39 | - ); |
|
| 36 | + $options = array( |
|
| 37 | + PDO::ATTR_PERSISTENT => true, |
|
| 38 | + PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION |
|
| 39 | + ); |
|
| 40 | 40 | |
| 41 | - try { |
|
| 42 | - parent::__construct("mysql:host=".$config['dbhost'].";dbname=".$config['dbname']."", $config['dbuser'], $config['dbpass'], $options); |
|
| 43 | - } catch (PDOException $e) { |
|
| 41 | + try { |
|
| 42 | + parent::__construct("mysql:host=".$config['dbhost'].";dbname=".$config['dbname']."", $config['dbuser'], $config['dbpass'], $options); |
|
| 43 | + } catch (PDOException $e) { |
|
| 44 | 44 | |
| 45 | - $this->error = $e->getMessage(); |
|
| 46 | - } |
|
| 47 | - echo $this->error; |
|
| 48 | - } |
|
| 45 | + $this->error = $e->getMessage(); |
|
| 46 | + } |
|
| 47 | + echo $this->error; |
|
| 48 | + } |
|
| 49 | 49 | |
| 50 | - /** |
|
| 51 | - * @param string $bind |
|
| 52 | - */ |
|
| 53 | - public function cleanup($bind) { |
|
| 54 | - if ( ! is_array($bind)) { |
|
| 55 | - if ( ! empty($bind)) |
|
| 56 | - $bind = array($bind); |
|
| 57 | - else |
|
| 58 | - $bind = array(); |
|
| 59 | - } |
|
| 60 | - return $bind; |
|
| 61 | - } |
|
| 50 | + /** |
|
| 51 | + * @param string $bind |
|
| 52 | + */ |
|
| 53 | + public function cleanup($bind) { |
|
| 54 | + if ( ! is_array($bind)) { |
|
| 55 | + if ( ! empty($bind)) |
|
| 56 | + $bind = array($bind); |
|
| 57 | + else |
|
| 58 | + $bind = array(); |
|
| 59 | + } |
|
| 60 | + return $bind; |
|
| 61 | + } |
|
| 62 | 62 | |
| 63 | - public function run($sql, $bind = "") { |
|
| 64 | - $this->sql = trim($sql); |
|
| 65 | - $this->bind = $this->cleanup($bind); |
|
| 66 | - $this->error = ""; |
|
| 63 | + public function run($sql, $bind = "") { |
|
| 64 | + $this->sql = trim($sql); |
|
| 65 | + $this->bind = $this->cleanup($bind); |
|
| 66 | + $this->error = ""; |
|
| 67 | 67 | |
| 68 | - try { |
|
| 69 | - $pdostmt = $this->prepare($this->sql); |
|
| 70 | - if ($pdostmt->execute($this->bind) !== false) { |
|
| 71 | - if (preg_match("/^(".implode("|", array("select", "describe", "pragma")).") /i", $this->sql)) |
|
| 72 | - return $pdostmt->fetchAll(PDO::FETCH_ASSOC); |
|
| 73 | - elseif (preg_match("/^(".implode("|", array("delete", "insert", "update")).") /i", $this->sql)) |
|
| 74 | - return $pdostmt->rowCount(); |
|
| 75 | - } |
|
| 76 | - } catch (PDOException $e) { |
|
| 77 | - $this->error = $e->getMessage(); |
|
| 78 | - return $this->error; |
|
| 79 | - } |
|
| 80 | - } |
|
| 68 | + try { |
|
| 69 | + $pdostmt = $this->prepare($this->sql); |
|
| 70 | + if ($pdostmt->execute($this->bind) !== false) { |
|
| 71 | + if (preg_match("/^(".implode("|", array("select", "describe", "pragma")).") /i", $this->sql)) |
|
| 72 | + return $pdostmt->fetchAll(PDO::FETCH_ASSOC); |
|
| 73 | + elseif (preg_match("/^(".implode("|", array("delete", "insert", "update")).") /i", $this->sql)) |
|
| 74 | + return $pdostmt->rowCount(); |
|
| 75 | + } |
|
| 76 | + } catch (PDOException $e) { |
|
| 77 | + $this->error = $e->getMessage(); |
|
| 78 | + return $this->error; |
|
| 79 | + } |
|
| 80 | + } |
|
| 81 | 81 | |
| 82 | 82 | } |
| 83 | 83 | |
@@ -159,16 +159,16 @@ discard block |
||
| 159 | 159 | $dataVariable['call_direction'] = "inbound"; |
| 160 | 160 | $dataVariable['calltype'] = "DID"; |
| 161 | 161 | |
| 162 | - //Override variables if call for DID PSTN |
|
| 163 | - if(isset($dataVariable['caller_did_account_id'])) |
|
| 164 | - { |
|
| 165 | - $dataVariable['receiver_accid'] = $dataVariable['caller_did_account_id']; |
|
| 166 | - $dataVariable['call_direction'] = "outbound"; |
|
| 167 | - $dataVariable['calltype'] = "STANDARD"; |
|
| 168 | - $dataVariable['effective_destination_number']=$dataVariable['sip_to_user']; |
|
| 169 | - unset($termination_rate); |
|
| 170 | - unset($provider_cost); |
|
| 171 | - } |
|
| 162 | + //Override variables if call for DID PSTN |
|
| 163 | + if(isset($dataVariable['caller_did_account_id'])) |
|
| 164 | + { |
|
| 165 | + $dataVariable['receiver_accid'] = $dataVariable['caller_did_account_id']; |
|
| 166 | + $dataVariable['call_direction'] = "outbound"; |
|
| 167 | + $dataVariable['calltype'] = "STANDARD"; |
|
| 168 | + $dataVariable['effective_destination_number']=$dataVariable['sip_to_user']; |
|
| 169 | + unset($termination_rate); |
|
| 170 | + unset($provider_cost); |
|
| 171 | + } |
|
| 172 | 172 | |
| 173 | 173 | |
| 174 | 174 | |
@@ -316,7 +316,7 @@ discard block |
||
| 316 | 316 | //Generate CDR string for insert query for reseller |
| 317 | 317 | function get_reseller_cdr_string($dataVariable,$accountid,$account_type,$actual_duration,$termination_rate,$origination_rate,$provider_cost,$parentid,$debit,$cost) |
| 318 | 318 | { |
| 319 | - $dataVariable['calltype'] = ($dataVariable['calltype'] == 'DID-LOCAL' || $dataVariable['calltype'] == 'SIP-DID' || $dataVariable['calltype'] == 'OTHER')?"DID":$dataVariable['calltype']; |
|
| 319 | + $dataVariable['calltype'] = ($dataVariable['calltype'] == 'DID-LOCAL' || $dataVariable['calltype'] == 'SIP-DID' || $dataVariable['calltype'] == 'OTHER')?"DID":$dataVariable['calltype']; |
|
| 320 | 320 | $callerIdNumber = isset($dataVariable['effective_caller_id_number']) && !empty($dataVariable['effective_caller_id_number'])? $dataVariable['effective_caller_id_number'] :$dataVariable['caller_id']; |
| 321 | 321 | |
| 322 | 322 | return $cdr_string = "'".($dataVariable['uuid'])."','".$accountid."','".(urldecode($callerIdNumber))."','".($dataVariable['effective_destination_number'])."','".$actual_duration."','".($dataVariable['hangup_cause'])."','".convert_to_gmt(urldecode($dataVariable['callstart']))."','".$debit."','".$cost."','".$origination_rate[$accountid]['RATEGROUP']."','".$dataVariable['package_id']."','".($origination_rate[$accountid]['CODE'])."',".(($origination_rate[$accountid]['DESTINATION']) ? "'".$origination_rate[$accountid]['DESTINATION']."'" : "'".''."'").",".(($origination_rate[$accountid]['COST']) ? "'".$origination_rate[$accountid]['COST']."'" : "'".'0'."'").",'".$parentid."',".(($origination_rate[$parentid]['CODE'] ) ? "'".$origination_rate[$parentid]['CODE']."'" : "'".'0'."'").",".(($origination_rate[$parentid]['DESTINATION']) ? "'".$origination_rate[$parentid]['DESTINATION']."'" : "'".''."'").",".(($origination_rate[$parentid]['COST']) ? "'".$origination_rate[$parentid]['COST']."'" : '0').",".(($dataVariable['call_direction']) ? "'".$dataVariable['call_direction']."'" : "'internal'").",'".($dataVariable['calltype'])."'"; |
@@ -327,27 +327,27 @@ discard block |
||
| 327 | 327 | * @param integer $entity_id |
| 328 | 328 | */ |
| 329 | 329 | function update_balance($user_id, $amount, $entity_id, $logger, $db) { |
| 330 | - $math_sign = ($entity_id == 0 || $entity_id == 1) ? '-' : '+'; |
|
| 331 | - $query = "UPDATE accounts SET balance=balance-" . $amount . " WHERE id=" . $user_id; |
|
| 332 | - $logger->log("Balance update : " . $query); |
|
| 333 | - $db->run($query); |
|
| 330 | + $math_sign = ($entity_id == 0 || $entity_id == 1) ? '-' : '+'; |
|
| 331 | + $query = "UPDATE accounts SET balance=balance-" . $amount . " WHERE id=" . $user_id; |
|
| 332 | + $logger->log("Balance update : " . $query); |
|
| 333 | + $db->run($query); |
|
| 334 | 334 | } |
| 335 | 335 | |
| 336 | 336 | //Normalize rate string which we are getting from dialplan |
| 337 | 337 | function normalize_rate($dataVariable) |
| 338 | 338 | { |
| 339 | 339 | $rates = urldecode($dataVariable); |
| 340 | - $data = explode("|", $rates); |
|
| 340 | + $data = explode("|", $rates); |
|
| 341 | 341 | |
| 342 | 342 | $newarray = array(); |
| 343 | - foreach ($data as $key => $value) |
|
| 344 | - { |
|
| 345 | - $data1 = explode(":", $value); |
|
| 346 | - foreach ($data1 as $newkey => $newvalue) |
|
| 347 | - { |
|
| 348 | - $newarray[$data1[0]] = $data1[$newkey]; |
|
| 349 | - } |
|
| 350 | - } |
|
| 343 | + foreach ($data as $key => $value) |
|
| 344 | + { |
|
| 345 | + $data1 = explode(":", $value); |
|
| 346 | + foreach ($data1 as $newkey => $newvalue) |
|
| 347 | + { |
|
| 348 | + $newarray[$data1[0]] = $data1[$newkey]; |
|
| 349 | + } |
|
| 350 | + } |
|
| 351 | 351 | return $newarray; |
| 352 | 352 | } |
| 353 | 353 | |
@@ -6,12 +6,12 @@ |
||
| 6 | 6 | <meta http-equiv="X-UA-Compatible" content="IE=edge"> |
| 7 | 7 | <title> |
| 8 | 8 | <?php |
| 9 | - $this->db->where('domain',$_SERVER['HTTP_HOST']); |
|
| 10 | - $this->db->select('*'); |
|
| 11 | - $this->db->order_by('accountid', 'desc'); |
|
| 12 | - $this->db->limit(1); |
|
| 13 | - $invoiceconf = $this->db->get('invoice_conf'); |
|
| 14 | - $invoiceconf = (array)$invoiceconf->first_row(); |
|
| 9 | + $this->db->where('domain',$_SERVER['HTTP_HOST']); |
|
| 10 | + $this->db->select('*'); |
|
| 11 | + $this->db->order_by('accountid', 'desc'); |
|
| 12 | + $this->db->limit(1); |
|
| 13 | + $invoiceconf = $this->db->get('invoice_conf'); |
|
| 14 | + $invoiceconf = (array)$invoiceconf->first_row(); |
|
| 15 | 15 | if(isset($invoiceconf['website_title']) && $invoiceconf['website_title']!='') { |
| 16 | 16 | ?> |
| 17 | 17 | Log In | <?php echo $invoiceconf['website_title']; ?> |
@@ -24,77 +24,77 @@ discard block |
||
| 24 | 24 | |
| 25 | 25 | class Signup extends MX_Controller { |
| 26 | 26 | |
| 27 | - function signup() { |
|
| 28 | - parent::__construct(); |
|
| 29 | - $this->load->model('signup_model'); |
|
| 30 | - $this->load->helper('captcha'); |
|
| 31 | - $this->load->helper('template_inheritance'); |
|
| 32 | - //$this->load->library('form_validation'); |
|
| 33 | - $this->load->library('astpp/common'); |
|
| 34 | - $this->load->library('astpp/email_lib'); |
|
| 35 | - $this->load->model('db_model'); |
|
| 36 | - $this->load->model('common_model'); |
|
| 37 | - $this->load->library('session'); |
|
| 38 | - $this->load->library('encrypt'); |
|
| 39 | - $this->load->model('Astpp_common'); |
|
| 40 | - |
|
| 41 | - error_reporting(-1); |
|
| 42 | - ini_set('display_errors', 'On'); |
|
| 43 | - |
|
| 44 | - $data['row'] = $this->signup_model->get_rate(); |
|
| 45 | - } |
|
| 46 | - |
|
| 47 | - function index($key = "") { |
|
| 48 | - |
|
| 49 | - if (Common_model::$global_config['system_config']['enable_signup'] == 1) |
|
| 27 | + function signup() { |
|
| 28 | + parent::__construct(); |
|
| 29 | + $this->load->model('signup_model'); |
|
| 30 | + $this->load->helper('captcha'); |
|
| 31 | + $this->load->helper('template_inheritance'); |
|
| 32 | + //$this->load->library('form_validation'); |
|
| 33 | + $this->load->library('astpp/common'); |
|
| 34 | + $this->load->library('astpp/email_lib'); |
|
| 35 | + $this->load->model('db_model'); |
|
| 36 | + $this->load->model('common_model'); |
|
| 37 | + $this->load->library('session'); |
|
| 38 | + $this->load->library('encrypt'); |
|
| 39 | + $this->load->model('Astpp_common'); |
|
| 40 | + |
|
| 41 | + error_reporting(-1); |
|
| 42 | + ini_set('display_errors', 'On'); |
|
| 43 | + |
|
| 44 | + $data['row'] = $this->signup_model->get_rate(); |
|
| 45 | + } |
|
| 46 | + |
|
| 47 | + function index($key = "") { |
|
| 48 | + |
|
| 49 | + if (Common_model::$global_config['system_config']['enable_signup'] == 1) |
|
| 50 | 50 | { |
| 51 | - redirect(base_url()); |
|
| 51 | + redirect(base_url()); |
|
| 52 | 52 | } |
| 53 | 53 | |
| 54 | - $userCaptcha = $this->input->post('userCaptcha'); |
|
| 55 | - $random_number = substr(number_format(time() * rand(), 0, '', ''), 0, 6); |
|
| 56 | - $accountinfo = (array)$this->db->get_where('accounts', array('type'=>-1))->first_row(); |
|
| 57 | - $data['timezone_id'] = ( ! $accountinfo['timezone_id']) ? 1 : $accountinfo['timezone_id']; |
|
| 58 | - $data['currency_id'] = ( ! $accountinfo['currency_id']) ? 1 : $accountinfo['currency_id']; |
|
| 59 | - $data['country_id'] = ( ! $accountinfo['country_id']) ? 1 : $accountinfo['country_id']; |
|
| 60 | - |
|
| 61 | - $vals = array( |
|
| 62 | - 'word' => $random_number, |
|
| 63 | - 'img_path' => getcwd().'/assets/captcha/', |
|
| 64 | - 'img_url' => base_url().'assets/captcha/', |
|
| 65 | - //'font_path' => './fonts/impact.ttf', |
|
| 66 | - 'img_width' => '243', |
|
| 67 | - 'img_height' => '50', |
|
| 68 | - 'expiration' => '3600' |
|
| 69 | - ); |
|
| 70 | - |
|
| 71 | - if (isset($key) && $key != '') { |
|
| 72 | - $data['key_unique'] = $key; |
|
| 73 | - } else { |
|
| 74 | - $data['key_unique'] = "admin"; |
|
| 75 | - } |
|
| 76 | - $unique = $data['key_unique']; |
|
| 77 | - |
|
| 78 | - if ($unique != "admin") { |
|
| 79 | - $unique = $this->common->decode_params(trim($unique)); |
|
| 80 | - $decoded_str = $this->common->decode($unique); |
|
| 81 | - $unique = $decoded_str; |
|
| 82 | - $query = $this->db_model->getSelect("*", 'accounts', array('id' => $unique, "deleted" => "0")); |
|
| 83 | - if ($query->num_rows() == 0) { |
|
| 84 | - redirect(base_url()."signup/signup_inactive"); |
|
| 85 | - } |
|
| 86 | - if ($query->num_rows() > 0) { |
|
| 87 | - $query = $query->result_array(); |
|
| 88 | - $query = $query[0]; |
|
| 89 | - |
|
| 90 | - if ($query['status'] != 0) { |
|
| 91 | - redirect(base_url()."signup/signup_inactive"); |
|
| 92 | - } |
|
| 93 | - } |
|
| 94 | - } |
|
| 95 | - $data['captcha'] = create_captcha($vals); |
|
| 96 | - $this->session->set_userdata('captchaWord', $data['captcha']['word']); |
|
| 97 | - $this->db->select("*"); |
|
| 54 | + $userCaptcha = $this->input->post('userCaptcha'); |
|
| 55 | + $random_number = substr(number_format(time() * rand(), 0, '', ''), 0, 6); |
|
| 56 | + $accountinfo = (array)$this->db->get_where('accounts', array('type'=>-1))->first_row(); |
|
| 57 | + $data['timezone_id'] = ( ! $accountinfo['timezone_id']) ? 1 : $accountinfo['timezone_id']; |
|
| 58 | + $data['currency_id'] = ( ! $accountinfo['currency_id']) ? 1 : $accountinfo['currency_id']; |
|
| 59 | + $data['country_id'] = ( ! $accountinfo['country_id']) ? 1 : $accountinfo['country_id']; |
|
| 60 | + |
|
| 61 | + $vals = array( |
|
| 62 | + 'word' => $random_number, |
|
| 63 | + 'img_path' => getcwd().'/assets/captcha/', |
|
| 64 | + 'img_url' => base_url().'assets/captcha/', |
|
| 65 | + //'font_path' => './fonts/impact.ttf', |
|
| 66 | + 'img_width' => '243', |
|
| 67 | + 'img_height' => '50', |
|
| 68 | + 'expiration' => '3600' |
|
| 69 | + ); |
|
| 70 | + |
|
| 71 | + if (isset($key) && $key != '') { |
|
| 72 | + $data['key_unique'] = $key; |
|
| 73 | + } else { |
|
| 74 | + $data['key_unique'] = "admin"; |
|
| 75 | + } |
|
| 76 | + $unique = $data['key_unique']; |
|
| 77 | + |
|
| 78 | + if ($unique != "admin") { |
|
| 79 | + $unique = $this->common->decode_params(trim($unique)); |
|
| 80 | + $decoded_str = $this->common->decode($unique); |
|
| 81 | + $unique = $decoded_str; |
|
| 82 | + $query = $this->db_model->getSelect("*", 'accounts', array('id' => $unique, "deleted" => "0")); |
|
| 83 | + if ($query->num_rows() == 0) { |
|
| 84 | + redirect(base_url()."signup/signup_inactive"); |
|
| 85 | + } |
|
| 86 | + if ($query->num_rows() > 0) { |
|
| 87 | + $query = $query->result_array(); |
|
| 88 | + $query = $query[0]; |
|
| 89 | + |
|
| 90 | + if ($query['status'] != 0) { |
|
| 91 | + redirect(base_url()."signup/signup_inactive"); |
|
| 92 | + } |
|
| 93 | + } |
|
| 94 | + } |
|
| 95 | + $data['captcha'] = create_captcha($vals); |
|
| 96 | + $this->session->set_userdata('captchaWord', $data['captcha']['word']); |
|
| 97 | + $this->db->select("*"); |
|
| 98 | 98 | $this->db->where(array("domain"=>$_SERVER["HTTP_HOST"])); |
| 99 | 99 | $res = $this->db->get("invoice_conf"); |
| 100 | 100 | $logo_arr = $res->result(); |
@@ -105,398 +105,398 @@ discard block |
||
| 105 | 105 | $this->session->set_userdata('user_logo', $data['user_logo']); |
| 106 | 106 | $this->session->set_userdata('user_header', $data['website_header']); |
| 107 | 107 | $this->session->set_userdata('user_footer', $data['website_footer']); |
| 108 | - $this->load->view('view_signup', $data); |
|
| 109 | - } |
|
| 110 | - |
|
| 111 | - public function check_captcha($str) { |
|
| 112 | - $word = $this->session->userdata('captchaWord'); |
|
| 113 | - if (strcmp(strtoupper($str), strtoupper($word)) == 0) { |
|
| 114 | - return true; |
|
| 115 | - } else { |
|
| 116 | - $this->form_validation->set_message('check_captcha', 'Please enter correct words!'); |
|
| 117 | - return false; |
|
| 118 | - } |
|
| 119 | - } |
|
| 120 | - |
|
| 121 | - function terms_check() { |
|
| 122 | - if (isset($_POST['agreeCheck'])) { |
|
| 123 | - return true; |
|
| 124 | - } |
|
| 125 | - $this->form_validation->set_message('terms_check', 'THIS IS SOOOOO REQUIRED, DUDE!'); |
|
| 126 | - return false; |
|
| 127 | - } |
|
| 128 | - |
|
| 129 | - function signup_save($id = "") { |
|
| 130 | - if (empty($_POST)) { |
|
| 131 | - redirect(base_url()."signup/"); |
|
| 132 | - } else { |
|
| 133 | - $post_values = $this->input->post(); |
|
| 134 | - $userCaptcha = $this->input->post('userCaptcha'); |
|
| 135 | - $cnt_result = $this->db_model->countQuery("*", 'accounts', array('email' => $post_values['email'])); |
|
| 136 | - |
|
| 137 | - if ($userCaptcha != $this->session->userdata('captchaWord') || ! filter_var($this->input->post('email'), FILTER_VALIDATE_EMAIL) || $cnt_result > 0) { |
|
| 138 | - if ( ! filter_var($this->input->post('email'), FILTER_VALIDATE_EMAIL)) { |
|
| 139 | - $data['error']['email'] = "<div style='color: red;'> Please enter proper email </div>"; |
|
| 140 | - } |
|
| 141 | - if ($userCaptcha != $this->session->userdata('captchaWord')) { |
|
| 142 | - $data['error']['userCaptcha'] = "<div style='color: red;'>Please enter valid Captcha code</div>"; |
|
| 143 | - } |
|
| 144 | - if ($cnt_result > 0) { |
|
| 145 | - $data['error']['email'] = "<div style='color: red;'>Email Address already exists</div>"; |
|
| 146 | - } |
|
| 147 | - $random_number = substr(number_format(time() * rand(), 0, '', ''), 0, 6); |
|
| 148 | - $vals = array( |
|
| 149 | - 'word' => $random_number, |
|
| 150 | - 'img_path' => getcwd().'/assets/captcha/', |
|
| 151 | - 'img_url' => base_url().'assets/captcha/', |
|
| 152 | - //'font_path' => './fonts/impact.ttf', |
|
| 153 | - 'img_width' => '243', |
|
| 154 | - 'img_height' => '50', |
|
| 155 | - 'expiration' => '3600' |
|
| 156 | - ); |
|
| 157 | - //echo "<pre>"; print_r($_POST); exit; |
|
| 158 | - if (isset($_POST['key_unique']) && $_POST['key_unique'] == "admin") { |
|
| 159 | - $data['key_unique'] = $_POST['key_unique']; |
|
| 160 | - } |
|
| 108 | + $this->load->view('view_signup', $data); |
|
| 109 | + } |
|
| 110 | + |
|
| 111 | + public function check_captcha($str) { |
|
| 112 | + $word = $this->session->userdata('captchaWord'); |
|
| 113 | + if (strcmp(strtoupper($str), strtoupper($word)) == 0) { |
|
| 114 | + return true; |
|
| 115 | + } else { |
|
| 116 | + $this->form_validation->set_message('check_captcha', 'Please enter correct words!'); |
|
| 117 | + return false; |
|
| 118 | + } |
|
| 119 | + } |
|
| 120 | + |
|
| 121 | + function terms_check() { |
|
| 122 | + if (isset($_POST['agreeCheck'])) { |
|
| 123 | + return true; |
|
| 124 | + } |
|
| 125 | + $this->form_validation->set_message('terms_check', 'THIS IS SOOOOO REQUIRED, DUDE!'); |
|
| 126 | + return false; |
|
| 127 | + } |
|
| 128 | + |
|
| 129 | + function signup_save($id = "") { |
|
| 130 | + if (empty($_POST)) { |
|
| 131 | + redirect(base_url()."signup/"); |
|
| 132 | + } else { |
|
| 133 | + $post_values = $this->input->post(); |
|
| 134 | + $userCaptcha = $this->input->post('userCaptcha'); |
|
| 135 | + $cnt_result = $this->db_model->countQuery("*", 'accounts', array('email' => $post_values['email'])); |
|
| 136 | + |
|
| 137 | + if ($userCaptcha != $this->session->userdata('captchaWord') || ! filter_var($this->input->post('email'), FILTER_VALIDATE_EMAIL) || $cnt_result > 0) { |
|
| 138 | + if ( ! filter_var($this->input->post('email'), FILTER_VALIDATE_EMAIL)) { |
|
| 139 | + $data['error']['email'] = "<div style='color: red;'> Please enter proper email </div>"; |
|
| 140 | + } |
|
| 141 | + if ($userCaptcha != $this->session->userdata('captchaWord')) { |
|
| 142 | + $data['error']['userCaptcha'] = "<div style='color: red;'>Please enter valid Captcha code</div>"; |
|
| 143 | + } |
|
| 144 | + if ($cnt_result > 0) { |
|
| 145 | + $data['error']['email'] = "<div style='color: red;'>Email Address already exists</div>"; |
|
| 146 | + } |
|
| 147 | + $random_number = substr(number_format(time() * rand(), 0, '', ''), 0, 6); |
|
| 148 | + $vals = array( |
|
| 149 | + 'word' => $random_number, |
|
| 150 | + 'img_path' => getcwd().'/assets/captcha/', |
|
| 151 | + 'img_url' => base_url().'assets/captcha/', |
|
| 152 | + //'font_path' => './fonts/impact.ttf', |
|
| 153 | + 'img_width' => '243', |
|
| 154 | + 'img_height' => '50', |
|
| 155 | + 'expiration' => '3600' |
|
| 156 | + ); |
|
| 157 | + //echo "<pre>"; print_r($_POST); exit; |
|
| 158 | + if (isset($_POST['key_unique']) && $_POST['key_unique'] == "admin") { |
|
| 159 | + $data['key_unique'] = $_POST['key_unique']; |
|
| 160 | + } |
|
| 161 | 161 | |
| 162 | 162 | $accountinfo = (array)$this->db->get_where('accounts', array('type'=>-1))->first_row(); |
| 163 | 163 | $data['timezone_id'] = ( ! $accountinfo['timezone_id']) ? 1 : $accountinfo['timezone_id']; |
| 164 | 164 | $data['currency_id'] = ( ! $accountinfo['currency_id']) ? 1 : $accountinfo['currency_id']; |
| 165 | 165 | $data['country_id'] = ( ! $accountinfo['country_id']) ? 1 : $accountinfo['country_id']; |
| 166 | 166 | |
| 167 | - $data['timezone_id'] = ( ! $data['timezone_id']) ? 1 : $data['timezone_id']; |
|
| 168 | - $data['currency_id'] = ( ! $data['currency_id']) ? 1 : $data['currency_id']; |
|
| 169 | - $data['country_id'] = ( ! $data['country_id']) ? 1 : $data['country_id']; |
|
| 167 | + $data['timezone_id'] = ( ! $data['timezone_id']) ? 1 : $data['timezone_id']; |
|
| 168 | + $data['currency_id'] = ( ! $data['currency_id']) ? 1 : $data['currency_id']; |
|
| 169 | + $data['country_id'] = ( ! $data['country_id']) ? 1 : $data['country_id']; |
|
| 170 | 170 | |
| 171 | - $data['value'] = $post_values; |
|
| 172 | - $data['captcha'] = create_captcha($vals); |
|
| 171 | + $data['value'] = $post_values; |
|
| 172 | + $data['captcha'] = create_captcha($vals); |
|
| 173 | 173 | |
| 174 | - $this->session->set_userdata('captchaWord', $data['captcha']['word']); |
|
| 175 | - $data['key_unique'] = $_POST['key_unique']; |
|
| 176 | - $this->load->view('view_signup', $data); |
|
| 177 | - } else { |
|
| 178 | - //AVTLATP |
|
| 179 | - $user_data = $this->input->post(); |
|
| 174 | + $this->session->set_userdata('captchaWord', $data['captcha']['word']); |
|
| 175 | + $data['key_unique'] = $_POST['key_unique']; |
|
| 176 | + $this->load->view('view_signup', $data); |
|
| 177 | + } else { |
|
| 178 | + //AVTLATP |
|
| 179 | + $user_data = $this->input->post(); |
|
| 180 | 180 | |
| 181 | - if ( ! isset($_POST['key_unique']) || ! isset($_POST['email'])) { |
|
| 182 | - redirect(base_url()."signup/"); |
|
| 183 | - } |
|
| 184 | - $reseller_id = 0; |
|
| 185 | - if (isset($_POST['key_unique']) && $_POST['key_unique'] != "admin") { |
|
| 186 | - $_POST['key_unique'] = $this->common->decode_params(trim($_POST['key_unique'])); |
|
| 187 | - $decoded_str = $this->common->decode($_POST['key_unique']); |
|
| 188 | - $_POST['key_unique'] = $decoded_str; |
|
| 189 | - $user_data['key_unique'] = $_POST['key_unique']; |
|
| 190 | - $reseller_id = $user_data['key_unique']; |
|
| 191 | - } |
|
| 192 | - //echo "<pre>"; print_r($_POST); exit; |
|
| 193 | - //AVTLATP |
|
| 194 | - //Data want to insert or update |
|
| 195 | - $user_data['status'] = "1"; |
|
| 196 | - $user_data['number'] = $this->common->find_uniq_rendno_customer(common_model::$global_config['system_config']['cardlength'], 'number', 'accounts'); |
|
| 197 | - |
|
| 198 | - $user_data['password'] = $this->common->encode($this->common->generate_password()); |
|
| 199 | - $user_data['pin'] = $this->common->generate_password(); |
|
| 200 | - $user_data['reseller_id'] = $reseller_id; |
|
| 201 | - $user_data['posttoexternal'] = "0"; |
|
| 202 | - |
|
| 203 | - unset($user_data['userCaptcha']); |
|
| 204 | - unset($user_data['action']); |
|
| 205 | - |
|
| 206 | - $system_config = common_model::$global_config['system_config']; |
|
| 207 | - $balance = $system_config["balance"]; |
|
| 208 | - |
|
| 209 | - /* $query = $this->db_model->getSelect("*", 'invoice_conf ', array('id' => $unique ,"deleted" => "0")); |
|
| 181 | + if ( ! isset($_POST['key_unique']) || ! isset($_POST['email'])) { |
|
| 182 | + redirect(base_url()."signup/"); |
|
| 183 | + } |
|
| 184 | + $reseller_id = 0; |
|
| 185 | + if (isset($_POST['key_unique']) && $_POST['key_unique'] != "admin") { |
|
| 186 | + $_POST['key_unique'] = $this->common->decode_params(trim($_POST['key_unique'])); |
|
| 187 | + $decoded_str = $this->common->decode($_POST['key_unique']); |
|
| 188 | + $_POST['key_unique'] = $decoded_str; |
|
| 189 | + $user_data['key_unique'] = $_POST['key_unique']; |
|
| 190 | + $reseller_id = $user_data['key_unique']; |
|
| 191 | + } |
|
| 192 | + //echo "<pre>"; print_r($_POST); exit; |
|
| 193 | + //AVTLATP |
|
| 194 | + //Data want to insert or update |
|
| 195 | + $user_data['status'] = "1"; |
|
| 196 | + $user_data['number'] = $this->common->find_uniq_rendno_customer(common_model::$global_config['system_config']['cardlength'], 'number', 'accounts'); |
|
| 197 | + |
|
| 198 | + $user_data['password'] = $this->common->encode($this->common->generate_password()); |
|
| 199 | + $user_data['pin'] = $this->common->generate_password(); |
|
| 200 | + $user_data['reseller_id'] = $reseller_id; |
|
| 201 | + $user_data['posttoexternal'] = "0"; |
|
| 202 | + |
|
| 203 | + unset($user_data['userCaptcha']); |
|
| 204 | + unset($user_data['action']); |
|
| 205 | + |
|
| 206 | + $system_config = common_model::$global_config['system_config']; |
|
| 207 | + $balance = $system_config["balance"]; |
|
| 208 | + |
|
| 209 | + /* $query = $this->db_model->getSelect("*", 'invoice_conf ', array('id' => $unique ,"deleted" => "0")); |
|
| 210 | 210 | $query = $query->result_array(); */ |
| 211 | 211 | |
| 212 | - $company_website = $system_config["company_website"]; |
|
| 213 | - $company_name = $system_config["company_name"]; |
|
| 212 | + $company_website = $system_config["company_website"]; |
|
| 213 | + $company_name = $system_config["company_name"]; |
|
| 214 | 214 | |
| 215 | - //echo $company_name; exit; |
|
| 216 | - $selection_rategroup_signup = $system_config["default_signup_rategroup"]; |
|
| 215 | + //echo $company_name; exit; |
|
| 216 | + $selection_rategroup_signup = $system_config["default_signup_rategroup"]; |
|
| 217 | 217 | |
| 218 | - if ($reseller_id != 0) { |
|
| 219 | - $result = $this->db_model->getSelect("*", "pricelists", array("reseller_id" => $reseller_id), "ASC"); |
|
| 220 | - $result_arr = $result->result_array(); |
|
| 221 | - $selection_rategroup_signup = $result_arr[0]['id']; |
|
| 222 | - $user_data['pricelist_id'] = (isset($selection_rategroup_signup) && $selection_rategroup_signup > 0) ? $selection_rategroup_signup : 0; |
|
| 223 | - } else { |
|
| 224 | - $pricelist_id = $this->common->get_field_name('id', 'pricelists', array('name' => $selection_rategroup_signup)); |
|
| 225 | - /* if($pricelis_id != "") |
|
| 218 | + if ($reseller_id != 0) { |
|
| 219 | + $result = $this->db_model->getSelect("*", "pricelists", array("reseller_id" => $reseller_id), "ASC"); |
|
| 220 | + $result_arr = $result->result_array(); |
|
| 221 | + $selection_rategroup_signup = $result_arr[0]['id']; |
|
| 222 | + $user_data['pricelist_id'] = (isset($selection_rategroup_signup) && $selection_rategroup_signup > 0) ? $selection_rategroup_signup : 0; |
|
| 223 | + } else { |
|
| 224 | + $pricelist_id = $this->common->get_field_name('id', 'pricelists', array('name' => $selection_rategroup_signup)); |
|
| 225 | + /* if($pricelis_id != "") |
|
| 226 | 226 | $user_data['pricelist_id'] = $pricelis_id; |
| 227 | 227 | else |
| 228 | 228 | $user_data['pricelist_id'] = 0; */ |
| 229 | - $user_data['pricelist_id'] = ($pricelist_id != "") ? $pricelist_id : 0; |
|
| 230 | - } |
|
| 231 | - $last_id = '0'; |
|
| 232 | - //Insert or Update record |
|
| 233 | - $signup_sipdevice_flag = $system_config['create_sipdevice']; |
|
| 234 | - $last_id = $this->signup_model->add_user($user_data); |
|
| 235 | - if ($last_id == "") { |
|
| 236 | - redirect(base_url()."signup/signup_inactive"); |
|
| 237 | - } |
|
| 238 | - if ($signup_sipdevice_flag == '0') { |
|
| 239 | - $query = $this->db_model->select("*", "sip_profiles", array('name' => "default"), "id", "ASC", '1', '0'); |
|
| 240 | - $sip_id = $query->result_array(); |
|
| 241 | - if ($reseller_id > 0) { |
|
| 229 | + $user_data['pricelist_id'] = ($pricelist_id != "") ? $pricelist_id : 0; |
|
| 230 | + } |
|
| 231 | + $last_id = '0'; |
|
| 232 | + //Insert or Update record |
|
| 233 | + $signup_sipdevice_flag = $system_config['create_sipdevice']; |
|
| 234 | + $last_id = $this->signup_model->add_user($user_data); |
|
| 235 | + if ($last_id == "") { |
|
| 236 | + redirect(base_url()."signup/signup_inactive"); |
|
| 237 | + } |
|
| 238 | + if ($signup_sipdevice_flag == '0') { |
|
| 239 | + $query = $this->db_model->select("*", "sip_profiles", array('name' => "default"), "id", "ASC", '1', '0'); |
|
| 240 | + $sip_id = $query->result_array(); |
|
| 241 | + if ($reseller_id > 0) { |
|
| 242 | 242 | $reseller_id = $reseller_id; |
| 243 | 243 | } else { |
| 244 | 244 | $reseller_id = '0'; |
| 245 | 245 | } |
| 246 | - $free_switch_array = array('fs_username' => $user_data['number'], |
|
| 247 | - 'fs_password' => $user_data['password'], |
|
| 248 | - 'context' => 'default', |
|
| 249 | - 'effective_caller_id_name' => $user_data['number'], |
|
| 250 | - 'effective_caller_id_number' => $user_data['number'], |
|
| 251 | - 'sip_profile_id' => $sip_id[0]['id'], |
|
| 252 | - 'reseller_id' => $reseller_id, |
|
| 253 | - 'pricelist_id' => $user_data['pricelist_id'], |
|
| 254 | - 'accountcode' => $last_id, |
|
| 255 | - 'status' => $user_data['status'], |
|
| 256 | - 'voicemail_enabled'=>true, |
|
| 257 | - 'voicemail_password'=>'', |
|
| 258 | - 'voicemail_mail_to'=>'', |
|
| 259 | - 'voicemail_attach_file'=>true, |
|
| 260 | - 'vm_keep_local_after_email'=>true, |
|
| 261 | - 'vm_send_all_message'=>true, |
|
| 262 | - ); |
|
| 263 | - $user_custom_array = array_merge($user_data, $free_switch_array); |
|
| 264 | - $user_custom_array['id'] = $last_id; |
|
| 265 | - $user_custom_array['email'] = $user_data['email']; |
|
| 246 | + $free_switch_array = array('fs_username' => $user_data['number'], |
|
| 247 | + 'fs_password' => $user_data['password'], |
|
| 248 | + 'context' => 'default', |
|
| 249 | + 'effective_caller_id_name' => $user_data['number'], |
|
| 250 | + 'effective_caller_id_number' => $user_data['number'], |
|
| 251 | + 'sip_profile_id' => $sip_id[0]['id'], |
|
| 252 | + 'reseller_id' => $reseller_id, |
|
| 253 | + 'pricelist_id' => $user_data['pricelist_id'], |
|
| 254 | + 'accountcode' => $last_id, |
|
| 255 | + 'status' => $user_data['status'], |
|
| 256 | + 'voicemail_enabled'=>true, |
|
| 257 | + 'voicemail_password'=>'', |
|
| 258 | + 'voicemail_mail_to'=>'', |
|
| 259 | + 'voicemail_attach_file'=>true, |
|
| 260 | + 'vm_keep_local_after_email'=>true, |
|
| 261 | + 'vm_send_all_message'=>true, |
|
| 262 | + ); |
|
| 263 | + $user_custom_array = array_merge($user_data, $free_switch_array); |
|
| 264 | + $user_custom_array['id'] = $last_id; |
|
| 265 | + $user_custom_array['email'] = $user_data['email']; |
|
| 266 | 266 | |
| 267 | - $this->load->model('freeswitch/freeswitch_model'); |
|
| 268 | - $this->freeswitch_model->add_freeswith($user_custom_array); |
|
| 269 | - } |
|
| 270 | - // echo "<pre>"; print_r ($user_data); exit; |
|
| 271 | - $activation = $this->encrypt->encode($user_data['number']); |
|
| 272 | - $message = base_url().'signup/signup_confirm?email='.urlencode($user_data['email'])."&key=".urlencode($activation); |
|
| 273 | - $user_data['confirm'] = $message; |
|
| 274 | - |
|
| 275 | - $this->send_mail($last_id, 'email_signup_confirmation', $user_data); |
|
| 276 | - redirect(base_url()."signup/signup_success"); |
|
| 277 | - } |
|
| 278 | - } |
|
| 279 | - } |
|
| 280 | - |
|
| 281 | - function signup_confirm() { |
|
| 282 | - if ( ! empty($_GET)) { |
|
| 283 | - |
|
| 284 | - $system_config = common_model::$global_config['system_config']; |
|
| 285 | - $balance = $system_config["balance"]; |
|
| 286 | - $accno = $this->encrypt->decode($_GET['key']); |
|
| 287 | - $email = $_GET['email']; |
|
| 288 | - $success = $this->signup_model->check_user($accno, $email, $balance); |
|
| 289 | - $query = $this->db_model->getSelect("*", "accounts", array('number' => $accno)); |
|
| 290 | - $data = $query->result_array(); |
|
| 291 | - $user_data = $data[0]; |
|
| 292 | - $user_data['accountid'] = $user_data['id']; |
|
| 293 | - $user_data['success'] = $success; |
|
| 294 | - $user_data['balance'] = $balance; |
|
| 295 | - $user_data['confirm'] = base_url(); |
|
| 296 | - $this->active($user_data, $success); |
|
| 297 | - } else { |
|
| 298 | - redirect(base_url()); |
|
| 299 | - } |
|
| 300 | - } |
|
| 301 | - |
|
| 302 | - function signup_success() { |
|
| 303 | - $this->load->view('view_signup_success'); |
|
| 304 | - } |
|
| 305 | - |
|
| 306 | - function signup_inactive() { |
|
| 307 | - $this->load->view('view_signup_inactive'); |
|
| 308 | - } |
|
| 309 | - |
|
| 310 | - function active($user_data, $success) { |
|
| 311 | - $data['user_data'] = $user_data; |
|
| 312 | - $data['user_data']['success'] = $success; |
|
| 313 | - |
|
| 314 | - if ($user_data['success']) { |
|
| 267 | + $this->load->model('freeswitch/freeswitch_model'); |
|
| 268 | + $this->freeswitch_model->add_freeswith($user_custom_array); |
|
| 269 | + } |
|
| 270 | + // echo "<pre>"; print_r ($user_data); exit; |
|
| 271 | + $activation = $this->encrypt->encode($user_data['number']); |
|
| 272 | + $message = base_url().'signup/signup_confirm?email='.urlencode($user_data['email'])."&key=".urlencode($activation); |
|
| 273 | + $user_data['confirm'] = $message; |
|
| 274 | + |
|
| 275 | + $this->send_mail($last_id, 'email_signup_confirmation', $user_data); |
|
| 276 | + redirect(base_url()."signup/signup_success"); |
|
| 277 | + } |
|
| 278 | + } |
|
| 279 | + } |
|
| 280 | + |
|
| 281 | + function signup_confirm() { |
|
| 282 | + if ( ! empty($_GET)) { |
|
| 283 | + |
|
| 284 | + $system_config = common_model::$global_config['system_config']; |
|
| 285 | + $balance = $system_config["balance"]; |
|
| 286 | + $accno = $this->encrypt->decode($_GET['key']); |
|
| 287 | + $email = $_GET['email']; |
|
| 288 | + $success = $this->signup_model->check_user($accno, $email, $balance); |
|
| 289 | + $query = $this->db_model->getSelect("*", "accounts", array('number' => $accno)); |
|
| 290 | + $data = $query->result_array(); |
|
| 291 | + $user_data = $data[0]; |
|
| 292 | + $user_data['accountid'] = $user_data['id']; |
|
| 293 | + $user_data['success'] = $success; |
|
| 294 | + $user_data['balance'] = $balance; |
|
| 295 | + $user_data['confirm'] = base_url(); |
|
| 296 | + $this->active($user_data, $success); |
|
| 297 | + } else { |
|
| 298 | + redirect(base_url()); |
|
| 299 | + } |
|
| 300 | + } |
|
| 301 | + |
|
| 302 | + function signup_success() { |
|
| 303 | + $this->load->view('view_signup_success'); |
|
| 304 | + } |
|
| 305 | + |
|
| 306 | + function signup_inactive() { |
|
| 307 | + $this->load->view('view_signup_inactive'); |
|
| 308 | + } |
|
| 309 | + |
|
| 310 | + function active($user_data, $success) { |
|
| 311 | + $data['user_data'] = $user_data; |
|
| 312 | + $data['user_data']['success'] = $success; |
|
| 313 | + |
|
| 314 | + if ($user_data['success']) { |
|
| 315 | 315 | $user_data['password'] = $this->common->decode($user_data['password']); |
| 316 | - $this->send_mail($user_data['id'], 'email_add_user', $user_data); |
|
| 317 | - } |
|
| 318 | - $this->load->view('view_signup_active', $data); |
|
| 319 | - } |
|
| 320 | - |
|
| 321 | - function forgotpassword() { |
|
| 322 | - $this->load->view('view_forgotpassword'); |
|
| 323 | - } |
|
| 324 | - |
|
| 325 | - function confirmpassword() { |
|
| 326 | - $email = $_POST['email']; |
|
| 327 | - unset($_POST['action']); |
|
| 328 | - $where = array('email' => $email); |
|
| 329 | - $this->db->where($where); |
|
| 330 | - $this->db->or_where('number', $email); |
|
| 331 | - $cnt_result = $this->db_model->countQuery("*", 'accounts', ""); |
|
| 332 | - if ( ! empty($email)) { |
|
| 333 | - $names = array('0', '1', '3'); |
|
| 334 | - $this->db->where_in('type', $names); |
|
| 335 | - $where_arr = array("email" => $email); |
|
| 336 | - $this->db->where($where_arr); |
|
| 316 | + $this->send_mail($user_data['id'], 'email_add_user', $user_data); |
|
| 317 | + } |
|
| 318 | + $this->load->view('view_signup_active', $data); |
|
| 319 | + } |
|
| 320 | + |
|
| 321 | + function forgotpassword() { |
|
| 322 | + $this->load->view('view_forgotpassword'); |
|
| 323 | + } |
|
| 324 | + |
|
| 325 | + function confirmpassword() { |
|
| 326 | + $email = $_POST['email']; |
|
| 327 | + unset($_POST['action']); |
|
| 328 | + $where = array('email' => $email); |
|
| 329 | + $this->db->where($where); |
|
| 330 | + $this->db->or_where('number', $email); |
|
| 331 | + $cnt_result = $this->db_model->countQuery("*", 'accounts', ""); |
|
| 332 | + if ( ! empty($email)) { |
|
| 333 | + $names = array('0', '1', '3'); |
|
| 334 | + $this->db->where_in('type', $names); |
|
| 335 | + $where_arr = array("email" => $email); |
|
| 336 | + $this->db->where($where_arr); |
|
| 337 | 337 | $this->db->or_where('number', $email); |
| 338 | - $acountdata = $this->db_model->getSelect("*", "accounts", ""); |
|
| 339 | - if ($acountdata->num_rows() > 0) { |
|
| 340 | - $user_data = $acountdata->result_array(); |
|
| 341 | - $user_data = $user_data[0]; |
|
| 342 | - if ($user_data['status'] > 0) { |
|
| 343 | - $data['error']['email'] = "<div id='error_mail' style='color:red; margin: 1% 22%; float: left;'>This account is not Active.</div>"; |
|
| 344 | - $this->load->view('view_forgotpassword', $data); |
|
| 345 | - exit; |
|
| 346 | - } |
|
| 347 | - } |
|
| 348 | - if ($acountdata->num_rows() == 0 && ! filter_var($email, FILTER_VALIDATE_EMAIL)) { |
|
| 349 | - if ( ! filter_var($email, FILTER_VALIDATE_EMAIL)) { |
|
| 350 | - $data['error']['email'] = "<div id='error_mail' style='color: red; margin: 2% 22%; float: left; width:100%;'>Please enter proper Username or Email.</div>"; |
|
| 351 | - |
|
| 352 | - $this->load->view('view_forgotpassword', $data); |
|
| 353 | - } else { |
|
| 354 | - $data['error']['email'] = "<div id='error_mail' style='color: red; margin: 2% 22%; float: left;width:100%;'>This Username or Email is not valid</div>"; |
|
| 355 | - |
|
| 356 | - $this->load->view('view_forgotpassword', $data); |
|
| 357 | - } |
|
| 358 | - } else if ($acountdata->num_rows() == 0) { |
|
| 359 | - $data['error']['email'] = "<div id='error_mail' style='color: red; margin: 2% 22%; float: left; width:100%;'>Please enter proper Username or Email.</div>"; |
|
| 360 | - $this->load->view('view_forgotpassword', $data); |
|
| 361 | - } else { |
|
| 362 | - $acountdata = $acountdata->result_array(); |
|
| 363 | - $user_data = $acountdata[0]; |
|
| 338 | + $acountdata = $this->db_model->getSelect("*", "accounts", ""); |
|
| 339 | + if ($acountdata->num_rows() > 0) { |
|
| 340 | + $user_data = $acountdata->result_array(); |
|
| 341 | + $user_data = $user_data[0]; |
|
| 342 | + if ($user_data['status'] > 0) { |
|
| 343 | + $data['error']['email'] = "<div id='error_mail' style='color:red; margin: 1% 22%; float: left;'>This account is not Active.</div>"; |
|
| 344 | + $this->load->view('view_forgotpassword', $data); |
|
| 345 | + exit; |
|
| 346 | + } |
|
| 347 | + } |
|
| 348 | + if ($acountdata->num_rows() == 0 && ! filter_var($email, FILTER_VALIDATE_EMAIL)) { |
|
| 349 | + if ( ! filter_var($email, FILTER_VALIDATE_EMAIL)) { |
|
| 350 | + $data['error']['email'] = "<div id='error_mail' style='color: red; margin: 2% 22%; float: left; width:100%;'>Please enter proper Username or Email.</div>"; |
|
| 351 | + |
|
| 352 | + $this->load->view('view_forgotpassword', $data); |
|
| 353 | + } else { |
|
| 354 | + $data['error']['email'] = "<div id='error_mail' style='color: red; margin: 2% 22%; float: left;width:100%;'>This Username or Email is not valid</div>"; |
|
| 355 | + |
|
| 356 | + $this->load->view('view_forgotpassword', $data); |
|
| 357 | + } |
|
| 358 | + } else if ($acountdata->num_rows() == 0) { |
|
| 359 | + $data['error']['email'] = "<div id='error_mail' style='color: red; margin: 2% 22%; float: left; width:100%;'>Please enter proper Username or Email.</div>"; |
|
| 360 | + $this->load->view('view_forgotpassword', $data); |
|
| 361 | + } else { |
|
| 362 | + $acountdata = $acountdata->result_array(); |
|
| 363 | + $user_data = $acountdata[0]; |
|
| 364 | 364 | |
| 365 | - $email = $this->encrypt->encode($user_data['email']); |
|
| 366 | - $activation = $this->encrypt->encode($user_data['number']); |
|
| 367 | - $message = base_url().'confirm_pass?email='.urlencode($email)."&key=".urlencode($activation); |
|
| 368 | - $user_data['confirm'] = $message; |
|
| 369 | - $where = array("email" => $user_data['email']); |
|
| 370 | - $data = array("pass_link_status" => 1); |
|
| 371 | - $this->db->where($where); |
|
| 372 | - $this->db->update('accounts', $data); |
|
| 373 | - $system_config = common_model::$global_config['system_config']; |
|
| 374 | - $balance = $system_config["balance"]; |
|
| 375 | - $this->send_mail($user_data['id'], 'email_forgot_confirmation', $user_data); |
|
| 376 | - $this->load->view('view_forgot_success'); |
|
| 377 | - } |
|
| 378 | - } else { |
|
| 379 | - redirect(base_url()); |
|
| 380 | - } |
|
| 381 | - } |
|
| 382 | - |
|
| 383 | - function confirm_pass() { |
|
| 384 | - $confirm_pass = $_GET; |
|
| 385 | - $accno = ''; |
|
| 386 | - $balance = ''; |
|
| 387 | - $email1 = $this->encrypt->decode($confirm_pass['email']); |
|
| 388 | - $success = $this->signup_model->check_user($accno, $email1, $balance); |
|
| 389 | - if ( ! empty($confirm_pass)) { |
|
| 390 | - $where_arr = array("email" => $email1, "status" => 0); |
|
| 391 | - $acountdata = $this->db_model->getSelect("*", "accounts", $where_arr); |
|
| 392 | - if ($acountdata->num_rows() > 0) { |
|
| 393 | - $acountdata = $acountdata->result_array(); |
|
| 394 | - $user_data = $acountdata[0]; |
|
| 395 | - $updateArr = array("pass_link_status" => 0); |
|
| 396 | - $this->db->where(array("email" => $email1)); |
|
| 397 | - $this->db->update("accounts", $updateArr); |
|
| 398 | - if ($user_data['pass_link_status'] == '0') { |
|
| 399 | - $user_data['success'] = $success; |
|
| 400 | - $data['user_data'] = $user_data; |
|
| 401 | - $this->active($user_data, $success); |
|
| 402 | - } else { |
|
| 403 | - $data['email'] = $_GET['email']; |
|
| 404 | - $this->load->view('view_confirmpassword', $data); |
|
| 405 | - } |
|
| 406 | - } |
|
| 407 | - } |
|
| 408 | - } |
|
| 409 | - |
|
| 410 | - function confirmpass() { |
|
| 411 | - $passwordconf = $_POST; |
|
| 412 | - $email1 = $this->encrypt->decode($passwordconf['email']); |
|
| 413 | - if ( ! empty($passwordconf)) { |
|
| 414 | - $acountdata = $this->db_model->getSelect("*", "accounts", array("email" => $email1)); |
|
| 415 | - //echo $this->db->last_query();exit; |
|
| 416 | - if ($acountdata->num_rows() > 0) { |
|
| 417 | - $acountdata = $acountdata->result_array(); |
|
| 418 | - $user_data = $acountdata[0]; |
|
| 419 | - } |
|
| 420 | - $user_data['password'] = $this->common->encode($passwordconf['password']); |
|
| 421 | - $updateArr = array("password" => $user_data['password']); |
|
| 422 | - $where_arr = array("email" => $email1, "status" => 0); |
|
| 423 | - $this->db->where($where_arr); |
|
| 424 | - $this->db->update("accounts", $updateArr); |
|
| 425 | - //$activation = $this->encrypt->encode($user_data['number']); |
|
| 426 | - $message = base_url(); |
|
| 427 | - $user_data['confirm'] = $message; |
|
| 428 | - $user_data['password'] = $passwordconf['password']; |
|
| 429 | - |
|
| 430 | - |
|
| 431 | - |
|
| 432 | - $system_config = common_model::$global_config['system_config']; |
|
| 433 | - $balance = $system_config["balance"]; |
|
| 434 | - |
|
| 435 | - $this->send_mail($user_data['id'], 'email_forgot_user', $user_data); |
|
| 436 | - |
|
| 437 | - $this->successpassword(); |
|
| 438 | - } |
|
| 439 | - } |
|
| 440 | - |
|
| 441 | - /** |
|
| 442 | - * @param string $temp_name |
|
| 443 | - */ |
|
| 444 | - function send_mail($account_id, $temp_name, $user_data) { |
|
| 365 | + $email = $this->encrypt->encode($user_data['email']); |
|
| 366 | + $activation = $this->encrypt->encode($user_data['number']); |
|
| 367 | + $message = base_url().'confirm_pass?email='.urlencode($email)."&key=".urlencode($activation); |
|
| 368 | + $user_data['confirm'] = $message; |
|
| 369 | + $where = array("email" => $user_data['email']); |
|
| 370 | + $data = array("pass_link_status" => 1); |
|
| 371 | + $this->db->where($where); |
|
| 372 | + $this->db->update('accounts', $data); |
|
| 373 | + $system_config = common_model::$global_config['system_config']; |
|
| 374 | + $balance = $system_config["balance"]; |
|
| 375 | + $this->send_mail($user_data['id'], 'email_forgot_confirmation', $user_data); |
|
| 376 | + $this->load->view('view_forgot_success'); |
|
| 377 | + } |
|
| 378 | + } else { |
|
| 379 | + redirect(base_url()); |
|
| 380 | + } |
|
| 381 | + } |
|
| 382 | + |
|
| 383 | + function confirm_pass() { |
|
| 384 | + $confirm_pass = $_GET; |
|
| 385 | + $accno = ''; |
|
| 386 | + $balance = ''; |
|
| 387 | + $email1 = $this->encrypt->decode($confirm_pass['email']); |
|
| 388 | + $success = $this->signup_model->check_user($accno, $email1, $balance); |
|
| 389 | + if ( ! empty($confirm_pass)) { |
|
| 390 | + $where_arr = array("email" => $email1, "status" => 0); |
|
| 391 | + $acountdata = $this->db_model->getSelect("*", "accounts", $where_arr); |
|
| 392 | + if ($acountdata->num_rows() > 0) { |
|
| 393 | + $acountdata = $acountdata->result_array(); |
|
| 394 | + $user_data = $acountdata[0]; |
|
| 395 | + $updateArr = array("pass_link_status" => 0); |
|
| 396 | + $this->db->where(array("email" => $email1)); |
|
| 397 | + $this->db->update("accounts", $updateArr); |
|
| 398 | + if ($user_data['pass_link_status'] == '0') { |
|
| 399 | + $user_data['success'] = $success; |
|
| 400 | + $data['user_data'] = $user_data; |
|
| 401 | + $this->active($user_data, $success); |
|
| 402 | + } else { |
|
| 403 | + $data['email'] = $_GET['email']; |
|
| 404 | + $this->load->view('view_confirmpassword', $data); |
|
| 405 | + } |
|
| 406 | + } |
|
| 407 | + } |
|
| 408 | + } |
|
| 409 | + |
|
| 410 | + function confirmpass() { |
|
| 411 | + $passwordconf = $_POST; |
|
| 412 | + $email1 = $this->encrypt->decode($passwordconf['email']); |
|
| 413 | + if ( ! empty($passwordconf)) { |
|
| 414 | + $acountdata = $this->db_model->getSelect("*", "accounts", array("email" => $email1)); |
|
| 415 | + //echo $this->db->last_query();exit; |
|
| 416 | + if ($acountdata->num_rows() > 0) { |
|
| 417 | + $acountdata = $acountdata->result_array(); |
|
| 418 | + $user_data = $acountdata[0]; |
|
| 419 | + } |
|
| 420 | + $user_data['password'] = $this->common->encode($passwordconf['password']); |
|
| 421 | + $updateArr = array("password" => $user_data['password']); |
|
| 422 | + $where_arr = array("email" => $email1, "status" => 0); |
|
| 423 | + $this->db->where($where_arr); |
|
| 424 | + $this->db->update("accounts", $updateArr); |
|
| 425 | + //$activation = $this->encrypt->encode($user_data['number']); |
|
| 426 | + $message = base_url(); |
|
| 427 | + $user_data['confirm'] = $message; |
|
| 428 | + $user_data['password'] = $passwordconf['password']; |
|
| 429 | + |
|
| 430 | + |
|
| 431 | + |
|
| 432 | + $system_config = common_model::$global_config['system_config']; |
|
| 433 | + $balance = $system_config["balance"]; |
|
| 434 | + |
|
| 435 | + $this->send_mail($user_data['id'], 'email_forgot_user', $user_data); |
|
| 436 | + |
|
| 437 | + $this->successpassword(); |
|
| 438 | + } |
|
| 439 | + } |
|
| 440 | + |
|
| 441 | + /** |
|
| 442 | + * @param string $temp_name |
|
| 443 | + */ |
|
| 444 | + function send_mail($account_id, $temp_name, $user_data) { |
|
| 445 | 445 | |
| 446 | 446 | |
| 447 | - $system_config = common_model::$global_config['system_config']; |
|
| 448 | - //$screen_path = getcwd()."/cron"; |
|
| 449 | - //$screen_filename = "Email_Broadcast_".strtotime('now'); |
|
| 450 | - //$command = "cd ".$screen_path." && /usr/bin/screen -d -m -S $screen_filename php cron.php BroadcastEmail"; |
|
| 451 | - //exec($command); |
|
| 447 | + $system_config = common_model::$global_config['system_config']; |
|
| 448 | + //$screen_path = getcwd()."/cron"; |
|
| 449 | + //$screen_filename = "Email_Broadcast_".strtotime('now'); |
|
| 450 | + //$command = "cd ".$screen_path." && /usr/bin/screen -d -m -S $screen_filename php cron.php BroadcastEmail"; |
|
| 451 | + //exec($command); |
|
| 452 | 452 | |
| 453 | 453 | |
| 454 | 454 | |
| 455 | 455 | |
| 456 | - $where = array('name' => $temp_name); |
|
| 457 | - $EmailTemplate = $this->db_model->getSelect("*", "default_templates", $where); |
|
| 458 | - $reseller_id = ($user_data['reseller_id'] > 0) ? $user_data['reseller_id'] : 1; |
|
| 459 | - $where = "accountid IN ('".$reseller_id."','1')"; |
|
| 460 | - $this->db->where($where); |
|
| 461 | - $this->db->select('*'); |
|
| 462 | - $this->db->order_by('accountid', 'desc'); |
|
| 463 | - $this->db->limit(1); |
|
| 464 | - $invoiceconf = $this->db->get('invoice_conf'); |
|
| 465 | - $invoiceconf = (array)$invoiceconf->first_row(); |
|
| 466 | - $company_email = $invoiceconf['emailaddress']; |
|
| 467 | - $company_website = $invoiceconf["website"]; |
|
| 468 | - $company_name = $invoiceconf["company_name"]; |
|
| 456 | + $where = array('name' => $temp_name); |
|
| 457 | + $EmailTemplate = $this->db_model->getSelect("*", "default_templates", $where); |
|
| 458 | + $reseller_id = ($user_data['reseller_id'] > 0) ? $user_data['reseller_id'] : 1; |
|
| 459 | + $where = "accountid IN ('".$reseller_id."','1')"; |
|
| 460 | + $this->db->where($where); |
|
| 461 | + $this->db->select('*'); |
|
| 462 | + $this->db->order_by('accountid', 'desc'); |
|
| 463 | + $this->db->limit(1); |
|
| 464 | + $invoiceconf = $this->db->get('invoice_conf'); |
|
| 465 | + $invoiceconf = (array)$invoiceconf->first_row(); |
|
| 466 | + $company_email = $invoiceconf['emailaddress']; |
|
| 467 | + $company_website = $invoiceconf["website"]; |
|
| 468 | + $company_name = $invoiceconf["company_name"]; |
|
| 469 | 469 | |
| 470 | - $TemplateData = array(); |
|
| 470 | + $TemplateData = array(); |
|
| 471 | 471 | |
| 472 | 472 | |
| 473 | - foreach ($EmailTemplate->result_array() as $value) { |
|
| 474 | - $TemplateData = $value; |
|
| 475 | - $TemplateData['subject'] = str_replace('#NAME#', $user_data['first_name']." ".$user_data['last_name'], $TemplateData['subject']); |
|
| 476 | - $TemplateData['template'] = str_replace('#NAME#', $user_data['first_name']." ".$user_data['last_name'], $TemplateData['template']); |
|
| 477 | - $TemplateData['template'] = str_replace('#NUMBER#', $user_data['number'], $TemplateData['template']); |
|
| 478 | - $TemplateData['template'] = str_replace('#PASSWORD#', $user_data['password'], $TemplateData['template']); |
|
| 479 | - $TemplateData['template'] = str_replace('#COMPANY_WEBSITE#', $company_website, $TemplateData['template']); |
|
| 480 | - $TemplateData['template'] = str_replace('#LINK#', $user_data['confirm'], $TemplateData['template']); |
|
| 481 | - $TemplateData['template'] = str_replace('#COMPANY_EMAIL#', $company_email, $TemplateData['template']); |
|
| 482 | - $TemplateData['template'] = str_replace('#COMPANY_NAME#', $company_name, $TemplateData['template']); |
|
| 483 | - } |
|
| 484 | - $email_array = array('accountid' => $account_id, |
|
| 485 | - 'subject' => $TemplateData['subject'], |
|
| 486 | - 'body' => $TemplateData['template'], |
|
| 487 | - 'from' => $invoiceconf['emailaddress'], |
|
| 488 | - 'to' => $user_data['email'], |
|
| 489 | - 'status' => "1", |
|
| 490 | - //'attachment'=> $Filenm, |
|
| 491 | - 'template' => ''); |
|
| 492 | - //echo "<pre>"; print_r($TemplateData); exit; |
|
| 493 | - $this->db->insert("mail_details", $email_array); |
|
| 494 | - return true; |
|
| 495 | - } |
|
| 496 | - |
|
| 497 | - function successpassword() { |
|
| 498 | - $this->load->view('view_successpassword'); |
|
| 499 | - } |
|
| 473 | + foreach ($EmailTemplate->result_array() as $value) { |
|
| 474 | + $TemplateData = $value; |
|
| 475 | + $TemplateData['subject'] = str_replace('#NAME#', $user_data['first_name']." ".$user_data['last_name'], $TemplateData['subject']); |
|
| 476 | + $TemplateData['template'] = str_replace('#NAME#', $user_data['first_name']." ".$user_data['last_name'], $TemplateData['template']); |
|
| 477 | + $TemplateData['template'] = str_replace('#NUMBER#', $user_data['number'], $TemplateData['template']); |
|
| 478 | + $TemplateData['template'] = str_replace('#PASSWORD#', $user_data['password'], $TemplateData['template']); |
|
| 479 | + $TemplateData['template'] = str_replace('#COMPANY_WEBSITE#', $company_website, $TemplateData['template']); |
|
| 480 | + $TemplateData['template'] = str_replace('#LINK#', $user_data['confirm'], $TemplateData['template']); |
|
| 481 | + $TemplateData['template'] = str_replace('#COMPANY_EMAIL#', $company_email, $TemplateData['template']); |
|
| 482 | + $TemplateData['template'] = str_replace('#COMPANY_NAME#', $company_name, $TemplateData['template']); |
|
| 483 | + } |
|
| 484 | + $email_array = array('accountid' => $account_id, |
|
| 485 | + 'subject' => $TemplateData['subject'], |
|
| 486 | + 'body' => $TemplateData['template'], |
|
| 487 | + 'from' => $invoiceconf['emailaddress'], |
|
| 488 | + 'to' => $user_data['email'], |
|
| 489 | + 'status' => "1", |
|
| 490 | + //'attachment'=> $Filenm, |
|
| 491 | + 'template' => ''); |
|
| 492 | + //echo "<pre>"; print_r($TemplateData); exit; |
|
| 493 | + $this->db->insert("mail_details", $email_array); |
|
| 494 | + return true; |
|
| 495 | + } |
|
| 496 | + |
|
| 497 | + function successpassword() { |
|
| 498 | + $this->load->view('view_successpassword'); |
|
| 499 | + } |
|
| 500 | 500 | |
| 501 | 501 | } |
| 502 | 502 | ?> |
@@ -6,12 +6,12 @@ |
||
| 6 | 6 | <meta http-equiv="X-UA-Compatible" content="IE=edge"> |
| 7 | 7 | <title> |
| 8 | 8 | <?php |
| 9 | - $this->db->where('domain',$_SERVER['HTTP_HOST']); |
|
| 10 | - $this->db->select('*'); |
|
| 11 | - $this->db->order_by('accountid', 'desc'); |
|
| 12 | - $this->db->limit(1); |
|
| 13 | - $invoiceconf = $this->db->get('invoice_conf'); |
|
| 14 | - $invoiceconf = (array)$invoiceconf->first_row(); |
|
| 9 | + $this->db->where('domain',$_SERVER['HTTP_HOST']); |
|
| 10 | + $this->db->select('*'); |
|
| 11 | + $this->db->order_by('accountid', 'desc'); |
|
| 12 | + $this->db->limit(1); |
|
| 13 | + $invoiceconf = $this->db->get('invoice_conf'); |
|
| 14 | + $invoiceconf = (array)$invoiceconf->first_row(); |
|
| 15 | 15 | if(isset($invoiceconf['website_title']) && $invoiceconf['website_title']!='') { |
| 16 | 16 | ?> |
| 17 | 17 | Forgot Password | <?php echo $invoiceconf['website_title']; ?> |
@@ -6,12 +6,12 @@ |
||
| 6 | 6 | <meta http-equiv="X-UA-Compatible" content="IE=edge"> |
| 7 | 7 | <title> |
| 8 | 8 | <?php |
| 9 | - $this->db->where('domain',$_SERVER['HTTP_HOST']); |
|
| 10 | - $this->db->select('*'); |
|
| 11 | - $this->db->order_by('accountid', 'desc'); |
|
| 12 | - $this->db->limit(1); |
|
| 13 | - $invoiceconf = $this->db->get('invoice_conf'); |
|
| 14 | - $invoiceconf = (array)$invoiceconf->first_row(); |
|
| 9 | + $this->db->where('domain',$_SERVER['HTTP_HOST']); |
|
| 10 | + $this->db->select('*'); |
|
| 11 | + $this->db->order_by('accountid', 'desc'); |
|
| 12 | + $this->db->limit(1); |
|
| 13 | + $invoiceconf = $this->db->get('invoice_conf'); |
|
| 14 | + $invoiceconf = (array)$invoiceconf->first_row(); |
|
| 15 | 15 | if(isset($invoiceconf['website_title']) && $invoiceconf['website_title']!='') { |
| 16 | 16 | ?> |
| 17 | 17 | Forgot Password | <?php echo $invoiceconf['website_title']; ?> |
@@ -6,12 +6,12 @@ |
||
| 6 | 6 | <meta http-equiv="X-UA-Compatible" content="IE=edge"> |
| 7 | 7 | <title> |
| 8 | 8 | <?php |
| 9 | - $this->db->where('domain',$_SERVER['HTTP_HOST']); |
|
| 10 | - $this->db->select('*'); |
|
| 11 | - $this->db->order_by('accountid', 'desc'); |
|
| 12 | - $this->db->limit(1); |
|
| 13 | - $invoiceconf = $this->db->get('invoice_conf'); |
|
| 14 | - $invoiceconf = (array)$invoiceconf->first_row(); |
|
| 9 | + $this->db->where('domain',$_SERVER['HTTP_HOST']); |
|
| 10 | + $this->db->select('*'); |
|
| 11 | + $this->db->order_by('accountid', 'desc'); |
|
| 12 | + $this->db->limit(1); |
|
| 13 | + $invoiceconf = $this->db->get('invoice_conf'); |
|
| 14 | + $invoiceconf = (array)$invoiceconf->first_row(); |
|
| 15 | 15 | if(isset($invoiceconf['website_title']) && $invoiceconf['website_title']!='') { |
| 16 | 16 | ?> |
| 17 | 17 | Signup | <?php echo $invoiceconf['website_title']; ?> |
@@ -6,12 +6,12 @@ |
||
| 6 | 6 | <meta http-equiv="X-UA-Compatible" content="IE=edge"> |
| 7 | 7 | <title> |
| 8 | 8 | <?php |
| 9 | - $this->db->where('domain',$_SERVER['HTTP_HOST']); |
|
| 10 | - $this->db->select('*'); |
|
| 11 | - $this->db->order_by('accountid', 'desc'); |
|
| 12 | - $this->db->limit(1); |
|
| 13 | - $invoiceconf = $this->db->get('invoice_conf'); |
|
| 14 | - $invoiceconf = (array)$invoiceconf->first_row(); |
|
| 9 | + $this->db->where('domain',$_SERVER['HTTP_HOST']); |
|
| 10 | + $this->db->select('*'); |
|
| 11 | + $this->db->order_by('accountid', 'desc'); |
|
| 12 | + $this->db->limit(1); |
|
| 13 | + $invoiceconf = $this->db->get('invoice_conf'); |
|
| 14 | + $invoiceconf = (array)$invoiceconf->first_row(); |
|
| 15 | 15 | if(isset($invoiceconf['website_title']) && $invoiceconf['website_title']!='') { |
| 16 | 16 | ?> |
| 17 | 17 | Signup | <?php echo $invoiceconf['website_title']; ?> |