2015-11-03 01:25:08 +01:00
< ? php
2015-11-04 22:52:12 +01:00
require_once ( 'required.php' );
2015-11-03 01:25:08 +01:00
2015-11-04 22:52:12 +01:00
session_start ();
$current_user = isset ( $_SESSION [ 'user' ]) ? $_SESSION [ 'user' ] : 0 ;
$notificationMessage = " " ;
2015-12-02 01:24:43 +01:00
if ( ! isset ( $_SESSION [ 'loginfailures' ]) || ( isset ( $_SESSION [ 'loginlockouttime' ]) && time () - $_SESSION [ 'loginlockouttime' ] >= 3600 )) {
// If never failed or more than 1 hour has passed, reset login failures.
$_SESSION [ 'loginfailures' ] = 0 ;
} else {
$alertlockoutmessage = " You failed logging in 10 times. To prevent request flooding and hacking attempts, you may not log in or create an account for about an hour. \\ n \\ nThe last time this page was loaded, you had been locked out for " . time_elapsed ( time () - $_SESSION [ 'loginlockouttime' ]);
$hoverlockoutmessage = str_replace ( " \\ n " , " \n " , $alertlockoutmessage );
}
2015-11-04 22:52:12 +01:00
if ( isset ( $_GET [ 'logout' ]) && $current_user > 0 ) {
session_destroy ();
2015-11-05 00:43:52 +01:00
header ( 'Location: ./?loggedout' );
2015-11-04 22:52:12 +01:00
}
2015-11-05 01:47:54 +01:00
elseif ( isset ( $_GET [ 'login' ]) && $current_user <= 0 ) {
2015-11-04 22:52:12 +01:00
if ( isset ( $_POST [ 'email' ]) && isset ( $_POST [ 'password' ])) {
if ( filter_var ( $_POST [ 'email' ], FILTER_VALIDATE_EMAIL )) {
if ( EmailExists ( $_POST [ 'email' ])) {
if ( Validate_Login ( $_POST [ 'email' ], $_POST [ 'password' ])) {
$_SESSION [ 'user' ] = Get_User_Id ( $_POST [ 'email' ]);
2015-11-05 00:43:52 +01:00
header ( 'Location: ./' );
2015-11-04 22:52:12 +01:00
} else {
2015-11-05 00:43:52 +01:00
header ( 'Location: ./?error=loginfailed' );
2015-11-04 22:52:12 +01:00
}
} else {
2015-11-05 00:43:52 +01:00
header ( 'Location: ./?error=emaildoesnotexist' );
2015-11-04 22:52:12 +01:00
}
} else {
2015-11-05 00:43:52 +01:00
header ( 'Location: ./?error=emailinvalid' );
2015-11-04 22:52:12 +01:00
}
} else {
2015-11-05 00:43:52 +01:00
header ( 'Location: ./?error=loginemailorpasswordblank' );
2015-11-04 22:52:12 +01:00
}
}
elseif ( isset ( $_GET [ 'createaccount' ])) {
if ( isset ( $_POST [ 'email' ]) && isset ( $_POST [ 'password' ])) {
if ( filter_var ( $_POST [ 'email' ], FILTER_VALIDATE_EMAIL ) && ! EmailExists ( $_POST [ 'email' ])) {
if ( query ( " INSERT INTO users (email, password, public_name, allow_email) VALUES (' " . $_POST [ 'email' ] . " ',' " . crypt ( $_POST [ 'password' ], $_POST [ 'email' ]) . " ',' " . htmlspecialchars ( $_POST [ 'publicname' ], ENT_QUOTES ) . " ', " . (( $_POST [ 'allowemails' ] != " on " ) ? 0 : 1 ) . " ) " )) {
2015-11-05 00:43:52 +01:00
header ( 'Location: ./?success' );
2015-11-04 22:52:12 +01:00
} else {
2015-11-05 00:43:52 +01:00
header ( 'Location: ./?error=couldnotcreate' );
2015-11-04 22:52:12 +01:00
}
} else {
2015-11-05 00:43:52 +01:00
header ( 'Location: ./?error=emailcreateinvalid' );
2015-11-04 22:52:12 +01:00
}
} else {
2015-11-05 00:43:52 +01:00
header ( 'Location: ./?error=createemailorpasswordblank' );
2015-11-04 22:52:12 +01:00
}
}
2015-11-05 01:47:54 +01:00
elseif ( isset ( $_GET [ 'error' ]) && $current_user <= 0 ) {
2015-11-04 22:52:12 +01:00
if ( $_GET [ 'error' ] == " couldnotcreate " ) {
$notificationMessage = " Could not create account.<br>Please try again later. " ;
} elseif ( $_GET [ 'error' ] == " emailcreateinvalid " ) {
$notificationMessage = " The email address used to create your account didn't work.<br>Please try another. " ;
} elseif ( $_GET [ 'error' ] == " createemailorpasswordblank " ) {
$notificationMessage = " The create account form somehow got submitted without some essential information.<br>Please try filling it out again. " ;
} elseif ( $_GET [ 'error' ] == " loginfailed " ) {
$notificationMessage = " We couldn't log you in because your email or password was incorrect.<br> " ;
2015-12-02 01:24:43 +01:00
2015-11-04 22:52:12 +01:00
$_SESSION [ 'loginfailures' ] += 1 ;
if ( $_SESSION [ 'loginfailures' ] < 10 ) {
2015-12-02 01:24:43 +01:00
$notificationMessage .= " This is your " . ordinal ( $_SESSION [ 'loginfailures' ]) . " time. Please try again. " ;
2015-11-04 22:52:12 +01:00
} else {
$_SESSION [ 'loginlockouttime' ] = time ();
$notificationMessage .= " Since you failed to log in successfully 10 times, you may not try again for about an hour. " ;
}
} elseif ( $_GET [ 'error' ] == " emaildoesnotexist " ) {
$notificationMessage = " The email address you entered doesn't have an account.<br>Would you like to <span class='clickable' onclick='ShowInfo( \" create \" )'>create an account</span>? " ;
} elseif ( $_GET [ 'error' ] == " emailinvalid " ) {
$notificationMessage = " The email address you entered didn't work.<br>Please try another. " ;
} else {
$notificationMessage = " Something seems to have gone wrong, but I don't know what.<br>Please try again. " ;
}
}
2015-11-05 01:47:54 +01:00
elseif ( isset ( $_GET [ 'success' ]) && $current_user <= 0 ) {
2015-11-04 22:52:12 +01:00
$notificationMessage = " Your account was created successfully!<br>Please log in using the email address and password you used to create it and you can start accessing your dictionaries anywhere! " ;
}
2015-11-05 01:47:54 +01:00
elseif ( isset ( $_GET [ 'loggedout' ]) && $current_user <= 0 ) {
2015-11-04 22:52:12 +01:00
$notificationMessage = " You have been successfully logged out.<br>You will only be able to use the dictionary saved to your browser. " ;
2015-12-01 00:08:43 +01:00
} elseif ( $current_user > 0 ) {
$notificationMessage = " Welcome back, " . Get_Public_Name ( $current_user ) . " ! " ;
2015-11-04 22:52:12 +01:00
}
2015-11-03 01:25:08 +01:00
?>
<! DOCTYPE html >
2015-10-26 05:41:25 +01:00
< html >
< head >
< meta charset = " utf-8 " />
2015-10-28 23:11:33 +01:00
< meta name = " viewport " content = " width=device-width, initial-scale=1 " >
2015-11-01 21:35:59 +01:00
< title > Lexiconga Dictionary Builder </ title >
2015-10-26 05:41:25 +01:00
< link href = " css/styles.css " rel = " stylesheet " />
2015-11-01 21:35:59 +01:00
< link href = " css/lexiconga.css " rel = " stylesheet " />
2015-10-26 05:41:25 +01:00
</ head >
< body >
2015-11-01 21:35:59 +01:00
< header >
< div id = " headerPadder " >
2015-12-02 01:24:43 +01:00
< a href = " ./ " id = " siteLogo " > Lexiconga Dictionary Builder </ a >
2015-11-02 04:09:20 +01:00
< div style = " float:right;margin: 16px 8px;font-size:12px; " >
2015-11-02 18:28:43 +01:00
< span id = " aboutButton " class = " clickable " onclick = " ShowInfo('about') " > About Lexiconga </ span >
2015-11-02 04:04:44 +01:00
</ div >
2015-11-04 22:52:12 +01:00
< div id = " loginoutArea " style = " font-size:12px; " >
< ? php if ( $current_user > 0 ) { //If logged in, show the log out button. ?>
< a href = " ?logout " id = " logoutLink " class = " clickable " > Log Out </ a >
2015-12-02 01:24:43 +01:00
< ? php } elseif ( ! isset ( $_SESSION [ 'loginfailures' ]) || ( isset ( $_SESSION [ 'loginfailures' ]) && $_SESSION [ 'loginfailures' ] < 10 )) { ?>
2015-11-04 22:52:12 +01:00
< span id = " loginLink " class = " clickable " onclick = " ShowInfo('login') " > Log In / Create Account </ span >
< ? php } else { ?>
2015-12-02 01:24:43 +01:00
< span id = " loginLink " class = " clickable " title = " <?php echo $hoverlockoutmessage ; ?> " onclick = " alert('<?php echo $alertlockoutmessage ; ?>'); " > Can ' t Login </ span >
2015-11-04 22:52:12 +01:00
< ? php } ?>
2015-11-01 21:35:59 +01:00
</ div >
</ div >
</ header >
< contents >
2015-11-10 01:53:01 +01:00
< div id = " notificationArea " style = " display:<?php echo (( $notificationMessage ) ? " block " : " none " ); ?>; " >
2015-11-09 20:20:03 +01:00
< span id = " notificationCloseButton " class = " clickable " onclick = " document.getElementById('notificationArea').style.display='none'; " > Close </ span >
2015-11-10 01:53:01 +01:00
< div id = " notificationMessage " >< ? php echo $notificationMessage ; ?> </div>
2015-11-09 19:45:46 +01:00
</ div >
2015-10-28 22:53:59 +01:00
< div id = " leftColumn " >
2015-10-26 22:50:09 +01:00
< form id = " wordEntryForm " >
2015-10-26 05:41:25 +01:00
< label >< span > Word </ span >
< input type = " text " id = " word " />
</ label >
2015-11-07 18:40:28 +01:00
< label >< span > Pronunciation < a class = " helperlink " href = " ./ipa_character_picker/ " target = " _blank " title = " IPA Character Picker backed up from http://r12a.github.io/pickers/ipa/ " > IPA Characters </ a ></ span >
2015-11-07 07:51:44 +01:00
< input type = " text " id = " pronunciation " />
2015-10-26 05:41:25 +01:00
</ label >
< label >< span > Part of Speech </ span >
2015-11-01 21:35:59 +01:00
< select id = " partOfSpeech " ></ select >
2015-10-26 05:41:25 +01:00
</ label >
2015-11-07 18:40:28 +01:00
< label >< span > Equivalent Word ( s ) </ span >
2015-10-26 05:41:25 +01:00
< input type = " text " id = " simpleDefinition " />
</ label >
2015-11-07 18:40:28 +01:00
< label >< span > Explanation / Long Definition </ span >
2015-10-26 05:41:25 +01:00
< textarea id = " longDefinition " ></ textarea >
</ label >
2015-10-26 22:50:09 +01:00
< input type = " hidden " id = " editIndex " />
< span id = " errorMessage " ></ span >
< div id = " newWordButtonArea " style = " display: block; " >
< button type = " button " onclick = " AddWord(); return false; " > Add Word </ button >
</ div >
< div id = " editWordButtonArea " style = " display: none; " >
2015-10-28 22:53:59 +01:00
< button type = " button " onclick = " AddWord(); return false; " > Edit Word </ button > < button type = " button " onclick = " ClearForm(); window.scroll(savedScroll.x, savedScroll.y); return false; " > Cancel </ button >
2015-10-26 22:50:09 +01:00
</ div >
< div id = " updateConflict " style = " display: none; " ></ div >
2015-10-26 05:41:25 +01:00
</ form >
2015-10-30 20:23:04 +01:00
2015-10-28 22:53:59 +01:00
</ div >
2015-10-26 05:41:25 +01:00
< div id = " dictionaryContainer " >
2015-10-28 22:53:59 +01:00
< span id = " settingsButton " class = " clickable " onclick = " ShowSettings() " > Settings </ span >
2015-12-01 00:08:43 +01:00
2015-11-01 21:35:59 +01:00
< h1 id = " dictionaryName " ></ h1 >
2015-10-28 05:54:27 +01:00
2015-11-01 21:35:59 +01:00
< span id = " descriptionToggle " class = " clickable " onclick = " ToggleDescription(); " > Show Description </ span >
2015-10-28 22:53:59 +01:00
< div id = " dictionaryDescription " style = " display:none; " ></ div >
2015-10-30 20:23:04 +01:00
< div id = " searchArea " style = " display:block; " >
< label style = " margin-top:10px; " >
< span > Search </ span >
2015-10-30 23:45:29 +01:00
< div style = " display:block; " >
< input type = " text " id = " searchBox " onclick = " this.select(); " onchange = " ShowDictionary() " style = " display:inline; " />& nbsp ;
< span style = " display:inline;cursor:pointer;font-size:10px;font-weight:bold; " onclick = " document.getElementById('searchBox').value='';ShowDictionary(); " > Clear Search </ span >
</ div >
2015-10-30 20:23:04 +01:00
< div id = " searchOptions " style = " font-size:12px; " >
2015-10-30 22:56:05 +01:00
< label style = " display:inline;margin:0; " > Word < input type = " checkbox " id = " searchOptionWord " checked = " checked " onchange = " ShowDictionary() " /></ label >& nbsp ; & nbsp ;
< label style = " display:inline;margin:0; " > Equivalent < input type = " checkbox " id = " searchOptionSimple " checked = " checked " onchange = " ShowDictionary() " /></ label >& nbsp ; & nbsp ;
< label style = " display:inline;margin:0; " > Explanation < input type = " checkbox " id = " searchOptionLong " checked = " checked " onchange = " ShowDictionary() " /></ label >
2015-10-30 20:23:04 +01:00
</ div >
</ label >
</ div >
2015-10-30 22:56:05 +01:00
< label style = " display:block; " >< b > Filter Words </ b >< select id = " wordFilter " onchange = " ShowDictionary() " >
2015-10-28 05:54:27 +01:00
< option value = " " > All </ option >
</ select >
</ label >
2015-10-26 05:41:25 +01:00
< div id = " theDictionary " ></ div >
</ div >
2015-11-02 18:28:43 +01:00
2015-11-03 01:25:08 +01:00
< div id = " rightColumn " class = " googleads " style = " float:right;width:20%;max-width:300px;min-width:200px;overflow:hidden; " >
2015-12-02 01:24:43 +01:00
< ? php if ( $_GET [ 'adminoverride' ] != " noadsortracking " ) { include_once ( " php/google/adsense.php " ); } ?>
2015-11-02 18:28:43 +01:00
</ div >
2015-10-26 22:50:09 +01:00
< div id = " settingsScreen " style = " display:none; " >
2015-10-28 22:53:59 +01:00
< div id = " settingsBackgroundFade " onclick = " HideSettings() " ></ div >
2015-10-27 23:36:24 +01:00
< div id = " settingsOptions " >
2015-10-28 22:53:59 +01:00
< span id = " settingsScreenCloseButton " class = " clickable " onclick = " HideSettings() " > Close </ span >
2015-10-27 23:36:24 +01:00
< h2 > Dictionary Settings </ h2 >
< form id = " settingsForm " >
< div class = " settingsCol " >
2015-10-30 18:38:41 +01:00
< div id = " hideIfComplete " >
2015-10-27 23:36:24 +01:00
< label >
2015-10-30 18:38:41 +01:00
< span > Dictionary Name </ span >
2015-10-27 23:36:24 +01:00
< input type = " text " id = " dictionaryNameEdit " />
</ label >
2015-10-28 06:41:01 +01:00
< label >< span > Dictionary Description / Rules </ span >
< textarea id = " dictionaryDescriptionEdit " ></ textarea >
</ label >
2015-10-27 23:36:24 +01:00
< label >
< span > Parts of Speech </ span >
< input type = " text " id = " dictionaryPartsOfSpeechEdit " />
</ label >
< label >
2015-10-30 18:38:41 +01:00
< span class = " checkboxlabel " > Allow Duplicates </ span >
< input type = " checkbox " id = " dictionaryAllowDuplicates " onchange = " ToggleCaseSensitiveOption() " />
< label >
< span class = " checkboxlabel " > Case - Sensitive </ span >
< input type = " checkbox " id = " dictionaryCaseSensitive " />
</ label >
</ label >
2015-11-07 18:40:28 +01:00
< label class = " inline " >
< span class = " checkboxlabel " > Sort by Equivalent Word </ span >
< input type = " checkbox " id = " dictionarySortByEquivalent " />
</ label > < span class = " helperlink clickable " onclick = 'alert("By default, your dictionary is organized alphabetically by word. Checking this box will organize it by the \"Equivalent Word\" field instead");' > ? </ span >
2015-10-30 18:38:41 +01:00
</ div >
2015-11-07 18:40:28 +01:00
< br >
2015-10-30 18:38:41 +01:00
< label >
< span class = " checkboxlabel " > Dictionary is Complete </ span >
2015-10-27 23:36:24 +01:00
< input type = " checkbox " id = " dictionaryIsComplete " />
</ label >
</ div >
< div class = " settingsCol " >
2015-10-30 20:23:04 +01:00
< label >
< b > Total Entries :</ b > < i id = " numberOfWordsInDictionary " ></ i >
</ label >
2015-10-27 23:36:24 +01:00
< label >< button type = " button " onclick = " ExportDictionary() " style = " cursor:pointer; " > Export Current Dictionary </ button ></ label >
2015-11-26 00:08:24 +01:00
< ? php if ( $current_user > 0 ) { //If logged in, show the log out button. ?>
< label >< span > Change Dictionaries </ span >
2015-11-28 07:17:52 +01:00
< select id = " userDictionaries " onchange = " ChangeDictionary(); " ></ select >
2015-11-26 00:08:24 +01:00
</ label >
< label >< button type = " button " onclick = " CreateNewDictionary() " style = " cursor:pointer; " > Create a New Dictionary </ button ></ label >
< ? php } ?>
2015-10-27 23:36:24 +01:00
< label >
< span > Import Dictionary </ span >
< input type = " file " id = " importFile " />
< button type = " button " onclick = " ImportDictionary(); return false; " > Import </ button >
</ label >
2015-12-01 00:08:43 +01:00
< ? php if ( $current_user > 0 ) { //If logged in, show the log out button. ?>
< label >< button type = " button " onclick = " DeleteCurrentDictionary() " style = " cursor:pointer; " > Delete Current Dictionary </ button ></ label >
< ? php } else { //If logged in, show the log out button. ?>
< label >< button type = " button " onclick = " EmptyWholeDictionary() " style = " cursor:pointer; " > Empty Current Dictionary </ button ></ label >
< ? php } ?>
2015-10-27 23:36:24 +01:00
</ div >
< div id = " settingsSaveButtons " >
< span id = " settingsErrorMessage " ></ span >< br >
< button type = " button " onclick = " SaveSettings(); HideSettings(); return false; " > Save and Close </ button >
< button type = " button " onclick = " SaveSettings(); return false; " > Save </ button >
</ div >
</ form >
</ div >
2015-10-26 22:50:09 +01:00
</ div >
2015-10-27 20:16:23 +01:00
2015-11-02 18:28:43 +01:00
< div id = " infoScreen " style = " display:none; " >
< div id = " infoBackgroundFade " onclick = " HideInfo() " ></ div >
< div id = " infoPage " >
< span id = " infoScreenCloseButton " class = " clickable " onclick = " HideInfo() " > Close </ span >
< div id = " infoText " ></ div >
2015-11-01 21:35:59 +01:00
</ div >
</ div >
2015-12-01 00:08:43 +01:00
< div id = " loadAfterDeleteScreen " style = " display:none; " >
< div id = " loadAfterDeleteFade " ></ div >
< div id = " loadAfterDeletePage " >
< div class = " settingsCol " >
< h1 > Dictionary Deleted </ h1 >
< label > Select dictionary to load :< br />
< select id = " loadAfterDelete " onchange = " ChangeDictionary(this);document.getElementById('loadAfterDeleteScreen').style.display = 'none'; " ></ select >
</ label >
< p > Or </ p >
< label >< button type = " button " onclick = " CreateNewDictionary();document.getElementById('loadAfterDeleteScreen').style.display = 'none'; " style = " cursor:pointer; " > Create a New Dictionary </ button ></ label >
</ div >
</ div >
</ div >
2015-11-01 21:35:59 +01:00
</ contents >
2015-10-30 20:23:04 +01:00
< footer >
2015-11-08 01:21:06 +01:00
Dictionary Builder only guaranteed to work with most up - to - date HTML5 browsers . < a href = " https://github.com/Alamantus/DictionaryBuilder/issues " target = " _blank " > Report a Problem </ a > | < span class = " clickable " onclick = " ShowInfo('terms') " style = " font-size:12px; " > Terms </ span > < span class = " clickable " onclick = " ShowInfo('privacy') " style = " font-size:12px; " > Privacy </ span >
2015-10-30 20:23:04 +01:00
</ footer >
2015-11-02 18:28:43 +01:00
<!-- Markdown Parser -->
2015-12-01 21:15:37 +01:00
< script src = " js/marked.js " ></ script >
2015-11-02 18:28:43 +01:00
<!-- JSON Search -->
< script src = " js/defiant-js/defiant-latest.min.js " ></ script >
2015-12-02 01:24:43 +01:00
<!-- Diacritics Removal for Exports -->
< script src = " js/removeDiacritics.js " ></ script >
2015-11-02 18:28:43 +01:00
<!-- Main Script -->
< script src = " js/dictionaryBuilder.js " ></ script >
2015-11-08 01:02:35 +01:00
< script src = " js/ui.js " ></ script >
2015-12-02 01:24:43 +01:00
< ? php if ( $_GET [ 'adminoverride' ] != " noadsortracking " ) { include_once ( " php/google/analytics.php " ); } ?>
2015-10-26 05:41:25 +01:00
</ body >
</ html >
2015-11-09 19:45:46 +01:00
< ? php
2015-11-09 23:44:10 +01:00
2015-11-09 19:45:46 +01:00
function get_include_contents ( $filename ) {
if ( is_file ( $filename )) {
ob_start ();
include $filename ;
return ob_get_clean ();
}
return false ;
}
?>