PageRenderTime 48ms CodeModel.GetById 23ms RepoModel.GetById 1ms app.codeStats 0ms

/application/controllers/class.settings.php

http://github.com/sixones/nzbvr
PHP | 60 lines | 42 code | 16 blank | 2 comment | 11 complexity | 8e2df315d98dbb7adc6d20dc1cd2dafb MD5 | raw file
  1. <?php if (!defined("PICNIC")) { header("Location: /"); exit(1); }
  2. class SettingsController extends ApplicationController {
  3. public function index() {
  4. $this->settings = nzbVR::instance()->settings;
  5. // find all the skins
  6. $skinDirs = scandir(ROOT_PATH."skins/");
  7. $this->skins = array();
  8. foreach ($skinDirs as $skinDir) {
  9. if ($skinDir != "." && $skinDir != "..") {
  10. if (is_dir(ROOT_PATH."skins/{$skinDir}")) {
  11. $this->skins[] = (string)$skinDir;
  12. }
  13. }
  14. }
  15. }
  16. public function save() {
  17. nzbVR::instance()->settings->set("base_url", $this->params()->get("base_url"));
  18. nzbVR::instance()->settings->set("main_skin", $this->params()->get("main_skin"));
  19. nzbVR::instance()->settings->set("mobile_skin", $this->params()->get("mobile_skin"));
  20. nzbVR::instance()->settings->set("newzbin_username", base64_encode($this->params()->get("newzbin_username")));
  21. nzbVR::instance()->settings->set("newzbin_password", base64_encode($this->params()->get("newzbin_password")));
  22. nzbVR::instance()->settings->set("sabnzbd_address", $this->params()->get("sabnzbd_address"));
  23. nzbVR::instance()->settings->set("sabnzbd_apikey", base64_encode($this->params()->get("sabnzbd_apikey")));
  24. nzbVR::instance()->settings->set("sabnzbd_username", base64_encode($this->params()->get("sabnzbd_username")));
  25. nzbVR::instance()->settings->set("sabnzbd_password", base64_encode($this->params()->get("sabnzbd_password")));
  26. nzbVR::instance()->settings->set("xbmc_address", $this->params()->get("xbmc_address"));
  27. nzbVR::instance()->settings->set("xbmc_username", base64_encode($this->params()->get("xbmc_username")));
  28. nzbVR::instance()->settings->set("xbmc_password", base64_encode($this->params()->get("xbmc_password")));
  29. nzbVR::instance()->settings->set("prowl_apikey", base64_encode($this->params()->get("prowl_apikey")));
  30. nzbVR::instance()->settings->set("growl_password", base64_encode($this->params()->get("growl_password")));
  31. if ($this->params()->get("growl_address") != nzbVR::instance()->settings->growl_address) {
  32. nzbVR::instance()->settings->set("growl_address", $this->params()->get("growl_address"));
  33. if (nzbVR::instance()->settings->growl_address != "") {
  34. $growl = new Growl();
  35. $growl->addNotification("Report found for watcher", true);
  36. $growl->register();
  37. }
  38. }
  39. nzbVR::instance()->settings->save();
  40. //$this->notification("Settings saved successfully", "success");
  41. $this->redirect("index");
  42. }
  43. }
  44. ?>