Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit 6478444
Showing
46 changed files
with
5,447 additions
and
0 deletions.
There are no files selected for viewing
Binary file not shown.
Binary file not shown.
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
<html> | ||
<body> | ||
<style> | ||
body { | ||
font-size: 12px; | ||
font-family: Trebuchet MS, Arial, Tahoma; | ||
padding: 0px; | ||
margin: 0px; | ||
} | ||
div.type { | ||
float: right; | ||
color: gray; | ||
font-weight: bold; | ||
padding-right: 10px; | ||
} | ||
h1 { | ||
margin: 0px; | ||
padding 20px; | ||
background-color: #444444; | ||
color: white; | ||
} | ||
pre.req { | ||
padding: 20px; | ||
background-color: #f1f1f1; | ||
} | ||
pre.resp { | ||
padding: 20px; | ||
background-color: #f1f1f1; | ||
} | ||
form { | ||
padding: 20px; | ||
background-color: #f1f1ff; | ||
} | ||
</style> | ||
<h1>InvoiceFox API explorer</h1> | ||
<?php | ||
require_once "pulp/Format.php"; | ||
require_once "strpcapi.php"; | ||
require_once "invfoxapi.php"; | ||
|
||
if (isset($_POST['call'])) { | ||
|
||
$api = new InvfoxAPI('vr64g6891lgatnf83dmxticsc10ashr2f4s9ye7w'); | ||
|
||
$resp = $api->assurePartner("name=asdasd&street=asdasds&postal=12312&city=asdasd&vatid=&phone=&website=&email=¬es=&vatbound=0&custaddr=&payment_period=14&street2=asdsad"); | ||
|
||
echo "<br/><div class='type'>response</div><pre class='resp'>"; print_r($resp->res); echo "</pre>"; | ||
|
||
} | ||
?> | ||
<form method="post"> | ||
<input type="submit" name="call" value="Call" /> | ||
</body> | ||
</html> | ||
name=asdasd&street=asdasds&postal=12312&city=asdasd&vatid=&phone=&website=&email=¬es=&vatbound=0&custaddr=&payment_period=14&street2=asdsad |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
<?php | ||
|
||
class InvFoxAPI { | ||
|
||
function get( ) { | ||
$header = "GET /API.html?apitoken=9i7a6dnr4b0k82r6qaj583ssefy9otcp7am2dhr4&_r=partner&_m=select-all-safe&filter=all&page=0 HTTP/1.1\r\n". | ||
"Host:example.com\n". | ||
"Content-Type: application/x-www-form-urlencoded\r\n". | ||
"User-Agent: PHP-Code\r\n". | ||
"Content-Length: " . strlen($req) . "\r\n". | ||
"Authorization: Basic ".base64_encode($username.':'.$password)."\r\n". | ||
"Connection: close\r\n\r\n"; | ||
|
||
//$req .= "&cmd=_initiate_query"; | ||
|
||
$fp = fsockopen ('ssl://www.invoicefox.com', 443, $errno, $errstr, 30); | ||
if (!$fp) { | ||
// HTTP ERROR | ||
} else { | ||
fputs ($fp, $header); | ||
while (!feof($fp)) { | ||
$result .= fgets ($fp, 128); | ||
} | ||
fclose ($fp); | ||
} | ||
|
||
} | ||
|
||
function createInvoice() { | ||
|
||
|
||
} | ||
|
||
} | ||
|
||
?> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
<html> | ||
<body> | ||
<style> | ||
body { | ||
font-size: 12px; | ||
font-family: Trebuchet MS, Arial, Tahoma; | ||
padding: 0px; | ||
margin: 0px; | ||
} | ||
div.type { | ||
float: right; | ||
color: gray; | ||
font-weight: bold; | ||
padding-right: 10px; | ||
} | ||
h1 { | ||
margin: 0px; | ||
padding 20px; | ||
background-color: #444444; | ||
color: white; | ||
} | ||
pre.req { | ||
padding: 20px; | ||
background-color: #f1f1f1; | ||
} | ||
pre.resp { | ||
padding: 20px; | ||
background-color: #f1f1f1; | ||
} | ||
form { | ||
padding: 20px; | ||
background-color: #f1f1ff; | ||
} | ||
</style> | ||
<h1>InvoiceFox API explorer</h1> | ||
<?php | ||
require_once "pulp/Format.php"; | ||
require_once "strpcapi.php"; | ||
require_once "invfoxapi.php"; | ||
|
||
|
||
$apidef = array( | ||
'invoice-sent' => array('select-all'), | ||
'invoice-recv' => array('select-all'), | ||
'partner' => array('select-all'), | ||
'preinvoice' => array('select-all') | ||
); | ||
|
||
$RESOURCE = isset($_POST['resource']) ? $_POST['resource'] : ''; | ||
$METHOD = isset($_POST['method']) ? $_POST['method'] : ''; | ||
$ARGS = isset($_POST['args']) ? $_POST['args'] : ''; | ||
|
||
|
||
if (isset($_POST['call'])) { | ||
$strpc = new StrpcAPI('vr64g6891lgatnf83dmxticsc10ashr2f4s9ye7w'); | ||
$response = $strpc->call($RESOURCE, $METHOD, $ARGS); | ||
echo "<br/><div class='type'>response</div><pre class='resp'>"; print_r($response->res); echo "</pre>"; | ||
} | ||
?> | ||
<form method="post"> | ||
resource:<br/><input name="resource" value="<?php echo $RESOURCE ?>" /> | ||
<small><?php foreach ( $apidef as $res => $meths ) { echo $res . " "; } ?></small> | ||
<br/> | ||
method: <br/><input name="method" value="<?php echo $METHOD ?>"/><br/> | ||
<br/> | ||
arguments: <br/><textarea name="args" cols="100" rows="5"></textarea><br/> | ||
<input type="submit" name="call" value="Call" /> | ||
</body> | ||
</html> | ||
name=asdasd&street=asdasds&postal=12312&city=asdasd&vatid=&phone=&website=&email=¬es=&vatbound=0&custaddr=&payment_period=14&street2=asdsad |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
<?php | ||
|
||
class InvFoxAPI { | ||
|
||
function get( ) { | ||
$header = "GET /API.html?apitoken=9i7a6dnr4b0k82r6qaj583ssefy9otcp7am2dhr4&_r=partner&_m=select-all-safe&filter=all&page=0 HTTP/1.1\r\n". | ||
"Host:example.com\n". | ||
"Content-Type: application/x-www-form-urlencoded\r\n". | ||
"User-Agent: PHP-Code\r\n". | ||
"Content-Length: " . strlen($req) . "\r\n". | ||
"Authorization: Basic ".base64_encode($username.':'.$password)."\r\n". | ||
"Connection: close\r\n\r\n"; | ||
|
||
//$req .= "&cmd=_initiate_query"; | ||
|
||
$fp = fsockopen ('ssl://www.invoicefox.com', 443, $errno, $errstr, 30); | ||
if (!$fp) { | ||
// HTTP ERROR | ||
} else { | ||
fputs ($fp, $header); | ||
while (!feof($fp)) { | ||
$result .= fgets ($fp, 128); | ||
} | ||
fclose ($fp); | ||
} | ||
|
||
} | ||
|
||
function createInvoice() { | ||
|
||
|
||
} | ||
|
||
} | ||
|
||
print_r(InvFoxAPI::get()); | ||
|
||
?> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
<?php | ||
|
||
class InvfoxAPI { | ||
|
||
var $api; | ||
|
||
function InvfoxAPI($apitoken) { | ||
$this->api = new StrpcAPI($apitoken); | ||
} | ||
|
||
function assurePartner($data) { | ||
$res = $this->api->call('partner', 'assure', $data); | ||
if ($res->isErr()) { | ||
// echo 'error' . $res->getErr(); | ||
} | ||
return $res; | ||
} | ||
|
||
function createInvoice($header, $body) { | ||
$res = $this->api->call('invoice-sent', 'insert', $header); | ||
if ($res->isErr()) { | ||
echo 'error' . $res->getErr(); | ||
} else { | ||
foreach ($body as $bl) { | ||
$res2 = $this->api->call('invoice-sent-b', 'insert', $bl); | ||
if ($res->isErr()) { | ||
echo 'error' . $res->getErr(); | ||
} | ||
} | ||
} | ||
return $res->getData(); | ||
} | ||
|
||
function downloadPDF($id) { | ||
$res = $apipdf->load($id, $id.".pdf"); | ||
if ($res->isErr()) { | ||
echo 'error' . $res->getErr(); | ||
} | ||
} | ||
|
||
function markPayed() { | ||
$res = $this->api->call('invoice-sent', 'mark-payed', array('id' => $id)); | ||
if ($res->isErr()) { | ||
echo 'error' . $res->getErr(); | ||
} | ||
} | ||
|
||
} | ||
|
||
?> |
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
<?php | ||
|
||
require_once 'Http.php'; | ||
|
||
class Arr { | ||
|
||
static function setDefaults($a, $defs) | ||
{ | ||
foreach($defs as $k => $d){ | ||
if (!isset($a[$k])) | ||
{ | ||
$a[$k] = $d; | ||
} | ||
} | ||
return $a; | ||
} | ||
|
||
static function toIndexed($a, $ks) | ||
{ | ||
$r = array(); | ||
foreach($ks as $k) | ||
{ | ||
$r[] = $a[$k]; | ||
} | ||
return $r; | ||
} | ||
|
||
static function reducek($array, $callback, $initial=null) | ||
//reduce function with array key and value | ||
{ | ||
$acc = $initial; | ||
foreach($array as $k => $v) | ||
$acc = call_user_func_array($callback, array($acc, $k, $v)); | ||
return $acc; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
<?php | ||
|
||
class Browser | ||
{ | ||
|
||
function redirect($location) | ||
//i: redirect using the header command and exit | ||
{ | ||
if (strtolower(substr($location, 0, 4)) == 'http') | ||
{ | ||
header("Location: $location"); | ||
exit; | ||
} | ||
else | ||
{ | ||
$host = $_SERVER['HTTP_HOST']; | ||
$uri = rtrim(dirname($_SERVER['PHP_SELF']), '/\\'); | ||
header("Location: http://$host$uri/" . htmlspecialchars_decode($location)); | ||
exit; | ||
} | ||
} | ||
|
||
function redirectDelayed($location, $delay, $text='Redirecting...', $other=array()) | ||
//i: redirect using the header command and exit | ||
{ | ||
$title = isset($other['title']) ? $other['title'] : 'Redirecting...'; | ||
$bodyParams = isset($other['bodyParams']) ? $other['bodyParams'] : ''; | ||
$divParams = isset($other['divParams']) ? $other['divParams'] : ''; | ||
$autoLink = isset($other['autoLink']) ? $other['autoLink'] : false; | ||
$autoLinkTemplate = isset($other['autoLinkTemplate']) ? $other['autoLinkTemplate'] : | ||
"<br/><br/><a href='%%'>Click here to go now</a>"; | ||
$location2 = isset($other['location2']) ? $other['location2'] : ''; | ||
$location3 = isset($other['location3']) ? $other['location3'] : ''; | ||
$location4 = isset($other['location4']) ? $other['location4'] : ''; | ||
$location5 = isset($other['location5']) ? $other['location5'] : ''; | ||
$location6 = isset($other['location6']) ? $other['location6'] : ''; | ||
|
||
if ($autoLink) | ||
{ | ||
$autoLinkTemplate = str_replace('%delay%', $delay, $autoLinkTemplate); | ||
$text .= str_replace('%location%', $location, $autoLinkTemplate); | ||
if ($location2) $text = str_replace('%location2%', $location2, $text); | ||
if ($location3) $text = str_replace('%location3%', $location3, $text); | ||
if ($location4) $text = str_replace('%location4%', $location4, $text); | ||
if ($location5) $text = str_replace('%location5%', $location5, $text); | ||
if ($location6) $text = str_replace('%location6%', $location6, $text); | ||
} | ||
|
||
echo "<html> | ||
<head> | ||
<title>$title</title> | ||
<META HTTP-EQUIV='Refresh' | ||
CONTENT='$delay; URL=$location'> | ||
</head> | ||
<body $bodyParams> | ||
<div $divParams> | ||
$text | ||
</div> | ||
</body> | ||
</html> | ||
"; | ||
exit(); | ||
} | ||
|
||
|
||
} | ||
|
||
?> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
<?php | ||
|
||
class Crumbs { | ||
|
||
static private $crumbs = array(); | ||
static private $end; | ||
|
||
static public function add($name, $link) { | ||
|
||
self::$crumbs[] = array('name'=>ucfirst($name), 'link'=>$link); | ||
|
||
} | ||
|
||
static public function addAtEnd($name, $link) { | ||
|
||
self::$end = array('name'=>ucfirst($name), 'link'=>$link); | ||
|
||
} | ||
|
||
static public function show() { | ||
|
||
if (isset(self::$end)) { | ||
self::$crumbs[] = self::$end; | ||
} | ||
$return = '<div id="crumbs"><ul>'; | ||
$return .= '<li><a href="' . URL::build('osnovna.php') . '"><span>Osnovna stran</span></a></li>'; | ||
foreach (self::$crumbs as $crumb) { | ||
$return .= "<li><a href='{$crumb['link']}'><span>{$crumb['name']}</span></a></li>"; | ||
} | ||
$return .= '</ul></div>'; | ||
|
||
return $return; | ||
} | ||
|
||
} |
Oops, something went wrong.