function limit_exceeded($duration, $enabled, $instance_id, $limit)
{
    if (!$enabled) {
        return false;
    }
    //throttling disabled
    $number = normalize_phone_to_E164($_REQUEST['From']);
    $data = PluginData::get($instance_id . "__" . $number);
    $duration = intval($duration) * 60;
    //convert it into seconds
    if (!$data) {
        PluginData::set($instance_id . "__" . $number, array('limit' => 1, 'added' => time()));
        return false;
    }
    //clean expired time
    if (!empty($data->added) && time() - $data->added > $duration) {
        PluginData::set($instance_id . "__" . $number, array('limit' => 0, 'added' => time()));
        $data = PluginData::get($instance_id . "__" . $number);
    }
    if ($data->limit >= $limit && time() - $data->added <= $duration) {
        PluginData::set($instance_id . "__" . $number, array('limit' => $data->limit + 1, 'added' => $data->added));
        return true;
    } else {
        PluginData::set($instance_id . "__" . $number, array('limit' => $data->limit + 1, 'added' => $data->added));
        return false;
    }
}
Esempio n. 2
0
 public static function get($key, $default = null)
 {
     error_log('Deprecating in 0.75: ' . __FUNCTION__);
     try {
         return PluginData::get($key, $default);
     } catch (PluginDataException $e) {
         throw new PluginStoreException($e->getMessage());
     }
 }
Esempio n. 3
0
<?php

if (count($_POST)) {
    foreach ($_POST['keys'] as $k => $v) {
        if (empty($v)) {
            unset($_POST['keys'][$k]);
            unset($_POST['status'][$k]);
        }
    }
    PluginData::set('orders', array('keys' => $_POST['keys'], 'status' => $_POST['status']));
}
$settings = PluginData::get('orders', array('keys' => array(), 'status' => array()));
#	print_r( $settings );
$statusArray = array('shipped' => 'Shipped', 'fullfillment' => 'Sent to Fullfillment', 'processing' => 'Processing');
OpenVBX::addJS('script.js');
?>
<div class="vbx-plugin orders-applet">
<form method="post">
	<h2>Order Tracker</h2>
	<p>Enter an order ID, without spaces.  For example, <code>1234</code> instead of <code>123 4</code>.</p>
	<table class="vbx-orders-grid options-table">
	<thead>
		<tr>
			<td>Order ID</td>
			<td>Status</td>
			<td>Actions</td>
		</tr>
	</thead>
	<tbody>
		<?php 
foreach ($settings->keys as $i => $key) {
<?php

$settings = PluginData::get('settings');
if (is_object($settings)) {
    $settings = get_object_vars($settings);
}
?>
<div class="vbx-applet">
<?php 
if (!empty($settings) && !empty($settings['api_key'])) {
    ?>
	<div class="vbx-full-pane">
		<h3>Amount</h3>
		<p>A positive integer in cents representing much to charge the card.</p>
		<fieldset class="vbx-input-container">
			<input type="text" name="amount" class="medium" value="<?php 
    echo AppletInstance::getValue('amount', 50);
    ?>
" />
		</fieldset>
		<h3>Description</h3>
		<fieldset class="vbx-input-container">
			<input type="text" name="description" class="medium" value="<?php 
    echo AppletInstance::getValue('description');
    ?>
" />
		</fieldset>
	</div>
	<h2>After the payment</h2>
	<div class="vbx-full-pane">
		<?php 
Esempio n. 5
0
<?php

$CI =& get_instance();
$plugin_info = $plugin->getInfo();
$zendesk_user = PluginData::get('zendesk_user');
$currentlyIsUser = AppletInstance::getUserGroupPickerValue('permissions') instanceof VBX_User;
?>
<style>
a.ajax_loader { background:url(<?php 
echo base_url();
?>
assets/i/ajax-loader.gif); display:inline-block; width:16px; height:11px; vertical-align:middle; }
div.system_msg { display:inline-block; line-height:30px; vertical-align:center; }
div.system_msg > * { vertical-align:middle; }
div.vbx-applet div.section { margin-bottom:20px; }
span[class$="err"] { color:red; }
</style>

<div class="vbx-applet zendesk_ticket_applet">
    <?php 
if (empty($zendesk_user)) {
    ?>
    <div id="zendesk_api_access" class="section">
        <h2>Zendesk API Access</h2>
        <p>It looks like you are setting up for the first time. Please enter your access credentials so we can connect to Zendesk.</p>

        <div class="vbx-input-container input" style="margin-bottom:10px;">
            <label>Zendesk Url - the url to your Zendesk which is something like https or http://yoursite.zendesk.com.</label>
            <input name="zendesk_url" class="medium" type="text" value="" />
            <span class="zendesk_url_err"></span>
        </div>
Esempio n. 6
0
<?php

require_once dirname(__FILE__) . '/../../lib/dopplr.php';
$user = OpenVBX::getCurrentUser();
$dopplr_token = PluginData::get("dopplr_token_{$user->id}", "");
$dopplr = new Dopplr($dopplr_token);
$response = new Response();
if ($dopplr->travel_today()) {
    $response->addRedirect(AppletInstance::GetDropZoneUrl('in_transit'));
} else {
    if ($dopplr->at_home) {
        $response->addRedirect(AppletInstance::GetDropZoneUrl('at_home'));
    } else {
        $response->addRedirect(AppletInstance::GetDropZoneUrl('on_the_road'));
    }
}
$response->Respond();
<?php

if (count($_POST)) {
    PluginData::set('settings', array('api_key' => $_POST['api_key'], 'card_prompt' => $_POST['card_prompt'], 'month_prompt' => $_POST['month_prompt'], 'year_prompt' => $_POST['year_prompt'], 'require_cvc' => isset($_POST['require_cvc']), 'cvc_prompt' => $_POST['cvc_prompt']));
}
$settings = PluginData::get('settings', array('api_key' => null, 'card_prompt' => "Please enter your credit card number followed by the pound sign.", 'month_prompt' => "Please enter the month of the card's expiration date followed by the pound sign.", 'year_prompt' => "Please enter the year of the expiration date followed by the pound sign.", 'require_cvc' => true, 'cvc_prompt' => "Please enter the card's security code followed by the pound sign."));
if (is_object($settings)) {
    $settings = get_object_vars($settings);
}
OpenVBX::addJS('stripe.js');
?>
<style>
	.vbx-stripe form {
		padding: 20px 5%;
	}
	.vbx-stripe form p {
		margin: 20px 0;
	}
</style>
<div class="vbx-content-main">
	<div class="vbx-content-menu vbx-content-menu-top">
		<h2 class="vbx-content-heading">Stripe Settings</h2>
	</div>
	<div class="vbx-table-section vbx-stripe">
		<form method="post" action="">
			<fieldset class="vbx-input-container">
				<p>
					<label class="field-label">API Key<br/>
						<input type="password" name="api_key" class="medium" value="<?php 
echo htmlentities($settings['api_key']);
?>
   
        var parts = phonenum.match(regexObj);
        var phone = "";
        if (parts[1]) { phone += "(" + parts[1] + ") "; }
        phone += parts[2] + "-" + parts[3];
        return phone;
    }
</script>

	
	<h3>Complete Call Log</h3>
	<div style="width: 100%; height: auto; overflow: hidden;">
	<br />
	<form method="POST">
		<label style="display: inline; float: left; margin-right: 20px; font-size: 16px; font-weight: bold; position: relative; top: 6px;">Set Your Timezone</label><?php 
echo timezone_menu(PluginData::get("timezone", 'UM8'));
?>
		<button class="submit-button ui-state-focus" style="margin-left: 4px; display: inline; float: left;" type="submit"><span>Set Timezone</span></button>
		
	</form>
	</div>
	<table>
		<thead>
			<tr>
				<th>Number</th>
				<th>Start Time</th>
				<th>Duration</th>
				<th>Called</th>
				<th>Status</th>
			</tr>
		</thead>