## Delete from table one row with 2 variable with limit

I’m developing a PHP script who store session of users in a Database.

When an user logout from server, remove only one row ( because same user can login more than one time )

When server reboot, remove all session of all users from that server with same ip.

# Table structure:

• Table name:
• totalconcurrent
• Column in table:
• ID [int, autoincrement, 11]
• serverip [mediumint]
• userid [text]

Running on :

mysql  Ver 15.1 Distrib 5.5.64-MariaDB, for Linux (x86_64) using readline 5.1 

# Case: User logout

Query runs correctly but doesn’t delete anything.

    elseif ($_GET['status'] == "logout"){$  sql = "DELETE FROM totalconcurrent WHERE (serverip,userid) IN ((INET_ATON('".get_server_ip()."'),'".$_GET['id']."')) LIMIT 1;"; if ($  conn->query($sql) === TRUE) { echo "1 Session of ".$  _GET['id']." removed";         } else {             echo "Error: " . $sql . "<br>" .$  conn->error;         }     } 

# Case: Server Reboot

Query runs correctly but doesn’t delete anything.

    elseif ($_GET['status'] == "reboot"){$  sql = "DELETE FROM totalconcurrent WHERE serverip IN ((INET_ATON('".get_server_ip()."')));";          if ($conn->query($  sql) === TRUE) {             echo "Server rebooted, removed all session stored in this server";         } else {             echo "Error: " . $sql . "<br>" .$  conn->error;         }     } 

# Problem:

I’ve tryed many times and many types of query to do this but without finding the correct way to do this.

What queries i need for do this?

## Closed formula for two variable recurrence

I would like to know if there exists a closed form formula to the following recurrence:

• $$f(s, 0) = 1$$
• $$f(s,b) = \displaystyle\sum_{i=1}^{min(s, b)} \left[ (s-i+1)\times f(i, b-i) \right]$$

This recurrence gives the solution to problem F of the ICPC Latin American regionals of 2019.

The problem itself can be solved in $$O(n^2)$$ by using dynamic programming and keeping a matrix of precomputed sums. I’m just curious about if there is some technique that allows obtaining a closed formula to recurrences like this, so I can solve it in better runtime complexity.

## Is there a reason why JWT cannot be used as “connection bound context variable” for TLS?

Apart from the fact that TLS doesn’t have “connection context” variables, is there any reason why this couldn’t be technically built into the standard for something like JWT?

Why it is needed

When a browser sends multiple requests to the same API server, it resends the JWT in the header multiple times. This means additional data overhead, and each time, the server needs to verify the JWT.

I would like to see the TLS standard include “connection bound context variables” so that JWTs can be sent once and used across multiple HTTP REQUESTS over that TLS connection.

How it could work

1) The client connects to the server, and a TLS encrypted session is established.

2) The client send the JWT to the server-side – there are two options for this:

A) The client can send connection variables directly on the TLS layer. The client sets the variable on the client side, and TLS sends the data to the server side. The variable name from the client is always prefixed with “CLIENT-“.

B) The client sends a HTTP request over the TLS session to a specific endpoint dedicated for use to set a TLS variable /api/setJWT. The client sends the JWT as a POST. The server reads the JWT, verifies it, and then sets it to the TLS connection context.

[B] would work best, because client software would be harder to change (browsers).

3)

On the serverside, the encapsulating TLS object’s ITLSConnectionContext interface is made available from HTTP REQUEST handlers. The ITLSConnectionContext has three functions, string[] ListVariables(), string GetVariable(name), SetVariable(name, string).

Assuming 2B is used, when GetVariable(“JWT”) is successful, it can be assumed that it’s valid.

How it could work without changing TLS standard

If a particular TLS connection between the server and the client has a secure identity, then the application-layer can link that to a simple dictionary lookup. Perhaps this could be a GUID (as well as the client-side IPAddress-Port tuple). This GUID approach would mean each language framework can natively implement the lookup, and that makes other benefits possible, where native memory objects can also be linked, not just platform-independent strings.

Other benefits

Furthermore, the server might variables on the context for other purposes:

1) A database PK for the Person behind the JWT, PersonID. It might be a stream interface 2) A particular stream (TCP connection) to another resource 3) A file lock to a user-related logging file

The web would be better.

But am I wrong? Am I missing something that would make this unworkable and insecure?

## define temporary variable inside the the definition of a funciton

This is mostly a matter of me trying to define functions in a tidy way. Suppose I want to define a function which is very complicated and so would like to break it into pieces. To get the idea, here’s a simple example

f[x_,y_]:= (x^2 + y^2)/(x y)  

I want to write it along the lines of

f[x_,y_]:= A/(x y) where A= (x^2 + y^2) 

What is the correct way to do this?

## Which statement best describes an Array variable?

a) Used to represent a group of variables that are of the same data type and that can be referenced using one variable name.

b) Can only be defined in a main method.

c) Not a Data Structure.

d) If the programmer attempts to store another piece of data in a memory location, the original data being stored is written over and lost.

## Exact meaning of metalinguistic variable

Consider the following BNF

<join-command> ::= <string> + <string> 

In this context <join-command> and <string> are normally called metalinguistic variables or syntactic categories. Note that the first usage of <string> don’t necessarily represent the same terminal string as the second usage.

Recently however I come across a slightly different notion of “metalinguistic variable” (in a course about formal logic). Here it meant a variable of the metalanguage that represent one string of the object language (i.e. terminal language) and always that. So the previous syntax would become:

<join-command> ::= <string1> + <string2> 

What’s the correct terminology? Should I avoid calling BNF syntactic categories “metalinguistic variables”?

Maybe calling them “syntactic variables” would fix the ambiguity?

## Get field value and use as variable in php

I have code below. Product field “position” has a value of 52 on 50% of the products. The other 50% have value 100. I want to set a value in the code below to be this variable. At the end of the code you see I have inserted variable $position, but it’s not working. Next to that, the generated text doesn’t seem to use the font I specified. Any idea where I am going wrong?  function add_frontend_fields(){ global$  product;         $product_id =$  product->get_id();         $position = get_field('position'); } function generate_image(){$  image = $_POST['image'];$  product_id = $_POST['product_id'];$  position = $_POST['position'];$  text = wc_clean($_POST['poster_text']);$  textlower = wc_clean($_POST['poster_textlower']);$  time = wc_clean($_POST['datetime']);$  location = wc_clean($_POST['location']);$  file_url = $this->_create_image($  image, $text,$  textlower, $time,$  location, $product_id); wp_send_json_success(array('file' =>$  file_url));     }   function _create_image( $virtualsky,$  text, $textlower,$  time, $location,$  product_id ) {         $upload_dir =$  this->get_upload_folder();         $filename = 'image.png';$  hashed_filename = md5( $filename . microtime() ) . '_' .$  filename;         $file_path =$  upload_dir[0].$hashed_filename;$  file_url = $upload_dir[1].$  hashed_filename;          $img = str_replace( 'data:image/png;base64,', '',$  virtualsky );         $img = str_replace( ' ', '+',$  img );         $decoded = base64_decode($  img );            $line1 =$  text;         $line2 =$  textlower;         //$line2 = "The sky above {$  location} on ".date('F d, Y', strtotime($time)).' at '.date('H:i', strtotime($  time));;          file_put_contents( $file_path,$  decoded );            $template = plugin_dir_path( WOO_VIRTUALSKY_GENERATOR_FILE ).'public/images/template.jpg'; if(!empty($  product_id)){             $template_id = get_field('poster_template',$  product_id);             if($template_id){$  template_file = get_attached_file($template_id); if($  template_file){                     $template =$  template_file;                  }             }         }          $template = imagecreatefromjpeg($  template);          $font_family = plugin_dir_url( WOO_VIRTUALSKY_GENERATOR_FILE ).'public/lib/fonts/AmaticSC-Regular.ttf'; imageloadfont ($  font_family);           $color = imagecolorallocate($  template, 0, 0, 0);         $fontSize = '22';$  width1 = imagefontwidth($fontSize) * strlen($  line1);         $width2 = imagefontwidth($  fontSize) * strlen($line2);$  height1 = imagefontheight($fontSize);$  img_w = 960;         $height = 1050; imagestring ($  template,$fontSize,($  img_w/2)-($width1/2),$  height, $line1,$  color);          imagestring ($template,$  fontSize,($img_w/2)-($  width2/2), $height+$  height1+10, $line2,$  color);           $sky = imagecreatefrompng($  file_path);         imagecopy($template,$  sky, 148, $position, 0, 0, 660, 660); unlink($  file_path);         imagejpeg($template,$  file_path);         imagedestroy($template); return$  file_url;         }  

## How can I trace/debug the origin of a specific POST/JS variable in JavaScript in Firefox?

Premise: I’m trying to automate posting on Stack Exchange. Not for abuse, but to have my own interface instead of having to bookmark and use the various “StackSites” and being subjected to the insulting “Viewed 1 times” bug which is never fixed no matter how many times it’s reported.

I have everything ready except for one small detail: the POST variable “i1l” is only set through JavaScript, in an extremely convoluted manner, to the point where I’m convinced that it is specifically done to stop any kind of automation. (Also, to make it clear, SE prevents any client that doesn’t have JavaScript enabled from posting at all.)

One of the comments mentions Stack Exchange apparently being open source now, and links to a GitHub URL, but I searched all over it and found no mention at all of this variable. It’s only present in the (heavily minified/obscurified) JavaScripts loaded on the actual site. So clearly it isn’t open source after all, at least not fully.

As it’s a complete mystery to me how this variable is determined, and it needs the right value or else it doesn’t let you post, I’m wondering if somebody can tell me how to “debug”/trace this specific variable in Firefox.

I cannot use their API because it requires you to have an account and only use that, which is not good for privacy. I want to be able to “ask as guest” for the StackSites that support it, and the API doesn’t let you do that.

I frankly doubt it would help me much even if I could follow this variable around, step by step, because the JS code I have dug up seems absolutely nonsensical to me. The very name is extremely cryptic and nothing indicates what it would be used for if not to prevent people from posting.

Note: Even if I were to abuse this, which again I’m not, the “one post per IP address per 90 minutes” limit, as well as the constant “too much abuse from your network, sorry” messages make it nearly impossible to abuse anyway. I get those constantly when trying to post perfectly legitimate questions.

## Does the decoy familiar archetype stack with improved familiar if the familiar can’t speak and does not give a variable bonus

familiar archetype rules

Animal archetypes modify familiars’ standard abilities, similar to how class archetypes modify player characters’ class features. These archetypes function by swapping out certain abilities that are common to standard familiars and replacing them with new abilities tailored to a particular theme. Where levels are referenced in archetype descriptions, they refer to the class level of the PC master in whichever class grants the familiar as a class feature.

Shapechanging Familiars: Familiars that can take various forms, such as the magical child’s animal guide, imps, and quasits, must have the same archetype for each form, and it must be legal for all of those forms (meaning if any form is an improved familiar, it can’t take archetypes that don’t stack with improved familiar).

Improved Familiars Restriction: The abilities of an improved familiar don’t stack with those of any familiar archetype that alters or replaces the variable bonus a familiar grants its master or speak with animals of its kind. (A leshy warden’s leshy familiar doesn’t grant a variable bonus or speak with animals of its kind, so it doesn’t have abilities that stack with those familiar archetypes.)

Note: Familiar archetypes modify familiars’ standard abilities, similar to how class archetypes modify player characters’ class features. These archetypes function by swapping out certain abilities that are standard to common familiars for new abilities tailored to particular themes. Unless otherwise stated, levels referenced in this section refer to the familiar’s effective level, which is the master’s combined levels in the classes that grant that familiar.

decoy familiar

A decoy misdirects its master’s enemies, allowing the master to strike by surprise.

Class Skills: A decoy treats Bluff as a class skill.

Deceitful A decoy gains Deceitful as a bonus feat. This replaces alertness.

Mockingbird (Ex) At 5th level, a decoy can speak any of its master’s languages. At 7th level, it can mimic its master’s voice and intonation perfectly.

This ability replaces speak with master and speak with animals of its kind.

Master’s Guise (Sp) At 11th level, a decoy can transform into a perfect likeness of its master, as the alter self spell. It can hold this form for up to 1 minute per caster level; upon changing back, the decoy must remain in its natural form for an equal amount of time before transforming again.

This ability replaces spell resistance.

improved familiar rules

This feat allows you to acquire a powerful familiar, but only when you could normally acquire a new familiar.

Prerequisites: Ability to acquire a new familiar, compatible alignment, sufficiently high level (see below).

Benefit: When choosing a familiar, the creatures listed here are also available to you. You may choose a familiar with an alignment up to one step away on each alignment axis (lawful through chaotic, good through evil).

Improved familiars otherwise use the rules for regular familiars, with two exceptions: if the creature’s type is something other than animal, its type does not change; and improved familiars do not gain the ability to speak with other creatures of their kind (although many of them already have the ability to communicate).

Under improved familiar restrictions it says that the leshy warden’s familiar stacks because it has no speak with animal or variable bonus which I believe is the +2 to a specific skill. Since most improved familiars that I skimmed through can neither speak nor do they give a skill bonus wouldn’t they be capable of stacking?

## NULL as a @variable within WHERE clasue

I would like to SET ‘IS NULL’ as a variable and use it in a WHERE clause. I will be unioning many tables together that carry the same WHERE clause and would like flexibility to use a variable for my yearCompleted column – see example below-

DECLARE @YEARCOMPLETED SET @YEARCOMPLETED = NULL  SELECT * FROM TABLE1 WHERE yearCompleted = @YEARCOMPLETED UNION ALL SELECT * FROM TABLE2 WHERE yearCompleted = @YEARCOMPLETED 

In this instance is it possible to find rows where yearCompleted IS NULL using a variable?