Commit b250db4463ebea59816f66cd187f366cc5815bdd
Merge branch 'edge' of git@github.com:ktgit/knowledgetree into edge
Showing
7 changed files
with
472 additions
and
182 deletions
dmsctl.bat
| ... | ... | @@ -6,6 +6,7 @@ rem KnowledgeTree Control Script |
| 6 | 6 | rem ============= SET ENVIRONMENT VARIABLES ============== |
| 7 | 7 | set INSTALL_PATH=%CD% |
| 8 | 8 | cd .. |
| 9 | +cd .. | |
| 9 | 10 | set ZEND_PATH=%CD% |
| 10 | 11 | cd %INSTALL_PATH% |
| 11 | 12 | set JAVA_BIN=%ZEND_PATH%\jre\bin\java.exe |
| ... | ... | @@ -82,4 +83,4 @@ echo The Scheduler automatic service was successfully installed |
| 82 | 83 | IF EXIST "%INSTALL_PATH%\var\bin\luceneinstall.bat" call "%INSTALL_PATH%\var\bin\luceneinstall.bat" |
| 83 | 84 | goto end |
| 84 | 85 | |
| 85 | -:end | |
| 86 | 86 | \ No newline at end of file |
| 87 | +:end | ... | ... |
setup/wizard/installUtil.php
| ... | ... | @@ -47,7 +47,7 @@ class InstallUtil { |
| 47 | 47 | private $salt = 'installers'; |
| 48 | 48 | public $dbUtilities = null; |
| 49 | 49 | public $iniUtilities = null; |
| 50 | - | |
| 50 | + | |
| 51 | 51 | /** |
| 52 | 52 | * Constructs installation object |
| 53 | 53 | * |
| ... | ... | @@ -83,9 +83,9 @@ class InstallUtil { |
| 83 | 83 | include($file); |
| 84 | 84 | $contents = ob_get_contents(); |
| 85 | 85 | ob_end_clean(); |
| 86 | - echo $contents; | |
| 86 | + echo $contents; | |
| 87 | 87 | } |
| 88 | - | |
| 88 | + | |
| 89 | 89 | return false; |
| 90 | 90 | |
| 91 | 91 | } |
| ... | ... | @@ -460,7 +460,7 @@ class InstallUtil { |
| 460 | 460 | return preg_replace('/java:/', '', $r); |
| 461 | 461 | } |
| 462 | 462 | } |
| 463 | - | |
| 463 | + | |
| 464 | 464 | return ''; |
| 465 | 465 | } |
| 466 | 466 | |
| ... | ... | @@ -530,10 +530,10 @@ class InstallUtil { |
| 530 | 530 | return true; |
| 531 | 531 | } |
| 532 | 532 | } |
| 533 | - | |
| 533 | + | |
| 534 | 534 | return false; |
| 535 | 535 | } |
| 536 | - | |
| 536 | + | |
| 537 | 537 | /** |
| 538 | 538 | * Check if system needs to be migrated |
| 539 | 539 | * |
| ... | ... | @@ -548,10 +548,10 @@ class InstallUtil { |
| 548 | 548 | return true; |
| 549 | 549 | } |
| 550 | 550 | } |
| 551 | - | |
| 551 | + | |
| 552 | 552 | return false; |
| 553 | 553 | } |
| 554 | - | |
| 554 | + | |
| 555 | 555 | /** |
| 556 | 556 | * Check if system needs to be migrated |
| 557 | 557 | * |
| ... | ... | @@ -566,10 +566,10 @@ class InstallUtil { |
| 566 | 566 | return true; |
| 567 | 567 | } |
| 568 | 568 | } |
| 569 | - | |
| 569 | + | |
| 570 | 570 | return false; |
| 571 | 571 | } |
| 572 | - | |
| 572 | + | |
| 573 | 573 | /** |
| 574 | 574 | * Check if system needs to be migrated |
| 575 | 575 | * |
| ... | ... | @@ -584,10 +584,10 @@ class InstallUtil { |
| 584 | 584 | return true; |
| 585 | 585 | } |
| 586 | 586 | } |
| 587 | - | |
| 587 | + | |
| 588 | 588 | return false; |
| 589 | 589 | } |
| 590 | - | |
| 590 | + | |
| 591 | 591 | /** |
| 592 | 592 | * Get session data from package |
| 593 | 593 | * |
| ... | ... | @@ -600,10 +600,10 @@ class InstallUtil { |
| 600 | 600 | if(empty($_SESSION[$package][$class])) { |
| 601 | 601 | return false; |
| 602 | 602 | } |
| 603 | - | |
| 603 | + | |
| 604 | 604 | return $_SESSION[$package][$class]; |
| 605 | 605 | } |
| 606 | - | |
| 606 | + | |
| 607 | 607 | /** |
| 608 | 608 | * Get session data from post |
| 609 | 609 | * |
| ... | ... | @@ -688,7 +688,7 @@ class InstallUtil { |
| 688 | 688 | /** |
| 689 | 689 | * Deletes migration lock file if a clean install is chosen |
| 690 | 690 | * This is in case someone changes their mind after choosing upgrade/migrate and clicks back up to this step |
| 691 | - * | |
| 691 | + * | |
| 692 | 692 | * @author KnowledgeTree Team |
| 693 | 693 | * @access public |
| 694 | 694 | * @return void |
| ... | ... | @@ -710,10 +710,10 @@ class InstallUtil { |
| 710 | 710 | return true; |
| 711 | 711 | return false; |
| 712 | 712 | } |
| 713 | - | |
| 713 | + | |
| 714 | 714 | /** |
| 715 | 715 | * Determine type of installation |
| 716 | - * | |
| 716 | + * | |
| 717 | 717 | * @author KnowledgeTree Team |
| 718 | 718 | * @access public |
| 719 | 719 | * @return string |
| ... | ... | @@ -732,10 +732,10 @@ class InstallUtil { |
| 732 | 732 | } |
| 733 | 733 | } |
| 734 | 734 | } |
| 735 | - | |
| 735 | + | |
| 736 | 736 | /** |
| 737 | 737 | * Determine if zend php exists |
| 738 | - * | |
| 738 | + * | |
| 739 | 739 | * @author KnowledgeTree Team |
| 740 | 740 | * @access public |
| 741 | 741 | * @return string |
| ... | ... | @@ -746,6 +746,7 @@ class InstallUtil { |
| 746 | 746 | $sysdir = explode(DS, SYSTEM_DIR); |
| 747 | 747 | array_pop($sysdir); |
| 748 | 748 | array_pop($sysdir); |
| 749 | + array_pop($sysdir); | |
| 749 | 750 | $zendsys = ''; |
| 750 | 751 | foreach ($sysdir as $v) { |
| 751 | 752 | $zendsys .= $v.DS; |
| ... | ... | @@ -757,13 +758,58 @@ class InstallUtil { |
| 757 | 758 | return DS."usr".DS."local".DS."zend".DS."bin".DS; |
| 758 | 759 | } |
| 759 | 760 | } |
| 760 | - | |
| 761 | + | |
| 761 | 762 | return false; |
| 762 | 763 | } |
| 763 | - | |
| 764 | + | |
| 765 | + public function useZendJVM() { | |
| 766 | + if($this->util->installEnvironment() == 'Zend') { | |
| 767 | + if(WINDOWS_OS) { // For Zend Installation only | |
| 768 | + $sysdir = explode(DS, SYSTEM_DIR); | |
| 769 | + array_pop($sysdir); | |
| 770 | + array_pop($sysdir); | |
| 771 | + array_pop($sysdir); | |
| 772 | + $zendsys = ''; | |
| 773 | + foreach ($sysdir as $v) { | |
| 774 | + $zendsys .= $v.DS; | |
| 775 | + } | |
| 776 | + $jvm = $zendsys."jre".DS."bin".DS."client".DS."jvm.dll"; | |
| 777 | + if(file_exists($jvm)) | |
| 778 | + return $jvm; | |
| 779 | + } | |
| 780 | + } | |
| 781 | + | |
| 782 | + return false; | |
| 783 | + } | |
| 784 | + | |
| 785 | + public function useZendJava() { | |
| 786 | + if($this->installEnvironment() == 'Zend') { | |
| 787 | + if(WINDOWS_OS) { // For Zend Installation only | |
| 788 | + $sysdir = explode(DS, SYSTEM_DIR); | |
| 789 | + array_pop($sysdir); | |
| 790 | + array_pop($sysdir); | |
| 791 | + array_pop($sysdir); | |
| 792 | + $zendsys = ''; | |
| 793 | + foreach ($sysdir as $v) { | |
| 794 | + $zendsys .= $v.DS; | |
| 795 | + } | |
| 796 | + $jvm = $zendsys."jre".DS."bin".DS."client".DS."jvm.dll"; | |
| 797 | + if(file_exists($jvm)) | |
| 798 | + return $jvm; | |
| 799 | + } else { | |
| 800 | + $java = "/usr/bin/java"; | |
| 801 | + if(file_exists($java)) { | |
| 802 | + return $java; | |
| 803 | + } | |
| 804 | + } | |
| 805 | + } | |
| 806 | + | |
| 807 | + return false; | |
| 808 | + } | |
| 809 | + | |
| 764 | 810 | /** |
| 765 | 811 | * Determine if mysql exists |
| 766 | - * | |
| 812 | + * | |
| 767 | 813 | * @author KnowledgeTree Team |
| 768 | 814 | * @access public |
| 769 | 815 | * @return string |
| ... | ... | @@ -780,14 +826,14 @@ class InstallUtil { |
| 780 | 826 | } |
| 781 | 827 | } |
| 782 | 828 | } |
| 783 | - | |
| 829 | + | |
| 784 | 830 | return "mysql"; // Assume its linux and can be executed from command line |
| 785 | 831 | } |
| 786 | 832 | |
| 787 | 833 | public function sqlInstallDir() { |
| 788 | 834 | return SYSTEM_DIR."sql".DS."mysql".DS."install".DS; |
| 789 | 835 | } |
| 790 | - | |
| 836 | + | |
| 791 | 837 | public function getFileByLine($file) { |
| 792 | 838 | $fileLines = array(); |
| 793 | 839 | $file_handle = fopen($file, "rb"); |
| ... | ... | @@ -799,7 +845,7 @@ class InstallUtil { |
| 799 | 845 | fclose($file_handle); |
| 800 | 846 | return $fileLines; |
| 801 | 847 | } |
| 802 | - | |
| 848 | + | |
| 803 | 849 | /** |
| 804 | 850 | * Portably execute a command on any of the supported platforms. |
| 805 | 851 | * |
| ... | ... | @@ -893,5 +939,8 @@ class InstallUtil { |
| 893 | 939 | return join(" ", $aSafeArgs); |
| 894 | 940 | } |
| 895 | 941 | |
| 942 | + /* | |
| 943 | + Just Because. | |
| 944 | + */ | |
| 896 | 945 | } |
| 897 | 946 | ?> | ... | ... |
setup/wizard/lib/services/windowsLucene.php
| ... | ... | @@ -45,19 +45,19 @@ class windowsLucene extends windowsService { |
| 45 | 45 | * |
| 46 | 46 | * @author KnowledgeTree Team |
| 47 | 47 | * @access private |
| 48 | - * @var string | |
| 48 | + * @var string | |
| 49 | 49 | */ |
| 50 | 50 | private $javaBin; |
| 51 | - | |
| 51 | + | |
| 52 | 52 | /** |
| 53 | 53 | * Java JVM path |
| 54 | 54 | * |
| 55 | 55 | * @author KnowledgeTree Team |
| 56 | 56 | * @access private |
| 57 | - * @var string | |
| 57 | + * @var string | |
| 58 | 58 | */ |
| 59 | 59 | private $javaJVM; |
| 60 | - | |
| 60 | + | |
| 61 | 61 | /** |
| 62 | 62 | * Java System object |
| 63 | 63 | * |
| ... | ... | @@ -66,61 +66,61 @@ class windowsLucene extends windowsService { |
| 66 | 66 | * @var object |
| 67 | 67 | */ |
| 68 | 68 | private $javaSystem; |
| 69 | - | |
| 69 | + | |
| 70 | 70 | /** |
| 71 | 71 | * Lucene executable path |
| 72 | 72 | * |
| 73 | 73 | * @author KnowledgeTree Team |
| 74 | 74 | * @access private |
| 75 | - * @var string | |
| 75 | + * @var string | |
| 76 | 76 | */ |
| 77 | 77 | private $luceneExe; |
| 78 | - | |
| 78 | + | |
| 79 | 79 | /** |
| 80 | 80 | * Lucene jar path |
| 81 | 81 | * |
| 82 | 82 | * @author KnowledgeTree Team |
| 83 | 83 | * @access private |
| 84 | - * @var string | |
| 84 | + * @var string | |
| 85 | 85 | */ |
| 86 | 86 | private $luceneSource; |
| 87 | - | |
| 87 | + | |
| 88 | 88 | /** |
| 89 | 89 | * Lucene package name |
| 90 | 90 | * |
| 91 | 91 | * @author KnowledgeTree Team |
| 92 | 92 | * @access private |
| 93 | - * @var string | |
| 93 | + * @var string | |
| 94 | 94 | */ |
| 95 | 95 | private $luceneServer; |
| 96 | - | |
| 96 | + | |
| 97 | 97 | /** |
| 98 | 98 | * Lucene output log path |
| 99 | 99 | * |
| 100 | 100 | * @author KnowledgeTree Team |
| 101 | 101 | * @access private |
| 102 | - * @var string | |
| 102 | + * @var string | |
| 103 | 103 | */ |
| 104 | 104 | private $luceneOut; |
| 105 | - | |
| 105 | + | |
| 106 | 106 | /** |
| 107 | 107 | * Lucene error log path |
| 108 | 108 | * |
| 109 | 109 | * @author KnowledgeTree Team |
| 110 | 110 | * @access private |
| 111 | - * @var string | |
| 111 | + * @var string | |
| 112 | 112 | */ |
| 113 | 113 | private $luceneError; |
| 114 | - | |
| 114 | + | |
| 115 | 115 | /** |
| 116 | 116 | * Lucene directory path |
| 117 | 117 | * |
| 118 | 118 | * @author KnowledgeTree Team |
| 119 | 119 | * @access private |
| 120 | - * @var string | |
| 120 | + * @var string | |
| 121 | 121 | */ |
| 122 | 122 | private $luceneDir; |
| 123 | - | |
| 123 | + | |
| 124 | 124 | |
| 125 | 125 | /** |
| 126 | 126 | * Service name |
| ... | ... | @@ -129,9 +129,9 @@ class windowsLucene extends windowsService { |
| 129 | 129 | * @access public |
| 130 | 130 | * @param none |
| 131 | 131 | * @return string |
| 132 | - */ | |
| 132 | + */ | |
| 133 | 133 | public $name = "KTLucene"; |
| 134 | - | |
| 134 | + | |
| 135 | 135 | /** |
| 136 | 136 | * Load defaults needed by service |
| 137 | 137 | * |
| ... | ... | @@ -150,7 +150,7 @@ class windowsLucene extends windowsService { |
| 150 | 150 | $this->setLuceneOut("lucene-out.txt"); |
| 151 | 151 | $this->setLuceneError("lucene-err.txt"); |
| 152 | 152 | } |
| 153 | - | |
| 153 | + | |
| 154 | 154 | /** |
| 155 | 155 | * Set Java Directory path |
| 156 | 156 | * |
| ... | ... | @@ -164,7 +164,7 @@ class windowsLucene extends windowsService { |
| 164 | 164 | if($this->util->javaBridge()) { |
| 165 | 165 | $this->javaSystem = new Java('java.lang.System'); |
| 166 | 166 | $this->javaBin = $this->javaSystem->getProperty('java.home').DS."bin"; |
| 167 | - | |
| 167 | + | |
| 168 | 168 | return true; |
| 169 | 169 | } |
| 170 | 170 | } |
| ... | ... | @@ -173,7 +173,7 @@ class windowsLucene extends windowsService { |
| 173 | 173 | $this->javaBin = file_get_contents($this->varDir.'outJVHome'); |
| 174 | 174 | if($this->javaBin != '') return true; |
| 175 | 175 | } |
| 176 | - | |
| 176 | + | |
| 177 | 177 | return false; |
| 178 | 178 | } |
| 179 | 179 | |
| ... | ... | @@ -188,7 +188,7 @@ class windowsLucene extends windowsService { |
| 188 | 188 | public function getJavaBin() { |
| 189 | 189 | return $this->javaBin; |
| 190 | 190 | } |
| 191 | - | |
| 191 | + | |
| 192 | 192 | /** |
| 193 | 193 | * Set Lucene directory path |
| 194 | 194 | * |
| ... | ... | @@ -200,7 +200,7 @@ class windowsLucene extends windowsService { |
| 200 | 200 | private function setLuceneDIR($luceneDir) { |
| 201 | 201 | $this->luceneDir = $luceneDir; |
| 202 | 202 | } |
| 203 | - | |
| 203 | + | |
| 204 | 204 | /** |
| 205 | 205 | * Get Lucene directory path |
| 206 | 206 | * |
| ... | ... | @@ -226,7 +226,7 @@ class windowsLucene extends windowsService { |
| 226 | 226 | private function setLuceneExe($luceneExe) { |
| 227 | 227 | $this->luceneExe = $this->getluceneDir().DS.$luceneExe; |
| 228 | 228 | } |
| 229 | - | |
| 229 | + | |
| 230 | 230 | /** |
| 231 | 231 | * Get Lucene executable path |
| 232 | 232 | * |
| ... | ... | @@ -240,7 +240,7 @@ class windowsLucene extends windowsService { |
| 240 | 240 | return $this->luceneExe; |
| 241 | 241 | return false; |
| 242 | 242 | } |
| 243 | - | |
| 243 | + | |
| 244 | 244 | /** |
| 245 | 245 | * Set Lucene source path |
| 246 | 246 | * |
| ... | ... | @@ -252,7 +252,7 @@ class windowsLucene extends windowsService { |
| 252 | 252 | private function setLuceneSource($luceneSource) { |
| 253 | 253 | $this->luceneSource = $this->getluceneDir().DS.$luceneSource; |
| 254 | 254 | } |
| 255 | - | |
| 255 | + | |
| 256 | 256 | /** |
| 257 | 257 | * Get Lucene source path |
| 258 | 258 | * |
| ... | ... | @@ -266,7 +266,7 @@ class windowsLucene extends windowsService { |
| 266 | 266 | return $this->luceneSource; |
| 267 | 267 | return false; |
| 268 | 268 | } |
| 269 | - | |
| 269 | + | |
| 270 | 270 | /** |
| 271 | 271 | * Set Lucene package name |
| 272 | 272 | * |
| ... | ... | @@ -278,7 +278,7 @@ class windowsLucene extends windowsService { |
| 278 | 278 | private function setLuceneServer($luceneServer) { |
| 279 | 279 | $this->luceneServer = $luceneServer; |
| 280 | 280 | } |
| 281 | - | |
| 281 | + | |
| 282 | 282 | /** |
| 283 | 283 | * Get Lucene package name |
| 284 | 284 | * |
| ... | ... | @@ -290,7 +290,7 @@ class windowsLucene extends windowsService { |
| 290 | 290 | public function getLuceneServer() { |
| 291 | 291 | return $this->luceneServer; |
| 292 | 292 | } |
| 293 | - | |
| 293 | + | |
| 294 | 294 | /** |
| 295 | 295 | * Set Lucene output file path |
| 296 | 296 | * |
| ... | ... | @@ -302,7 +302,7 @@ class windowsLucene extends windowsService { |
| 302 | 302 | private function setLuceneOut($luceneOut) { |
| 303 | 303 | $this->luceneOut = $this->outputDir.$luceneOut; |
| 304 | 304 | } |
| 305 | - | |
| 305 | + | |
| 306 | 306 | /** |
| 307 | 307 | * Get Lucene output file path |
| 308 | 308 | * |
| ... | ... | @@ -314,7 +314,7 @@ class windowsLucene extends windowsService { |
| 314 | 314 | public function getLuceneOut() { |
| 315 | 315 | return $this->luceneOut; |
| 316 | 316 | } |
| 317 | - | |
| 317 | + | |
| 318 | 318 | /** |
| 319 | 319 | * Set Lucene error file path |
| 320 | 320 | * |
| ... | ... | @@ -326,7 +326,7 @@ class windowsLucene extends windowsService { |
| 326 | 326 | private function setLuceneError($luceneError) { |
| 327 | 327 | $this->luceneError = $this->outputDir.$luceneError; |
| 328 | 328 | } |
| 329 | - | |
| 329 | + | |
| 330 | 330 | /** |
| 331 | 331 | * Get Lucene error file path |
| 332 | 332 | * |
| ... | ... | @@ -338,7 +338,7 @@ class windowsLucene extends windowsService { |
| 338 | 338 | public function getLuceneError() { |
| 339 | 339 | return $this->luceneError; |
| 340 | 340 | } |
| 341 | - | |
| 341 | + | |
| 342 | 342 | /** |
| 343 | 343 | * Set Java JVM path |
| 344 | 344 | * |
| ... | ... | @@ -357,32 +357,13 @@ class windowsLucene extends windowsService { |
| 357 | 357 | } elseif (file_exists($this->getJavaBin().DS."bin".DS."server".DS."jvm.dll")) { |
| 358 | 358 | $this->javaJVM = $this->getJavaBin().DS."bin".DS."server".DS."jvm.dll"; |
| 359 | 359 | } else { |
| 360 | - $javaJVM = $this->useZendJVM(); | |
| 360 | + $javaJVM = $this->util->useZendJVM(); | |
| 361 | 361 | if(file_exists($javaJVM)) { |
| 362 | 362 | $this->javaJVM = $javaJVM; |
| 363 | 363 | } |
| 364 | 364 | } |
| 365 | 365 | } |
| 366 | - | |
| 367 | - public function useZendJVM() { | |
| 368 | - if($this->util->installEnvironment() == 'Zend') { | |
| 369 | - if(WINDOWS_OS) { // For Zend Installation only | |
| 370 | - $sysdir = explode(DS, SYSTEM_DIR); | |
| 371 | - array_pop($sysdir); | |
| 372 | - array_pop($sysdir); | |
| 373 | - $zendsys = ''; | |
| 374 | - foreach ($sysdir as $v) { | |
| 375 | - $zendsys .= $v.DS; | |
| 376 | - } | |
| 377 | - $jvm = $zendsys."jre".DS."bin".DS."client".DS."jvm.dll"; | |
| 378 | - if(file_exists($jvm)) | |
| 379 | - return $jvm; | |
| 380 | - } | |
| 381 | - } | |
| 382 | - | |
| 383 | - return false; | |
| 384 | - } | |
| 385 | - | |
| 366 | + | |
| 386 | 367 | /** |
| 387 | 368 | * Get Java JVM path |
| 388 | 369 | * |
| ... | ... | @@ -394,7 +375,7 @@ class windowsLucene extends windowsService { |
| 394 | 375 | public function getJavaJVM() { |
| 395 | 376 | return $this->javaJVM; |
| 396 | 377 | } |
| 397 | - | |
| 378 | + | |
| 398 | 379 | private function writeLuceneInstall($cmd) { |
| 399 | 380 | $luceneInstallFile = SYS_VAR_DIR."bin".DS."luceneinstall.bat"; |
| 400 | 381 | $fp = fopen($luceneInstallFile, "w+"); |
| ... | ... | @@ -428,10 +409,10 @@ class windowsLucene extends windowsService { |
| 428 | 409 | } |
| 429 | 410 | return $state; |
| 430 | 411 | } |
| 431 | - | |
| 412 | + | |
| 432 | 413 | return $state; |
| 433 | 414 | } |
| 434 | - | |
| 415 | + | |
| 435 | 416 | /** |
| 436 | 417 | * Start Service |
| 437 | 418 | * |
| ... | ... | @@ -459,7 +440,7 @@ class windowsLucene extends windowsService { |
| 459 | 440 | $state = preg_replace('/^STATE *\: *\d */', '', trim($response['out'][3])); // Status store in third key |
| 460 | 441 | return $state; |
| 461 | 442 | } |
| 462 | - | |
| 443 | + | |
| 463 | 444 | return ''; |
| 464 | 445 | } |
| 465 | 446 | } | ... | ... |
setup/wizard/lib/validation/luceneValidation.php
| ... | ... | @@ -49,7 +49,7 @@ class luceneValidation extends serviceValidation { |
| 49 | 49 | * @var string |
| 50 | 50 | */ |
| 51 | 51 | private $java = ""; |
| 52 | - | |
| 52 | + | |
| 53 | 53 | /** |
| 54 | 54 | * Minumum Java Version |
| 55 | 55 | * |
| ... | ... | @@ -67,7 +67,7 @@ class luceneValidation extends serviceValidation { |
| 67 | 67 | * @var mixed |
| 68 | 68 | */ |
| 69 | 69 | private $providedJava = false; |
| 70 | - | |
| 70 | + | |
| 71 | 71 | /** |
| 72 | 72 | * Flag, if java is specified and an error has been encountered |
| 73 | 73 | * |
| ... | ... | @@ -76,7 +76,7 @@ class luceneValidation extends serviceValidation { |
| 76 | 76 | * @var booelean |
| 77 | 77 | */ |
| 78 | 78 | private $javaExeError = false; |
| 79 | - | |
| 79 | + | |
| 80 | 80 | /** |
| 81 | 81 | * Holds path error, if java is specified |
| 82 | 82 | * |
| ... | ... | @@ -85,16 +85,16 @@ class luceneValidation extends serviceValidation { |
| 85 | 85 | * @var string |
| 86 | 86 | */ |
| 87 | 87 | private $javaExeMessage = ''; |
| 88 | - | |
| 88 | + | |
| 89 | 89 | /** |
| 90 | - * Java Installed | |
| 90 | + * Java Installed | |
| 91 | 91 | * |
| 92 | 92 | * @author KnowledgeTree Team |
| 93 | 93 | * @access private |
| 94 | 94 | * @var mixed |
| 95 | 95 | */ |
| 96 | 96 | private $javaCheck = 'cross'; |
| 97 | - | |
| 97 | + | |
| 98 | 98 | /** |
| 99 | 99 | * Flag if bridge extension needs to be disabled |
| 100 | 100 | * |
| ... | ... | @@ -105,14 +105,14 @@ class luceneValidation extends serviceValidation { |
| 105 | 105 | private $disableExtension = false; |
| 106 | 106 | |
| 107 | 107 | /** |
| 108 | - * Java Bridge Installed | |
| 108 | + * Java Bridge Installed | |
| 109 | 109 | * |
| 110 | 110 | * @author KnowledgeTree Team |
| 111 | 111 | * @access private |
| 112 | 112 | * @var mixed |
| 113 | 113 | */ |
| 114 | 114 | private $javaExtCheck = 'cross_orange'; |
| 115 | - | |
| 115 | + | |
| 116 | 116 | public function preset() { |
| 117 | 117 | /* Rely on Script */ |
| 118 | 118 | $this->zendBridgeInstalled(); |
| ... | ... | @@ -124,7 +124,7 @@ class luceneValidation extends serviceValidation { |
| 124 | 124 | // $this->javaNotInstalled(); // Set java to not installed |
| 125 | 125 | // $this->setJava(); // Check if java has been auto detected |
| 126 | 126 | } |
| 127 | - | |
| 127 | + | |
| 128 | 128 | /** |
| 129 | 129 | * Check if java executable was found |
| 130 | 130 | * |
| ... | ... | @@ -140,7 +140,7 @@ class luceneValidation extends serviceValidation { |
| 140 | 140 | $this->temp_variables['java']['location'] = $this->java; |
| 141 | 141 | return ; |
| 142 | 142 | } |
| 143 | - | |
| 143 | + | |
| 144 | 144 | $this->temp_variables['java']['location'] = $this->java; |
| 145 | 145 | } |
| 146 | 146 | |
| ... | ... | @@ -156,7 +156,7 @@ class luceneValidation extends serviceValidation { |
| 156 | 156 | $this->temp_variables['java']['class'] = 'tick'; |
| 157 | 157 | $this->temp_variables['java']['found'] = "Java Runtime Installed"; |
| 158 | 158 | } |
| 159 | - | |
| 159 | + | |
| 160 | 160 | /** |
| 161 | 161 | * Store Java state as not installed |
| 162 | 162 | * |
| ... | ... | @@ -169,7 +169,7 @@ class luceneValidation extends serviceValidation { |
| 169 | 169 | $this->temp_variables['java']['class'] = 'cross'; |
| 170 | 170 | $this->temp_variables['java']['found'] = "Java runtime environment required"; |
| 171 | 171 | } |
| 172 | - | |
| 172 | + | |
| 173 | 173 | /** |
| 174 | 174 | * Store Java version state as correct |
| 175 | 175 | * |
| ... | ... | @@ -182,7 +182,7 @@ class luceneValidation extends serviceValidation { |
| 182 | 182 | $this->temp_variables['version']['class'] = 'tick'; |
| 183 | 183 | $this->temp_variables['version']['found'] = "Java Version 1.5+ Installed"; |
| 184 | 184 | } |
| 185 | - | |
| 185 | + | |
| 186 | 186 | /** |
| 187 | 187 | * Store Java version state as warning |
| 188 | 188 | * @author KnowledgeTree Team |
| ... | ... | @@ -194,7 +194,7 @@ class luceneValidation extends serviceValidation { |
| 194 | 194 | $this->temp_variables['version']['class'] = 'cross_orange'; |
| 195 | 195 | $this->temp_variables['version']['found'] = "Java Runtime Version Cannot be detected"; |
| 196 | 196 | } |
| 197 | - | |
| 197 | + | |
| 198 | 198 | /** |
| 199 | 199 | * Store Java version as state incorrect |
| 200 | 200 | * |
| ... | ... | @@ -207,7 +207,7 @@ class luceneValidation extends serviceValidation { |
| 207 | 207 | $this->temp_variables['version']['class'] = 'cross'; |
| 208 | 208 | $this->temp_variables['version']['found'] = "Requires Java 1.5+ to be installed"; |
| 209 | 209 | } |
| 210 | - | |
| 210 | + | |
| 211 | 211 | /** |
| 212 | 212 | * Store Zend Bridge state as installed |
| 213 | 213 | * |
| ... | ... | @@ -220,10 +220,10 @@ class luceneValidation extends serviceValidation { |
| 220 | 220 | $this->temp_variables['extensions']['class'] = 'tick'; |
| 221 | 221 | $this->temp_variables['extensions']['found'] = "Java Bridge Installed"; |
| 222 | 222 | } |
| 223 | - | |
| 223 | + | |
| 224 | 224 | /** |
| 225 | 225 | * Store Zend Bridge state as not installed |
| 226 | - * | |
| 226 | + * | |
| 227 | 227 | * @author KnowledgeTree Team |
| 228 | 228 | * @param none |
| 229 | 229 | * @access private |
| ... | ... | @@ -233,7 +233,7 @@ class luceneValidation extends serviceValidation { |
| 233 | 233 | $this->temp_variables['extensions']['class'] = 'cross_orange'; |
| 234 | 234 | $this->temp_variables['extensions']['found'] = "Zend Java Bridge Not Installed"; |
| 235 | 235 | } |
| 236 | - | |
| 236 | + | |
| 237 | 237 | /** |
| 238 | 238 | * Store Zend Bridge state as warning |
| 239 | 239 | * |
| ... | ... | @@ -246,18 +246,18 @@ class luceneValidation extends serviceValidation { |
| 246 | 246 | $this->temp_variables['extensions']['class'] = 'cross_orange'; |
| 247 | 247 | $this->temp_variables['extensions']['found'] = "Zend Java Bridge Not Functional"; |
| 248 | 248 | } |
| 249 | - | |
| 249 | + | |
| 250 | 250 | public function installed() { |
| 251 | 251 | $this->disableExtension = true; // Disable the use of the php bridge extension |
| 252 | 252 | $this->javaVersionCorrect(); |
| 253 | 253 | $this->javaInstalled(); |
| 254 | 254 | $this->javaCheck = 'tick'; |
| 255 | 255 | } |
| 256 | - | |
| 256 | + | |
| 257 | 257 | public function getBinary() { |
| 258 | 258 | $this->java = $this->util->getJava(); |
| 259 | 259 | } |
| 260 | - | |
| 260 | + | |
| 261 | 261 | /** |
| 262 | 262 | * Do some basic checks to help the user overcome java problems |
| 263 | 263 | * |
| ... | ... | @@ -267,7 +267,7 @@ class luceneValidation extends serviceValidation { |
| 267 | 267 | * @return boolean |
| 268 | 268 | */ |
| 269 | 269 | public function binaryChecks() { |
| 270 | - $java = $this->useZendJava(); | |
| 270 | + $java = $this->util->useZendJava(); | |
| 271 | 271 | if(!$java) { |
| 272 | 272 | if($this->util->javaSpecified()) { |
| 273 | 273 | $this->disableExtension = true; // Disable the use of the php bridge extension |
| ... | ... | @@ -292,10 +292,10 @@ class luceneValidation extends serviceValidation { |
| 292 | 292 | return $auto; |
| 293 | 293 | } |
| 294 | 294 | } |
| 295 | - | |
| 295 | + | |
| 296 | 296 | return $java; |
| 297 | 297 | } |
| 298 | - | |
| 298 | + | |
| 299 | 299 | /** |
| 300 | 300 | * Set template view to specify java |
| 301 | 301 | * |
| ... | ... | @@ -307,7 +307,7 @@ class luceneValidation extends serviceValidation { |
| 307 | 307 | private function specifyJava() { |
| 308 | 308 | $this->javaExeError = true; |
| 309 | 309 | } |
| 310 | - | |
| 310 | + | |
| 311 | 311 | /** |
| 312 | 312 | * Attempts to use bridge and configure java settings |
| 313 | 313 | * |
| ... | ... | @@ -348,7 +348,7 @@ class luceneValidation extends serviceValidation { |
| 348 | 348 | return false; |
| 349 | 349 | } |
| 350 | 350 | } |
| 351 | - | |
| 351 | + | |
| 352 | 352 | /** |
| 353 | 353 | * Check if Zend Bridge is functional |
| 354 | 354 | * |
| ... | ... | @@ -362,33 +362,9 @@ class luceneValidation extends serviceValidation { |
| 362 | 362 | return true; |
| 363 | 363 | } else { |
| 364 | 364 | return false; |
| 365 | - } | |
| 366 | - } | |
| 367 | - | |
| 368 | - public function useZendJava() { | |
| 369 | - if($this->util->installEnvironment() == 'Zend') { | |
| 370 | - if(WINDOWS_OS) { // For Zend Installation only | |
| 371 | - $sysdir = explode(DS, SYSTEM_DIR); | |
| 372 | - array_pop($sysdir); | |
| 373 | - array_pop($sysdir); | |
| 374 | - $zendsys = ''; | |
| 375 | - foreach ($sysdir as $k=>$v) { | |
| 376 | - $zendsys .= $v.DS; | |
| 377 | - } | |
| 378 | - $java = $zendsys."jre".DS."bin".DS."java.exe"; | |
| 379 | - if(file_exists($java)) | |
| 380 | - return $java; | |
| 381 | - } else { | |
| 382 | - $java = "/usr/bin/java"; | |
| 383 | - if(file_exists($java)) { | |
| 384 | - return $java; | |
| 385 | - } | |
| 386 | - } | |
| 387 | - } | |
| 388 | - | |
| 389 | - return false; | |
| 365 | + } | |
| 390 | 366 | } |
| 391 | - | |
| 367 | + | |
| 392 | 368 | /** |
| 393 | 369 | * Attempts to use user input and configure java settings |
| 394 | 370 | * |
| ... | ... | @@ -405,13 +381,13 @@ class luceneValidation extends serviceValidation { |
| 405 | 381 | } |
| 406 | 382 | $javaExecutable = $this->java; |
| 407 | 383 | } |
| 408 | - if(WINDOWS_OS) { | |
| 384 | + if(WINDOWS_OS) { | |
| 409 | 385 | $cmd = "\"$javaExecutable\" -cp \"".SYS_DIR.";\" javaVersion \"".$this->outputDir."outJV\""." \"".$this->outputDir."outJVHome\""; |
| 410 | 386 | $func = OS."ReadJVFromFile"; |
| 411 | 387 | if($this->$func($cmd)) { |
| 412 | 388 | return true; |
| 413 | 389 | } else { |
| 414 | - $this->java = $this->useZendJava(); // Java not installed | |
| 390 | + $this->java = $this->util->useZendJava(); // Java not installed | |
| 415 | 391 | $javaExecutable = $this->java; |
| 416 | 392 | $cmd = "\"$javaExecutable\" -cp \"".SYS_DIR.";\" javaVersion \"".$this->outputDir."outJV\""." \"".$this->outputDir."outJVHome\""; |
| 417 | 393 | if($this->$func($cmd)) { |
| ... | ... | @@ -422,7 +398,7 @@ class luceneValidation extends serviceValidation { |
| 422 | 398 | $cmd = "\"$javaExecutable\" -version > ".$this->outputDir."outJV 2>&1 echo $!"; |
| 423 | 399 | $func = OS."ReadJVFromFile"; |
| 424 | 400 | if($this->$func($cmd)) { |
| 425 | - return true; | |
| 401 | + return true; | |
| 426 | 402 | } else { |
| 427 | 403 | // TODO: Not sure |
| 428 | 404 | } |
| ... | ... | @@ -433,7 +409,7 @@ class luceneValidation extends serviceValidation { |
| 433 | 409 | $this->error[] = "Requires Java 1.5+ to be installed"; |
| 434 | 410 | return false; |
| 435 | 411 | } |
| 436 | - | |
| 412 | + | |
| 437 | 413 | function windowsReadJVFromFile($cmd) { |
| 438 | 414 | $response = $this->util->pexec($cmd); |
| 439 | 415 | if(file_exists($this->outputDir.'outJV')) { |
| ... | ... | @@ -443,14 +419,14 @@ class luceneValidation extends serviceValidation { |
| 443 | 419 | $this->javaVersionInCorrect(); |
| 444 | 420 | $this->javaCheck = 'cross'; |
| 445 | 421 | $this->error[] = "Requires Java 1.5+ to be installed"; |
| 446 | - | |
| 422 | + | |
| 447 | 423 | return false; |
| 448 | 424 | } else { |
| 449 | 425 | $this->javaVersionCorrect(); |
| 450 | 426 | $this->javaInstalled(); |
| 451 | 427 | $this->javaCheck = 'tick'; |
| 452 | 428 | $this->providedJava = true; |
| 453 | - | |
| 429 | + | |
| 454 | 430 | return true; |
| 455 | 431 | } |
| 456 | 432 | } else { |
| ... | ... | @@ -461,12 +437,12 @@ class luceneValidation extends serviceValidation { |
| 461 | 437 | $this->javaExeError = true; |
| 462 | 438 | $this->error[] = "Requires Java 1.5+ to be installed"; |
| 463 | 439 | } |
| 464 | - | |
| 440 | + | |
| 465 | 441 | return false; |
| 466 | 442 | } |
| 467 | 443 | } |
| 468 | 444 | } |
| 469 | - | |
| 445 | + | |
| 470 | 446 | function unixReadJVFromFile($cmd) { |
| 471 | 447 | $response = $this->util->pexec($cmd); |
| 472 | 448 | if(file_exists($this->outputDir.'outJV')) { |
| ... | ... | @@ -477,14 +453,14 @@ class luceneValidation extends serviceValidation { |
| 477 | 453 | $this->javaVersionInCorrect(); |
| 478 | 454 | $this->javaCheck = 'cross'; |
| 479 | 455 | $this->error[] = "Requires Java 1.5+ to be installed"; |
| 480 | - | |
| 456 | + | |
| 481 | 457 | return false; |
| 482 | 458 | } else { |
| 483 | 459 | $this->javaVersionCorrect(); |
| 484 | 460 | $this->javaInstalled(); |
| 485 | 461 | $this->javaCheck = 'tick'; |
| 486 | 462 | $this->providedJava = true; |
| 487 | - | |
| 463 | + | |
| 488 | 464 | return true; |
| 489 | 465 | } |
| 490 | 466 | } else { |
| ... | ... | @@ -495,12 +471,12 @@ class luceneValidation extends serviceValidation { |
| 495 | 471 | $this->javaExeError = true; |
| 496 | 472 | $this->error[] = "Requires Java 1.5+ to be installed"; |
| 497 | 473 | } |
| 498 | - | |
| 474 | + | |
| 499 | 475 | return false; |
| 500 | 476 | } |
| 501 | 477 | } |
| 502 | 478 | } |
| 503 | - | |
| 479 | + | |
| 504 | 480 | /** |
| 505 | 481 | * Set all silent mode varibles |
| 506 | 482 | * | ... | ... |
webservice/clienttools/ajaxhandler.php
| 1 | 1 | <?php |
| 2 | 2 | class ajaxHandler{ |
| 3 | + protected $rawRequestObject=NULL; | |
| 4 | + protected $digestToken=NULL; | |
| 5 | + protected $remoteIp=NULL; | |
| 6 | + | |
| 3 | 7 | public $ret=NULL; |
| 4 | 8 | public $req=NULL; |
| 5 | 9 | public $version=NULL; |
| ... | ... | @@ -9,60 +13,310 @@ class ajaxHandler{ |
| 9 | 13 | public $authenticator=NULL; |
| 10 | 14 | public $noAuthRequireList=array(); |
| 11 | 15 | public $standardServices=array('system'); |
| 16 | + | |
| 17 | + protected $errors=array(); | |
| 18 | + | |
| 19 | + /** | |
| 20 | + * 1.Parse JSON | |
| 21 | + * 2.Check Request Validity (hash/ip/expiration token) | |
| 22 | + * 3.Preliminary Session Check | |
| 23 | + * if no session or invalid session | |
| 24 | + * 3.1 Use credentials to create a new session. | |
| 25 | + * 3.3 Update Authentication segment with new sessionid | |
| 26 | + * 4.Authentication Check | |
| 27 | + * 5.Service Dispatch | |
| 28 | + */ | |
| 29 | + | |
| 30 | + public function __construct(&$response=NULL,&$kt,$noAuthRequests=''){ | |
| 31 | + | |
| 32 | + //========================= Preparations | |
| 33 | + // set the response object | |
| 34 | + if(get_class($response)=='jsonResponseObject'){ | |
| 35 | + $this->ret=&$response; | |
| 36 | + }else{ | |
| 37 | + $this->ret=new jsonResponseObject(); | |
| 38 | + } | |
| 39 | + $this->log("[__construct]ENTERING PREPARATIONS"); | |
| 40 | + | |
| 41 | + $this->remoteIp = (getenv(HTTP_X_FORWARDED_FOR)) ? getenv(HTTP_X_FORWARDED_FOR) : getenv(REMOTE_ADDR); | |
| 42 | + $this->log("[__construct]Remote IP determined as: {$this->remoteIp}"); | |
| 12 | 43 | |
| 13 | - public function __construct(&$ret=NULL,&$kt,$noAuthRequests=''){ | |
| 14 | - // set a local copy of the json request wrapper | |
| 15 | 44 | $noAuthRequests=is_array($noAuthRequests)?$noAuthRequests:split(',',(string)$noAuthRequests); |
| 16 | 45 | $this->registerNoAuthRequest($noAuthRequests); |
| 17 | - $this->req=new jsonWrapper(isset($_GET['request'])?$_GET['request']:(isset($_POST['request'])?$_POST['request']:'')); | |
| 46 | + | |
| 47 | + $this->rawRequestObject=isset($_GET['request'])?$_GET['request']:(isset($_POST['request'])?$_POST['request']:''); | |
| 48 | + $this->digestToken=isset($_GET['msgAuth'])?$_GET['msgAuth']:(isset($_POST['msgAuth'])?$_POST['msgAuth']:''); | |
| 49 | + $this->log("[__construct]DigestToken Found: {$this->digestToken}"); | |
| 50 | + | |
| 51 | + $this->ret->addDebug('Raw Request',$this->rawRequestObject); | |
| 52 | + $this->ret->addDebug('DigestToken Received',$this->digestToken); | |
| 53 | + $this->ret->addDebug('Remote IP',$this->remoteIp); | |
| 54 | + | |
| 55 | + | |
| 56 | + if($this->auth['session'])session_id($this->auth['session']); | |
| 57 | + $this->session=session_id(); | |
| 58 | + $this->log("[__construct]Session Restarted as: {$this->session}"); | |
| 59 | + // session_id('BLANK_SESSION'); | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + //========================= 1. Parse Json | |
| 64 | + $this->log("[__construct]ENTERING Parse Json"); | |
| 65 | + $this->req=new jsonWrapper($this->rawRequestObject); | |
| 18 | 66 | $this->auth=$this->structArray('user,pass,passhash,appType,session,token,version',$this->req->jsonArray['auth']); |
| 19 | 67 | $this->request=$this->structArray('service,function,parameters',$this->req->jsonArray['request']); |
| 20 | 68 | |
| 69 | + //Add additional parameters | |
| 21 | 70 | $add_params=array_merge($_GET,$_POST); |
| 22 | 71 | unset($add_params['request'],$add_params['datasource']); |
| 23 | 72 | $this->request['parameters']=array_merge($this->request['parameters'],$add_params); |
| 24 | - | |
| 25 | - | |
| 26 | - // set the response object | |
| 27 | - if(get_class($ret)=='jsonResponseObject'){ | |
| 28 | - $this->ret=&$ret; | |
| 29 | - }else{ | |
| 30 | - $this->ret=new jsonResponseObject(); | |
| 31 | - } | |
| 73 | + | |
| 74 | + if(!$this->auth['debug'])$this->ret->includeDebug=false; | |
| 75 | + | |
| 32 | 76 | $this->ret->setRequest($this->req->jsonArray); |
| 33 | 77 | $this->ret->setTitle($this->request['service'].'::'.$this->request['function']); |
| 34 | 78 | $this->ret->setDebug('Server Versions',$this->getServerVersions()); |
| 35 | - | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + //========================= 2. Test System Requirements | |
| 85 | + $this->log("[__construct]ENTERING Test System Requirements"); | |
| 36 | 86 | if(get_class($kt)=='KTAPI'){ |
| 37 | 87 | $this->kt=&$kt; |
| 38 | 88 | }else{ |
| 39 | 89 | $this->ret->addError('KnowledgeTree Object not Received in '.__CLASS__.' constructor. Quitting.'); |
| 40 | 90 | return $this->render(); |
| 41 | 91 | } |
| 92 | + | |
| 93 | + | |
| 94 | + //TODO: Get rid of this service | |
| 95 | + $this->loadService('auth'); | |
| 96 | + $this->authenticator=new auth($this,$this->ret,$this->kt,$this->request,$this->auth); | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
| 100 | + //========================= 3. Check Request Validity | |
| 101 | + $this->log("[__construct]ENTERING Check Request Validity"); | |
| 102 | + if(!$this->checkRequestValidity())return $this->render(); | |
| 103 | + if(!$this->checkTokenValidity())return $this->render(); | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
| 107 | + | |
| 108 | + //========================= 4. Preliminary Session Check | |
| 109 | + $this->log("[__construct]ENTERING Preliminary Session Check"); | |
| 110 | + if(!$this->checkSessionValidity()){ | |
| 111 | + $this->creatNewSession(); //(login) This may fail, be the user is still allowed to dispatch to the | |
| 112 | + } | |
| 113 | + | |
| 114 | + | |
| 115 | + | |
| 116 | + | |
| 117 | + | |
| 118 | + //========================= 5. Authentication Check | |
| 119 | + $this->log("[__construct]ENTERING Authentication Check"); | |
| 120 | + if(!$this->isStandardService() && !$this->isNoAuthRequiredRequest()){ | |
| 121 | + //Authentication is Required | |
| 122 | + $this->log("[__construct]Determined Authentication is required"); | |
| 123 | + if(!$this->checkCredentials()){ | |
| 124 | + throw new Exception('User Credentials Necessary for Requested Service'); | |
| 125 | + return $this->render(); | |
| 126 | + } | |
| 127 | + } | |
| 128 | + | |
| 129 | + | |
| 130 | + | |
| 131 | + | |
| 132 | + | |
| 133 | + | |
| 134 | + //========================= 6. Service Dispatch | |
| 135 | + $this->log("[__construct]ENTERING Service Dispatch"); | |
| 136 | + $this->dispatch(); | |
| 137 | + return $this->render(); | |
| 138 | + } | |
| 139 | + | |
| 140 | + | |
| 141 | + | |
| 142 | + | |
| 143 | + | |
| 144 | + | |
| 145 | + | |
| 146 | + | |
| 147 | + | |
| 148 | + | |
| 149 | + | |
| 150 | + | |
| 151 | + protected function checkRequestValidity(){ | |
| 152 | + $this->log("[checkRequestvalidity]Entering..."); | |
| 153 | + $securityHash=md5(md5($this->rawRequestObject).'_'.$this->auth['token'].'_'.$this->getUserPass()); | |
| 154 | + $digestToken=$this->digestToken; | |
| 155 | + $this->log("[checkRequestvalidity]comparing {$securityHash} with {$digestToken} as received"); | |
| 42 | 156 | |
| 43 | - // Prepare | |
| 44 | - if(!$this->isStandardService()){ | |
| 45 | - $this->loadService('auth'); | |
| 46 | - $this->authenticator=new auth($this,$this->ret,$this->kt,$this->request,$this->auth); | |
| 47 | - | |
| 157 | + $passed=$securityHash==$digestToken; | |
| 158 | + | |
| 159 | + $data=array( | |
| 160 | + 'Received Token' =>$digestToken, | |
| 161 | + 'Expected Token' =>$securityHash, | |
| 162 | + 'Passed' =>$passed, | |
| 163 | + '' | |
| 164 | + ); | |
| 165 | + $this->ret->addDebug('Message Digest Security',$data); | |
| 166 | + | |
| 167 | + if(!$passed){ | |
| 168 | + $this->log("[checkRequestvalidity]Failed Validity Test"); | |
| 169 | + throw new Exception('Message Integrity Was Compromised.'); | |
| 170 | + } | |
| 171 | + return $passed; | |
| 172 | + } | |
| 48 | 173 | |
| 49 | - //Make sure a token exists before continuing | |
| 50 | - if(!$this->verifyToken())return $this->render(); | |
| 51 | 174 | |
| 175 | + protected function checkSessionValidity(){ | |
| 176 | + $valid=$this->start_session(); | |
| 177 | + $this->auth['session']=session_id(); | |
| 178 | + $this->ret->setStatus('session_id',session_id()); | |
| 179 | + $this->ret->addDebug('Auth',array('Session Check'=>$valid)); | |
| 180 | +// echo $valid?'true':'false'.'<br /><br /><br /><br /><br /><br /><br />'; | |
| 181 | + return $valid; | |
| 182 | + } | |
| 52 | 183 | |
| 53 | - if(!$this->verifySession()){ | |
| 54 | - $this->doLogin(); | |
| 55 | - $isAuthRequired=$this->isNoAuthRequiredRequest(); | |
| 56 | - $isAuthenticated=$this->isAuthenticated(); | |
| 57 | - if(!$isAuthRequired && !$isAuthenticated)return $this->render(); | |
| 58 | - } | |
| 184 | + //TODO: Alter this to verify whether token was used before or whether it is new | |
| 185 | + protected function checkTokenValidity(){ | |
| 186 | + $token=$this->auth['token']; | |
| 187 | + $tokenList=$_SESSION['JAPI_TOKEN_STORE']?$_SESSION['JAPI_TOKEN_STORE']:array(); | |
| 188 | + $valid=!in_array($token,$tokenList); | |
| 189 | + if($valid){ | |
| 190 | + $tokenList[$token]=$token; | |
| 191 | + $_SESSION['JAPI_TOKEN_STORE']=$tokenList; | |
| 192 | + }else{ | |
| 193 | + $this->error('Invalid Token - Already Used'); | |
| 194 | + $this->log('Invalid Token - Already Used'); | |
| 59 | 195 | } |
| 60 | 196 | |
| 61 | - $this->dispatch(); | |
| 62 | - | |
| 63 | - return $this->render(); | |
| 197 | + return $valid; | |
| 198 | + } | |
| 199 | + | |
| 200 | + | |
| 201 | + protected function creatNewSession(){ | |
| 202 | + $this->ret->addDebug('Auth',array('Attempting to Create a New Session')); | |
| 203 | + if($this->checkCredentials()){ | |
| 204 | + $ssession=KTAPI_UserSession::_check_session($this->getUserObject(),$this->remoteIp,$this->auth['appType']); | |
| 205 | + $session=$ssession[0]; | |
| 206 | + $this->ret->addDebug('####################################Session Created : '.$session); | |
| 207 | + $this->auth['session']=session_id(); | |
| 208 | + $this->ret->setStatus('session_id',session_id()); | |
| 209 | + return true; | |
| 210 | + }else{ | |
| 211 | + return false; | |
| 212 | + } | |
| 213 | + } | |
| 214 | + | |
| 215 | + protected function start_session(){ | |
| 216 | + $app_type=$this->auth['appType']; | |
| 217 | + $session_id=$this->auth['session']; | |
| 218 | + $ip=$this->remoteIp; | |
| 219 | + | |
| 220 | + $session=$this->kt->get_session(); | |
| 221 | + | |
| 222 | + if(get_class($session)=='KTAPI_UserSession'){ | |
| 223 | + return true; | |
| 224 | + }else{ | |
| 225 | + $session = $this->kt->get_active_session($session_id, $ip, $app_type); | |
| 226 | + | |
| 227 | + if (PEAR::isError($session)){ | |
| 228 | + return false; | |
| 229 | + } | |
| 230 | + $this->auth['session']=session_id(); | |
| 231 | + $this->ret->setStatus('session_id',session_id()); | |
| 232 | + return true; | |
| 233 | + } | |
| 234 | + | |
| 235 | + | |
| 236 | + } | |
| 237 | + | |
| 238 | + | |
| 239 | + protected function getUserPass(){ | |
| 240 | + $l_pass=md5('@NO_AUTH_NEEDED@'); | |
| 241 | + $u=$this->getUserObject(); | |
| 242 | + if($u){ | |
| 243 | + $l_pass=$this->getUserObject()->getPassword(); | |
| 244 | + } | |
| 245 | + return $l_pass; | |
| 246 | + } | |
| 247 | + | |
| 248 | + protected function getUserObject(){ | |
| 249 | + $kt=$this->kt; | |
| 250 | + $user=$this->auth['user']; | |
| 251 | + $o_user=$kt->get_user_object_by_username($user); | |
| 252 | + | |
| 253 | + if(PEAR::isError($o_user)){ | |
| 254 | + if(!isset($this->errors['usernotfound']))$this->ret->addError('User '.$user.' not found'); | |
| 255 | + $this->errors['usernotfound']=true; | |
| 256 | + return false; | |
| 257 | + }else{ | |
| 258 | + $this->log("[getUserObject] Found User: ".$o_user->getName()); | |
| 259 | + } | |
| 260 | + return $o_user; | |
| 261 | + } | |
| 262 | + | |
| 263 | + protected function checkCredentials(){ | |
| 264 | + $user=$this->auth['user']; | |
| 265 | + $passHash=$this->auth['passhash']; | |
| 266 | + | |
| 267 | + $kt=$this->kt; | |
| 268 | + | |
| 269 | + $o_user=$kt->get_user_object_by_username($user); | |
| 270 | + | |
| 271 | + if(PEAR::isError($o_user)){ | |
| 272 | + if(!isset($this->errors['usernotfound']))$this->ret->addError('User '.$user.' not found'); | |
| 273 | + $this->errors['usernotfound']=true; | |
| 274 | + return false; | |
| 275 | + } | |
| 276 | + | |
| 277 | + try{ | |
| 278 | + $l_pass=$o_user->getPassword(); | |
| 279 | + $l_passHash=md5($l_pass.$this->auth['token']); | |
| 280 | + | |
| 281 | + $passed=$passHash==$l_passHash; | |
| 282 | + | |
| 283 | + $this->ret->setDebug('Auth',array( | |
| 284 | + 'User Real Password'=>$l_pass, | |
| 285 | + 'User Real Password Hash'=>$l_passHash, | |
| 286 | + 'Received Password Hash'=>$passHash, | |
| 287 | + 'passed'=>$passed | |
| 288 | + )); | |
| 289 | + | |
| 290 | + return $passed; | |
| 291 | + | |
| 292 | + }catch(Exception $e){ | |
| 293 | + throw new Exception('Unknown credentialCheck error encountered'); | |
| 294 | + return false; | |
| 295 | + } | |
| 296 | + | |
| 297 | + return ture; | |
| 298 | + } | |
| 299 | + | |
| 300 | + | |
| 301 | + | |
| 302 | + protected function log($str=''){ | |
| 303 | + $this->ret->log($str); | |
| 304 | + } | |
| 305 | + | |
| 306 | + | |
| 307 | + protected function error($errMsg=NULL){ | |
| 308 | + $this->ret->addError($errMsg); | |
| 64 | 309 | } |
| 65 | 310 | |
| 311 | + | |
| 312 | + | |
| 313 | + | |
| 314 | + | |
| 315 | + | |
| 316 | + | |
| 317 | + | |
| 318 | + | |
| 319 | + | |
| 66 | 320 | private function structArray($structString=NULL,$arr=NULL){ |
| 67 | 321 | $struct=array_flip(split(',',(string)$structString)); |
| 68 | 322 | return array_merge($struct,is_array($arr)?$arr:array()); |
| ... | ... | @@ -91,7 +345,17 @@ class ajaxHandler{ |
| 91 | 345 | } |
| 92 | 346 | |
| 93 | 347 | public function isStandardService(){ |
| 94 | - return in_array($this->request['service'],$this->standardServices); | |
| 348 | + $isStandardService=in_array($this->request['service'],$this->standardServices); | |
| 349 | + | |
| 350 | + $debug=array( | |
| 351 | + 'requested service' =>$this->request['service'], | |
| 352 | + 'standard services' =>$this->standardServices, | |
| 353 | + 'isStandardService' =>$isStandardService | |
| 354 | + ); | |
| 355 | + | |
| 356 | + $this->ret->addDebug('ajaxhandler::isStandardService',$debug); | |
| 357 | + | |
| 358 | + return $isStandardService; | |
| 95 | 359 | } |
| 96 | 360 | |
| 97 | 361 | |
| ... | ... | @@ -188,7 +452,17 @@ class ajaxHandler{ |
| 188 | 452 | public function isNoAuthRequiredRequest(){ |
| 189 | 453 | $req=$this->request; |
| 190 | 454 | $reqString=strtolower("{$req['service']}.{$req['function']}"); |
| 191 | - return in_array($reqString,$this->noAuthRequireList); | |
| 455 | + $requiresAuth=in_array($reqString,$this->noAuthRequireList); | |
| 456 | + | |
| 457 | + $debug=array( | |
| 458 | + 'requested service method' =>$reqString, | |
| 459 | + 'no auth required list' =>$this->noAuthRequireList, | |
| 460 | + 'requires auth' =>$requiresAuth | |
| 461 | + ); | |
| 462 | + | |
| 463 | + $this->ret->addDebug('ajaxhandler::isNoAuthRequiredRequest',$debug); | |
| 464 | + | |
| 465 | + return $requiresAuth; | |
| 192 | 466 | } |
| 193 | 467 | |
| 194 | 468 | } | ... | ... |
webservice/clienttools/comms.php
webservice/clienttools/jsonWrapper.php
| ... | ... | @@ -9,6 +9,7 @@ class jsonResponseObject{ |
| 9 | 9 | protected $errors=array(); |
| 10 | 10 | protected $status=array('session_id'=>'','random_token'=>''); |
| 11 | 11 | protected $data=array(); |
| 12 | + protected $log=array(); | |
| 12 | 13 | protected $request=array(); |
| 13 | 14 | protected $debug=array(); |
| 14 | 15 | public $additional=array(); |
| ... | ... | @@ -28,7 +29,8 @@ class jsonResponseObject{ |
| 28 | 29 | ), |
| 29 | 30 | 'data' =>array(), |
| 30 | 31 | 'request' =>array(), |
| 31 | - 'debug' =>array() | |
| 32 | + 'debug' =>array(), | |
| 33 | + 'log' =>array() | |
| 32 | 34 | ); |
| 33 | 35 | |
| 34 | 36 | |
| ... | ... | @@ -49,9 +51,12 @@ class jsonResponseObject{ |
| 49 | 51 | } |
| 50 | 52 | |
| 51 | 53 | public function setDebug($varName=NULL,$value=NULL){ |
| 54 | + if(is_array($this->debug[$varName]) && is_array($value))$value=array_merge($this->debug[$varName],$value); | |
| 52 | 55 | $this->debug[$varName]=$value; |
| 53 | 56 | } |
| 54 | 57 | |
| 58 | + public function addDebug($varName=NULL,$value=NULL){$this->setDebug($varName,$value);} | |
| 59 | + | |
| 55 | 60 | public function setRequest($request=NULL){ |
| 56 | 61 | $this->request=$request; |
| 57 | 62 | } |
| ... | ... | @@ -61,6 +66,10 @@ class jsonResponseObject{ |
| 61 | 66 | $this->title=$title; |
| 62 | 67 | } |
| 63 | 68 | |
| 69 | + public function log($str){ | |
| 70 | + $this->log[]='['.date('h:i:s').'] '.$str; | |
| 71 | + } | |
| 72 | + | |
| 64 | 73 | public function getJson(){ |
| 65 | 74 | $response=array_merge(array( |
| 66 | 75 | 'requestName' =>$this->title, |
| ... | ... | @@ -72,6 +81,7 @@ class jsonResponseObject{ |
| 72 | 81 | 'data' =>$this->data, |
| 73 | 82 | 'request' =>$this->request, |
| 74 | 83 | 'debug' =>$this->debug, |
| 84 | + 'log' =>$this->log | |
| 75 | 85 | ),$this->additional); |
| 76 | 86 | if(!$this->includeDebug) unset($response['debug']); |
| 77 | 87 | |
| ... | ... | @@ -91,7 +101,6 @@ class jsonWrapper{ |
| 91 | 101 | public $jsonArray=array(); |
| 92 | 102 | |
| 93 | 103 | public function __construct($content=NULL){ |
| 94 | -// $content=stripslashes($content); | |
| 95 | 104 | $this->raw=$content; |
| 96 | 105 | $content=@json_decode($content,true); |
| 97 | 106 | if(!is_array($content))throw new jsonContentException('Invalid JSON input',jsonContentException::INPUT_ERROR); | ... | ... |