public function install($response) { $Request = new \Core\Request(); $Url = new \Core\Url(); $zip = PHPFOX_DIR_FILE . 'static/' . uniqid() . '.zip'; file_put_contents($zip, file_get_contents($response->download)); switch ($Request->get('type')) { case 'isAppInstalled': echo "OK"; break; case 'language': $file = PHPFOX_DIR_FILE . 'static/' . uniqid() . '/'; mkdir($file); $Zip = new \ZipArchive(); $Zip->open($zip); $Zip->extractTo($file); $Zip->close(); // $xml = \Phpfox::getLib('xml.parser')->parse($file . 'phpfox-language-import.xml'); $name = false; $fullPath = $file . 'upload/include/'; foreach (scandir($fullPath . 'xml/language/') as $dir) { if (file_exists($fullPath . 'xml/language/' . $dir . '/phpfox-language-import.xml')) { $name = $dir; } } if (!$name) { throw new \Exception('Not a valid language package to install.'); } \Language_Service_Process::instance()->installPackFromFolder($name, $fullPath . 'xml/language/' . $name . '/'); $Url->send('admincp/language/import', ['dir' => base64_encode($fullPath . 'xml/language/' . $name . '/')]); break; default: $Theme = new \Core\Theme(); $Theme->import($zip, ['image' => $response->image, 'id' => $response->internal_id, 'version' => $response->internal_version]); $Url->send('admincp/theme', null, 'Theme successfully installed!'); break; } exit; }
* Using the Event handler we add JS & CSS to the <head></head> */ new Core\Event(['lib_phpfox_template_getheader' => function (Phpfox_Template $Template) { if (!setting('m9_facebook_enabled')) { $Template->setHeader('<script>var Fb_Login_Disabled = true;</script>'); $Template->setHeader('<style>.fb_login_go, #header_menu #js_block_border_user_login-block form > .table:first-of-type:before {display:none !important;} #header_menu #js_block_border_user_login-block .title { margin-bottom: 0px; }</style>'); } }]); // Make sure the app is enabled if (!setting('m9_facebook_enabled')) { return; } // Use the FB SDK to set the apps ID & Secret Facebook\FacebookSession::setDefaultApplication(setting('m9_facebook_app_id'), setting('m9_facebook_app_secret')); // We override the main settings page since their account is connected to FB $Url = new Core\Url(); if (Phpfox::isUser() && $Url->uri() == '/user/setting/' && substr(Phpfox::getUserBy('email'), -3) == '@fb') { (new Core\Route('/user/setting'))->run(function (\Core\Controller $Controller) { return $Controller->render('setting.html'); }); } /** * Controller for the FB login routine */ (new Core\Route('/fb/login'))->run(function (\Core\Controller $Controller) { $helper = new Facebook\FacebookRedirectLoginHelper($Controller->url->make('/fb/auth')); $loginUrl = $helper->getLoginUrl(); header('Location: ' . $loginUrl); exit; }); /**