url() public static method

Returns a URL pointing to a combination of controller and action. Param $url can be: - Empty - the method will find address to actual controller/action. - '/' - the method will find base URL of application. - A combination of controller/action - the method will find URL for it. There are a few 'special' parameters that can change the final URL string that is generated - base - Set to false to remove the base path from the generated URL. If your application is not in the root directory, this can be used to generate URLs that are 'cake relative'. cake relative URLs are required when using requestAction. - ? - Takes an array of query string parameters - # - Allows you to set URL hash fragments. - full_base - If true the Router::fullBaseUrl() value will be prepended to generated URLs.
public static url ( string | array $url = null, boolean | array $full = false ) : string
$url string | array Cake-relative URL, like "/products/edit/92" or "/presidents/elect/4" or an array specifying any of the following: 'controller', 'action', and/or 'plugin', in addition to named arguments (keyed array elements), and standard URL arguments (indexed array elements)
$full boolean | array If (bool) true, the full base URL will be prepended to the result. If an array accepts the following keys - escape - used when making URLs embedded in html escapes query string '&' - full - if true the full base URL will be prepended.
return string Full translated URL with base path.
Example #1
0
 public function doPayment()
 {
     $this->autoRender = false;
     $this->layout = 'ajax';
     $token = $this->params->query['token'];
     $payerId = $this->params->query['PayerID'];
     try {
         $details = $this->Paypal->getExpressCheckoutDetails($token);
     } catch (Exception $e) {
         debug($e->getMessage());
     }
     $items = $this->setItemsFromToken($details);
     $order = $this->setPaymentOptions('finish');
     $order['items'] = $items;
     try {
         $doExpress = $this->Paypal->doExpressCheckoutPayment($order, $token, $payerId);
     } catch (PaypalRedirectException $e) {
         $this->redirect($e->getMessage());
     } catch (Exception $e) {
         debug($e->getMessage());
     }
     //enviamos o email
     $this->Emails->paymentSended($payerId, $items);
     $this->redirect(Router::url('/', true) . '#!tienda/emptyCart');
 }
Example #2
0
 public function disconnect()
 {
     //S'il n'est meme pas connecter et essaye d'ouvrir l'action disconnect
     //le redireger ver la page de connexion
     $this->backupDB();
     if (!isset($this->session->user)) {
         header("Location:" . url("connexion"));
     }
     $id = $this->session->idconnexion;
     $connexion = "Connexion réussie";
     /** il a deborder, sa session est expiree */
     if ($this->session->timeout <= time()) {
         $datefin = date("Y-m-d H:i:s", $this->session->timeout);
         $deconnexion = "Session expriée";
     } else {
         /** Il s'est deconnecter durant sa session normale */
         $deconnexion = "Session fermée correctement";
         $datefin = date("Y-m-d H:i:s", time());
     }
     //updateConnexion($idconnexion, $connexion, $datefin, $deconnexion)
     $this->Connexion->updateConnexion($id, $connexion, $datefin, $deconnexion);
     unset($_SESSION['user']);
     unset($_SESSION['profile']);
     unset($_SESSION['droits']);
     unset($_SESSION['timeout']);
     unset($_SESSION['idconnexion']);
     unset($_SESSION['idprofile']);
     session_destroy();
     header("Location:" . Router::url('connexion'));
 }
Example #3
0
 public function image($imagePath, $width = null, $height = null, $class = null, $typeImage = null, $isThumb = false, $crop = 2)
 {
     if (empty($imagePath)) {
         $imagePath = 'no_image.png';
     } else {
         if (!empty($typeImage)) {
             if ($typeImage == 'UserProfile') {
                 $imagePath = Configure::read('ImagePath.UserProfile') . $imagePath;
             } elseif ($typeImage == 'AdvisorProfile') {
                 $imagePath = Configure::read('ImagePath.AdvisorProfile') . $imagePath;
             } elseif ($typeImage == 'temp') {
                 $imagePath = Configure::read('ImagePath.temp') . $imagePath;
             } elseif ($typeImage == 'Job') {
                 $imagePath = Configure::read('ImagePath.Job') . $imagePath;
             } elseif ($typeImage == 'BusinessField') {
                 $imagePath = Configure::read('ImagePath.BusinessField') . $imagePath;
             }
         }
     }
     if ($isThumb) {
         if ($imagePath === 'no_image.png') {
             $imagePath = 'no_image.jpg';
         }
         $imagePath = Router::url('/', true) . IMAGES_URL . $imagePath;
         $imagePath = "/timthumb.php?src={$imagePath}&w={$width}&h={$height}&zc={$crop}";
     }
     return $this->Html->image($imagePath, array('width' => $width, 'height' => $height, 'class' => $class));
 }
Example #4
0
 /**
  *
  * @param AppController $controller
  * @param array         $settings
  */
 public function initialize($controller, $settings = array())
 {
     $this->settings = Set::merge($this->settings, $settings);
     $this->controller = $controller;
     $this->getTwitterSource();
     $this->Cookie->path = Router::url('/');
 }
Example #5
0
 public function programmation()
 {
     if (!empty($this->request->programmation)) {
         $chapitres = $this->Chapitre->getChapitresByEnseignement($this->request->idenseignement);
         foreach ($chapitres as $chap) {
             $seq = $this->request->{"seq" . $chap['IDCHAPITRE']};
             $params = ["sequence" => $seq];
             $this->Chapitre->update($params, ["IDCHAPITRE" => $chap['IDCHAPITRE']]);
         }
         # Inserer les lecon dans la table programmation
         # Supprimer les ancienne programmation par enseignement
         $this->Programmation->deleteProgrammationsByEnseignement($this->request->idenseignement);
         $lecons = $this->Lecon->getLeconsByEnseignement($this->request->idenseignement);
         foreach ($lecons as $lec) {
             $params = ["lecon" => $lec['IDLECON'], "etat" => 0];
             $this->Programmation->insert($params);
         }
         header("Location:" . Router::url("pedagogie"));
     }
     $this->view->clientsJS("pedagogie" . DS . "programmation");
     $view = new View();
     $this->comboClasses->first = " ";
     $view->Assign("comboClasses", $this->comboClasses->view());
     $content = $view->Render("pedagogie" . DS . "programmation", false);
     $this->Assign("content", $content);
 }
Example #6
0
 /**
  * get comment of shop
  * 
  */
 function getListComment($shop_id, $limit = null)
 {
     $comments = $this->find("all", array('joins' => array(array('table' => 'users', 'alias' => 'User', 'type' => 'INNER', 'conditions' => array('User.id = Comment.user_id'))), 'conditions' => array('Comment.shop_id' => $shop_id), "order" => "Comment.id DESC", "fields" => array("Comment.*", "User.name", "User.avatar")));
     $countComment = count($comments);
     $result = array();
     foreach ($comments as $val) {
         if (empty($val["User"]["avatar"])) {
             $val["Comment"]["avatarUser"] = Router::url('/', true) . 'app/systems/background/default.png';
         } else {
             if (!filter_var($val["User"]["avatar"], FILTER_VALIDATE_URL)) {
                 $val["Comment"]["avatarUser"] = Router::url('/', true) . $val["User"]["avatar"];
             } else {
                 $val["Comment"]["avatarUser"] = $val["User"]["avatar"];
             }
         }
         $val["Comment"]["time"] = date("H:i", strtotime($val["Comment"]["created"]));
         $val["Comment"]["nameUser"] = $val["User"]["name"];
         unset($val["User"]);
         $result[] = $val;
         if (empty($limit) && count($result) >= 5) {
             break;
         }
     }
     $ret = array("data" => $result, "count" => $countComment);
     return $ret;
 }
Example #7
0
 function redirect($url, $code = null)
 {
     if ($code == 301) {
         header("HTTP/1.1 301 Moved Permanently");
     }
     header("Location: " . Router::url($url));
 }
Example #8
0
 /**
  * download file uploaded
  *
  * @param string $fieldName This should be "Modelname.fieldname"
  */
 public function downloadInput($field, $options = array())
 {
     // get model and field
     $explodeField = explode('.', $field);
     if (!is_array($explodeField)) {
         return;
     }
     $modelName = $explodeField[0];
     $fieldName = $explodeField[1];
     $model = $this->_getModel($modelName);
     if (empty($model->filePath)) {
         return;
     }
     if (!empty($this->request->data[$modelName][$fieldName])) {
         $urlBase = Router::url('/', true);
         $oldFileName = $this->getFilename($this->request->data[$modelName][$fieldName]);
         // file in tmp folder
         $filePath = $model->filePath . 'tmp/' . $this->request->data[$modelName][$fieldName];
         // file in destination folder
         if (!empty($options['model-id'])) {
             $model->id = $options['model-id'];
             if ($this->request->data[$modelName][$fieldName] == $model->field($fieldName)) {
                 $filePath = $model->filePath . $this->request->data[$modelName][$fieldName];
             }
         }
         $options['download'] = $oldFileName;
         return $this->Html->link($oldFileName, $urlBase . $filePath, $options);
     }
     return;
 }
Example #9
0
 function displayFlickrImages($type, $farm_id, $server_id, $photo_id, $secret, $keyword)
 {
     $_url = sprintf('http://farm%d.static.flickr.com/%d/%s_%s%%s.jpg', $farm_id, $server_id, $photo_id, $secret);
     switch ($type) {
         case '1':
             // thumbnail
             $_type = '_t';
             break;
         case '2':
             // small
             $_type = '_m';
             break;
         case '3':
             // square
             $_type = '_s';
             break;
         case '4':
             // large
             $_type = '_b';
             break;
         default:
             $_type = '';
     }
     $url = sprintf($_url, $_type);
     $image_url = sprintf($_url, '_m');
     //echo '<li id="image_set_flickr"><a href="/flickr/image/'.$photo_id.'&keyword='.$_GET['keyword'].'"><img src='.$url.' alt="" border="0"/></a></li>';
     echo '<li id="image_set_flickr"><a href="' . Router::url('/flickr/image/' . $photo_id . '/tag/' . urlencode($keyword)) . '"><img src=' . $url . ' alt="" border="0"/></a></li>';
 }
Example #10
0
 /**
  * Displays a view
  *
  * @param mixed What page to display
  * @return void
  */
 public function display()
 {
     $path = func_get_args();
     $count = count($path);
     if (!$count) {
         $this->redirect('/');
     }
     $page = $subpage = $title_for_layout = null;
     if (!empty($path[0])) {
         $page = $path[0];
     }
     if (!empty($path[1])) {
         $subpage = $path[1];
     }
     if (!empty($path[$count - 1])) {
         $title_for_layout = Inflector::humanize($path[$count - 1]);
     }
     $this->set(compact('page', 'subpage', 'title_for_layout'));
     /*
     if ($this->Session->read('Auth.User'))
     {
     	$this->render("/users/index");
     }
     else
     {
     */
     if ($page == "home") {
         $this->redirect(Router::url("/dashboards"));
     } else {
         $this->render(implode('/', $path));
     }
 }
 /**
  *  http://www.paypalobjects.com/de_DE/html/IntegrationCenter/ic_std-variable-reference.html
  *  Setup the config based on Config settings
  */
 public function __construct(View $View, $settings = array())
 {
     $this->settings = $this->_defaults;
     if ($x = Configure::read('Localization.decimalPoint')) {
         $this->settings['dec'] = $x;
     }
     if ($x = Configure::read('Localization.thousandsSeparator')) {
         $this->settings['sep'] = $x;
     }
     $this->settings = array_merge($this->settings, (array) Configure::read('PayPal'));
     if ($this->settings['live']) {
         $this->formOptions['server'] = 'https://www.paypal.com';
     } else {
         $this->formOptions['server'] = 'https://www.sandbox.paypal.com';
     }
     $data = array('HTTP_HOST' => HTTP_HOST, 'HTTP_BASE' => HTTP_BASE);
     $this->formOptions['notify_url'] = String::insert($this->settings['notify_url'], $data, array('before' => '{', 'after' => '}', 'clean' => true));
     $this->formOptions['business'] = $this->settings['email'];
     $this->formOptions['lc'] = $this->settings['locale'];
     $this->formOptions['amount'] = $this->settings['amount'];
     $this->formOptions['no_shipping'] = (int) (!$this->settings['shipping']);
     $this->formOptions['currency_code'] = $this->settings['currency_code'];
     if ($this->settings['cancel_return']) {
         $this->formOptions['cancel_return'] = Router::url(null, true);
     }
     //pr($this->formOptions); die();
     parent::__construct($View, $settings);
 }
 /**
  * startup
  * called after Controller::beforeFilter()
  * 
  * @param object $controller instance of controller
  * @return void
  * @access public
  */
 public function startup(Controller $controller)
 {
     // Maintenance mode OFF but on offline page -> redirect to root url
     if (!$this->isOn() && strpos($controller->here, Configure::read('Maintenance.site_offline_url')) !== false) {
         $controller->redirect(Router::url('/', true));
         return;
     }
     // Maintenance mode ON user logoout allowed
     if ($this->isOn() && strpos($controller->here, 'users/logout') !== false) {
         return;
     }
     // Maintenance mode ON but not in offline page requested - > redirect to offline page
     if ($this->isOn() && strpos($controller->here, Configure::read('Maintenance.site_offline_url')) === false) {
         // All users auto logged off if setting is true
         if (Configure::read('Maintenance.offline_destroy_session')) {
             $this->Session->destroy();
         }
         $controller->redirect(Router::url(Configure::read('Maintenance.site_offline_url'), true));
         return;
     }
     // Maintenance mode scheduled show message!!
     if ($this->hasSchedule()) {
         $this->Flash->maintenance(__('This application will be on maintenance mode at  %s ', Configure::read('Maintenance.start')));
     }
 }
 /**
  * Parses a string url into an array. Parsed urls will result in an automatic
  * redirection
  *
  * @param string $url The url to parse
  * @return boolean False on failure
  */
 public function parse($url)
 {
     $params = parent::parse($url);
     if (!$params) {
         return false;
     }
     if (!$this->response) {
         $this->response = new CakeResponse();
     }
     $redirect = $this->defaults;
     if (count($this->defaults) == 1 && !isset($this->defaults['controller'])) {
         $redirect = $this->defaults[0];
     }
     if (isset($this->options['persist']) && is_array($redirect)) {
         $argOptions['context'] = array('action' => $redirect['action'], 'controller' => $redirect['controller']);
         $args = Router::getArgs($params['_args_'], $argOptions);
         $redirect += $args['pass'];
         $redirect += $args['named'];
     }
     $status = 301;
     if (isset($this->options['status']) && ($this->options['status'] >= 300 && $this->options['status'] < 400)) {
         $status = $this->options['status'];
     }
     $this->response->header(array('Location' => Router::url($redirect, true)));
     $this->response->statusCode($status);
     $this->response->send();
 }
Example #14
0
 /**
  * 店舗情報とイメージ情報をマージします。
  */
 public function margeSimpleInfo($topInfo, $mediaInfoList)
 {
     // jsonの情報が何も無ければ、カラの画像だけ設定して戻る
     if (empty($topInfo['DtbBasicInfo']['info'])) {
         // noimageへ置換する
         $returnInfo = array();
         for ($i = 0; $i < 5; $i++) {
             $imageInfo = array('url' => Router::url('/img/common/noimage/noimage_top_shop.png', true), 'date' => '---- / -- / --');
             $returnInfo['image_info_list'][] = $imageInfo;
         }
         return json_encode($returnInfo);
     }
     $topInfoObj = json_decode($topInfo['DtbBasicInfo']['info'], true);
     // 画像情報をマージする。
     // 画像情報が存在しなければ、noimageを返却する。
     if (empty($mediaInfoList) || empty($topInfoObj['image_id_list'])) {
         // noimageへ置換する
         $topInfoObj['image_url_list'] = array('common/noimage/noimage_icon.png');
     } else {
         // 置換する
         $urlList = array();
         foreach ($topInfoObj['image_id_list'] as $imageId) {
             $urlList[] = $mediaInfoList[$imageId];
         }
         $topInfoObj['image_url_list'] = $urlList;
     }
     // jsonの形式にエンコードして返却する。
     return json_encode($topInfoObj);
 }
Example #15
0
 public function initialize(&$controller, $settings = array())
 {
     if (empty($settings['maintenanceUrl'])) {
         return true;
     }
     if (empty($settings['statusFilePath'])) {
         $settings['statusFilePath'] = TMP . 'maintenance';
     }
     $this->controller = $controller;
     $this->_set($settings);
     $maintenanceUrl = Router::url($this->maintenanceUrl, true);
     $clientIp = $this->RequestHandler->getClientIP();
     $maintenanceEnable = $this->isMaintenance();
     if ($maintenanceEnable === true) {
         // maintenance status
         if (!$this->isAllowedAction($this->controller->params) && strstr(Router::url('', true), $controller->webroot) && Router::url('', true) != Router::url($maintenanceUrl, true) && !in_array($clientIp, (array) $this->allowedIp)) {
             $controller->redirect($maintenanceUrl);
         }
     } else {
         // on service
         if (Router::url('', true) == $maintenanceUrl) {
             $controller->redirect('/');
         }
     }
 }
Example #16
0
 function index($c = null)
 {
     $this->placename = 'news';
     $this->paginate = array('limit' => 3, 'conditions' => array('News.published' => 1), 'order' => array('News.created' => 'desc'), 'contain' => array('NewsType', 'Author' => array('fields' => array('username', 'active', 'user_id'))));
     if ($c) {
         /* Let's add some fields and conditions */
         $this->NewsType->contain(array());
         $cat = $this->NewsType->findByTitre($c);
         if (empty($cat)) {
             $this->Session->setFlash(__('La catégorie <i>' . $c . '</i> n\'existe pas', true), 'messages/failure');
             $this->redirect(array('action' => 'index'), 302);
         }
         $this->paginate['conditions'] = array_merge(array('NewsType.titre' => $c), (array) @$this->paginate['conditions']);
     }
     $this->pageTitle = __('Archives des actualités', true);
     $nttmp = $this->News->NewsType->find('list');
     /* Build up a 'url => title' list for the select box */
     $nt = array();
     if (!empty($cat)) {
         $this->pageTitle .= __(' - Catégorie : ', true) . $cat['NewsType']['titre'];
         $k = Router::url(array('action' => 'index'));
         /* Unfilter */
         $nt[$k] = __('Tous', true);
     }
     foreach ($nttmp as $k => $v) {
         if (isset($cat['NewsType']['id']) && $k == $cat['NewsType']['id']) {
             /* Skip current newstype, will be displayed in the views as empty option */
             continue;
         }
         $k = Router::url(array('action' => 'index', 'cat' => $v));
         $nt[$k] = $v;
     }
     $this->set('newstypes', $nt);
     $this->set('news', $this->paginate('News'));
 }
Example #17
0
 public function beforeFilter()
 {
     $this->Auth->allow(array('clear_cache'));
     $this->helpers = empty($this->helpers) ? array() : $this->helpers;
     $this->helpers += array('Session');
     $this->home = Configure::read('Environment.Routes.home') ?: '/';
     $returnTo = $this->Session->read('Environment.returnTo');
     if (is_array($returnTo) || is_string($returnTo)) {
         $params = $this->request->params;
         $exceptions = empty(static::$returnException[$params['controller']]) ? array() : static::$returnException[$params['controller']];
         if (!in_array($params['action'], $exceptions)) {
             if ($this->Session->delete('Environment.returnTo')) {
                 return $this->redirect($returnTo);
             }
         }
     }
     $this->clientConfiguration = empty($this->clientConfiguration) ? array() : $this->clientConfiguration;
     $facebookSettings = Configure::read('Facebook') ? array('fbAppId' => Configure::read('Facebook.appId'), 'fbAppUrl' => Configure::read('Facebook.appUrl')) : array();
     if ($this->request->prefix === 'panel') {
         $this->theme = 'CakeStrap';
         $this->layout = 'default';
         $environmentType = Configure::read('Environment.Type');
         $this->clientConfiguration += $facebookSettings + array('enviromentType' => $environmentType, 'basePath' => Router::url('/'), 'baseUrl' => Router::url('/', true), 'pageType' => $this->request->prefix);
         $this->set('config', (object) $this->clientConfiguration);
         $this->set('referer', $this->referer());
     }
     $this->request->actionTitle = ucfirst(str_replace("{$this->request->prefix}_", '', $this->request->action));
     return parent::beforeFilter();
 }
Example #18
0
 function blackhole($type)
 {
     if ($this->request->params['action'] == 'login' && $this->request->is('ajax') || $this->request->params['action'] == "adminLinks" && $this->request->is('ajax')) {
         return true;
     }
     throw new MethodNotAllowedException(__('Nope: ' . $type . ' - ' . Router::url($this->here, true)));
 }
Example #19
0
 public function execute()
 {
     //load setting
     $settings = $this->Settings->find('first', array('conditions' => array('param_name' => 'DefaultGroupId')));
     $clientGroupId = 0;
     if (!empty($settings)) {
         $clientGroupId = $settings['Settings']['param_value'];
     }
     $this->Quotation->virtualFields['TotalDays'] = 'validity - FLOOR((UNIX_TIMESTAMP(NOW()) - UNIX_TIMESTAMP(Quotation.date))/86400)';
     $dayNotice = 0;
     $quotations = $this->Quotation->find('all', array('fields' => 'Quotation.*, ( validity - FLOOR((UNIX_TIMESTAMP(NOW()) - UNIX_TIMESTAMP(Quotation.date))/86400) ) as Quotation_TotalDays', 'conditions' => array('Quotation.history_status' => 1, 'send_first_expiry' => 1, 'send_second_expiry' => 1, 'status <' => 5), 'group' => 'Quotation.id HAVING Quotation_TotalDays <= ' . $dayNotice));
     if (!empty($quotations)) {
         foreach ($quotations as $k => $item) {
             $clientUser = $this->User->find('list', array('fields' => 'User.id, User.email', 'conditions' => array('User.company_id' => $item['Quotation']['client_id'], 'User.group_id' => $clientGroupId, 'User.active' => 1), 'permissionable' => false));
             if (!empty($clientUser)) {
                 $content = '<a href="' . FULL_PATH_DOMAIN . Router::url(array('plugin' => 'accounting', 'controller' => 'quotations', 'action' => 'view', $item['Quotation']['id'])) . '">' . $item['Quotation']['estimate_number'] . '</a> is status on expiry';
                 $arr_options = array('to' => $clientUser, 'subject' => __('Send Expired notification email to client on expiry'), 'viewVars' => array('content' => $content));
                 if ($this->Quotation->sendEmail($arr_options)) {
                     $item['Quotation']['status'] = 6;
                     $this->Quotation->save($item);
                 }
             }
         }
     }
 }
 public function login()
 {
     if ($this->Auth->loggedIn()) {
         $this->redirect(array('controller' => 'Users', 'action' => 'index'));
     }
     if ($this->request->is('post')) {
         if ($this->Auth->login()) {
             $user = $this->getLoggedUser();
             switch ($user['activation_status']) {
                 case 'active':
                     $this->redirect($this->Auth->redirect());
                     break;
                 case 'waiting_validation':
                     $link = Router::url(array('controller' => 'Users', 'action' => 'resendConfirmationEmail', $user['id']));
                     $this->Session->setFlash(sprintf(__('Seu e-mail não foi confirmado. <a href="%s">Clique aqui para reenviar o e-mail de confirmação</a>.'), $link));
                     $this->logout();
                     break;
                 case 'waiting_activation':
                     $this->Session->setFlash(__('Por favor aguarde ativação pelo administrador.'));
                     $this->logout();
                     break;
             }
         } else {
             $this->Session->setFlash(__('Número USP e senha não conferem.'));
             unset($this->request->data['User']['password']);
         }
     }
 }
Example #21
0
 /**
  * index
  *
  * @return void
  */
 public function index()
 {
     $conditions = array('Node.status' => 1);
     $types = array_keys(Configure::read('Sitemaps.types'));
     if ($types != array('*')) {
         $conditions['Node.type'] = $types;
     }
     $nodes = $this->Node->find('all', array('conditions' => $conditions, 'fields' => array('id', 'title', 'slug', 'type', 'updated'), 'recursive' => -1));
     $output = '<?xml version="1.0"?>';
     $output .= '<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">';
     foreach ($nodes as $node) {
         $output .= '<url>';
         $settings = Configure::read('Sitemaps.types.' . $node['Node']['type']);
         if (!$settings) {
             $settings = Configure::read('Sitemaps.types.*');
         }
         $url = Router::url(array('plugin' => 'nodes', 'controller' => 'nodes', 'action' => 'view', 'type' => $node['Node']['type'], 'slug' => $node['Node']['slug']), true);
         $output .= '<loc>' . $url . '</loc>';
         $output .= '<lastmod>' . date('Y-m-d', strtotime($node['Node']['updated'])) . '</lastmod>';
         $output .= '<changefreq>' . $settings['changefreq'] . '</changefreq>';
         $output .= '</url>';
     }
     $output .= '</urlset>';
     header('Content-type: text/xml; charset=utf-8');
     echo $output;
     exit;
 }
Example #22
0
 public function beforeRender()
 {
     $this->AppMetaTags->set('og:site_name', AppController::NAME);
     $this->AppMetaTags->set('og:url', Router::url());
     $this->AppMetaTags->set('og:title', $this->controller->data->get('pageTitle'));
     return parent::beforeRender();
 }
Example #23
0
    /**
     * selectURL
     *
     * @return string
     */
    public function selectURL()
    {
        $output = <<<EOF
function selectURL(url, title, description) {
\tif (url == '') return false;

\turl = '%s' + url;

\tdesc_field = window.top.opener.browserWin.document.forms[0].elements[2];
\tif (typeof description !== 'undefined') {
\t\tdesc_field.value = description;
\t}

\ttitle_field = window.top.opener.browserWin.document.forms[0].elements[3];
\tif (typeof title !== 'undefined') {
\t\ttitle_field.value = title;
\t}

\tfield = window.top.opener.browserWin.document.forms[0].elements[window.top.opener.browserField];
\tfield.value = url;
\tif (field.onchange != null) field.onchange();
\t\twindow.top.close();
\t\twindow.top.opener.browserWin.focus();
}
EOF;
        $output = sprintf($output, Router::url('/uploads/', true));
        return $output;
    }
 public function insert_user()
 {
     if ($this->request->is('ajax')) {
         $this->autoRender = false;
         $user_id = $this->request->data['user_id'];
         $user_name = $this->request->data['user_name'];
         $user_email = $this->request->data['user_email'];
         $user_picture = $this->request->data['user_picture'];
         $isExist = $this->User->find('first', array('recursive' => '-1', 'fields' => 'User.id', 'conditions' => array('User.facebook_id' => $user_id)));
         if (!$isExist) {
             $this->User->create();
             $data = array('username' => $user_name, 'email' => $user_email, 'facebook_id' => $user_id, 'image_profile' => $user_picture);
         } else {
             $data = array('id' => $isExist['User']['id'], 'username' => $user_name, 'email' => $user_email, 'facebook_id' => $user_id, 'image_profile' => $user_picture);
         }
         $isSave = $this->User->insertUser($data);
         if ($isSave) {
             $this->Auth->login(array('id' => $this->User->id, 'avatar' => $user_picture));
             $redirectFrom = $this->Session->read('login.redirect.from');
             $this->Session->delete('login.redirect.from');
             if ($redirectFrom == '') {
                 $redirectFrom = Router::url('/');
             }
             return json_encode(array('success' => true, 'redirect' => $redirectFrom));
         } else {
             $this->Session->setFlash(__('The user could not be saved. Please, try again.'));
             return json_encode(array('success' => false));
         }
     }
 }
 public function authenticate(CakeRequest $request, CakeResponse $response)
 {
     $user = $this->_Collection->Auth->user();
     $service = strtolower($request->params['pass'][0]);
     if ($service !== $this->service) {
         return false;
     }
     try {
         $facebook = new Facebook(array('appId' => $this->myConsumerKey, 'secret' => $this->myConsumerSec, 'cookie' => true));
         $action = $request->params['action'];
         if ($action === 'login') {
             $url = $facebook->getLoginUrl(array('redirect_uri' => Router::url('callback/facebook/', true), 'scope' => 'email,publish_stream'));
             if ($url !== null) {
                 $response->header('Location', $url);
                 $response->send();
             }
         } elseif ($action === 'callback') {
             preg_match('/state=(.*)/', $_REQUEST['url'], $state);
             $_REQUEST['state'] = $state[1];
             $accessToken = $facebook->getAccessToken();
             if ($accessToken != '') {
                 $this->_fetch($facebook, $accessToken, $response);
             } else {
                 //you should throw exception
             }
         }
     } catch (OAuthException $E) {
         //you can catch OAuth exception
     }
 }
Example #26
0
 public function redirect($url, $status = null, $exit = true)
 {
     if (is_array($url)) {
         $url += array('controller' => 'questions');
     }
     $this->redirectUrl = Router::url($url);
 }
 /**
  * Parses a string url into an array. Parsed urls will result in an automatic
  * redirection
  *
  * @param string $url The url to parse
  * @return boolean False on failure
  */
 public function parse($url)
 {
     $params = parent::parse($url);
     if (!$params) {
         return false;
     }
     if (!$this->response) {
         $this->response = new CakeResponse();
     }
     $redirect = $this->redirect;
     if (count($this->redirect) == 1 && !isset($this->redirect['controller'])) {
         $redirect = $this->redirect[0];
     }
     if (isset($this->options['persist']) && is_array($redirect)) {
         $redirect += array('named' => $params['named'], 'pass' => $params['pass'], 'url' => array());
         $redirect = Router::reverse($redirect);
     }
     $status = 301;
     if (isset($this->options['status']) && ($this->options['status'] >= 300 && $this->options['status'] < 400)) {
         $status = $this->options['status'];
     }
     $this->response->header(array('Location' => Router::url($redirect, true)));
     $this->response->statusCode($status);
     $this->response->send();
     $this->_stop();
 }
Example #28
0
 public function admin_reset_password($token = null)
 {
     if ($this->Auth->loggedIn()) {
         $this->redirect('/admin/index');
     }
     if (!isset($token)) {
         if ($this->request->is('post')) {
             $user = $this->User->findByEmail($this->request->data['User']['email']);
             if (empty($user)) {
                 $this->Session->setFlash('W bazie nie ma takiego adresu e-mail', 'flash_warning');
                 $this->redirect('/admin/users/reset_password');
             }
             $token = Utilities::token();
             $this->adminSendMail($this->request->data['User']['email'], 'kAdmin - resetowanie hasła', 'reset_password', array('username' => $user['User']['username'], 'link' => '<a href="' . Router::url('/admin/users/reset_password/' . $token, true) . '">' . Router::url('/admin/users/reset_password/' . $token . $user['User']['id'], true) . '</a>'));
             $this->User->id = $user['User']['id'];
             $this->User->saveField('token', $token);
             $this->set('afterPost', true);
         }
     } else {
         $user = $this->User->findByToken($token);
         if (empty($user)) {
             throw new NotFoundException('Podany token jest nieprawidłowy.');
         }
         $pass = substr(str_shuffle('abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789!$'), 0, 6);
         $this->User->id = $user['User']['id'];
         $this->User->save(array('token' => null, 'password' => $pass), false);
         $this->adminSendMail($user['User']['email'], 'kAdmin - resetowanie hasła', 'new_password', array('password' => $pass, 'username' => $user['User']['username']));
         $this->set('afterReset', true);
     }
 }
Example #29
0
 function channelProfileUrl($channel)
 {
     if ($channel[0] == '#') {
         $channel = substr($channel, 1);
     }
     return Router::url(array('controller' => 'channel_profiles', 'action' => 'view', 'channel' => $channel));
 }
 private function isPage($params = array())
 {
     if (is_string($params) && isset($this->pages[$params])) {
         $params = $this->pages[$params];
     }
     return Router::url($this->Controller->request->params) == Router::url(array_merge($this->Controller->request->params, $params));
 }