How to make double quotes and single quotes be handled the same - codemirror

We have an issue finding a way to make codemirror behave the same for single and double quote strings.
It would have been been a quick css hack but, for double quotes the css generated has no tags around it.
The single quotes have a class called "cm-string" that would be nice to have on both.

For me it is like this. I use the theme light, in the theme / light.css file line:
.cm-s-light span.cm-string {color: # 3ad900; }
it displays me like on the screen "" and "the same in green
Search in your theme file.
AND
for file sql.js in line 57:
} else if (ch == "'" || (ch == '"' && support.doubleQuote)) {
remove:
&& support.doubleQuote
so that it stays:
} else if (ch == "'" || (ch == '"')) {
and you will get the desired effect in SQL mode.
For TCL
Replace line 45 tcl.js:
if ((ch == '"' || ch == "'") && state.inParams) {
such as line:
if ((ch == '"' || ch == "'")) {

Related

Why doesn't this form code work? It seems logical

I'm trying to program a simple form that asks for the following inputs:
mood, age, and gender
It does not matter what I put in the mood prompt. It always comes out positive. For the age, I would like the tab to close if they are under 18 years old. For gender, it goes the same with the mood prompt. Any help would be appreciated.
var userMood = prompt("Hey! How's it going?");
if (userMood = "good" || "Good") {
alert("Awesome! We just need you to fill out a form for security reasons.");
} else if (userMood != "good" || "Good") {
alert("Oh, I'm sorry to hear that... We just need you to fill out a form for security reasons.");
}
var userAge = prompt("What is your current age?");
if (userAge >= "18" ) {
alert("Great! You are the sufficient age to enter this webpage!");
userAge = true;
} else if ( userAge <= "17"){
alert("Sorry, you are too young to view this content...");
window.close();
}
var userGender = prompt ("What is your gender?");
if (userGender = "male" || "Male" || "female" || "Female"){
alert("Great! You're human!");
userGender = true;
} else {
alert("The webpage has perdicted non-human cyber activity, you can no longer continue.");
window.close();
}
i'm going to make my answer verbose to help you learn. for starters, you are using = when you mean to use == or even ===. this is why the mood is always registering as good, because userMood = "good" sets userMood to 'good' and so the expression evaluates to "good", which validates the if statement because FALSE for strings is "" and true is every other string. also userMood = "good" || "Good" doesn't do what you think it does. you need to check both strings like so (userMood === "good" || userMood === "Good").
I tried varying some lines in your code into something below.
var userMood = prompt("Hey! How's it going?");
if (userMood == "good" || userMood == "Good")
alert("Awesome! We just need you to fill out a form for security reasons.");
else
alert("Oh, I'm sorry to hear that... We just need you to fill out a form for security reasons.");
var userAge = prompt("What is your current age?");
if (userAge >= 18 )
{
alert("Great! You are the sufficient age to enter this webpage!");
userAge = true;
}
else if ( userAge < 18 && userAge > 0)
{
alert("Sorry, you are too young to view this content...");
window.close();
}
else if ( userAge < 0 )
{
alert(" ***** prompt message for inputting negative number ****");
window.close();
}
var userGender = prompt ("What is your gender?");
if (userGender == "male" || userGender == "Male" || userGender == "female" || userGender == "Female")
{
alert("Great! You're human!");
userGender = true;
}
else
{
alert("The webpage has perdicted non-human cyber activity, you can no longer continue.");
window.close();
}

CodeIgniter PHP Parsing Error unexpected '{', expecting '('

What's with this PHP Parsing Error Unexpected '{', expecting '('
No backtrace, no any other error message, just one line in the controller, that's it -_-
I kept looking for solutions and reading many links related to this.
What could be the reason for the error in my code below..
This was my controller code (which was working fine):
if (isset($filter) && !empty($search)) {
$data['users'] = $this->model_search->searchTutor($field, $search);
}
elseif (($filter == 'subjName') && !empty($search)) {
$data['users'] = $this->model_search->searchBySubj($field, $search);
}
else {
$data['users'] = $this->model_search->getlist($field);
}
//later i wanted to add a code that will show No Result Found
The view file of my page started giving this error when I added an elseif statement in my controller (Search.php):
if (isset($filter) && !empty($search)) {
$data['users'] = $this->model_search->searchTutor($field, $search);
}
elseif (($filter == 'subjName') && !empty($search)) {
$data['users'] = $this->model_search->searchBySubj($field, $search);
}
//so I added another elseif
elseif (isset($filter) && empty($search)) {
$data['users'] = $this->model_search->getlist($field);
}
//and put the No Result last
else {
$this->session->set_flashdata('nores','<div class="alert text-center">No result matched your search.</div>');
}
Is it because of the multiple elseif condition or am I really missing something here? Please help..
elseif {
Your new elseif has no condition. When do you expect it to run? You need to add a condition.

NGUI avoid line-break in UIInput

Is there any way to avoid users to input line-breaks in UIInputs?
Do not want the user to be able to write line-breaks in username inputs, for example.
I searched for multiline attribute but it seems it only exists in UILabel objects.
Tried "validation:Username" but this option does not allow to write characters like "-", which is a valid username character of my application.
Thanks!
You can similarly limit your input field to a single line by setting the Max Lines property to 1 on the UILabel.
http://www.tasharen.com/forum/index.php?topic=6752.0
Had to check the UIInput.cs file to know how to ignore newlines, and I found this:
case KeyCode.KeypadEnter:
{
ev.Use();
bool newLine = (onReturnKey == OnReturnKey.NewLine) ||
(onReturnKey == OnReturnKey.Default &&
label.multiLine && !ctrl &&
label.overflowMethod != UILabel.Overflow.ClampContent &&
validation == Validation.None);
if (newLine)
{
//Insert("\n");
}
else
{
UICamera.currentScheme = UICamera.ControlScheme.Controller;
UICamera.currentKey = ev.keyCode;
Submit();
UICamera.currentKey = KeyCode.None;
}
return true;
}
So in order to avoid newlines, you need to do:
UILabelObject.multiLine = false;
UIInputObject.onReturnKey = UIInput.OnReturnKey.Default;
Doing that, bool newLine becomes false and performs Submit();

Drupal redirection

I am working on a project and there is a custom module in that which have the drupal redirection code in it here is the code :
if (empty($_GET['destination'])
&& isset($_COOKIE["abc"])
&& $_COOKIE["abc"]<>''
&& ($_POST['form_id'] != 'user_pass_reset'))
{
$_GET['destination'] = "xyz" ;
}
}
Can anyone please explain the 3rd line of code or maybe all of it. Thanks
I have added comments to the source. <> is the same as !=. See PHP Comparison Opperators.
if (empty($_GET['destination']) //Check if $_GET['destination'] is empty.
&& isset($_COOKIE["abc"]) //Check if $_COOKIE["abc"] is not NULL.
&& $_COOKIE["abc"]<>'' //Check if $_COOKIE["abc"] does not equal an empty string.
&& ($_POST['form_id'] != 'user_pass_reset')) //Check if $_POST['form_id'] is not 'user_pass_reset'
{
$_GET['destination'] = "xyz" ; //Set $_GET['destination'] to "xyz"
}
}
should be modify a little bit in second line
if (empty($_GET['destination']) //Check if $_GET['destination'] is empty.
&& isset($_COOKIE["abc"]) //Check if $_COOKIE["abc"] is EXISTS.
&& $_COOKIE["abc"]<>'' //Check if $_COOKIE["abc"] does not equal an empty string.
&& ($_POST['form_id'] != 'user_pass_reset')) //Check if $_POST['form_id'] is not 'user_pass_reset'
{
$_GET['destination'] = "xyz" ; //Set $_GET['destination'] to "xyz"
}
}

Checking form submission against a word list

I have some code to check is a form is being spammed and if so then stop the email.
It includes a section like this:
if(strpos($messagefield, " cialis") !== false){
$noemail = true;
}
if(strpos($messagefield, " viagra") !== false){
$noemail = true;
}
etc for as many words as we have in the bad word list
This works fine, but is clumsy and difficult to easily add new words to check.
It would be easier if I could create an array and check any field against the array, but I am strugling to find an example to use (most examples still specify the text to search for which defeats the object in this case)
Can anyone help with code to check $messagefield against an array?
(I know there are better ways maybe but this works for us at the moment!)
$i = 0;
$wordlist = array(' cialis', ' viagra');
while ($i < count($wordlist) && $noemail == false) {
if (strpos($messagefield, $wordlist[$i]) !== false) {
$noemail = true;
}
$i++;
}
It is better to use stripos (case-insensitive version of strpos).
Try following code:
$a = array(' cialis', ' viagra');
for ($i = 0; $i < count($a); $i++)
if(stripos($messagefield, $a[$i]) !== false){
$noemail = true;
break;
}
}