I'm creating a login and registration for my app. Every time I run this code I recieve this error:
#import <UIKit/UIKit.h>
#import "THRAppDelegate.h"
int main(int argc, char *argv[])
{
#autoreleasepool {
return UIApplicationMain(argc, argv, nil, NSStringFromClass([THRAppDelegate class]));
}
}
Can someone tell me what it means? I believe its happening from the server side(PHP)
Also the JSON response I keep getting is error: False
Here is the php code:
function registerUser($email, $name, $username, $password){
$uuid = uniqid('', true);
$hash = hashSSHA($password);
$encrypted_password = $hash["encrypted"]; //encrypted password
$salt = $hash["salt"]; //salt password
$register = query("SELECT email FROM users WHERE email='$email' limit 1");
if (count($register['result'])>0) {
errorJson('This email is already registered. Try to login or recover your password.');
}
//try to register the user
$result = query("INSERT INTO users(unique_id, name, email, username, encrypted_password, salt) VALUES('$uuid', '$name', '$email','$username', '$encrypted_password', '$salt', NOW())");
if (!$result['error']) {
//success
login($email, $password);
} else {
//error
//errorJson('Sorry, something went wrong :( . Please try again later.');
errorJson(mysql_error());
}
}
function login($email, $password){
$result = query("SELECT uid, email FROM users WHERE email ='%s' AND password ='%s' limit 1", $email, $password);
if (count($result['result'])>0) {
$salt = $result['salt'];
$encrypted_password = $result['encrypted_password'];
$hash = checkhashSSHA($salt, $password);
//checking for password equality
if ($encrypted_password == $hash) {
//user authentication details are correct
return $result;
//authorized
$_SESSION['uid'] = $result['result'][0]['uid'];
print json_encode($result);
}
} else {
//not authorized
errorJson('Wrong Email and password combination.');
}
}
function hashSSHA($password){
$salt = sha1(rand());
$salt = substr($salt, 0,10);
$encrypted = base64_encode(sha1($password . $salt, true) . $salt);
$hash = array("salt" => $salt, "encrypted" => $encrypted);
return $hash;
}
/*
*Decrypting password
*#param salt. pasword
returns hash string
*/
function checkhashSSHA($salt, $password){
$hash = base64_encode(sha1($password.$salt, true) . $salt);
return $hash;
}
Xcode error
2012-10-11 15:04:42.528 Thryfting[1457:c07] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[__NSCFBoolean isEqualToString:]: unrecognized selector sent to instance 0x1883964'
*** First throw call stack:
(0x1752012 0x1577e7e 0x17dd4bd 0x1741bbc 0x174194e 0x6184af 0x618674 0x8b0706 0x8be578 0x8beb50 0x1b5fb 0x1ce4c 0x1e6fb 0xed99 0x1f0753f 0x1f19014 0x1f097d5 0x16f8af5 0x16f7f44 0x16f7e1b 0x2c827e3 0x2c82668 0x4bf65c 0x2bad 0x2ad5 0x1)
libc++abi.dylib: terminate called throwing an exception
You can trace your code by Zombie objects:
⌥⌘R
select the "Diagnostics" tab and click "Enable Zombie Objects":
This turns released objects into NSZombie instances that print console warnings when used again. This is a debugging aid that increases memory use (no object is really released) but improves error reporting.
A typical case is when you over-release an object and you don't know which one:
With zombies: -[UITextView release]: message sent to deallocated instance
Without zombies:
So, as far as I see, your error is
[__NSCFBoolean isEqualToString:]: unrecognized selector....
This means that, somewhere in your code (can't tell you where, since you dont provide it) you are sending isEqualToString message to an object that is not a NSString.
Could you please make a quick search and see where are you sending that message? It could be that you are reading a boolean value but treating it as a NSString. Please, check your code, and verify that you check the type of data before you send that message.
Please, provide the piece of code where that could happen.
Related
I am very new to Groovy and this is an old application where the author is no longer with our organization. None of the previous questions that look similar offered any help. The application needs to send a simple message to the user to warn they are missing an entry before they con continue on.
I have made no fewer than 20 changes from flash.message to confirm. Flash causes the application to jump all the way to the user login function. This confirm is giving a crash message: Error 500: Executing action [submitrequest] of controller [SdrmController] caused exception: Runtime error executing action
def submitrequest = {
def testChecker
testChecker = [params.fullExpName].flatten().findAll { it != null }
log.info('testChecker.size = ' + testChecker.size)
if (testChecker.size > 0) {
if (!confirm('Submitting can not be undone, are you sure?')) return
} else {
if (!confirm('You have to pick an expedition. Please return to your Request and pick at least one expedition.')) return
} else {
return
}
}
// rest of long time working code here
}
Expected Result is a simple message to screen tell the user to pick an "Expedition" from a list and then the code returns to the same point so the user can make the change then hit the submit again.
Then full message:
No signature of method: SdrmController.confirm() is applicable for argument types: (java.lang.String) values: [You have to pick an expedition. Please return to your Request and pick at least one expedition.] Possible solutions: notify(), render(java.lang.String)
-- flash.message worked for our situation.
`legChecker = [params.programLeg].flatten().findAll{it!=null}
if(requestInstance.futurePast == "future" && expChecker.size<1) {
flash.message = " you must select a future expedition "
render(view: 'stepstart', model: [....])
return
}`
I created a custom attribute, inheriting from HandleErrorAttribute:
public class CustomHandleErrorAttribute : HandleErrorAttribute
{
public override void OnException(ExceptionContext filterContext)
{
try
{
Utility.LogAndNotifyOfError(filterContext.Exception, null, true);
}
catch(Exception ex)
{
filterContext.Exception = ex;
}
}
}
, and then registered with:
filters.Add(new CustomHandleErrorAttribute());
This has always worked as intended. However a common problem with my log method is that it uses a custom event log source when writing to the event log, which the app pool account typically doesn't have the permissions to create. Creating the event log source is a simple powershell script, however I wanted to actually include that tidbit in the error:
try
{
log.WriteEntry(error, EventLogEntryType.Error);
}
catch(SecurityException ex1)
{
throw new ErrorHandlerException($"The event log could not be written to due to a SecurityExcption. The likely issue is that the '{eventLogSource}' does not already exist. Please run the following powershell command:\r\n"
+ $"New - EventLog - LogName Application - Source {eventLogSource}", ex1);
}
The problem is that the catch in the OnException is never hit. When debugging, the custom error I throw from LogAndNotifyOfError instead triggers a second call to OnException, and the detail of my ErrorHandlerException is never seen. I want the asp.net error page that comes up to be with my custom error detail rather than the SecurityException that was originally raised.
You can even see the surrounding try in the displayed error:
Edit: Entire log method listed:
public static void LogAndNotifyOfError(Exception ex, String extraInfo, Boolean sendEmail)
{
//if the error handler itself faulted...
if (ex is ErrorHandlerException)
return;
string eventLogName = "Application";
string eventLogSource = "MySourceName";
String error = ex.ToString();
if (error.Length > 28000)
error.Substring(0, 28000);//event log is limited to 32k
error += "\r\n\r\nAdditional Information: \r\n"
+ "Machine Name: " + Environment.MachineName + "\r\n"
+ "Logged in user:" + App.CurrentSecurityContext.CurrentUser?.UserId + "\r\n"
+ extraInfo + "\r\n";
EventLog log = new EventLog(eventLogName);
log.Source = eventLogSource;
try
{
log.WriteEntry(error, EventLogEntryType.Error);
}
catch(SecurityException ex1)
{//this doesn't work - for some reason, OnError still reports the original error.
throw new ErrorHandlerException($"The event log could not be written to due to a SecurityExcption. The likely issue is that the '{eventLogSource}' does not already exist. Please run the following powershell command:\r\n"
+ $"New - EventLog - LogName Application - Source {eventLogSource}", ex1);
}
//if the email-to field has been set...
if (!String.IsNullOrEmpty(App.Config.General.ErrorHandlerSendToAddresses) && sendEmail)
{
//...then send the email
MailMessage email = new MailMessage();
email.To.Add(App.Config.General.ErrorHandlerSendToAddresses);
email.IsBodyHtml = false;
email.Subject = String.Format("Error in {0}", eventLogSource);
email.Body = email.Subject + "\r\n\r\n"
//+ "Note: This error may be occuring continuously, but this email is only sent once per hour, per url, in order to avoid filling your mailbox. Please check the event log for reoccurances and variations of this error.\r\n\r\n"
+ "The error description is as follows: \r\n\r\n"
+ error + "\r\n\r\n";
SmtpClient smtp = new SmtpClient();
smtp.Send(email);
}
}
I figured it out (sort of). It would appear that when the newly throw exception has an inner exception, it is only displaying that inner exception. It does not matter what the type is on the outer or inner exception.
I am trying to query log messages sent via ASL and the NSLog wrapper. Running the below code on an iOS 9 device, I get one response from the ASL query and that is the first log string sent via NSLog. The second string "Hello from asl_log" is not returned by the query, even though it goes to the default ASL client. Any suggestions on what I might be doing wrong with the query or the asl_log call?
// Send test data
NSLog(#"Hello from NSLog");
asl_log(NULL, NULL, ASL_LEVEL_EMERG, "Hello from asl_log");
// Query all logged strings
aslmsg query = asl_new(ASL_TYPE_QUERY);
aslresponse response = asl_search(NULL, query);
asl_free(query);
// Only one message found: "Hello from NSLog"
aslmsg message;
while((message = asl_next(response))) {
const char *msg = asl_get(message, ASL_KEY_MSG);
}
After trying several ways to set ASL_KEY_READ_UID to "-1", following the hint of bk138, I finally came up with the following:
asl_object_t msg = asl_new(ASL_TYPE_MSG);
asl_set(msg, ASL_KEY_READ_UID, "-1");
asl_log(NULL, msg, ASL_LEVEL_EMERG, "Hello from asl_log");
This will make the logs appear in the asl query results.
Hi i have added a new mas action in the sales order grid which allow create batch invoices.
For this my controler file is
<?php
class Iclp_Batchupdate_IndexController extends Mage_Adminhtml_Controller_Action
public function batchinvoiceAction ()
{
$already = " already ";
$refererUrl = $this->getRequest()->getServer('HTTP_REFERER');
$this->loadLayout();
$this->renderLayout();
$orderIds = explode(",",$this->getRequest()->getParam('order_ids'));
foreach ($orderIds as $orderIdss) {
$order = Mage::getModel('sales/order')->load($orderIdss);
//echo $orderIdss ."<br/>";
//echo "already ".$order->getStatusLabel();
try
{
if(!$order->canInvoice())
{
echo Mage::getSingleton('core/session')->addError($orderIdss.$already.$order->getStatusLabel());
}
$invoice = Mage::getModel('sales/service_order', $order)->prepareInvoice();
if (!$invoice->getTotalQty()) {
Mage::throwException(Mage::helper('core')->__('Cannot create an invoice without products.'));
}
$invoice->setRequestedCaptureCase(Mage_Sales_Model_Order_Invoice::CAPTURE_ONLINE);
$invoice->register();
$transactionSave = Mage::getModel('core/resource_transaction')->addObject($invoice)->addObject($invoice->getOrder());
$transactionSave->save();
$order->setState(Mage_Sales_Model_Order::STATE_PROCESSING, true)->save();
//echo "Invoice are created";
}
catch (Mage_Core_Exception $e) {
}
}
//A Success Message
Mage::getSingleton('core/session')->addSuccess("Some success message");
//A Error Message
Mage::getSingleton('core/session')->addError("Some error message");
//A Info Message (See link below)
Mage::getSingleton('core/session')->addNotice("This is just a FYI message...");
//These lines are required to get it to work
session_write_close();
$this->getResponse()->setRedirect($refererUrl);
}
}
every thing is working fine but the problem is it is not printing the error message in foreach in above code
if(!$order->canInvoice())
{
echo Mage::getSingleton('core/session')->addError($orderIdss.$already.$order->getStatusLabel());
}
but the bottom error message are displayed properly. MOreover if i extend the class with front-action than it also prints the foreach messages. Please suggest where i am doing the mistake
You should add your errors and messages to admintml/session and not to core/session when you are in adminhtml. That should display the message correctly. You shouldn't need session_write_close();. There is also no need to echo the message, that should be handled automatically by Magento after the redirect.
There is also no need to call $this->loadLayout(); and $this->renderLayout(); because you are redirecting at the end.
Finally, regarding the redirect, you should not read the referrer yourself, Magento can to that for you more reliably. Just use the $this->_redirectReferer(); method instead of $this->getResponse()->setRedirect($refererUrl);.
I'm working on an Titanium application which displays the contacts in iPhone. When user selects the email property of the user, I'm displaying the email composer window.
But my application is crashing and console displays:
** Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'Attempting to begin a modal transition from <ABPeoplePickerNavigationController: 0xb1b7940> to <MFMailComposeViewController: 0x1508c880> while a transition is already in progress. Wait for viewDidAppear/viewDidDisappear to know the current transition has completed'
*** First throw call stack:
(0x33fb012 0x2e4de7e 0x33fae78 0x923f35 0xf55d05 0xd544f3 0x33ef1bd 0x33ef0d6 0xd481c5 0xd53342 0x1fb1402 0x1fb1dbd 0x1fb1c30 0x11af4e9 0x370b53f 0x371d014 0x370d7d5 0x33a1af5 0x33a0f44 0x33a0e1b 0x31137e3 0x3113668 0xc6a65c 0x33c8 0x27d5)
I'm using the following code:
var values = {cancel:function(){}};
values.fields = ['firstName','email'];
function showContacts()
{
Titanium.Contacts.showContacts(values);
};
values.selectedProperty = function(e) {
if(e.property == 'email')
{
var emailDialog = Titanium.UI.createEmailDialog();
emailDialog.subject = "Hello from Titanium";
emailDialog.toRecipients = [e.value];
emailDialog.messageBody = 'Appcelerator Titanium Rocks!';
if(emailDialog.isSupported())
{
emailDialog.open();
}
}
}
I know this error is because of I'm trying to display the email composer when the contact window is being dismissed.
How to display the email composer after dismissing the contact window?
Please help me. Thanks in advance.
wrap the code in a setTimeout... I use it often when working with animations.
values.selectedProperty = function(e){
setTimeout(function() {
// DO SOMETHING...
}, 200);
};
Finally I find a solution.
I wrote a sleep function and called it in the callback function. It solved my problem and crash is not happening... Hurray !!!
function sleepMyThread(milliseconds)
{
var startTime = new Date().getTime();
while((new Date().getTime() - startTime) < milliseconds)
{
}
}
And added the sleep method as the first statement of callback function.
values.selectedProperty = function(e){
sleepMyThread(777);
//other stuffs
}