Why, if a function accepts arguments, it fails on ajax calls?

I am trying to write a WP function to work with both ajax and direct calls, something like this:


function some_function($  var){     $  var = !empty($  var) ? $  var : $  _POST['var'];     echo $  var;          //or even      $  var = null;     echo 'something';      if(!empty($  _POST['action'])) wp_die(); } 


let ajaxurl = '███'; let data = {'action': 'somefunction','var':'foo')}; $  .post(ajaxurl, data, function(response) {console.log(response);}); 

WP use

add_action( 'wp_ajax_somefunction', 'some_function',10,1); add_action( 'wp_ajax_nopriv_somefunction', 'some_function',10,1); 

Another WP use


However, any time I place $ var as an accepted function argument, some_function($ var), my ajax calls start returning a 500 error. So, something like this

function some_function(){     $  var = !empty($  var) ? $  var : $  _POST['var'];     echo $  var; } 

works for ajax.

I tried looking up wp ajax & arguments, but the search results are always about the variables we pass through ajax, not the callback function arguments. The only thing I learned is that we have to add a number of accepted arguments into add_action()

What am I doing wrong?

Thank you.

…P.S. I found a funny workaround:

function some_function_ajax(){     $  var = $  _POST['var'];     some_function($  var); } function some_function($  var){     echo $  var; } // =) 

but still, what is the right way?

Is running bash script that is taking arguments from site dialog box a good idea?

I’m building a site that will use youtubeAPI to keep track of playlist changes. In order for 3rd party to use it I would supply a dialog box in which user would type his/hers playlistID – this would be read and then put as an argument into bash script that in turn runs curl/python scripts to connect with API (ran on my machine) and another bash script that would mkdirs on my disk.

Does this potentially endanger me/my files somehow ? Can someone input some magic command that would do “rm * -f” or similar malicious endeavor ? Should I use some external server instead of my machine ?

I know nothing about security, Ive read few topics here but didnt find similar problem.

Applying rules to functions with non numeric arguments

I am trying to do the following (it’s a simplified version):

In[1]:= rulepositive = { f[a_?Positive]:> f[a] }; In[2]:= rulenegative = { f[a_?Negative]:> 0 };  In[3]:= $  Assumptions = Elements[w,Positive];  In[4]:= f[w]/.rulepositive In[5]:= f[w]/.rulenegative 

where I expect

Out[4]:= f[w] Out[5]:= 0 

But it doesn’t work. In words I want to apply a set of mapping rules in functions with non numeric arguments, which nevertheless have definite nature (e.g. Positive/Negative). How could I do it?

Unlawful use of bulk data information client name holder arguments [closed]

DST:, Port: 80, Host: ikosher.co.il , Get: /discussion/multi: router, 30. Has been identified access to my bulk data of network Using a trickbot software to calaberate to my IP in Spam emails for a bit catch fragment hit to my IP address domain mobile operator IP address domain a lot of routers set up to my network domain renewed there routers and have been stilling everything in value in my emails like invcioses my Facebook account bissness page account’s to Facebook unlawful use of bulk data information lonching attacks with created element a 👈 clone nod that carrys out attacks with created element a 👈and what to do with information about the commands put in to do hidden in element a 👈 if information like money from an account is taken with element a 👈 hidden in element a 👈 transfer in the software program trickbot looks like this in software a=b or a=f or a=d ect that’s how the software knows what to do with the task it’s carrying out and where it’s going. This that have set me up with there routers and renewed them have not paid me my 10,00USD$ for bulk access to My data so fare I have indintafied 3 routers Router, 30. authority, Router, 24. authority, Port 80. Router, 33. authority, There are more than just that that have set up and renewed there routers to my network domain IP address So they can reseale my data because data behaves like internet service provider dus for there privet owned business Xfinity they run from there department The tag I placed in is where you we’ll see there names in the document https://mm.icann.org/pipermail/comments-biz-renewal-03apr19/2019q2.txt

Why does using WP_Query inside a shortcode in an elementor page cause the arguments for WP_Query to get malformed?

I am trying to embed a custom WP_Query inside a shortcode I have activated on one of my pages (created in Elementor). I have a Custom Post Type called ‘inspector-profiles’, and for some reason when I add that to my $ args array, it gets either not honored by WP, or it is overwritten by something else.

I cannot see what is causing an overwrite if anything.

The code is this, so far:

private function isInspector() {     if (is_user_logged_in()) {         $  user = wp_get_current_user();         return in_array('general_inspector', (array)$  user->roles);     }     return false; }  public function sc_inspectorProfileData() {     global $  wpdb;     $  user = \wp_get_current_user();       // WP_Query arguments     $  args = array(         'post_type'              => 'inspector-profiles',         'post_status'            => 'publish',         'author'                 => $  user->ID     );       // The Query     echo '<pre>';      $  myq = new \WP_Query( $  args );      print_r($  myq->request);      if ($  myq->have_posts()) {         while ($  myq->have_posts()) {             $  myq->the_post();             print_r($  myq->post);             wp_reset_postdata();             wp_reset_query();         }     }      echo '</pre>'; } 

When I create the arguments for WP_Query above, the $ args array looks fine prior to running the query. When I run the query, I immediately spit out the generated SQL query, and it looks like this:

SELECT SQL_CALC_FOUND_ROWS wp_posts.ID FROM wp_posts WHERE 1=1 AND wp_posts.post_author IN (1) AND wp_posts.post_type IN ('post', 'page', 'attachment', 'memberpressproduct', 'memberpressgroup', 'mpdl-file', 'ht_kb') AND ((wp_posts.post_status = 'publish')) ORDER BY wp_posts.post_date DESC LIMIT 0, 200

My specified post_type is not even in that list. What am I doing wrong? I have tried using instances of get_posts(), using the WP_Query object, and some stuff that has been deprecated even.

Efficiently populate a look-up table for a function over a range of arguments in Python

I am minimizing a scalar function which takes a n-dimensional vector input and outputs the scalar value, n-dim vector (Jacobian), and an nxn matrix (Hessian). Given a range of the elements in my input vector I’m looking for a efficient way to precalculate the outputs in an efficient to access format.

I’ve been thinking of a scheme based on numpy.interpn with a regularly spaced grid of inputs, but this only allow for linear interpolation of intermediate values, and requires regular sampling.

I’m hoping there is a tool available that does this with a more intelligent method? Perhaps with automatic refinement of inputs sampled or a more sophisticated interpolation scheme?

Technically, the scalar output contains the Jacobian and Hessian but I need those with decent fidelity, so I would either need a higher order representation of the scalar function (with added sampling frequency) or I ccan interpolate on the Jacobian and Hessian directly (as they are outputted by the minimizer anyway)


pg_upgrade arguments order

This isn’t really a question since I’ve figured out the answer, but I didn’t find it documented anywhere else so I’m putting it here.

I attempted to use pg_upgrade with the -c (check-only) and -k (hard links) options (not at the same time), but it consistently ignored them both. After much searching and trial, error, and hair loss, I finally figured out this nugget – they have to be the first argument (or at least before the ones I used) for them to be applied.

These seem to work:

/usr/pgsql-12/bin/pg_upgrade -c –old-datadir “/var/lib/pgsql/9.5/data” –new-datadir “/var/lib/pgsql/12/data” –old-bindir “/usr/pgsql-9.5/bin” –new-bindir “/usr/pgsql-12/bin” /usr/pgsql-12/bin/pg_upgrade -k –old-datadir “/var/lib/pgsql/9.5/data” –new-datadir “/var/lib/pgsql/12/data” –old-bindir “/usr/pgsql-9.5/bin” –new-bindir “/usr/pgsql-12/bin”

These do NOT:

/usr/pgsql-12/bin/pg_upgrade –old-datadir “/var/lib/pgsql/9.5/data” –new-datadir “/var/lib/pgsql/12/data” –old-bindir “/usr/pgsql-9.5/bin” –new-bindir “/usr/pgsql-12/bin” -c /usr/pgsql-12/bin/pg_upgrade –old-datadir “/var/lib/pgsql/9.5/data” –new-datadir “/var/lib/pgsql/12/data” –old-bindir “/usr/pgsql-9.5/bin” –new-bindir “/usr/pgsql-12/bin” -k

OS: CentOS 6.6

Passing Function Calls vs. Values as Arguments

I tried writing code for a program that evaluates an inline expression using an operand stack (nstack) and an operator stack (ostack):

#include<stdio.h> #include<stdlib.h> #include<string.h> int nstack[10]; //the operand stack char ostack[10] = "E"; //the operator stack with 'E' as the sentinel int ntop = -1; //top value of operand stack int otop = 0;  //top value of operator stack  //Function Declarations void opush(char op); int npop(); void npush(int a); int opop(); char o; int precedence(char op); void evaluate(); void tokenizer(char c); int result(int j, char o, int i); //Calculates the result of i (o) j  void npush(int a){ //Operand Push     nstack[++ntop] = a; }  int npop(){ //Operand Pop     return nstack[ntop--]; }  int opop(){ //Operator Pop     return ostack[otop--]; }  void opush(char op){ //Operator Push     while (precedence(op) <= precedence(ostack[otop])){             //keep popping the operator(s) and evaluate their results (while the operands are being popped as well) until the condition turns false              int x = npop(); int y = npop(); char o = opop();              // **************LINE 1*******************             npush(result(x, o, y));               *************LINE 2***********************             //npush(result(npop(), opop(), npop()));      }     ostack[++otop] = op;  }  int precedence(char op){ //function 5     if(op == '+' || op == '-')         return 1;     else if (op == '*' || op == '/')         return 2;     else          return 0; //sentinel case }  int result(int x, char o, int y){ //for an operation y op x i.e. reverse order     switch(o){         case '+': return y + x;         case '-': return y - x;         case '*': return y * x;         case '/': return (y / x);     } }  void stackInput(char c){ //Pushes operators to ostack and operands to nstack     int val = c - '0';      //if an integer     if (val >= 0 && val < 10){          npush(val);     }      //else, an operator     else{          opush(c);     } }  void evaluate(){     while(otop!=0){         int x = npop(); int y = npop(); char o = opop();         npush(result(x, o, y));         //npush(result(npop(), opop(), npop()));     } }   void main() {     char expr[10] = "8/1/2";     int i;     for (i = 0; i< strlen(expr); ++i){     stackInput(expr[i]);     } evaluate(); printf("Result = %d", nstack[0]); } 

When I run the code by using function calls as arguments for the function result(), I get a floating point exception. On the other hand, when I save the popped values in separate variables and pass them as arguments to result(), I do get the expected output.

I would appreciate if someone could explain the anomaly. Generally, we would expect the values to be passed in order (which I came to realize doesn’t happen when I passed function calls and tried printing the received values).

Forgive me if this question is off-topic here. I believe it isn’t since the question is about what happens inside during execution.

ret2libc calling function arguments order

while I was studying the ret2libc a doubt as arisen. I saw that peoples in their tutorials use the following: call_to_function + ret addr+ arguments. For example I understand that if I want to execute system function from libc I can use the following scheme: system_address(that overwrite eip) + addrsssOf_exit_function + arguments. What I didn’t understand instead is why we use this order if before calling a function the arguments need to be already on the stack?. If I overwrite the eip the next instruction called is system but we don’t have already the arguments, right? What’s I’m missing?

Error “TypeError: Serial() takes no arguments” en Python (pySerial, Raspbian)

estoy intentando leer los bytes que entran mediante un usb (el cable que está enchufado en el usb es un conversor usb-serial232).

Yo no se mucho de python,y he estado buscando ayuda por internet hasta que me he encontrado con el siguiente código:

import serial ser = serial.Serial('/dev/ttyUSB0', 9600)  while True:     data = ser.readline()     if data:         print(data) 

Cuando ví esto me dio buenas vibraciones, ya que la forma que tengo de leer el mbus es con una librería de Linux que utiliza el ttyISB0.

La 1era vez que lo ejecuté me pedía que instalase la librería ‘serial’. Como estoy trabajando con PyCharm, con hacer Ctrl-Mayus-Intro se me instalaba sola.

Una vez instalé serial, me dio el error de ‘Serial’ (S mayúscula). Total, que lo instalé también.

Pero me sigue dando el siguiente error:

/root/PycharmProjects/prueba1/venv/bin/python /root/PycharmProjects/prueba1/file1.py Traceback (most recent call last):   File "/root/PycharmProjects/prueba1/file1.py", line 2, in <module>     ser = serial.Serial('/dev/ttyUSB0', 9600) TypeError: Serial() takes no arguments  Process finished with exit code 1 

Y ya no se que hacer, he estado mirando en internet, pero no hay nada sobre ese error.

Toda ayuda será bien recibida. Un Saludo