if ($maxResults1 > 0) { $curr_url .= "&max=" . $maxResults1; } if ($start != 0) { $curr_url .= "&start=" . $start; } //$curr_url .= "#section"; echo "<dt><input class=\"img-ol\" src=\"\" alt=\"\" title=\"\" type=\"image\" /> <a href='#' >" . stripslashes($row['title']) . "</a></dt>"; /* if( strlen($row['description']) < 300 ) echo $row['description']."<br/>"; else echo substr($row['description'],0,300)."...<br/>"; */ echo "<dd>"; echo "<p><strong>" . _AT('ol_descri') . "</strong><br/>" . stripslashes($row['description']) . "</p>"; echo "<p><strong>" . _AT('ol_keywords') . "</strong><br/>" . stripslashes($row['keywords']) . "</p>"; $datentime = datestamp(stripslashes($row['datestamp'])); echo "<p><strong>" . _AT('ol_last_modi') . "</strong><br/>" . $datentime[0] . " " . _AT('ol_at') . " " . $datentime[1] . "</p>"; echo "<br/>"; $i++; //link for CC & CP files of unit $imgs = "<a href='" . $row['cp'] . "'> <img src='mods/ol_search_open_learn/images/cp.png' alt='" . _AT('ol_tool_1') . "' title='" . _AT('ol_tool_1') . "' border='0' /> </a> <a href='" . $row['cc'] . "'> <img src='mods/ol_search_open_learn/images/cc.png' alt='" . _AT('ol_tool_2') . "' title='" . _AT('ol_tool_2') . "' border='0' /> </a>"; //link for popup window of unit $prevw = "<a href=\"javascript: void(popup('" . $row['website'] . "','Preview',screen.width*0.45,screen.height*0.45));\" ><img src='mods/ol_search_open_learn/images/popup.gif' alt='" . _AT('ol_tool_3') . "' title='" . _AT('ol_tool_3') . "' border='0' /> </a>"; //link for RSS of unit $rss = "<a href=\"javascript: void(popup('" . parseForNumber($row['cc'], $row['entry'], $_config['ol_rss_url']) . "','RSS',screen.width*0.45,screen.height*0.45));\"><img src='mods/ol_search_open_learn/images/rss.gif' alt='" . _AT('ol_tool_4') . "' title='" . _AT('ol_tool_4') . "' border='0' /></a>"; //link for .doc file of unit $doc_file = "<a href=\"javascript: void(popup('" . AT_BASE_HREF . "mods/ol_search_open_learn/doc.php?cc=" . $row['cc'] . "&entry=" . $row['entry'] . "','Download',screen.width*0.30,screen.height*0.20));\" ><img src='mods/ol_search_open_learn/images/word.gif' alt='" . _AT('ol_tool_5') . "' title='" . _AT('ol_tool_5') . "' border='0' /></a>"; echo "<div align='left' class='menuitems'>" . $imgs . $prevw . $rss . $doc_file . "</div><br/>"; echo "</dd>"; } echo "</dl>";
* * $auth = sha1($entropy.$SERVER_KEY.$action.$version) * * If it isn't, the request is bad. ***/ $r = $u->verifyApp($app_verify); if (!$r['status']) { returnAjax(array('status' => false, 'human_error' => "This app isn't authorized. Please log out and log back in.", 'error' => 'Invalid app credentials', 'app_error_code' => 106)); } # Call the $action $action_data['user_data'] = $r['data']; $action_result = $action_function_map[$action]($action_data); $action_result['elapsed'] = elapsed(); returnAjax($action_result); } $write = "\n" . datestamp() . ' - ' . json_encode($_REQUEST); file_put_contents('access.log', $write, FILE_APPEND | LOCK_EX); authorizeApp($_REQUEST); /******************* * The functions that actually do stuff * Called by the "action" key through verifyApp *******************/ function syncUserData($data_array) { return $data_array['user_data']; } function billUser($data_array) { /*** * Do a charge against the user, then update the status all around. ***/
function billUser($full_data_array) { /*** * Do a charge against the user, then update the status all around. * * https://developers.braintreepayments.com/android+php/reference/request/transaction/sale ***/ $data_array = $full_data_array["post_data"]; $brainTreeTransaction = array("amount" => $data_array["amount"], "paymentMethodNonce" => $data_array["nonce"], 'customer' => array(), 'options' => array('storeInVaultOnSuccess' => true, 'submitForSettlement' => true)); global $billingTokens; $billingTokens = array(); try { $braintree = Braintree_Transaction::sale($brainTreeTransaction); $result = array("status" => $braintree->success, "braintree_result" => $braintree); if (!$braintree->success) { $result["app_error_code"] = 115; $result["details"] = array(); $result["requested_action"] = "bill"; $result["human_error"] = "Failed to charge your card. Please try again later."; $result["given"] = $data_array; } else { try { # Post-process $billingTokens["status"] = true; $postProcessDetails = array(); $givenArgs = smart_decode64($data_array["billActionDetail"]); $billingTokens["provided"] = $givenArgs; $postAction = $givenArgs["action"]; switch ($postAction) { # Set all the $postProcessDetails data case "session": break; case "roleChange": $newRole = $givenArgs["newRole"]; # Do the role change break; default: throw new Exception("Bad post-process action '{$postAction}'"); break; } $billingTokens["post_process_details"] = $postProcessDetails; } catch (Exception $e) { # An internal error! We want to log this. $error_id = Stronghash::createSalt(); $write = "\n\n\n\n" . datestamp() . " - " . json_encode($_REQUEST); $write .= "\nError ID: {$error_id}"; $write .= "\nGot error: " . $e->getMessage(); $write .= "\n" . implode("\n", jTraceEx($e)); file_put_contents('billing_errors.log', $write, FILE_APPEND | LOCK_EX); $billingTokens["status"] = false; $billingTokens["error"] = $e->getMessage(); $billingTokens["human_error"] = "Your card was charged, but we couldn't update the server. Please contact support with error ID {$error_id}"; $billingTokens["need_popup"] = true; $result["status"] = false; $result["app_error_code"] = 116; } } } catch (Exception $e) { # Just the Braintree errors $result = array("status" => false, "error" => $e->getMessage(), "human_error" => "Unable to charge your card", "app_error_code" => 114, "given" => $data_array); } return $result; }