Advertisement
Guest User

Untitled

a guest
Jul 24th, 2017
60
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.15 KB | None | 0 0
  1. public function __construct()
  2. {
  3. parent::__construct();
  4. $this->load->helper('url');
  5. }
  6.  
  7. public function my_function() {
  8. $config['upload_path'] = 'my_file_destination/';
  9. $config['allowed_types'] = 'txt';
  10. $this->load->library('upload', $config);
  11. if ($this->upload->do_upload('text_file')) {
  12.  
  13. $upload_data = $this->upload->data();
  14.  
  15.  
  16. function curl_load($number_url){
  17. curl_setopt($ch=curl_init(), CURLOPT_URL, $number_url);
  18. curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
  19. $response = curl_exec($ch);
  20. curl_close($ch);
  21. return $response;
  22. }
  23.  
  24. $number_url = base_url()."my_file_destination/".$upload_data['file_name'];
  25. $file_content = curl_load($number_url);
  26.  
  27. $mobileNO = explode(',', $file_content);
  28. $smsFormat = "Hello, this is a test message from LMS. Test Multiple sms. Let me know if you get it.";
  29.  
  30. function httpGet($url) {
  31. $ch = curl_init();
  32. curl_setopt($ch, CURLOPT_URL, $url);
  33. curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
  34.  
  35. $output = curl_exec($ch);
  36. curl_close($ch);
  37. return $output;
  38. }
  39.  
  40. $user = "my_username";
  41. $pass = "my_password";
  42. $sid = "api_key";
  43. $url = "my_sms_api";
  44. $SMSText = urlencode($smsFormat);
  45. $i = 1;
  46. foreach($mobileNO as $mobile_no){
  47. $mobile_no = '88'.$mobile_no;
  48. echo httpGet("my_sms_api/plain?user=$user&password=$pass&sender=$sid&SMSText=$SMSText&GSM=$mobile_no&type=longSMS&datacoding=1");
  49.  
  50. $sms_data = array(
  51. 'mobile_no' => $mobile_no ,
  52. 'message' => $SMSText ,
  53. 'sms_date' => date('d/m/Y')
  54. );
  55. $this->db->insert('tbl_custom_sms', $sms_data);
  56.  
  57. $i++;
  58. }
  59.  
  60. if($i = count($mobileNO)+1){
  61. redirect('customsms/index');
  62. }
  63.  
  64. }
  65. }
  66.  
  67. <IfModule mod_rewrite.c>
  68.  
  69. Options +FollowSymLinks
  70. RewriteEngine on
  71.  
  72. # Send request via index.php
  73. RewriteCond %{REQUEST_FILENAME} !-f
  74. RewriteCond %{REQUEST_FILENAME} !-d
  75. RewriteRule ^(.*)$ index.php/$1 [L]
  76.  
  77. </IfModule>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement