/**
  *	This is the class constructor for the YDFormElement_Captcha class.
  *
  *	@param $form		The name of the form to which this element is connected.
  *	@param $name		The name of the form element.
  *	@param $label		(optional) The label for the form element.
  *	@param $attributes	(optional) The attributes for the form element.
  *	@param $options		(optional) The options for the elment.
  */
 function YDFormElement_Captcha($form, $name, $label = '', $attributes = array(), $options = array())
 {
     // init parent
     $this->YDFormElement($form, $name, $label, $attributes, $options);
     // set type
     $this->_type = 'captcha';
     $attributes = '';
     foreach (YDConfig::get('YD_FORMELEMENT_CAPTCHA_URLATTRIBUTES') as $k => $v) {
         $attributes .= '&' . $k . '=' . $v;
     }
     // create default image url
     $this->_url = YDRequest::getCurrentUrl(true) . '?do=ShowCaptcha' . $attributes . '&id=' . md5(microtime());
     // text box position
     $this->_textPosition_left = false;
     // refresh button or refresh image. not added by default
     $this->_button = null;
     $this->_refreshimage = false;
     $this->_refreshcaption = YDConfig::get('YD_FORMELEMENT_CAPTCHA_LABEL');
     // add refresh button
     if (isset($options['refreshbutton']) || in_array('refreshbutton', $options)) {
         $this->addRefreshButton();
     }
     if (isset($options['refreshimage']) || in_array('refreshimage', $options)) {
         $this->addRefreshImage();
     }
     if (isset($options['refreshcaption'])) {
         $this->_refreshcaption = $options['refreshcaption'];
     }
     // compute image
     $this->img = new YDFormElement_Img($form, $name . 'captcha', $this->_url, array('width' => 200, 'height' => 40));
     // compute on click
     $this->_onclick = "document.getElementById('" . $this->img->getAttribute('id') . "').src = document.getElementById('" . $this->img->getAttribute('id') . "').src.split('&id=')[0] + '&id=' + Math.random();document.getElementById('" . $this->getAttribute('id') . "').value='';document.getElementById('" . $this->getAttribute('id') . "').focus();";
 }
 /**
  *	This is the class constructor for the YDFormElement_Captcha class.
  *
  *	@param $form		The name of the form to which this element is connected.
  *	@param $name		The name of the form element.
  *	@param $label		(optional) The label for the form element.
  *	@param $attributes	(optional) The attributes for the form element.
  *	@param $options		(optional) The options for the elment.
  */
 function YDFormElement_Captcha($form, $name, $label = '', $attributes = array(), $options = array())
 {
     // init parent
     $this->YDFormElement($form, $name, $label, $attributes, $options);
     // set type
     $this->_type = 'captcha';
     // create default image url
     $this->_url = YDRequest::getCurrentUrl(true) . '?do=ShowCaptcha&id=' . md5(microtime());
     // text box position
     $this->_textPosition_left = false;
     // refresh button. not added by default
     $this->_button = null;
 }
function YDTplModLinkWithID($base, $item, $suffix = null)
{
    $base .= strpos($base, '?') === false ? '?id=' : '&id=';
    if (is_numeric($item)) {
        $base .= $item;
    } else {
        $base .= isset($item['id']) ? $item['id'] : $item;
    }
    if (!is_null($suffix)) {
        $base = $base . $suffix;
    }
    return YDUrl::makeLinkAbsolute($base, YDRequest::getCurrentUrl(true));
}
 /**
  *	This is the class constructor for the YDFeedCreator class.
  */
 function YDFeedCreator()
 {
     // Initialize YDBase
     $this->YDAddOnModule();
     // Setup the module
     $this->_author = 'Pieter Claerhout';
     $this->_version = '1.0';
     $this->_copyright = '(c) 2005 Pieter Claerhout, pieter@yellowduck.be';
     $this->_description = 'This addon class defines a RSS/ATOM feed. You can use this class to create RSS and ' . 'Atom feeds in a very easy and straightforward way. If you set up your class instance, ' . 'you can automatically output to the different versions of RSS and ATOM with the same ' . 'source data.';
     // Start with the general variables
     $this->_encoding = 'ISO-8859-1';
     $this->_title = '';
     $this->_description = '';
     $this->_link = YDRequest::getCurrentUrl();
     $this->_items = array();
     $this->_generator = YD_FW_NAMEVERS . ' - YDFeedCreator';
 }
예제 #5
0
 /**
  *  Helper function for the makeLinksAbsolute function.
  *
  *  @param  $rel_uri    The uri to convert to an absolute one.
  *  @param  $base       (optional) The base url. By default, it uses the current url.
  *
  *  @returns    The link converted to an absolute one.
  *
  *  @static
  */
 function makeLinkAbsolute($rel_uri, $base = null)
 {
     if (substr(strtolower($rel_uri), 0, 7) == 'http://') {
         return rtrim($rel_uri, '/.');
     }
     if (is_null($base)) {
         $base = YDRequest::getCurrentUrl(true);
     }
     preg_match("'^([^:]+://[^/]+)/'", $base, $m);
     $base_start = $m[1];
     if (preg_match("'^/'", $rel_uri)) {
         return rtrim($base_start . $rel_uri, '/.');
     }
     $base = preg_replace("{[^/]+\$}", '', $base);
     $base .= $rel_uri;
     $base = preg_replace("{^[^:]+://[^/]+}", '', $base);
     $base_array = explode('/', $base);
     if (count($base_array) && !strlen($base_array[0])) {
         array_shift($base_array);
     }
     $i = 1;
     while ($i < count($base_array)) {
         if ($base_array[$i - 1] == ".") {
             array_splice($base_array, $i - 1, 1);
             if ($i > 1) {
                 $i--;
             }
         } elseif ($base_array[$i] == ".." && $base_array[$i - 1] != "..") {
             array_splice($base_array, $i - 1, 2);
             if ($i > 1) {
                 $i--;
                 if ($i == count($base_array)) {
                     array_push($base_array, "");
                 }
             }
         } else {
             $i++;
         }
     }
     if (count($base_array) && isset($base_array[-1]) && $base_array[-1] == ".") {
         $base_array[-1] = "";
     }
     while (count($base_array) && preg_match("/^\\.\\.?\$/", $base_array[0])) {
         array_shift($base_array);
     }
     return rtrim($base_start . '/' . implode("/", $base_array), '/.');
 }
 /**
  *	This function will return a normalized URI. This is the URI without the debug information and will all keys
  *	sorted alphabetically.
  *
  *	@returns	Normalized request URI.
  */
 function getNormalizedUri()
 {
     $url = parse_url(YDRequest::getCurrentUrl());
     $params = $_GET;
     ksort($params);
     if (isset($params['YD_DEBUG'])) {
         unset($params['YD_DEBUG']);
     }
     $query = array();
     foreach ($params as $key => $val) {
         if ($key != 'PHPSESSID') {
             array_push($query, urlencode($key) . '=' . urlencode($val));
         }
     }
     $url['query'] = implode('&', $query);
     if (!empty($url['query'])) {
         $url['query'] = '?' . $url['query'];
     }
     return $url['path'] . $url['query'];
 }
 function YDWeblogAPI()
 {
     // Initialize the parent
     $this->YDBase();
     // Get the database connection
     $this->db = YDDatabase::getInstance('mysql', YDConfig::get('db_name', 'YDWeblog'), YDConfig::get('db_user', 'root'), YDConfig::get('db_pass', ''), YDConfig::get('db_host', 'localhost'));
     // Get a link to the database metadata
     $this->dbmeta = new YDDatabaseMetaData($this->db);
     // Upgrade the schema if needed
     $this->upgradeSchemaIfNeeded();
     // The array that will hold the image metadata
     $this->imagemetadata = null;
     // Delete spam comments older than 7 days
     $sql = 'DELETE FROM #_comments WHERE is_spam = 1 AND created < (unix_timestamp()-604800)';
     $this->db->executeSql($sql);
     // Delete the old IP numbers from spam check
     $comment_interval = YDConfig::get('comment_interval', 10);
     if ($comment_interval != '' && is_numeric($comment_interval)) {
         $sql = 'DELETE FROM #_spamcheck WHERE lastvisit < (unix_timestamp()-' . $comment_interval . ')';
         $this->db->executeSql($sql);
     }
     // Cleanup the bad behaviour table part 1
     $sql = 'DELETE FROM #_bad_behavior WHERE DATE_SUB( `date`, INTERVAL 1 day ) < DATE_SUB( CURDATE(), INTERVAL 1 day ) AND request_method = \'GET\' AND `key` = \'00000000\'';
     $this->db->executeSql($sql);
     // Cleanup the bad behaviour table part 2
     $sql = 'DELETE FROM #_bad_behavior WHERE DATE_SUB( `date`, INTERVAL 7 day ) < DATE_SUB( CURDATE(), INTERVAL 7 day )';
     $this->db->executeSql($sql);
     // Check against akismet if a key is there
     if (YDConfig::get('akismet_key', '') != '') {
         // Include the YDAkismet addon
         include_once YD_DIR_HOME_ADD . '/YDAkismet/YDAkismet.php';
         // Get the URL of the weblog
         $weblog_url = dirname(YDRequest::getCurrentUrl(true)) . '/';
         // Initialize YDAkismet
         $this->akismet = new YDAkismet($weblog_url, YDConfig::get('akismet_key', ''));
     } else {
         // No akismet
         $this->akismet = null;
     }
 }
function YDTplModLinkWithID($base, $item, $suffix = null)
{
    $ori_base = $base;
    $base .= strpos($base, '?') === false ? '?id=' : '&id=';
    if (is_numeric($item)) {
        $base .= $item;
    } else {
        $base .= is_array($item) && isset($item['id']) ? $item['id'] : $item;
    }
    if (YDConfig::get('friendly_urls', false)) {
        if ($ori_base == 'item_gallery.php') {
            $base = str_replace('item_gallery.php?id=', 'image/', $base);
        } else {
            $base = str_replace('.php?id=', '_', $base) . '.php';
        }
    }
    if (!is_null($suffix)) {
        $base = $base . $suffix;
    }
    return YDUrl::makeLinkAbsolute($base, YDRequest::getCurrentUrl(true));
}