• Main Page
  • Related Pages
  • Namespaces
  • Data Structures
  • Files
  • Examples
  • File List
  • Globals

INSTALL/settingsform.php

Go to the documentation of this file.
00001 <?php
00002 if(!defined('__PRAGYAN_CMS'))
00003 { 
00004         header($_SERVER['SERVER_PROTOCOL'].' 403 Forbidden');
00005         echo "<h1>403 Forbidden<h1><h4>You are not authorized to access the page.</h4>";
00006         echo '<hr/>'.$_SERVER['SERVER_SIGNATURE'];
00007         exit(1);
00008 }
00009 /*
00010  * Created on Sep 28, 2008
00011  *
00012  * To change the template for this generated file go to
00013  * Window - Preferences - PHPeclipse - PHP - Code Templates
00014  */
00015 
00016 
00017 $settingsForm = <<<SETTINGSFORM
00018 <script type="text/javascript" language="javascript">
00019         function toggleImap(b) {
00020                 document.getElementById('txtIMAPServerAddress').disabled =
00021                 document.getElementById('txtIMAPPort').disabled =
00022                 document.getElementById('txtIMAPUserDomain').disabled = b;
00023         }
00024 
00025         function toggleLdap(b) {
00026                 document.getElementById('txtLDAPServerAddress').disabled =
00027                 document.getElementById('txtLDAPSearchGroup').disabled = 
00028 
00029                   document.getElementById('txtLDAPUserDomain').disabled = b;
00030         }
00031 
00032         function toggleAds(b) {
00033                 document.getElementById('txtADSServerAddress').disabled =
00034                 document.getElementById('txtADSNetworkName').disabled =
00035                 document.getElementById('txtADSUserDomain').disabled = b;
00036         }
00037         
00038         function trim(str)
00039         {
00040           return str.replace(/^\s+|\s+$/g, '');
00041         }               
00042         function validate_domain(field,num)
00043         {
00044         
00045                 var val = field.value;
00046                 var check = /^(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})$/; //IP Address
00047                 var check2 = /^[A-Za-z\.\s]*$/; //Domain Name
00048                 if(val.length != 0)
00049                 {
00050                         if(!check.test(val) && !check2.test(val))
00051                         {
00052                                 if(num==0)
00053                                 {
00054                         
00055                                 alert("Enter a valid server address !");
00056                                 }
00057                         return 0;
00058                         }
00059                         
00060                         else return 1;
00061                 }
00062         }
00063         
00064         function validate_name(field,num)
00065         {
00066                 var val = trim(field.value);
00067                 var check = /^[A-Za-z\.\s]*$/;
00068         
00069                 if(val.length != 0)
00070                 {       
00071                         if(!check.test(val))
00072                         {
00073                                 if(num==0)
00074                                 {
00075                                 alert("Enter a valid name !");
00076                                 
00077                         }
00078                         return 0;
00079                         }
00080                         
00081                         else return 1;
00082                 }
00083         }
00084 
00085         function validate_num(field,num)
00086         {
00087                 error=0;
00088                 var val = trim(field.value);
00089                 var check = /^\d*$/;
00090         
00091                 if(val.length != 0)
00092                 {       
00093                         if(!check.test(val))
00094                         {
00095                                 if(num==0)
00096                                 {
00097                         alert("Enter a valid numeric value");
00098                 
00099                         }
00100                         return 0;
00101                         }
00102                         
00103                         else return 1;
00104                 }
00105         }
00106 
00107         function validate_username(field,num)
00108         {
00109                 
00110                 var val = trim(field.value);
00111                 var a = val.indexOf(" ")
00112                 var check = /^[A-Za-z\d]*$/;
00113         
00114                 if(val.length != 0)
00115                 {
00116                         if(a != -1)
00117                         {
00118                                 if(num==0)
00119                                 {
00120                                         alert("Username fields shold not contain blank space(s) inbetween characters .!");
00121                                 }
00122                                 return 0;
00123                         }
00124         
00125                         else if(!check.test(val))
00126                         {
00127                                 if(num==0)
00128                                 {
00129                                 alert("Entry not valid ! The Username should contain only characters and numbers .");
00130                                 
00131                         }
00132                                 return 0;
00133                         }
00134                         
00135                         else return 1;
00136                 }
00137         }
00138 
00139         function validate_email(field,num)
00140         {
00141         
00142                 var val = trim(field.value);
00143                 var check = /^[A-Za-z0-9][a-z0-9._-]+(\.[a-z0-9_\+-]+)*@[a-z0-9-]+(\.[a-z0-9-]+)*\.([a-z]{2,4})$/;
00144         
00145                 if(val.length != 0)
00146                 {
00147                         if(!check.test(val))
00148                         {
00149                                 if(num==0)
00150                                 {
00151                                         alert("Email Id not valid ! Check for the following : 1.Start with Alphabets or Numbers , 2.Special Characters allowed : '.' , '_' , '-' , 3.Special characters should not occur in succession");
00152                                 }
00153                         return 0;
00154                         }
00155                         
00156                         else return 1;
00157                 }
00158         }
00159         
00160         function validate_port(field,num)
00161         {
00162                 var val = trim(field.value);
00163                 var check = /^\d{1,5}$/;
00164         
00165                 if(val.length != 0)
00166                 {       
00167                         if(!check.test(val))
00168                         {
00169                                 if(num==0)
00170                                 {
00171                         alert("Enter a valid Port number");
00172                                 }
00173                         return 0;
00174                         }
00175                         
00176                         else return 1;
00177 
00178                 }
00179         }
00180 
00181         function validate_form()
00182         {
00183                 var txtMySQLServerHost  = trim(document.SettingsForm.txtMySQLServer.value);
00184                 var txtMySQLUsername    = trim(document.SettingsForm.txtMySQLUsername.value);
00185                 var txtMySQLPassword    = trim(document.SettingsForm.txtMySQLPassword.value);
00186                 var txtMySQLDatabase    = trim(document.SettingsForm.txtMySQLDatabase.value);
00187 
00188                 var txtAdminUsername    = trim(document.SettingsForm.txtAdminUsername.value);
00189                 var txtAdminEmail       = trim(document.SettingsForm.txtAdminEmail.value);
00190                 var txtAdminFullname    = trim(document.SettingsForm.txtAdminFullname.value);
00191                 var txtAdminPassword    = trim(document.SettingsForm.txtAdminPassword.value);
00192                 var txtAdminPassword2   = trim(document.SettingsForm.txtAdminPassword2.value);
00193 
00194                 var txtCMSTitle         = trim(document.SettingsForm.txtCMSTitle.value);
00195                 var txtCMSMailId        = trim(document.SettingsForm.txtCMSMailId.value);
00196 
00197                 var txtUploadLimit      = trim(document.SettingsForm.txtUploadLimit.value);
00198                 var txtCookieTimeout    = trim(document.SettingsForm.txtCookieTimeout.value);
00199 
00200                 var txtIMAPServerAddress= trim(document.SettingsForm.txtIMAPServerAddress.value);
00201                 var txtIMAPPort         = trim(document.SettingsForm.txtIMAPPort.value);
00202                 var txtIMAPUserDomain   = trim(document.SettingsForm.txtIMAPUserDomain.value);
00203 
00204                 var txtLDAPServerAddress= trim(document.SettingsForm.txtLDAPServerAddress.value);
00205                 var txtLDAPSearchGroup  = trim(document.SettingsForm.txtLDAPSearchGroup.value);
00206                 var txtLDAPUserDomain   = trim(document.SettingsForm.txtLDAPUserDomain.value);
00207 
00208                 var txtADSServerAddress = trim(document.SettingsForm.txtADSServerAddress.value);
00209                 var txtADSNetworkName   = trim(document.SettingsForm.txtADSNetworkName.value);
00210                 var txtADSUserDomain    = trim(document.SettingsForm.txtADSUserDomain.value);
00211 
00212                 var empty = 0;
00213                 
00214                 if(document.SettingsForm.optEnableADSYes.checked == true){      
00215                 if(txtADSUserDomain.length == 0) empty++;
00216                 if(txtADSNetworkName.length == 0) empty++;
00217                 if(txtADSServerAddress.length == 0) empty++;
00218                 }
00219 
00220                 if(document.SettingsForm.optEnableLDAPYes.checked == true){     
00221                 if(txtLDAPUserDomain.length == 0) empty++;
00222                 if(txtLDAPSearchGroup.length == 0) empty++;
00223                 if(txtLDAPServerAddress.length == 0) empty++;
00224                 }
00225                 if(document.SettingsForm.optEnableIMAPYes.checked == true){     
00226                 if(txtIMAPUserDomain.length == 0) empty++;
00227                 if(txtIMAPPort.length == 0) empty++;
00228                 if(txtIMAPServerAddress.length == 0) empty++;
00229                 }
00230                 if(txtCookieTimeout.length == 0) empty++;
00231                 if(txtUploadLimit.length == 0) empty++;
00232 
00233                 if(txtCMSMailId.length == 0) empty++;
00234                 if(txtCMSTitle.length == 0) empty++;
00235 
00236                 if(txtAdminPassword2.length == 0) empty++;
00237                 if(txtAdminPassword.length == 0) empty++;
00238                 if(txtAdminFullname.length == 0) empty++;
00239                 if(txtAdminEmail.length == 0) empty++;
00240                 if(txtAdminUsername.length == 0) empty++;
00241 
00242                 
00243                 if(txtMySQLDatabase.length == 0) empty++;
00244                 if(txtMySQLPassword.length == 0) empty++;
00245                 if(txtMySQLUsername.length == 0) empty++;
00246                 if(txtMySQLServerHost.length == 0) empty++;
00247                 
00248                 var error=0;
00249                 var message="Correct the following before proceeding : ";
00250 
00251                         if(!validate_domain(document.getElementById('txtMySQLServerHost'),1))
00252                         {
00253                         message+="MySQL Server Host , ";
00254                         error++;
00255                         }if(!validate_username(document.getElementById('txtMySQLUsername'),1))
00256                         {
00257                         message+="Username , ";
00258                         error++;
00259                         }
00260                 if(!validate_username(document.getElementById('txtAdminUsername'),1))
00261                 {
00262                 message+="Administrator Username , ";
00263                 error++;
00264                 }
00265                 if(!validate_email(document.getElementById('txtAdminEmail'),1))
00266                 {
00267                 message+="Administrator Email , ";
00268                 error++;
00269                 }
00270                 if(!validate_name(document.getElementById('txtAdminFullname'),1))
00271                 {
00272                 message+="Administrator Full Name , ";
00273                 error++;
00274                 }
00275                 if(!validate_email(document.getElementById('txtCMSMailId'),1))
00276                 {
00277                 message+="Website Email Id , ";
00278                 error++;
00279                 }
00280                 if(!validate_num(document.getElementById('txtUploadLimit'),1))
00281                 {
00282                 message+="Upload Limit (bytes) , ";
00283                 error++;
00284                 }
00285                         
00286                         
00287                 if(document.SettingsForm.optEnableIMAPYes.checked == true && !validate_domain(document.getElementById('txtIMAPServerAddress'),1))
00288                 {
00289                 message+="IMAP Server Address , ";
00290                 error++;
00291                 }
00292                 if(document.SettingsForm.optEnableIMAPYes.checked == true && !validate_port(document.getElementById('txtIMAPPort'),1))
00293                 {
00294                 message+="IMAP Port , ";
00295                 error++;
00296                 }
00297                 if(document.SettingsForm.optEnableADSYes.checked == true && !validate_domain(document.getElementById('txtADSServerAddress'),1))
00298                         {
00299                         message+="ADS Server Address , ";
00300                         error++;
00301                         }
00302                         
00303                         if(!error)
00304                         {
00305                                 return true;
00306                         }
00307         
00308                         else if(empty) 
00309                         {
00310                                 alert("You have left "+empty+" required field(s) Empty !");
00311         
00312                         document.SettingsForm.txtMySQLUsername.focus();
00313         
00314                                 return (empty == 0);
00315                         }
00316                 
00317                         else
00318                          {
00319                         
00320                                 alert(message);         
00321                                 return false;
00322                          }
00323         }
00324         function checkForm()
00325         {
00326           if(!document.getElementById('optEnableOpenIDYes').checked && !document.getElementById('optEnableOpenIDNo').checked)
00327             {
00328               alert("Please select if you want to enable OpenID");
00329               return false;
00330             }
00331                 if(document.getElementById('txtAdminPassword').value != document.getElementById('txtAdminPassword2').value)
00332                 {
00333                         alert("Administrator Passwords do not match");
00334                         return false;
00335                 }
00336                 else if(document.getElementById('txtAdminPassword').value.length == 0)
00337                 {
00338                         alert("Administrator Password should not be left blank");
00339                         return false;
00340                 }
00341                 
00342                 return validate_form();
00343         }
00344 
00345 
00346 </script>
00347 
00348 <form name="SettingsForm" method="POST" action="">
00349 
00350 
00351 
00352 <fieldset name="DatabaseSettings">
00353         <legend>Database Settings</legend>
00354         <table border="0" width="580px">
00355                 <tr>
00356                         <td width="210px"><label for="txtMySQLServerHost">MySQL Server Host:</label></td>
00357                         <td><input type="text" name="txtMySQLServerHost" id="txtMySQLServerHost" value="localhost" onblur="validate_domain(this,0)" /></td>
00358                 </tr>
00359                 <tr>
00360                         <td width="210px"><label for="txtMySQLServerPort">MySQL Server Port:<br/>(Leave blank if not sure) </label></td>
00361                         <td><input type="text" name="txtMySQLServerPort" id="txtMySQLServerPort" value="" onblur="validate_port(this,0)" /></td>
00362                 </tr>
00363                 <tr>
00364                         <td><label for="txtMySQLUsername">Username:</label></td>
00365                         <td><input type="text" name="txtMySQLUsername" id="txtMySQLUsername" value="" autocomplete="off" onblur="validate_username(this,0)" /></td>
00366                 </tr>
00367                 <tr>
00368                         <td><label for="txtMySQLPassword">Password:</label></td>
00369                         <td><input type="password" name="txtMySQLPassword" id="txtMySQLPassword" autocomplete="off" value="" /></td>
00370                 </tr>
00371                 <tr>
00372                         <td><label for="txtMySQLDatabase">Database:</label></td>
00373                         <td><input type="text" name="txtMySQLDatabase" id="txtMySQLDatabase" autocomplete="off" value="" /></td>
00374                 </tr>
00375                 <tr>
00376                         <td><label for="txtMySQLTablePrefix">Table Prefix:</label></td>
00377                         <td><input type="text" name="txtMySQLTablePrefix" id="txtMySQLTablePrefix" value="pragyanV3_" /></td>
00378                 </tr>
00379         </table>
00380 </fieldset>
00381 
00382 <fieldset name="AdminUser">
00383         <legend>Administrator Details</legend>
00384         <table border="0" width="580px">
00385                 <tr>
00386                         <td width="210px"><label for="txtAdminUsername">Administrator Username:</label></td>
00387                         <td><input type="text" name="txtAdminUsername" id="txtAdminUsername" value="admin" onblur="validate_username(this,0)" /></td>
00388                 </tr>
00389                 <tr>
00390                         <td><label for="txtAdminEmail">Administrator Email:</label></td>
00391                         <td><input type="text" name="txtAdminEmail" id="txtAdminEmail" value="admin@localhost.com" autocomplete="off" onblur="validate_email(this,0)" /></td>
00392                 </tr>
00393                 <tr>
00394                         <td><label for="txtAdminFullname">Administrator Full Name:</label></td>
00395                         <td><input type="text" name="txtAdminFullname" id="txtAdminFullname" value="" autocomplete="off" onblur="validate_name(this,0)" /></td>
00396                 </tr>
00397                 <tr>
00398                         <td><label for="txtAdminPassword">Administrator Password:</label></td>
00399                         <td><input type="password" name="txtAdminPassword" id="txtAdminPassword" autocomplete="off" value="" /></td>
00400                 </tr>
00401                 <tr>
00402                         <td><label for="txtAdminPassword2">Administrator Password (Verify):</label></td>
00403                         <td><input type="password" name="txtAdminPassword2" id="txtAdminPassword2" autocomplete="off" value="" /></td>
00404                 </tr>
00405         </table>
00406 </fieldset>
00407 
00408 <fieldset name="CMSSettings">
00409         <legend>CMS Settings</legend>
00410 
00411         <table border="0" width="580px">
00412                 <tr>
00413                         <td width="210px"><label for="txtCMSTitle">Website Title:</label></td>
00414                         <td><input type="text" name="txtCMSTitle" id="txtCMSTitle" value="Pragyan CMS" /></td>
00415                 </tr>
00416                 <tr>
00417                         <td><label for="selTemplate">Template:</label></td>
00418                         <td>
00419                                 <select name="selTemplate" id="selTemplate">
00420                                         <option selected="selected" value="crystalx">Crystal X</option>
00421                                         <option value="blacksilver">Black Silver</option>
00422                                 </select>
00423                         </td>
00424                 </tr>
00425                 <tr>
00426                         <td><label for="optURLRewrite">Enable Pretty URLs (requires .htaccess and rewrite module enabled in webserver):</label></td>
00427                         <td>
00428                         <labe><input type="radio" name="optURLRewrite" id="optURLRewriteNo" value="No" checked="checked"/>No</label>
00429                         <label><input type="radio" name="optURLRewrite" id="optURLRewriteYes" value="Yes" />Yes</label>
00430                         </td>
00431                 </tr>
00432                 <tr>
00433                         <td>Activate user on registration?</td>
00434                         <td>
00435                                 <label><input type="radio" name="optDefaultUserActive" id="optDefaultUserActiveYes" value="Yes" checked="checked" />Yes</label>
00436                                 <label><input type="radio" name="optDefaultUserActive" id="optDefaultUserActiveNo" value="No" />No</label>
00437                         </td>
00438                 </tr>
00439                 <tr>
00440                         <td>Send mail on registration?</td>
00441                         <td>
00442                                 <label><input type="radio" name="optSendVerification" id="optSendVerificationYes" value="Yes" />Yes</label>
00443                                 <label><input type="radio" name="optSendVerification" id="optSendVerificationNo" value="No" checked="checked" />No</label>
00444                         </td>
00445                 </tr>
00446                 <tr>
00447                         <td><label for="txtCMSMailId">Website Email Id:</label></td>
00448                         <td><input type="text" name="txtCMSMailId" id="txtCMSMailId" value="no-reply@pragyan.org" onblur="validate_email(this,0)" /></td> 
00449                 </tr>
00450                 <tr>
00451                         <td><label for="txtUploadLimit">Upload Limit (bytes):</label></td>
00452                         <td><input type="text" name="txtUploadLimit" id="txtUploadLimit" value="50000000" onblur="validate_num(this,0)" /></td>
00453                 </tr>
00454                 
00455                 <tr>
00456                         <td><label for="txtCookieTimeout">Cookie Timeout (seconds):</label></td>
00457                         <td><input type="text" name="txtCookieTimeout" id="txtCookieTimeout" value="60 * 30" /></td>
00458                 </tr>
00459                 <tr>
00460                         <td><label for="selErrorReporting">Error Reporting Level:</label></td>
00461                         <td>
00462                                 <select name="selErrorReporting" id="selErrorReporting">
00463                                         <option value="0" selected="selected">None</option>
00464                                         <option value="1">Errors and Warnings</option>
00465                                         <option value="2">Errors, Warnings, Notices, Debugging Information</option>
00466                                         <option value="3">Everything except Notices</option>
00467                                         <option value="4">Everything</option>
00468                                 </select>
00469                         </td>
00470                 </tr>
00471         </table>
00472 </fieldset>
00473 
00474 <fieldset name="AuthenticationSettings">
00475         <legend>Authentication Settings</legend>
00476 
00477         <table border="0" width="580px">
00478                 <tr>
00479                         <td width="210px">Enable IMAP Login:</td>
00480                         <td>
00481                                 <label><input type="radio" name="optEnableIMAP" id="optEnableIMAPYes" value="Yes" onclick="toggleImap(false)"/>Yes</label>
00482                                 <label><input type="radio" name="optEnableIMAP" id="optEnableIMAPNo" value="No" onclick="toggleImap(true)" checked="checked" />No</label>
00483                         </td>
00484                 </tr>
00485                 <tr>
00486                         <td><label for="txtIMAPServerAddress">Server Address:</label></td>
00487                         <td><input type="text" id="txtIMAPServerAddress" name="txtIMAPServerAddress" value="10.0.0.2" onblur="validate_domain(this,0)" /></td>
00488                 </tr>
00489                 <tr>
00490                         <td><label for="txtIMAPPort">Port:</label></td>
00491                         <td><input type="text" id="txtIMAPPort" name="txtIMAPPort" value="143" onblur="validate_port(this,0)" /></td>
00492                 </tr>
00493                 <tr>
00494                         <td><label for="txtIMAPUserDoman">User Domain:</label></td>
00495                         <td><input type="text" id="txtIMAPUserDomain" name="txtIMAPUserDomain" value="nitt.edu" /></td>
00496                 </tr>
00497 
00498                 <tr>
00499                         <td>Enable LDAP Login:</td>
00500                         <td>
00501                                 <label><input type="radio" name="optEnableLDAP" id="optEnableLDAPYes" value="Yes" onclick="toggleLdap(false)"/>Yes</label>
00502                                 <label><input type="radio" name="optEnableLDAP" id="optEnableLDAPNo" value="No" onclick="toggleLdap(true)" checked="checked" />No</label>
00503                         </td>
00504                 </tr>
00505                 <tr>
00506                         <td><label for="txtLDAPServerAddress">Server Address:</label></td>
00507                         <td><input type="text" id="txtLDAPServerAddress" name="txtLDAPServerAddress" value="delta.nitt.edu" /></td>
00508                 </tr>
00509                 <tr>
00510                         <td><label for="txtLDAPSearchGroup">Search Group:</label></td>
00511                         <td><input type="text" id="txtLDAPSearchGroup" name="txtLDAPSearchGroup" value="ou=Webteam,dc=delta,dc=nitt.edu" /></td>
00512                 </tr>
00513                 <tr>
00514                         <td><label for="txtLDAPUserDomain">User Domain:</label></td>
00515                         <td><input type="text" id="txtLDAPUserDomain" name="txtLDAPUserDomain" value="delta.nitt.edu" /></td>
00516                 </tr>
00517 
00518                 <tr>
00519                         <td>Enable ADS Login:</td>
00520                         <td>
00521                                 <label><input type="radio" name="optEnableADS" id="optEnableADSYes" value="Yes" onclick="toggleAds(false)" />Yes</label>
00522                                 <label><input type="radio" name="optEnableADS" id="optEnableADSNo" value="No" onclick="toggleAds(true)" checked="checked" />No</label>
00523                         </td>
00524                 </tr>
00525                 <tr>
00526                         <td><label for="txtADSServerAddress">Server Address:</label></td>
00527                         <td><input type="text" id="txtADSServerAddress" name="txtADSServerAddress" value="10.0.0.2" onblur="validate_domain(this,0)" /></td>
00528                 </tr>
00529                 <tr>
00530                         <td><label for="txtADSNetworkName">Network Name:</label></td>
00531                         <td><input type="text" id="txtADSNetworkName" name="txtADSNetworkName" value="NITT\\" /></td>
00532                 </tr>
00533                 <tr>
00534                         <td><label for="txtADSUserDomain">User Domain:</label></td>
00535                         <td><input type="text" id="txtADSUserDomain" name="txtADSUserDomain" value="sangam.nitt.edu" /></td>
00536                 </tr>
00537         </table>
00538 </fieldset>
00539 <fieldset name="OpeinIDSettings">
00540         <legend>OpenID Settings</legend>
00541 
00542         <table border="0" width="580px">
00543         
00544                 <tr>
00545                         <td><label for="optEnableOpenID">Enable OpenID?</label></td>
00546                         <td>
00547                         <labe><input type="radio" name="optEnableOpenID" id="optEnableOpenIDNo" checked="checked" value="No" />No</label>
00548                         <label><input type="radio" name="optEnableOpenID" id="optEnableOpenIDYes" value="Yes" />Yes</label>
00549                         </td>
00550                 </tr>
00551                 </table>
00552 </fieldset>
00553 
00554 <script type="text/javascript" language="javascript">
00555         toggleImap(true);
00556         toggleLdap(true);
00557         toggleAds(true);
00558 </script>
00559 <input type="submit" name="btnSubmitSettings" onclick="return checkForm();" value="Continue" />
00560 </form>
00561 
00562 SETTINGSFORM;
00563 

Generated on Sun Jan 2 2011 04:55:32 for Pragyan CMS by  doxygen 1.7.1