Esempio n. 1
0
 public function testCanUnsetAVariable()
 {
     $this->namespace->testUnset = 5;
     $this->assertEquals(5, $this->storage->get('testUnset'));
     $this->storage->remove('testUnset');
     $this->assertFalse(isset($this->namespace->testUnset));
     $this->assertFalse($this->storage->has('testUnset'));
 }
 /**
  * Base testing
  */
 public function testBase()
 {
     $storage = new Storage();
     $alphabet = new Alphabet('en', array(), array(), array());
     $storage->add($alphabet);
     $this->assertEquals($alphabet, $storage->get('en'));
     $this->assertEquals(array('en' => $alphabet), $storage->all());
     $storage->remove($alphabet);
     $this->assertNull($storage->get('en'));
 }
Esempio n. 3
0
	public static function configure( $home ){
		self::$home = $home;
                $js = ""; $css = "";
                if( Authorization::isAuthorized() ){
                    $files = API::getFileList( INCLUDEPATH );
                    
                    $files = array_merge(API::getFileList( PLUGINSPATH ), $files);
                    $pos = array_search("./include/cmf/js/lib.js",$files);
                    unset($files[$pos]);
                }
                else{
                    $files = API::getFileList( INCLUDEPATH,-1 );
                    $files[] = "./include/cmf/js/lib.js";
                    $files[] = "./include/cmf/css/cmf.notify.css";
                    $files[] = "./include/cmf/css/cmf.ui.css";
                }
                
                rsort($files);
                foreach ($files as $path) {

                    $ext = pathinfo($path);
                    if( substr($ext['filename'], 0,1) == '_' ) continue;
                    $ext = $ext['extension'];
                    if($ext == "js"){
                        $js .= str_replace("{PATH}", $path, Storage::get("Template::jsInclude"));
                    }else if($ext == "css")
                        $css .= str_replace("{PATH}", $path, Storage::get("Template::cssInclude"));
                }

                self::assign("TITLE", Config::$SiteConf['name']);
                self::assign("META", Config::$SiteConf['meta']);
                self::assign("JSINCLUDE", $js);
                self::assign("CSSINCLUDE", $css);
               // l(self::$vars);
	}
Esempio n. 4
0
 public function store()
 {
     $posts = \Input::get('posts');
     $results = array();
     if (count($posts)) {
         $insertData = [];
         foreach ($posts as $post) {
             $tags = isset($post['tags']) ? $post['tags'] : array();
             $result = Post::create(array('title' => $post['title'], 'body' => $post['body']));
             if (count($tags) && $result) {
                 $this->savePostTags($result->id, $tags);
             }
             array_push($results, $result);
         }
         if (count($results)) {
             $emails = json_decode(\Storage::get('emails.json'), true);
             \Mail::send('emails.post', ['results' => $results], function ($message) use($emails) {
                 $message->from(env('MAIL_FROM_ADDRESS'), env('MAIL_FROM_NAME'));
                 $message->to($emails)->subject('New posts');
             });
             Cache::forget('all_post');
             return self::makeResponse($results, 201);
         } else {
             return self::makeResponse(array(), 500, 'Server Error');
         }
     } else {
         return self::makeResponse(array(), 400, 'Bad Request');
     }
 }
Esempio n. 5
0
 /**
  * вывод html-карты сайта по шорт-коду [sitemap-html]
  */
 static function viewSitemap()
 {
     $sitemap = Storage::get(md5('mgPluginSitemapHtml'));
     if ($sitemap == null) {
         $pages = self::getPages();
         $catalog = self::getCatalog();
         $html = '
 <div class="sitemap-html">
  <h2 class="new-products-title">Карта сайта</h2>
 <ul class="js_listSiteMap">';
         foreach ($pages as $url => $title) {
             $partsUrl = URL::getSections($url);
             $priority = count($partsUrl);
             if (is_array($title)) {
                 $html .= '<li><a href="' . SITE . '/' . $url . '">' . $title[$url] . '<ul>';
                 foreach ($title as $suburl => $subtitle) {
                     if ($suburl != $url) {
                         $html .= '<li><a href="' . SITE . '/' . $suburl . '" title="' . $subtitle . '">' . $subtitle . '</a></li>';
                     }
                 }
                 $html .= '</ul></li>';
             } else {
                 $html .= '<li><a href="' . SITE . '/' . $url . '" title="' . $title . '">' . $title . '</a></li>';
                 if ($url == 'catalog') {
                     $html .= '<ul>' . $catalog . '</ul>';
                 }
             }
         }
         $sitemap = $html . '</ul></div>';
         Storage::save(md5('mgPluginSitemapHtml'), $sitemap);
     }
     return $sitemap;
 }
Esempio n. 6
0
 public function action_parse()
 {
     $source_file_content = \Storage::get('coolbaby_11082015.csv');
     $source_file_rows = explode("\n", $source_file_content);
     array_shift($source_file_rows);
     if (empty($source_file_rows)) {
         $this->error('Массив пуст');
         return;
     }
     $this->output->progressStart(count($source_file_rows));
     foreach ($source_file_rows as $row) {
         $row = trim($row);
         if (empty($row)) {
             continue;
         }
         $fields = explode(';', $row);
         $product_model = \App\Models\Product::create(['code' => trim($fields[0]), 'article' => trim($fields[1]), 'name' => trim($fields[2]), 'category_name' => trim($fields[3]), 'brand' => trim($fields[4]), 'price_2' => trim($fields[5]), 'price_1' => trim($fields[6]), 'catalog_id' => 2]);
         $source_url = 'http://' . substr(trim($fields[7]), 0, -4) . '_big.jpg';
         $media_model = new \App\Models\Media();
         $media_model->product_id = $product_model->id;
         $media_model->source_url = $source_url;
         $media_model->save();
         $this->output->progressAdvance();
     }
     $this->output->progressFinish();
 }
Esempio n. 7
0
 public function __construct($args)
 {
     //$script = file_get_contents(LIB . "/OrongoScript/Tests/test.osc");
     //$parser = new OrongoScriptParser($script);
     //$parser->startParser();
     require 'TerminalPlugin.php';
     Plugin::hookTerminalPlugin(new TerminalPlugin());
     $stored = Plugin::getSettings($args['auth_key']);
     //Access the settings in the array.
     if (isset($stored['example_setting_2']) && $stored['example_setting_2']) {
         $this->injectHTML = true;
         $this->htmlToInject = $stored['example_setting_1'];
     } else {
         $this->injectHTML = false;
     }
     $store_string = 'this is a variable';
     $bool = Storage::store('a_storage_key', $store_string, true);
     if ($bool) {
         //This will fail and return false, because overwrite = false
         $bool2 = Storage::store('a_storage_key', 'will this overwrite?', false);
         if ($bool2 == false) {
             //This wil return: this is a variable
             $returnString = Storage::get('a_storage_key');
             //Delete the storage
             Storage::delete('a_storage_key');
         }
     }
 }
Esempio n. 8
0
 /**
  * Run the database seeds.
  *
  * @return void
  */
 public function run()
 {
     Model::unguard();
     if (!Storage::disk('local')->exists('seeds/develop')) {
         $this->command->info('Dev seed data file not present. Creating...');
         $this->createData();
     } else {
         $this->data = unserialize(Storage::get('seeds/develop'));
         $this->command->info('Dev seed data file found.');
         if (count($this->data) < 7) {
             $this->command->info('Dev seed data file out of date. Creating...');
             $this->createData();
         }
     }
     foreach ($this->data as $class => $data) {
         $full_class = 'App\\' . $class;
         $model = new $full_class();
         $table = $model->getTable();
         DB::table($table)->delete();
         $chunks = array_chunk($data, 500);
         foreach ($chunks as $chunk) {
             $model::insert($chunk);
         }
         $this->command->getOutput()->writeln("<info>Seeded:</info> {$table}");
     }
 }
Esempio n. 9
0
 private static function getImg(Meeting $meeting)
 {
     $name = 'meetings/' . $meeting->id;
     if (!\Storage::exists($name)) {
         return false;
     }
     return \Storage::get($name);
 }
Esempio n. 10
0
 public function __construct()
 {
     $object = Storage::get('db', false);
     //  Sanity check
     if ($object === false) {
         return Error::log('Could not get Database class');
     }
     $this->db = $this->database = $object;
 }
Esempio n. 11
0
 public function getArticle($uri)
 {
     $environment = Environment::createCommonMarkEnvironment();
     $environment->addExtension(new TableExtension());
     $converter = new Converter(new DocParser($environment), new HtmlRenderer($environment));
     $contents = \Storage::get($uri . '.md');
     preg_match('/^.*$/m', $contents, $matches);
     return view('portal', array('body' => $converter->convertToHtml($contents), 'title' => substr($matches[0], 2)));
 }
Esempio n. 12
0
 function __construct()
 {
     $model = new Models_Product();
     // Требуется только пересчет цены товара.
     if (!empty($_REQUEST['calcPrice'])) {
         $model->calcPrice();
         exit;
     }
     $product = Storage::get(md5('ControllersProduct' . URL::getUrl()));
     if ($product == null) {
         $settings = MG::get('settings');
         $product = $model->getProduct(URL::getQueryParametr('id'));
         if (empty($product)) {
             MG::redirect('/404');
             exit;
         }
         $product['meta_title'] = $product['meta_title'] ? $product['meta_title'] : $product['title'];
         $product['currency'] = $settings['currency'];
         $blockVariants = $model->getBlockVariants($product['id']);
         $blockedProp = $model->noPrintProperty();
         $propertyFormData = $model->createPropertyForm($param = array('id' => $product['id'], 'maxCount' => $product['count'], 'productUserFields' => $product['thisUserFields'], 'action' => "/catalog", 'method' => "POST", 'ajax' => true, 'blockedProp' => $blockedProp, 'noneAmount' => false, 'noneButton' => $product['count'] ? false : true, 'titleBtn' => MG::getSetting('buttonBuyName'), 'blockVariants' => $blockVariants, 'currency_iso' => $product['currency_iso']));
         // Легкая форма без характеристик.
         $liteFormData = $model->createPropertyForm($param = array('id' => $product['id'], 'maxCount' => $product['count'], 'productUserFields' => null, 'action' => "/catalog", 'method' => "POST", 'ajax' => true, 'blockedProp' => $blockedProp, 'noneAmount' => false, 'noneButton' => $product['count'] ? false : true, 'titleBtn' => MG::getSetting('buttonBuyName'), 'blockVariants' => $blockVariants));
         //echo viewData($propertyFormData['defaultSet']);
         $product['price_course'] += $propertyFormData['marginPrice'];
         $currencyRate = MG::getSetting('currencyRate');
         $currencyShopIso = MG::getSetting('currencyShopIso');
         $product['currency_iso'] = $product['currency_iso'] ? $product['currency_iso'] : $currencyShopIso;
         $product['old_price'] = $product['old_price'] * $currencyRate[$product['currency_iso']];
         $product['old_price'] = $product['old_price'] ? $product['old_price'] : 0;
         $product['price'] = MG::priceCourse($product['price_course']);
         $product['propertyForm'] = $propertyFormData['html'];
         $product['propertyNodummy'] = $propertyFormData['propertyNodummy'];
         $product['stringsProperties'] = $propertyFormData['stringsProperties'];
         $product['liteFormData'] = $liteFormData['html'];
         $product['description'] = MG::inlineEditor(PREFIX . 'product', "description", $product['id'], $product['description']);
         $product['title'] = MG::modalEditor('catalog', $product['title'], 'edit', $product["id"]);
         // Информация об отсутствии товара на складе.
         if (MG::getSetting('printRemInfo') == "true") {
             $message = 'Здравствуйте, меня интересует товар "' . str_replace("'", "&quot;", $product['title']) . '" с артикулом "' . $product['code'] . '", но его нет в наличии.
     Сообщите, пожалуйста, о поступлении этого товара на склад. ';
             if ($product['count'] != 0) {
                 $style = 'style="display:none;"';
             }
             $product['remInfo'] = "<span class='rem-info' " . $style . ">Товара временно нет на складе!<br/><a href='" . SITE . "/feedback?message=" . $message . "'>Сообщить когда будет в наличии.</a></span>";
         }
         if ($product['count'] < 0) {
             $product['count'] = "много";
         }
         $product['related'] = $model->createRelatedForm($product['related']);
         Storage::save(md5('ControllersProduct' . URL::getUrl()), $product);
     }
     // MG::set('propertyNodummy',$product['propertyNodummy']);
     // $_SESSION['propertyNodummy'] = $product['propertyNodummy'];
     $this->data = $product;
 }
Esempio n. 13
0
 public function index()
 {
     $paths = \Storage::files('blog');
     $articles = array();
     foreach ($paths as $path) {
         preg_match('/^.*$/m', \Storage::get($path), $matches);
         $articles[] = array('uri' => substr($path, 5, -3), 'title' => substr($matches[0], 2));
     }
     return view('blog/index', array('articles' => $articles, 'title' => 'sinkcup的博客'));
 }
Esempio n. 14
0
 public function download()
 {
     $contents = Http::get($_GET["url"]);
     $fileInfo = new SplFileInfo($_GET["fname"]);
     // Add the torrent to deluge using the RPC api
     $tconfig = Storage::get("torrents");
     $client = new HTTPClient((array) $tconfig->deluge);
     $client->core->add_torrent_file($tconfig->dropPath . "/" . $fileInfo->getFilename() . ".torrent", base64_encode($contents), null);
     return $this->redirect("/?alert=" . urlencode("Torrent download started"));
 }
Esempio n. 15
0
 /**
  * @covers mychaelstyle\Storage::putContents
  */
 public function testPutContents()
 {
     $def1 = $this->dsnMap['Local'];
     $def2 = $this->dsnMap['Local2'];
     $this->object->addProvider($def2['dsn'], $def2['options']);
     $expected = 'This is put contents test';
     $this->object->putContents($this->uri_example, $expected, array('permission' => 0644));
     $result = $this->object->get($this->uri_example);
     $this->assertEquals($expected, $result);
 }
Esempio n. 16
0
 public function testLoadInvalidValueAtKey()
 {
     $redis1 = $this->getMockBuilder('\\Redis')->getMock();
     $redis1->method('get')->willReturn(false);
     $storage = new Storage($redis1, 'prefix');
     $this->assertEquals(false, $storage->get('unchecked:key'));
     $redis2 = $this->getMockBuilder('\\Redis')->getMock();
     $redis2->method('get')->willReturn([]);
     $storage = new Storage($redis2, 'prefix');
     $this->assertEquals(false, $storage->get('unchecked:key'));
 }
Esempio n. 17
0
 public function __construct()
 {
     foreach (Storage::get('objects') as $name => $class) {
         $this->{$name} = $class;
     }
     //  Set the default config from the database
     if (Config::get('autoload_config') === true and method_exists($this->model, '_loadConfig')) {
         foreach ($this->model->_loadConfig() as $key => $value) {
             Config::set($key, $value);
         }
     }
 }
Esempio n. 18
0
 static function breadcrumbs()
 {
     $breadcrumbs = Storage::get(md5('breadcrumbs' . URL::getUrl()));
     if ($breadcrumbs == null) {
         $sections = URL::getSections();
         array_splice($sections, 0, 1);
         if (SHORT_LINK == 1 && MG::get('controller') == 'controllers_product') {
             $product_url = URL::getLastSection();
             $res = DB::query('SELECT CONCAT(c.`parent_url`, c.`url`) as fullurl
       FROM `' . PREFIX . 'product` p LEFT JOIN `' . PREFIX . 'category` c 
       ON p.cat_id  = c.id WHERE p.url = ' . DB::quote($product_url));
             $cat = DB::fetchArray($res);
             $sections = explode('/', $cat['fullurl']);
             $sections[] = $product_url;
         }
         $breadcrumbs = '<a href="' . SITE . '/catalog">Каталог</a>';
         $max = count($sections);
         $i = 0;
         $par = '';
         foreach ($sections as $section) {
             $url = $section;
             $cat = 'title';
             if ($url != 'catalog') {
                 $data = self::checkURLname('*', 'category', $section, 'url', $par);
                 $url = $data[0]['parent_url'] . $section;
                 $res = $data[0]['title'];
                 $par = $data[0]['id'];
                 if (!$data[0]['title']) {
                     $cat = 'name';
                     $n = '';
                     $result = self::checkURLname('*', 'product', $section, 'url', $n);
                     $url = $data[0]['parent_url'] . $sections[1] . '/' . $sections[2];
                     $categoryRes = self::checkURLname('url, parent_url', 'category', $result[0]['cat_id'], 'id');
                     $url = $categoryRes[0]['parent_url'] . $categoryRes[0]['url'] . '/' . $result[0]['url'];
                     $res = $result[0]['title'];
                 }
             }
             $i++;
             if ($max == $i) {
                 $breadcrumbs .= ' » <span class="last-crumb">' . $res . '</span>';
             } else {
                 $breadcrumbs .= ' » <a href="' . SITE . '/' . $url . '">' . $res . '</a>';
             }
         }
         $breadcrumbs = "<div class='bread-crumbs'>" . $breadcrumbs . "</div>";
         //сохраняем объект в кэш
         Storage::save(md5('breadcrumbs' . URL::getUrl()), $breadcrumbs);
     }
     return $breadcrumbs;
 }
Esempio n. 19
0
 public function get($id)
 {
     // $entry = File::where('filename', '=', $filename)->firstOrFail();
     // $file = \Storage::disk('local')->get($entry->filename);
     // // return (new \Response($file, 200))
     //             // ->header('Content-Type', $entry->mime);
     // return response($file,200)
     //           ->header('Content-Type', $entry->mime);
     // ===============================================================================================
     // $entry = File::where('filename', '=', $filename)->firstOrFail();
     // 	if (\Storage::exists($entry->filename)) {
     // 	$file = \Storage::disk('local')->get($entry->filename);
     // 	// return (new \Response($file, 200))
     //              // ->header('Content-Type', $entry->mime);
     // 	return response($file,200)
     //            ->header('Content-Type', $entry->mime);
     // 	}
     // 	else{
     // 		return 'File Rusak atau tidak ditemukan, Silahkan Update Ulang ';
     // 	}
     $entry = File::find(base64_decode($id));
     // dd($entry);
     if ($entry) {
         $dirfile = empty($entry->nama_baru) ? $entry->filename : $entry->dir . '/' . $entry->nama_baru;
         // echo $dirfile;
         // ARSIPPROSESSP2D-UYUYphpFDCC.tmp.pdf
         // dinas-p/ARSIPPROSESSP2D-UYUYphpF441.tmp.pdf
         // dd($dirfile);
         // dd($dirfile);
         // "SEKWAN-II/164-sp2d-nhl-setwn-09-arsipprosessp2d-164-sp2d-nhl-setwn-09-phpCAC5.tmp.pdf";
         // "164-sp2d-nhl-setwn-09-arsipprosessp2d-164-sp2d-nhl-setwn-09-1-php757E.tmp"
         if (\Storage::exists($dirfile)) {
             $file = \Storage::get($dirfile);
             // return (new \Response($file, 200))
             // ->header('Content-Type', $entry->mime);
             return response($file, 200)->header('Content-Type', $entry->mime);
         } elseif (!empty($entry->filename) && \Storage::exists($entry->filename)) {
             $file = \Storage::get($entry->filename);
             // return (new \Response($file, 200))
             // ->header('Content-Type', $entry->mime);
             return response($file, 200)->header('Content-Type', $entry->mime);
         } else {
             return 'File tidak ditemukan, Silahkan Update Ulang ';
         }
     } else {
         return 'Data File Rusak atau tidak ditemukan, Silahkan Update Ulang ';
     }
 }
Esempio n. 20
0
 /**
  *html静态文件缓存
  * @access protected
  * @param string $filename 生成的静态文件名称
  * @param string $filepath 生成的静态文件路径
  * @param string $expire 静态文件缓存时间
  * @return void
 */
 protected function html_before($filename = '',$filepath = '',$expire = 15){
     $suffix = C('HTML_FILE_SUFFIX')?C('HTML_FILE_SUFFIX'):'shtml';
     if($filename === '' && $filepath === ''){
         $filename = APP_PATH.'/static/'.__ACTION__.'.'.$suffix;
     }else{
         $filename = $filename?$filename.'.'.$suffix:md5(__ACTION__).'.'.$suffix;
         $filepath = $filepath?APP_PATH.'/'.$filepath:APP_PATH.'/static';
         $filename = $filepath.'/'.$filename;
     }
     if(Storage::has($filename)){
         if(time() - Storage::get($filename,'mtime') < $expire){
             exit(Storage::read($filename));
         }
     }
     $this->filename = $filename;
 }
 public function getCityByCountry($countryCode)
 {
     $file = 'city_list_' . $countryCode;
     if (!\Storage::has('location/' . $file)) {
         $data = json_encode(\DB::table($this->cityTable)->where('countryCode', $countryCode)->orderBy('name', 'asc')->get());
         \Storage::put('location/' . $file, $data);
         return $data;
     } else {
         try {
             $city = \Storage::get('location/' . $file);
             return $city;
         } catch (\Exception $e) {
             return $e->getMessage();
         }
     }
 }
function uihelper_preprocess_pic_path($pic)
{
    $pic = trim($pic);
    //    if (defined("NEW_STORAGE") && preg_match("|^pa://|", $pic)) {
    if (preg_match("|^pa://|", $pic)) {
        $pic = Storage::get($pic);
    } else {
        if (preg_match("|^files/|", $pic)) {
            if (defined("NEW_STORAGE")) {
                throw new PAException(INVALID_ID, "Old code is prepending files/ to an image path");
            }
        } else {
            $pic = "files/{$pic}";
        }
    }
    return $pic;
}
Esempio n. 23
0
 /**
  * Display the specified resource.
  *
  * @param  int  $id
  * @return Response
  */
 public function show($filename)
 {
     $file = \Storage::get($filename);
     // Append the filename to the path where our images are located
     //$path = '/var/www/html/tucson/storage/' . \Config::get('assets.images') . $filename;
     // Initialize an instance of Symfony's File class.
     // This is a dependency of Laravel so it is readily available.
     //$file = new \Symfony\Component\HttpFoundation\File\File($path);
     // Make a new response out of the contents of the file
     // Set the response status code to 200 OK
     $response = \Response::make($file, 200);
     // Modify our output's header.
     // Set the content type to the mime of the file.
     // In the case of a .jpeg this would be image/jpeg
     $response->header('Content-type', 'image');
     // We return our image here.
     return $response;
 }
Esempio n. 24
0
 static function breadcrumbs()
 {
     $breadcrumbs = Storage::get(md5('breadcrumbs' . URL::getUrl()));
     if ($breadcrumbs == null) {
         $sections = URL::getSections();
         array_splice($sections, 0, 1);
         $breadcrumbs = '<a href="' . SITE . '/catalog">Каталог</a>';
         $max = count($sections);
         $i = 0;
         $par = '';
         foreach ($sections as $section) {
             $url = $section;
             $cat = 'title';
             if ($url != 'catalog') {
                 $data = self::checkURLname('*', 'category', $section, 'url', $par);
                 $url = $data[0]['parent_url'] . $section;
                 $res = $data[0]['title'];
                 $par = $data[0]['id'];
                 if (!$data[0]['title']) {
                     $cat = 'name';
                     $n = '';
                     $result = self::checkURLname('*', 'product', $section, 'url', $n);
                     $url = $data[0]['parent_url'] . $sections[1] . '/' . $sections[2];
                     $categoryRes = self::checkURLname('url, parent_url', 'category', $result[0]['cat_id'], 'id');
                     $url = $categoryRes[0]['parent_url'] . $categoryRes[0]['url'] . '/' . $result[0]['url'];
                     $res = $result[0]['title'];
                 }
             }
             $i++;
             if ($max == $i) {
                 $breadcrumbs .= ' » <span class="last-crumb">' . $res . '</span>';
             } else {
                 $breadcrumbs .= ' » <a href="' . SITE . '/' . $url . '">' . $res . '</a>';
             }
         }
         $breadcrumbs = "<div class='bread-crumbs'>" . $breadcrumbs . "</div>";
         //сохраняем объект в кэш
         Storage::save(md5('breadcrumbs' . URL::getUrl()), $breadcrumbs);
     }
     return $breadcrumbs;
 }
Esempio n. 25
0
 /**
  * initialize temporary files
  */
 public function initialize()
 {
     $this->tmp = tempnam(sys_get_temp_dir(), 'mychaelstyle_tmp_');
     $this->previous = tempnam(sys_get_temp_dir(), 'mychaelstyle_priv_');
     try {
         $this->storage->get($this->uri, $this->previous);
     } catch (\mychaelstyle\Exception $e) {
         // nothing to do
     }
     clearstatcache();
     if (file_exists($this->previous) && filesize($this->previous) > 0) {
         if (file_exists($this->tmp)) {
             @unlink($this->tmp);
         }
         copy($this->previous, $this->tmp);
     } else {
         @unlink($this->previous);
         $this->previous = null;
         touch($this->tmp);
     }
 }
Esempio n. 26
0
 public function details()
 {
     $volumes = Storage::get("volumes");
     $volume = null;
     $root = "/";
     if (isset($_GET["path"]) && $_GET["path"] !== "/") {
         $root = urldecode($_GET["path"]);
     }
     foreach ($volumes as $vol) {
         if ($vol->id == $_GET["id"]) {
             $volume = $vol;
             break;
         }
     }
     $folder = new DirectoryIterator($volume->path . $root);
     $files = array();
     foreach ($folder as $file) {
         if ($file->isDot()) {
             continue;
         }
         $icon = "file-o";
         $iconMap = array("pdf" => "file-pdf-o", "jpg" => "file-image-o", "png" => "file-image-o", "jpeg" => "file-image-o", "gif" => "file-image-o", "bmp" => "file-image-o", "php" => "file-code-o", "xml" => "file-code-o", "html" => "file-code-o", "cs" => "file-code-o", "js" => "file-code-o", "ts" => "file-code-o", "xls" => "file-excel-o", "xlsx" => "file-excel-o", "doc" => "file-word-o", "docx" => "file-word-o", "ppt" => "file-powerpoint-o", "pptx" => "file-powerpoint-o", "mp3" => "file-audio-o", "mpeg" => "file-audio-o", "flac" => "file-audio-o", "txt" => "file-text-o");
         if ($file->isDir()) {
             $icon = "folder-o";
         } else {
             if (isset($iconMap[$file->getExtension()])) {
                 $icon = $iconMap[$file->getExtension()];
             }
         }
         $files[] = array("name" => $file->getBasename(), "type" => $file->isDir() ? "dir" : "file", "icon" => $icon, "path" => $root . $file->getFilename(), "is_image" => strrpos($icon, "image") > -1);
     }
     usort($files, function ($a, $b) {
         return $b["type"] === "dir";
     });
     $up_path = pathinfo($root)["dirname"];
     if (substr($up_path, strlen($up_path) - 1, 1) !== "/") {
         $up_path .= "/";
     }
     return $this->renderView("volume/details", array("volume" => $volume, "page" => "volume", "files" => $files, "path" => $root, "up_path" => $up_path));
 }
Esempio n. 27
0
 public function action_load()
 {
     $source_file_content = \Storage::get('rino-group.csv');
     $source_file_rows = explode("\n", $source_file_content);
     array_shift($source_file_rows);
     if (empty($source_file_rows)) {
         $this->error('Массив пуст');
         return;
     }
     $source_file_rows = array_slice($source_file_rows, 8);
     $this->output->progressStart(count($source_file_rows));
     foreach ($source_file_rows as $row) {
         $row = trim($row);
         if (empty($row)) {
             continue;
         }
         $fields = explode(';', $row);
         $product_model = \App\Models\Product::create(['code' => trim($fields[1]), 'article' => '', 'name' => trim($fields[2]), 'category_name' => '', 'brand' => trim($fields[3]), 'in_packing' => intval($fields[4]), 'price_1' => trim($fields[5]), 'catalog_id' => 3]);
         $this->output->progressAdvance();
     }
     $this->output->progressFinish();
 }
Esempio n. 28
0
 /**
  * function that load the language
  * @param string
  * @return bool
  **/
 public static function language(string $language, string $file = null) : bool
 {
     if (file_exists(DIR_LANGUAGES . '/' . $language . '.php')) {
         require DIR_LANGUAGES . '/' . $language . '.php';
     }
     if (file_exists(DIR_LANGUAGES . '/' . $language . '/packages.php')) {
         require DIR_LANGUAGES . '/' . $language . '/packages.php';
     }
     if (file_exists(DIR_LANGUAGES . '/' . $language . '/' . $file . '.php') && !empty($file)) {
         require DIR_LANGUAGES . '/' . $language . '/' . $file . '.php';
     }
     if (!empty(Storage::get('packages'))) {
         foreach (Storage::get('packages') as $package) {
             if (file_exists(DIR_PACKAGES . '/' . $package['repertory'] . '/languages/' . $language . '.php')) {
                 require DIR_PACKAGES . '/' . $package['repertory'] . '/languages/' . $language . '.php';
             }
             if (file_exists(DIR_PACKAGES . '/' . $package['repertory'] . '/languages/' . $language . '/' . $file . '.php') && !empty($file)) {
                 require DIR_PACKAGES . '/' . $package['repertory'] . '/languages/' . $language . '/' . $file . '.php';
             }
         }
     }
     return true;
 }
Esempio n. 29
0
 public function index()
 {
     $volumes = Storage::get("volumes");
     $path = urldecode($_GET["path"]);
     $data = array("volume" => null, "file" => array(), "page" => "volume");
     foreach ($volumes as $vol) {
         if ($vol->id == $_GET["volume_id"]) {
             $data["volume"] = $vol;
             break;
         }
     }
     $file = new SplFileInfo($data["volume"]->path . $path);
     $data["embed_url"] = "file.php?volume_id=" . $data["volume"]->id . "&path=" . $path . "&embed=." . $file->getExtension();
     $data["file"]["name"] = $file->getBasename();
     $data["file"]["type"] = $file->isDir() ? "dir" : "file";
     $data["file"]["path"] = $file->getFilename();
     $data["file"]["dir"] = pathinfo($path)["dirname"] . "/";
     $fileMap = array("txt" => "textFile", "mp4" => "movieFile", "wmv" => "movieFile", "mov" => "movieFile", "jpg" => "photoFile", "png" => "photoFile", "bmp" => "photoFile", "jpeg" => "photoFile", "gif" => "photoFile", "pdf" => "pdfFile", "xls" => "excelFile", "xlsx" => "excelFile", "md" => "markdownFile", "markdown" => "markdownFile");
     if (isset($fileMap[$file->getExtension()])) {
         return $this->{$fileMap}[$file->getExtension()]($data, $file);
     } else {
         return $this->textFile($data, $file);
     }
 }
Esempio n. 30
0
 public function extraer()
 {
     $this->text = \Storage::get('/proyectos/temp.txt');
     $this->extraerProyecto();
     $this->extraerNombreProyecto();
     $this->extraerUrg();
     $this->extraerDescUrg();
     $this->extraerFechas();
     $this->extraerFondo();
     $this->extraerMontoProyecto();
     $this->extraerPartida();
     $this->extraerCog();
     $this->extraerMontoPartida();
     $this->extraerObjetivo();
     if (count($this->arr_partida) == count($this->arr_cog) && count($this->arr_partida) == count($this->arr_monto)) {
         for ($i = 0; $i < count($this->arr_partida); $i++) {
             $this->arr_recursos[$this->arr_partida[$i]]['cog'] = $this->arr_cog[$i];
             $this->arr_recursos[$this->arr_partida[$i]]['d_rm'] = $this->arr_drm[$i];
             $this->arr_recursos[$this->arr_partida[$i]]['monto'] = $this->arr_monto[$i];
             $this->arr_recursos[$this->arr_partida[$i]]['objetivo'] = $this->arr_rm_objetivo[$this->arr_partida[$i]];
             $this->arr_recursos[$this->arr_partida[$i]]['d_objetivo'] = $this->arr_rm_d_objetivo[$this->arr_partida[$i]];
         }
     }
 }