public function setUp()
 {
     $files = \Fuel\Core\File::read_dir(APPPATH . 'tests/files', 1);
     foreach ($files as $file => $val) {
         \Fuel\Core\File::delete_dir(APPPATH . 'tests/files' . DS . $file);
     }
     $this->pass = Model_Pass::forge(array('name' => 'test name', 'description' => 'desc', 'logo_text' => 'sample', 'barcode_message' => 'message', 'barcode_format' => 0, 'offer_label' => 'samaplelabel', 'offer_value' => 'samplevalue'));
     $this->pass->save();
     \Fuel\Core\Config::set('pass.files_dir', APPPATH . 'tests/files');
     $this->path = \Fuel\Core\Config::get('pass.files_dir');
     $this->manager = new Pass_File_Manager($this->pass);
     \Fuel\Core\File::copy(APPPATH . 'tests/certificate.p12', $this->manager->file_path('certificate.p12'));
 }
 public function test_generate_zip()
 {
     $manager = new Pass_File_Manager($this->pass);
     \Fuel\Core\File::copy(APPPATH . 'tests/certificate.p12', $manager->file_path('certificate.p12'));
     $cert_password = '';
     $manager->generate_file('pass.json', $this->pass->pass_json());
     $manager->generate_file('manifest.json', $this->pass->manifest($manager->files()));
     $cert = new Certificate($manager->file_path('certificate.p12'));
     $signature = $cert->signature($manager->file_path('manifest.json'), $manager->file_path('signature'));
     $manager->generate_file('signature', $signature);
     $this->assertTrue($manager->generate_zip());
     $this->assertFileExists($manager->pkpass_path());
 }
Beispiel #3
0
 public function run()
 {
     $FoursquareClient = new \Foursquare\Client();
     $file_content = File::read(DOCROOT . 'data/NY.csv', true);
     $data = Format::forge($file_content, 'csv')->to_array();
     $valid_counties = array();
     $valid_counties[] = 'BRONX';
     $valid_counties[] = 'QUEENS';
     $valid_counties[] = 'KINGS';
     $valid_counties[] = 'NEW YORK';
     $valid_counties[] = 'RICHMOND';
     $i = 0;
     $j = 0;
     foreach ($data as $key => $value) {
         if (!in_array($value['County'], $valid_counties)) {
             continue;
         }
         $i++;
         if ($i > 300) {
             break;
         }
         $match = $FoursquareClient->getVenueMapping($value['Latitude'], $value['Longitude'], $value['Store_Name']);
         if ($this->hasMatches($match, &$j)) {
             $this->logMatches($value, $match, $matches, $j, $i);
             continue;
         }
         $this->CliOutput('write', 'Stripping chars from Store_Name: ' . $value['Store_Name']);
         // remove numbers from store name
         $value['Store_Name'] = trim(preg_replace("/[0-9]/", "", $value['Store_Name']));
         $match = $FoursquareClient->getVenueMapping($value['Latitude'], $value['Longitude'], $value['Store_Name']);
         if ($this->hasMatches($match, &$j)) {
             $this->logMatches($value, $match, $matches, $j, $i);
             continue;
         }
         $this->CliOutput('error', 'No match for ' . $value['Store_Name'] . ' ' . $value['Address'] . ' ' . $value['City'] . ' ' . $value['Zip5']);
     }
     $this->CliOutput('write', 'Matches: ' . $j . '/' . $i);
 }
Beispiel #4
0
 /**
  * Update cat. background to database
  *
  * @param integer $id cat. id
  * @param string $img cat. background-img
  * @param string $old old background
  * @return boolean
  *
  * @access public
  * @since 1.0
  * @version 1.0
  * @author Nguyen Van Hiep
  * @author Dao Anh Minh
  */
 public static function save_bg($id, $img, $old = false)
 {
     try {
         if (!empty($old) and \Fuel\Core\File::exists(DOCROOT . 'assets/img/cat/' . $old)) {
             File::delete(DOCROOT . 'assets/img/cat/' . $old);
         }
         DB::update('cat')->value('bg', $img)->where('id', $id)->execute();
         File::delete(DOCROOT . 'assets/img/cat/temp/' . $img);
         DB::commit_transaction();
         return true;
     } catch (Exception $e) {
         DB::rollback_transaction();
         return false;
     }
 }
Beispiel #5
0
 public function action_image($id = null, $name = null)
 {
     $pass = Model_Pass::find($id);
     $manager = new Pass_File_Manager($pass);
     $path = $manager->file_path($name . '.png');
     $body = null;
     if (file_exists($path)) {
         $info = \Fuel\Core\File::file_info($path);
         $body = file_get_contents($path);
     }
     return Response::forge($body, 200, array('Content-Type' => 'image/png', 'Cache-Control' => 'no-cache, no-store, max-age=0, must-revalidate', 'Content-Length' => $info['size']));
 }
 public function action_create($what = null)
 {
     is_null($what) and \Fuel\Core\Response::redirect('filemanager');
     try {
         if (\Fuel\Core\Input::method() == 'POST') {
             if ($what == 'dir') {
                 $dir = \Fuel\Core\File::create_dir('/var/www/html/' . $this->_dir . '/', \Fuel\Core\Input::post('dir_name'), 0777);
                 if ($dir) {
                     \Fuel\Core\Response::redirect('filemanager');
                 }
             }
         }
     } catch (Exception $e) {
         die($e->getMessage());
     }
     \Fuel\Core\Response::redirect('filemanager');
 }
 public function remove_file($path = null)
 {
     if (file_exists($path)) {
         if (\Fuel\Core\File::delete($path)) {
             return true;
         } else {
             $this->error = 'Could not delete ' . $path;
             return false;
         }
     } else {
         return true;
     }
 }
Beispiel #8
0
 public static function delete_photo($type, $photo_name)
 {
     $image_config = Config::get('app.image');
     switch ($type) {
         case 'photo':
             $path = Config::get('app.path.root_photo');
             foreach ($image_config[$type] as $version => $size) {
                 if (File::exists($path . $version . '/' . $photo_name)) {
                     File::delete($path . $version . '/' . $photo_name);
                 }
             }
             break;
         default:
             break;
     }
 }
Beispiel #9
0
 /**
  * Xóa ngôn ngữ
  *
  * @param string $lang_dir_name language folder name
  *
  * @access public
  * @author Dao Anh Minh
  */
 public function action_delete($lang_dir_name = null)
 {
     $lang_path = APPPATH . "lang/{$lang_dir_name}";
     if (is_null($lang_dir_name) or !is_dir($lang_path) or $lang_dir_name == 'vi') {
         Session::set_flash('error', 'Ngôn ngữ không tồn tại');
     } else {
         \Fuel\Core\File::delete_dir($lang_path, true);
         Session::set_flash('success', 'Xóa ngôn ngữ thành công');
     }
     Response::redirect('admin/language');
 }
Beispiel #10
0
 public function action_remove($path)
 {
     try {
         \Fuel\Core\File::delete_dir($path);
     } catch (Exception $e) {
         die($e->getMessage());
     }
 }