function proxyAction()
 {
     // time to get params from get
     /* @var $request Zend_Controller_Request_Http */
     $request = $this->getRequest();
     if (!$this->plugin->config('proxy.enabled', true) && !X_VlcShares_Plugins::helpers()->devices()->isWiimc()) {
         throw new Exception(X_Env::_('p_animeftw_err_proxydisabled'));
     }
     // this action is so special.... no layout or viewRenderer
     $this->_helper->viewRenderer->setNoRender();
     $this->_helper->layout->disableLayout();
     $videoUrl = $request->getParam('v', false);
     // video file url
     $refererUrl = $request->getParam('r', false);
     // referer page needed
     if ($videoUrl === false || $refererUrl === false) {
         // invalid request
         throw new Exception(X_Env::_('p_animeftw_err_invalidrequest'));
         return;
     }
     $videoUrl = X_Env::decode($videoUrl);
     $refererUrl = X_Env::decode($refererUrl);
     // if user abort request (vlc/wii stop playing, this process ends
     ignore_user_abort(false);
     // close and clean the output buffer, everything will be read and send to device
     ob_end_clean();
     //$userAgent = $this->plugin->config('hide.useragent', true) ? 'User-Agent: vlc-shares/'.X_VlcShares::VERSION : 'User-Agent: Mozilla/5.0 (X11; Linux i686; rv:2.0.1) Gecko/20101019 Firefox/4.0.1';
     $userAgent = 'User-Agent: vlc-shares/' . X_VlcShares::VERSION . ' animeftw/' . X_VlcShares_Plugins_AnimeFTW::VERSION;
     $opts = array('http' => array('header' => array("Referer: {$refererUrl}", "User-Agent: {$userAgent}")));
     $context = stream_context_create($opts);
     // readfile open a file and send it directly to output buffer
     readfile($videoUrl, false, $context);
 }
 public function startEngine(X_Threads_Thread $thread)
 {
     // assume all parameters are ready
     $thread->log("Spawning RTMPDump (rtmpdump-weebtv | vlc)...");
     $source = $this->getParam('source');
     // set the path
     if (X_Env::isWindows()) {
         X_RtmpDumpWeebTv::getInstance()->setPath(APPLICATION_PATH . '/../bin/rtmpdump-weebtv-win/rtmpdump-weebtv.exe');
     } else {
         X_RtmpDumpWeebTv::getInstance()->setPath(APPLICATION_PATH . '/../bin/rtmpdump-weebtv-linux/rtmpdump-weebtv');
     }
     $weebPlugin = X_VlcShares_Plugins::broker()->getPlugins('weebtv');
     if ($weebPlugin instanceof X_VlcShares_Plugins_WeebTv && X_VlcShares_Plugins::helpers()->streamer()->isRegistered('vlc')) {
         // try to get reference to vlc-streamer
         /* @var $vlcStreamer X_Streamer_Engine_Vlc */
         $vlcStreamer = X_VlcShares_Plugins::helpers()->streamer()->get('vlc');
         // get the channel id
         $source = substr($source, strlen('rtmpdump-weebtv://'));
         // make the plugin to parse params from server and build a rtmpdump-weebtv uri
         $source = $weebPlugin->getLinkParams($source);
         // always live
         $command = (string) X_RtmpDumpWeebTv::getInstance()->parseUri($source);
         $vlcStreamer->getVlcWrapper()->setPipe($command);
         $vlcStreamer->setSource('-');
         $vlcStreamer->setParam('profile', "#std{access=http{mime=video/x-flv},mux=ffmpeg{mux=flv},dst=0.0.0.0:{$weebPlugin->getStreamingPort()}/stream}");
         // redirect std error to null
         // and force quite
         //X_Env::execute("$command -q 2> /dev/null", X_Env::EXECUTE_OUT_NONE, X_Env::EXECUTE_PS_WAIT);
         //X_Env::execute($command, X_Env::EXECUTE_OUT_NONE, X_Env::EXECUTE_PS_WAIT);
         $vlcStreamer->getVlcWrapper()->spawn();
         $thread->log("RTMPDump execution finished");
     } else {
         $thread->log("RTMPDump-weebtv cannot be started without weebtv plugin and vlc streamer");
     }
 }
 public function addAction()
 {
     $request = $this->getRequest();
     $form = new Application_Form_Bookmark();
     $form->setAction($this->_helper->url('add'));
     if ($this->getRequest()->isPost()) {
         if ($form->isValid($request->getPost())) {
             $bookmark = new Application_Model_Bookmark();
             $id = $request->getParam('id', false);
             if ($id !== false && !is_null($id)) {
                 Application_Model_BookmarksMapper::i()->find($id, $bookmark);
                 if ($bookmark->isNew() || $bookmark->getId() != $id) {
                     throw new Exception(X_Env::_('p_bookmarks_err_invalidid'));
                 }
             }
             $url = $form->getValue('url');
             $title = $form->getValue('title');
             $description = $form->getValue('description');
             $thumbnail = $form->getValue('thumbnail');
             $bookmark->setUrl($url);
             $bookmark->setTitle($title);
             $bookmark->setThumbnail($thumbnail);
             $bookmark->setDescription($description);
             Application_Model_BookmarksMapper::i()->save($bookmark);
             //return $this->_helper->redirector('index');
             $this->_helper->redirector('index', 'bookmarks');
         }
     }
     $this->view->form = $form;
 }
 public function init()
 {
     // Set the method for the display form to POST
     $this->setMethod('post');
     $this->addElement('select', 'hoster', array('label' => X_Env::_('p_onlinelibrary_form_hoster_name'), 'description' => X_Env::_('p_onlinelibrary_form_hoster_description'), 'required' => true, 'filters' => array('StringTrim')));
     $this->addElement('text', 'idVideo', array('label' => X_Env::_('p_onlinelibrary_form_idvideo_name'), 'description' => X_Env::_('p_onlinelibrary_form_idvideo_description'), 'required' => true, 'filters' => array('StringTrim')));
     $this->addElement('text', 'category', array('label' => X_Env::_('p_onlinelibrary_form_category_name'), 'description' => X_Env::_('p_onlinelibrary_form_category_description'), 'required' => true, 'validators' => array(array('validator' => 'StringLength', 'options' => array(0, 50)))));
     $this->addElement('checkbox', 'check', array('label' => X_Env::_('p_onlinelibrary_form_check_name'), 'description' => X_Env::_('p_onlinelibrary_form_check_description'), 'required' => false));
     // Add the comment element
     $this->addElement('text', 'title', array('label' => X_Env::_('p_onlinelibrary_form_title_name'), 'description' => X_Env::_('p_onlinelibrary_form_title_description'), 'required' => false, 'validators' => array(array('validator' => 'StringLength', 'options' => array(0, 50)))));
     $this->addElement('textarea', 'description', array('label' => X_Env::_('p_onlinelibrary_form_description_name'), 'description' => X_Env::_('p_onlinelibrary_form_description_description'), 'rows' => '5', 'filters' => array('StripTags'), 'required' => false));
     // Add the comment element
     $this->addElement('text', 'thumbnail', array('label' => X_Env::_('p_onlinelibrary_form_thumbnail_name'), 'description' => X_Env::_('p_onlinelibrary_form_thumbnail_description'), 'required' => false));
     // Add the submit button
     $this->addElement('submit', 'submit', array('ignore' => true, 'label' => X_Env::_('p_onlinelibrary_form_submit')));
     // Add the submit button
     $this->addElement('button', 'abort', array('onClick' => 'javascript:history.back();', 'ignore' => true, 'label' => X_Env::_('p_onlinelibrary_form_abort')));
     $this->addDisplayGroup(array('submit', 'abort'), 'buttons', array('decorators' => $this->getDefaultButtonsDisplayGroupDecorators()));
     /*
     // And finally add some CSRF protection
     $this->addElement('hash', 'csrf', array(
         'ignore' => true,
     ));
     */
 }
Beispiel #5
0
 /**
  * Execute vlcwrapper initialization on the first request
  */
 private function lazyInit()
 {
     if ($this->_initialized === false) {
         $options = $this->options;
         $adapterConf = $options->get('adapter', new Zend_Config(array()));
         $adapter = $adapterConf->get('name', "X_Vlc_Adapter_" . (X_Env::isWindows() ? 'Windows' : 'Linux'));
         X_Debug::i("Adapter: {$adapter}");
         $this->adapter = new $adapter($options);
         $commanderConf = $options->get('commander', new Zend_Config(array()));
         $commander = $commanderConf->get('name', '');
         $commanderPath = $commanderConf->get('path', '');
         if ($commanderPath != '' && file_exists($commanderPath)) {
             X_Debug::i("Including commanderPath: {$commanderPath}");
             include_once $commanderPath;
         }
         if (class_exists($commander, true) && array_key_exists('X_Vlc_Commander', class_parents($commander))) {
             X_Debug::i("Commander: {$commander}");
             $commander = new $commander($options);
             $this->adapter->setCommander($commander);
         } else {
             X_Debug::w("Commander: no selection");
         }
         $this->_conf_vlcArgs = $options->get('args', "{%source%} --play-and-exit --sout=\"#{%profile%}:{%output%}\" --sout-keep {%subtitles%} {%audio%} {%filters%}");
         $this->_conf_vlcPath = $options->get('path', "vlc");
         $this->_initialized = true;
     }
 }
 public function forceKill()
 {
     if (!X_Env::isWindows()) {
         X_Env::execute("kill -9 `ps aux | grep {$this->path} | grep -v grep | awk '{print \$2}'`", X_Env::EXECUTE_OUT_NONE, X_Env::EXECUTE_PS_WAIT);
     } else {
         X_Env::execute("taskkill /IM SopCast.exe /F", X_Env::EXECUTE_OUT_NONE, X_Env::EXECUTE_PS_WAIT);
     }
 }
 public function gen_afterPageBuild(X_Page_ItemList_PItem $items, Zend_Controller_Action $controller)
 {
     if (count($items->getItems()) == 0) {
         X_Debug::i("Plugin triggered");
         $item = new X_Page_Item_PItem('emptylists', X_Env::_('p_emptylists_moveaway'));
         $item->setType(X_Page_Item_PItem::TYPE_ELEMENT)->setLink(X_Env::completeUrl($controller->getHelper('url')->url()));
         $items->append($item);
     }
 }
 public function init()
 {
     parent::init();
     if (!X_VlcShares_Plugins::broker()->isRegistered('upnprenderer')) {
         throw new Exception(X_Env::_('err_pluginnotregistered') . ": upnprenderer");
     } else {
         $this->plugin = X_VlcShares_Plugins::broker()->getPlugins('upnprenderer');
     }
 }
 public function startEngine(X_Threads_Thread $thread)
 {
     // assume all parameters are ready
     $thread->log("Spawning SopCast...");
     $source = $this->getParam('source');
     $command = (string) X_SopCast::getInstance()->setUri($source);
     X_Env::execute($command, X_Env::EXECUTE_OUT_NONE, X_Env::EXECUTE_PS_WAIT);
     //$this->vlc->spawn();
     $thread->log("SopCast execution finished");
 }
 public function init()
 {
     // Set the method for the display form to POST
     $this->setMethod('post')->setAttrib('enctype', 'multipart/form-data');
     $this->addElement('hidden', 'key', array('ignore' => false, 'decorators' => array('ViewHelper'), 'required' => true));
     // Add the submit button
     $this->addElement('submit', 'submit', array('ignore' => true, 'label' => X_Env::_('plugin_action_uninstall'), 'decorators' => array('ViewHelper')));
     // And finally add some CSRF protection
     $this->addElement('hash', 'csrf', array('ignore' => true, 'salt' => 'plugin_uconfirm_salt', 'decorators' => array('ViewHelper')));
     $this->addDisplayGroup(array('submit', 'csrf', 'key'), 'buttons', array('decorators' => $this->getDefaultButtonsDisplayGroupDecorators()));
 }
 public function init()
 {
     // Set the method for the display form to POST
     $this->setMethod('post')->setAttrib('enctype', 'multipart/form-data');
     $this->addElement('file', 'file', array('label' => X_Env::_('plugin_install_label'), 'description' => X_Env::_('plugin_install_desc'), 'required' => true, 'filters' => array('StringTrim'), 'destination' => APPLICATION_PATH . '/../data/plugin/', 'validators' => array(array('validator' => 'Count', 'options' => array(false, 1)), array('validator' => 'Size', 'options' => array(false, ini_get('upload_max_filesize'))), array('validator' => 'Extension', 'options' => array(false, 'zip,xegg'))), 'decorators' => array('CompositeFile')));
     // Add the submit button
     $this->addElement('submit', 'submit', array('ignore' => true, 'label' => X_Env::_('plugin_installsubmit')));
     // And finally add some CSRF protection
     $this->addElement('hash', 'csrf', array('ignore' => true, 'salt' => 'plugin_install_salt'));
     $this->addDisplayGroup(array('submit', 'csrf'), 'buttons', array('decorators' => $this->getDefaultButtonsDisplayGroupDecorators()));
 }
 public function gen_afterPageBuild(X_Page_ItemList_PItem $items, Zend_Controller_Action $controller)
 {
     if ($this->helpers()->devices()->isWiimc() && $this->helpers()->devices()->isWiimcBeforeVersion('1.0.9')) {
         if (count($items->getItems()) === 1) {
             X_Debug::i("Plugin triggered");
             $item = new X_Page_Item_PItem('workaroundwiimcplaylistitemsbug', '-- Workaround for bug in Wiimc <= 1.0.9 --');
             $item->setType(X_Page_Item_PItem::TYPE_ELEMENT)->setLink(X_Env::completeUrl($controller->getHelper('url')->url()));
             $items->append($item);
         }
     }
 }
 /**
  * 
  * @param DirectoryIterator $entry
  */
 private function _checkEntry($entry)
 {
     if (X_Env::isWindows()) {
         return !$this->_isHiddenOnWindows($entry);
     } else {
         // in linux, hidden files start with .
         if (substr(pathinfo($entry, PATHINFO_BASENAME), 0, 1) == '.') {
             return false;
         }
     }
     return true;
 }
 /**
  * Add the button BackToStream in controls page
  *
  * @param X_Streamer_Engine $engine
  * @param Zend_Controller_Action $controller the controller who handle the request
  * @return array
  */
 public function preGetControlItems(X_Streamer_Engine $engine, Zend_Controller_Action $controller)
 {
     // ignore if the streamer is not vlc
     if (!$engine instanceof X_Streamer_Engine_RtmpDump) {
         return;
     }
     $outputLink = "http://{%SERVER_NAME%}:{$this->helpers()->rtmpdump()->getStreamPort()}/";
     $outputLink = str_replace(array('{%SERVER_IP%}', '{%SERVER_NAME%}'), array($_SERVER['SERVER_ADDR'], strstr($_SERVER['HTTP_HOST'], ':') ? strstr($_SERVER['HTTP_HOST'], ':') : $_SERVER['HTTP_HOST']), $outputLink);
     $item = new X_Page_Item_PItem($this->getId(), X_Env::_('p_profiles_backstream'));
     $item->setType(X_Page_Item_PItem::TYPE_PLAYABLE)->setIcon('/images/icons/play.png')->setLink($outputLink);
     return new X_Page_ItemList_PItem(array($item));
 }
 public function scriptAction()
 {
     $hosters = X_VlcShares_Plugins::helpers()->hoster()->getHosters();
     $csrf = new Zend_Form_Element_Hash('csrf', array('salt' => __CLASS__));
     $csrf->initCsrfToken();
     $this->view->hosters = $hosters;
     $this->view->frameUrl = X_Env::completeUrl($this->_helper->url->url(array('controller' => 'bookmarklets', 'action' => 'frame')));
     $this->view->cssUrl = X_Env::completeUrl($this->_helper->viewRenderer->view->baseUrl('/css/bookmarklets/injected.css'));
     $this->view->xfcUrl = X_Env::completeUrl($this->_helper->viewRenderer->view->baseUrl('/js/jquery.xfc.js'));
     $this->_helper->layout->disableLayout();
     $this->_helper->viewRenderer->setViewSuffix('pjs');
     $this->getResponse()->setHeader('Content-Type', 'application/javascript');
 }
 public function init()
 {
     $this->setName('aclclass');
     // Set the method for the display form to POST
     $this->setMethod('post');
     $this->addElement('text', 'name', array('label' => X_Env::_('p_auth_form_acl_class_name_label'), 'required' => true, 'filters' => array('StringTrim')));
     $this->addElement('text', 'description', array('label' => X_Env::_('p_auth_form_acl_class_description_label'), 'required' => false, 'filters' => array('StringTrim'), 'validators' => array(array('validator' => 'StringLength', 'options' => array(0, 255)))));
     // Add the submit button
     $this->addElement('submit', 'submit', array('ignore' => true, 'label' => X_Env::_('submit'), 'decorators' => array('ViewHelper')));
     // And finally add some CSRF protection
     $this->addElement('hash', 'csrf', array('ignore' => true, 'salt' => __CLASS__));
     $this->addDisplayGroup(array('submit', 'csrf'), 'buttons', array('decorators' => $this->getDefaultButtonsDisplayGroupDecorators()));
 }
 /**
  * Show the dashboard
  */
 public function indexAction()
 {
     /* @var $messages X_Page_ItemList_Message */
     $messages = new X_Page_ItemList_Message();
     $messages->merge(X_VlcShares_Plugins::broker()->getIndexMessages($this));
     $fm = $this->_helper->flashMessenger->getMessages();
     foreach ($fm as $i => $m) {
         $_m = new X_Page_Item_Message("fm-{$i}", '');
         if (is_array($m)) {
             if (array_key_exists('type', $m)) {
                 $_m->setType($m['type']);
             }
             if (array_key_exists('text', $m)) {
                 $_m->setLabel($m['text']);
             }
         } else {
             $_m->setType(X_Page_Item_Message::TYPE_WARNING)->setLabel((string) $m);
         }
         $messages->append($_m);
     }
     $news = X_VlcShares_Plugins::broker()->getIndexNews($this);
     $manageLinks = new X_Page_ItemList_ManageLink();
     $item = new X_Page_Item_ManageLink('core-manage-browse', X_Env::_('manage_goto_browsetitle'));
     $item->setTitle(X_Env::_('manage_goto_browse'))->setIcon('/images/manage/browse.png')->setLink(array('controller' => 'index', 'action' => 'collections'), 'default', true);
     $manageLinks->append($item);
     $item = new X_Page_Item_ManageLink('core-manage-test', X_Env::_('manage_goto_testtitle'));
     $item->setTitle(X_Env::_('manage_goto_test'))->setIcon('/images/manage/test.png')->setLink(array('controller' => 'test', 'action' => 'index'), 'default', true);
     $manageLinks->append($item);
     $item = new X_Page_Item_ManageLink('core-manage-configs', X_Env::_('manage_goto_configstitle'));
     $item->setTitle(X_Env::_('manage_goto_configs'))->setIcon('/images/manage/configs.png')->setLink(array('controller' => 'gconfigs', 'action' => 'index'), 'default', true);
     $manageLinks->append($item);
     $item = new X_Page_Item_ManageLink('core-manage-threads', X_Env::_('manage_goto_threadstitle'));
     $item->setTitle(X_Env::_('manage_goto_threads'))->setIcon('/images/manage/threads.png')->setLink(array('controller' => 'tmanager', 'action' => 'index'), 'default', true);
     $manageLinks->append($item);
     $manageLinks->merge(X_VlcShares_Plugins::broker()->getIndexManageLinks($this));
     // fetch links from plugins
     $actionLinks = X_VlcShares_Plugins::broker()->getIndexActionLinks($this);
     $statistics = X_VlcShares_Plugins::broker()->getIndexStatistics($this);
     $this->view->version = X_VlcShares::VERSION;
     //$this->view->configPath = X_VlcShares::config();
     //$this->view->test = $this->_helper->url('index', 'test');
     //$this->view->pcstream = $this->_helper->url('pcstream', 'index');
     //$this->view->pcstream_enabled = ($this->options->pcstream->get('commanderEnabled', false) && $this->vlc->isRunning());
     $this->view->actionLinks = $actionLinks;
     $this->view->manageLinks = $manageLinks;
     $this->view->statistics = $statistics;
     $this->view->news = $news;
     $this->view->messages = $messages;
     // i need to get first class links
 }
 public function init()
 {
     $this->setName('aclresource');
     // Set the method for the display form to POST
     $this->setMethod('post');
     $this->addElement('text', 'key', array('label' => X_Env::_('p_auth_form_acl_resource_key_label'), 'description' => X_Env::_('p_auth_form_acl_resource_key_desc'), 'required' => true, 'filters' => array('StringTrim')));
     $this->addElement('select', 'class', array('label' => X_Env::_('p_auth_form_acl_resource_class_label'), 'description' => X_Env::_('p_auth_form_acl_resource_class_desc'), 'required' => true));
     $this->addElement('select', 'generator', array('label' => X_Env::_('p_auth_form_acl_resource_generator_label'), 'description' => X_Env::_('p_auth_form_acl_resource_generator_desc'), 'required' => true));
     // Add the submit button
     $this->addElement('submit', 'submit', array('ignore' => true, 'label' => X_Env::_('submit'), 'decorators' => array('ViewHelper')));
     // And finally add some CSRF protection
     $this->addElement('hash', 'csrf', array('ignore' => true, 'salt' => __CLASS__));
     $this->addDisplayGroup(array('submit', 'csrf'), 'buttons', array('decorators' => $this->getDefaultButtonsDisplayGroupDecorators()));
 }
 public function init()
 {
     // Set the method for the display form to POST
     $this->setMethod('post');
     $this->addElement('text', 'label', array('label' => X_Env::_('p_filesystem_share_label_label'), 'description' => X_Env::_('p_filesystem_share_label_desc'), 'required' => true, 'filters' => array('StringTrim')));
     $this->addElement('text', 'path', array('label' => X_Env::_('p_filesystem_share_path_label'), 'description' => X_Env::_('p_filesystem_share_path_desc'), 'required' => true, 'filters' => array('StringTrim'), 'validators' => array(array('validator' => 'StringLength', 'options' => array(0, 255)))));
     // Add the submit button
     $this->addElement('submit', 'submit', array('ignore' => true, 'label' => X_Env::_('submit')));
     // Add the submit button
     $this->addElement('reset', 'abort', array('ignore' => true, 'label' => X_Env::_('abort')));
     // And finally add some CSRF protection
     $this->addElement('hash', 'csrf', array('ignore' => true, 'salt' => __CLASS__));
     $this->addElement('hidden', 'id', array('ignore' => true, 'required' => false));
     $this->addDisplayGroup(array('submit', 'csrf', 'id', 'abort'), 'buttons', array('decorators' => $this->getDefaultButtonsDisplayGroupDecorators()));
 }
 public function init()
 {
     // Set the method for the display form to POST
     $this->setMethod('post');
     $decorators = array(array('ViewHelper'), array('Errors'), array('Description', array('tag' => 'p', 'class' => 'description')));
     $this->addElement('text', 'label', array('label' => X_Env::_('p_youtube_form_account_label'), 'description' => X_Env::_('p_youtube_form_account_label_desc'), 'required' => true, 'filters' => array('StringTrim')));
     // Add the submit button
     $this->addElement('submit', 'submit', array('ignore' => true, 'label' => X_Env::_('submit')));
     // Add the submit button
     $this->addElement('reset', 'abort', array('ignore' => true, 'label' => X_Env::_('abort')));
     // And finally add some CSRF protection
     $this->addElement('hash', 'csrf', array('ignore' => true, 'salt' => 'p_youtube_account_new_salt'));
     $this->addElement('hidden', 'id', array('ignore' => true, 'required' => false));
     $this->addDisplayGroup(array('submit', 'abort', 'csrf', 'id'), 'buttons', array('decorators' => $this->getDefaultButtonsDisplayGroupDecorators()));
 }
 /**
  * Retrieve news from plugins
  * @param Zend_Controller_Action $this
  * @return X_Page_ItemList_News
  */
 public function getIndexNews(Zend_Controller_Action $controller)
 {
     try {
         $view = $controller->getHelper('viewRenderer');
         $view->view->headScript()->appendFile('http://www.google.com/jsapi');
         $view->view->headScript()->appendFile($view->view->baseUrl("/js/widgetdevnews/script.js"));
         $view->view->headLink()->appendStylesheet($view->view->baseUrl('/css/widgetdevnews/style.css'));
         $text = (include dirname(__FILE__) . '/WidgetDevNews.commits.phtml');
         $item = new X_Page_Item_News($this->getId(), '');
         $item->setTab(X_Env::_('p_widgetdevnews_commits_tab'))->setContent($text);
         return new X_Page_ItemList_News(array($item));
     } catch (Exception $e) {
         X_Debug::e('No view O_o');
     }
 }
 /**
  * get an array with standard information about the playable
  * @param string $url the hoster page or resource ID
  * @param boolean $isId
  * @return array format:
  * 		array(
  * 			'title' => TITLE
  * 			'description' => DESCRIPTION
  * 			'length' => LENGTH
  * 			...
  * 		)
  */
 function getPlayableInfos($url, $isId = true)
 {
     if (!$isId) {
         $url = $this->getResourceId($url);
     }
     // use cached values
     if (array_key_exists($url, $this->info_cache)) {
         return $this->info_cache[$url];
     }
     // use the api
     $http = new Zend_Http_Client("http://www.4shared.com/video/" . $url, array('headers' => array('User-Agent' => "vlc-shares/" . X_VlcShares::VERSION . " 4shared/" . X_VlcShares_Plugins_4Shared::VERSION)));
     $xml = $http->request()->getBody();
     if (preg_match('/<!--\\/\\/ ref\\:null-->/', $xml)) {
         throw new Exception("Invalid ID {{$url}}", self::E_ID_INVALID);
     }
     $matches = array();
     if (!preg_match('/<h1 id\\=\\"fileNameText\\">(?P<title>[^\\<]+)<\\/h1>/', $xml, $matches)) {
         $title = X_Env::_('p_4shared_title_not_setted');
     }
     $title = $matches['title'];
     $matches = array();
     if (!preg_match('/<h2 id\\=\\"fileDescriptionText\\">(?P<description>[^\\<]+)<\\/h2>/', $xml, $matches)) {
         $description = '';
     }
     $description = $matches['description'];
     /*
     $matches = array();
     if ( !preg_match('/length\=\"(?P<length>[^\"]+)\"/', $xml, $matches)  ) {
     	$length = '';
     }
     $length = $matches['length'];
     */
     $length = 0;
     $matches = array();
     if (!preg_match('/image: \\"(?P<thumbnail>[^\\"]+)\\",/', $xml, $matches)) {
         $thumbnail = '';
     }
     $thumbnail = $matches['thumbnail'];
     $matches = array();
     if (!preg_match('/file: \\"(?P<video>[^\\"]+)\\"/', $xml, $matches)) {
         $video = '';
     }
     $video = $matches['video'];
     $infos = array('title' => $title, 'description' => $description, 'length' => $length, 'thumbnail' => $thumbnail, 'url' => $video);
     // add in cache
     $this->info_cache[$url] = $infos;
     return $infos;
 }
 public function getModeItems($provider, $location, Zend_Controller_Action $controller)
 {
     $list = new X_Page_ItemList_PItem();
     $urlHelper = $controller->getHelper('url');
     if ($this->countdown > 0) {
         $countdown = new X_Page_Item_PItem('core-countdown', X_Env::_('core_countdown', $this->countdown));
         $countdown->setType(X_Page_Item_PItem::TYPE_ELEMENT)->setIcon("/images/{$this->getId()}/logo.png")->setLink(X_Env::completeUrl($urlHelper->url()));
         $list->append($countdown);
     }
     if ($this->error_message) {
         $error = new X_Page_Item_PItem('core-error', X_Env::_($this->error_message));
         $error->setType(X_Page_Item_PItem::TYPE_ELEMENT)->setIcon("/images/{$this->getId()}/logo.png")->setLink(X_Env::completeUrl($urlHelper->url()));
         $list->append($error);
     }
     return $list;
 }
 public function run($params = array(), X_Threads_Thread $thread)
 {
     $this->thread = $thread;
     $streamerId = X_Env::isset_or($params['streamerId'], false);
     $streamerClass = X_Env::isset_or($params['streamerClass'], false);
     $params = X_Env::isset_or($params['params'], array());
     if (!$streamerId) {
         $thread->log("Sorry dude, no streamerId submitted. Can't do anything");
         return X_Threads_Thread::RETURN_INVALID_PARAMS;
     }
     /* @var $streamer X_Streamer_Engine_Vlc */
     $streamer = X_VlcShares_Plugins::helpers()->streamer()->get($streamerId);
     $streamer->setParams($params);
     $streamer->startEngine($thread);
     return self::RETURN_NORMAL;
 }
 public function init()
 {
     $this->setName('profiles');
     // Set the method for the display form to POST
     $this->setMethod('post');
     $this->addElement('text', 'label', array('label' => X_Env::_('p_profiles_form_label_label'), 'description' => X_Env::_('p_profiles_form_label_desc'), 'required' => true, 'filters' => array('StringTrim')));
     $this->addElement('textarea', 'arg', array('label' => X_Env::_('p_profiles_form_arg_label'), 'description' => X_Env::_('p_profiles_form_arg_desc'), 'required' => true, 'filters' => array('StringTrim'), 'validators' => array(array('validator' => 'StringLength', 'options' => array(0, 1000)))));
     $this->addElement('text', 'link', array('label' => X_Env::_('p_profiles_form_link_label'), 'description' => X_Env::_('p_profiles_form_link_desc'), 'required' => true, 'filters' => array('StringTrim')));
     // Add the submit button
     $this->addElement('submit', 'submit', array('ignore' => true, 'label' => X_Env::_('submit'), 'decorators' => array('ViewHelper')));
     // Add the submit button
     $this->addElement('reset', 'abort', array('ignore' => true, 'label' => X_Env::_('abort')));
     // And finally add some CSRF protection
     $this->addElement('hash', 'csrf', array('ignore' => true, 'salt' => 'p_profiles_salt'));
     $this->addElement('hidden', 'id', array('ignore' => true, 'required' => false));
     $this->addDisplayGroup(array('submit', 'csrf', 'id', 'abort'), 'buttons', array('decorators' => $this->getDefaultButtonsDisplayGroupDecorators()));
 }
 public function init()
 {
     // Set the method for the display form to POST
     $this->setMethod('post');
     $this->setName('installer');
     $this->addElement('select', 'lang', array('required' => true, 'label' => X_Env::_('installer_selectlanguage'), 'multiOptions' => array()));
     $this->addElement('radio', 'auth', array('label' => X_Env::_('installer_authrequired_label'), 'description' => X_Env::_('installer_authrequired_desc'), 'required' => true, 'filters' => array('StringTrim'), 'multiOptions' => array(1 => X_Env::_('configs_options_yes'), 0 => X_Env::_('configs_options_no'))));
     $this->addElement('text', 'username', array('label' => X_Env::_('p_auth_form_account_username_label'), 'required' => true, 'filters' => array('StringTrim')));
     $this->addElement('password', 'password', array('label' => X_Env::_('p_auth_form_account_password_label'), 'description' => X_Env::_('p_auth_form_account_password_desc2'), 'required' => true, 'filters' => array('StringTrim'), 'validators' => array(array('validator' => 'StringLength', 'options' => array(5, 32)))));
     $this->addElement('text', 'threads', array('label' => X_Env::_('config_general_threads_forker_label'), 'description' => X_Env::_('config_general_threads_forker_desc'), 'required' => true, 'class' => 'hidden'));
     $this->addElement('multiCheckbox', 'plugins', array('required' => false, 'label' => X_Env::_('installer_optionalplugins'), 'description' => X_Env::_('installer_optionalplugins_desc'), 'escape' => false, 'decorators' => array('PluginsMultiCheckBox')));
     // Add the submit button
     $this->addElement('submit', 'submit', array('ignore' => true, 'label' => X_Env::_('installer_startbutton')));
     // And finally add some CSRF protection
     $this->addElement('hash', 'csrf', array('salt' => __CLASS__, 'ignore' => true));
     $this->addDisplayGroup(array('submit', 'csrf'), 'buttons', array('decorators' => $this->getDefaultButtonsDisplayGroupDecorators()));
 }
 public function init()
 {
     $this->setName('auth_account');
     // Set the method for the display form to POST
     $this->setMethod('post');
     $this->addElement('text', 'username', array('label' => X_Env::_('p_auth_form_account_username_label'), 'required' => true, 'filters' => array('StringTrim')));
     $this->addElement('password', 'password', array('label' => X_Env::_('p_auth_form_account_password_label'), 'description' => X_Env::_('p_auth_form_account_password_desc'), 'required' => true, 'filters' => array('StringTrim'), 'validators' => array(array('validator' => 'StringLength', 'options' => array(5, 32)))));
     $this->addElement('radio', 'enabled', array('label' => X_Env::_('p_auth_form_account_enabled_label'), 'required' => true, 'multiOptions' => array(1 => X_Env::_('enabled'), 0 => X_Env::_('disabled'))));
     $this->addElement('radio', 'altallowed', array('label' => X_Env::_('p_auth_form_account_altallowed_label'), 'description' => X_Env::_('p_auth_form_account_altallowed_desc'), 'required' => true, 'multiOptions' => array(1 => X_Env::_('enabled'), 0 => X_Env::_('disabled'))));
     $this->addElement('multiCheckbox', 'permissions', array('label' => X_Env::_('p_auth_form_account_permissions_label'), 'description' => X_Env::_('p_auth_form_account_permissions_desc'), 'required' => true, 'escape' => false));
     // Add the submit button
     $this->addElement('submit', 'submit', array('ignore' => true, 'label' => X_Env::_('p_auth_form_account_save'), 'decorators' => array('ViewHelper')));
     // And finally add some CSRF protection
     $this->addElement('hash', 'csrf', array('ignore' => true, 'salt' => __CLASS__));
     $this->addElement('hidden', 'id', array('ignore' => true, 'required' => false));
     $this->addDisplayGroup(array('submit', 'csrf', 'id'), 'buttons', array('decorators' => $this->getDefaultButtonsDisplayGroupDecorators()));
 }
 /**
  * Retrieve statistic from plugins
  * @param Zend_Controller_Action $this
  * @return X_Page_ItemList_Message
  */
 public function getIndexMessages(Zend_Controller_Action $controller)
 {
     $version = X_VlcShares::VERSION;
     X_Debug::i('Plugin triggered');
     $showError = false;
     $type = 'warning';
     if (strpos($version, 'alpha') !== false || strpos($version, 'beta') !== false || strpos($version, 'dev') !== false || strpos($version, 'unstable') !== false) {
         $showError = true;
     } elseif (strpos($version, 'rc') !== false || strpos($version, 'release_candidate') !== false) {
         $showError = true;
         $type = 'info';
     }
     if ($showError) {
         $m = new X_Page_Item_Message($this->getId(), X_Env::_('p_widgetdevalert_warningmessage'));
         $m->setType($type);
         return new X_Page_ItemList_Message(array($m));
     }
 }
 /**
  * Retrieve statistic from plugins
  * @param Zend_Controller_Action $this
  * @return X_Page_ItemList_Message
  */
 public function getIndexMessages(Zend_Controller_Action $controller)
 {
     $updates = $this->checkUpdates();
     $list = new X_Page_ItemList_Message();
     if ($updates['core'] !== false) {
         $m = new X_Page_Item_Message("{$this->getId()}-core", X_Env::_('p_updatenotifier_coreupdate', $updates['core']['version'], $updates['core']['type'], trim($updates['core']['changelog']), $updates['core']['download'], $updates['core']['update']));
         $m->setType(X_Page_Item_Message::TYPE_INFO);
         $list->append($m);
     }
     if (count($updates['plugins'])) {
         foreach ($updates['plugins'] as $key => $infos) {
             $m = new X_Page_Item_Message("{$this->getId()}-plugin", X_Env::_('p_updatenotifier_pluginupdate', $key, $infos['version'], $infos['type'], trim($infos['changelog']), $infos['download'], $infos['update']));
             $m->setType(X_Page_Item_Message::TYPE_INFO);
             $list->append($m);
         }
     }
     return count($list->getItems()) ? $list : null;
 }
 public function addTranslation($key)
 {
     $moduleName = $key . '.' . $this->lang;
     // i have to check $moduleName to be sure that the file is inside the languages/ directory
     if (file_exists(realpath(APPLICATION_PATH . "/../languages/{$moduleName}"))) {
         $translate = new Zend_Translate('ini', realpath(APPLICATION_PATH . "/../languages/{$moduleName}"));
     } elseif ($this->lang != 'en_GB.ini' && file_exists(realpath(APPLICATION_PATH . "/../languages/{$key}.en_GB.ini"))) {
         // fallback to english translation
         X_Debug::w("Language file not found: {$moduleName}. Falling back to english translation");
         $translate = new Zend_Translate('ini', realpath(APPLICATION_PATH . "/../languages/{$key}.en_GB.ini"));
     } else {
         X_Debug::w("Language file not found: {$moduleName}");
         return false;
     }
     // time to append translator to the global instance
     X_Env::initTranslator($translate);
     return true;
 }