_id
stringlengths 2
7
| title
stringlengths 3
151
| partition
stringclasses 3
values | text
stringlengths 83
13k
| language
stringclasses 1
value | meta_information
dict |
---|---|---|---|---|---|
q256000 | QuickBooks_Driver.authResolve | test | final public function authResolve($ticket)
{
$err = '';
$this->_callHook(QUICKBOOKS_DRIVER_HOOK_AUTHRESOLVE, $ticket, $err, array());
return $this->_authResolve($ticket);
} | php | {
"resource": ""
} |
q256001 | QuickBooks_Driver.authCheck | test | final public function authCheck($ticket)
{
$err = '';
$this->_callHook(QUICKBOOKS_DRIVER_HOOK_AUTHCHECK, $ticket, $err, array());
return $this->_authCheck($ticket);
} | php | {
"resource": ""
} |
q256002 | QuickBooks_Driver.authLogout | test | final public function authLogout($ticket)
{
$err = '';
$this->_callHook(QUICKBOOKS_DRIVER_HOOK_AUTHLOGOUT, $ticket, $err, array());
return $this->_authLogout($ticket);
} | php | {
"resource": ""
} |
q256003 | QuickBooks_Driver.authCreate | test | final public function authCreate($username, $password, $company_file = null, $wait_before_next_update = null, $min_run_every_n_seconds = null)
{
$hookdata = array(
'username' => $username,
'password' => $password,
'qb_company_file' => $company_file,
'qbwc_wait_before_next_update' => $wait_before_next_update,
'qbwc_min_run_every_n_seconds' => $min_run_every_n_seconds,
);
$err = '';
$this->_callHook(QUICKBOOKS_DRIVER_HOOK_AUTHCREATE, null, $err, $hookdata);
return $this->_authCreate($username, $password, $company_file, $wait_before_next_update, $min_run_every_n_seconds);
} | php | {
"resource": ""
} |
q256004 | QuickBooks_Driver.initialize | test | public function initialize($options)
{
$hookdata = array(
'options' => $options,
);
$err = '';
$this->_callHook(QUICKBOOKS_DRIVER_HOOK_INITIALIZE, null, $err, $hookdata);
return $this->_initialize($options);
} | php | {
"resource": ""
} |
q256005 | QuickBooks_Driver.initialized | test | public function initialized()
{
$hookdata = array();
$err = '';
$this->_callHook(QUICKBOOKS_DRIVER_HOOK_INITIALIZED, null, $err, $hookdata);
return $this->_initialized();
} | php | {
"resource": ""
} |
q256006 | QuickBooks_Driver.log | test | final public function log($msg, $ticket = null, $lvl = QUICKBOOKS_LOG_NORMAL)
{
/*
$hookdata = array(
'message' => $msg,
'level' => $lvl,
);
$err = '';
$this->_callHook(QUICKBOOKS_DRIVER_HOOK_LOG, $ticket, $err, $hookdata);
*/
if (is_null($lvl) or $this->_loglevel >= $lvl)
{
return $this->_log($msg, $ticket, $lvl);
}
return true;
} | php | {
"resource": ""
} |
q256007 | QuickBooks_Driver._callHook | test | final protected function _callHook($hook, $ticket, &$err, $hook_data)
{
$user = '';
if ($ticket)
{
$user = (string) $this->_authResolve($ticket);
}
// Call the hook
QuickBooks_Callbacks::callHook($this, $this->_hooks, $hook, null, $user, $ticket, $err, $hook_data, null, __FILE__, __LINE__);
if ($err)
{
// Log errors reporting by hooks
$this->errorLog($ticket, QUICKBOOKS_ERROR_HOOK, $err);
}
return true;
} | php | {
"resource": ""
} |
q256008 | QuickBooks_IPP_Federator.connectOAuth | test | public function connectOAuth($provider, $token, $pem_key, $encryption_key, $app_username, $app_tenant, $auth_id_pseudonym, $realm_id_pseudonym, $realm, $flavor)
{
if (!$this->_driver)
{
$this->_log('Could not connect to OAuth, no DRIVER storage instance.');
return false;
}
$url = QuickBooks_IPP_Federator::URL_OAUTH;
// First we need to push the request data into the OAuth storage
$this->_driver->oauthRequestWrite(
$app_username,
$app_tenant,
$auth_id_pseudonym,
$realm_id_pseudonym);
$params = array(
'xoauth_service_provider_id' => $provider,
'xoauth_auth_id_pseudonym' => $auth_id_pseudonym,
'xoauth_realm_id_pseudonym' => $realm_id_pseudonym,
);
// Create our OAuth instance class
$OAuth = new QuickBooks_IPP_OAuth(
$token, // The "consumer key" in this case is our application token
''); // There is no consumer secret
$OAuth->signature(QuickBooks_IPP_OAuth::SIGNATURE_RSA, $pem_key);
// Sign the request
$sign = $OAuth->sign(QuickBooks_IPP_OAuth::METHOD_GET, $url, null, null, $params);
// Now make our HTTP request to get the OAuth tokens
$HTTP = new QuickBooks_HTTP($sign[2]);
$HTTP->useDebugMode($this->_debug);
$data = $HTTP->GET();
$this->_log('OAuth HTTP request: [' . $HTTP->lastRequest() . ']');
$this->_log('OAuth HTTP response: [' . $HTTP->lastResponse() . ']');
if ($data)
{
$tmp = array();
parse_str($data, $tmp);
if (!empty($tmp['oauth_token']) and
!empty($tmp['oauth_token_secret']))
{
// Store the OAuth tokens
$this->_log('Storing OAuth tokens...');
return $this->_driver->oauthAccessWrite(
$encryption_key,
$auth_id_pseudonym,
$tmp['oauth_token'],
$tmp['oauth_token_secret'],
$realm,
$flavor);
}
}
return false;
} | php | {
"resource": ""
} |
q256009 | QuickBooks_WebConnector_Handlers._defaults | test | protected function _defaults($config)
{
$url = '?';
if (isset($_SERVER['REQUEST_URI']))
{
$url = $_SERVER['REQUEST_URI'];
}
$defaults = array(
'qb_company_file' => null, // To force a specific company file to be used
'qbwc_min_version' => null, // Minimum version of the QBWC that must be used to connect
'qbwc_wait_before_next_update' => null, // Tell the QBWC to wait this number of seconds before doing another update
'qbwc_min_run_every_n_seconds' => null, // Tell the QBWC to run every n seconds (overrides whatever was in the .QWC web connector configuration file)
'qbwc_version_warning_message' => null, // Not implemented...
'qbwc_version_error_message' => null, // Not implemented...
'qbwc_interactive_url' => null, // Provide the URL for an interactive session to the QuickBooks Web Connector
'autoadd_missing_requestid' => true,
'check_valid_requestid' => true,
'server_version' => 'PHP QuickBooks SOAP Server v' . QUICKBOOKS_PACKAGE_VERSION . ' at ' . $url, // Server version string
'authenticate' => null, // If you want to use some custom authentication scheme (and not the quickbooks_user MySQL table) you can specify your own function here
'authenticate_dsn' => null, // (backward compat. for 'authenticate')
'map_application_identifiers' => true, // Try to map web application IDs to QuickBooks ListIDs/TxnIDs
'allow_remote_addr' => array(),
'deny_remote_addr' => array(),
'convert_unix_newlines' => true,
'deny_concurrent_logins' => true,
'deny_concurrent_timeout' => 60,
'deny_reallyfast_logins' => true,
'deny_reallyfast_timeout' => 600,
'masking' => true,
);
$config = array_merge($defaults, $config);
// Make sure this is an *array* of addresses to allow
if (!is_array($config['allow_remote_addr']))
{
$config['allow_remote_addr'] = array( $config['allow_remote_addr'] );
}
// Make sure this is an *array* of addresses to deny
if (!is_array($config['deny_remote_addr']))
{
$config['deny_remote_addr'] = array( $config['deny_remote_addr'] );
}
$config['autoadd_missing_requestid'] = (boolean) $config['autoadd_missing_requestid'];
$config['check_valid_requestid'] = (boolean) $config['check_valid_requestid'];
$config['map_application_identifiers'] = (boolean) $config['map_application_identifiers'];
$config['convert_unix_newlines'] = (boolean) $config['convert_unix_newlines'];
$config['deny_concurrent_logins'] = (boolean) $config['deny_concurrent_logins'];
$config['deny_concurrent_timeout'] = (int) max(1, $config['deny_concurrent_timeout']);
$config['deny_reallyfast_logins'] = (boolean) $config['deny_reallyfast_logins'];
$config['deny_reallyfast_timeout'] = (int) max(1, $config['deny_reallyfast_timeout']);
return $config;
} | php | {
"resource": ""
} |
q256010 | QuickBooks_WebConnector_Handlers._handleRecurringEvents | test | protected function _handleRecurringEvents($ticket)
{
if ($user = $this->_driver->authResolve($ticket))
{
while ($next = $this->_driver->recurDequeue($user, true))
{
//$this->_driver->log('Dequeued a recurring event, enqueuing!', $ticket, QUICKBOOKS_LOG_VERBOSE);
$this->_log('Dequeued a recurring event, enqueuing!', $ticket, QUICKBOOKS_LOG_VERBOSE);
$extra = null;
if ($next['extra'])
{
$extra = unserialize($next['extra']);
}
//print_r($next);
$hookerr = '';
$this->_callHook($ticket,
QUICKBOOKS_HANDLERS_HOOK_RECURRING,
null, //$this->_constructRequestID($next['qb_action'], $next['ident']),
$next['qb_action'],
$next['ident'],
$extra,
$hookerr);
// $ticket, $hook, $requestID, $action, $ident, $extra, &$err, $xml = '', $qb_identifiers = array()
//print_r($next);
//exit;
// (boolean) $next['replace']
// $user, $action, $ident, $replace = true, $priority = 0, $extra = null, $qbxml = null
$this->_driver->queueEnqueue($user, $next['qb_action'], $next['ident'], true, (int) $next['priority'], $extra, $next['qbxml']);
}
return true;
}
return false;
} | php | {
"resource": ""
} |
q256011 | QuickBooks_WebConnector_Handlers._extractIdentifiers | test | protected function _extractIdentifiers($xml)
{
$fetch_tagdata = array(
'ListID',
'TxnID',
'OwnerID',
'TxnLineID',
'EditSequence',
'FullName',
'Name',
'RefNumber',
);
$fetch_attributes = array(
'requestID',
'iteratorID',
'iteratorRemainingCount',
'metaData',
'retCount',
'statusCode',
'statusSeverity',
'statusMessage',
'newMessageSetID',
'messageSetStatusCode',
);
$list = array();
foreach ($fetch_tagdata as $tag)
{
if (false !== ($start = strpos($xml, '<' . $tag . '>')) and
false !== ($end = strpos($xml, '</' . $tag . '>')))
{
$list[$tag] = substr($xml, $start + 2 + strlen($tag), $end - $start - 2 - strlen($tag));
}
}
foreach ($fetch_attributes as $attribute)
{
if (false !== ($start = strpos($xml, ' ' . $attribute . '="')) and
false !== ($end = strpos($xml, '"', $start + strlen($attribute) + 3)))
{
$list[$attribute] = substr($xml, $start + strlen($attribute) + 3, $end - $start - strlen($attribute) - 3);
}
}
return $list;
} | php | {
"resource": ""
} |
q256012 | QuickBooks_WebConnector_Handlers._extractStatusCode | test | protected function _extractStatusCode($xml)
{
if (false !== ($start = strpos($xml, ' statusCode="')) and
false !== ($end = strpos($xml, '"', $start + 13)))
{
return substr($xml, $start + 13, $end - $start - 13);
}
return QUICKBOOKS_ERROR_OK;
} | php | {
"resource": ""
} |
q256013 | QuickBooks_WebConnector_Handlers._extractStatusMessage | test | protected function _extractStatusMessage($xml)
{
if (false !== ($start = strpos($xml, ' statusMessage="')) and
false !== ($end = strpos($xml, '"', $start + 16)))
{
return substr($xml, $start + 16, $end - $start - 16);
}
return '';
} | php | {
"resource": ""
} |
q256014 | QuickBooks_WebConnector_Handlers._callMappedFunction | test | protected function _callMappedFunction($which, $user, $requestID, $action, $ident, $extra, &$err, $last_action_time, $last_actionident_time, $xml_or_version = '', $qb_identifier_or_locale = array(), $qbxml = null)
{
if ($which == 0)
{
return QuickBooks_Callbacks::callRequestHandler($this->_driver, $this->_map, $requestID, $action, $user, $ident, $extra, $err, $last_action_time, $last_actionident_time, $xml_or_version, $qb_identifier_or_locale, $this->_callback_config, $qbxml);
}
else if ($which == 1)
{
return QuickBooks_Callbacks::callResponseHandler($this->_driver, $this->_map, $requestID, $action, $user, $ident, $extra, $err, $last_action_time, $last_actionident_time, $xml_or_version, $qb_identifier_or_locale, $this->_callback_config, $qbxml);
}
$err = 'Request for a mapped function could not be fulfilled, invalid $which parameter.';
return false;
} | php | {
"resource": ""
} |
q256015 | QuickBooks_WebConnector_Handlers._callHook | test | protected function _callHook($ticket, $hook, $requestID, $action, $ident, $extra, &$err, $xml = '', $qb_identifiers = array(), $hook_data = array())
{
$user = '';
if ($ticket)
{
$user = $this->_driver->authResolve($ticket);
}
// Call the hook
$ret = QuickBooks_Callbacks::callHook($this->_driver, $this->_hooks, $hook, $requestID, $user, $ticket, $err, $hook_data, $this->_callback_config, __FILE__, __LINE__);
// If the hook reported an error, log the error
if ($err)
{
$errerr = '';
$this->_handleError($ticket, QUICKBOOKS_ERROR_HOOK, $err, $requestID, $action, $ident, $extra, $errerr, $xml, $qb_identifiers);
}
return true;
} | php | {
"resource": ""
} |
q256016 | QuickBooks_WebConnector_Handlers._handleError | test | protected function _handleError($ticket, $errnum, $errmsg, $requestID, $action, $ident, $extra, &$err, $xml = '', $qb_identifiers = array())
{
// , $requestID, $user, $action, $ident, $extra, &$err, $xml, $qb_identifier
// Call the error handler (if one is set)
$errmsg = html_entity_decode($errmsg);
// First, set the status of the item to error
/*
if ($action and $ident)
{
$this->_driver->queueStatus($ticket, $action, $ident, QUICKBOOKS_STATUS_ERROR, $errnum . ': ' . $errmsg);
}
*/
if ($requestID)
{
$this->_driver->queueStatus($ticket, $requestID, QUICKBOOKS_STATUS_ERROR, $errnum . ': ' . $errmsg);
}
// Log the last error (for the ticket)
$this->_driver->errorLog($ticket, $errnum, $errmsg);
//$this->_driver->log('Attempting to handle error: ' . $errnum . ', ' . $errmsg);
$this->_log('Attempting to handle error: ' . $errnum . ', ' . $errmsg, $ticket, QUICKBOOKS_LOG_NORMAL);
// By default, we don't want to continue if the error is not handled
$continue = false;
// Get username of user which experienced the error
$user = $this->_driver->authResolve($ticket);
// CALL THE ERROR HANDLER
$err = '';
$continue = QuickBooks_Callbacks::callErrorHandler($this->_driver, $this->_onerror, $errnum, $errmsg, $user, $requestID, $action, $ident, $extra, $err, $xml, $this->_callback_config);
// $Driver, $errmap, $errnum, $errmsg, $user, $action, $ident, $extra, &$errerr, $xml, $callback_config
if ($err)
{
// Log error messages returned by the error handler
//$this->_driver->log('An error occured while handling error: ' . $errnum . ': ' . $errmsg . ': ' . $err, $ticket, QUICKBOOKS_LOG_NORMAL);
$this->_log('An error occured while handling error: ' . $errnum . ': ' . $errmsg . ': ' . $err, $ticket, QUICKBOOKS_LOG_NORMAL);
$this->_driver->errorLog($ticket, QUICKBOOKS_ERROR_HANDLER, $err);
}
// Log the last error (for the log)
//$this->_driver->log('Handled error: ' . $errnum . ': ' . $errmsg . ' (handler returned: ' . $continue . ')', $ticket, QUICKBOOKS_LOG_NORMAL);
$this->_log('Handled error: ' . $errnum . ': ' . $errmsg . ' (handler returned: ' . $continue . ')', $ticket, QUICKBOOKS_LOG_NORMAL);
// Update the queue status
//if ($action and $ident)
if ($requestID and
$continue)
{
//$this->_driver->queueStatus($ticket, $action, $ident, QUICKBOOKS_STATUS_HANDLED, $errnum . ': ' . $errmsg);
$this->_driver->queueStatus($ticket, $requestID, QUICKBOOKS_STATUS_HANDLED, $errnum . ': ' . $errmsg);
}
return $continue;
} | php | {
"resource": ""
} |
q256017 | Quickbooks.enqueue | test | public function enqueue($action, $ident, $priority = 0, $extra = null, $user = null)
{
$Queue = new QuickBooks_WebConnector_Queue($this->_dsn);
return $Queue->enqueue($action, $ident, $priority, $extra, $user);
} | php | {
"resource": ""
} |
q256018 | QuickBooks_IPP_Service_Item.findByName | test | public function findByName($Context, $realmID, $name)
{
$IPP = $Context->IPP();
if ($IPP->flavor() == QuickBooks_IPP_IDS::FLAVOR_DESKTOP)
{
for ($i = 0; $i < 999; $i++)
{
$list = $this->findAll($Context, $realmID, $name, $i, 50);
foreach ($list as $Item)
{
if (strtolower($Item->getName()) == strtolower($name))
{
return $Item;
}
}
}
return false;
}
else
{
$xml = null;
return parent::_findByName($Context, $realmID, QuickBooks_IPP_IDS::RESOURCE_ITEM, $name, $xml);
}
} | php | {
"resource": ""
} |
q256019 | QuickBooks_SQL._startsWith | test | protected function _startsWith($str, $startswith)
{
$length = strlen($startswith);
return (substr($str, 0, $length)) == $startswith;
} | php | {
"resource": ""
} |
q256020 | QuickBooks_SQL.query | test | public function query($sql, $look = true)
{
if ($this->_driver)
{
if ($look)
{
$tmp = trim(strtoupper($sql));
if ($this->_startsWith($sql, 'UPDATE '))
{
}
else if ($this->_startsWith($sql, 'INSERT INTO '))
{
}
else if ($this->_startsWith($sql, 'DELETE FROM '))
{
}
}
return $this->_driver->query($sql);
}
return false;
} | php | {
"resource": ""
} |
q256021 | QuickBooks_XML.extractTagContents | test | static public function extractTagContents($tag, $data)
{
$tag = trim($tag, '<> ');
if (false !== strpos($data, '<' . $tag . '>') and
false !== strpos($data, '</' . $tag . '>'))
{
$data = strstr($data, '<' . $tag . '>');
$end = strpos($data, '</' . $tag . '>');
return substr($data, strlen($tag) + 2, $end - (strlen($tag) + 2));
}
return null;
} | php | {
"resource": ""
} |
q256022 | QuickBooks_XML.extractTagAttributes | test | static public function extractTagAttributes($tag_w_attrs, $return_tag_first = false)
{
$tag = '';
$attributes = array();
$tag_w_attrs = trim($tag_w_attrs);
/*if (substr($tag_w_attrs, -1, 1) == '/') // condensed empty tag
{
$tag = trim($tag_w_attrs, '/ ');
$attributes = array();
}
else*/
if (false !== strpos($tag_w_attrs, ' '))
{
$tmp = explode(' ', $tag_w_attrs);
//$tag = trim(array_shift($tmp), " \n\r\t<>");
$tag = trim(array_shift($tmp));
$attributes = array();
$attrs = trim(implode(' ', $tmp));
$length = strlen($attrs);
$key = '';
$value = '';
$in_key = true;
$in_value = false;
$expect_key = false;
$expect_value = false;
for ($i = 0; $i < $length; $i++)
{
if ($attrs{$i} == '=')
{
$in_key = false;
$in_value = false;
$expect_value = true;
}
/*
else if ($attrs{$i} == '"' and $expect_value)
{
$in_value = true;
$expect_value = false;
}
*/
/*else if ($attrs{$i} == '"' and $in_value)*/
else if (($attrs{$i} == '"' or $attrs{$i} == '\'') and $expect_value)
{
$in_value = true;
$expect_value = false;
}
else if (($attrs{$i} == '"' or $attrs{$i} == '\'') and $in_value)
{
$attributes[trim($key)] = $value;
$key = '';
$value = '';
$in_value = false;
$expect_key = true;
}
else if ($attrs{$i} == ' ' and $expect_key)
{
$expect_key = false;
$in_key = true;
}
else if ($in_key)
{
$key .= $attrs{$i};
}
else if ($in_value)
{
$value .= $attrs{$i};
}
}
/*
foreach ($tmp as $attribute)
{
if (false !== ($pos = strpos($attribute, '=')))
{
$key = trim(substr($attribute, 0, $pos));
$value = trim(substr($attribute, $pos + 1), '"');
$attributes[$key] = $value;
}
}*/
}
else
{
$tag = $tag_w_attrs;
$attributes = array();
}
// This returns the actual tag without attributes as the first key of the array
if ($return_tag_first)
{
array_unshift($attributes, $tag);
}
return $attributes;
} | php | {
"resource": ""
} |
q256023 | QuickBooks_XML.encode | test | static public function encode($str, $for_qbxml = true, $double_encode = true)
{
$transform = array(
'&' => '&',
'<' => '<',
'>' => '>',
//'\'' => ''',
'"' => '"',
);
$str = str_replace(array_keys($transform), array_values($transform), $str);
if (!$double_encode)
{
$fix = array();
foreach ($transform as $raw => $encoded)
{
$fix[str_replace('&', '&', $encoded)] = $encoded;
}
$str = str_replace(array_keys($fix), array_values($fix), $str);
}
return $str;
} | php | {
"resource": ""
} |
q256024 | QuickBooks_XML.decode | test | static public function decode($str, $for_qbxml = true)
{
$transform = array(
'<' => '<',
'>' => '>',
''' => '\'',
'"' => '"',
'&' => '&', // Make sure that this is *the last* transformation to run, otherwise we end up double-un-encoding things
);
return str_replace(array_keys($transform), array_values($transform), $str);
} | php | {
"resource": ""
} |
q256025 | QuickBooks_IPP_IntuitAnywhere.check | test | public function check($app_username, $app_tenant)
{
if ($arr = $this->load($app_username, $app_tenant))
{
return true;
}
return false;
} | php | {
"resource": ""
} |
q256026 | QuickBooks_IPP_IntuitAnywhere.load | test | public function load($app_username, $app_tenant)
{
if ($arr = $this->_driver->oauthLoad($this->_key, $app_username, $app_tenant) and
strlen($arr['oauth_access_token']) > 0 and
strlen($arr['oauth_access_token_secret']) > 0)
{
$arr['oauth_consumer_key'] = $this->_consumer_key;
$arr['oauth_consumer_secret'] = $this->_consumer_secret;
return $arr;
}
return false;
} | php | {
"resource": ""
} |
q256027 | QuickBooks_IPP_IntuitAnywhere.handle | test | public function handle($app_username, $app_tenant)
{
if ($this->check($app_username, $app_tenant) and // We have tokens ...
$this->test($app_username, $app_tenant)) // ... and they are valid
{
// They are already logged in, send them on to exchange data
header('Location: ' . $this->_that_url);
exit;
}
else
{
if (isset($_GET['oauth_token']))
{
// We're in the middle of an OAuth token session
/*
$arr = mysql_fetch_array(mysql_query("
SELECT
*
FROM
quickbooks_oauth
WHERE
oauth_request_token = '" . $_REQUEST['oauth_token'] . "' "));
*/
if ($arr = $this->_driver->oauthRequestResolve($_GET['oauth_token']))
{
$info = $this->_getAccessToken(
$arr['oauth_request_token'],
$arr['oauth_request_token_secret'],
$_GET['oauth_verifier']);
//print('got back [' . $info . ']');
//print_r($info);
//exit;
if ($info)
{
/*
mysql_query("
UPDATE
quickbooks_oauth
SET
oauth_access_token = '" . $info['oauth_token'] . "',
oauth_access_token_secret = '" . $info['oauth_token_secret'] . "',
qb_realm = '" . $_REQUEST['realmId'] . "',
qb_flavor = '" . $_REQUEST['dataSource'] . "'
WHERE
quickbooks_oauth_id = " . $arr['quickbooks_oauth_id']);
*/
$this->_driver->oauthAccessWrite(
$this->_key,
$arr['oauth_request_token'],
$info['oauth_token'],
$info['oauth_token_secret'],
$_GET['realmId'],
$_GET['dataSource']);
//print_r($_REQUEST);
//exit;
//print_r($info);
//print('authd now, go here <a href="exchange_data.php">exchange_data.php</a>');
header('Location: ' . $this->_that_url);
exit;
}
else
{
// Something went wrong when fetching the user token...?
print('something went wrong fetching user token');
}
}
else
{
print('something went wrong... invalid oauth token?');
}
}
else
{
$auth_url = $this->_getAuthenticateURL($app_username, $app_tenant, $this->_this_url);
// Forward them to the auth page
header('Location: ' . $auth_url);
exit;
}
}
return true;
} | php | {
"resource": ""
} |
q256028 | QuickBooks_IPP_IntuitAnywhere.widgetMenu | test | public function widgetMenu($app_username, $app_tenant)
{
$token = null;
$secret = null;
if ($creds = $this->load($app_username, $app_tenant))
{
return $this->_request(
QuickBooks_IPP_OAuth::METHOD_GET,
QuickBooks_IPP_IntuitAnywhere::URL_APP_MENU,
array(),
$creds['oauth_access_token'],
$creds['oauth_access_token_secret']);
}
return '';
} | php | {
"resource": ""
} |
q256029 | QuickBooks_SQL_Schema.mapSchemaToSQLDefinition | test | static public function mapSchemaToSQLDefinition($xml, &$tables)
{
$Parser = new QuickBooks_XML_Parser($xml);
$errnum = 0;
$errmsg = '';
$tmp = $Parser->parse($errnum, $errmsg);
$tmp = $tmp->children();
$base = current($tmp);
$tmp = $base->children();
$rs = next($tmp);
foreach ($rs->children() as $qbxml)
{
QuickBooks_SQL_Schema::_transform('', $qbxml, $tables);
}
/*
while (count($subtables) > 0)
{
$node = array_shift($subtables);
$subsubtables = array();
$tables[] = QuickBooks_SQL_Schema::_transform('', $node, $subsubtables);
$subtables = array_merge($subtables, $subsubtables);
}
*/
// The code below tries to guess as a good set of indexes to use for
// any database tables we've generated from the schema. The code looks
// at all of the fields in the table and if any of them are *ListID or
// *TxnID it makes them indexes.
// This is a list of field names that will *always* be assigned
// indexes, regardless of what table they are in
$always_index_fields = array(
'qbsql_external_id',
'Name',
'FullName',
'EntityType',
'TxnType',
'Email',
//'Phone',
'IsActive',
'RefNumber',
//'Address_City',
//'Address_State',
'Address_Country',
//'Address_PostalCode',
//'BillAddress_City',
//'BillAddress_State',
'BillAddress_Country',
//'BillAddress_PostalCode',
//'ShipAddress_City',
//'ShipAddress_State',
'ShipAddress_Country',
//'ShipAddress_PostalCode',
'CompanyName',
//'FirstName',
'LastName',
//'Contact',
'TxnDate',
'IsPaid',
'IsPending',
'IsManuallyClosed',
'IsFullyReceived',
'IsToBePrinted',
'IsToBeEmailed',
'IsFullyInvoiced',
//'IsFinanceCharge',
);
// This is a list of table.field names that will be assigned indexes
$always_index_tablefields = array(
//'Account.AccountType',
);
/*
'*FullName',
'*ListID',
'*TxnID',
'*EntityType',
'*TxnType',
'*LineID',
*/
foreach ($tables as $table => $tabledef)
{
$uniques = array();
$indexes = array();
foreach ($tabledef[1] as $field => $fielddef)
{
if ($field == 'ListID' or // Unique keys
$field == 'TxnID' or
$field == 'Name')
{
// We can't apply indexes to TEXT columns, so we need to
// check and make sure the column isn't of type TEXT
// before we decide to use this as an index
if ($fielddef[0] != QUICKBOOKS_DRIVER_SQL_TEXT)
{
$uniques[] = $field;
}
}
else if (substr($field, -6, 6) == 'ListID' or // Other things we should index for performance
substr($field, -5, 5) == 'TxnID' or
substr($field, -6, 6) == 'LineID' or
in_array($field, $always_index_fields) or
in_array($table . '.' . $field, $always_index_tablefields))
{
// We can't apply indexes to TEXT columns, so we need to
// check and make sure the column isn't of type TEXT
// before we decide to use this as an index
if ($fielddef[0] != QUICKBOOKS_DRIVER_SQL_TEXT)
{
$indexes[] = $field;
}
}
}
//print_r($indexes);
//print_r($uniques);
$tables[$table][3] = $indexes;
$tables[$table][4] = $uniques;
}
return true;
} | php | {
"resource": ""
} |
q256030 | QuickBooks_SQL_Schema._transform | test | static protected function _transform($curpath, $node, &$tables)
{
print('' . $curpath . ' node: ' . $node->name() . "\n");
$table = '';
$field = '';
$this_sql = array();
$other_sql = array();
QuickBooks_SQL_Schema::mapToSchema($curpath . ' ' . $node->name(), QUICKBOOKS_SQL_SCHEMA_MAP_TO_SQL, $this_sql, $other_sql);
foreach (array_merge(array( $this_sql ), $other_sql) as $sql)
{
$table = $sql[0];
$field = $sql[1];
/*
if (!$sql[0] or !$sql[1])
{
print(' table for node: ' . $sql[0] . "\n");
print(' field for node: ' . $sql[1] . "\n");
}
else
{
print("\n");
}
*/
if ($table)
{
if (!isset($tables[$table]))
{
$tables[$table] = array(
0 => $table,
1 => array(), // fields
2 => null, // primary key
3 => array(), // other keys
4 => array( ), // uniques
);
}
}
if ($table and $field)
{
if (!isset($tables[$table][1][$field]))
{
$tables[$table][1][$field] = QuickBooks_SQL_Schema::mapFieldToSQLDefinition($table, $field, $node->data());
}
}
}
if ($node->childCount())
{
foreach ($node->children() as $child)
{
QuickBooks_SQL_Schema::_transform($curpath . ' ' . $node->name(), $child, $tables);
}
}
return true;
} | php | {
"resource": ""
} |
q256031 | QuickBooks_QBXML_Object.set | test | public function set($key, $value, $cast = true)
{
if (is_array($value))
{
$this->_object[$key] = $value;
}
else
{
//print('set(' . $key . ', ' . $value . ', ' . $cast . ')' . "\n");
if ($cast and $value != '__EMPTY__')
{
$value = QuickBooks_Cast::cast($this->object(), $key, $value, true, false);
}
//print(' setting [' . $key . '] to value {' . $value . '}' . "\n");
$this->_object[$key] = $value;
}
return true;
} | php | {
"resource": ""
} |
q256032 | QuickBooks_QBXML_Object.get | test | public function get($key, $default = null)
{
if (isset($this->_object[$key]))
{
return $this->_object[$key];
}
return $default;
} | php | {
"resource": ""
} |
q256033 | QuickBooks_QBXML_Object.setFullNameType | test | public function setFullNameType($fullname_key, $name_key, $parent_key, $value)
{
if (false !== strpos($value, ':'))
{
if ($name_key and $parent_key)
{
// This covers the case where we are setting FullName, which
// needs to be broken up into:
// Name
// ParentRef FullName
$explode = explode(':', $value);
$name = end($explode);
$parent = implode(':', array_slice($explode, 0, -1));
$this->set($name_key, $name);
$this->set($parent_key, $parent);
// Build the parent name from the newly set Name and ParentRef (need to fetch because they might have been casted/truncate)
$value = $this->get($parent_key) . ':' . $this->get($name_key);
}
else
{
// This covers the case where we are setting
// CustomerType_FullName, there is no separate parent element,
// so we just set the whole chunk
;
}
}
else
{
$this->set($name_key, $value);
// Fetch the Name (need to fetch because they might have been casted/truncate)
$value = $this->get($name_key);
}
$this->set($fullname_key, $value);
} | php | {
"resource": ""
} |
q256034 | QuickBooks_QBXML_Object.setBooleanType | test | public function setBooleanType($key, $value)
{
//print('setting BooleanType [' . $key . '] to ' . $value . "\n");
if ($value == 'true' or $value === 1 or $value === true)
{
//print("\t" . ' set to TRUE' . "\n");
return $this->set($key, 'true');
}
//print("\t" . ' set to FALSE' . "\n");
return $this->set($key, 'false');
} | php | {
"resource": ""
} |
q256035 | QuickBooks_QBXML_Object.setDateType | test | public function setDateType($key, $date, $dont_allow_19691231 = true)
{
if ($date == '1969-12-31' and $dont_allow_19691231)
{
return false;
}
if (!strlen($date) or
$date == '0')
{
return false;
}
// 1228241458 vs. 19830102
//if (ereg('^[[:digit:]]+$', $date) and strlen($date) > 8)
if (ctype_digit($date) and strlen($date) > 8)
{
// It's a unix timestamp (seconds since unix epoch, conver to string)
$date = date('Y-m-d', $date);
}
return $this->set($key, date('Y-m-d', strtotime($date)));
} | php | {
"resource": ""
} |
q256036 | QuickBooks_QBXML_Object.getDateType | test | public function getDateType($key, $format = 'Y-m-d')
{
if (!strlen($format))
{
$format = 'Y-m-d';
}
if ($this->exists($key) and $this->get($key))
{
return date($format, strtotime($this->get($key)));
}
return null;
} | php | {
"resource": ""
} |
q256037 | QuickBooks_QBXML_Object.remove | test | public function remove($key)
{
if (isset($this->_object[$key]))
{
unset($this->_object[$key]);
return true;
}
return false;
} | php | {
"resource": ""
} |
q256038 | QuickBooks_QBXML_Object._schema | test | protected function _schema($request)
{
if (strtolower(substr($request, -2, 2)) != 'rq')
{
$request = $request . 'Rq';
}
$class = 'QuickBooks_QBXML_Schema_Object_' . $request;
$file = 'QuickBooks/QBXML/Schema/Object/' . $request . '.php';
include_once $file;
if (class_exists($class))
{
return new $class();
}
return false;
} | php | {
"resource": ""
} |
q256039 | QuickBooks_QBXML_Object.asXML | test | public function asXML($root = null, $parent = null, $object = null)
{
if (is_null($root))
{
$root = $this->object();
}
if (is_null($object))
{
$object = $this->_object;
}
$Node = new QuickBooks_XML_Node($root);
foreach ($object as $key => $value)
{
if (is_array($value))
{
$Node->setChildDataAt($root . ' ' . $key, '', true);
foreach ($value as $sub)
{
//print('printing sub' . "\n");
//print_r($sub);
//print($sub->asXML());
$Node->addChildAt($root, $sub->asXML(null, $root));
}
}
else
{
$Node->setChildDataAt($root . ' ' . $key, $value, true);
}
}
//print_r($Node);
return $Node;
} | php | {
"resource": ""
} |
q256040 | QuickBooks_Driver_Sql_Mssql._initialized | test | protected function _initialized()
{
$required = array(
//$this->_mapTableName(QUICKBOOKS_DRIVER_SQL_IDENTTABLE) => false,
$this->_mapTableName(QUICKBOOKS_DRIVER_SQL_TICKETTABLE) => false,
$this->_mapTableName(QUICKBOOKS_DRIVER_SQL_USERTABLE) => false,
$this->_mapTableName(QUICKBOOKS_DRIVER_SQL_RECURTABLE) => false,
$this->_mapTableName(QUICKBOOKS_DRIVER_SQL_QUEUETABLE) => false,
$this->_mapTableName(QUICKBOOKS_DRIVER_SQL_LOGTABLE) => false,
$this->_mapTableName(QUICKBOOKS_DRIVER_SQL_CONFIGTABLE) => false,
//$this->_mapTableName(QUICKBOOKS_DRIVER_SQL_NOTIFYTABLE) => false,
//$this->_mapTableName(QUICKBOOKS_DRIVER_SQL_CONNECTIONTABLE) => false,
);
$errnum = 0;
$errmsg = '';
$res = $this->_query("
SELECT
table_name AS name
FROM
INFORMATION_SCHEMA.Tables
WHERE
TABLE_TYPE = 'BASE TABLE' ", $errnum, $errmsg);
while ($arr = $this->_fetch($res))
{
$table = current($arr);
if (isset($required[$table]))
{
$required[$table] = true;
}
}
foreach ($required as $table => $exists)
{
if (!$exists)
{
return false;
}
}
return true;
} | php | {
"resource": ""
} |
q256041 | QuickBooks_IPP_Service_Department.add | test | public function add($Context, $realmID, $Object)
{
return parent::_add($Context, $realmID, QuickBooks_IPP_IDS::RESOURCE_DEPARTMENT, $Object);
} | php | {
"resource": ""
} |
q256042 | QuickBooks_QBXML_Object_Employee.getName | test | public function getName()
{
if (!$this->exists('Name'))
{
if (!is_null($this->getFirstName()) || !is_null($this->getLastName())) {
$this->setNameAsFirstLast();
}
}
return $this->get('Name');
} | php | {
"resource": ""
} |
q256043 | QuickBooks_QBXML_Object_Employee.setNameAsFirstLast | test | public function setNameAsFirstLast() {
$first = $this->getFirstName();
$last = $this->getLastName();
if (is_null($first)) { $first = ''; }
if (is_null($last)) { $last = ''; }
return $this->set('Name', $first .' '. $last);
} | php | {
"resource": ""
} |
q256044 | QuickBooks_WebConnector_Server_SQL._sqlDefaults | test | protected function _sqlDefaults($config)
{
$tmp = array(
//'only_query',
//'dont_query',
'only_import',
'dont_import',
'only_add',
'dont_add',
'only_modify',
'dont_modify',
'only_misc',
'dont_misc',
);
foreach ($tmp as $filter)
{
if (empty($config[$filter]) or
(!empty($config[$filter]) and !is_array($config[$filter])))
{
$config[$filter] = array();
}
}
// Any other configuration defaults go here
$defaults = array(
);
return array_merge($defaults, $config);
} | php | {
"resource": ""
} |
q256045 | QuickBooks_Status_Report.status | test | public function status($user = null, $levels = array())
{
$Driver = $this->_driver;
if (!$user)
{
$user = $Driver->authDefault();
}
if (!count($levels))
{
$levels = array(
60 * 60 * 12 => array( QuickBooks_Status_Report::STATUS_NOTICE, 'Notice: A connection has not been made in %d days, %d hours and %d minutes.' ),
60 * 60 * 24 => array( QuickBooks_Status_Report::STATUS_CAUTION, 'Caution: A connection has not been made in %d days, %d hours and %d minutes.' ),
60 * 60 * 36 => array( QuickBooks_Status_Report::STATUS_WARNING, 'Warning! A connection has not been made in %d days, %d hours and %d minutes.' ),
60 * 60 * 48 => array( QuickBooks_Status_Report::STATUS_DANGER, 'DANGER! A connection has not been made in %d days, %d hours and %d minutes! Contact support to get this issue resolved!' ),
);
}
if (!isset($levels[0]))
{
$levels[0] = array( QuickBooks_Status_Report::STATUS_OK, 'Status is OK. Last connection made %d days, %d hours, and %d minutes ago.' );
}
if (!isset($levels[-1]))
{
$levels[-1] = array( QuickBooks_Status_Report::STATUS_UNKNOWN, 'Status is unknown.');
}
//print_r($levels);
// Find the status from the ticket table
$last = $Driver->authLast($user);
if (is_array($last))
{
krsort($levels);
$ago = time() - strtotime($last[1]);
$days = floor($ago / (60 * 60 * 24));
$hours = floor(($ago - ($days * 60 * 60 * 24)) / 60.0 / 60.0);
$minutes = max(1, floor(($ago - ($days * 60 * 60 * 24) - ($hours * 60 * 60)) / 60.0));
$retr = null;
foreach ($levels as $level => $tuple)
{
if ($level <= 0)
{
continue;
}
if ($ago > $level)
{
$retr = $tuple;
break;
}
}
if (!$retr)
{
$retr = $levels[0];
}
$retr[1] = sprintf($retr[1], $days, $hours, $minutes);
$retr[] = $last[0];
$retr[] = $last[1];
return $retr;
}
return $levels[-1];
} | php | {
"resource": ""
} |
q256046 | QuickBooks_IPP_Service_PurchaseOrder.delete | test | public function delete($Context, $realmID, $IDType)
{
return parent::_delete($Context, $realmID, QuickBooks_IPP_IDS::RESOURCE_PURCHASEORDER, $IDType);
} | php | {
"resource": ""
} |
q256047 | QuickBooks_XML_Parser._read | test | protected function _read($mixed)
{
if (empty($mixed))
{
return '';
}
else if (is_resource($mixed) and
get_resource_type($mixed) == 'stream')
{
$buffer = '';
$tmp = '';
while ($tmp = fread($mixed, 8192))
{
$buffer .= $tmp;
}
return $buffer;
}
else if (substr(trim($mixed), 0, 6) == '{"warn')
{
// Intuit has a bug where some of their services return JSON erors
// instead of XML, so we catch these here...
return '';
}
else if (substr(trim($mixed), 0, 1) != '<')
{
return file_get_contents($mixed);
}
return $mixed;
} | php | {
"resource": ""
} |
q256048 | QuickBooks_XML_Parser.load | test | public function load($xml_or_file)
{
$xml_or_file = $this->_read($xml_or_file);
$this->_xml = $xml_or_file;
return $this->_backend->load($xml_or_file);
} | php | {
"resource": ""
} |
q256049 | QuickBooks_XML_Parser.parse | test | public function parse(&$errnum, &$errmsg)
{
if (!strlen($this->_xml))
{
$errnum = QuickBooks_XML::ERROR_CONTENT;
$errmsg = 'No XML content to parse.';
return false;
}
// first, let's remove all of the comments
if ($this->validate($errnum, $errmsg))
{
return $this->_backend->parse($errnum, $errmsg);
}
return false;
} | php | {
"resource": ""
} |
q256050 | QuickBooks_QBXML_Object_SalesTaxGroupItem.asQBXML | test | public function asQBXML($request, $version = null, $locale = null, $root = null)
{
return parent::asQBXML($request, $version, $locale, $root);
} | php | {
"resource": ""
} |
q256051 | QuickBooks_Callbacks_API_Errors.e500_notfound | test | static public function e500_notfound($requestID, $user, $action, $ident, $extra, &$err, $xml, $errnum, $errmsg, $config)
{
//$requestID, $user, $action, $ident, $extra, $errerr, $xml, $errnum, $errmsg, $this->_callback_config
// Not found, *still call the callback!*
/*
$extra['callbacks'], $method, $action, $ID, $err, $qbxml, $qbobject, $qbres
*/
// Get the driver instance
$Driver = QuickBooks_Driver_Singleton::getInstance();
if (!isset($extra['callbacks']))
{
$extra['callbacks'] = array();
}
if (!is_array($extra['callbacks']))
{
$extra['callbacks'] = array( $extra['callbacks'] );
}
$method = null;
if (isset($extra['method']))
{
$method = $extra['method'];
}
$err = '';
$qbobject = new QuickBooks_Iterator(array());
$qbres = null;
foreach ($extra['callbacks'] as $func)
{
if (false !== strpos($func, '::') and
true) // method_exists()) // is this safe to do?
{
// Callback *static method*
$tmp = explode('::', $func);
$return = call_user_func(array( $tmp[0], $tmp[1] ), $method, $action, $ident, $err, $xml, $qbobject, $qbres);
}
else if (function_exists($func))
{
// Callback *function*
$return = call_user_func($func, $method, $action, $ident, $err, $xml, $qbobject, $qbres);
}
else
{
$err = 'Could not call function or method: ' . $func;
$Driver->log('API: ' . $err, null, QUICKBOOKS_LOG_NORMAL);
return false;
}
if (!$return)
{
break;
}
}
if ($err)
{
return false;
}
return true;
} | php | {
"resource": ""
} |
q256052 | QuickBooks_Driver_Sql._ticketResolve | test | protected function _ticketResolve($ticket)
{
static $cache = array();
if (!$ticket)
{
return 0;
}
$errnum = 0;
$errmsg = '';
if (isset($cache[$ticket]))
{
return $cache[$ticket];
}
else if ($arr = $this->_fetch($this->_query("
SELECT
quickbooks_ticket_id
FROM
" . $this->_mapTableName(QUICKBOOKS_DRIVER_SQL_TICKETTABLE) . "
WHERE
ticket = '" . $this->_escape($ticket) . "' ", $errnum, $errmsg, 0, 1)))
{
$cache[$ticket] = $arr['quickbooks_ticket_id'];
return $arr['quickbooks_ticket_id'];
}
return 0;
} | php | {
"resource": ""
} |
q256053 | QuickBooks_Driver_Sql._configWrite | test | protected function _configWrite($user, $module, $key, $value, $type, $opts)
{
$errnum = 0;
$errmsg = '';
if ($arr = $this->_fetch($this->_query("
SELECT
quickbooks_config_id
FROM
" . $this->_mapTableName(QUICKBOOKS_DRIVER_SQL_CONFIGTABLE) . "
WHERE
qb_username = '" . $this->_escape($user) . "' AND
module = '" . $this->_escape($module) . "' AND
cfgkey = '" . $this->_escape($key) . "' ", $errnum, $errmsg, 0, 1)))
{
$this->_query("
UPDATE
" . $this->_mapTableName(QUICKBOOKS_DRIVER_SQL_CONFIGTABLE) . "
SET
cfgval = '" . $this->_escape($value) . "',
mod_datetime = '" . date('Y-m-d H:i:s') . "'
WHERE
quickbooks_config_id = " . $arr['quickbooks_config_id'], $errnum, $errmsg);
}
else
{
return $this->_query("
INSERT INTO
" . $this->_mapTableName(QUICKBOOKS_DRIVER_SQL_CONFIGTABLE) . "
(
qb_username,
module,
cfgkey,
cfgval,
cfgtype,
cfgopts,
write_datetime,
mod_datetime
) VALUES (
'" . $this->_escape($user) . "',
'" . $this->_escape($module) . "',
'" . $this->_escape($key) . "',
'" . $this->_escape($value) . "',
'" . $this->_escape($type) . "',
'" . $this->_escape(serialize($opts)) . "',
'" . date('Y-m-d H:i:s') . "',
'" . date('Y-m-d H:i:s') . "'
) ", $errnum, $errmsg);
}
} | php | {
"resource": ""
} |
q256054 | QuickBooks_Driver_Sql._configRead | test | protected function _configRead($user, $module, $key, &$type, &$opts)
{
$errnum = 0;
$errmsg = '';
$sql = "
SELECT
cfgval,
cfgtype,
cfgopts
FROM
" . $this->_mapTableName(QUICKBOOKS_DRIVER_SQL_CONFIGTABLE) . "
WHERE
qb_username = '" . $this->_escape($user) . "' AND
module = '" . $this->_escape($module) . "' AND
cfgkey = '" . $this->_escape($key) . "' ";
//print($sql);
if ($arr = $this->_fetch($this->_query($sql, $errnum, $errmsg, 0, 1)))
{
$type = $arr['cfgtype'];
$opts = $arr['cfgopts'];
//print_r($arr);
return $arr['cfgval'];
}
$type = null;
$opts = null;
return null;
} | php | {
"resource": ""
} |
q256055 | QuickBooks_Driver_Sql._authCreate | test | protected function _authCreate($username, $password, $company_file = null, $wait_before_next_update = null, $min_run_every_n_seconds = null)
{
$errnum = 0;
$errmsg = '';
if (!$this->_count($this->_query("SELECT qb_username FROM " . $this->_mapTableName(QUICKBOOKS_DRIVER_SQL_USERTABLE) . " WHERE qb_username = '" . $this->_escape($username) . "' ", $errnum, $errmsg, 0, 1)))
{
return $this->_query("
INSERT INTO
" . $this->_mapTableName(QUICKBOOKS_DRIVER_SQL_USERTABLE) . "
(
qb_username,
qb_password,
qb_company_file,
qbwc_wait_before_next_update,
qbwc_min_run_every_n_seconds,
status,
write_datetime,
touch_datetime
) VALUES (
'" . $this->_escape($username) . "',
'" . $this->_escape($this->_hash($password)) . "',
'" . $this->_escape($company_file) . "',
" . (int) $wait_before_next_update . ",
" . (int) $min_run_every_n_seconds . ",
'" . QUICKBOOKS_USER_ENABLED . "',
'" . date('Y-m-d H:i:s') . "',
'" . date('Y-m-d H:i:s') . "'
) ", $errnum, $errmsg);
}
return false;
} | php | {
"resource": ""
} |
q256056 | QuickBooks_Driver_Sql._authDefault | test | protected function _authDefault()
{
$errnum = 0;
$errmsg = '';
if ($arr = $this->_fetch($this->_query("
SELECT
qb_username
FROM
" . $this->_mapTableName(QUICKBOOKS_DRIVER_SQL_USERTABLE) . "
WHERE
status = '" . QUICKBOOKS_USER_ENABLED . "' ", $errnum, $errmsg, 0, 1)))
{
return $arr['qb_username'];
}
return '';
} | php | {
"resource": ""
} |
q256057 | QuickBooks_Driver_Sql._authLogin | test | protected function _authLogin($username, $password, &$company_file, &$wait_before_next_update, &$min_run_every_n_seconds, $override = false)
{
$errnum = 0;
$errmsg = '';
if ($override) // We still need to make sure that the user exists, even if using external authentication
{
$this->authCreate($username, $password);
}
else if (strlen(trim($password)) == 0)
{
// Blank passwords *always fail*
return null;
}
else if (strlen(trim($password)) == 32 or strlen(trim($password)) == 40)
{
// Possible *hack* attempt (they're sending us a random hash hoping it will match one of the hashed passwords)
return null;
}
// Support for plain-text, MD5 (without salt), and SHA1 (without salt) passwords
$plain_text = $password;
$plain_md5 = md5($password);
$plain_sha1 = sha1($password);
if ($override or
$arr = $this->_fetch($this->_query("
SELECT
*
FROM
" . $this->_mapTableName(QUICKBOOKS_DRIVER_SQL_USERTABLE) . "
WHERE
qb_username = '" . $this->_escape($username) . "' AND
(
qb_password = '" . $this->_escape($this->_hash($password)) . "' OR
qb_password = '" . $this->_escape($plain_text) . "' OR
qb_password = '" . $this->_escape($plain_md5) . "' OR
qb_password = '" . $this->_escape($plain_sha1) . "'
) AND
status = '" . QUICKBOOKS_USER_ENABLED . "' ", $errnum, $errmsg, 0, 1)))
{
//$ticket = md5((string) microtime() . $username . $this->_mapTableName(QUICKBOOKS_DRIVER_SQL_SALT));
$ticket = QuickBooks_WebConnector_QWC::GUID(false);
$this->_query("
INSERT INTO
" . $this->_mapTableName(QUICKBOOKS_DRIVER_SQL_TICKETTABLE) . "
(
qb_username,
ticket,
ipaddr,
write_datetime,
touch_datetime
) VALUES (
'" . $this->_escape($username) . "',
'" . $this->_escape($ticket) . "',
'" . $_SERVER['REMOTE_ADDR'] . "',
'" . date('Y-m-d H:i:s') . "',
'" . date('Y-m-d H:i:s') . "'
) ", $errnum, $errmsg);
$this->_query("
UPDATE
" . $this->_mapTableName(QUICKBOOKS_DRIVER_SQL_USERTABLE) . "
SET
touch_datetime = '" . date('Y-m-d H:i:s') . "'
WHERE
qb_username = '" . $this->_escape($username) . "' ", $errnum, $errmsg);
if (isset($arr) and
is_array($arr)) // Might not have this if it's an authenticate override
{
$company_file = $arr['qb_company_file'];
$wait_before_next_update = $arr['qbwc_wait_before_next_update'];
$min_run_every_n_seconds = $arr['qbwc_min_run_every_n_seconds'];
}
return $ticket;
}
return null;
} | php | {
"resource": ""
} |
q256058 | QuickBooks_Driver_Sql._authCheck | test | protected function _authCheck($ticket)
{
$errnum = 0;
$errmsg = '';
if ($arr = $this->_fetch($this->_query("
SELECT
quickbooks_ticket_id
FROM
" . $this->_mapTableName(QUICKBOOKS_DRIVER_SQL_TICKETTABLE) . "
WHERE
ticket = '" . $this->_escape($ticket) . "' AND
touch_datetime > '" . date('Y-m-d H:i:s', time() - QUICKBOOKS_TIMEOUT) . "' ", $errnum, $errmsg, 0, 1)))
{
$this->_query("
UPDATE
" . $this->_mapTableName(QUICKBOOKS_DRIVER_SQL_TICKETTABLE) . "
SET
touch_datetime = '" . date('Y-m-d H:i:s') . "'
WHERE
quickbooks_ticket_id = " . $arr['quickbooks_ticket_id'], $errnum, $errmsg);
return true;
}
return false;
} | php | {
"resource": ""
} |
q256059 | QuickBooks_Driver_Sql._errorLog | test | protected function _errorLog($ticket, $errnum, $errmsg)
{
if ($ticket_id = $this->_ticketResolve($ticket))
{
$db_errnum = 0;
$db_errmsg = '';
return $this->_query("
UPDATE
" . $this->_mapTableName(QUICKBOOKS_DRIVER_SQL_TICKETTABLE) . "
SET
lasterror_num = '" . $this->_escape($errnum) . "',
lasterror_msg = '" . $this->_escape(substr($errmsg, 0, 255)) . "'
WHERE
quickbooks_ticket_id = " . (int) $ticket_id, $db_errnum, $db_errmsg);
}
return false;
} | php | {
"resource": ""
} |
q256060 | QuickBooks_Driver_Sql._recurEnqueue | test | protected function _recurEnqueue($user, $run_every, $action, $ident, $replace = true, $priority = 0, $extra = null, $qbxml = null)
{
$errnum = 0;
$errmsg = '';
// By default, it has *never* occured
$recur_lasttime = (time() - $run_every - 60);
if ($replace)
{
if ($existing = $this->_fetch($this->_query("
SELECT
recur_lasttime
FROM
" . $this->_mapTableName(QUICKBOOKS_DRIVER_SQL_RECURTABLE) . "
WHERE
qb_username = '" . $this->_escape($user) . "' AND
qb_action = '" . $this->_escape($action) . "' AND
ident = '" . $this->_escape($ident) . "' ", $errnum, $errmsg)))
{
$this->_query("
DELETE FROM
" . $this->_mapTableName(QUICKBOOKS_DRIVER_SQL_RECURTABLE) . "
WHERE
qb_username = '" . $this->_escape($user) . "' AND
qb_action = '" . $this->_escape($action) . "' AND
ident = '" . $this->_escape($ident) . "' ", $errnum, $errmsg);
$recur_lasttime = $existing['recur_lasttime'];
}
}
if ($extra)
{
$extra = serialize($extra);
}
return $this->_query("
INSERT INTO
" . $this->_mapTableName(QUICKBOOKS_DRIVER_SQL_RECURTABLE) . "
(
qb_username,
qb_action,
ident,
extra,
qbxml,
priority,
run_every,
recur_lasttime,
enqueue_datetime
) VALUES (
'" . $this->_escape($user) . "',
'" . $this->_escape($action) . "',
'" . $this->_escape($ident) . "',
'" . $this->_escape($extra) . "',
'" . $this->_escape($qbxml) . "',
" . (int) $priority . ",
" . (int) $run_every . ",
" . $recur_lasttime . ",
'" . date('Y-m-d H:i:s') . "'
) ", $errnum, $errmsg);
} | php | {
"resource": ""
} |
q256061 | QuickBooks_Driver_Sql._recurDequeue | test | protected function _recurDequeue($user, $by_priority = false)
{
$errnum = 0;
$errmsg = '';
$sql = "
SELECT
*
FROM
" . $this->_mapTableName(QUICKBOOKS_DRIVER_SQL_RECURTABLE) . "
WHERE
qb_username = '" . $this->_escape($user) . "' AND
recur_lasttime + run_every <= " . time();
if ($by_priority)
{
$sql .= ' ORDER BY priority DESC ';
}
if ($arr = $this->_fetch($this->_query($sql . ' ', $errnum, $errmsg, 0, 1)))
{
// Update it, so it doesn't get fetched again until it's supposed to
$errnum = 0;
$errmsg = '';
$this->_query("UPDATE " . $this->_mapTableName(QUICKBOOKS_DRIVER_SQL_RECURTABLE) . " SET recur_lasttime = " . time() . " WHERE quickbooks_recur_id = " . $arr['quickbooks_recur_id'], $errnum, $errmsg);
return $arr;
}
return false;
} | php | {
"resource": ""
} |
q256062 | QuickBooks_Driver_Sql._queueEnqueue | test | protected function _queueEnqueue($user, $action, $ident, $replace = true, $priority = 0, $extra = null, $qbxml = null)
{
$errnum = 0;
$errmsg = '';
if ($replace)
{
$this->_query("
DELETE FROM
" . $this->_mapTableName(QUICKBOOKS_DRIVER_SQL_QUEUETABLE) . "
WHERE
qb_username = '" . $this->_escape($user) . "' AND
qb_action = '" . $this->_escape($action) . "' AND
ident = '" . $this->_escape($ident) . "' AND
qb_status = '" . QUICKBOOKS_STATUS_QUEUED . "' ", $errnum, $errmsg);
}
if ($extra)
{
$extra = serialize($extra);
}
return $this->_query("
INSERT INTO
" . $this->_mapTableName(QUICKBOOKS_DRIVER_SQL_QUEUETABLE) . "
(
qb_username,
qb_action,
ident,
extra,
qbxml,
priority,
qb_status,
enqueue_datetime
) VALUES (
'" . $this->_escape($user) . "',
'" . $this->_escape($action) . "',
'" . $this->_escape($ident) . "',
'" . $this->_escape($extra) . "',
'" . $this->_escape($qbxml) . "',
" . (int) $priority . ",
'" . QUICKBOOKS_STATUS_QUEUED . "',
'" . date('Y-m-d H:i:s') . "'
) ", $errnum, $errmsg);
} | php | {
"resource": ""
} |
q256063 | QuickBooks_Driver_Sql._queueProcessing | test | protected function _queueProcessing($user)
{
$errnum = 0;
$errmsg = '';
// Fetch the latest record to be dequeued for this user, and check that it's set with a status of in processing
$sql = "
SELECT
quickbooks_queue_id,
qb_action,
ident,
qb_status,
dequeue_datetime
FROM
" . $this->_mapTableName(QUICKBOOKS_DRIVER_SQL_QUEUETABLE) . "
WHERE
dequeue_datetime IS NOT NULL
ORDER BY
dequeue_datetime DESC ";
$res = $this->_query($sql, $errnum, $errmsg, 0, 1);
if ($arr = $this->_fetch($res) and
$arr['qb_status'] == QUICKBOOKS_STATUS_PROCESSING and // Make sure this was the last thing we tried to process...
time() - strtotime($arr['dequeue_datetime']) < QUICKBOOKS_TIMEOUT) // ... and it occurred during a reasonably recent run
{
return $this->_queueGet($user, $arr['quickbooks_queue_id'], QUICKBOOKS_STATUS_PROCESSING);
//return $this->_queueFetch($user, $arr['qb_action'], $arr['ident'], QUICKBOOKS_STATUS_PROCESSING);
}
return false;
} | php | {
"resource": ""
} |
q256064 | QuickBooks_Driver_Sql._queueLeft | test | protected function _queueLeft($user, $queued = true)
{
$errnum = 0;
$errmsg = '';
// SELECT * FROM quickbooks_queue WHERE qb_status = 'q'
$sql = "
SELECT
COUNT(*) AS num_left
FROM
" . $this->_mapTableName(QUICKBOOKS_DRIVER_SQL_QUEUETABLE) . "
WHERE
qb_username = '" . $this->_escape($user) . "' ";
if ($queued)
{
$sql .= " AND qb_status = '" . QUICKBOOKS_STATUS_QUEUED . "' ";
}
$arr = $this->_fetch($this->_query($sql, $errnum, $errmsg));
return $arr['num_left'];
} | php | {
"resource": ""
} |
q256065 | QuickBooks_Driver_Sql._queueProcessed | test | protected function _queueProcessed($ticket)
{
$errnum = 0;
$errmsg = '';
if ($arr = $this->_fetch($this->_query("
SELECT
processed
FROM
" . $this->_mapTableName(QUICKBOOKS_DRIVER_SQL_TICKETTABLE) . "
WHERE
ticket = '" . $this->_escape($ticket) . "' ", $errnum, $errmsg, 0, 1)))
{
return $arr['processed'];
}
return 0;
} | php | {
"resource": ""
} |
q256066 | QuickBooks_Driver_Sql._log | test | protected function _log($msg, $ticket = null, $log_level = QUICKBOOKS_LOG_NORMAL, $cur_log_level = null)
{
static $batch = 0;
/*
if ($batch == 0) // Batching needs to be revised, *major* performance hit
{
// We store a batch ID so that we can tell which logged messages go with which actual separate HTTP request
$errnum = 0;
$errmsg = '';
if ($arr = $this->_fetch($this->_query("SELECT MAX(batch) AS maxbatch FROM " . $this->_mapTableName(QUICKBOOKS_DRIVER_SQL_LOGTABLE) . " ", $errnum, $errmsg)))
{
$batch = (int) $arr['maxbatch'];
}
$batch++;
}
*/
// Truncate log and queue tables
$this->_truncate(QUICKBOOKS_DRIVER_SQL_LOGTABLE, $this->_max_log_history);
$this->_truncate(QUICKBOOKS_DRIVER_SQL_QUEUETABLE, $this->_max_queue_history);
$this->_truncate(QUICKBOOKS_DRIVER_SQL_TICKETTABLE, $this->_max_ticket_history);
// Actually insert the log message...
$errnum = 0;
$errmsg = '';
// Make sure the message isn't too long
$msg = substr($msg, 0, 65534);
// Log level handling is handled by the QuickBooks_Driver base class (see public method {@link QuickBooks_Driver::log()})
if ($ticket_id = $this->_ticketResolve($ticket))
{
return $this->_query("
INSERT INTO
" . $this->_mapTableName(QUICKBOOKS_DRIVER_SQL_LOGTABLE) . "
(
quickbooks_ticket_id,
batch,
msg,
log_datetime
) VALUES (
" . $ticket_id . ",
" . $batch . ",
'" . $this->_escape($msg) . "',
'" . date('Y-m-d H:i:s') . "' ) ", $errnum, $errmsg);
}
else
{
return $this->_query("
INSERT INTO
" . $this->_mapTableName(QUICKBOOKS_DRIVER_SQL_LOGTABLE) . "
(
batch,
msg,
log_datetime
) VALUES (
" . $batch . ",
'" . $this->_escape($msg) . "',
'" . date('Y-m-d H:i:s') . "' ) ", $errnum, $errmsg);
}
} | php | {
"resource": ""
} |
q256067 | QuickBooks_Driver_Sql.query | test | public function query($sql, &$errnum, &$errmsg, $offset = 0, $limit = null, $vars = array())
{
if (is_array($vars)
and count($vars))
{
foreach ($vars as $key => $value)
{
$vars[$key] = $this->escape($value);
}
array_unshift($vars, $sql);
$sql = call_user_func_array('sprintf', $vars);
}
//print($sql . '<br>');
return $this->_query($sql, $errnum, $errmsg, $offset, $limit);
} | php | {
"resource": ""
} |
q256068 | QuickBooks_Driver_Sql.fields | test | public function fields($table, $with_field_names_as_keys = false)
{
static $cache = array();
if (isset($cache[$table]))
{
return $cache[$table];
}
// *Careful* by default it's stored as array( 'field_name' => true, ... )
$tmp = $this->_fields($table);
$cache[$table] = array_combine($tmp, array_fill(0, count($tmp), true));
if ($with_field_names_as_keys)
{
return $cache[$table];
}
else
{
return array_keys($cache[$table]);
}
} | php | {
"resource": ""
} |
q256069 | QuickBooks_Driver_Sql.select | test | public function select($table, $restrict, $order = array(), $offset = null, $limit = null)
{
$list = array();
if (count($restrict))
{
$where = array();
foreach ($restrict as $field => $value)
{
$where[] = $field . " = '" . $this->_escape($value) . "' ";
}
$where = " WHERE " . implode(' AND ', $where) . " ";
}
else
{
$where = "";
}
$orderby = "";
if (is_array($order) and
count($order))
{
$orderby = array();
foreach ($order as $field => $direction)
{
$orderby[] = " " . $field . " " . $direction;
}
$orderby = " ORDER BY " . implode(', ', $orderby);
}
$errnum = 0;
$errmsg = '';
if ($res = $this->_query("SELECT * FROM " . $this->_escape($table) . " " . $where . " " . $orderby, $errnum, $errmsg, $offset, $limit))
{
while ($arr = $this->_fetch($res))
{
$list[] = $arr;
}
}
return $list;
} | php | {
"resource": ""
} |
q256070 | QuickBooks_Driver_Sql.update | test | public function update($table, $object, $where = array(), $resync = true, $discov = null, $derive = true) // @todo Is that the correct default for $derive?
{
$sql = '';
$set = array();
if (is_object($object))
{
$object = $object->asArray();
}
$avail = $this->fields($table, true); // List of available fields
// Case folding support
if ($this->foldsToLower())
{
$object = array_change_key_case($object, CASE_LOWER);
}
else if ($this->foldsToUpper())
{
$object = array_change_key_case($object, CASE_UPPER);
}
// Merge by keys to make sure we don't INSERT any fields that don't exist in this schema
$object = array_intersect_key($object, $avail);
//
foreach ($object as $field => $value)
{
// Commented out because doing this to very large integers (i.e. ItemRef/FullName is a large integer SKU) causes integer overflow
/*if (strlen((int) $value) == strlen($value))
{
$set[] = $field . ' = ' . (int) $value;
}
else
{*/
// $set[] = $field . " = '" . $this->_escape($value) . "' ";
//}
if (is_null($value))
{
$set[] = $field . " = NULL ";
}
else
{
$set[] = $field . " = '" . $this->_escape($value) . "' ";
}
}
$wheres = array();
foreach ($where as $part)
{
foreach ($part as $field => $value)
{
$wheres[] = $field . " = '" . $this->_escape($value) . "' ";
}
}
$sql = "UPDATE " . $this->_escape($table) . " SET " . implode(', ', $set);
if ($resync)
{
$sql .= ", " . QUICKBOOKS_DRIVER_SQL_FIELD_RESYNC . " = '" . date('Y-m-d H:i:s') . "' ";
}
$sql .= " WHERE " . implode(' AND ', $wheres);
//print($sql);
$errnum = 0;
$errmsg = '';
$return = $this->_query($sql, $errnum, $errmsg);
if (is_null($discov))
{
$discov = $resync;
}
if ($discov)
{
// Update the discover datetime *IF THE DISCOVER DATETIME IS NULL*
// This happens when an AddResponse is received, and we need to
// update a record that has just been added to QuickBooks. If we
// don't mark it as discovered, then updates to the record will
// never be picked up and sent to QuickBooks
$errnum = 0;
$errmsg = '';
$wheres[] = QUICKBOOKS_DRIVER_SQL_FIELD_DISCOVER . " IS NULL ";
$this->_query("
UPDATE
" . $this->_escape($table) . "
SET
" . QUICKBOOKS_DRIVER_SQL_FIELD_DISCOVER . " = " . QUICKBOOKS_DRIVER_SQL_FIELD_RESYNC . "
WHERE
" . implode(' AND ', $wheres), $errnum, $errmsg);
}
return $return;
} | php | {
"resource": ""
} |
q256071 | QuickBooks_WebConnector_Queue.interactive | test | public function interactive($priority = 0, $user = null)
{
if ($this->_driver)
{
$tmp = array_merge(range('a', 'z'), range(0, 9));
shuffle($tmp);
$random = substr(implode('', $tmp), 0, 8);
/*
if (!$user)
{
$user = $this->_driver->authDefault();
}
*/
if (!$user)
{
$user = $this->_user;
}
return $this->_driver->queueEnqueue(QUICKBOOKS_INTERACTIVE_MODE, $random, true, $priority, $user);
}
return false;
} | php | {
"resource": ""
} |
q256072 | QuickBooks_WebConnector_Queue.recurring | test | public function recurring($run_every, $action, $ident = null, $priority = 0, $extra = null, $user = null, $qbxml = null, $replace = true)
{
$run_every = QuickBooks_Utilities::intervalToSeconds($run_every);
if (!strlen($ident))
{
$tmp = array_merge(array('a', 'z'), range(0, 9));
shuffle($tmp);
$ident = substr(implode('', $tmp), 0, 8);
}
if ($this->_driver)
{
/*
if (!$user)
{
$user = $this->_driver->authDefault();
}
*/
// Use the default user (provided in __construct) if none is given
if (!$user)
{
$user = $this->_user;
}
return $this->_driver->recurEnqueue($user, $run_every, $action, substr($ident, 0, 40), $replace, $priority, $extra, $qbxml);
}
return false;
} | php | {
"resource": ""
} |
q256073 | QuickBooks_WebConnector_Queue.size | test | public function size($user = null)
{
if ($this->_driver)
{
// Use the default user (provided in __construct) if none is given
if (!$user)
{
$user = $this->_user;
}
$queued = true;
return $this->_driver->queueLeft($user, $queued);
}
return null;
} | php | {
"resource": ""
} |
q256074 | Quickbooks_QBXML_Object_CreditCardRefund.getAddress | test | public function getAddress($part = null, $defaults = array())
{
if (!is_null($part))
{
return $this->get('Address ' . $part);
}
return $this->getArray('Address *', $defaults);
} | php | {
"resource": ""
} |
q256075 | QuickBooks_IPP.authenticate | test | public function authenticate($username, $password, $token)
{
$this->_username = $username;
$this->_password = $password;
$this->_token = $token;
$url = 'https://workplace.intuit.com/db/main?act=API_Authenticate';
$action = 'API_Authenticate';
$xml = '<?xml version="1.0" encoding="UTF-8" ?>
<qdbapi>
<username>' . $username . '</username>
<password>' . $password . '</password>
<apptoken>' . $token . '</apptoken>
</qdbapi>';
$Context = null;
$response = $this->_request($Context, QuickBooks_IPP::REQUEST_IPP, $url, $action, $xml);
if (!$this->_hasErrors($response) and
$ticket = QuickBooks_XML::extractTagContents('ticket', $response))
{
$this->_ticket = $ticket;
$cookies = array(
'scache',
'ptest',
'stest',
'luid',
'TICKET',
'qbn.ticket',
'qbn.tkt',
'qbn.authid',
'qbn.gauthid',
'qbn.agentid',
'iamValidationTime'
);
foreach ($cookies as $cookie)
{
if ($value = $this->_extractCookie($cookie, $response))
{
$this->_cookies[$cookie] = $value;
}
}
return new QuickBooks_IPP_Context($this, $ticket, $token);
}
return false;
} | php | {
"resource": ""
} |
q256076 | QuickBooks_IPP_Service_Company.findById | test | public function findById($Context, $realmID)
{
$xml = null;
// WATCH OUT! We pass in the realmID as ID value
return parent::_findById($Context, $realmID, QuickBooks_IPP_IDS::RESOURCE_COMPANY, $realmID, $xml);
} | php | {
"resource": ""
} |
q256077 | QuickBooks_IPP_Service_VendorCredit.delete | test | public function delete($Context, $realmID, $IDType)
{
return parent::_delete($Context, $realmID, QuickBooks_IPP_IDS::RESOURCE_VENDORCREDIT, $IDType);
} | php | {
"resource": ""
} |
q256078 | QuickBooks_HTTP._request | test | protected function _request($method)
{
$start = microtime(true);
if (!function_exists('curl_init'))
{
die('You must have the PHP cURL extension (php.net/curl) enabled to use this (' . QUICKBOOKS_PACKAGE_NAME . ' v' . QUICKBOOKS_PACKAGE_VERSION . ').');
}
$this->_log('Using CURL to send request!', QUICKBOOKS_LOG_DEVELOP);
$return = $this->_requestCurl($method, $errnum, $errmsg);
if ($errnum)
{
$this->_setError($errnum, $errmsg);
}
// Calculate and set how long the last HTTP request/response took to make
$this->_last_duration = microtime(true) - $start;
return $return;
} | php | {
"resource": ""
} |
q256079 | QuickBooks_MerchantService.signOn | test | public function signOn()
{
$this->_setError(QuickBooks_MerchantService::ERROR_OK);
$xml = '';
$xml .= '<?xml version="1.0" ?>' . QUICKBOOKS_CRLF;
$xml .= '<?qbmsxml version="4.1"?>' . QUICKBOOKS_CRLF;
$xml .= '<QBMSXML>' . QUICKBOOKS_CRLF;
$xml .= ' <SignonMsgsRq>' . QUICKBOOKS_CRLF;
if ($this->_certificate)
{
$this->_log('Signing on a HOSTED QBMS application.', QUICKBOOKS_LOG_DEBUG);
$xml .= ' <SignonAppCertRq>' . QUICKBOOKS_CRLF;
$xml .= ' <ClientDateTime>' . date('Y-m-d\TH:i:s') . '</ClientDateTime>' . QUICKBOOKS_CRLF;
$xml .= ' <ApplicationLogin>' . $this->_application_login . '</ApplicationLogin>' . QUICKBOOKS_CRLF;
$xml .= ' <ConnectionTicket>' . $this->_ticket_connection . '</ConnectionTicket>' . QUICKBOOKS_CRLF;
$xml .= ' </SignonAppCertRq>' . QUICKBOOKS_CRLF;
}
else
{
$this->_log('Signing on as a DESKTOP QBMS application.', QUICKBOOKS_LOG_DEBUG);
$xml .= ' <SignonDesktopRq>' . QUICKBOOKS_CRLF;
$xml .= ' <ClientDateTime>' . date('Y-m-d\TH:i:s') . '</ClientDateTime>' . QUICKBOOKS_CRLF;
$xml .= ' <ApplicationLogin>' . $this->_application_login . '</ApplicationLogin>' . QUICKBOOKS_CRLF;
$xml .= ' <ConnectionTicket>' . $this->_ticket_connection . '</ConnectionTicket>' . QUICKBOOKS_CRLF;
$xml .= ' </SignonDesktopRq>' . QUICKBOOKS_CRLF;
}
$xml .= ' </SignonMsgsRq>' . QUICKBOOKS_CRLF;
$xml .= '</QBMSXML>' . QUICKBOOKS_CRLF;
$errnum = QuickBooks_MerchantService::ERROR_OK;
$errmsg = '';
$response = $this->_request($xml, $errnum, $errmsg);
if ($errnum)
{
$this->_setError(QuickBooks_MerchantService::ERROR_SOCKET, $errnum . ': ' . $errmsg);
return false;
}
$code = $this->_extractAttribute('statusCode', $response);
$message = $this->_extractAttribute('statusMessage', $response);
$severity = $this->_extractAttribute('statusSeverity', $response);
$this->_log('SignOn (initial) response: ' . $severity . '/' . $code . ': ' . $message, QUICKBOOKS_LOG_DEBUG);
if ($code != QuickBooks_MerchantService::ERROR_OK)
{
$this->_setError($code, $message);
return false;
}
if ($ticket = $this->_extractTagContents('SessionTicket', $response))
{
$this->_ticket_session = $ticket;
return true;
}
$this->_setError(QuickBooks_MerchantService::ERROR_INTERNAL, 'Could not locate SessionTicket in response.');
return false;
} | php | {
"resource": ""
} |
q256080 | QuickBooks_MerchantService._transRequestID | test | protected function _transRequestID($type, $Obj, $amount, $force_new_transaction = true)
{
$rand = '';
if ($force_new_transaction)
{
$rand = mt_rand() . microtime();
}
return md5($type . '-' . serialize($Obj) . '-' . $amount . '-' . $rand);
} | php | {
"resource": ""
} |
q256081 | QuickBooks_MerchantService.refund | test | public function refund($Card, $amount, $salestax = null, $comment = null, $is_card_present = false, $is_ecommerce = true, $force_new_transaction = true)
{
$this->_setError(QuickBooks_MerchantService::ERROR_OK);
$this->_log('refund()', QUICKBOOKS_LOG_VERBOSE);
if (!$this->isSignedOn())
{
$this->signOn();
if ($this->errorNumber())
{
return false;
}
}
// Error checking
if (!($Card instanceof QuickBooks_MerchantService_CreditCard))
{
$this->_setError(QuickBooks_MerchantService::ERROR_PARAM, 'refund() expects first parameter to be a Card object, got: ' . print_r($Card, true));
return false;
}
if (!is_numeric($amount))
{
$this->_setError(QuickBooks_MerchantService::ERROR_PARAM, 'refund() expects second parameter to be a float, got: ' . print_r($amount, true));
return false;
}
$transRequestID = $this->_transRequestID(QuickBooks_MerchantService::TYPE_REFUND, $Card, $amount, $force_new_transaction);
$xml = '';
$xml .= '<?xml version="1.0" encoding="utf-8"?>' . QUICKBOOKS_CRLF;
$xml .= '<?qbmsxml version="4.1"?>' . QUICKBOOKS_CRLF;
$xml .= '<QBMSXML>' . QUICKBOOKS_CRLF;
$xml .= $this->_createSessionXML();
$xml .= ' <QBMSXMLMsgsRq>' . QUICKBOOKS_CRLF;
$xml .= ' <CustomerCreditCardRefundRq>' . QUICKBOOKS_CRLF;
$xml .= ' <TransRequestID>' . $transRequestID . '</TransRequestID>' . QUICKBOOKS_CRLF;
// $Card, $amount, $salestax, $is_card_present, $is_ecommerce, $is_recurring, $is_mobile, $include_address_data = true, $include_amounts = true, $include_card_number = true, $include_card_cvv = true, $include_card_dates = true
$xml .= $this->_createCreditCardXML($Card, $amount, $salestax, $is_card_present, $is_ecommerce, false, null, false, true, true, false);
//<BatchID >STRTYPE</BatchID> <!-- optional -->
if ($comment)
{
$xml .= ' <Comment>' . substr(QuickBooks_XML::encode($comment), 0, 500) . '</Comment>' . QUICKBOOKS_CRLF;
}
$xml .= ' </CustomerCreditCardRefundRq>' . QUICKBOOKS_CRLF;
$xml .= ' </QBMSXMLMsgsRq>' . QUICKBOOKS_CRLF;
$xml .= '</QBMSXML>' . QUICKBOOKS_CRLF;
return $this->_doQBMS(QuickBooks_MerchantService::TYPE_REFUND, 'QBMSXML/QBMSXMLMsgsRs/CustomerCreditCardRefundRs', $xml, $Card);
} | php | {
"resource": ""
} |
q256082 | QuickBooks_WebConnector_Queue_Singleton.initialize | test | static public function initialize($dsn = null, $user = null, $config = array(), $return_boolean = true)
{
static $instance;
if (empty($instance))
{
if (empty($dsn))
{
return false;
}
$instance = new QuickBooks_WebConnector_Queue($dsn, $user, $config);
}
if ($return_boolean and $instance)
{
return true;
}
return $instance;
} | php | {
"resource": ""
} |
q256083 | QuickBooks_WebConnector_Server._adapterFactory | test | protected function _adapterFactory($adapter, $wsdl, $soap_options, $loglevel)
{
$adapter = ucfirst(strtolower($adapter));
$file = '/QuickBooks/Adapter/Server/' . $adapter . '.php';
$class = 'QuickBooks_Adapter_Server_' . $adapter;
QuickBooks_Loader::load($file);
if (class_exists($class))
{
return new $class($wsdl, $soap_options);
}
return null;
} | php | {
"resource": ""
} |
q256084 | QuickBooks_WebConnector_Server._defaults | test | final protected function _defaults($arr)
{
$defaults = array(
'error_handler' => '',
'use_builtin_error_handler' => false,
'time_limit' => 0,
'log_to_file' => null,
'log_to_syslog' => null,
'masking' => true,
);
$arr = array_merge($defaults, $arr);
return $arr;
} | php | {
"resource": ""
} |
q256085 | QuickBooks_WebConnector_Server._headers | test | protected function _headers()
{
if ($_SERVER['REQUEST_METHOD'] == 'POST')
{
header('Content-Type: text/xml');
}
else if (isset($_GET['wsdl']) or isset($_GET['WSDL']))
{
header('Content-Type: text/xml');
}
else
{
header('Content-Type: text/plain');
}
return true;
} | php | {
"resource": ""
} |
q256086 | Controller_Qbapi_Quickbooks.action_index | test | public function action_index() {
//Username and password used for the web connector, QWC file, and the QB Framework
$user = 'QBAPI Username';
$pass = 'QBAPI Password';
//Configure the logging level
$log_level = QUICKBOOKS_LOG_DEVELOP;
//Pure-PHP SOAP server
$soapserver = QUICKBOOKS_SOAPSERVER_BUILTIN;
//we can turn this off
$handler_options = array(
'deny_concurrent_logins' => false,
'deny_reallyfast_logins' => false,
);
// The next three params $map, $errmap, and $hooks are callbacks which
// will be called when certain actions/events/requests/responses occur within
// the framework
// Maps inbound requests to functions
$map = array(
QUICKBOOKS_ADD_CUSTOMER => array( array($this, '_quickbooks_customer_add_request'), array($this,'_quickbooks_customer_add_response' )),
QUICKBOOKS_MOD_CUSTOMER => array( array($this, '_quickbooks_customer_mod_request'), array($this, '_quickbooks_customer_mod_response')),
);
//Map error handling to functions
$errmap = array(
3070 => array($this, '_quickbooks_error_stringtoolong'),
3140 => array($this, '_quickbooks_reference_error'),
'*' => array($this, '_quickbooks_error_handler'),
);
//Login success callback
$hooks = array(
QuickBooks_WebConnector_Handlers::HOOK_LOGINSUCCESS => array(array($this,'_quickbooks_hook_loginsuccess')),
);
//MySQL database name containing the QuickBooks tables is named 'quickbooks' (if the tables don't exist, they'll be created for you)
$dsn = 'mysql://username:password@host/databasename';
QuickBooks_WebConnector_Queue_Singleton::initialize($dsn);
if (!QuickBooks_Utilities::initialized($dsn)) {
// Initialize creates the neccessary database schema for queueing up requests and logging
QuickBooks_Utilities::initialize($dsn);
// This creates a username and password which is used by the Web Connector to authenticate
QuickBooks_Utilities::createUser($dsn, $user, $pass);
// Initial test case customer
$primary_key_of_new_customer = 512;
// Fire up the Queue
$Queue = new QuickBooks_WebConnector_Queue($dsn);
// Drop the directive and the customer into the queue
$Queue->enqueue(QUICKBOOKS_ADD_CUSTOMER, $primary_key_of_new_customer);
// Also note the that ->enqueue() method supports some other parameters:
// string $action The type of action to queue up
// mixed $ident = null Pass in the unique primary key of your record here, so you can pull the data from your application to build a qbXML request in your request handler
// $priority = 0 You can assign priorities to requests, higher priorities get run first
// $extra = null Any extra data you want to pass to the request/response handler
// $user = null If you're using multiple usernames, you can pass the username of the user to queue this up for here
// $qbxml = null
// $replace = true
}
//To be used with singleton queue
$driver_options = array();
//Callback options, not needed at the moment
$callback_options = array();
//nothing needed here at the moment
$soap_options = array();
//construct a new instance of the web connector server
$Server = new QuickBooks_WebConnector_Server($dsn, $map, $errmap, $hooks, $log_level, $soapserver, QUICKBOOKS_WSDL, $soap_options, $handler_options, $driver_options, $callback_options);
//instruct server to handle responses
$response = $Server->handle(true, true);
} | php | {
"resource": ""
} |
q256087 | QuickBooks_SOAP_Server._requestFactory | test | protected function _requestFactory($request)
{
$class = 'QuickBooks_WebConnector_Request_' . ucfirst(strtolower($request));
$file = '/QuickBooks/WebConnector/Request/' . ucfirst(strtolower($request)) . '.php';
// Make sure that class gets loaded
QuickBooks_Loader::load($file, false);
if (class_exists($class))
{
return new $class();
}
return false;
} | php | {
"resource": ""
} |
q256088 | QuickBooks_SOAP_Server.handle | test | public function handle($raw_http_input)
{
// Determine the method, call the correct handler function
$builtin = QuickBooks_XML::PARSER_BUILTIN; // The SimpleXML parser has a difference namespace behavior, so force this to use the builtin parser
$Parser = new QuickBooks_XML_Parser($raw_http_input, $builtin);
$errnum = 0;
$errmsg = '';
if ($Doc = $Parser->parse($errnum, $errmsg))
{
//print('parsing...');
$Root = $Doc->getRoot();
$Body = $Root->getChildAt('SOAP-ENV:Envelope SOAP-ENV:Body');
if (!$Body)
{
$Body = $Root->getChildAt('soap:Envelope soap:Body');
}
$Container = $Body->getChild(0);
$Request = null;
$method = '';
if ($Container)
{
$namespace = '';
$method = $this->_namespace($Container->name(), $namespace);
$Request = $this->_requestFactory($method);
foreach ($Container->children() as $Child)
{
$namespace = '';
$member = $this->_namespace($Child->name(), $namespace);
//$Request->$member = html_entity_decode($Child->data(), ENT_QUOTES);
$Request->$member = $Child->data();
}
}
//print('method is: ' . $method . "\n");
$Response = null;
if (method_exists($this->_class, $method))
{
$Response = $this->_class->$method($Request);
}
$soap = '<?xml version="1.0" encoding="UTF-8"?>
<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:ns1="http://developer.intuit.com/">
<SOAP-ENV:Body><ns1:' . $method . 'Response>';
$vars = get_object_vars($Response);
$soap .= $this->_serialize($vars);
$soap .= '</ns1:' . $method . 'Response>
</SOAP-ENV:Body>
</SOAP-ENV:Envelope>';
print($soap);
return true;
}
else
{
$soap = '';
$soap .= '<?xml version="1.0" encoding="UTF-8"?>' . QUICKBOOKS_CRLF;
$soap .= '<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/">' . QUICKBOOKS_CRLF;
$soap .= ' <SOAP-ENV:Body>' . QUICKBOOKS_CRLF;
$soap .= ' <SOAP-ENV:Fault>' . QUICKBOOKS_CRLF;
$soap .= ' <faultcode>SOAP-ENV:Client</faultcode>' . QUICKBOOKS_CRLF;
$soap .= ' <faultstring>Bad Request: ' . htmlspecialchars($errnum) . ': ' . htmlspecialchars($errmsg) . '</faultstring>' . QUICKBOOKS_CRLF;
$soap .= ' </SOAP-ENV:Fault>' . QUICKBOOKS_CRLF;
$soap .= ' </SOAP-ENV:Body>' . QUICKBOOKS_CRLF;
$soap .= '</SOAP-ENV:Envelope>' . QUICKBOOKS_CRLF;
print($soap);
return false;
}
} | php | {
"resource": ""
} |
q256089 | QuickBooks_IPP_Object.walk | test | public function walk($callback)
{
//print_r($this->_data);
//exit;
foreach ($this->_data as $key => $value)
{
if (is_object($value))
{
$value->walk($callback);
}
else if (is_array($value))
{
foreach ($value as $skey => $svalue)
{
if (is_object($svalue))
{
$svalue->walk($callback);
}
else
{
$this->_data[$key][$skey] = call_user_func($callback, $this->resource(), $key, $svalue);
}
}
}
else
{
$this->_data[$key] = call_user_func($callback, $this->resource(), $key, $value);
}
}
} | php | {
"resource": ""
} |
q256090 | Quickbooks_Payments.charge | test | public function charge($Context, $Object_or_token, $amount, $currency = 'USD', $description = '', array $context = array())
{
$capture = true;
return $this->_chargeOrAuth($Context, $Object_or_token, $amount, $currency, $capture, $description, $context);
} | php | {
"resource": ""
} |
q256091 | Quickbooks_Payments.getCharge | test | public function getCharge($Context, $id)
{
$resp = $this->_http($Context, QuickBooks_Payments::URL_CHARGE . '/' . $id, null);
$data = json_decode($resp, true);
$ignore_declines = true;
if ($this->_handleError($data, $ignore_declines))
{
return false;
}
return new QuickBooks_Payments_Transaction($data);
} | php | {
"resource": ""
} |
q256092 | Quickbooks_Payments.getDebit | test | public function getDebit($Context, $id)
{
$resp = $this->_http($Context, QuickBooks_Payments::URL_ECHECK . '/' . $id, null);
$data = json_decode($resp, true);
$ignore_declines = true;
if ($this->_handleError($data, $ignore_declines))
{
return false;
}
return new QuickBooks_Payments_Transaction($data);
} | php | {
"resource": ""
} |
q256093 | Quickbooks_Payments.refund | test | public function refund($Context, $id, $amount, $context = array())
{
$url = str_replace('<id>', $id, QuickBooks_Payments::URL_REFUND);
$payload = array(
'amount' => $amount,
'context' => array(
'mobile' => false,
'isEcommerce' => false,
'recurring' => false,
),
);
$resp = $this->_http($Context, $url, json_encode($payload));
$data = json_decode($resp, true);
if ($this->_handleError($data))
{
return false;
}
return new QuickBooks_Payments_Transaction($data);
} | php | {
"resource": ""
} |
q256094 | Quickbooks_Payments.storeCard | test | public function storeCard($Context, $id, $Object)
{
$id = str_replace(array('{', '}', '-'), '', $id);
$url = str_replace('<id>', $id, QuickBooks_Payments::URL_CARD);
if ($Object instanceof QuickBooks_Payments_CreditCard)
{
$payload = $Object->toArray();
}
else
{
$this->_setError();
return false;
}
$resp = $this->_http($Context, $url, json_encode($payload));
$data = json_decode($resp, true);
if ($this->_handleError($data))
{
return false;
}
return QuickBooks_Payments_CreditCard::fromArray($data);
} | php | {
"resource": ""
} |
q256095 | Quickbooks_Payments.storeCardFromToken | test | public function storeCardFromToken($Context, $id, $token)
{
$id = str_replace(array('{', '}', '-'), '', $id);
$url = str_replace('<id>', $id, QuickBooks_Payments::URL_CARD . '/createFromToken');
$payload = array(
'value' => $token
);
$resp = $this->_http($Context, $url, json_encode($payload));
$data = json_decode($resp, true);
if ($this->_handleError($data))
{
return false;
}
return QuickBooks_Payments_CreditCard::fromArray($data);
} | php | {
"resource": ""
} |
q256096 | Quickbooks_Payments.getCard | test | public function getCard($Context, $id, $card_id)
{
$id = str_replace(array('{', '}', '-'), '', $id);
$url = str_replace('<id>', $id, QuickBooks_Payments::URL_CARD . '/' . $card_id);
$resp = $this->_http($Context, $url);
$data = json_decode($resp, true);
if ($this->_handleError($data))
{
return false;
}
return QuickBooks_Payments_CreditCard::fromArray($data);
} | php | {
"resource": ""
} |
q256097 | Quickbooks_Payments.getCards | test | public function getCards($Context, $id)
{
$id = str_replace(array('{', '}', '-'), '', $id);
$url = str_replace('<id>', $id, QuickBooks_Payments::URL_CARD);
$resp = $this->_http($Context, $url, null);
$data = json_decode($resp, true);
if ($this->_handleError($data))
{
return false;
}
$cards = array();
foreach ($data as $card)
{
$cards[] = QuickBooks_Payments_CreditCard::fromArray($card);
}
return $cards;
} | php | {
"resource": ""
} |
q256098 | Quickbooks_Payments.deleteCard | test | public function deleteCard($Context, $id, $card_id)
{
$id = str_replace(array('{', '}', '-'), '', $id);
$url = str_replace('<id>', $id, QuickBooks_Payments::URL_CARD . '/' . $card_id);
$resp = $this->_http($Context, $url, null, 'DELETE');
$data = json_decode($resp, true);
if ($this->_handleError($data))
{
return false;
}
return true;
} | php | {
"resource": ""
} |
q256099 | Quickbooks_Payments._handleError | test | protected function _handleError($data, $ignore_declines = false)
{
if (!$data)
{
// Check for 401/other errors
$info = $this->_last_httpinfo;
if ($info['http_code'] == QuickBooks_HTTP::HTTP_401)
{
$this->_setError($info['http_code'], 'Unauthorized.');
return true;
}
else if ($info['http_code'] == QuickBooks_HTTP::HTTP_404)
{
$this->_setError($info['http_code'], 'Not Found.');
return true;
}
else if ($info['http_code'] == QuickBooks_HTTP::HTTP_500)
{
$this->_setError($info['http_code'], 'Internal Server Error.');
return true;
}
}
if (isset($data['errors']))
{
$err = array_merge(array(
'code' => null,
'message' => null,
'type' => null,
'detail' => null,
'infoLink' => null,
), $data['errors'][0]);
$this->_setError($err['code'], $err['message'], $err['type'], $err['detail'], $err['infoLink']);
return true;
}
if (!$ignore_declines)
{
if (isset($data['status']) and
$data['status'] == self::STATUS_DECLINED)
{
$this->_setError(self::ERROR_DECLINE, 'This transaction was declined.');
return true;
}
}
return false;
} | php | {
"resource": ""
} |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.