/**
  * Looks up user supplied email address / alias and sends a mail
  *
  * @param $email email address or username
  */
 function sendMail($in)
 {
     $in = trim($in);
     if (is_email($in)) {
         $user_id = UserFinder::byEmail($in);
     } else {
         $user_id = UserFinder::byUsername($in);
     }
     $error = ErrorHandler::getInstance();
     if (!$user_id) {
         $error->add('Invalid email address or username');
         return false;
     }
     $email = UserSetting::getEmail($user_id);
     if (!$email) {
         throw new \Exception('entered email not found');
     }
     $code = Token::generate($user_id, 'activation_code');
     $pattern = array('/@USERNAME@/', '/@IP@/', '/@URL@/', '/@EXPIRETIME@/');
     $user = User::get($user_id);
     $page = XmlDocumentHandler::getInstance();
     $url = $page->getUrl() . 'u/reset_pwd/' . $code;
     $replacement = array($user->getName(), client_ip(), $url, shortTimePeriod($this->expire_time_email));
     $msg = preg_replace($pattern, $replacement, $this->password_msg);
     //d($msg);
     $mail = SendMail::getInstance();
     $mail->addRecipient($email);
     $mail->setSubject('Forgot password');
     $mail->send($msg);
     return true;
 }
Пример #2
0
 function renderXls()
 {
     $page = XmlDocumentHandler::getInstance();
     $page->setMimeType('application/vnd.ms-excel');
     $page->setAttachmentName('export.xls');
     $writer = new XlsWriter();
     $writer->setData($this->data);
     return $writer->render();
 }
Пример #3
0
 function render()
 {
     $header = XhtmlHeader::getInstance();
     $page = XmlDocumentHandler::getInstance();
     $header->includeJs('http://yui.yahooapis.com/3.4.1/build/yui/yui-min.js');
     $header->includeJs($page->getRelativeCoreDevUrl() . 'js/ext/gallery-lightbox/gallery-lightbox-min.js');
     $header->includeCss($page->getRelativeCoreDevUrl() . 'js/ext/gallery-lightbox/assets/skins/sam/gallery-lightbox-skin.css');
     $js = 'YUI().use("gallery-lightbox", "node-deprecated", ' . 'function (Y)' . '{' . 'Y.Lightbox.init();' . '}' . ');';
     return js_embed($js);
 }
Пример #4
0
 /**
  * @param $id album id
  */
 public static function albumUploader($id)
 {
     $header = XhtmlHeader::getInstance();
     $page = XmlDocumentHandler::getInstance();
     $header->includeJs($page->getRelativeCoreDevUrl() . 'js/ext/html5uploader.js');
     $header->embedJsOnload("new uploader('drop', 'status', '/u/upload/album/" . $id . "', 'list');");
     $header->embedCss('#box{' . 'width:300px;' . 'border:2px solid #454545;' . 'border-radius:6px;' . '}' . '#drop{' . 'width:100%;' . 'height:200px;' . 'background-color:#E5E5E5;' . '}' . '#status{' . 'font-size:10px;' . 'color:#fff;' . 'padding:5px;' . 'background:#7F7F7F;' . 'filter: progid:DXImageTransform.Microsoft.gradient(startColorstr="#7F7F7F", endColorstr="#242424");' . 'background: -webkit-gradient(linear, left top, left bottom, from(#7F7F7F), to(#242424));' . 'background: -moz-linear-gradient(top, #7F7F7F, #242424);' . 'background: -o-linear-gradient(top, #7F7F7F, #242424);' . '}' . '#list{' . 'width:100%;' . 'font-size:10px;' . 'float:left;' . 'margin-left:10px;' . '}' . '.addedIMG{' . 'height:100px;' . '}');
     $txt = 'Drag the images from a folder to the area below ...';
     $res = '<div id="box">' . '<div id="status">' . $txt . '</div>' . '<div id="drop"></div>' . '</div>' . '<div id="list"></div>';
     return $res;
 }
 function render()
 {
     if (!$this->url) {
         throw new \Exception('no url set');
     }
     $page = XmlDocumentHandler::getInstance();
     $page->disableDesign();
     //remove XhtmlHeader, designHead & designFoot for this request
     $page->setMimeType('application/xml');
     // or "application/opensearchdescription+xml"
     if (!is_url($this->icon)) {
         $this->icon = $page->getUrl() . $this->icon;
     }
     if (!is_url($this->url)) {
         $this->url = $page->getUrl() . $this->url;
     }
     return '<?xml version="1.0" encoding="UTF-8"?>' . '<OpenSearchDescription xmlns="http://a9.com/-/spec/opensearch/1.1/">' . '<ShortName>' . $this->name . '</ShortName>' . ($this->icon ? '<Image height="16" width="16" type="image/x-icon">' . $this->icon . '</Image>' : '') . '<Url type="text/html" template="' . $this->url . '{searchTerms}"/>' . '</OpenSearchDescription>';
 }
 function render()
 {
     if (!is_array($this->options)) {
         throw new \Exception('options not an array: ' . $this->options);
     }
     $page = XmlDocumentHandler::getInstance();
     $header = XhtmlHeader::getInstance();
     $el_id = 'multi_' . mt_rand();
     $header->registerJsFunction('function toggle_multi_opt(n) {' . 'var e = document.getElementById(n);' . 'if (e.multiple == true) {' . 'e.multiple = false;' . 'e.size = ' . $this->collapsed_size . ';' . '} else {' . 'e.multiple = true;' . 'e.size = ' . $this->expanded_size . ';' . '}' . '}');
     $out = '<select id="' . $el_id . '" name="' . strip_tags($this->name) . '[]"' . ($this->js_onchange ? ' onchange="' . $this->js_onchange . '"' : '') . '>';
     $out .= '<option value="0">---</option>';
     //default to "0" instead of an empty string for "no option selected"
     foreach ($this->options as $id => $title) {
         $out .= '<option value="' . $id . '"' . ($this->value && $this->value == $id ? ' selected="selected"' : '') . '>' . $title . '</option>';
     }
     $out .= '</select>';
     $out .= '<a href="#" onclick="toggle_multi_opt(\'' . $el_id . '\'); return false;" style="vertical-align: bottom;"><img src="' . $page->getRelativeCoreDevUrl() . 'gfx/bullet_toggle_plus.png"/></a>';
     return $out;
 }
Пример #7
0
 function render()
 {
     $page = XmlDocumentHandler::getInstance();
     $page->setMimeType('application/xhtml+xml');
     //page wont even display in IE
     $res = "\n" . '<svg xmlns="http://www.w3.org/2000/svg"' . ' version="1.1">' . "\n";
     // viewBox="0 0 '.$this->width.' '.$this->height.'">'; // style="position:absolute; top:0; left:0; z-index:-1;">';
     // SVG has a transparent background by default, set background color with a filled rectangle
     if ($this->bgcolor) {
         $bg = new SvgRectangle();
         $bg->width = "100%";
         $bg->height = "100%";
         $bg->fill_color = $this->bgcolor;
         $res .= $bg->render() . "\n";
     }
     foreach ($this->objs as $o) {
         $res .= $o->render() . "\n";
     }
     $res .= '</svg>' . "\n";
     return $res;
 }
Пример #8
0
 public function render()
 {
     //available variables in the scope of the view
     if (class_exists('\\cd\\ErrorHandler')) {
         $error = ErrorHandler::getInstance();
     }
     if (class_exists('\\cd\\SessionHandler')) {
         $session = SessionHandler::getInstance();
     }
     if (class_exists('\\cd\\SqlHandler')) {
         $db = SqlHandler::getInstance();
     }
     if (class_exists('\\cd\\XhtmlHeader')) {
         $header = XhtmlHeader::getInstance();
     }
     if (class_exists('\\cd\\XmlDocumentHandler')) {
         $page = XmlDocumentHandler::getInstance();
     }
     if (class_exists('\\cd\\LocaleHandler')) {
         $locale = LocaleHandler::getInstance();
     }
     if (class_exists('\\cd\\TempStore')) {
         $temp = TempStore::getInstance();
     }
     // make reference to calling object available in the namespace of the view
     $caller = $this->caller;
     $file = $page->getCoreDevPath() . $this->template;
     if (!file_exists($file)) {
         // if not built in view, look in app dir
         $file = $this->template;
         if (!file_exists($file)) {
             throw new \Exception('cannot find ' . $this->template);
         }
     }
     ob_start();
     require $file;
     return ob_get_clean();
 }
Пример #9
0
 function render($type = 'png', $dst_file = '')
 {
     if (!$this->resource) {
         throw new \Exception('no image resource loaded');
     }
     $page = XmlDocumentHandler::getInstance();
     $page->disableHtmlHeaders();
     $page->disableDesign();
     switch ($type) {
         case 'image/gif':
         case 'gif':
             if (!$dst_file) {
                 $page->setMimeType('image/gif');
             }
             imagegif($this->resource, $dst_file);
             break;
         case 'image/jpeg':
         case 'jpg':
         case 'jpeg':
             if (!$dst_file) {
                 $page->setMimeType('image/jpeg');
             }
             imagejpeg($this->resource, $dst_file, $this->jpeg_quality);
             break;
         case 'image/png':
         case 'png':
             if (!$dst_file) {
                 $page->setMimeType('image/png');
             }
             imagepng($this->resource, $dst_file);
             break;
         default:
             throw new \Exception('odd render type ' . $type);
     }
 }
Пример #10
0
<?php

/**
 * This is the application handler
 * all webpage requests is sent here from a RewriteRule in .htaccess
 */
require_once 'config.php';
require_once 'RequestHandler.php';
try {
    $front = RequestHandler::getInstance();
    $front->excludeSession(array('api'));
    //exclude session handling for these controllers
    $front->route();
    $page = XmlDocumentHandler::getInstance();
    echo $page->render();
} catch (Exception $e) {
    echo '<pre>';
    echo $e->__toString();
    dp($e->__toString());
    //because the exception is caught it is not written to error log
    echo '</pre>';
}
Пример #11
0
 public static function passthru($id)
 {
     $path = self::getUploadPath($id);
     $f = self::get($id);
     // Displays the file in the browser, and assigns a filename for the browser's "save as..." features
     header('Content-Disposition: inline; filename="' . basename($f->name) . '"');
     header('Content-Transfer-Encoding: binary');
     $page = XmlDocumentHandler::getInstance();
     $page->disableDesign();
     $page->setMimeType($f->mimetype);
     if ($f->size) {
         header('Content-Length: ' . $f->size);
     }
     readfile($path);
 }
Пример #12
0
 /** Logs out the user */
 function logout()
 {
     dp($this->username . ' logged out');
     if (!$this->id) {
         throw new \Exception('already logged out');
     }
     Sql::pUpdate('UPDATE tblUsers SET time_last_logout = NOW() WHERE id = ?', 'i', $this->id);
     $params = session_get_cookie_params();
     setcookie(session_name(), '', time() - 604800, $params['path'], $params['domain'], $params['secure'], $params['httponly']);
     $page = XmlDocumentHandler::getInstance();
     $show_page = $this->logged_out_start_page ? $this->logged_out_start_page : $page->getRelativeUrl();
     header('Location: ' . $show_page);
     $this->end();
     die;
 }
Пример #13
0
 /**
  * Creates a instance of requested controller and invokes requested method on that controller
  */
 public function route()
 {
     $page = XmlDocumentHandler::getInstance();
     $error = ErrorHandler::getInstance();
     // automatically resumes session unless it is blacklisted
     if (class_exists('\\cd\\SessionHandler') && !in_array($this->_controller, $this->exclude_session)) {
         $session = SessionHandler::getInstance();
         if ($session->getName()) {
             $session->start();
         }
     }
     switch ($this->_controller) {
         case 'a':
             $file = $page->getCoreDevPath() . 'views/admin/' . $this->_view . '.php';
             break;
         case 'u':
             $file = $page->getCoreDevPath() . 'views/user/' . $this->_view . '.php';
             break;
         case 'c':
             $file = $page->getCoreDevPath() . 'views/core/' . $this->_view . '.php';
             break;
         case 't':
             $file = $page->getCoreDevPath() . 'views/tools/' . $this->_view . '.php';
             break;
         default:
             $file = 'views/' . $this->_controller . '.php';
     }
     if (!file_exists($file)) {
         $file = 'views/error/404.php';
     }
     // expose request params for the view
     $view = new ViewModel($file);
     // XXX BUG: naming should be set correctly according to the hierarchy of the url, in reverse,
     // like: views/user/upload.php takes album/id parameters
     // so then in upload.php, "album" should be in the view param, and id in the owner param
     // -- now "album" is in owner, and "id" in child
     $view->view = $this->_view;
     $view->owner = $this->_owner;
     $view->child = $this->_child;
     $view->child2 = $this->_child2;
     $view->child3 = $this->_child3;
     $page->attach($view);
     // this must be done last, so that errors that was created during the view render can be displayed
     if ($error->getErrorCount()) {
         $page->attach($error);
     }
 }
Пример #14
0
 function __construct($interface_name, $interface_path)
 {
     $page = XmlDocumentHandler::getInstance();
     $this->interface_name = $interface_name;
     $this->interface_url = $page->getUrl() . $interface_path;
 }
Пример #15
0
 function render($format = '')
 {
     if ($format) {
         //echo "pl->render(FORMAT) is deprecated!! use ->setFormat()\n";
         $this->format = $format;
     }
     $page = XmlDocumentHandler::getInstance();
     switch ($this->format) {
         case 'xspf':
             if ($this->headers) {
                 $page->setMimeType('application/xspf+xml');
                 $page->disableDesign();
             }
             return $this->renderXSPF();
         case 'm3u':
             if ($this->headers) {
                 $page->setMimeType('audio/x-mpegurl');
                 $page->disableDesign();
             }
             return $this->renderM3U();
         case 'pls':
             if ($this->headers) {
                 $page->setMimeType('audio/x-scpls');
                 $page->disableDesign();
             }
             return $this->renderPLS();
         case 'sh':
             if ($this->headers) {
                 $page->setMimeType('text/plain; charset=utf-8');
                 $page->disableDesign();
             }
             return $this->renderSh();
         case 'xhtml':
         case 'html':
             return $this->renderXHTML();
         case 'atom':
             $feed = new NewsFeed();
             $feed->sendHeaders($this->headers);
             $feed->addItems($this->getItems());
             $feed->setTitle($this->title);
             return $feed->render('atom');
         case 'rss2':
         case 'rss':
             $feed = new NewsFeed();
             $feed->sendHeaders($this->headers);
             $feed->addItems($this->getItems());
             $feed->setTitle($this->title);
             return $feed->render('rss');
     }
     echo "Playlist->render: unknown format " . $this->format . "\n";
     return false;
 }