| 1 |
<?php |
| 2 |
/* |
| 3 |
Plugin Name: Quick Interest Slider |
| 4 |
Plugin URI: http://loanpaymentplugin.com/ |
| 5 |
Description: Interest calculator with slider and multiple display options. |
| 6 |
Version: 2.2 |
| 7 |
Author: aerin |
| 8 |
Author URI: http://quick-plugins.com/ |
| 9 |
Text Domain: quick-interest-slider |
| 10 |
Domain Path: /languages |
| 11 |
*/ |
| 12 |
|
| 13 |
require_once( plugin_dir_path( __FILE__ ) . '/options.php' ); |
| 14 |
require_once( plugin_dir_path( __FILE__ ) . '/register.php' ); |
| 15 |
|
| 16 |
$qis_forms = 0; |
| 17 |
|
| 18 |
add_shortcode('qis', 'qis_loop'); |
| 19 |
add_shortcode('qis-subscribe', 'qis_subscribe'); |
| 20 |
|
| 21 |
add_action('wp_enqueue_scripts', 'qis_scripts'); |
| 22 |
add_action('plugins_loaded', 'qis_lang_init'); |
| 23 |
add_action('wp_head', 'qis_head_css'); |
| 24 |
add_action( 'template_redirect', 'qis_upgrade_ipn' ); |
| 25 |
|
| 26 |
add_filter('plugin_action_links', 'qis_plugin_action_links', 10, 2 ); |
| 27 |
|
| 28 |
if (is_admin()) require_once( plugin_dir_path( __FILE__ ) . '/settings.php' ); |
| 29 |
|
| 30 |
function qis_loop($atts) { |
| 31 |
|
| 32 |
// Shortcode Attributes |
| 33 |
|
| 34 |
$atts = shortcode_atts(array( |
| 35 |
'formheader' => '', |
| 36 |
'currency' => '', |
| 37 |
'ba' => '', |
| 38 |
'primary' => '', |
| 39 |
'secondary' => '', |
| 40 |
'loanmin' => '', |
| 41 |
'loanmax' => '', |
| 42 |
'loaninitial' => '', |
| 43 |
'loanstep' => '', |
| 44 |
'periodslider' => '', |
| 45 |
'periodmin' => '', |
| 46 |
'periodmax' => '', |
| 47 |
'periodinitial' => '', |
| 48 |
'periodstep' => '', |
| 49 |
'period' => '', |
| 50 |
'interestslider' => '', |
| 51 |
'interestselector' => '', |
| 52 |
'multiplier' => '', |
| 53 |
'triggertype' => '', |
| 54 |
'trigger' => '', |
| 55 |
'outputtotallabel' => '', |
| 56 |
'interesttype' => '', |
| 57 |
'totallabel' => '', |
| 58 |
'primarylabel' => '', |
| 59 |
'secondarylabel' => '', |
| 60 |
'usebubble' => '', |
| 61 |
'outputlimits' => '', |
| 62 |
'outputtotal' => '', |
| 63 |
'outputrepayments' => '', |
| 64 |
'outputhelp' => '', |
| 65 |
'application' => '', |
| 66 |
'repaymentlabel' => '', |
| 67 |
'buttons' => '', |
| 68 |
'markers' => '', |
| 69 |
'processing' => '', |
| 70 |
'adminfee' => '', |
| 71 |
'adminfeevalue' => '', |
| 72 |
'textinputs' => '', |
| 73 |
'interesttype' => '', |
| 74 |
'decimals' => '', |
| 75 |
'discount' => '', |
| 76 |
'applynow' => '', |
| 77 |
'fixedaddition' => '', |
| 78 |
'application' => '', |
| 79 |
'formname' => '', |
| 80 |
'fields' => '', |
| 81 |
'loanlabel' => '', |
| 82 |
'termlabel' => '', |
| 83 |
'interestlabel' => '', |
| 84 |
'parttwo' => '', |
| 85 |
'usecurrencies' => '', |
| 86 |
'usefx' => '', |
| 87 |
'usedownpayment' => '' |
| 88 |
),$atts,'quick-interest-slider'); |
| 89 |
|
| 90 |
// Pro Version filters |
| 91 |
|
| 92 |
$qppkey = get_option('qpp_key'); |
| 93 |
if (!$qppkey['authorised']) { |
| 94 |
$atts['formheader'] = $atts['loanlabel'] = $atts['termlabel'] = $atts['application'] = $atts['applynow'] = $atts['interestslider'] = $atts['intereselector']= $atts['usecurrencies'] = $atts['usefx'] = $atts['usedownpayment'] = false; |
| 95 |
if ($atts['interesttype'] == 'amortization' || $atts['interesttype'] == 'amortisation') $atts['interesttype'] = 'compound'; |
| 96 |
} |
| 97 |
|
| 98 |
global $post; |
| 99 |
|
| 100 |
// Apply Now Button |
| 101 |
|
| 102 |
if (!empty($_POST['qisapply'])) { |
| 103 |
$settings = qis_get_stored_settings(); |
| 104 |
$formvalues = $_POST; |
| 105 |
$url = $settings['applynowaction']; |
| 106 |
if ($settings['applynowquery']) $url = $url.'?amount='.$_POST['loan-amount'].'&period='.$_POST['loan-period']; |
| 107 |
echo "<p>".__('Redirecting....','quick-interest-slider')."</p><meta http-equiv='refresh' content='0;url=$url' />"; |
| 108 |
die(); |
| 109 |
|
| 110 |
// Application Form |
| 111 |
|
| 112 |
} elseif (!empty($_POST['qissubmit'])) { |
| 113 |
$formvalues = $_POST; |
| 114 |
$formerrors = array(); |
| 115 |
if (!qis_verify_form($formvalues, $formerrors)) { |
| 116 |
return qis_display($atts,$formvalues, $formerrors,null); |
| 117 |
} else { |
| 118 |
qis_process_form($formvalues); |
| 119 |
$apply = qis_get_stored_application_messages(); |
| 120 |
if ($apply['enable'] || $atts['parttwo']) return qis_display_application($formvalues,array(),'checked'); |
| 121 |
else return qis_display($atts,$formvalues, array(),'checked'); |
| 122 |
} |
| 123 |
|
| 124 |
// Part 2 Application |
| 125 |
|
| 126 |
} elseif (!empty($_POST['part2submit'])) { |
| 127 |
$formvalues = $_POST; |
| 128 |
$formerrors = array(); |
| 129 |
if (!qis_verify_application($formvalues, $formerrors)) { |
| 130 |
return qis_display_application($formvalues, $formerrors,null); |
| 131 |
} else { |
| 132 |
qis_process_application($formvalues); |
| 133 |
return qis_display_result($formvalues); |
| 134 |
} |
| 135 |
|
| 136 |
// Default Display |
| 137 |
|
| 138 |
} else { |
| 139 |
$formname = $atts['formname'] == 'alternate' ? 'alternate' : ''; |
| 140 |
$values = qis_get_stored_register($formname); |
| 141 |
$values['formname'] = $formname; |
| 142 |
$digit1 = mt_rand(1,10); |
| 143 |
$digit2 = mt_rand(1,10); |
| 144 |
if( $digit2 >= $digit1 ) { |
| 145 |
$values['thesum'] = "$digit1 + $digit2"; |
| 146 |
$values['answer'] = $digit1 + $digit2; |
| 147 |
} else { |
| 148 |
$values['thesum'] = "$digit1 - $digit2"; |
| 149 |
$values['answer'] = $digit1 - $digit2; |
| 150 |
} |
| 151 |
return qis_display($atts,$values ,array(),null); |
| 152 |
} |
| 153 |
} |
| 154 |
|
| 155 |
// Display the form on the page |
| 156 |
|
| 157 |
function qis_display($atts,$formvalues,$formerrors,$registered) { |
| 158 |
|
| 159 |
global $qis_forms; |
| 160 |
|
| 161 |
$style = qis_get_stored_style(); |
| 162 |
$settings = qis_get_stored_settings(); |
| 163 |
$register = qis_get_stored_register($formvalues['formname']); |
| 164 |
$fx = qis_get_stored_forex(); |
| 165 |
$qppkey = get_option('qpp_key'); |
| 166 |
|
| 167 |
$qis_forms++; |
| 168 |
|
| 169 |
foreach ($atts as $item => $key) { |
| 170 |
if ($key) { |
| 171 |
$settings[$item] = $key; |
| 172 |
} |
| 173 |
} |
| 174 |
|
| 175 |
// Field override |
| 176 |
|
| 177 |
if ($atts['fields']) $formvalues['fields'] = $atts['fields']; |
| 178 |
if ($atts['interesttype'] = 'amortization') $settings['forceapr'] = true; |
| 179 |
if ($atts['application']) $register['application'] = 'checked'; |
| 180 |
if ($atts['primary']) $settings['triggers'][0]['rate'] = $atts['primary']; |
| 181 |
if ($atts['secondary']) $settings['triggers'][1]['rate'] = $atts['primary']; |
| 182 |
if ($atts['trigger']) $settings['triggers'][1]['trigger'] = $atts['trigger']; |
| 183 |
if ($atts['processing']) { |
| 184 |
if (stristr($atts['processing'],'%')) { |
| 185 |
$settings['adminfee'] = true; |
| 186 |
if (preg_match('/^(\d+?\.?\d*)%$/',$atts['processing'],$matches)) { |
| 187 |
$settings['adminfeevalue'] = trim($matches[1],'.'); |
| 188 |
$settings['adminfeetype'] = 'percent'; |
| 189 |
} |
| 190 |
} else { |
| 191 |
$settings['adminfee'] = true; |
| 192 |
if (is_numeric($atts['processing'])) { |
| 193 |
$settings['adminfeevalue'] = (float) $atts['processing']; |
| 194 |
$settings['adminfeetype'] = 'fixed'; |
| 195 |
} |
| 196 |
} |
| 197 |
} |
| 198 |
|
| 199 |
if ($atts['repaymentlabel']) $settings['outputrepayments'] = 'true'; |
| 200 |
|
| 201 |
$settings['repaymentlabel'] = preg_replace('/{(\w+)}/','[\1]',$settings['repaymentlabel']); |
| 202 |
|
| 203 |
if ($settings['ba'] == 'before') { |
| 204 |
$settings['cb'] = $settings['currency']; |
| 205 |
$settings['ca'] = ' '; |
| 206 |
} else { |
| 207 |
$settings['ca'] = $settings['currency']; |
| 208 |
$settings['cb'] = ' '; |
| 209 |
} |
| 210 |
|
| 211 |
if ($register['application']) $settings['application'] = true; |
| 212 |
if (!isset($formvalues['loan-amount'])) $formvalues['loan-amount'] = $settings['loaninitial']; |
| 213 |
if (!isset($formvalues['loan-period'])) $formvalues['loan-period'] = $settings['periodinitial']; |
| 214 |
if (!isset($formvalues['loan-interest'])) $formvalues['loan-interest'] = $settings['interestinitial']; |
| 215 |
if ($settings['multiplier'] < 1) $formvalues['multiplier'] = 1; |
| 216 |
|
| 217 |
$settings['singleperiod'] = $settings['singleperiodlabel'] ? $settings['singleperiodlabel'] : $settings['period']; |
| 218 |
$settings['periodlabel'] = $settings['periodlabel'] ? $settings['periodlabel'] : $settings['period']; |
| 219 |
|
| 220 |
$settings['offset'] = $register['offset'] ? $register['offset'] : 0; |
| 221 |
|
| 222 |
// Normalize values |
| 223 |
|
| 224 |
$outputA = array(); |
| 225 |
foreach ($settings as $k => $v) { |
| 226 |
$outputA[$k] = $v; |
| 227 |
|
| 228 |
if (@strtolower($v) == 'checked') $outputA[$k] = true; |
| 229 |
|
| 230 |
if ($v == '') $outputA[$k] = false; |
| 231 |
|
| 232 |
if (@preg_match('/[0-9.]+/',$v)) $outputA[$k] = (float) $v; |
| 233 |
} |
| 234 |
|
| 235 |
if ($settings['nosliderlabel']) { |
| 236 |
$amountmin = qis_separator($settings['loanmin'],$outputA['separator']); |
| 237 |
$amountmax = qis_separator($settings['loanmax'],$outputA['separator']); |
| 238 |
$periodmin = $settings['periodmin']; |
| 239 |
$periodmax = $settings['periodmax']; |
| 240 |
$interestmin = $settings['interestmin']; |
| 241 |
$interestmax = $settings['interestmax']; |
| 242 |
} else { |
| 243 |
$amountmin = $settings['cb'].qis_separator($settings['loanmin'],$outputA['separator']).$settings['ca']; |
| 244 |
$amountmax = $settings['cb'].qis_separator($settings['loanmax'],$outputA['separator']).$settings['ca']; |
| 245 |
$periodmin = $settings['periodmin'].' '.$settings['singleperiod']; |
| 246 |
$periodmax = $settings['periodmax'].' '.$settings['periodlabel']; |
| 247 |
$interestmin = $settings['interestmin'].'%'; |
| 248 |
$interestmax = $settings['interestmax'].'%'; |
| 249 |
} |
| 250 |
|
| 251 |
if ($settings['onlyslidervalue']) { |
| 252 |
$amountmin = $amountmax = $periodmin = $periodmax = ' '; |
| 253 |
} |
| 254 |
|
| 255 |
if ($settings['usefx'] && $qppkey['authorised']) { |
| 256 |
$outputA['fx'] = $fx; |
| 257 |
} |
| 258 |
|
| 259 |
// Append the currencies to the rates object |
| 260 |
|
| 261 |
$outputA['currencies'] = array(); |
| 262 |
$s_form = ((isset($_POST['submitted_form']))? $_POST['submitted_form']:'N/A'); |
| 263 |
|
| 264 |
$i = 1; |
| 265 |
for ($A_i = 0; isset($settings['currency_array'][$A_i]); $A_i++) { |
| 266 |
$outputA['currencies']['c'.$A_i] = $settings['currency_array'][$A_i]; |
| 267 |
} |
| 268 |
|
| 269 |
$output = '<script type="text/javascript">'; |
| 270 |
$output .= 'qis__rates["qis_'.$qis_forms.'"] = '.json_encode($outputA).';'; |
| 271 |
$output .= 'qis_form = '.json_encode($s_form).';'; |
| 272 |
$output .= '</script>'; |
| 273 |
$output .= '<form action="" class="qis_form '.$style['border'].'" method="POST" id="qis_'.$qis_forms.'">'; |
| 274 |
$output .= '<input type="hidden" name="submitted_form" value="qis_'.$qis_forms.'" />'; |
| 275 |
|
| 276 |
if ($settings['formheader'] && $qppkey['authorised']) $output .= '<h2>'.$settings['formheader'].'</h2>'; |
| 277 |
|
| 278 |
$output .= '<input type="hidden" name="interesttype" value="'.$settings['interesttype'].'" /> |
| 279 |
<div class="range qis-slider-principal">'; |
| 280 |
|
| 281 |
// Principle Slider |
| 282 |
|
| 283 |
if ($settings['loanlabel'] && $qppkey['authorised']) { |
| 284 |
$output .= '<div class="slider-label">'.$settings['loanlabel']; |
| 285 |
if ($settings['loanhelp']) $output .= qis_tooltip($settings['loaninfo']); |
| 286 |
$output .= '</div>'; |
| 287 |
} |
| 288 |
|
| 289 |
if ($settings['textinputs'] != 'slider') $oX = '<input type="text" class="output" value="'.$formvalues['loan-amount'].'" />'; |
| 290 |
else $oX = '<output></output>'; |
| 291 |
|
| 292 |
if ($settings['textinputs'] != 'text') { |
| 293 |
if ($settings['maxminlimits'] && $settings['buttons']) |
| 294 |
$output .= qis_outputs ($amountmin,$amountmax,$oX,'–','+'); |
| 295 |
elseif ($settings['maxminlimits']) |
| 296 |
$output .= qis_outputs ($amountmin,$amountmax,$oX,null,null); |
| 297 |
elseif ($settings['outputlimits'] && $settings['buttons']) |
| 298 |
$output .= qis_outputs (' ',' ',$oX,'–','+'); |
| 299 |
elseif ($settings['outputlimits']) |
| 300 |
$output .= qis_outputs (' ',' ',$oX,null,null); |
| 301 |
|
| 302 |
$output .= '<input type="range" name="loan-amount" min="'.$settings['loanmin'].'" max="'.$settings['loanmax'].'" value="'.$formvalues['loan-amount'].'" step="'.$settings['loanstep'].'" data-qis>'; |
| 303 |
if ($settings['markers']) { |
| 304 |
$handle = $style['slider-thickness'] + 1; |
| 305 |
|
| 306 |
$output .= '<div class="qis_slider_markers" style="position: relative; margin-left: '.($handle/2).'em; margin-right: '.($handle/2).'em; border-left: 1px solid black; border-right: 1px solid black; height: 10px">'; |
| 307 |
/* |
| 308 |
Put together a step total and output a set of step markers |
| 309 |
*/ |
| 310 |
$inner_value = (float) $settings['loanmax'] - $settings['loanmin']; |
| 311 |
$pps = $inner_value / $settings['loanstep']; |
| 312 |
$ppw = 100 / $pps; |
| 313 |
|
| 314 |
for ($i = 1; $i < $pps; $i++) { |
| 315 |
$output .= '<div class="qis_slider_marker" style="position: absolute; height: 10px; left: '.$ppw * $i.'%; margin-left: -1px; width: 1px; background-color: black;"></div>'; |
| 316 |
} |
| 317 |
$output .= '</div>'; |
| 318 |
} |
| 319 |
} else { |
| 320 |
$output .= 'Amount: <br />'; |
| 321 |
$output .= '<div>'.$oX.'</div>'; |
| 322 |
$output .= '<div>Minimum Amount: '.$amountmin.' Maximum Amount: '.$amountmax.' '.$settings['period'].'</div>'; |
| 323 |
$output .= '<div class="hidethis"><input type="range" name="loan-amount" min="'.$settings['loanmin'].'" max="'.$settings['loanmax'].'" value="'.$formvalues['loan-amount'].'" step="'.$settings['loanstep'].'" data-qis></div>'; |
| 324 |
} |
| 325 |
|
| 326 |
// Alternate Currencies |
| 327 |
|
| 328 |
if ($settings['usecurrencies'] && $qppkey['authorised']) { |
| 329 |
$output .= '<div class="checkradio"><ul>'; |
| 330 |
$output .= ' <li class="label">'.$settings['currencieslabel'].':</li>'; |
| 331 |
$index_A = 0; |
| 332 |
foreach ($outputA['currencies'] as $C_k => $C_v) { |
| 333 |
$index_A++; |
| 334 |
$output .= '<li><input type="radio" name="currencyname"'.(($index_A == 1)? ' checked="checked"':'').' value="'.$C_k.'" id="name'.$index_A.'"><label for="name'.$index_A.'"><span></span>'.$C_v['name'].'</label></li>'; |
| 335 |
} |
| 336 |
$output .= '</ul></div>'; |
| 337 |
$output .= '<div style="clear:both"></div>'; |
| 338 |
} |
| 339 |
|
| 340 |
$output .= '</div>'; |
| 341 |
|
| 342 |
// Term Slider |
| 343 |
|
| 344 |
if ($settings['textinputs'] != 'slider') $oX = '<input type="text" class="output" value="'.$formvalues['loan-period'].'" />'; |
| 345 |
else $oX = '<output></output>'; |
| 346 |
|
| 347 |
if ($settings['periodslider']) { |
| 348 |
|
| 349 |
if ($settings['termlabel'] && $qppkey['authorised']) { |
| 350 |
$output .= '<div class="slider-label">'.$settings['termlabel']; |
| 351 |
if ($settings['periodhelp']) $output .= qis_tooltip($settings['periodinfo']); |
| 352 |
$output .= '</div>'; |
| 353 |
} |
| 354 |
|
| 355 |
$output .= '<div class="range qis-slider-term">'; |
| 356 |
|
| 357 |
if ($settings['textinputs'] != 'text') { |
| 358 |
if ($settings['maxminlimits'] && $settings['buttons']) |
| 359 |
$output .= qis_outputs ($periodmin,$periodmax,$oX,'–','+'); |
| 360 |
elseif ($settings['maxminlimits']) |
| 361 |
$output .= qis_outputs ($periodmin,$periodmax,$oX,null,null); |
| 362 |
elseif ($settings['outputlimits'] && $settings['buttons']) |
| 363 |
$output .= qis_outputs (' ',' ',$oX,'–','+'); |
| 364 |
elseif ($settings['outputlimits']) |
| 365 |
$output .= qis_outputs (' ',' ',$oX,null,null); |
| 366 |
|
| 367 |
$output .= '<input type="range" name="loan-period" min="'.$settings['periodmin'].'" max="'.$settings['periodmax'].'" value="'.$formvalues['loan-period'].'" step="'.$settings['periodstep'].'" data-qis>'; |
| 368 |
if ($settings['markers']) { |
| 369 |
$handle = $style['slider-thickness'] + 1; |
| 370 |
$output .= '<div class="qis_slider_markers" style="position: relative; margin-left: '.($handle/2).'em; margin-right: '.($handle/2).'em; border-left: 1px solid black; border-right: 1px solid black; height: 10px">'; |
| 371 |
|
| 372 |
//Put together a step total and output a set of step markers |
| 373 |
$inner_value = (float) $settings['periodmax'] - $settings['periodmin']; |
| 374 |
$pps = $inner_value / $settings['periodstep']; |
| 375 |
$ppw = 100 / $pps; |
| 376 |
|
| 377 |
for ($i = 1; $i < $pps; $i++) { |
| 378 |
$output .= '<div class="qis_slider_marker" style="position: absolute; height: 10px; left: '.$ppw * $i.'%; margin-left: -1px; width: 1px; background-color: black;"></div>'; |
| 379 |
} |
| 380 |
$output .= '</div>'; |
| 381 |
} |
| 382 |
|
| 383 |
} else { |
| 384 |
$output .= 'Period In '.$settings['period'].':<br />'; |
| 385 |
$output .= '<div>'.$oX.'</div>'; |
| 386 |
$output .= '<div>Minimum Period: '.$settings['periodmin'].' '.$settings['period'].' Maximum Period: '.$settings['periodmax'].' '.$settings['period'].'</div>'; |
| 387 |
$output .= '<div class="hidethis"><input type="range" name="loan-period" min="'.$settings['periodmin'].'" max="'.$settings['periodmax'].'" value="'.$formvalues['loan-period'].'" step="'.$settings['periodstep'].'" data-qis></div>'; |
| 388 |
} |
| 389 |
|
| 390 |
$output .= '</div>'; |
| 391 |
} |
| 392 |
|
| 393 |
// Interest Slider |
| 394 |
|
| 395 |
if ($settings['textinputs'] != 'slider') $oX = '<input type="text" class="output" value="'.$formvalues['loan-interest'].'" />'; |
| 396 |
else $oX = '<output></output>'; |
| 397 |
|
| 398 |
if ($settings['interestslider'] && $qppkey['authorised'] && !$settings['interestselector']) { |
| 399 |
|
| 400 |
if ($settings['interestlabel']) { |
| 401 |
$output .= '<div class="slider-label">'.$settings['interestlabel']; |
| 402 |
if ($settings['interesthelp']) $output .= qis_tooltip($settings['interestinfo']); |
| 403 |
$output .= '</div>'; |
| 404 |
} |
| 405 |
|
| 406 |
$output .= '<div class="range qis-slider-term">'; |
| 407 |
|
| 408 |
if ($settings['textinputs'] != 'text') { |
| 409 |
if ($settings['maxminlimits'] && $settings['buttons']) |
| 410 |
$output .= qis_outputs ($interestmin,$interestmax,$oX,$style['buttonleft'],$style['buttonright']); |
| 411 |
elseif ($settings['maxminlimits']) |
| 412 |
$output .= qis_outputs ($interestmin,$interestmax,$oX,null,null); |
| 413 |
elseif ($settings['outputlimits'] && $settings['buttons']) |
| 414 |
$output .= qis_outputs (' ',' ',$oX,$style['buttonleft'],$style['buttonright']); |
| 415 |
elseif ($settings['outputlimits']) |
| 416 |
$output .= qis_outputs (' ',' ',$oX,null,null); |
| 417 |
|
| 418 |
$output .= '<input type="range" name="loan-period" min="'.$settings['interestmin'].'" max="'.$settings['interestmax'].'" value="'.$formvalues['loan-interest'].'" step="'.$settings['intereststep'].'" data-qis>'; |
| 419 |
if ($settings['markers']) { |
| 420 |
$handle = $style['slider-thickness'] + 1; |
| 421 |
|
| 422 |
$output .= '<div class="qis_slider_markers" style="position: relative; margin-left: '.($handle/2).'em; margin-right: '.($handle/2).'em; border-left: 1px solid black; border-right: 1px solid black; height: 10px">'; |
| 423 |
|
| 424 |
//Put together a step total and output a set of step markers |
| 425 |
$inner_value = (float) $settings['interestmax'] - $settings['interestmin']; |
| 426 |
$pps = $inner_value / $settings['intereststep']; |
| 427 |
$ppw = 100 / $pps; |
| 428 |
|
| 429 |
for ($i = 1; $i < $pps; $i++) { |
| 430 |
$output .= '<div class="qis_slider_marker" style="position: absolute; height: 10px; left: '.$ppw * $i.'%; margin-left: -1px; width: 1px; background-color: black;"></div>'; |
| 431 |
} |
| 432 |
$output .= '</div>'; |
| 433 |
} |
| 434 |
|
| 435 |
} else { |
| 436 |
$output .= 'Interest In '.$settings['interest'].':<br />'; |
| 437 |
$output .= '<div>'.$oX.'</div>'; |
| 438 |
$output .= '<div>Minimum Interest: '.$settings['interestmin'].'% Maximum Interest: '.$settings['interestmax'].'% </div>'; |
| 439 |
$output .= '<div class="hidethis"><input type="range" name="loan-period" min="'.$settings['interestmin'].'" max="'.$settings['interestmax'].'" value="'.$formvalues['loan-period'].'" step="'.$settings['intereststep'].'" data-qis></div>'; |
| 440 |
} |
| 441 |
|
| 442 |
$output .= '</div>'; |
| 443 |
} |
| 444 |
|
| 445 |
// Interest Selectors |
| 446 |
|
| 447 |
if ($settings['interestselector'] && $qppkey['authorised'] && !$settings['interestslider']) { |
| 448 |
$output .= '<div class="checkradio"><ul>'; |
| 449 |
if ($settings['interestselectorlabel']) $output .= '<li class="label">'.$settings['interestselectorlabel'].':</li>'; |
| 450 |
for ($i = 1; $i <= 4; $i++) { |
| 451 |
if ($settings['interestname'.$i]) { |
| 452 |
$checked = $i == 1 ? 'checked' : ''; |
| 453 |
$output .= '<li><input type="radio" name="interestselector" value="'.$i.'" '.$checked.' id="interestname'.$i.'"><label for="interestname'.$i.'"><span></span>'.$settings['interestname'.$i].'</label></li>'; |
| 454 |
} |
| 455 |
} |
| 456 |
$output .= '</ul></div>'; |
| 457 |
$output .= '<div style="clear:both"></div>'; |
| 458 |
} |
| 459 |
|
| 460 |
// Alternate Currencies |
| 461 |
|
| 462 |
if ($settings['usefx'] && $qppkey['authorised']) { |
| 463 |
$output .= '<div class="checkradio"><ul>'; |
| 464 |
$output .= '<li class="label">'.$settings['fxlabel'].':</li>'; |
| 465 |
$index_A = 0; |
| 466 |
foreach ($outputA['currencies'] as $C_k => $C_v) { |
| 467 |
$index_A++; |
| 468 |
$output .= '<li><input type="radio" name="fxname" value="'.$C_k.'"'.(($index_A == 1)? ' checked="checked"':'').' id="fxname'.$index_A.'"><label for="fxname'.$index_A.'"><span></span>'.$C_v['name'].'</label></li>'; |
| 469 |
} |
| 470 |
$output .= '</ul></div>'; |
| 471 |
$output .= '<div style="clear:both"></div>'; |
| 472 |
} |
| 473 |
|
| 474 |
if ($settings['downpaymentfixed']) $dpf = $settings['cb'].$settings['downpaymentfixed'].$settings['ca']; |
| 475 |
if ($settings['downpaymentpercent'] && $dpf) $dpf = $dpf.' and '.$settings['downpaymentpercent'].'%'; |
| 476 |
if ($settings['downpaymentpercent'] && !$dpf) $dpf = $settings['downpaymentpercent'].'%'; |
| 477 |
|
| 478 |
|
| 479 |
// Shortcode Replacements |
| 480 |
|
| 481 |
$arr = array('repaymentlabel','outputtotallabel'); |
| 482 |
|
| 483 |
foreach ($arr as $item) { |
| 484 |
$settings[$item] = str_replace('[step]', $settings['periodstep'], $settings[$item]); |
| 485 |
$settings[$item] = str_replace('[amount]', '<span class="repayment"></span>', $settings[$item]); |
| 486 |
$settings[$item] = str_replace('[repayment]', '<span class="repayment"></span>', $settings[$item]); |
| 487 |
$settings[$item] = str_replace('[period]', $settings['period'], $settings[$item]); |
| 488 |
$settings[$item] = str_replace('[rate]', '<span class="interestrate"></span>', $settings[$item]); |
| 489 |
$settings[$item] = str_replace('[interest]', '<span class="current_interest"></span>', $settings[$item]); |
| 490 |
$settings[$item] = str_replace('[total]', '<span class="final_total"></span>', $settings[$item]); |
| 491 |
$settings[$item] = str_replace('[discount]', '<span class="discount"></span>', $settings[$item]); |
| 492 |
$settings[$item] = str_replace('[principle]', '<span class="principle"></span>', $settings[$item]); |
| 493 |
$settings[$item] = str_replace('[term]', '<span class="term"></span> '.$settings['period'], $settings[$item]); |
| 494 |
$settings[$item] = str_replace('[processing]', '<span class="processing"></span>', $settings[$item]); |
| 495 |
$settings[$item] = str_replace('[date]', '<span class="repaymentdate"></span>', $settings[$item]); |
| 496 |
if ($qppkey['authorised']) { |
| 497 |
$settings[$item] = str_replace('[downpayment]', '<span class="downpayment"></span>', $settings[$item]); |
| 498 |
$settings[$item] = str_replace('[fixeddownpayment]', $settings['cb'].$settings['downpaymentfixed'].$settings['ca'], $settings[$item]); |
| 499 |
$settings[$item] = str_replace('[downpaymentpercent]', $settings['downpaymentpercent'].'%', $settings[$item]); |
| 500 |
$settings[$item] = str_replace('[mitigated]', '<span class="mitigated"></span>', $settings[$item]); |
| 501 |
} |
| 502 |
} |
| 503 |
|
| 504 |
$output .= '<div class="qis-outputs">'; |
| 505 |
|
| 506 |
// Display output messages |
| 507 |
|
| 508 |
if ($settings['outputrepayments']) { |
| 509 |
$output .= '<div class="qis-repayments">'.$settings['repaymentlabel']; |
| 510 |
if ($settings['outputhelp']) $output .= qis_tooltip($settings['outputinfo']); |
| 511 |
$output .= '</div>'; |
| 512 |
} |
| 513 |
|
| 514 |
if ($settings['outputtotal']) { |
| 515 |
$output .= '<div class="qis-total">'.$settings['outputtotallabel'].'</div>'; |
| 516 |
} |
| 517 |
|
| 518 |
$output .= '</div>'; |
| 519 |
|
| 520 |
// Apply Now and Application Form |
| 521 |
|
| 522 |
if ($register['application'] && $qppkey['authorised']) $output .= qis_display_form($formvalues,$formerrors,$registered); |
| 523 |
elseif ($settings['applynow'] && $qppkey['authorised']) $output .= '<div class="qis-register"><input type="submit" class="submit" name="qisapply" onclick="this.value=\'Processing\'" value="'.$settings['applynowlabel'].'" /></div>'; |
| 524 |
$output .= '<input type="hidden" name="repayment" value="'.$formvalues['repayment'].'" />'; |
| 525 |
$output .= '<input type="hidden" name="totalamount" value="'.$formvalues['totalamount'].'" />'; |
| 526 |
$output .= '</form>'; |
| 527 |
return $output; |
| 528 |
} |
| 529 |
|
| 530 |
// Display Values |
| 531 |
|
| 532 |
function qis_outputs ($min,$max,$oX,$buttonleft,$buttonright) { |
| 533 |
$output = '<div class="qis-slideroutput qis-loan"> |
| 534 |
<span class="qis-sliderleft qis-min">'.$min.'</span> |
| 535 |
<span class="qis-sliderbuttonleft">'; |
| 536 |
if ($buttonleft) $output .= '<span class="cssCircle minusSign">⊖</span>'; |
| 537 |
else $output .= ' '; |
| 538 |
$output .= '</span> |
| 539 |
<span class="qis-slidercenter">'.$oX.'</span> |
| 540 |
<span class="qis-sliderbuttonright">'; |
| 541 |
if ($buttonright) $output .= '<span class="cssCircle plusSign">⊕</span>'; |
| 542 |
else $output .= ' '; |
| 543 |
$output .= '</span> |
| 544 |
<span class="qis-sliderright qis-max">'.$max.'</span> |
| 545 |
</div>'; |
| 546 |
return $output; |
| 547 |
} |
| 548 |
|
| 549 |
// Display Tooltip |
| 550 |
|
| 551 |
function qis_tooltip($text) { |
| 552 |
return '<span class="qis_tooltip_toggle"><a href="javascript:void(0);"></a><div class="qis_tooltip_body"><div class="qis_tooltip_content">'.$text.'</div><div class="close"></div></div></span>'; |
| 553 |
} |
| 554 |
|
| 555 |
// Enqueue Scripts and Styles |
| 556 |
|
| 557 |
function qis_scripts() { |
| 558 |
$style = qis_get_stored_style(); |
| 559 |
if (!$style['nostyles']) wp_enqueue_style( 'qis_style',plugins_url('slider.css', __FILE__)); |
| 560 |
wp_enqueue_script("jquery-effects-core"); |
| 561 |
wp_enqueue_script('qis_script',plugins_url('slider.js', __FILE__ ), array( 'jquery' ), false, true ); |
| 562 |
} |
| 563 |
|
| 564 |
// Dashboard Link |
| 565 |
|
| 566 |
function qis_plugin_action_links($links, $file ) { |
| 567 |
if ( $file == plugin_basename( __FILE__ ) ) { |
| 568 |
$qis_links = '<a href="'.get_admin_url().'options-general.php?page=quick-interest-slider/settings.php">'.__('Settings','quick-interest-slider').'</a>'; |
| 569 |
array_unshift( $links, $qis_links ); |
| 570 |
} |
| 571 |
return $links; |
| 572 |
} |
| 573 |
|
| 574 |
// Build Custom CSS |
| 575 |
|
| 576 |
function qis_generate_css() { |
| 577 |
$style = qis_get_stored_style(); |
| 578 |
if ($style['nostyles'] || $style['nocustomstyles']) return; |
| 579 |
$border = $radius = $background = false; |
| 580 |
$handle = $style['slider-thickness'] + 1; |
| 581 |
|
| 582 |
if ($style['border']<>'none') { |
| 583 |
$border = ".qis_form.".$style['border']." {border:".$style['form-border-thickness']."px solid ".$style['form-border-color']."; padding: ".$style['form-padding']."px;border-radius:".$style['form-border-radius']."px;}"; |
| 584 |
} |
| 585 |
if ($style['background'] == 'white') { |
| 586 |
$background = "form.qis_form {background:#FFF;}"; |
| 587 |
} |
| 588 |
if ($style['background'] == 'color') { |
| 589 |
$background = "form.qis_form {background:".$style['backgroundhex'].";}"; |
| 590 |
} |
| 591 |
if ($style['backgroundimage']) { |
| 592 |
$background = "form.qis_form {background: url('".$style['backgroundimage']."');}"; |
| 593 |
} |
| 594 |
|
| 595 |
$formwidth = preg_split('#(?<=\d)(?=[a-z%])#i', $style['width']); |
| 596 |
if (!isset($formwidth[1])) $formwidth[1] = 'px'; |
| 597 |
if ($style['widthtype'] == 'pixel') $width = $formwidth[0].$formwidth[1]; |
| 598 |
else $width = '100%'; |
| 599 |
|
| 600 |
$data = $border.$radius.$background.' |
| 601 |
.qis_form {width:'.$width.';max-width:100%;} |
| 602 |
.qis, .qis__fill {height: '.$style['slider-thickness'].'em;background: '.$style['slider-background'].';} |
| 603 |
.qis__fill {background: '.$style['slider-revealed'].';} |
| 604 |
.qis__handle {background: '.$style['handle-background'].';border: '.$style['handle-thickness'].'px solid '.$style['handle-border'].';width: '.$handle.'em;height: '.$handle.'em;position: absolute;top: -0.5em;'.$style['handle-corners'].'%;border-radius:'.$style['handle-corners'].'%;} |
| 605 |
.total {font-weight:bold;border-top:1px solid #FFF;margin-top:6px;text-align:left;font-size:'.$handle.'em;} |
| 606 |
.qis, .qis__fill {font-size:1em;width: 100%;} |
| 607 |
.loanoutput{text-align:left;margin-bottom:6px;} |
| 608 |
.qis-slideroutput {color:'.$style['output-colour'].'} |
| 609 |
.qis-slidercenter {color:'.$style['slideroutputcolour'].';font-size:'.$style['slideroutputfont'].'em;} |
| 610 |
.qis-sliderleft, .qis-sliderright {color:'.$style['toplinecolour'].';font-size:'.$style['toplinefont'].'em;} |
| 611 |
.slider-label {color:'.$style['slider-label-colour'].';font-size:'.$style['slider-label-size'].'em;margin:'.$style['slider-label-margin'].';} |
| 612 |
.qis-interest, .qis-repayments {color:'.$style['interestcolour'].';font-size:'.$style['interestfont'].'em;margin:'.$style['interestmargin'].';} |
| 613 |
.qis-total {color:'.$style['totalcolour'].';font-size:'.$style['totalfont'].'em;margin:'.$style['totalmargin'].';} |
| 614 |
.qis_tooltip_body {border: '.$style['tooltipborderthickness'].'px solid '.$style['tooltipbordercolour'].'; background-color: '.$style['tooltipbackground'].'; border-radius: '.$style['tooltipcorner'].'px; color: '.$style['tooltipcolour'].';} |
| 615 |
.qis_tooltip_content {overflow: hidden; width: 100%; height: 100%;} |
| 616 |
.checkradio input[type=radio]:not(old) + label > span{border:3px solid '.$style['handle-border'].'} |
| 617 |
.checkradio input[type=radio]:not(old):checked + label > span{background: '.$style['handle-background'].';border: 3px solid '.$style['handle-border'].';} |
| 618 |
.cssCircle {color: '.$style['buttoncolour'].';line-height: '.$style['buttonsize'].'px;font-size: '.$style['buttonsize'].'px;}'; |
| 619 |
if ($style['slider-block']) $data .= qis_square_css ($style); |
| 620 |
return $data; |
| 621 |
} |
| 622 |
|
| 623 |
// Builds Application Form CSS |
| 624 |
|
| 625 |
function qis_register_css () { |
| 626 |
$code=$header=$input=$submitwidth=$paragraph=$submitbutton=$submit=''; |
| 627 |
$style = qis_get_register_style(); |
| 628 |
$corners = '-webkit-border-radius:'.$style['corners'].'px;border-radius:'.$style['corners'].'px;'; |
| 629 |
$input = '.qis-register input[type=text], .qis-register textarea, .qis-register select, .qis_checkbox label {color:'.$style['font-colour'].';border:'.$style['input-border'].';background-color:'.$style['inputbackground'].';'.$corners.'}.registerradio input[type=radio]:not(old) + label > span{border:'.$style['input-border'].';}'; |
| 630 |
$required = '.qis-register input[type=text].required, .qis-register textarea.required, .qis-register select.required {border:'.$style['input-required'].'}'; |
| 631 |
$focus = ".qis-register input:focus, .qis-register textarea:focus {background:".$style['inputfocus'].";}"; |
| 632 |
$text = ".qis-register p {color:".$style['font-colour'].";margin: 6px 0 !important;padding: 0 !important;}"; |
| 633 |
$error = ".qis-register .error {color:".$style['error-font-colour']." !important;border-color:".$style['error-font-colour']." !important;}"; |
| 634 |
$button = "h2.toggle-qis {color: ".$style['header-colour'].";height:auto;font-size:1em;margin:0;} h2.toggle-qis a{text-decoration:none;}"; |
| 635 |
$submit = "color:".$style['submit-colour'].";background:".$style['submit-background'].";border:".$style['submit-border'].";font-size: inherit;".$corners; |
| 636 |
$submithover = "background:".$style['submit-hover-background'].";"; |
| 637 |
$submitbutton = ".qis-register .submit, h2.toggle-qis {".$submit."}.qis-register .submit:hover {".$submithover."}"; |
| 638 |
$code = ".qis-register {max-width:100%;overflow:hidden;}".$submitbutton.$header.$paragraph.$input.$focus.$required.$text.$error; |
| 639 |
$data = '<style type="text/css" media="screen">'.$code.'</style>'; |
| 640 |
echo $data; |
| 641 |
} |
| 642 |
|
| 643 |
// Builds Square Slider CSS |
| 644 |
|
| 645 |
function qis_square_css ($style) { |
| 646 |
$css = '.qis, .qis__fill {height: '.$style['slider-thickness'].'em;-webkit-box-shadow: none;-moz-box-shadow: none;box-shadow: none;-webkit-border-radius: 0;-moz-border-radius: 0;-ms-border-radius: 0;-o-border-radius: none;border-radius: 0;} |
| 647 |
.qis__handle {width: '.$style['slider-thickness'].'em;height: '.$style['slider-thickness'].'em;border:none;top: 0;-webkit-box-shadow: none;-moz-box-shadow: none;box-shadow: none;-webkit-border-radius: 0;-moz-border-radius: 0;-ms-border-radius: 0;-o-border-radius: 0;border-radius: 0;}'; |
| 648 |
return $css; |
| 649 |
} |
| 650 |
|
| 651 |
// Add to Head |
| 652 |
|
| 653 |
function qis_head_css () { |
| 654 |
$data = '<style type="text/css" media="screen">'.qis_generate_css().'</style><script type="text/javascript">qis__rates = [];</script>'; |
| 655 |
echo $data; |
| 656 |
qis_register_css(); |
| 657 |
} |
| 658 |
|
| 659 |
// GDPR Subscribe/Unsubsribe |
| 660 |
|
| 661 |
function qis_subscribe() { |
| 662 |
$message = get_option('qis_messages'); |
| 663 |
|
| 664 |
$auto = qis_get_stored_autoresponder(); |
| 665 |
if ( isset ($_GET['sub']) ) { |
| 666 |
$ref = $_GET['sub']; |
| 667 |
foreach ($message as $key => $value ) { |
| 668 |
if ($ref == $value['timestamp'] && $value['confirmed'] != true) { |
| 669 |
if ($auto['notification']) qis_send_notification ($value); |
| 670 |
$message[$key]['confirmed'] = true; |
| 671 |
update_option('qis_messages',$message); |
| 672 |
return '<div class="emailresponse">'.$auto['subscribemessage'].'</div>'; |
| 673 |
} |
| 674 |
} |
| 675 |
return '<div class="emailresponse">'.$auto['subscribealready'].'</div>'; |
| 676 |
} |
| 677 |
if ( isset ($_GET['unsub']) ) { |
| 678 |
$ref = $_GET['unsub']; |
| 679 |
foreach ($message as $key => $value ) { |
| 680 |
if ($ref == $value['timestamp']) { |
| 681 |
unset($value); |
| 682 |
$message = array_values($message); |
| 683 |
update_option('qis_messages',$message); |
| 684 |
return '<div class="emailresponse">'.$auto['unsubscribemessage'].'</div>'; |
| 685 |
} |
| 686 |
} |
| 687 |
return '<div class="emailresponse">You have already unsubscribed</div>'; |
| 688 |
} |
| 689 |
} |
| 690 |
|
| 691 |
|
| 692 |
|
| 693 |
|
| 694 |
|
| 695 |
// Report of all Applications |
| 696 |
|
| 697 |
function qis_registration_report() { |
| 698 |
$message = get_option('qis_messages'); |
| 699 |
ob_start(); |
| 700 |
$content ='<div id="qis-widget"> |
| 701 |
<h2>'.__('Loan Applications','quick-interest-slider').'</h2>'; |
| 702 |
$content .= qis_build_registration_table ($message,'report'); |
| 703 |
$content .='</div>'; |
| 704 |
echo $content; |
| 705 |
$output_string=ob_get_contents(); |
| 706 |
ob_end_clean(); |
| 707 |
return $output_string; |
| 708 |
} |
| 709 |
|
| 710 |
// Build the table of registrations |
| 711 |
|
| 712 |
function qis_build_registration_table ($message,$report) { |
| 713 |
$register = qis_get_stored_register(null); |
| 714 |
$span=$charles=$content=''; |
| 715 |
$delete=array();$i=0; |
| 716 |
$dashboard = '<table cellspacing="0"> |
| 717 |
<tr> |
| 718 |
<th>'.__('Reference', 'quick-interest-slider').'</th>'; |
| 719 |
if ($register['usename']) $dashboard .= '<th>'.$register['yourname'].'</th>'; |
| 720 |
if ($register['usemail']) $dashboard .= '<th>'.$register['youremail'].'</th>'; |
| 721 |
if ($register['usetelephone']) $dashboard .= '<th>'.$register['yourtelephone'].'</th>'; |
| 722 |
if ($register['usemessage']) $dashboard .= '<th>'.$register['yourmessage'].'</th>'; |
| 723 |
if ($register['usecheckboxes']) $dashboard .= '<th>'.$register['checkboxeslabel'].'</th>'; |
| 724 |
if ($register['usedropdown']) $dashboard .= '<th>'.$register['dropdownlabel'].'</th>'; |
| 725 |
if ($register['useradio']) $dashboard .= '<th>'.$register['radiolabel'].'</th>'; |
| 726 |
if ($register['useconsent']) $dashboard .= '<th>Consent</th>'; |
| 727 |
$dashboard .= '<th>'.__('Amount', 'quick-interest-slider').'</th><th>Period</th>'; |
| 728 |
$dashboard .= '<th>'.__('Date Sent', 'quick-interest-slider').'</th>'; |
| 729 |
if (!$report) $dashboard .= '<th></th>'; |
| 730 |
$dashboard .= '</tr>'; |
| 731 |
|
| 732 |
foreach($message as $value) { |
| 733 |
$span = ($value['reference'] && !$value['confirmed']) ? ' style="font-style:italic;color:#ccc;"' : ''; |
| 734 |
$content .= '<tr'.$span.'> |
| 735 |
<td>'.$value['reference'].'</td>'; |
| 736 |
if ($register['usename']) $content .= '<td>'.$value['yourname'].'</td>'; |
| 737 |
if ($register['usemail']) $content .= '<td>'.$value['youremail'].'</td>'; |
| 738 |
if ($register['usetelephone']) $content .= '<td>'.$value['yourtelephone'].'</td>'; |
| 739 |
if ($register['usemessage']) $content .= '<td>'.$value['yourmessage'].'</td>'; |
| 740 |
if ($register['usecheckboxes']) $content .= '<td>'.$value['yourchecks'].'</td>'; |
| 741 |
if ($register['usedropdown']) $content .= '<td>'.$value['yourdropdown'].'</td>'; |
| 742 |
if ($register['useradio']) $content .= '<td>'.$value['yourradio'].'</td>'; |
| 743 |
if ($register['useconsent']) $content .= '<td>'.$value['yourconsent'].'</td>'; |
| 744 |
$content .= '<td>'.$value['loan-amount'].'</td>'; |
| 745 |
$content .= '<td>'.$value['loan-period'].'</td>'; |
| 746 |
if ($value['yourname']) $charles = 'messages'; |
| 747 |
$content .= '<td>'.$value['sentdate'].'</td>'; |
| 748 |
if (!$report) $content .= '<td><input type="checkbox" name="'.$i.'" value="checked" /></td>'; |
| 749 |
$content .= '</tr>'; |
| 750 |
$i++; |
| 751 |
} |
| 752 |
$dashboard .= $content.'</table>'; |
| 753 |
if ($charles) return $dashboard; |
| 754 |
} |
| 755 |
|
| 756 |
// Languages |
| 757 |
|
| 758 |
function qis_lang_init() { |
| 759 |
load_plugin_textdomain( 'qis', false, dirname( plugin_basename( __FILE__ ) ) . '/languages' ); |
| 760 |
} |
| 761 |
|
| 762 |
// Upgrade IPN function |
| 763 |
|
| 764 |
function qis_upgrade_ipn() { |
| 765 |
$qppkey = get_option('qpp_key'); |
| 766 |
if (!isset($_POST['custom']) || $qppkey['authorised']) |
| 767 |
return; |
| 768 |
$raw_post_data = file_get_contents('php://input'); |
| 769 |
$raw_post_array = explode('&', $raw_post_data); |
| 770 |
$myPost = array(); |
| 771 |
foreach ($raw_post_array as $keyval) { |
| 772 |
$keyval = explode ('=', $keyval); |
| 773 |
if (count($keyval) == 2) |
| 774 |
$myPost[$keyval[0]] = urldecode($keyval[1]); |
| 775 |
} |
| 776 |
$req = 'cmd=_notify-validate'; |
| 777 |
if(function_exists('get_magic_quotes_gpc')) { |
| 778 |
$get_magic_quotes_exists = true; |
| 779 |
} |
| 780 |
foreach ($myPost as $key => $value) { |
| 781 |
if($get_magic_quotes_exists == true && get_magic_quotes_gpc() == 1) { |
| 782 |
$value = urlencode(stripslashes($value)); |
| 783 |
} else { |
| 784 |
$value = urlencode($value); |
| 785 |
} |
| 786 |
$req .= "&$key=$value"; |
| 787 |
} |
| 788 |
|
| 789 |
$ch = curl_init("https://www.paypal.com/cgi-bin/webscr"); |
| 790 |
if ($ch == FALSE) { |
| 791 |
return FALSE; |
| 792 |
} |
| 793 |
|
| 794 |
curl_setopt($ch, CURLOPT_HTTP_VERSION, CURL_HTTP_VERSION_1_1); |
| 795 |
curl_setopt($ch, CURLOPT_POST, 1); |
| 796 |
curl_setopt($ch, CURLOPT_RETURNTRANSFER,1); |
| 797 |
curl_setopt($ch, CURLOPT_POSTFIELDS, $req); |
| 798 |
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 1); |
| 799 |
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 2); |
| 800 |
curl_setopt($ch, CURLOPT_FORBID_REUSE, 1); |
| 801 |
curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 30); |
| 802 |
curl_setopt($ch, CURLOPT_HTTPHEADER, array('Connection: Close')); |
| 803 |
|
| 804 |
$res = curl_exec($ch); |
| 805 |
|
| 806 |
$tokens = explode("\r\n\r\n", trim($res)); |
| 807 |
$res = trim(end($tokens)); |
| 808 |
|
| 809 |
if (strcmp ($res, "VERIFIED") == 0 && $qppkey['key'] == $_POST['custom']) { |
| 810 |
$qppkey['authorised'] = 'true'; |
| 811 |
update_option('qpp_key',$qppkey); |
| 812 |
$qpp_setup = qp_get_stored_setup(); |
| 813 |
$email = bloginfo('admin_email'); |
| 814 |
$headers = "From: Quick Plugins <mail@quick-plugins.com>\r\n" |
| 815 |
. "MIME-Version: 1.0\r\n" |
| 816 |
. "Content-Type: text/html; charset=\"utf-8\"\r\n"; |
| 817 |
$message = '<html><p>'.__('Thank for upgrading. Your authorisation key is','quick-interest-slider').':</p><p>'.$qppkey['key'].'</p></html>'; |
| 818 |
wp_mail($email,__('Quick Plugins Authorisation Key','quick-interest-slider'),$message,$headers); |
| 819 |
} |
| 820 |
exit(); |
| 821 |
} |
| 822 |
|
| 823 |
// Get URL of the current page |
| 824 |
|
| 825 |
function qis_current_page_url() { |
| 826 |
$pageURL = 'http'; |
| 827 |
if (!isset($_SERVER['HTTPS'])) $_SERVER['HTTPS'] = ''; |
| 828 |
if (!empty($_SERVER["HTTPS"])) { |
| 829 |
$pageURL .= "s"; |
| 830 |
} |
| 831 |
$pageURL .= "://"; |
| 832 |
if (($_SERVER["SERVER_PORT"] != "80") && ($_SERVER['SERVER_PORT'] != '443')) |
| 833 |
$pageURL .= $_SERVER["SERVER_NAME"].":".$_SERVER["SERVER_PORT"].$_SERVER["REQUEST_URI"]; |
| 834 |
else |
| 835 |
$pageURL .= $_SERVER["SERVER_NAME"].$_SERVER["REQUEST_URI"]; |
| 836 |
return $pageURL; |
| 837 |
} |
| 838 |
|
| 839 |
// Changes thousands seperator |
| 840 |
|
| 841 |
function qis_separator($s,$separator) { |
| 842 |
if ($separator == 'none') return $s; |
| 843 |
$se = (($separator == 'comma')? ',':' '); |
| 844 |
return trim(preg_replace("/(\d)(?=(\d{3})+$)/",'$1'.$se,$s)); |
| 845 |
} |