Passed
Pull Request — v3.0 (#189)
by
unknown
10:51
created
freeswitch/fs/lib/astpp.functions.php 1 patch
Indentation   +80 added lines, -80 removed lines patch added patch discarded remove patch
@@ -24,97 +24,97 @@  discard block
 block discarded – undo
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
 block discarded – undo
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
 ?>
Please login to merge, or discard this patch.
freeswitch/fs/lib/astpp.db.php 2 patches
Indentation   +47 added lines, -47 removed lines patch added patch discarded remove patch
@@ -23,61 +23,61 @@
 block discarded – undo
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
 
Please login to merge, or discard this patch.
Braces   +10 added lines, -8 removed lines patch added patch discarded remove patch
@@ -52,10 +52,11 @@  discard block
 block discarded – undo
52 52
      */
53 53
     public function cleanup($bind) {
54 54
         if ( ! is_array($bind)) {
55
-            if ( ! empty($bind))
56
-                $bind = array($bind);
57
-            else
58
-                $bind = array();
55
+            if ( ! empty($bind)) {
56
+                            $bind = array($bind);
57
+            } else {
58
+                            $bind = array();
59
+            }
59 60
         }
60 61
         return $bind;
61 62
     }
@@ -68,10 +69,11 @@  discard block
 block discarded – undo
68 69
         try {
69 70
             $pdostmt = $this->prepare($this->sql);
70 71
             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();
72
+                if (preg_match("/^(".implode("|", array("select", "describe", "pragma")).") /i", $this->sql)) {
73
+                                    return $pdostmt->fetchAll(PDO::FETCH_ASSOC);
74
+                } elseif (preg_match("/^(".implode("|", array("delete", "insert", "update")).") /i", $this->sql)) {
75
+                                    return $pdostmt->rowCount();
76
+                }
75 77
             }
76 78
         } catch (PDOException $e) {
77 79
             $this->error = $e->getMessage();
Please login to merge, or discard this patch.
freeswitch/fs/lib/astpp.xml.php 2 patches
Braces   +3 added lines, -2 removed lines patch added patch discarded remove patch
@@ -154,8 +154,9 @@
 block discarded – undo
154 154
 
155 155
 		$sp_gw_settings  = json_decode($sp_gw_value['gateway_data'], true);
156 156
 			foreach ($sp_gw_settings as $sp_gw_settings_key => $sp_gw_settings_value) {
157
-				if ($sp_gw_settings_value != "")
158
-					$xml .= "           <param name=\"" . $sp_gw_settings_key . "\" value=\"" . $sp_gw_settings_value . "\"/>\n";
157
+				if ($sp_gw_settings_value != "") {
158
+									$xml .= "           <param name=\"" . $sp_gw_settings_key . "\" value=\"" . $sp_gw_settings_value . "\"/>\n";
159
+				}
159 160
 			}
160 161
 			$xml .= "       </gateway>\n";
161 162
 		}
Please login to merge, or discard this patch.
Spacing   +33 added lines, -33 removed lines patch added patch discarded remove patch
@@ -36,7 +36,7 @@  discard block
 block discarded – undo
36 36
 }
37 37
 
38 38
 //Build acl xml
39
-function load_acl($logger, $db,$config) {
39
+function load_acl($logger, $db, $config) {
40 40
 	$xml = "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"no\"?>\n";
41 41
 	$xml .= "<document type=\"freeswitch/xml\">\n";
42 42
 	$xml .= "   <section name=\"Configuration\" description=\"Configuration\">\n";
@@ -46,29 +46,29 @@  discard block
 block discarded – undo
46 46
 	
47 47
 	//For customer and provider ips
48 48
 	$query = "SELECT ip FROM ip_map,accounts WHERE ip_map.accountid=accounts.id AND accounts.status=0 AND deleted=0";
49
-	$logger->log("ACL Query : " . $query);
49
+	$logger->log("ACL Query : ".$query);
50 50
 	$res_acl = $db->run($query);
51 51
 	$logger->log($res_acl);
52 52
 
53 53
 	foreach ($res_acl as $res_acl_key => $res_acl_value) {
54
-		$xml .= "       <node type=\"allow\" cidr=\"" . $res_acl_value['ip'] . "\"/>\n";
54
+		$xml .= "       <node type=\"allow\" cidr=\"".$res_acl_value['ip']."\"/>\n";
55 55
 	}
56 56
 
57 57
 	//For gateways
58 58
 	$query = "SELECT * FROM gateways WHERE status=0";
59
-	$logger->log("Sofia Gateway Query : " . $query);
59
+	$logger->log("Sofia Gateway Query : ".$query);
60 60
 	$sp_gw = $db->run($query);
61 61
 	$logger->log($sp_gw);
62 62
 
63 63
 	foreach ($sp_gw as $sp_gw_key => $sp_gw_value) {
64 64
 
65
-			$sp_gw_settings  = json_decode($sp_gw_value['gateway_data'], true);
65
+			$sp_gw_settings = json_decode($sp_gw_value['gateway_data'], true);
66 66
 			foreach ($sp_gw_settings as $sp_gw_settings_key => $sp_gw_settings_value) {
67 67
 				if ($sp_gw_settings_value != "" && $sp_gw_settings_key == "proxy")
68 68
 				{
69
-					$tmp_ip_arr = explode(":",$sp_gw_settings_value);
70
-					if (!filter_var($tmp_ip_arr[0], FILTER_VALIDATE_IP) === false) {
71
-						$xml .= "   <node type=\"allow\" cidr=\"" . $tmp_ip_arr[0] . "/32\"/>\n";
69
+					$tmp_ip_arr = explode(":", $sp_gw_settings_value);
70
+					if ( ! filter_var($tmp_ip_arr[0], FILTER_VALIDATE_IP) === false) {
71
+						$xml .= "   <node type=\"allow\" cidr=\"".$tmp_ip_arr[0]."/32\"/>\n";
72 72
 					}
73 73
 				}
74 74
 	   	}
@@ -77,7 +77,7 @@  discard block
 block discarded – undo
77 77
 
78 78
 
79 79
 	//For opensips
80
-	if($config['opensips'] == '0')
80
+	if ($config['opensips'] == '0')
81 81
 	{
82 82
 		$xml .= "<node type=\"allow\" cidr=\"".$config['opensips_domain']."/32\"/>\n";     
83 83
 	}
@@ -85,7 +85,7 @@  discard block
 block discarded – undo
85 85
 	$xml .= "       </list>\n";
86 86
 
87 87
 	//For loopback 
88
-	if($config['opensips'] == '0')
88
+	if ($config['opensips'] == '0')
89 89
 	{
90 90
 		$xml .= "<list name=\"loopback.auto\" default=\"allow\">\n";
91 91
 			$xml .= "<node type=\"allow\" cidr=\"".$config['opensips_domain']."/32\"/>\n";
@@ -94,7 +94,7 @@  discard block
 block discarded – undo
94 94
 
95 95
 	//For event handing
96 96
 	$xml .= "<list name=\"event\" default=\"deny\">\n";
97
-		$xml .= ($config['opensips'] == "0")?"<node type=\"allow\" cidr=\"".$config['opensips_domain']."/32\"/>\n":"\n";
97
+		$xml .= ($config['opensips'] == "0") ? "<node type=\"allow\" cidr=\"".$config['opensips_domain']."/32\"/>\n" : "\n";
98 98
 		$xml .= "<node type=\"allow\" cidr=\"127.0.0.0/8\"/>\n";
99 99
 	$xml .= "</list>\n";
100 100
 	$xml .= "           </network-lists>\n";
@@ -114,7 +114,7 @@  discard block
 block discarded – undo
114 114
 	$xml .= "   <profiles>\n";
115 115
 
116 116
 	$query = "SELECT * FROM sip_profiles WHERE status=0";
117
-	$logger->log("Sofia Query : " . $query);
117
+	$logger->log("Sofia Query : ".$query);
118 118
 	$res_sp = $db->run($query);
119 119
 	//$logger->log($res_sp);
120 120
 
@@ -122,40 +122,40 @@  discard block
 block discarded – undo
122 122
 
123 123
 		$settings = json_decode($sp_value['profile_data'], true);
124 124
 		//$logger->log(print_r($settings,true));
125
-		$xml .= "   <profile name=\"" . $sp_value['name'] . "\">\n";
125
+		$xml .= "   <profile name=\"".$sp_value['name']."\">\n";
126 126
 
127 127
 		$xml .= "   <domains>\n";
128
-			$xml .= "       <domain name=\"" . $sp_value['sip_ip'] . "\" alias=\"true\" parse=\"true\"/>\n";
128
+			$xml .= "       <domain name=\"".$sp_value['sip_ip']."\" alias=\"true\" parse=\"true\"/>\n";
129 129
 		$xml .= "   </domains>\n";
130 130
 		/*$xml .= "   <aliases>\n";
131 131
             $xml .= "       <alias name=\"" . $sp_value['sip_ip'] . "\"/>\n";
132 132
         $xml .= "   </aliases>\n";*/
133 133
 
134 134
 	$xml .= "   <settings>\n";
135
-	$xml .= "       <param name=\"sip-ip\" value=\"" . $sp_value['sip_ip'] . "\"/>\n";
136
-	$xml .= "       <param name=\"sip-port\" value=\"" . $sp_value['sip_port'] . "\"/>\n";    
137
-	foreach($settings as $set_key => $set_val)
135
+	$xml .= "       <param name=\"sip-ip\" value=\"".$sp_value['sip_ip']."\"/>\n";
136
+	$xml .= "       <param name=\"sip-port\" value=\"".$sp_value['sip_port']."\"/>\n";    
137
+	foreach ($settings as $set_key => $set_val)
138 138
 	{
139
-			$xml .= "       <param name=\"" . $set_key . "\" value=\"" . $set_val . "\"/>\n";
139
+			$xml .= "       <param name=\"".$set_key."\" value=\"".$set_val."\"/>\n";
140 140
 	}
141 141
 		$xml .= "   </settings>\n";
142 142
 	
143 143
 
144 144
 		//Gateway block start 
145 145
 		$xml .= "   <gateways>\n";
146
-		$query = "SELECT * FROM gateways WHERE sip_profile_id=" . $sp_value['id'] . " AND status=0";
147
-		$logger->log("Sofia Gateway Query : " . $query);
146
+		$query = "SELECT * FROM gateways WHERE sip_profile_id=".$sp_value['id']." AND status=0";
147
+		$logger->log("Sofia Gateway Query : ".$query);
148 148
 		$sp_gw = $db->run($query);
149 149
 		$logger->log($sp_gw);
150 150
 		foreach ($sp_gw as $sp_gw_key => $sp_gw_value) {
151
-			$xml .= "       <gateway name=\"" . $sp_gw_value['name'] . "\">\n";
151
+			$xml .= "       <gateway name=\"".$sp_gw_value['name']."\">\n";
152 152
 
153 153
 
154 154
 
155
-		$sp_gw_settings  = json_decode($sp_gw_value['gateway_data'], true);
155
+		$sp_gw_settings = json_decode($sp_gw_value['gateway_data'], true);
156 156
 			foreach ($sp_gw_settings as $sp_gw_settings_key => $sp_gw_settings_value) {
157 157
 				if ($sp_gw_settings_value != "")
158
-					$xml .= "           <param name=\"" . $sp_gw_settings_key . "\" value=\"" . $sp_gw_settings_value . "\"/>\n";
158
+					$xml .= "           <param name=\"".$sp_gw_settings_key."\" value=\"".$sp_gw_settings_value."\"/>\n";
159 159
 			}
160 160
 			$xml .= "       </gateway>\n";
161 161
 		}
@@ -177,9 +177,9 @@  discard block
 block discarded – undo
177 177
 function load_directory($logger, $db) {
178 178
 	$xml = "";
179 179
 
180
-  $query = "SELECT username,dir_params,dir_vars,number as accountcode,accountid FROM sip_devices,accounts WHERE sip_devices.status=0 AND accounts.status=0 AND accounts.deleted=0 AND accounts.id=sip_devices.accountid AND username='" . $_REQUEST['user']."' limit 1";
180
+  $query = "SELECT username,dir_params,dir_vars,number as accountcode,accountid FROM sip_devices,accounts WHERE sip_devices.status=0 AND accounts.status=0 AND accounts.deleted=0 AND accounts.id=sip_devices.accountid AND username='".$_REQUEST['user']."' limit 1";
181 181
 	
182
-	$logger->log("Directory Query : " . $query);
182
+	$logger->log("Directory Query : ".$query);
183 183
 	$res_dir = $db->run($query);
184 184
 	$logger->log($res_dir);
185 185
 
@@ -187,21 +187,21 @@  discard block
 block discarded – undo
187 187
 		$xml = "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"no\"?>\n";
188 188
 		$xml .= "<document type=\"freeswitch/xml\">\n";
189 189
 		$xml .= "   <section name=\"Directory\" description=\"Directory\">\n";
190
-		$xml .= "       <domain name=\"" . $_REQUEST['domain'] . "\" alias=\"true\">\n";
191
-		$xml .= "           <user id=\"" . $_REQUEST['user'] . "\">\n";
190
+		$xml .= "       <domain name=\"".$_REQUEST['domain']."\" alias=\"true\">\n";
191
+		$xml .= "           <user id=\"".$_REQUEST['user']."\">\n";
192 192
 
193 193
 	$params = json_decode($res_dir_value['dir_params'], true);
194 194
 
195 195
 	$vars   = json_decode($res_dir_value['dir_vars'], true);
196 196
 	$param_xml = $var_xml = "";
197
-	foreach($params as $parms_key => $res_dir_params)
197
+	foreach ($params as $parms_key => $res_dir_params)
198 198
 	{	
199
-						$param_xml .= "<param name=\"" . $parms_key . "\" value=\"" . $res_dir_params . "\"/>\n";
199
+						$param_xml .= "<param name=\"".$parms_key."\" value=\"".$res_dir_params."\"/>\n";
200 200
 	}
201 201
 
202
-	foreach($vars as $var_key => $res_dir_vars)
202
+	foreach ($vars as $var_key => $res_dir_vars)
203 203
 	{	
204
-						$var_xml .= "<variable name=\"" . $var_key . "\" value=\"" . $res_dir_vars . "\"/>\n";
204
+						$var_xml .= "<variable name=\"".$var_key."\" value=\"".$res_dir_vars."\"/>\n";
205 205
 	}		
206 206
 
207 207
 
@@ -214,8 +214,8 @@  discard block
 block discarded – undo
214 214
 		$xml .= "               <variables>\n";
215 215
 		$xml .= $var_xml;
216 216
 		$xml .= "<variable name=\"sipcall\" value=\"true\"/>\n";
217
-		$xml .= "<variable name=\"accountcode\" value=\"" . $res_dir_value['accountcode'] . "\"/>\n";
218
-		$xml .= "<variable name=\"domain_name\" value=\"" . $_REQUEST['domain'] . "\"/>\n";
217
+		$xml .= "<variable name=\"accountcode\" value=\"".$res_dir_value['accountcode']."\"/>\n";
218
+		$xml .= "<variable name=\"domain_name\" value=\"".$_REQUEST['domain']."\"/>\n";
219 219
 		$xml .= "               </variables>\n";
220 220
 
221 221
 		$xml .= "           </user>\n";
Please login to merge, or discard this patch.
freeswitch/fs/lib/astpp.logger.php 2 patches
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -30,15 +30,15 @@
 block discarded – undo
30 30
 		$this->config = $lib->config;
31 31
 		$this->config['log_path'] = "/var/log/astpp/";
32 32
 		if ($this->config['debug'] == '0')
33
-			$this->fp = fopen($this->config['log_path'] . 'astpp_' . date('Y-m-d') . '.txt', 'a');
33
+			$this->fp = fopen($this->config['log_path'].'astpp_'.date('Y-m-d').'.txt', 'a');
34 34
 	}
35 35
 
36 36
 	function log($log) {
37 37
 		if ($this->config['debug'] == '0') {
38 38
 			if (is_array($log))
39
-				fwrite($this->fp, "[" . date('Y-m-d H:i:s') . "] " . print_r($log, TRUE));
39
+				fwrite($this->fp, "[".date('Y-m-d H:i:s')."] ".print_r($log, TRUE));
40 40
 			else
41
-				fwrite($this->fp, "[" . date('Y-m-d H:i:s') . "] " . $log . "\n");
41
+				fwrite($this->fp, "[".date('Y-m-d H:i:s')."] ".$log."\n");
42 42
 		}
43 43
 	}
44 44
 
Please login to merge, or discard this patch.
Braces   +11 added lines, -8 removed lines patch added patch discarded remove patch
@@ -29,22 +29,25 @@
 block discarded – undo
29 29
 	function logger($lib) {
30 30
 		$this->config = $lib->config;
31 31
 		$this->config['log_path'] = "/var/log/astpp/";
32
-		if ($this->config['debug'] == '0')
33
-			$this->fp = fopen($this->config['log_path'] . 'astpp_' . date('Y-m-d') . '.txt', 'a');
32
+		if ($this->config['debug'] == '0') {
33
+					$this->fp = fopen($this->config['log_path'] . 'astpp_' . date('Y-m-d') . '.txt', 'a');
34
+		}
34 35
 	}
35 36
 
36 37
 	function log($log) {
37 38
 		if ($this->config['debug'] == '0') {
38
-			if (is_array($log))
39
-				fwrite($this->fp, "[" . date('Y-m-d H:i:s') . "] " . print_r($log, TRUE));
40
-			else
41
-				fwrite($this->fp, "[" . date('Y-m-d H:i:s') . "] " . $log . "\n");
39
+			if (is_array($log)) {
40
+							fwrite($this->fp, "[" . date('Y-m-d H:i:s') . "] " . print_r($log, TRUE));
41
+			} else {
42
+							fwrite($this->fp, "[" . date('Y-m-d H:i:s') . "] " . $log . "\n");
43
+			}
42 44
 		}
43 45
 	}
44 46
 
45 47
 	function close() {
46
-		if ($this->config['debug'] == '0')
47
-			fclose($this->fp);
48
+		if ($this->config['debug'] == '0') {
49
+					fclose($this->fp);
50
+		}
48 51
 	}
49 52
 
50 53
 }
Please login to merge, or discard this patch.
freeswitch/fs/scripts/astpp.directory.php 2 patches
Braces   +4 added lines, -3 removed lines patch added patch discarded remove patch
@@ -28,10 +28,11 @@
 block discarded – undo
28 28
 
29 29
 if (isset($_REQUEST['user']) && isset($_REQUEST['domain'])) {
30 30
 	$xml = load_directory($logger, $db);
31
-	if ($xml == "")
32
-		xml_not_found();
31
+	if ($xml == "") {
32
+			xml_not_found();
33
+	}
33 34
 	echo $xml;
34
-}else {
35
+} else {
35 36
 	xml_not_found();
36 37
 }
37 38
 $logger->log("*************************** Directory Ends **********************************");
Please login to merge, or discard this patch.
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -31,7 +31,7 @@
 block discarded – undo
31 31
 	if ($xml == "")
32 32
 		xml_not_found();
33 33
 	echo $xml;
34
-}else {
34
+} else {
35 35
 	xml_not_found();
36 36
 }
37 37
 $logger->log("*************************** Directory Ends **********************************");
Please login to merge, or discard this patch.
freeswitch/fs/scripts/astpp.configuration.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -29,7 +29,7 @@
 block discarded – undo
29 29
 	header('Content-Type: text/xml');
30 30
 	echo $xml;
31 31
 } elseif ($_REQUEST['key_value'] == 'acl.conf') {
32
-	$xml = load_acl($logger, $db,$config);
32
+	$xml = load_acl($logger, $db, $config);
33 33
 	header('Content-Type: text/xml');
34 34
 	echo $xml;
35 35
 } else {
Please login to merge, or discard this patch.
application/modules/rates/views/view_import_termination_rate_mapper.php 3 patches
Indentation   +55 added lines, -55 removed lines patch added patch discarded remove patch
@@ -7,19 +7,19 @@  discard block
 block discarded – undo
7 7
    });
8 8
 </script> <script type="text/javascript" language="javascript"><?
9 9
    if (isset($mapto_fields) && !empty($mapto_fields)) {
10
-    foreach($mapto_fields as $csv_key => $csv_value) {
11
-    echo '$("#'.$csv_value .'-prefix").live("change", function () {';
12
-    echo 'var select = document.getElementById("'.$csv_value .'-select");';
13
-    echo 'var answer = select.options[select.selectedIndex].value;';
14
-    echo 'document.getElementById("'.$csv_value .'-display").value =  (!answer) ? document.getElementById("'.$csv_value .'-prefix").value : document.getElementById("'.$csv_value .'-prefix").value + csv_tmp_data[2][answer];';
15
-    echo '});';
16
-    echo '$("#'.$csv_value .'-select").live("change", function () {';
17
-    echo 'var select = document.getElementById("'.$csv_value .'-select");';
18
-    echo 'var answer = select.options[select.selectedIndex].value;';
19
-    echo 'document.getElementById("'.$csv_value .'-display").value = (!answer) ? document.getElementById("'.$csv_value .'-prefix").value : document.getElementById("'.$csv_value .'-prefix").value + csv_tmp_data[2][answer];';
20
-    echo '});';
21
-    }
22
-    }
10
+	foreach($mapto_fields as $csv_key => $csv_value) {
11
+	echo '$("#'.$csv_value .'-prefix").live("change", function () {';
12
+	echo 'var select = document.getElementById("'.$csv_value .'-select");';
13
+	echo 'var answer = select.options[select.selectedIndex].value;';
14
+	echo 'document.getElementById("'.$csv_value .'-display").value =  (!answer) ? document.getElementById("'.$csv_value .'-prefix").value : document.getElementById("'.$csv_value .'-prefix").value + csv_tmp_data[2][answer];';
15
+	echo '});';
16
+	echo '$("#'.$csv_value .'-select").live("change", function () {';
17
+	echo 'var select = document.getElementById("'.$csv_value .'-select");';
18
+	echo 'var answer = select.options[select.selectedIndex].value;';
19
+	echo 'document.getElementById("'.$csv_value .'-display").value = (!answer) ? document.getElementById("'.$csv_value .'-prefix").value : document.getElementById("'.$csv_value .'-prefix").value + csv_tmp_data[2][answer];';
20
+	echo '});';
21
+	}
22
+	}
23 23
    ?></script>
24 24
 <?
25 25
    if (isset($csv_tmp_data) && !empty($csv_tmp_data)) {
@@ -27,7 +27,7 @@  discard block
 block discarded – undo
27 27
    echo 'var csv_tmp_data = ' . json_encode($csv_tmp_data) . ';';
28 28
    echo '</script>';
29 29
    }
30
-    ?>
30
+	?>
31 31
 <?php
32 32
    endblock() ?>
33 33
 <?php
@@ -50,9 +50,9 @@  discard block
 block discarded – undo
50 50
                   <div class="w-box">
51 51
                      <span  style="margin-left:10px; text-align: center;background-color: none;color:#DD191D;">
52 52
                      <?php
53
-                        if (isset($error) && !empty($error)) {
54
-                        	echo $error;
55
-                        } ?>
53
+						if (isset($error) && !empty($error)) {
54
+							echo $error;
55
+						} ?>
56 56
                      </span>
57 57
                      <h3 class="padding-t-10 padding-l-16">You must either select a field from your file OR provide a default value for the following fields:</h3>
58 58
                      <p>Code,Destination,Connect Cost,Included Seconds,Per Minute Cost,Increment,Precedence,Strip,Prepend.</p>
@@ -66,10 +66,10 @@  discard block
 block discarded – undo
66 66
                            <label class="col-md-3">Trunk List:</label>
67 67
                            <div class="col-md-8">
68 68
                               <?php
69
-                                 $trunklist = form_dropdown('trunk_id', $this->db_model->build_dropdown("id,name", "trunks", "where_arr", array(
70
-                                 	"status " => "0"
71
-                                 )) , '');
72
-                                 echo $trunklist; ?>
69
+								 $trunklist = form_dropdown('trunk_id', $this->db_model->build_dropdown("id,name", "trunks", "where_arr", array(
70
+								 	"status " => "0"
71
+								 )) , '');
72
+								 echo $trunklist; ?>
73 73
                            </div>
74 74
                         </div>
75 75
 
@@ -134,28 +134,28 @@  discard block
 block discarded – undo
134 134
                   </thead>
135 135
                   <tbody>
136 136
                      <?php
137
-                        foreach($mapto_fields as $csv_key => $csv_value) {
137
+						foreach($mapto_fields as $csv_key => $csv_value) {
138 138
 
139
-                        		echo "<tr>";
140
-                        		echo "<td>" . $csv_key . '(' . $csv_value . ")</td>";
141
-                        		echo "<td><input type='text' name='".$csv_value ."-prefix' id='".$csv_value ."-prefix'></td>";
142
-                        		echo "<td>";
143
-                        		echo "<select name='".$csv_value ."-select' id='".$csv_value ."-select'>";
144
-                        		?>
139
+								echo "<tr>";
140
+								echo "<td>" . $csv_key . '(' . $csv_value . ")</td>";
141
+								echo "<td><input type='text' name='".$csv_value ."-prefix' id='".$csv_value ."-prefix'></td>";
142
+								echo "<td>";
143
+								echo "<select name='".$csv_value ."-select' id='".$csv_value ."-select'>";
144
+								?>
145 145
                      <option value=""></option>
146 146
                      <?php
147
-                        $keys = array_keys($file_data);
148
-                        for ($i = 0; $i < count($file_data); $i++) { ?>
147
+						$keys = array_keys($file_data);
148
+						for ($i = 0; $i < count($file_data); $i++) { ?>
149 149
                      <option value="<?php
150
-                        echo $file_data[$i]; ?>"><?php
151
-                        echo $file_data[$i]; ?></option>
150
+						echo $file_data[$i]; ?>"><?php
151
+						echo $file_data[$i]; ?></option>
152 152
                      <?php
153
-                        }
154
-                        echo "</td>";
155
-                        echo "<td><input type='text' name='".$csv_value ."-display' id='".$csv_value ."-display'></td>";
156
-                        echo "</tr>";
153
+						}
154
+						echo "</td>";
155
+						echo "<td><input type='text' name='".$csv_value ."-display' id='".$csv_value ."-display'></td>";
156
+						echo "</tr>";
157 157
 
158
-                        } ?>
158
+						} ?>
159 159
                   </tbody>
160 160
                </table>
161 161
                <input type="hidden" name="trunkid" value="<?php echo $trunkid ?>" />
@@ -167,30 +167,30 @@  discard block
 block discarded – undo
167 167
                <H2> Import File Data..</H2>
168 168
                <table width="100%" border="1"  class="details_table">
169 169
                   <?php
170
-                     $cnt = 1;
171
-                     foreach($csv_tmp_data as $csv_key => $csv_value) {
172
-                     	if ($csv_key < 15) {
173
-                     		echo "<tr>";
174
-                     		foreach($csv_value as $field_name => $field_val) {
175
-                     			if ($csv_key == 0) {
170
+					 $cnt = 1;
171
+					 foreach($csv_tmp_data as $csv_key => $csv_value) {
172
+					 	if ($csv_key < 15) {
173
+					 		echo "<tr>";
174
+					 		foreach($csv_value as $field_name => $field_val) {
175
+					 			if ($csv_key == 0) {
176 176
 
177
-                     				 echo "<th>".ucfirst($field_val)."</th>";
177
+					 				 echo "<th>".ucfirst($field_val)."</th>";
178 178
 
179
-                     			}
180
-                     			else {
181
-                     				echo "<td class='portlet-content'>" . $field_val . "</td>";
182
-                     				$cnt++;
183
-                     			}
184
-                     		}
179
+					 			}
180
+					 			else {
181
+					 				echo "<td class='portlet-content'>" . $field_val . "</td>";
182
+					 				$cnt++;
183
+					 			}
184
+					 		}
185 185
 
186
-                     		echo "</tr>";
187
-                     	}
188
-                     }
186
+					 		echo "</tr>";
187
+					 	}
188
+					 }
189 189
 
190
-                     echo "<tr><td colspan='" . $cnt . "'>
190
+					 echo "<tr><td colspan='" . $cnt . "'>
191 191
                                             <a href='" . base_url() . "rates/termination_rate_list/'><input type='button' class='btn btn-line-sky pull-right  margin-x-10' value='Back'/></a>
192 192
                                             <input type='submit' class='btn btn-line-parrot pull-right'' id='Process' value='Process Records'/></td></tr>";
193
-                     ?>
193
+					 ?>
194 194
                </table>
195 195
             </form>
196 196
          </div>
Please login to merge, or discard this patch.
Spacing   +25 added lines, -25 removed lines patch added patch discarded remove patch
@@ -6,25 +6,25 @@  discard block
 block discarded – undo
6 6
    $(document).ready(function() {
7 7
    });
8 8
 </script> <script type="text/javascript" language="javascript"><?
9
-   if (isset($mapto_fields) && !empty($mapto_fields)) {
10
-    foreach($mapto_fields as $csv_key => $csv_value) {
11
-    echo '$("#'.$csv_value .'-prefix").live("change", function () {';
12
-    echo 'var select = document.getElementById("'.$csv_value .'-select");';
9
+   if (isset($mapto_fields) && ! empty($mapto_fields)) {
10
+    foreach ($mapto_fields as $csv_key => $csv_value) {
11
+    echo '$("#'.$csv_value.'-prefix").live("change", function () {';
12
+    echo 'var select = document.getElementById("'.$csv_value.'-select");';
13 13
     echo 'var answer = select.options[select.selectedIndex].value;';
14
-    echo 'document.getElementById("'.$csv_value .'-display").value =  (!answer) ? document.getElementById("'.$csv_value .'-prefix").value : document.getElementById("'.$csv_value .'-prefix").value + csv_tmp_data[2][answer];';
14
+    echo 'document.getElementById("'.$csv_value.'-display").value =  (!answer) ? document.getElementById("'.$csv_value.'-prefix").value : document.getElementById("'.$csv_value.'-prefix").value + csv_tmp_data[2][answer];';
15 15
     echo '});';
16
-    echo '$("#'.$csv_value .'-select").live("change", function () {';
17
-    echo 'var select = document.getElementById("'.$csv_value .'-select");';
16
+    echo '$("#'.$csv_value.'-select").live("change", function () {';
17
+    echo 'var select = document.getElementById("'.$csv_value.'-select");';
18 18
     echo 'var answer = select.options[select.selectedIndex].value;';
19
-    echo 'document.getElementById("'.$csv_value .'-display").value = (!answer) ? document.getElementById("'.$csv_value .'-prefix").value : document.getElementById("'.$csv_value .'-prefix").value + csv_tmp_data[2][answer];';
19
+    echo 'document.getElementById("'.$csv_value.'-display").value = (!answer) ? document.getElementById("'.$csv_value.'-prefix").value : document.getElementById("'.$csv_value.'-prefix").value + csv_tmp_data[2][answer];';
20 20
     echo '});';
21 21
     }
22 22
     }
23 23
    ?></script>
24 24
 <?
25
-   if (isset($csv_tmp_data) && !empty($csv_tmp_data)) {
25
+   if (isset($csv_tmp_data) && ! empty($csv_tmp_data)) {
26 26
    echo '<script>';
27
-   echo 'var csv_tmp_data = ' . json_encode($csv_tmp_data) . ';';
27
+   echo 'var csv_tmp_data = '.json_encode($csv_tmp_data).';';
28 28
    echo '</script>';
29 29
    }
30 30
     ?>
@@ -40,7 +40,7 @@  discard block
 block discarded – undo
40 40
 <?php
41 41
    startblock('content') ?>
42 42
 <?php
43
-   if (!isset($csv_tmp_data)) { ?>
43
+   if ( ! isset($csv_tmp_data)) { ?>
44 44
 <section class="slice color-three padding-t-20">
45 45
    <div class="w-section inverse no-padding">
46 46
       <div class="container">
@@ -50,7 +50,7 @@  discard block
 block discarded – undo
50 50
                   <div class="w-box">
51 51
                      <span  style="margin-left:10px; text-align: center;background-color: none;color:#DD191D;">
52 52
                      <?php
53
-                        if (isset($error) && !empty($error)) {
53
+                        if (isset($error) && ! empty($error)) {
54 54
                         	echo $error;
55 55
                         } ?>
56 56
                      </span>
@@ -68,7 +68,7 @@  discard block
 block discarded – undo
68 68
                               <?php
69 69
                                  $trunklist = form_dropdown('trunk_id', $this->db_model->build_dropdown("id,name", "trunks", "where_arr", array(
70 70
                                  	"status " => "0"
71
-                                 )) , '');
71
+                                 )), '');
72 72
                                  echo $trunklist; ?>
73 73
                            </div>
74 74
                         </div>
@@ -100,7 +100,7 @@  discard block
 block discarded – undo
100 100
             <div class="col-md-12 padding-b-10">
101 101
                <div class="pull-right">
102 102
                   <input class="btn btn-line-parrot" id="import_terminationrate" type="submit" name="action" value="Import" />
103
-                  <a href="<?php echo base_url() . 'rates/termination_rate_list/' ?>" >
103
+                  <a href="<?php echo base_url().'rates/termination_rate_list/' ?>" >
104 104
                   <input class="btn btn-line-sky margin-x-10" id="ok" type="button" name="action" value="Cancel"/>
105 105
                   </a>
106 106
                </div>
@@ -113,7 +113,7 @@  discard block
 block discarded – undo
113 113
 <?php
114 114
    } ?>
115 115
 <?php
116
-   if (isset($csv_tmp_data) && !empty($csv_tmp_data)) { ?>
116
+   if (isset($csv_tmp_data) && ! empty($csv_tmp_data)) { ?>
117 117
 <section class="slice color-three padding-b-20">
118 118
    <div class="w-section inverse no-padding">
119 119
       <div class="container">
@@ -134,13 +134,13 @@  discard block
 block discarded – undo
134 134
                   </thead>
135 135
                   <tbody>
136 136
                      <?php
137
-                        foreach($mapto_fields as $csv_key => $csv_value) {
137
+                        foreach ($mapto_fields as $csv_key => $csv_value) {
138 138
 
139 139
                         		echo "<tr>";
140
-                        		echo "<td>" . $csv_key . '(' . $csv_value . ")</td>";
141
-                        		echo "<td><input type='text' name='".$csv_value ."-prefix' id='".$csv_value ."-prefix'></td>";
140
+                        		echo "<td>".$csv_key.'('.$csv_value.")</td>";
141
+                        		echo "<td><input type='text' name='".$csv_value."-prefix' id='".$csv_value."-prefix'></td>";
142 142
                         		echo "<td>";
143
-                        		echo "<select name='".$csv_value ."-select' id='".$csv_value ."-select'>";
143
+                        		echo "<select name='".$csv_value."-select' id='".$csv_value."-select'>";
144 144
                         		?>
145 145
                      <option value=""></option>
146 146
                      <?php
@@ -152,7 +152,7 @@  discard block
 block discarded – undo
152 152
                      <?php
153 153
                         }
154 154
                         echo "</td>";
155
-                        echo "<td><input type='text' name='".$csv_value ."-display' id='".$csv_value ."-display'></td>";
155
+                        echo "<td><input type='text' name='".$csv_value."-display' id='".$csv_value."-display'></td>";
156 156
                         echo "</tr>";
157 157
 
158 158
                         } ?>
@@ -168,17 +168,17 @@  discard block
 block discarded – undo
168 168
                <table width="100%" border="1"  class="details_table">
169 169
                   <?php
170 170
                      $cnt = 1;
171
-                     foreach($csv_tmp_data as $csv_key => $csv_value) {
171
+                     foreach ($csv_tmp_data as $csv_key => $csv_value) {
172 172
                      	if ($csv_key < 15) {
173 173
                      		echo "<tr>";
174
-                     		foreach($csv_value as $field_name => $field_val) {
174
+                     		foreach ($csv_value as $field_name => $field_val) {
175 175
                      			if ($csv_key == 0) {
176 176
 
177 177
                      				 echo "<th>".ucfirst($field_val)."</th>";
178 178
 
179 179
                      			}
180 180
                      			else {
181
-                     				echo "<td class='portlet-content'>" . $field_val . "</td>";
181
+                     				echo "<td class='portlet-content'>".$field_val."</td>";
182 182
                      				$cnt++;
183 183
                      			}
184 184
                      		}
@@ -187,8 +187,8 @@  discard block
 block discarded – undo
187 187
                      	}
188 188
                      }
189 189
 
190
-                     echo "<tr><td colspan='" . $cnt . "'>
191
-                                            <a href='" . base_url() . "rates/termination_rate_list/'><input type='button' class='btn btn-line-sky pull-right  margin-x-10' value='Back'/></a>
190
+                     echo "<tr><td colspan='".$cnt."'>
191
+                                            <a href='" . base_url()."rates/termination_rate_list/'><input type='button' class='btn btn-line-sky pull-right  margin-x-10' value='Back'/></a>
192 192
                                             <input type='submit' class='btn btn-line-parrot pull-right'' id='Process' value='Process Records'/></td></tr>";
193 193
                      ?>
194 194
                </table>
Please login to merge, or discard this patch.
Braces   +1 added lines, -2 removed lines patch added patch discarded remove patch
@@ -176,8 +176,7 @@
 block discarded – undo
176 176
 
177 177
                      				 echo "<th>".ucfirst($field_val)."</th>";
178 178
 
179
-                     			}
180
-                     			else {
179
+                     			} else {
181 180
                      				echo "<td class='portlet-content'>" . $field_val . "</td>";
182 181
                      				$cnt++;
183 182
                      			}
Please login to merge, or discard this patch.
web_interface/astpp/application/modules/login/views/view_login.php 3 patches
Indentation   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -6,12 +6,12 @@
 block discarded – undo
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']; ?>
Please login to merge, or discard this patch.
Spacing   +9 added lines, -9 removed lines patch added patch discarded remove patch
@@ -6,17 +6,17 @@  discard block
 block discarded – undo
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']);
9
+        $this->db->where('domain', $_SERVER['HTTP_HOST']);
10 10
         $this->db->select('*');
11 11
         $this->db->order_by('accountid', 'desc');
12 12
         $this->db->limit(1);
13 13
         $invoiceconf = $this->db->get('invoice_conf');
14 14
         $invoiceconf = (array)$invoiceconf->first_row();
15
-	if(isset($invoiceconf['website_title']) && $invoiceconf['website_title']!='') {
15
+	if (isset($invoiceconf['website_title']) && $invoiceconf['website_title'] != '') {
16 16
 	?>
17 17
 	Log In | <?php echo $invoiceconf['website_title']; ?>
18 18
 	<?php
19
-		}else{ 
19
+		} else { 
20 20
 	?>
21 21
 	Log In | ASTPP - Open Source Voip Billing Solution
22 22
 	<?php
@@ -54,9 +54,9 @@  discard block
 block discarded – undo
54 54
             <div class="row">
55 55
                    
56 56
                         <div class="col-md-4 col-md-offset-4">&nbsp;<span class="login_error">
57
-                        <?php if (isset($astpp_notification)){ ?>
57
+                        <?php if (isset($astpp_notification)) { ?>
58 58
                         Login unsuccessful. Please make sure you entered the correct username and password, and that your account is active.
59
-                    <?php }else{
59
+                    <?php } else {
60 60
 						 echo "&nbsp;";
61 61
 					} ?>
62 62
                     </span></div> <br/>
@@ -70,16 +70,16 @@  discard block
 block discarded – undo
70 70
                         	<h2 class="text-center">
71 71
                           
72 72
 							<?php
73
-							if(isset($this->session->userdata['user_logo']) && $this->session->userdata['user_logo'] != ""){
73
+							if (isset($this->session->userdata['user_logo']) && $this->session->userdata['user_logo'] != "") {
74 74
 								$logo = $this->session->userdata['user_logo'];
75
-							}else{
75
+							} else {
76 76
 								$logo = 'logo.png';
77 77
 							}
78 78
 
79 79
 							if ($this->session->userdata('userlevel_logintype') != '0') {?>
80
-									<img style="height:53px;width:216px;" id="logo" alt="login" src="<?php echo base_url(); ?>upload/<?php echo$logo;?>">
80
+									<img style="height:53px;width:216px;" id="logo" alt="login" src="<?php echo base_url(); ?>upload/<?php echo$logo; ?>">
81 81
 							<? } else {?> 
82
-									<img style="height:53px;width:216px;" id="logo" title='ASTPP - Open Source Voip Billing Solution' alt='login' src="<?php echo base_url(); ?>upload/<?php echo$logo;?>">
82
+									<img style="height:53px;width:216px;" id="logo" title='ASTPP - Open Source Voip Billing Solution' alt='login' src="<?php echo base_url(); ?>upload/<?php echo$logo; ?>">
83 83
 							<? }?>
84 84
                             	<div class="clear"></div>
85 85
                             
Please login to merge, or discard this patch.
Braces   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -16,7 +16,7 @@  discard block
 block discarded – undo
16 16
 	?>
17 17
 	Log In | <?php echo $invoiceconf['website_title']; ?>
18 18
 	<?php
19
-		}else{ 
19
+		} else{ 
20 20
 	?>
21 21
 	Log In | ASTPP - Open Source Voip Billing Solution
22 22
 	<?php
@@ -56,7 +56,7 @@  discard block
 block discarded – undo
56 56
                         <div class="col-md-4 col-md-offset-4">&nbsp;<span class="login_error">
57 57
                         <?php if (isset($astpp_notification)){ ?>
58 58
                         Login unsuccessful. Please make sure you entered the correct username and password, and that your account is active.
59
-                    <?php }else{
59
+                    <?php } else{
60 60
 						 echo "&nbsp;";
61 61
 					} ?>
62 62
                     </span></div> <br/>
@@ -72,7 +72,7 @@  discard block
 block discarded – undo
72 72
 							<?php
73 73
 							if(isset($this->session->userdata['user_logo']) && $this->session->userdata['user_logo'] != ""){
74 74
 								$logo = $this->session->userdata['user_logo'];
75
-							}else{
75
+							} else{
76 76
 								$logo = 'logo.png';
77 77
 							}
78 78
 
Please login to merge, or discard this patch.
web_interface/astpp/application/modules/signup/controllers/signup.php 1 patch
Indentation   +427 added lines, -427 removed lines patch added patch discarded remove patch
@@ -24,77 +24,77 @@  discard block
 block discarded – undo
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
 block discarded – undo
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
 ?>
Please login to merge, or discard this patch.