organizr-functions.php 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642
  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' => 'popup-with-form getPlexTokenSSO',
  151. 'icon' => 'fa fa-paper-plane',
  152. 'text' => 'Retrieve'
  153. ),
  154. array(
  155. 'type' => 'select',
  156. 'name' => 'authType',
  157. 'label' => 'Authentication Type',
  158. 'value' => $GLOBALS['authType'],
  159. 'options' => getAuthTypes()
  160. ),
  161. array(
  162. 'type' => 'select',
  163. 'name' => 'authBackend',
  164. 'label' => 'Authentication Backend',
  165. 'value' => $GLOBALS['authBackend'],
  166. 'options' => getAuthBackends()
  167. ),
  168. array(
  169. 'type' => 'input',
  170. 'name' => 'plexToken',
  171. 'class' => 'plexAuth',
  172. 'label' => 'Plex Token',
  173. 'value' => $GLOBALS['plexToken'],
  174. 'placeholder' => 'Use Get Token Button'
  175. ),
  176. array(
  177. 'type' => 'button',
  178. 'label' => 'Get Plex Token',
  179. 'class' => 'popup-with-form getPlexTokenAuth plexAuth',
  180. 'icon' => 'fa fa-paper-plane',
  181. 'text' => 'Retrieve',
  182. 'href' => '#auth-plex-token-form',
  183. 'attr' => 'data-effect="mfp-3d-unfold"'
  184. ),
  185. array(
  186. 'type' => 'input',
  187. 'name' => 'plexID',
  188. 'class' => 'plexAuth',
  189. 'label' => 'Plex Machine',
  190. 'value' => $GLOBALS['plexID'],
  191. 'placeholder' => 'Use Get Plex Machine Button'
  192. ),
  193. array(
  194. 'type' => 'button',
  195. 'label' => 'Get Plex Machine',
  196. 'class' => 'popup-with-form getPlexMachineAuth plexAuth',
  197. 'icon' => 'fa fa-paper-plane',
  198. 'text' => 'Retrieve',
  199. 'href' => '#auth-plex-machine-form',
  200. 'attr' => 'data-effect="mfp-3d-unfold"'
  201. ),
  202. /*array(
  203. 'type' => 'button',
  204. 'label' => 'Send Test',
  205. 'class' => 'phpmSendTestEmail',
  206. 'icon' => 'fa fa-paper-plane',
  207. 'text' => 'Send'
  208. )*/
  209. );
  210. }
  211. function getSSO(){
  212. return array(
  213. array(
  214. 'type' => 'input',
  215. 'name' => 'plexToken',
  216. 'label' => 'Plex Token',
  217. 'value' => $GLOBALS['plexToken'],
  218. 'placeholder' => 'Use Get Token Button'
  219. ),
  220. array(
  221. 'type' => 'button',
  222. 'label' => 'Get Plex Token',
  223. 'class' => 'popup-with-form getPlexTokenSSO',
  224. 'icon' => 'fa fa-paper-plane',
  225. 'text' => 'Retrieve',
  226. 'href' => '#sso-plex-token-form',
  227. 'attr' => 'data-effect="mfp-3d-unfold"'
  228. ),
  229. array(
  230. 'type' => 'input',
  231. 'name' => 'plexID',
  232. 'label' => 'Plex Machine',
  233. 'value' => $GLOBALS['plexID'],
  234. 'placeholder' => 'Use Get Plex Machine Button'
  235. ),
  236. array(
  237. 'type' => 'button',
  238. 'label' => 'Get Plex Machine',
  239. 'class' => 'popup-with-form getPlexMachineSSO',
  240. 'icon' => 'fa fa-paper-plane',
  241. 'text' => 'Retrieve',
  242. 'href' => '#sso-plex-machine-form',
  243. 'attr' => 'data-effect="mfp-3d-unfold"'
  244. ),
  245. array(
  246. 'type' => 'html',
  247. 'label' => 'Plex Note',
  248. 'html' => '<span lang="en">Please make sure both Token and Machine are filled in</span>'
  249. ),
  250. array(
  251. 'type' => 'switch',
  252. 'name' => 'ssoPlex',
  253. 'label' => 'Enable',
  254. 'value' => $GLOBALS['ssoPlex']
  255. ),
  256. array(
  257. 'type' => 'input',
  258. 'name' => 'ombiURL',
  259. 'label' => 'Ombi URL',
  260. 'value' => $GLOBALS['ombiURL'],
  261. 'placeholder' => 'http(s)://hostname'
  262. ),
  263. array(
  264. 'type' => 'switch',
  265. 'name' => 'ssoOmbi',
  266. 'label' => 'Enable',
  267. 'value' => $GLOBALS['ssoOmbi']
  268. ),
  269. array(
  270. 'type' => 'input',
  271. 'name' => 'tautulliURL',
  272. 'label' => 'Tautulli URL',
  273. 'value' => $GLOBALS['tautulliURL'],
  274. 'placeholder' => 'http(s)://hostname'
  275. ),
  276. array(
  277. 'type' => 'switch',
  278. 'name' => 'ssoTautulli',
  279. 'label' => 'Enable',
  280. 'value' => $GLOBALS['ssoTautulli']
  281. )
  282. /*array(
  283. 'type' => 'button',
  284. 'label' => 'Send Test',
  285. 'class' => 'phpmSendTestEmail',
  286. 'icon' => 'fa fa-paper-plane',
  287. 'text' => 'Send'
  288. )*/
  289. );
  290. }
  291. function loadAppearance(){
  292. $appearance = array();
  293. $appearance['logo'] = $GLOBALS['logo'];
  294. $appearance['title'] = $GLOBALS['title'];
  295. $appearance['useLogo'] = $GLOBALS['useLogo'];
  296. $appearance['headerColor'] = $GLOBALS['headerColor'];
  297. $appearance['loginWallpaper'] = $GLOBALS['loginWallpaper'];
  298. return $appearance;
  299. }
  300. function getCustomizeAppearance(){
  301. if(file_exists(dirname(__DIR__,1).DIRECTORY_SEPARATOR.'config'.DIRECTORY_SEPARATOR.'config.php')){
  302. return array(
  303. 'config' => array(/*
  304. array(
  305. 'type' => 'select',
  306. 'name' => 'branch',
  307. 'label' => 'Organizr Branch',
  308. 'value' => $GLOBALS['branch'],
  309. 'options' => array(
  310. 'Master' => 'v2-master',
  311. 'Develop' => 'v2-develop'
  312. )
  313. ),*/
  314. array(
  315. 'type' => 'input',
  316. 'name' => 'logo',
  317. 'label' => 'Logo',
  318. 'value' => $GLOBALS['logo']
  319. ),
  320. array(
  321. 'type' => 'input',
  322. 'name' => 'loginWallpaper',
  323. 'label' => 'Login Wallpaper',
  324. 'value' => $GLOBALS['loginWallpaper']
  325. ),
  326. array(
  327. 'type' => 'input',
  328. 'name' => 'title',
  329. 'label' => 'Title',
  330. 'value' => $GLOBALS['title']
  331. ),
  332. array(
  333. 'type' => 'switch',
  334. 'name' => 'useLogo',
  335. 'label' => 'Use Logo instead of Title',
  336. 'value' => $GLOBALS['useLogo']
  337. ),
  338. array(
  339. 'type' => 'input',
  340. 'name' => 'headerColor',
  341. 'label' => 'Nav Bar Color',
  342. 'value' => $GLOBALS['headerColor'],
  343. 'class' => 'colorpicker',
  344. 'disabled' => true
  345. ),
  346. array(
  347. 'type' => 'select',
  348. 'name' => 'theme',
  349. 'label' => 'Theme',
  350. 'class' => 'themeChanger',
  351. 'value' => $GLOBALS['theme'],
  352. 'options' => getThemes()
  353. )
  354. ),
  355. 'database' => array(
  356. )
  357. );
  358. }
  359. }
  360. function editAppearance($array){
  361. switch ($array['data']['value']) {
  362. case 'true':
  363. $array['data']['value'] = (bool) true;
  364. break;
  365. case 'false':
  366. $array['data']['value'] = (bool) false;
  367. break;
  368. default:
  369. $array['data']['value'] = $array['data']['value'];
  370. }
  371. //return gettype($array['data']['value']).' - '.$array['data']['value'];
  372. switch ($array['data']['action']) {
  373. case 'editCustomizeAppearance':
  374. $newItem = array(
  375. $array['data']['name'] => $array['data']['value']
  376. );
  377. return (updateConfig($newItem)) ? true : false;
  378. break;
  379. default:
  380. # code...
  381. break;
  382. }
  383. }
  384. function updateConfigItem($array){
  385. switch ($array['data']['value']) {
  386. case 'true':
  387. $array['data']['value'] = (bool) true;
  388. break;
  389. case 'false':
  390. $array['data']['value'] = (bool) false;
  391. break;
  392. default:
  393. $array['data']['value'] = $array['data']['value'];
  394. }
  395. // Hash
  396. if($array['data']['type'] == 'password'){
  397. $array['data']['value'] = encrypt($array['data']['value']);
  398. }
  399. //return gettype($array['data']['value']).' - '.$array['data']['value'];
  400. $newItem = array(
  401. $array['data']['name'] => $array['data']['value']
  402. );
  403. return (updateConfig($newItem)) ? true : false;
  404. }
  405. function getPlugins(){
  406. if(file_exists(dirname(__DIR__,1).DIRECTORY_SEPARATOR.'config'.DIRECTORY_SEPARATOR.'config.php')){
  407. $pluginList = array();
  408. foreach($GLOBALS['plugins'] as $plugin){
  409. foreach ($plugin as $key => $value) {
  410. $plugin[$key]['enabled'] = $GLOBALS[$value['configPrefix'].'-enabled'];
  411. }
  412. $pluginList = array_merge($pluginList, $plugin);
  413. }
  414. return $pluginList;
  415. }
  416. return false;
  417. }
  418. function editPlugins($array){
  419. switch ($array['data']['action']) {
  420. case 'enable':
  421. $newItem = array(
  422. $array['data']['configName'] => true
  423. );
  424. writeLog('success', 'Plugin Function - Enabled Plugin ['.$_POST['data']['name'].']', $GLOBALS['organizrUser']['username']);
  425. return (updateConfig($newItem)) ? true : false;
  426. break;
  427. case 'disable':
  428. $newItem = array(
  429. $array['data']['configName'] => false
  430. );
  431. writeLog('success', 'Plugin Function - Disabled Plugin ['.$_POST['data']['name'].']', $GLOBALS['organizrUser']['username']);
  432. return (updateConfig($newItem)) ? true : false;
  433. break;
  434. default:
  435. # code...
  436. break;
  437. }
  438. }
  439. function auth(){
  440. $debug = false; // CAREFUL WHEN SETTING TO TRUE AS THIS OPENS AUTH UP
  441. $ban = isset($_GET['ban']) ? strtoupper($_GET['ban']) : "";
  442. $whitelist = isset($_GET['whitelist']) ? $_GET['whitelist'] : false;
  443. $blacklist = isset($_GET['blacklist']) ? $_GET['blacklist'] : false;
  444. $group = isset($_GET['group']) ? $_GET['group'] : 0;
  445. $currentIP = userIP();
  446. $currentUser = $GLOBALS['organizrUser']['username'];
  447. if ($whitelist) {
  448. if(in_array($currentIP, arrayIP($whitelist))) {
  449. !$debug ? exit(http_response_code(200)) : die("$currentIP Whitelist Authorized");
  450. }
  451. }
  452. if ($blacklist) {
  453. if(in_array($currentIP, arrayIP($blacklist))) {
  454. !$debug ? exit(http_response_code(401)) : die("$currentIP Blacklisted");
  455. }
  456. }
  457. if($group !== null){
  458. if(qualifyRequest($group)){
  459. !$debug ? exit(http_response_code(200)) : die("$currentUser on $currentIP Authorized");
  460. }else{
  461. !$debug ? exit(http_response_code(401)) : die("$currentUser on $currentIP Not Authorized");
  462. }
  463. }else{
  464. !$debug ? exit(http_response_code(401)) : die("Not Authorized Due To No Parameters Set");
  465. }
  466. }
  467. function logoOrText(){
  468. if($GLOBALS['useLogo'] == false){
  469. return '<h1>'.$GLOBALS['title'].'</h1>';
  470. }else{
  471. return '<img style="max-width: 350px;" src="'.$GLOBALS['logo'].'" alt="Home" />';
  472. }
  473. }
  474. function getImages(){
  475. $dirname = dirname(__DIR__,2).DIRECTORY_SEPARATOR.'plugins'.DIRECTORY_SEPARATOR.'images'.DIRECTORY_SEPARATOR.'tabs'.DIRECTORY_SEPARATOR;
  476. $path = 'plugins/images/tabs/';
  477. $images = scandir($dirname);
  478. $ignore = Array(".", "..", "._.DS_Store", ".DS_Store");
  479. $allIcons = array();
  480. foreach($images as $image){
  481. if(!in_array($image, $ignore)) {
  482. $allIcons[] = $path.$image;
  483. }
  484. }
  485. return $allIcons;
  486. }
  487. function editImages(){
  488. $array = array();
  489. $postCheck = array_filter($_POST);
  490. $filesCheck = array_filter($_FILES);
  491. if(!empty($postCheck)){
  492. if($_POST['data']['action'] == 'deleteImage'){
  493. if(file_exists(dirname(__DIR__,2).DIRECTORY_SEPARATOR.$_POST['data']['imagePath'])){
  494. writeLog('success', 'Image Manager Function - Deleted Image ['.$_POST['data']['imageName'].']', $GLOBALS['organizrUser']['username']);
  495. return (unlink(dirname(__DIR__,2).DIRECTORY_SEPARATOR.$_POST['data']['imagePath'])) ? true : false;
  496. }
  497. }
  498. }
  499. if(!empty($filesCheck)){
  500. ini_set('upload_max_filesize', '10M');
  501. ini_set('post_max_size', '10M');
  502. $tempFile = $_FILES['file']['tmp_name'];
  503. $targetPath = dirname(__DIR__,2).DIRECTORY_SEPARATOR.'plugins'.DIRECTORY_SEPARATOR.'images'.DIRECTORY_SEPARATOR.'tabs'.DIRECTORY_SEPARATOR;
  504. $targetFile = $targetPath. $_FILES['file']['name'];
  505. return (move_uploaded_file($tempFile,$targetFile)) ? true : false;
  506. }
  507. return false;
  508. }
  509. function getThemes(){
  510. $themes = array();
  511. foreach (glob(dirname(__DIR__,2).DIRECTORY_SEPARATOR.'css' . DIRECTORY_SEPARATOR . 'themes' . DIRECTORY_SEPARATOR . "*.css") as $filename){
  512. $themes[] = array(
  513. 'name' => preg_replace('/\\.[^.\\s]{3,4}$/', '', basename($filename)),
  514. 'value' => preg_replace('/\\.[^.\\s]{3,4}$/', '', basename($filename))
  515. );
  516. }
  517. return $themes;
  518. }
  519. function getBranches(){
  520. return array(
  521. array(
  522. 'name' => 'Develeop',
  523. 'value' => 'v2-develop'
  524. ),
  525. array(
  526. 'name' => 'Master',
  527. 'value' => 'v2-master'
  528. )
  529. );
  530. }
  531. function getAuthTypes(){
  532. return array(
  533. array(
  534. 'name' => 'Organizr DB',
  535. 'value' => 'internal'
  536. ),
  537. array(
  538. 'name' => 'Organizr DB + Backend',
  539. 'value' => 'both'
  540. ),
  541. array(
  542. 'name' => 'Backend Only',
  543. 'value' => 'external'
  544. )
  545. );
  546. }
  547. function getAuthBackends(){
  548. $backendOptions = array();
  549. $backendOptions[] = array(
  550. 'name' => 'Choose Backend',
  551. 'value' => false,
  552. 'disabled' => true
  553. );
  554. foreach (array_filter(get_defined_functions()['user'],function($v) { return strpos($v, 'plugin_auth_') === 0; }) as $value) {
  555. $name = str_replace('plugin_auth_','',$value);
  556. if (strpos($name, 'disabled') === false) {
  557. $backendOptions[] = array(
  558. 'name' => ucwords(str_replace('_',' ',$name)),
  559. 'value' => $name
  560. );
  561. } else {
  562. $backendOptions[] = array(
  563. 'name' => $value(),
  564. 'value' => 'none',
  565. 'disabled' => true,
  566. );
  567. }
  568. }
  569. ksort($backendOptions);
  570. return $backendOptions;
  571. }
  572. /*
  573. function sendEmail($email = null, $username = "Organizr User", $subject, $body, $cc = null, $bcc = null){
  574. try {
  575. $mail = new PHPMailer(true);
  576. $mail->isSMTP();
  577. $mail->Host = $GLOBALS['smtpHost'];
  578. $mail->SMTPAuth = $GLOBALS['smtpHostAuth'];
  579. $mail->Username = $GLOBALS['smtpHostUsername'];
  580. $mail->Password = $GLOBALS['smtpHostPassword'];
  581. $mail->SMTPSecure = $GLOBALS['smtpHostType'];
  582. $mail->Port = $GLOBALS['smtpHostPort'];
  583. $mail->setFrom($GLOBALS['smtpHostSenderEmail'], $GLOBALS['smtpHostSenderName']);
  584. $mail->addReplyTo($GLOBALS['smtpHostSenderEmail'], $GLOBALS['smtpHostSenderName']);
  585. $mail->isHTML(true);
  586. if($email){
  587. $mail->addAddress($email, $username);
  588. }
  589. if($cc){
  590. $mail->addCC($cc);
  591. }
  592. if($bcc){
  593. if(strpos($bcc , ',') === false){
  594. $mail->addBCC($bcc);
  595. }else{
  596. $allEmails = explode(",",$bcc);
  597. foreach($allEmails as $gotEmail){
  598. $mail->addBCC($gotEmail);
  599. }
  600. }
  601. }
  602. $mail->Subject = $subject;
  603. $mail->Body = $body;
  604. $mail->send();
  605. writeLog('success', 'Mail Function - E-Mail Sent', $GLOBALS['organizrUser']['username']);
  606. return true;
  607. } catch (Exception $e) {
  608. writeLog('error', 'Mail Function - E-Mail Failed['.$mail->ErrorInfo.']', $GLOBALS['organizrUser']['username']);
  609. return false;
  610. }
  611. return false;
  612. }
  613. //EMAIL SHIT
  614. function sendTestEmail($to, $from, $host, $auth, $username, $password, $type, $port, $sendername){
  615. try {
  616. $mail = new PHPMailer(true);
  617. $mail->isSMTP();
  618. $mail->Host = $host;
  619. $mail->SMTPAuth = $auth;
  620. $mail->Username = $username;
  621. $mail->Password = $password;
  622. $mail->SMTPSecure = $type;
  623. $mail->Port = $port;
  624. $mail->setFrom($from, $sendername);
  625. $mail->addReplyTo($from, $sendername);
  626. $mail->isHTML(true);
  627. $mail->addAddress($to, "Organizr Admin");
  628. $mail->Subject = "Organizr Test E-Mail";
  629. $mail->Body = "This was just a test!";
  630. $mail->send();
  631. writeLog('success', 'Mail Function - E-Mail Test Sent', $GLOBALS['organizrUser']['username']);
  632. return true;
  633. } catch (Exception $e) {
  634. writeLog('error', 'Mail Function - E-Mail Test Failed['.$mail->ErrorInfo.']', $GLOBALS['organizrUser']['username']);
  635. return false;
  636. }
  637. return false;
  638. }
  639. */