PageRenderTime 49ms CodeModel.GetById 24ms RepoModel.GetById 0ms app.codeStats 0ms

/ajax.php

https://bitbucket.org/Mab879/johtaja-schools
PHP | 261 lines | 219 code | 10 blank | 32 comment | 25 complexity | 7f2bc43e0a727b314f48afbcc32b92d4 MD5 | raw file
Possible License(s): GPL-2.0
  1. <?php
  2. #**************************************************************************
  3. # openSIS is a free student information system for public and non-public
  4. # schools from Open Solutions for Education, Inc. web: www.os4ed.com
  5. #
  6. # openSIS is web-based, open source, and comes packed with features that
  7. # include student demographic info, scheduling, grade book, attendance,
  8. # report cards, eligibility, transcripts, parent portal,
  9. # student portal and more.
  10. #
  11. # Visit the openSIS web site at http://www.opensis.com to learn more.
  12. # If you have question regarding this system or the license, please send
  13. # an email to info@os4ed.com.
  14. #
  15. # This program is released under the terms of the GNU General Public License as
  16. # published by the Free Software Foundation, version 2 of the License.
  17. # See license.txt.
  18. #
  19. # This program is distributed in the hope that it will be useful,
  20. # but WITHOUT ANY WARRANTY; without even the implied warranty of
  21. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  22. # GNU General Public License for more details.
  23. #
  24. # You should have received a copy of the GNU General Public License
  25. # along with this program. If not, see <http://www.gnu.org/licenses/>.
  26. #
  27. #***************************************************************************************
  28. //error_reporting(1);
  29. //include('Redirect_root.php');
  30. error_reporting(E_ERROR);
  31. $isajax="ajax";
  32. $start_time = time();
  33. include 'Warehouse.php';
  34. array_rwalk($_REQUEST,'strip_tags');
  35. if(UserStudentID() && User('PROFILE')!='parent' && User('PROFILE')!='student')
  36. {
  37. $RET = DBGet(DBQuery("SELECT FIRST_NAME,LAST_NAME,MIDDLE_NAME,NAME_SUFFIX FROM STUDENTS WHERE STUDENT_ID='".UserStudentID()."'"));
  38. $count_student_RET=DBGet(DBQuery("SELECT COUNT(*) AS NUM FROM STUDENTS"));
  39. if($count_student_RET[1]['NUM']>1){
  40. DrawHeaderHome( 'Selected Student: '.$RET[1]['FIRST_NAME'].'&nbsp;'.($RET[1]['MIDDLE_NAME']?$RET[1]['MIDDLE_NAME'].' ':'').$RET[1]['LAST_NAME'].'&nbsp;'.$RET[1]['NAME_SUFFIX'].' (<A HREF=Side.php?student_id=new&modcat='.$_REQUEST['modcat'].'><font color=red>Remove</font></A>) | <A HREF=Modules.php?modname=Students/Student.php&search_modfunc=list&next_modname=Students%2FStudent.php&ajax=true&bottom_back=true&return_session=true target=body>Back to Student List</A>');
  41. }else if($count_student_RET[1]['NUM']==1){
  42. DrawHeaderHome( 'Selected Student: '.$RET[1]['FIRST_NAME'].'&nbsp;'.($RET[1]['MIDDLE_NAME']?$RET[1]['MIDDLE_NAME'].' ':'').$RET[1]['LAST_NAME'].'&nbsp;'.$RET[1]['NAME_SUFFIX'].' (<A HREF=Side.php?student_id=new&modcat='.$_REQUEST['modcat'].'><font color=red>Remove</font></A>) ');
  43. }
  44. }
  45. if(UserStaffID() && User('PROFILE')=='admin')
  46. {
  47. //if(UserStudentID())
  48. // echo '<IMG SRC=assets/pixel_trans.gif height=2>';
  49. $RET = DBGet(DBQuery("SELECT FIRST_NAME,LAST_NAME FROM STAFF WHERE STAFF_ID='".UserStaffID()."'"));
  50. DrawHeaderHome( 'Selected User: '.$RET[1]['FIRST_NAME'].'&nbsp;'.$RET[1]['LAST_NAME'].' (<A HREF=Side.php?staff_id=new&modcat='.$_REQUEST['modcat'].'><font color=red>Remove</font></A>)');
  51. }
  52. echo "<center><div id='divErr'></div></center>";
  53. if(!isset($_REQUEST['_openSIS_PDF']))
  54. {
  55. Warehouse('header');
  56. //if(strpos($_REQUEST['modname'],'misc/')===false && $_REQUEST['modname']!='Students/Student.php' && $_REQUEST['modname']!='School_Setup/Calendar.php' && $_REQUEST['modname']!='Scheduling/Schedule.php' && $_REQUEST['modname']!='Attendance/Percent.php' && $_REQUEST['modname']!='Attendance/Percent.php?list_by_day=true' && $_REQUEST['modname']!='Scheduling/MassRequests.php' && $_REQUEST['modname']!='Scheduling/MassSchedule.php' && $_REQUEST['modname']!='Student_Billing/Fees.php')
  57. if(strpos($_REQUEST['modname'],'misc/')===false)
  58. echo '<script language="JavaScript">if(window == top && (!window.opener || window.opener.location.href.substring(0,(window.opener.location.href.indexOf("&")!=-1?window.opener.location.href.indexOf("&"):window.opener.location.href.replace("#","").length))!=window.location.href.substring(0,(window.location.href.indexOf("&")!=-1?window.location.href.indexOf("&"):window.location.href.replace("#","").length)))) window.location.href = "index.php";</script>';
  59. echo "<body marginwidth=0 leftmargin=0 border=0 onload='doOnload();' background=assets/bg.gif>";
  60. #echo '<div id="Migoicons" style="visibility:hidden;position:absolute;z-index:1000;top:-100"></DIV><SCRIPT language="JavaScript1.2" type="text/javascript">var TipId="Migoicons";var FiltersEnabled = 1;mig_clay();';
  61. echo '<div id="Migoicons" style="visibility:hidden;position:absolute;z-index:1000;top:-100"></div>';
  62. echo "<table width=100% height=100% border=0 cellpadding=0 align=center><tr><td valign=top align=center>";
  63. }
  64. if($_REQUEST['modname'])
  65. {
  66. if($_REQUEST['_openSIS_PDF']=='true')
  67. ob_start();
  68. if(strpos($_REQUEST['modname'],'?')!==false)
  69. {
  70. $vars = substr($_REQUEST['modname'],(strpos($_REQUEST['modname'],'?')+1));
  71. $modname = substr($_REQUEST['modname'],0,strpos($_REQUEST['modname'],'?'));
  72. $vars = explode('?',$vars);
  73. foreach($vars as $code)
  74. {
  75. $code = decode_unicode_url("\$_REQUEST['".str_replace('=',"']='",$code)."';");
  76. eval($code);
  77. }
  78. }
  79. else
  80. $modname = $_REQUEST['modname'];
  81. if($_REQUEST['LO_save']!='1' && !isset($_REQUEST['_openSIS_PDF']) && (strpos($modname,'misc/')===false || $modname=='misc/Registration.php' || $modname=='misc/Export.php' || $modname=='misc/Portal.php'))
  82. $_SESSION['_REQUEST_vars'] = $_REQUEST;
  83. $allowed = false;
  84. include 'Menu.php';
  85. foreach($_openSIS['Menu'] as $modcat=>$programs)
  86. {
  87. if($_REQUEST['modname']==$modcat.'/Search.php')
  88. {
  89. $allowed = true;
  90. break;
  91. }
  92. foreach($programs as $program=>$title)
  93. {
  94. if($_REQUEST['modname']==$program)
  95. {
  96. $allowed = true;
  97. break;
  98. }
  99. }
  100. }
  101. if(substr($_REQUEST['modname'],0,5)=='misc/')
  102. $allowed = true;
  103. if($allowed || $_SESSION['take_mssn_attn'])
  104. {
  105. if(Preferences('SEARCH')!='Y')
  106. $_REQUEST['search_modfunc'] = 'list';
  107. include('modules/'.$modname);
  108. }
  109. else
  110. {
  111. if(User('USERNAME'))
  112. {
  113. echo "You're not allowed to use this program! This attempted violation has been logged and your IP address was captured.";
  114. DBQuery("INSERT INTO HACKING_LOG (HOST_NAME,IP_ADDRESS,LOGIN_DATE,VERSION,PHP_SELF,DOCUMENT_ROOT,SCRIPT_NAME,MODNAME,USERNAME) values('$_SERVER[SERVER_NAME]','$_SERVER[REMOTE_ADDR]','".date('Y-m-d')."','$openSISVersion','$_SERVER[PHP_SELF]','$_SERVER[DOCUMENT_ROOT]','$_SERVER[SCRIPT_NAME]','$_REQUEST[modname]','".User('USERNAME')."')");
  115. Warehouse('footer');
  116. if($openSISNotifyAddress)
  117. mail($openSISNotifyAddress,'HACKING ATTEMPT',"INSERT INTO HACKING_LOG (HOST_NAME,IP_ADDRESS,LOGIN_DATE,VERSION,PHP_SELF,DOCUMENT_ROOT,SCRIPT_NAME,MODNAME,USERNAME) values('$_SERVER[SERVER_NAME]','$_SERVER[REMOTE_ADDR]','".date('Y-m-d')."','$openSISVersion','$_SERVER[PHP_SELF]','$_SERVER[DOCUMENT_ROOT]','$_SERVER[SCRIPT_NAME]','$_REQUEST[modname]','".User('USERNAME')."')");
  118. }
  119. exit;
  120. }
  121. if($_SESSION['unset_student'])
  122. {
  123. unset($_SESSION['unset_student']);
  124. unset($_SESSION['staff_id']);
  125. }
  126. }
  127. echo "<div id='cal' class='divcal'> </div>";
  128. if(!isset($_REQUEST['_openSIS_PDF']))
  129. {
  130. echo '</td></tr></table>';
  131. for($i=1;$i<=$_openSIS['PrepareDate'];$i++)
  132. {
  133. echo '<script type="text/javascript">
  134. Calendar.setup({
  135. monthField : "monthSelect'.$i.'",
  136. dayField : "daySelect'.$i.'",
  137. yearField : "yearSelect'.$i.'",
  138. ifFormat : "%d-%b-%y",
  139. button : "trigger'.$i.'",
  140. align : "Tl",
  141. singleClick : true
  142. });
  143. </script>';
  144. }
  145. echo '</body>';
  146. echo '</html>';
  147. }
  148. function decode_unicode_url($str)
  149. {
  150. $res = '';
  151. $i = 0;
  152. $max = strlen($str) - 6;
  153. while ($i <= $max)
  154. {
  155. $character = $str[$i];
  156. if ($character == '%' && $str[$i + 1] == 'u')
  157. {
  158. $value = hexdec(substr($str, $i + 2, 4));
  159. $i += 6;
  160. if ($value < 0x0080) // 1 byte: 0xxxxxxx
  161. $character = chr($value);
  162. else if ($value < 0x0800) // 2 bytes: 110xxxxx 10xxxxxx
  163. $character =
  164. chr((($value & 0x07c0) >> 6) | 0xc0)
  165. . chr(($value & 0x3f) | 0x80);
  166. else // 3 bytes: 1110xxxx 10xxxxxx 10xxxxxx
  167. $character =
  168. chr((($value & 0xf000) >> 12) | 0xe0)
  169. . chr((($value & 0x0fc0) >> 6) | 0x80)
  170. . chr(($value & 0x3f) | 0x80);
  171. }
  172. else
  173. $i++;
  174. $res .= $character;
  175. }
  176. return $res . substr($str, $i);
  177. }
  178. function code2utf($num){
  179. if($num<128)
  180. return chr($num);
  181. if($num<1024)
  182. return chr(($num>>6)+192).chr(($num&63)+128);
  183. if($num<32768)
  184. return chr(($num>>12)+224).chr((($num>>6)&63)+128)
  185. .chr(($num&63)+128);
  186. if($num<2097152)
  187. return chr(($num>>18)+240).chr((($num>>12)&63)+128)
  188. .chr((($num>>6)&63)+128).chr(($num&63)+128);
  189. return '';
  190. }
  191. function unescape($strIn, $iconv_to = 'UTF-8') {
  192. $strOut = '';
  193. $iPos = 0;
  194. $len = strlen ($strIn);
  195. while ($iPos < $len) {
  196. $charAt = substr ($strIn, $iPos, 1);
  197. if ($charAt == '%') {
  198. $iPos++;
  199. $charAt = substr ($strIn, $iPos, 1);
  200. if ($charAt == 'u') {
  201. // Unicode character
  202. $iPos++;
  203. $unicodeHexVal = substr ($strIn, $iPos, 4);
  204. $unicode = hexdec ($unicodeHexVal);
  205. $strOut .= code2utf($unicode);
  206. $iPos += 4;
  207. }
  208. else {
  209. // Escaped ascii character
  210. $hexVal = substr ($strIn, $iPos, 2);
  211. if (hexdec($hexVal) > 127) {
  212. // Convert to Unicode
  213. $strOut .= code2utf(hexdec ($hexVal));
  214. }
  215. else {
  216. $strOut .= chr (hexdec ($hexVal));
  217. }
  218. $iPos += 2;
  219. }
  220. }
  221. else {
  222. $strOut .= $charAt;
  223. $iPos++;
  224. }
  225. }
  226. if ($iconv_to != "UTF-8") {
  227. $strOut = iconv("UTF-8", $iconv_to, $strOut);
  228. }
  229. return $strOut;
  230. }
  231. ?>