phpinfo to check server configuration - grep

I would like to ask how to check server configuration (CPU, system, RAM) by "grep" phpinfo sub-information (or any other php commands), if any.
<? if (phpinfo system info == "something A"
&& phpinfo CPU info == "something B"
&& phpinfo RAM info == "something C") {
//Redirect to index.php and not allowed to access in-pages.
header('Location: index.php');
}
?>

// Get CPU name
$cpuinfo = file('/proc/cpuinfo');
$cpu = substr($cpuinfo[4],13);
// Get memory size
$meminfo = file('/proc/meminfo');
$memsize = substr($meminfo[0],10);
// Get IP address
$arp = file('/proc/net/arp');
$arp1 = explode(" ", $arp[1]);
$ipv4 = $arp1[0];
if (strpos($ipv4,[your device ip address]) !== false
&& strpos($memsize,[your device memory size]) !== false
&& strpos($cpu,[your device CPU name]) !== false) {
// go
}

Related

Application crashes in IBM Mobilfirst

I am developing a hybrid application with IBM Worklight 7.0.
I am searching with the following command from the local store with the following code. This code works by pressing each button on the screen. After the user has been running for a while, the application crashes. Does this cause a search with "like" command? Does the this code work asynchronously?
My Code :
var queryPart = WL.JSONStore.QueryPart().like('name', str).like('type',
typeStr);
WL.JSONStore.get(allReason.name).advancedFind([queryPart]).
then(function(arrayResults) { ... }
Logcat :
E/SQLiteLog( 1481): (10) POSIX Error : 11 SQLite Error : 3850
D/NONE (26304): reasons event binded!
D/PhoneWindow(26304): *FMB* installDecor mIsFloating : true
D/PhoneWindow(26304): *FMB* installDecor flags : 8388610
W/ResourceType(26304): Failure getting entry for 0x01080ad0 (t=7 e=2768)
(error -75)
D/InputDispatcher( 898): Focus left window: 26304
D/InputDispatcher( 898): Focus entered window: 26304
D/PhoneWindow(26304): *FMB* isFloatingMenuEnabled mFloatingMenuBtn : null
D/PhoneWindow(26304): *FMB* isFloatingMenuEnabled return false
D/NONE (26304): Request [/apps/services/api/Bukalemun/android/ heartbeat]
I/System.out(26304): Thread-1548(ApacheHTTPLog):isSBSettingEnabled false
I/System.out(26304): Thread-1548(ApacheHTTPLog):isShipBuild true
I/System.out(26304): Thread-1548(ApacheHTTPLog):SMARTBONDING_ENABLED is
false
I/System.out(26304): Thread-1548(ApacheHTTPLog):SmartBonding Enabling is
false, SHIP_BUILD is true, log to file is false, DBG is false
D/Netd ( 256): getNetworkForDns: using netid 0 for uid 10187
I/System.out(26304): pool-5-thread-6 calls detatch()
D/HttpPostRequestSender(26304): WLHybridRequestSender.run in
WLHybridRequestSender.java:42 :: Sending request
http://
xxxx.org.tr:80 /Bukalemun/apps/services/api/Bukalemun/android/heartbeat
E/NONE (26304): [/apps/services/api/Bukalemun/android/heartbeat] Host is
not responsive. Try to manually access the URL through the android emulator
browser to verify connectivity.
D/NONE (26304): Failed to send heartbeat
Below is the code that pulls the data to the selectboxes.
var queryPart = WL.JSONStore.QueryPart().like('name', regexStr3).like('type',
asansorTipi);
WL.JSONStore.get(allReason.name).advancedFind([queryPart]).then(function(arrayResults) {
// if data not present , get the data from DB
if (arrayResults.length == 0) {
} else {
var myLikeReasonId = arrayResults[0].json.reasonid;
if(myLikeReasonId != null && myLikeReasonId != ' '){
tmpVal = myLikeReasonId +','+ '2';
reasonValue = tmpVal.split(',');
$("#"+reasonValue[0]).each ( function() {
if(reasonValue[1] == 1 || reasonValue[1] == 2 || reasonValue[1] == 3){
$(this).val(reasonValue[1]).change();
if(reasonValue[1] == "2") {
uygundegil = true;
uygunDegilArray.push(reasonValue[0]);
} else if(reasonValue[1] == "3"){
uygulanamaz = true;
uygulanamazArray.push(reasonValue[0]);
} else {
uygun = true;
uygunArray.push(reasonValue[0]);
}
}
});
} else {
WL.Logger.error("collection filter returns null result.");
}
}
}).fail(function(errorObject) {
WL.Logger.error("fail" + errorObject);
});
By looking up the error code: 3850. It seems there is an IO lock problem. I would surround your code with a try{}catch() and if you receive the 3850 error, wait and try the process again.
The SQLITE_IOERR_LOCK error code is an extended error code for SQLITE_IOERR indicating an I/O error in the advisory file locking logic. Usually an SQLITE_IOERR_LOCK error indicates a problem obtaining a PENDING lock. However it can also indicate miscellaneous locking errors on some of the specialized VFSes used on Macs.

Basic Use of Tmp-String-0

I'm trying to use the Tmp-String-0 variable within a dhcp site enabled.
My version is old and in production (2.1.12).
Here is the content of my dhcp file.
dhcp DHCP-Discover {
update control{
Tmp-String-0 = "%{sql: CALL sqlprocedure('%{DHCP-Agent-Circuit-Id}','%{DHCP-Gateway-IP-Address}','%{DHCP-Relay-Remote-Id}')}"
}
if(control:Tmp-String-0 != "" ) {
update reply {
DHCP-Message-Type = DHCP-Offer
}
}
else {
update reply {
DHCP-Message-Type = DHCP-NAK
}
}
update reply {
DHCP-Your-IP-Address = "control:Tmp-String-0"
}
}
And here is the result I have in debug mode.
rlm_sql_mysql: query: CALL sqlprocedure('value','1.2.3.4','value')
sql_xlat finished
rlm_sql (sql): Released sql socket id: 4
expand: %{sql: CALL sqlprocedure('%{DHCP-Agent-Circuit-Id}','%{DHCP-Gateway-IP-Address}','%{DHCP-Relay-Remote-Id}')} -> 10.10.10.10
++[control] returns noop
++? if (control:Tmp-String-0 != "" )
? Evaluating (control:Tmp-String-0 != "" ) -> TRUE
++? if (control:Tmp-String-0 != "" ) -> TRUE
++- entering if (control:Tmp-String-0 != "" ) {...}
+++[reply] returns noop
++- if (control:Tmp-String-0 != "" ) returns noop
++ ... skipping else for request 445: Preceding "if" was taken
ERROR: Failed parsing value "control:Tmp-String-0" for attribute DHCP-Your-
IP-Address: Failed to find IP address for control:Tmp-String-0
++[reply] returns fail
I don't know what is wrong with that maybe I should use the operator "=" instead of ":=".
What do you think?
Many thanks, Will
Did you try the following
update reply {
DHCP-Your-IP-Address = "Tmp-String-0"
}

Why i dont get an answer from my Host in Icinga?

(Bild)No Answer from Zone
(Bild)All other Services i can check
apply Service "load" {
import "generic-service"
check_command = "load"
if (host.name != NodeName){
command_endpoint = host.name}
assign where host.name == NodeName
assign where host.vars.os == "Linux" && host.vars.zone == "Cluster"
When checking the Icinga service runs on the targethost I have done it exactly the same, only that I get here a result back but not with "load".
apply Service "icinga" {
import "30-mins"
check_command = "icinga"
assign where host.name == NodeName
assign where host.vars.os == "Linux" && host.vars.zone == "Cluster"

my data is not updating on online server .the data is updating on local

<?php include('../include/config.php');
if(empty($_SESSION['sus']) && empty($_SESSION['spa']))
{
echo "<script>window.location='index.php'</script>";
}
/*##########################################*/
$id=$_GET['id'];
if(isset($_POST['save']))
{
define ("MAX_SIZE","1000");
function getExtension($str)
{
$i = strrpos($str,".");
if (!$i) { return ""; }
$l = strlen($str) - $i;
$ext = substr($str,$i+1,$l);
return $ext;
}
$errors=0;
$image=$_FILES['image']['name'];
if ($image)
{
$filename = stripslashes($_FILES['image']['name']);
$extension = getExtension($filename);
$extension = strtolower($extension);
if (($extension != "jpg") && ($extension != "jpeg") && ($extension != "png")
&& ($extension != "gif")&& ($extension != "JPG") && ($extension != "JPEG")
&& ($extension != "PNG") && ($extension != "GIF"))
{
echo '<h3>Unknown extension!</h3>';
$errors=1;
}
else
{
$size=filesize($_FILES['image']['tmp_name']);
if ($size > MAX_SIZE*1024)
{
echo '<h4>You have exceeded the size limit!</h4>';
$errors=1;
}
$image_name=time().'.'.$extension;
$newname="img/".$image_name;
$copied = copy($_FILES['image']['tmp_name'], $newname);
if (!$copied)
{
echo '<h3>Copy unsuccessfull!</h3>';
$errors=1;
}
else //echo '<h3>uploaded successfull!</h3>';
$title=$_POST['title'];
$content=$_POST['content'];
$sql="update home set title='$title',content='$content',img='$newname' where id='$id'";
$res=mysql_query($sql);
if($res)
{
echo "<script>alert('You have successfully Uploaded')</script>";
echo "<script>window.location='admin_home.php'</script>";
}
else{
echo "failed submit";
echo "<script>window.location='admin_home.php'</script>";
}
}
}
}
?>
actully i updating code on local host it is updating but in online server it is not updating how to update the code
actully i updating code on local host it is updating but in online server it is not updating how to update the code
actully i updating code on local host it is updating but in online server it is not updating how to update the code
What error code do you get?
echo $_FILES['image']['error']
0 => 'There is no error, the file uploaded with success'
1 => 'The uploaded file exceeds the upload_max_filesize directive in php.ini'
2 => 'The uploaded file exceeds the MAX_FILE_SIZE directive that was specified in the HTML form'
3 => 'The uploaded file was only partially uploaded'
4 => 'No file was uploaded'
6 => 'Missing a temporary folder'
7 => 'Failed to write file to disk.'
8 => 'A PHP extension stopped the file upload.'

Apple Push Notification Limits

I'm developing an iOS application that uses push notifications, I have implemented the app and the server side and it works great if I send just one or two notifications. The problem comes when I need to send the same notification to all of my users, the notifications only get to the first users of the loop.
I'm in sandbox, so I wonder if there is any limit for sandbox environment, because I have read that the APNS service has no limit.
Any idea?
Thanks in advance,
UPDATED SOLUTION:
I had to check apple response, I was sending push to invalid tokens and Apple disconnected me from server. With the following function I have solved the problem.
Thanks #Eran and this post
/* FUNCTION to check if there is an error response from Apple
* Returns TRUE if there was and FALSE if there was not
*/
public function checkAppleErrorResponse($fp) {
//byte1=always 8, byte2=StatusCode, bytes3,4,5,6=identifier(rowID).
// Should return nothing if OK.
//NOTE: Make sure you set stream_set_blocking($fp, 0) or else fread will pause your script and wait
// forever when there is no response to be sent.
$apple_error_response = fread($fp, 6);
if ($apple_error_response) {
// unpack the error response (first byte 'command" should always be 8)
$error_response = unpack('Ccommand/Cstatus_code/Nidentifier', $apple_error_response);
if ($error_response['status_code'] == '0') {
$error_response['status_code'] = '0-No errors encountered';
} else if ($error_response['status_code'] == '1') {
$error_response['status_code'] = '1-Processing error';
} else if ($error_response['status_code'] == '2') {
$error_response['status_code'] = '2-Missing device token';
} else if ($error_response['status_code'] == '3') {
$error_response['status_code'] = '3-Missing topic';
} else if ($error_response['status_code'] == '4') {
$error_response['status_code'] = '4-Missing payload';
} else if ($error_response['status_code'] == '5') {
$error_response['status_code'] = '5-Invalid token size';
} else if ($error_response['status_code'] == '6') {
$error_response['status_code'] = '6-Invalid topic size';
} else if ($error_response['status_code'] == '7') {
$error_response['status_code'] = '7-Invalid payload size';
} else if ($error_response['status_code'] == '8') {
$error_response['status_code'] = '8-Invalid token';
} else if ($error_response['status_code'] == '255') {
$error_response['status_code'] = '255-None (unknown)';
} else {
$error_response['status_code'] = $error_response['status_code'].'-Not listed';
}
echo '<br><b>+ + + + + + ERROR</b> Response Command:<b>' . $error_response['command'] . '</b> Identifier:<b>' . $error_response['identifier'] . '</b> Status:<b>' . $error_response['status_code'] . '</b><br>';
echo 'Identifier is the rowID (index) in the database that caused the problem, and Apple will disconnect you from server. To continue sending Push Notifications, just start at the next rowID after this Identifier.<br>';
return true;
}
return false;
}
The likely problem is that some of the device tokens you are using are invalid (remember that production device tokens are invalid in sandbox environment and vica versa). Sending a notification to an invalid device token will close your socket to the APN servers. All the notifications written to that socket after the invalid one will be discarded until you open a new socket.
You can try to read error responses from Apple to find out which device token is invalid.
You should definitely read the error checking section of the Tech Note that was already mentioned by other people here.
There is no limit on the number of users you can send to, you just have to make sure that the size of the message you send it below that limit, which as Kirti stated, is around 2048 bytes.
There is also no limit to how frequently you can send messages, but I would not recommend sending things too often.
Might want to check this out:
There are no caps or batch size limits for using APNs. The iOS 6.1
press release stated that APNs has sent over 4 trillion push
notifications since it was established. It was announced at WWDC
2012 that APNs is sending 7 billion notifications daily.
If you're seeing throughput lower than 9,000 notifications per
second, your server might benefit from improved error handling
logic.

Resources