Пример #1
0
 /**
  * decode the encoded id
  * 
  * @param type string|array $id
  * @return string|array
  */
 protected function decode($id)
 {
     $tiny = new \ZackKitzmiller\Tiny($this->salt);
     if (is_array($id)) {
         $decodedId = [];
         foreach ($id as $name => $encodedId) {
             $decodedId[$name] = $tiny->from($encodedId);
         }
         return $decodedId;
     }
     return $tiny->from($id);
 }
Пример #2
0
 /**
  * decode the encoded id
  * 
  * @param type string|array $id
  * @return string|array
  */
 public static function decode($id)
 {
     $tiny = new \ZackKitzmiller\Tiny(self::$salt);
     if (is_array($id)) {
         $decodedId = [];
         foreach ($id as $name => $encodedId) {
             $decodedId[$name] = $tiny->from($encodedId);
         }
         return $decodedId;
     }
     return $tiny->from($id);
 }
Пример #3
0
 public function _onBeforeRedirectSave(CakeEvent $event)
 {
     // Short-circuit if the paste is not private
     $data = $event->subject->request->data;
     if (!Hash::get($data, 'Paste.private')) {
         return;
     }
     // Construct the private url using the Tiny class
     $tiny = new \ZackKitzmiller\Tiny(Configure::read('Tiny.set'));
     $pasteUrl = Router::url(['controller' => 'pastes', 'action' => 'P', $tiny->to($event->subject->id)], true);
     // Modify the message to include the private paste url
     $Session = $event->subject->controller->Session;
     $message = $Session->read('Message.flash');
     $Session->delete('Message.flash');
     $Session->setFlash($message['message'] . ' at url ' . $pasteUrl, $message['element'], $message['params'], 'flash');
 }