Advertisement
Guest User

Untitled

a guest
Feb 29th, 2016
182
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 6.11 KB | None | 0 0
  1. SipUserName = ""
  2. SipAuthName = ""
  3. DisplayName = ""
  4. Password = ""
  5. Domain = ""
  6. Proxy = ""
  7. Port = ""
  8. ServerMode = ""
  9. UCServer = 123456
  10. UCPassword = 123456
  11. DP_Exception = 123456
  12. DP_Rule1 = 123456
  13. DP_Rule2 = 123456
  14. OperationMode = 123456
  15. MutePkey = 123456
  16. Codec = 123456
  17. PTime = 123456
  18. AudioMode = 123456
  19. SoftwareAEC = 123456
  20. EchoTailLength = 123456
  21. PlaybackBuffer = 123456
  22. CaptureBuffer = 123456
  23. JBPrefetchDelay = 123456
  24. JBMaxDelay = 123456
  25. SipToS = ""
  26. RTPToS = 123456
  27. LogLevel = 123456
  28.  
  29. [INIDetails]
  30. SipUserName =
  31. SipAuthName =
  32. DisplayName =
  33. Password =
  34. Domain =
  35. Proxy =
  36. Port =
  37. ServerMode =
  38. UCServer = 123456
  39. UCPassword = 123456
  40.  
  41. [DialPlan]
  42. DP_Exception = 123456
  43. DP_Rule1 = 123456
  44. DP_Rule2 = 123456
  45.  
  46. [Advanced]
  47. OperationMode = 123456
  48. MutePkey = 123456
  49. Codec = 123456
  50. PTime = 123456
  51. AudioMode = 123456
  52. SoftwareAEC = 123456
  53. EchoTailLength = 123456
  54. PlaybackBuffer = 123456
  55. CaptureBuffer = 123456
  56. JBPrefetchDelay = 123456
  57. JBMaxDelay = 123456
  58. SipToS =
  59. RTPToS = 123456
  60. LogLevel = 123456
  61.  
  62. public function edit_ini($id)
  63. {
  64.  
  65. /*The ID wen get from View's URI*/
  66. $path = "./uploads/";
  67.  
  68. $site = $this->session->userdata('site');
  69. /*Set the path to open the file*/
  70.  
  71. $this->db->select('*');
  72.  
  73. $this->db->where('site_key',$site);
  74.  
  75. $this->db->where('id',$id);
  76. /*Here the id it the ID we got in URI from View*/
  77.  
  78. $this->db->from('base_ini');
  79.  
  80. $query = $this->db->get();
  81.  
  82. $result = $query->row();
  83.  
  84. $filename= $result->base_ini_filename;
  85.  
  86. $path= $result->file_path;
  87.  
  88. echo $this->db->last_query();
  89.  
  90. /*Setting the Path and the filename from database.*/
  91.  
  92. file_get_contents($path.$filename);
  93.  
  94.  
  95. /*Get All The Contents from that file*/
  96.  
  97. $this->data['params'] = $this->parameter_m->get();
  98. /*Getting the parameters to display on view*/
  99.  
  100. $this->data['parameters'] = parse_ini_file($path.$filename,true);
  101.  
  102.  
  103. $insert = array(
  104.  
  105. 'SipUserName' => $this->input->post('SipUserName'),
  106. 'SipAuthName' => $this->input->post('SipAuthName'),
  107. 'DisplayName' => $this->input->post('DisplayName'),
  108. 'Password' => $this->input->post('Password'),
  109. 'Domain' => $this->input->post('Domain'),
  110. 'Proxy' => $this->input->post('Proxy'),
  111. 'Port' => $this->input->post('Port'),
  112. 'ServerMode' => $this->input->post('ServerMode'),
  113. 'UCServer' => $this->input->post('UCServer'),
  114. 'UCPassword' => $this->input->post('UCPassword'),
  115. 'DP_Exception' => $this->input->post('DP_Exception'),
  116. 'DP_Rule1' => $this->input->post('DP_Rule1'),
  117. 'DP_Rule2' => $this->input->post('DP_Rule2'),
  118. 'OperationMode' => $this->input->post('OperationMode'),
  119. 'MutePkey' => $this->input->post('MutePkey'),
  120. 'Codec' => $this->input->post('Codec'),
  121. 'PTime' => $this->input->post('PTime'),
  122. 'AudioMode' => $this->input->post('AudioMode'),
  123. 'SoftwareAEC' => $this->input->post('SoftwareAEC'),
  124. 'EchoTailLength' => $this->input->post('EchoTailLength'),
  125. 'PlaybackBuffer' => $this->input->post('PlaybackBuffer'),
  126. 'CaptureBuffer' => $this->input->post('CaptureBuffer'),
  127. 'JBPrefetchDelay' => $this->input->post('JBPrefetchDelay'),
  128. 'JBMaxDelay' => $this->input->post('JBMaxDelay'),
  129. 'SipToS' => $this->input->post('SipToS'),
  130. 'RTPToS' => $this->input->post('RTPToS'),
  131. 'LogLevel' => $this->input->post('LogLevel')
  132.  
  133.  
  134.  
  135.  
  136.  
  137. );
  138.  
  139.  
  140. $this->load->helper('file');
  141.  
  142.  
  143. $file = $path.$filename;
  144.  
  145.  
  146. function write_php_ini($array, $file)
  147. {
  148. $res = array();
  149. foreach($array as $key => $val)
  150. {
  151. if(is_array($val))
  152. {
  153. $res[] = "[$key]";
  154. foreach($val as $skey => $sval) $res[] = "$skey = ".(is_numeric($sval) ? $sval : '"'.$sval.'"');
  155. }
  156. else $res[] = "$key = ".(is_numeric($val) ? $val : '"'.$val.'"');
  157. }
  158. safefilerewrite($file, implode("rn", $res));
  159. }
  160.  
  161. function safefilerewrite($fileName, $dataToSave)
  162. { if ($fp = fopen($fileName, 'w'))
  163. {
  164. $startTime = microtime(TRUE);
  165. do
  166. { $canWrite = flock($fp, LOCK_EX);
  167. // If lock not obtained sleep for 0 - 100 milliseconds, to avoid collision and CPU load
  168. if(!$canWrite) usleep(round(rand(0, 100)*1000));
  169. } while ((!$canWrite)and((microtime(TRUE)-$startTime) < 5));
  170.  
  171. //file was locked so now we can store information
  172. if ($canWrite)
  173. { fwrite($fp, $dataToSave);
  174. flock($fp, LOCK_UN);
  175. }
  176. fclose($fp);
  177. }
  178.  
  179. }
  180.  
  181.  
  182. /*Inserting The Data into .ini File*/
  183. write_php_ini($insert,$file);
  184.  
  185. /*Back to you index page id data is submmited*/
  186. if(isset($_POST['submit'] ))
  187. {
  188. redirect('customer/upload_ini/index');
  189. }
  190.  
  191. $this->data['subview'] = 'customer/upload/edit_ini';
  192. $this->load->view('customer/_layout_main', $this->data);
  193.  
  194.  
  195.  
  196. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement