Пример #1
0
 function check_authen_credentials()
 {
     // First check for an existing authentication token.
     if (isset($_COOKIE[$this->_cookie_name])) {
         $this->notice('cookie exists');
         if ($result = $this->_handler->check_cookie($_COOKIE[$this->_cookie_name])) {
             return $result;
         }
     }
     //Check for a temporary auth token
     if (isset($_GET[$this->_cookie_name]) && isset($_GET['authtype']) && $_GET['authtype'] == 'temp') {
         if ($result = $this->_handler->check_cookie($_GET[$this->_cookie_name])) {
             $cookie_bits = explode(':', $_GET[$this->_cookie_name]);
             $hash = $cookie_bits[0];
             $this->_handler->set_authen_tokens();
             $this->_dbcon->Execute('DELETE FROM users_sessions where hash=' . $this->_dbcon->qstr($hash));
             if (isset($_GET['auth_action']) && $_GET['auth_action'] == 'reset') {
                 trigger_error('redirecting to :' . AMP_url_update('/system/' . AMP_SYSTEM_URL_USER, array('id' => $this->_handler->userid, 'action' => 'reset')));
                 ampredirect(AMP_url_update('/system/' . AMP_SYSTEM_URL_USER, array('id' => $this->_handler->userid, 'action' => 'reset')));
                 exit;
             }
             return $result;
         }
     }
     if (isset($_REQUEST[$this->_login_username_field]) || isset($_SERVER['PHP_AUTH_USER'])) {
         $this->notice('checking password');
         return $this->_handler->check_password();
     }
     $this->error('neither cookie nor password found');
     return false;
 }
Пример #2
0
 function get_url_edit()
 {
     if (!(isset($this->id) && $this->id)) {
         return AMP_SYSTEM_URL_FAQ;
     }
     return AMP_url_update(AMP_SYSTEM_URL_FAQ, array('id' => $this->id));
 }
Пример #3
0
function nav_articles_by_date()
{
    $page =& AMPContent_Page::instance();
    if ($class = $page->getClassId()) {
        $date_values = AMP_lookup('classArticlesByDate', $class);
    } else {
        $date_values = AMP_lookup('articlesByDate');
    }
    if (!$date_values) {
        return false;
    }
    $output = array();
    $renderer = AMP_get_renderer();
    foreach ($date_values as $pretty_date => $qty) {
        $real_date = strtotime($pretty_date);
        $url['year'] = date('Y', $real_date);
        $url['month'] = date('m', $real_date);
        $url['offset'] = false;
        $url['qty'] = false;
        $new_url = AMP_url_update($_SERVER['REQUEST_URI'], $url);
        $output[] = $renderer->link($new_url, $pretty_date, array('class' => AMP_CONTENT_CSS_CLASS_NAV_LINK));
        if (count($output) == AMP_CONTENT_NAV_ARCHIVE_LIMIT) {
            break;
        }
    }
    return join($renderer->newline(), $output);
}
Пример #4
0
 function onDelete(&$controller, $args = array())
 {
     $model = $controller->get_model();
     $nav_layout = $model->getLayoutId();
     if ($nav_layout) {
         ampredirect(AMP_url_update(AMP_SYSTEM_URL_NAV_LAYOUT, array('id' => $nav_layout)));
     }
 }
Пример #5
0
 function temp_auth_actions()
 {
     if (isset($_GET['auth_action']) && $_GET['auth_action'] == 'reset') {
         trigger_error('redirecting to :' . AMP_url_update('/system/' . AMP_SYSTEM_URL_USER, array('id' => $this->_handler->userid, 'action' => 'reset')));
         ampredirect(AMP_url_update('/system/' . AMP_SYSTEM_URL_USER, array('id' => $this->_handler->userid, 'action' => 'reset')));
         exit;
     }
 }
Пример #6
0
 function render_url_for_scaled($source, $width_limit)
 {
     if ($source->width <= $width_limit) {
         return $this->render_url_for($source);
     }
     $img_class = end(split(DIRECTORY_SEPARATOR, dirname($source->getPath())));
     return AMP_url_update(AMP_CONTENT_URL_IMAGE, array('filename' => $source->getName(), 'class' => $img_class, 'action' => 'resize', 'width' => $width_limit));
 }
Пример #7
0
 function buildUrlArray()
 {
     foreach ($this->section_keys as $id) {
         $this->urls[] = AMP_url_update(AMP_CONTENT_URL_LIST_SECTION, array('type' => $id));
     }
     foreach ($this->article_keys as $id) {
         $this->urls[] = AMP_url_update(AMP_CONTENT_URL_ARTICLE, array('id' => $id));
     }
 }
Пример #8
0
 function get_url_edit()
 {
     $badge = $this->getBadgeId();
     if ($badge) {
         return AMP_url_update(AMP_SYSTEM_URL_BADGE, array('id' => $badge));
     }
     $nav = $this->getNavId();
     if ($nav) {
         return AMP_url_update(AMP_SYSTEM_URL_NAV, array('id' => $nav));
     }
     return false;
 }
Пример #9
0
 function render_sections($source)
 {
     $section_list = $this->load_live_sections($source);
     $sections = array();
     foreach ($section_list as $section_id => $section_name) {
         $sections[] = $this->_renderer->link(AMP_url_update(AMP_CONTENT_URL_LIST_CLASS, array('type' => $section_id, 'class' => AMP_CONTENT_CLASS_BLOG)), $section_name);
     }
     $result = join(", ", $sections);
     if (!$result) {
         return false;
     }
     return AMP_TEXT_POSTED_IN . $this->_renderer->space() . $result;
 }
Пример #10
0
 function _dbEdit($source, $column_name)
 {
     $db_images = AMP_lookup('db_images');
     if (!$db_images) {
         return false;
     }
     $image_db_id = array_search($source->getName(), $db_images);
     if ($image_db_id === FALSE) {
         return false;
     }
     $renderer =& $this->_getRenderer();
     return $renderer->link(AMP_url_update(AMP_SYSTEM_URL_IMAGES, array('id' => $image_db_id)), AMP_TEXT_EDIT);
 }
Пример #11
0
 function render_nav_links($data, $fieldname)
 {
     if (!(isset($data['id']) && $data['id'])) {
         return false;
     }
     $linked_navs = AMP_lookup('navs_by_badge', $data['id']);
     if (!$linked_navs) {
         return false;
     }
     $renderer = AMP_get_renderer();
     foreach ($linked_navs as $id => $name) {
         $links[$id] = $renderer->link(AMP_url_update(AMP_SYSTEM_URL_NAV, array('id' => $id)), $name);
     }
     return 'Linked Navs:' . $renderer->UL($links);
 }
Пример #12
0
 function link_to_layouts($data, $fieldname)
 {
     if (!(isset($data['id']) && $data['id'])) {
         return false;
     }
     $linked_layouts = AMP_lookup('nav_layouts_by_nav', $data['id']);
     if (!$linked_layouts) {
         return false;
     }
     $renderer = AMP_get_renderer();
     asort($linked_layouts);
     foreach ($linked_layouts as $id => $name) {
         if (!$name) {
             continue;
         }
         $links[$id] = $renderer->link(AMP_url_update(AMP_SYSTEM_URL_NAV_LAYOUT, array('id' => $id)), $name);
     }
     return 'Used in Layouts:' . $renderer->UL($links, array('class' => 'linked_items'));
 }
Пример #13
0
 function _init_criteria()
 {
     if (!isset($this->_pager)) {
         return;
     }
     $pager_target = false;
     $section = isset($this->_source_criteria['section']) && $this->_source_criteria['section'] && !is_array($this->_source_criteria['section']) ? $this->_source_criteria['section'] : false;
     $class = isset($this->_source_criteria['class']) && $this->_source_criteria['class'] && !is_array($this->_source_criteria['class']) ? $this->_source_criteria['class'] : false;
     if ($section && $class) {
         $pager_target = AMP_url_update(AMP_CONTENT_URL_LIST_CLASS, array('type' => $section, 'class' => $class));
     } elseif ($section) {
         $pager_target = AMP_url_update(AMP_CONTENT_URL_LIST_SECTION, array('type' => $section));
     } elseif ($class) {
         $pager_target = AMP_url_update(AMP_CONTENT_URL_LIST_CLASS, array('class' => $class));
     }
     if ($pager_target) {
         $this->_pager->set_target($pager_target);
     }
 }
Пример #14
0
 function restore()
 {
     $target_id = $this->getData('id');
     if (!$target_id) {
         return false;
     }
     require_once 'AMP/Content/Template.inc.php';
     $template =& new AMPContent_Template($this->dbcon, $target_id);
     $template->save_version();
     $template->mergeData($this->getData());
     $result = $template->save();
     if (!$result) {
         return false;
     }
     AMP_flush_common_cache();
     $flash =& AMP_System_Flash::instance();
     $flash->add_message(sprintf(AMP_TEXT_DATA_RESTORE_SUCCESS, $this->getName()));
     ampredirect(AMP_url_update(AMP_SYSTEM_URL_TEMPLATE, array('id' => $target_id)));
     return $result;
 }
Пример #15
0
 function _make_event_list_field()
 {
     $uid = $this->udm->uid;
     if (!$uid) {
         $uid = isset($_REQUEST['uid']) ? $_REQUEST['uid'] : false;
     }
     if (!$uid) {
         return;
     }
     $events = AMP_lookup('eventsByOwner', $uid);
     if (!$events) {
         return;
     }
     $event_list = '';
     $renderer = AMP_get_renderer();
     foreach ($events as $event_id => $event_name) {
         $event_list .= $renderer->link(AMP_url_update(AMP_SYSTEM_URL_EVENT, array('id' => $event_id)), $event_name) . $renderer->newline();
     }
     $this->fields['events_list'] = array('type' => 'static', 'enabled' => true, 'default' => $event_list, 'public' => false);
     $this->fields['events_list_header'] = array('type' => 'header', 'label' => 'All Events Created By this User', 'public' => false, 'enabled' => true);
     $this->insertAfterFieldOrder(array('events_list_header', 'events_list'));
 }
Пример #16
0
 function nav_sub_section($type, $sort)
 {
     $finder = new Section(AMP_Registry::getDbcon());
     if (isset($sort) && $sort) {
         $finder_source =& $finder->getSearchSource();
         $finder_source->addSort($sort);
     }
     $sections = $finder->find(array('parent' => $type, 'displayable' => '1'));
     if (!$sections) {
         return;
     }
     $html = '<ul>';
     foreach ($sections as $section) {
         if (AMP_CONTENT_HUMANIZE_URLS) {
             $sectionURL = AMP_url_update('section.php', array('id' => $section->id));
         } else {
             $sectionURL = 'section.php?id=' . $section->id;
         }
         $html .= '<li><a href="' . $sectionURL . '">' . $section->getName() . '</a><img src="img/spacer.gif" height="4" width="3" align="left"> </li>';
     }
     $html .= '</ul>';
     return $html;
 }
Пример #17
0
/**
 * amp_badge_articles archive
 * class: default( blank ) set to a value to limit the archive to one class ( accepts comma-separated set )
 * limit: default( 24 ) set a max # of links to archived months. 2 years is the max and the default.
 */
function amp_badge_articles_archive($options)
{
    $renderer = AMP_get_renderer();
    $class = isset($options['class']) && $options['class'] ? $options['class'] : false;
    $limit = isset($options['limit']) && $options['limit'] ? $options['limit'] : 24;
    $articles_archive = $class ? AMP_lookup('article_archives_by_month_by_class', $class) : AMP_lookup('article_archives_by_month');
    if (!$articles_archive) {
        return false;
    }
    $articles_archive = array_slice(array_keys($articles_archive), 0, $limit);
    $links = array();
    $url_vars = array();
    if ($class) {
        $url_vars['class'] = $class;
    }
    foreach ($articles_archive as $date) {
        $datetime = strtotime($date);
        $url_vars['date[M]'] = date('m', $datetime);
        $url_vars['date[Y]'] = date('Y', $datetime);
        $links[] = $renderer->link(AMP_url_update('list.php', $url_vars), $date);
    }
    return $renderer->UL($links, array('class' => 'article-archives'));
}
Пример #18
0
 function &to_akismet($item_data)
 {
     $false = false;
     if (!AKISMET_KEY) {
         return $false;
     }
     $options = $this->getOptions();
     if (isset($options['akismet_body_field']) && $options['akismet_body_field']) {
         return $false;
     }
     $all_data = $this->udm->getData();
     if (!isset($all_data[$options['akismet_body_field']])) {
         return $false;
     }
     $body_field = $all_data[$options['akismet_body_field']];
     $ak_data = array();
     $ak_data['author'] = $item_data['First_Name'] . ' ' . $item_data['Last_Name'];
     $ak_data['email'] = $item_data['Email'];
     $ak_data['type'] = 'form_input';
     $ak_data['website'] = $item_data['Website'];
     $ak_data['body'] = $item_data[$body_field];
     $ak_data['permalink'] = isset($item_data['modin']) && $item_data['modin'] ? AMP_url_update(AMP_SITE_URL . '/' . AMP_CONTENT_URL_FORM, array('modin' => $item_data['modin'])) : false;
     require_once 'akismet/akismet.class.php';
     $akismet = new Akismet(AMP_SITE_URL, AKISMET_KEY, $ak_data);
     if ($akismet->isError(AKISMET_SERVER_NOT_FOUND)) {
         trigger_error('Akismet: Server Not Found');
         return $false;
     }
     if ($akismet->isError(AKISMET_RESPONSE_FAILED)) {
         trigger_error('Akismet: Response Failed');
         return $false;
     }
     if ($akismet->isError(AKISMET_INVALID_KEY)) {
         trigger_error('Akismet: Invalid Key');
         return $false;
     }
     return $akismet;
 }
Пример #19
0
 function do_request()
 {
     if (!$this->_request->execute()) {
         return false;
     }
     if (!AMP_DISPLAYMODE_DEBUG) {
         ampredirect(AMP_url_update($_SERVER['REQUEST_URI']));
     }
     if ($affected_qty = $this->_request->getAffectedQty()) {
         $this->message(sprintf(AMP_TEXT_LIST_ACTION_SUCCESS, ucfirst(AMP_PastParticiple($this->_request->getPerformedAction())), $affected_qty));
         AMP_flush_common_cache();
     } else {
         $this->message(sprintf(AMP_TEXT_LIST_ACTION_FAIL, AMP_PastParticiple($this->_request->getPerformedAction())));
     }
     $this->_after_request();
 }
Пример #20
0
 function render_comments($source)
 {
     if (!$source->allowsComments()) {
         return false;
     }
     require_once 'AMP/Content/Article/Comment/Public/List.php';
     $comments = new Article_Comment_Public_List(null, array('article' => $source->id));
     $comment_header = '<p class="subtitle comment_header"><a name="comments"></a>Comments</p>';
     $add_link = $this->_renderer->link(AMP_url_update(AMP_CONTENT_URL_COMMENT_ADD, array('articleid' => $source->id)), AMP_TEXT_ADD_A_COMMENT);
     return $comment_header . $comments->execute() . ($source->acceptingNewComments() ? $add_link : $this->_renderer->p(AMP_TEXT_COMMENTS_CLOSED));
 }
Пример #21
0
 function get_url_edit()
 {
     if ($db_id = $this->db_id()) {
         return AMP_url_update(AMP_SYSTEM_URL_IMAGE_EDIT, array("id" => $db_id));
     }
     $file_name = $this->id;
     if (!$file_name || $file_name == 'downloads') {
         return AMP_url_update(AMP_SYSTEM_URL_IMAGES, array('action' => 'new'));
     }
     return AMP_url_update(AMP_SYSTEM_URL_IMAGES, array("file" => $file_name, 'action' => 'new'));
 }
Пример #22
0
 function render_all()
 {
     if ($this->_qty_page >= $this->_qty_total || $this->_qty_page_internal && $this->_qty_page >= $this->_qty_page_internal) {
         return false;
     }
     $url = AMP_url_update($this->url_offset(), array('all' => '1', 'offset' => '', 'qty' => ''));
     return $this->_renderer->link($url, $this->_renderer->double_arrow_left() . $this->_renderer->space() . $this->_text_all . $this->_renderer->space() . $this->_renderer->double_arrow_right(), array('class' => $this->_css_class_link));
 }
Пример #23
0
function AMP_route_for($type, $id, $options = array())
{
    $route = AMP_url_update(constant(strtoupper("AMP_CONTENT_URL_{$type}")), array('id' => $id));
    if (empty($options)) {
        return $route;
    }
    if (isset($options['preview']) && $options['preview']) {
        #if( strpos( $route,'.php')) {
        return AMP_url_add_vars($route, array('preview=1', 'cache=0'));
        #}
    }
    return $route;
}
Пример #24
0
    }
    //check to make sure parent section is live
    require_once 'AMP/Content/Section.inc.php';
    $currentSection = new Section(AMP_Registry::getDbcon(), $currentArticle->getParent());
    if (!AmpUtility::display_okay($currentSection)) {
        AMP_make_404();
    }
    /**
     * Check if specified article is a section header and redirect to that section
     */
    if (AMP_CONTENT_REDIRECT_SECTIONHEADERS_TO_SECTIONS && $currentArticle->getClass() == AMP_CONTENT_CLASS_SECTIONHEADER) {
        if ($currentSection->hasData()) {
            //drop article id, keep preview or other url vars
            $new_params = $_GET;
            unset($new_params['id']);
            ampredirect(AMP_url_update($currentSection->getURL(), $new_params));
        }
    }
}
/**
 * Check Section List pages for a redirect in the SectionHeader 
 */
if ($currentPage->isList(AMP_CONTENT_LISTTYPE_SECTION) && ($currentSection =& $currentPage->getSection())) {
    if (!AmpUtility::display_okay($currentSection)) {
        AMP_make_404();
    }
    if ($target = $currentSection->getHeaderRedirect()) {
        ampredirect($target);
    }
}
/**
Пример #25
0
 function set_pager_request($vars)
 {
     if (!isset($this->_pager)) {
         $this->_pager_target = AMP_url_update($this->_pager_target, $vars);
         return;
     }
     $this->_pager->set_request($vars);
 }
Пример #26
0
 function _ancestryLinks()
 {
     $links = array();
     if (!isset($this->current_section)) {
         return $links;
     }
     $ancestors = $this->map->getAncestors($this->current_section);
     if (empty($ancestors)) {
         return $links;
     }
     foreach ($ancestors as $id => $section_name) {
         $section_name = $this->_trimText($section_name);
         $sectionURL = AMP_url_update('section.php', array('id' => $id));
         $new_item = "<a href=\"" . $this->baseURL . $sectionURL . "\" class=\"" . $this->css_class . "\">" . $section_name . "</a>";
         array_unshift($links, $new_item);
     }
     return $links;
 }
Пример #27
0
 function _renderBlock($output)
 {
     //$sortable_script = 'Sortable.create( "'.$this->list_id.'", { tag: "tr", only: "list_row", scroll: window  });';
     return $this->root_render_block($this->_renderer->form($this->render_toolbar() . $this->_renderer->tag('table', $this->_renderer->tag('tbody', $this->render_column_headers() . $output, array('id' => $this->list_id, 'class' => 'system'))) . $this->render_toolbar(), array('name' => $this->list_id, 'action' => AMP_url_update($_SERVER['REQUEST_URI']), 'method' => 'POST')));
 }
Пример #28
0
/*
$modidselect = $dbcon->Execute("SELECT id from modules where userdatamodid=" . $dbcon->qstr( $modin ) )
 or die( "Couldn't get module information: " . $dbcon->ErrorMsg() );

$modid = $modidselect->Fields("id");
*/
// Fetch the form instance specified by submitted modin value.
$udm = new UserDataInput($dbcon, $modin, true);
$udm->doPlugin("QuickForm", "BuildAdmin");
$mod_id = $udm->modTemplateID;
// Was data submitted via the web?
$sub = isset($_REQUEST['btnUdmSubmit']) && $_REQUEST['btnUdmSubmit'];
// Fetch or save user data.
if ($sub) {
    $udm->doPlugin('AMPsystem', 'Save');
    ampredirect(AMP_url_update($_SERVER['PHP_SELF'], array('modin' => $modin)));
}
/* Now Output the Form.

   Any necessary changes to the form should have been registered
   before now, including any error messages, notices, or
   complete form overhauls. This can happen either within the
   $udm object, or from print() or echo() statements.

   By default, the form will include AMP's base template code,
   and any database-backed intro text to the appropriate module.

*/
include "header.php";
print "<h2>Add/Edit " . $udm->name . " Form</h2>";
print $udm->output();
Пример #29
0
 /**
  * returns html for the search form
  */
 function execute($options = array())
 {
     $options = array_merge($this->getOptions(), $options);
     if (isset($options['search_form_display']) && !$options['search_form_display'] && !$this->udm->admin) {
         return false;
     }
     $frmName = $options['form_name'];
     $frmMethod = 'GET';
     $frmAction = $_SERVER['PHP_SELF'];
     $form = new HTML_QuickForm($frmName, $frmMethod, $frmAction);
     //remove the zip field if distance search is disabled
     //this is no longer relevant since all the fields can be specified directly
     //if (!$options['show_distance']) unset ($this->fields_def['zip']);
     if (isset($this->fields_def['field_order'])) {
         $fieldOrder = preg_split("/\\s?,\\s?/", $this->fields_def['field_order']);
         foreach ($fieldOrder as $field) {
             $field = trim($field);
             if (isset($this->fields_def[$field]) && (isset($options['show_' . $field]) ? $options['show_' . $field] : true)) {
                 $this->form_addElement($form, $field, $this->fields_def[$field], $this->udm->admin);
             }
         }
     } else {
         foreach ($this->fields_def as $fname => $fdef) {
             if (isset($options['show_' . $field]) ? $options['show_' . $field] : true) {
                 $this->form_addElement($form, $fname, $fdef, $this->udm->admin);
             }
         }
     }
     $this->form =& $form;
     $output = $form->toHtml();
     if ($options['show_search_header']) {
         $output = $this->search_text_header() . $output;
     }
     if ($this->udm->admin) {
         $renderer = AMP_get_renderer();
         $live_url = AMP_SITE_URL . AMP_url_update(AMP_CONTENT_URL_FORM, array('modin' => $this->udm->instance));
         $output .= $renderer->div(AMP_TEXT_LIVE_LINK . ': ' . $renderer->link($live_url, $live_url, array('target' => 'blank')), array('class' => 'preview_link')) . $renderer->newline();
     }
     return $output;
 }
Пример #30
0
 function get_constant_url($url_type, $interface_type)
 {
     $url_constant = strtoupper($interface_type . $url_type);
     if (!defined($url_constant)) {
         return false;
     }
     if (!(isset($this->id) && $this->id)) {
         return constant($url_constant);
     }
     return AMP_url_update(constant($url_constant), array($this->id_field => $this->id));
 }