function decode($url) { $_this =& UrlParam::getInstance(); $serialized = false; $human = true; $decoded = $url; if (substr($decoded, 0, strlen($_this->humanFlag)) == $_this->humanFlag) { $human = false; $decoded = substr($decoded, strlen($_this->humanFlag)); $decoded = base64_decode($decoded); } if (substr($decoded, 0, strlen($_this->serializedFlag)) == $_this->serializedFlag) { $serialized = true; $decoded = substr($decoded, strlen($_this->serializedFlag)); } if ($human) { $escape = array_reverse($_this->escape, true); $decoded = str_replace(array_keys($escape), array_values($escape), $decoded); } if ($serialized) { $decoded = unserialize($decoded); } return $decoded; }
<?php /** * ownCloud - ownpad_lite plugin * * @author Victor Dubiniuk * @copyright 2013 Victor Dubiniuk victor.dubiniuk@gmail.com * * This file is licensed under the Affero General Public License version 3 or * later. */ namespace OCA\ownpad_lite; \OCP\JSON::checkLoggedIn(); \OCP\JSON::callCheck(); $search = UrlParam::post(UrlParam::SHARE_SEARCH); \OCP\JSON::success(array('data' => Contacts::search($search))); exit;
function buyUrl($id = null, $nb = null, $model = null, $options = array()) { if (is_array($id) && !is_array($id)) { $options = $id; } else { if (is_array($nb)) { $options = $nb; } elseif (!empty($nb)) { $options['nb'] = $nb; } if (is_array($id)) { $options['product'] = $id; } else { $options['id'] = $id; } if (!empty($model)) { $options['model'] = $model; } } if (empty($options['id']) && !empty($options['product'])) { if (!empty($options['product']['id'])) { $options['id'] = $options['product']['id']; } else { if (empty($options['model'])) { $options['model'] = $this->defModel(); } if (!empty($options['product'][$options['model']]['id'])) { $options['id'] = $options['product'][$options['model']]['id']; } } } /*if(is_array($options['id'])){ }*/ if (empty($options['id']) && ($defID = $this->defID())) { $options['id'] = $defID; } if (empty($options['id']) || !is_numeric($options['id'])) { return null; } $localOpt = array('routed', 'product'); $defaultOptions = array('model' => $this->defModel(), 'nb' => null, 'routed' => true, 'back' => null, 'redirect' => null); $options = array_merge($defaultOptions, $options); if (!empty($options['back'])) { App::import('Lib', 'Shop.UrlParam'); //debug($options['back']); $options['back'] = UrlParam::encode($options['back']); //debug($options['back']); //debug(UrlParam::decode($options['back'])); } if (!empty($options['redirect'])) { App::import('Lib', 'Shop.UrlParam'); $options['redirect'] = UrlParam::encode($options['redirect']); } $urlOpt = array('plugin' => 'shop', 'controller' => 'shop_cart', 'action' => 'add'); $urlOpt = array_merge(array_diff_key($options, array_flip($localOpt)), $urlOpt); //debug($urlOpt); if ($options['routed']) { return $this->Html->url($urlOpt); } else { return $urlOpt; } }
function add($options) { //séparer option et produits ? $defaultOptions = array('products' => array(), 'redirect' => true, 'back' => null); if (!is_array($options)) { $options = array('products' => array($options)); } if (!empty($options['products']) && is_array($options['products']) && empty($options['products'][0])) { $options['products'] = array($options['products']); } $options = array_merge($defaultOptions, $options); foreach ($options['products'] as $product) { $product = $this->ShopFunct->formatProductAddOption($product); //debug($product); $pos = $this->match($product); if ($pos > -1) { $this->data['products'][$pos]['nb'] += $product['nb']; if ($this->data['products'][$pos]['nb'] <= 0) { $this->remove($pos); } } elseif ($product['nb'] > 0) { $this->data['products'][] = $product; } } //debug($this->data); //exit(); $this->clearCache(); $this->save(); if ($options['redirect']) { $url = array('plugin' => 'shop', 'controller' => 'shop_cart', 'action' => 'index'); if (!empty($options['back'])) { App::import('Lib', 'Shop.UrlParam'); //debug($options['back']); $url['redirect'] = UrlParam::encode($options['back']); //debug($options['back']); //debug(UrlParam::decode($options['back'])); } $this->controller->redirect($url); exit; } }
/** * ownCloud - ownpad_lite plugin * * @author Victor Dubiniuk * @copyright 2013 Victor Dubiniuk victor.dubiniuk@gmail.com * * This file is licensed under the Affero General Public License version 3 or * later. */ namespace OCA\ownpad_lite; \OCP\JSON::checkLoggedIn(); \OCP\JSON::callCheck(); $status = true; $recipients = UrlParam::post(UrlParam::SHARE_WITH); $source = UrlParam::post(UrlParam::SHARE_WHAT); if ($source && $recipients) { $currentUser = \OCP\User::getUser(); $nameFrom = \OCP\User::getDisplayName($currentUser); $subject = App::$l10n->t('Document was shared'); $message = App::$l10n->t('User %s shared quick document %s with you.', array($nameFrom, $source)); $pattern = '/(.*)\\s+<(.*)>$/'; $recipientList = array('name' => array(), 'email' => array()); $sendTo = explode(',', $recipients); foreach ($sendTo as $recipient) { if (preg_match_all($pattern, $recipient, $matches)) { // We have 'John Doe <*****@*****.**>' $recipientList['name'][] = $matches[1][0]; $recipientList['email'][] = $matches[2][0]; } else { // Name is unknown, we have email@example.org
/** * ownCloud - ownpad_lite plugin * * @author Victor Dubiniuk * @copyright 2012 Victor Dubiniuk victor.dubiniuk@gmail.com * * This file is licensed under the Affero General Public License version 3 or * later. */ namespace OCA\ownpad_lite; \OCP\JSON::checkLoggedIn(); \OCP\JSON::callCheck(); $serviceUrl = UrlParam::post(UrlParam::CONFIG_URL); $username = UrlParam::post(UrlParam::CONFIG_USERNAME); $errors = array(); $username = preg_replace('/[^0-9a-zA-Z\\.\\-_]*/i', '', $username); if ($username) { App::setUsername($username); } else { $errors[] = App::ERROR_USERNAME_INVALID; } if ($serviceUrl) { if (preg_match('|^http(s)?://[a-z0-9-]+(.[a-z0-9-]+)*(:[0-9]+)?(/.*)?$|i', $serviceUrl)) { App::setServiceUrl($serviceUrl); } else { $errors[] = App::ERROR_URL_INVALID; } } \OCP\JSON::success(array('data' => $errors));
function add($model = null, $id = null, $nb = 1) { $extract_data = array('products.model' => array('data.ShopCart.model', 'params.named.model', 'params.model', 'pass.model'), 'products.foreign_id' => array('data.ShopCart.id', 'params.named.id', 'params.id', 'pass.id'), 'products.nb' => array('data.ShopCart.nb', 'params.named.nb', 'params.nb', 'pass.nb'), 'back_encoded' => array('params.named.back', 'params.back'), 'redirect_encoded' => array('params.named.redirect', 'params.redirect'), 'redirect' => array('data.ShopCart.redirect'), 'back' => array('data.ShopCart.back'), 'products.SubItem' => array('data.ShopCart.SubItem')); App::import('Lib', 'Shop.SetMulti'); $source = array('params' => $this->params, 'data' => $this->data, 'pass' => array('model' => $model, 'id' => $id, 'nb' => $nb)); $opt = SetMulti::extractHierarchicMulti($extract_data, $source); if (!empty($opt['back_encoded'])) { App::import('Lib', 'Shop.UrlParam'); $opt['back'] = UrlParam::decode($opt['back_encoded']); unset($opt['back_encoded']); } $redirect = array('action' => 'index'); if (!empty($opt['redirect_encoded'])) { App::import('Lib', 'Shop.UrlParam'); $opt['redirect'] = UrlParam::decode($opt['redirect_encoded']); unset($opt['redirect_encoded']); } if (!empty($opt['redirect'])) { $redirect = $opt['redirect']; $opt['redirect'] = false; } if (empty($opt['products']['foreign_id']) || empty($opt['products']['model'])) { $this->Session->setFlash(sprintf(__('Invalid %s', true), 'product')); $this->redirect($redirect); } $this->CartMaker->add($opt); $this->redirect($redirect); }