organizr-functions.php 21 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694
  1. <?php
  2. function wizardConfig($array){
  3. foreach ($array['data'] as $items) {
  4. foreach ($items as $key => $value) {
  5. if($key == 'name'){
  6. $newKey = $value;
  7. }
  8. if($key == 'value'){
  9. $newValue = $value;
  10. }
  11. if(isset($newKey) && isset($newValue)){
  12. $$newKey = $newValue;
  13. }
  14. }
  15. }
  16. $location = cleanDirectory($location);
  17. $dbName = $dbName.'.db';
  18. $configVersion = $GLOBALS['installedVersion'];
  19. $configArray = array(
  20. 'dbName' => $dbName,
  21. 'dbLocation' => $location,
  22. 'license' => $license,
  23. 'organizrHash' => $hashKey,
  24. 'organizrAPI' => $api,
  25. 'registrationPassword' => $registrationPassword,
  26. );
  27. // Create Config
  28. if(createConfig($configArray)){
  29. // Call DB Create
  30. if(createDB($location,$dbName)){
  31. // Add in first user
  32. if(createFirstAdmin($location,$dbName,$username,$password,$email)){
  33. if(createToken($username,$email,gravatar($email),'Admin',0,$hashKey,1)){
  34. return true;
  35. }
  36. }
  37. }
  38. }
  39. return false;
  40. }
  41. function register($array){
  42. // Grab username and password from login form
  43. foreach ($array['data'] as $items) {
  44. foreach ($items as $key => $value) {
  45. if($key == 'name'){
  46. $newKey = $value;
  47. }
  48. if($key == 'value'){
  49. $newValue = $value;
  50. }
  51. if(isset($newKey) && isset($newValue)){
  52. $$newKey = $newValue;
  53. }
  54. }
  55. }
  56. if($registrationPassword == $GLOBALS['registrationPassword']){
  57. $defaults = defaultUserGroup();
  58. writeLog('success', 'Registration Function - Registration Password Verified', $username);
  59. if(createUser($username,$password,$defaults,$email)){
  60. writeLog('success', 'Registration Function - A User has registered', $username);
  61. if(createToken($username,$email,gravatar($email),$defaults['group'],$defaults['group_id'],$GLOBALS['organizrHash'],1)){
  62. writeLoginLog($username, 'success');
  63. writeLog('success', 'Login Function - A User has logged in', $username);
  64. return true;
  65. }
  66. }else{
  67. writeLog('error', 'Registration Function - An error occured', $username);
  68. return 'username taken';
  69. }
  70. }else{
  71. writeLog('warning', 'Registration Function - Wrong Password', $username);
  72. return 'mismatch';
  73. }
  74. }
  75. function editUser($array){
  76. return $array;
  77. }
  78. function logout(){
  79. coookie('delete','organizrToken');
  80. $GLOBALS['organizrUser'] = false;
  81. return true;
  82. }
  83. function qualifyRequest($accessLevelNeeded){
  84. if(getUserLevel() <= $accessLevelNeeded){
  85. return true;
  86. }else{
  87. return false;
  88. }
  89. }
  90. function getUserLevel(){
  91. $requesterToken = isset(getallheaders()['Token']) ? getallheaders()['Token'] : false;
  92. // Check token or API key
  93. // If API key, return 0 for admin
  94. if(strlen($requesterToken) == 20 && $requesterToken == $GLOBALS['organizrAPI']){
  95. //DO API CHECK
  96. return 0;
  97. }elseif(isset($GLOBALS['organizrUser'])){
  98. return $GLOBALS['organizrUser']['groupID'];
  99. }
  100. // All else fails? return guest id
  101. return 999;
  102. }
  103. function organizrStatus(){
  104. $status = array();
  105. $dependenciesActive = array();
  106. $dependenciesInactive = array();
  107. $extensions = array("PDO_SQLITE", "PDO", "SQLITE3", "zip", "cURL", "openssl", "simplexml", "json", "session");
  108. $functions = array("hash", "fopen", "fsockopen", "fwrite", "fclose", "readfile");
  109. foreach($extensions as $check){
  110. if(extension_loaded($check)){
  111. array_push($dependenciesActive,$check);
  112. }else{
  113. array_push($dependenciesInactive,$check);
  114. }
  115. }
  116. foreach($functions as $check){
  117. if(function_exists($check)){
  118. array_push($dependenciesActive,$check);
  119. }else{
  120. array_push($dependenciesInactive,$check);
  121. }
  122. }
  123. if(!file_exists('config'.DIRECTORY_SEPARATOR.'config.php')){
  124. $status['status'] = "wizard";//wizard - ok for test
  125. }
  126. if(count($dependenciesInactive)>0 || !is_writable(dirname(__DIR__,2))){
  127. $status['status'] = "dependencies";
  128. }
  129. $status['status'] = (!empty($status['status'])) ? $status['status'] : $status['status'] = "ok";
  130. $status['writable'] = is_writable(dirname(__DIR__,2)) ? 'yes' : 'no';
  131. $status['dependenciesActive'] = $dependenciesActive;
  132. $status['dependenciesInactive'] = $dependenciesInactive;
  133. $status['version'] = $GLOBALS['installedVersion'];
  134. $status['os'] = getOS();
  135. $status['php'] = phpversion();
  136. return $status;
  137. }
  138. function getSettingsMain(){
  139. return array(
  140. array(
  141. 'type' => 'select',
  142. 'name' => 'branch',
  143. 'label' => 'Branch',
  144. 'value' => $GLOBALS['branch'],
  145. 'options' => getBranches()
  146. ),
  147. array(
  148. 'type' => 'button',
  149. 'label' => 'Force Install Branch',
  150. 'class' => 'updateNow',
  151. 'icon' => 'fa fa-paper-plane',
  152. 'text' => 'Retrieve'
  153. ),
  154. array(
  155. 'type' => 'select',
  156. 'name' => 'authType',
  157. 'id' => 'authSelect',
  158. 'label' => 'Authentication Type',
  159. 'value' => $GLOBALS['authType'],
  160. 'options' => getAuthTypes()
  161. ),
  162. array(
  163. 'type' => 'select',
  164. 'name' => 'authBackend',
  165. 'id' => 'authBackendSelect',
  166. 'label' => 'Authentication Backend',
  167. 'class' => 'backendAuth switchAuth',
  168. 'value' => $GLOBALS['authBackend'],
  169. 'options' => getAuthBackends()
  170. ),
  171. array(
  172. 'type' => 'input',
  173. 'name' => 'plexToken',
  174. 'class' => 'plexAuth switchAuth',
  175. 'label' => 'Plex Token',
  176. 'value' => $GLOBALS['plexToken'],
  177. 'placeholder' => 'Use Get Token Button'
  178. ),
  179. array(
  180. 'type' => 'button',
  181. 'label' => 'Get Plex Token',
  182. 'class' => 'popup-with-form getPlexTokenAuth plexAuth switchAuth',
  183. 'icon' => 'fa fa-paper-plane',
  184. 'text' => 'Retrieve',
  185. 'href' => '#auth-plex-token-form',
  186. 'attr' => 'data-effect="mfp-3d-unfold"'
  187. ),
  188. array(
  189. 'type' => 'input',
  190. 'name' => 'plexID',
  191. 'class' => 'plexAuth switchAuth',
  192. 'label' => 'Plex Machine',
  193. 'value' => $GLOBALS['plexID'],
  194. 'placeholder' => 'Use Get Plex Machine Button'
  195. ),
  196. array(
  197. 'type' => 'button',
  198. 'label' => 'Get Plex Machine',
  199. 'class' => 'popup-with-form getPlexMachineAuth plexAuth switchAuth',
  200. 'icon' => 'fa fa-paper-plane',
  201. 'text' => 'Retrieve',
  202. 'href' => '#auth-plex-machine-form',
  203. 'attr' => 'data-effect="mfp-3d-unfold"'
  204. ),
  205. array(
  206. 'type' => 'input',
  207. 'name' => 'authBackendHost',
  208. 'class' => 'ldapAuth ftpAuth switchAuth',
  209. 'label' => 'Host Address',
  210. 'value' => $GLOBALS['authBackendHost'],
  211. 'placeholder' => 'http{s) | ftp(s) | ldap(s)://hostname:port'
  212. ),
  213. array(
  214. 'type' => 'input',
  215. 'name' => 'authBaseDN',
  216. 'class' => 'ldapAuth switchAuth',
  217. 'label' => 'Host Base DN',
  218. 'value' => $GLOBALS['authBaseDN'],
  219. 'placeholder' => 'cn=%s,dc=sub,dc=domain,dc=com'
  220. ),
  221. array(
  222. 'type' => 'input',
  223. 'name' => 'embyURL',
  224. 'class' => 'embyAuth switchAuth',
  225. 'label' => 'Emby URL',
  226. 'value' => $GLOBALS['embyURL'],
  227. 'placeholder' => ''
  228. ),
  229. array(
  230. 'type' => 'input',
  231. 'name' => 'embyToken',
  232. 'class' => 'embyAuth switchAuth',
  233. 'label' => 'Emby Token',
  234. 'value' => $GLOBALS['embyToken'],
  235. 'placeholder' => ''
  236. )
  237. /*array(
  238. 'type' => 'button',
  239. 'label' => 'Send Test',
  240. 'class' => 'phpmSendTestEmail',
  241. 'icon' => 'fa fa-paper-plane',
  242. 'text' => 'Send'
  243. )*/
  244. );
  245. }
  246. function getSSO(){
  247. return array(
  248. array(
  249. 'type' => 'input',
  250. 'name' => 'plexToken',
  251. 'label' => 'Plex Token',
  252. 'value' => $GLOBALS['plexToken'],
  253. 'placeholder' => 'Use Get Token Button'
  254. ),
  255. array(
  256. 'type' => 'button',
  257. 'label' => 'Get Plex Token',
  258. 'class' => 'popup-with-form getPlexTokenSSO',
  259. 'icon' => 'fa fa-paper-plane',
  260. 'text' => 'Retrieve',
  261. 'href' => '#sso-plex-token-form',
  262. 'attr' => 'data-effect="mfp-3d-unfold"'
  263. ),
  264. array(
  265. 'type' => 'input',
  266. 'name' => 'plexID',
  267. 'label' => 'Plex Machine',
  268. 'value' => $GLOBALS['plexID'],
  269. 'placeholder' => 'Use Get Plex Machine Button'
  270. ),
  271. array(
  272. 'type' => 'button',
  273. 'label' => 'Get Plex Machine',
  274. 'class' => 'popup-with-form getPlexMachineSSO',
  275. 'icon' => 'fa fa-paper-plane',
  276. 'text' => 'Retrieve',
  277. 'href' => '#sso-plex-machine-form',
  278. 'attr' => 'data-effect="mfp-3d-unfold"'
  279. ),
  280. array(
  281. 'type' => 'html',
  282. 'label' => 'Plex Note',
  283. 'html' => '<span lang="en">Please make sure both Token and Machine are filled in</span>'
  284. ),
  285. array(
  286. 'type' => 'switch',
  287. 'name' => 'ssoPlex',
  288. 'label' => 'Enable',
  289. 'value' => $GLOBALS['ssoPlex']
  290. ),
  291. array(
  292. 'type' => 'input',
  293. 'name' => 'ombiURL',
  294. 'label' => 'Ombi URL',
  295. 'value' => $GLOBALS['ombiURL'],
  296. 'placeholder' => 'http(s)://hostname'
  297. ),
  298. array(
  299. 'type' => 'switch',
  300. 'name' => 'ssoOmbi',
  301. 'label' => 'Enable',
  302. 'value' => $GLOBALS['ssoOmbi']
  303. ),
  304. array(
  305. 'type' => 'input',
  306. 'name' => 'tautulliURL',
  307. 'label' => 'Tautulli URL',
  308. 'value' => $GLOBALS['tautulliURL'],
  309. 'placeholder' => 'http(s)://hostname'
  310. ),
  311. array(
  312. 'type' => 'switch',
  313. 'name' => 'ssoTautulli',
  314. 'label' => 'Enable',
  315. 'value' => $GLOBALS['ssoTautulli']
  316. )
  317. /*array(
  318. 'type' => 'button',
  319. 'label' => 'Send Test',
  320. 'class' => 'phpmSendTestEmail',
  321. 'icon' => 'fa fa-paper-plane',
  322. 'text' => 'Send'
  323. )*/
  324. );
  325. }
  326. function loadAppearance(){
  327. $appearance = array();
  328. $appearance['logo'] = $GLOBALS['logo'];
  329. $appearance['title'] = $GLOBALS['title'];
  330. $appearance['useLogo'] = $GLOBALS['useLogo'];
  331. $appearance['headerColor'] = $GLOBALS['headerColor'];
  332. $appearance['loginWallpaper'] = $GLOBALS['loginWallpaper'];
  333. return $appearance;
  334. }
  335. function getCustomizeAppearance(){
  336. if(file_exists(dirname(__DIR__,1).DIRECTORY_SEPARATOR.'config'.DIRECTORY_SEPARATOR.'config.php')){
  337. return array(
  338. 'config' => array(/*
  339. array(
  340. 'type' => 'select',
  341. 'name' => 'branch',
  342. 'label' => 'Organizr Branch',
  343. 'value' => $GLOBALS['branch'],
  344. 'options' => array(
  345. 'Master' => 'v2-master',
  346. 'Develop' => 'v2-develop'
  347. )
  348. ),*/
  349. array(
  350. 'type' => 'input',
  351. 'name' => 'logo',
  352. 'label' => 'Logo',
  353. 'value' => $GLOBALS['logo']
  354. ),
  355. array(
  356. 'type' => 'input',
  357. 'name' => 'loginWallpaper',
  358. 'label' => 'Login Wallpaper',
  359. 'value' => $GLOBALS['loginWallpaper']
  360. ),
  361. array(
  362. 'type' => 'input',
  363. 'name' => 'title',
  364. 'label' => 'Title',
  365. 'value' => $GLOBALS['title']
  366. ),
  367. array(
  368. 'type' => 'switch',
  369. 'name' => 'useLogo',
  370. 'label' => 'Use Logo instead of Title',
  371. 'value' => $GLOBALS['useLogo']
  372. ),
  373. array(
  374. 'type' => 'input',
  375. 'name' => 'headerColor',
  376. 'label' => 'Nav Bar Color',
  377. 'value' => $GLOBALS['headerColor'],
  378. 'class' => 'colorpicker',
  379. 'disabled' => true
  380. ),
  381. array(
  382. 'type' => 'select',
  383. 'name' => 'theme',
  384. 'label' => 'Theme',
  385. 'class' => 'themeChanger',
  386. 'value' => $GLOBALS['theme'],
  387. 'options' => getThemes()
  388. ),
  389. array(
  390. 'type' => 'select',
  391. 'name' => 'style',
  392. 'label' => 'Style',
  393. 'class' => 'styleChanger',
  394. 'value' => $GLOBALS['style'],
  395. 'options' => array(
  396. array(
  397. 'name' => 'Light',
  398. 'value' => 'light'
  399. ),
  400. array(
  401. 'name' => 'Dark',
  402. 'value' => 'dark'
  403. )
  404. )
  405. )
  406. ),
  407. 'database' => array(
  408. )
  409. );
  410. }
  411. }
  412. function editAppearance($array){
  413. switch ($array['data']['value']) {
  414. case 'true':
  415. $array['data']['value'] = (bool) true;
  416. break;
  417. case 'false':
  418. $array['data']['value'] = (bool) false;
  419. break;
  420. default:
  421. $array['data']['value'] = $array['data']['value'];
  422. }
  423. //return gettype($array['data']['value']).' - '.$array['data']['value'];
  424. switch ($array['data']['action']) {
  425. case 'editCustomizeAppearance':
  426. $newItem = array(
  427. $array['data']['name'] => $array['data']['value']
  428. );
  429. return (updateConfig($newItem)) ? true : false;
  430. break;
  431. default:
  432. # code...
  433. break;
  434. }
  435. }
  436. function updateConfigItem($array){
  437. switch ($array['data']['value']) {
  438. case 'true':
  439. $array['data']['value'] = (bool) true;
  440. break;
  441. case 'false':
  442. $array['data']['value'] = (bool) false;
  443. break;
  444. default:
  445. $array['data']['value'] = $array['data']['value'];
  446. }
  447. // Hash
  448. if($array['data']['type'] == 'password'){
  449. $array['data']['value'] = encrypt($array['data']['value']);
  450. }
  451. //return gettype($array['data']['value']).' - '.$array['data']['value'];
  452. $newItem = array(
  453. $array['data']['name'] => $array['data']['value']
  454. );
  455. return (updateConfig($newItem)) ? true : false;
  456. }
  457. function getPlugins(){
  458. if(file_exists(dirname(__DIR__,1).DIRECTORY_SEPARATOR.'config'.DIRECTORY_SEPARATOR.'config.php')){
  459. $pluginList = array();
  460. foreach($GLOBALS['plugins'] as $plugin){
  461. foreach ($plugin as $key => $value) {
  462. $plugin[$key]['enabled'] = $GLOBALS[$value['configPrefix'].'-enabled'];
  463. }
  464. $pluginList = array_merge($pluginList, $plugin);
  465. }
  466. return $pluginList;
  467. }
  468. return false;
  469. }
  470. function editPlugins($array){
  471. switch ($array['data']['action']) {
  472. case 'enable':
  473. $newItem = array(
  474. $array['data']['configName'] => true
  475. );
  476. writeLog('success', 'Plugin Function - Enabled Plugin ['.$_POST['data']['name'].']', $GLOBALS['organizrUser']['username']);
  477. return (updateConfig($newItem)) ? true : false;
  478. break;
  479. case 'disable':
  480. $newItem = array(
  481. $array['data']['configName'] => false
  482. );
  483. writeLog('success', 'Plugin Function - Disabled Plugin ['.$_POST['data']['name'].']', $GLOBALS['organizrUser']['username']);
  484. return (updateConfig($newItem)) ? true : false;
  485. break;
  486. default:
  487. # code...
  488. break;
  489. }
  490. }
  491. function auth(){
  492. $debug = false; // CAREFUL WHEN SETTING TO TRUE AS THIS OPENS AUTH UP
  493. $ban = isset($_GET['ban']) ? strtoupper($_GET['ban']) : "";
  494. $whitelist = isset($_GET['whitelist']) ? $_GET['whitelist'] : false;
  495. $blacklist = isset($_GET['blacklist']) ? $_GET['blacklist'] : false;
  496. $group = isset($_GET['group']) ? $_GET['group'] : 0;
  497. $currentIP = userIP();
  498. $currentUser = $GLOBALS['organizrUser']['username'];
  499. if ($whitelist) {
  500. if(in_array($currentIP, arrayIP($whitelist))) {
  501. !$debug ? exit(http_response_code(200)) : die("$currentIP Whitelist Authorized");
  502. }
  503. }
  504. if ($blacklist) {
  505. if(in_array($currentIP, arrayIP($blacklist))) {
  506. !$debug ? exit(http_response_code(401)) : die("$currentIP Blacklisted");
  507. }
  508. }
  509. if($group !== null){
  510. if(qualifyRequest($group)){
  511. !$debug ? exit(http_response_code(200)) : die("$currentUser on $currentIP Authorized");
  512. }else{
  513. !$debug ? exit(http_response_code(401)) : die("$currentUser on $currentIP Not Authorized");
  514. }
  515. }else{
  516. !$debug ? exit(http_response_code(401)) : die("Not Authorized Due To No Parameters Set");
  517. }
  518. }
  519. function logoOrText(){
  520. if($GLOBALS['useLogo'] == false){
  521. return '<h1>'.$GLOBALS['title'].'</h1>';
  522. }else{
  523. return '<img style="max-width: 350px;" src="'.$GLOBALS['logo'].'" alt="Home" />';
  524. }
  525. }
  526. function getImages(){
  527. $dirname = dirname(__DIR__,2).DIRECTORY_SEPARATOR.'plugins'.DIRECTORY_SEPARATOR.'images'.DIRECTORY_SEPARATOR.'tabs'.DIRECTORY_SEPARATOR;
  528. $path = 'plugins/images/tabs/';
  529. $images = scandir($dirname);
  530. $ignore = Array(".", "..", "._.DS_Store", ".DS_Store");
  531. $allIcons = array();
  532. foreach($images as $image){
  533. if(!in_array($image, $ignore)) {
  534. $allIcons[] = $path.$image;
  535. }
  536. }
  537. return $allIcons;
  538. }
  539. function editImages(){
  540. $array = array();
  541. $postCheck = array_filter($_POST);
  542. $filesCheck = array_filter($_FILES);
  543. if(!empty($postCheck)){
  544. if($_POST['data']['action'] == 'deleteImage'){
  545. if(file_exists(dirname(__DIR__,2).DIRECTORY_SEPARATOR.$_POST['data']['imagePath'])){
  546. writeLog('success', 'Image Manager Function - Deleted Image ['.$_POST['data']['imageName'].']', $GLOBALS['organizrUser']['username']);
  547. return (unlink(dirname(__DIR__,2).DIRECTORY_SEPARATOR.$_POST['data']['imagePath'])) ? true : false;
  548. }
  549. }
  550. }
  551. if(!empty($filesCheck)){
  552. ini_set('upload_max_filesize', '10M');
  553. ini_set('post_max_size', '10M');
  554. $tempFile = $_FILES['file']['tmp_name'];
  555. $targetPath = dirname(__DIR__,2).DIRECTORY_SEPARATOR.'plugins'.DIRECTORY_SEPARATOR.'images'.DIRECTORY_SEPARATOR.'tabs'.DIRECTORY_SEPARATOR;
  556. $targetFile = $targetPath. $_FILES['file']['name'];
  557. return (move_uploaded_file($tempFile,$targetFile)) ? true : false;
  558. }
  559. return false;
  560. }
  561. function getThemes(){
  562. $themes = array();
  563. foreach (glob(dirname(__DIR__,2).DIRECTORY_SEPARATOR.'css' . DIRECTORY_SEPARATOR . 'themes' . DIRECTORY_SEPARATOR . "*.css") as $filename){
  564. $themes[] = array(
  565. 'name' => preg_replace('/\\.[^.\\s]{3,4}$/', '', basename($filename)),
  566. 'value' => preg_replace('/\\.[^.\\s]{3,4}$/', '', basename($filename))
  567. );
  568. }
  569. return $themes;
  570. }
  571. function getBranches(){
  572. return array(
  573. array(
  574. 'name' => 'Develop',
  575. 'value' => 'v2-develop'
  576. ),
  577. array(
  578. 'name' => 'Master',
  579. 'value' => 'v2-master'
  580. )
  581. );
  582. }
  583. function getAuthTypes(){
  584. return array(
  585. array(
  586. 'name' => 'Organizr DB',
  587. 'value' => 'internal'
  588. ),
  589. array(
  590. 'name' => 'Organizr DB + Backend',
  591. 'value' => 'both'
  592. ),
  593. array(
  594. 'name' => 'Backend Only',
  595. 'value' => 'external'
  596. )
  597. );
  598. }
  599. function getAuthBackends(){
  600. $backendOptions = array();
  601. $backendOptions[] = array(
  602. 'name' => 'Choose Backend',
  603. 'value' => false,
  604. 'disabled' => true
  605. );
  606. foreach (array_filter(get_defined_functions()['user'],function($v) { return strpos($v, 'plugin_auth_') === 0; }) as $value) {
  607. $name = str_replace('plugin_auth_','',$value);
  608. if (strpos($name, 'disabled') === false) {
  609. $backendOptions[] = array(
  610. 'name' => ucwords(str_replace('_',' ',$name)),
  611. 'value' => $name
  612. );
  613. } else {
  614. $backendOptions[] = array(
  615. 'name' => $value(),
  616. 'value' => 'none',
  617. 'disabled' => true,
  618. );
  619. }
  620. }
  621. ksort($backendOptions);
  622. return $backendOptions;
  623. }
  624. /*
  625. function sendEmail($email = null, $username = "Organizr User", $subject, $body, $cc = null, $bcc = null){
  626. try {
  627. $mail = new PHPMailer(true);
  628. $mail->isSMTP();
  629. $mail->Host = $GLOBALS['smtpHost'];
  630. $mail->SMTPAuth = $GLOBALS['smtpHostAuth'];
  631. $mail->Username = $GLOBALS['smtpHostUsername'];
  632. $mail->Password = $GLOBALS['smtpHostPassword'];
  633. $mail->SMTPSecure = $GLOBALS['smtpHostType'];
  634. $mail->Port = $GLOBALS['smtpHostPort'];
  635. $mail->setFrom($GLOBALS['smtpHostSenderEmail'], $GLOBALS['smtpHostSenderName']);
  636. $mail->addReplyTo($GLOBALS['smtpHostSenderEmail'], $GLOBALS['smtpHostSenderName']);
  637. $mail->isHTML(true);
  638. if($email){
  639. $mail->addAddress($email, $username);
  640. }
  641. if($cc){
  642. $mail->addCC($cc);
  643. }
  644. if($bcc){
  645. if(strpos($bcc , ',') === false){
  646. $mail->addBCC($bcc);
  647. }else{
  648. $allEmails = explode(",",$bcc);
  649. foreach($allEmails as $gotEmail){
  650. $mail->addBCC($gotEmail);
  651. }
  652. }
  653. }
  654. $mail->Subject = $subject;
  655. $mail->Body = $body;
  656. $mail->send();
  657. writeLog('success', 'Mail Function - E-Mail Sent', $GLOBALS['organizrUser']['username']);
  658. return true;
  659. } catch (Exception $e) {
  660. writeLog('error', 'Mail Function - E-Mail Failed['.$mail->ErrorInfo.']', $GLOBALS['organizrUser']['username']);
  661. return false;
  662. }
  663. return false;
  664. }
  665. //EMAIL SHIT
  666. function sendTestEmail($to, $from, $host, $auth, $username, $password, $type, $port, $sendername){
  667. try {
  668. $mail = new PHPMailer(true);
  669. $mail->isSMTP();
  670. $mail->Host = $host;
  671. $mail->SMTPAuth = $auth;
  672. $mail->Username = $username;
  673. $mail->Password = $password;
  674. $mail->SMTPSecure = $type;
  675. $mail->Port = $port;
  676. $mail->setFrom($from, $sendername);
  677. $mail->addReplyTo($from, $sendername);
  678. $mail->isHTML(true);
  679. $mail->addAddress($to, "Organizr Admin");
  680. $mail->Subject = "Organizr Test E-Mail";
  681. $mail->Body = "This was just a test!";
  682. $mail->send();
  683. writeLog('success', 'Mail Function - E-Mail Test Sent', $GLOBALS['organizrUser']['username']);
  684. return true;
  685. } catch (Exception $e) {
  686. writeLog('error', 'Mail Function - E-Mail Test Failed['.$mail->ErrorInfo.']', $GLOBALS['organizrUser']['username']);
  687. return false;
  688. }
  689. return false;
  690. }
  691. */