Jquery application example

Source: Internet
Author: User
Add a record for the operations in the queue of the Geography Institute: make various functions into sub-menus. The general idea is as follows :.. /csm/conf. configure all the operation commands in php: // Commandtohandlethequeueopration $ execute_to_reconfig $ shell_cgi. & quot ;. escapeshe...

Add a record for the operations on the physical server Queue:

Make the functions into sub-menus. The general idea is as follows:

../Csm/conf. php:

// Command to handle the queue opration

$ Execute_to_reconfig = $ shell_cgi. "". escapeshellarg ("$ QUEUES_BIN/badmin reconfig ");

$ Prepare_to_setenv = $ shell_cgi. "". escapeshellarg ("export LSF_ENVDIR ");

$ List_all_queues_command = $ shell_cgi. "". escapeshellarg ("source/etc/profile; $ QUEUES_BIN/bqueues | $ ROOT_BIN/awk '{if (NR> 1) print $1 }'"); // If source/etc/profile is not added, the system will prompt some environment variables with unset errors.

$ Get_user_queue = $ shell_cgi. "". escapeshellarg ("$ USR_YPBIN/bqueueadm-u % s ");

$ Add_user_to_queue = $ shell_cgi. "". escapeshellarg ("$ USR_YPBIN/bqueueadm-u % s-a % s ");

$ Del_user_from_queue = $ shell_cgi. "". escapeshellarg ("$ USR_YPBIN/bqueueadm-u % s-d % s ");

$ Change_user_to_queue = $ shell_cgi. "". escapeshellarg ("$ USR_YPBIN/bqueueadm-u % s-d % s-a % s ");
 

 

Define the displayed view in the corresponding tpl file. Note that only the view does not include the displayed data.

Similar to: ../csm/addusertoqueue. php actually transmits data to tpl. User Data and queue data are required.

All are passed in from here.

Similar to: js/addusertoqueue. js uses ajax to asynchronously send requests to the processing page, and receives the processing page

Returned value.

Similar: ../csm/addusertoqueue-ajax.php is to receive ajax parameters, the actual execution of the command

.

Note: The $ list_all_queues_command command restricts source/etc/profile to read environment variables,

Otherwise, an error is returned if no value exists in the returned array.

Example in the Js file:

$ (). Ready (function (){

$ ('# Submit_change_user_to_queue'). click (function (){

$. Ajax ({

Url: '../csm/changeusertoqueue-ajax.php ',

Type: 'get ',

Data: 'username = '+ $ (' # usernamelist option: selected '). text () + '& beforqueue =' + $ ('# queueslist_befor option: selected '). text () + '& nowqueue =' + $ ('# queueslist_now option: selected '). text (),

DataType: 'text ',

Success: function (data ){

Alert (data );

},

Error: function (XMLHttpRequest, textStatus, errorThrown ){

Alert (XMLHttpRequest. status );

Alert (XMLHttpRequest. readyState );

Alert (textStatus );

}

});

});

});
 

 


Examples in Changeusertoqueue-ajax.php:

Include_once "../conf. php ";

Include_once "../functions. php ";

Include_once "../csm/conf. php ";

$ Username = $ _ GET ["username"];

$ Beforqueue = $ _ GET ["beforqueue"];

$ Nowqueue = $ _ GET ["nowqueue"];

 

$ Change_user_to_queue = $ change_user_to_queue;

$ Execute_to_reconf = $ execute_to_reconfig;

$ Change_user_to_queue_cmd = sprintf ($ change_user_to_queue, $ username, $ beforqueue, $ nowqueue );

$ Change_user_to_queue_cmd = ConstructShellCommand ($ change_user_to_queue_cmd );

$ Execute_to_reconf_cmd = ConstructShellCommand ($ execute_to_reconf );

// Echo $ execute_to_reconf_cmd;

ExecuteCommand ($ change_user_to_queue_cmd, $ output, $ return );

If ($ return = 0 ){

ExecuteCommand ($ execute_to_reconf_cmd, $ output, $ return );

If ($ return = 0 ){

Echo "user". $ username. "You have successfully changed from queue". $ beforqueue. "To queue". $ nowqueue! ";

} Else {

Echo "failed to execute the command to make the configuration take effect! ";

}

} Else {

Echo "An error occurred while adding the user to the specified queue. Please contact the administrator! ";

}

?>
 

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.