bigdata_helper.php 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. <?php
  2. class bigdata {
  3. public $absolutePrefix = '';
  4. public $relativePrefix = '';
  5. static function startDataSession($data='') {
  6. $this->absolutePrefix = 'static/uploads/temps/';
  7. $this->relativePrefix = '';
  8. if ($data!='') {
  9. $temp_file_name = $this->absolutePrefix.time().".dat";
  10. file_put_contents($this->relativePrefix.$temp_file_name,$data);
  11. return $temp_file_name;
  12. }
  13. else {
  14. return false;
  15. }
  16. }
  17. static function appendDataSession($data,$temp_file_name='') {
  18. if ($data!='' && $temp_file_name!='') {
  19. $fa = fopen($this->relativePrefix.$temp_file_name,'a');
  20. fwrite($fa,$data);
  21. fclose($fa);
  22. return $temp_file_name;
  23. }
  24. else {
  25. return $temp_file_name;
  26. }
  27. }
  28. static function loadDataFile($file_name='') {
  29. if ($file_name!='') {
  30. $data = file_get_contents($file_name);
  31. return $data;
  32. }
  33. else {
  34. return false;
  35. }
  36. }
  37. }