function actionDefault()
 {
     // Get the filter
     $filter = 'no_spam';
     if (isset($_GET['filter']) && strtolower($_GET['filter']) == 'spam') {
         $filter = 'spam';
     }
     // Get the ID from the query string
     $id = $this->getIdFromQS();
     // If there is something, set the defaults
     if ($id != -1) {
         // Get the list of comments
         $comments = $this->weblog->getComments($id, 'CREATED DESC');
         // Get the item details
         $item = $this->weblog->getItemById($id);
         $this->tpl->assign('item', $item);
     } else {
         // Get the list of comments
         if ($filter == 'no_spam') {
             $comments = $this->weblog->getComments(null, 'CREATED DESC');
         } else {
             $comments = $this->weblog->getComments(null, 'CREATED DESC', -1, -1, false, true);
         }
     }
     // Get the pagesize and current page from the URL
     $page = @$_GET['page'];
     // Create the YDRecordSet object
     $comments = new YDRecordSet($comments, $page, YDConfig::get('YD_DB_DEFAULTPAGESIZE', 20));
     // Assign it to the template
     $this->tpl->assign('comments', $comments);
     $this->tpl->assign('filter', $filter);
     // Display the template
     $this->display();
 }
 function actionDefault()
 {
     // Get the data
     $db = YDDatabase::getInstance('sqlite', 'database2.db');
     // Output the server version
     YDDebugUtil::dump($db->getServerVersion(), 'Version:');
     // Output some queries
     YDDebugUtil::dump($db->getRecords('select * from escalations'), 'escalations');
     YDDebugUtil::dump($db->getRecords('select * from sqlite_master'), 'sqlite_master');
     YDConfig::set('YD_DB_FETCHTYPE', YD_DB_FETCH_NUM);
     YDDebugUtil::dump($db->getRecords('select * from sqlite_master'), 'array - sqlite_master');
     YDConfig::set('YD_DB_FETCHTYPE', YD_DB_FETCH_ASSOC);
     // Test string escaping
     YDDebugUtil::dump($db->string("Pieter's Framework"), '$db->string');
     // Show number of queries
     YDDebugUtil::dump($db->getSqlCount(), 'Number of queries');
     // Test timestamps
     YDDebugUtil::dump($db->getDate(), 'getDate()');
     YDDebugUtil::dump($db->getTime(), 'getTime()');
     YDDebugUtil::dump($db->getDate('__NOW__'), 'getDate( \'__NOW__\' )');
     YDDebugUtil::dump($db->getTime('__NOW__'), 'getTime( \'__NOW__\' )');
     YDDebugUtil::dump($db->getDate('28-FEB-1977'), 'getDate( \'28-FEB-1977\' )');
     YDDebugUtil::dump($db->getTime('28-FEB-1977'), 'getTime( \'28-FEB-1977\' )');
     YDDebugUtil::dump($db->sqlString($db->getDate()), 'sqlString( getDate() )');
     YDDebugUtil::dump($db->sqlString($db->getTime()), 'sqlString( getTime() )');
     YDDebugUtil::dump($db->sqlString($db->getDate('__NOW__')), 'sqlString( getDate( \'__NOW__\' ) )');
     YDDebugUtil::dump($db->sqlString($db->getTime('__NOW__')), 'sqlString( getTime( \'__NOW__\' ) )');
     // Test limits
     YDDebugUtil::dump($db->_prepareSqlForLimit('SELECT * FROM TABLE', 10));
     YDDebugUtil::dump($db->_prepareSqlForLimit('SELECT * FROM TABLE', 10, 25));
     // Test errors
     YDDebugUtil::dump($db->getRecords('xx'), 'should return error');
     // Close the database connection
     $db->close();
 }
 function actionDefault()
 {
     // Create the form
     $form = new YDForm('form1');
     $form->registerFilter('reverse', 'strrev');
     $form->setDefaults(array('txt2' => 'First text', 'txt3' => "2\nlines", 'hid1' => 'me hidden', 'chk1' => 'x', 'chk2' => false, 'sel1' => 2));
     $text =& $form->addElement('text', 'txt1', 'Enter text 1:');
     $text->_label = 'new label for txt1';
     $form->addElement('text', 'txt2', 'Enter text 2:', array('class' => 'textInputClass', 'name' => 'x'));
     $form->addElement('textarea', 'txt3', 'Enter text 2:');
     $form->addElement('textareacounter', 'txtcounter_1', 'Textarea counter 1', array(), array('maxlength' => 10, 'before' => ' (', 'after' => ' characters remaining)'));
     $form->addElement('textareacounter', 'txtcounter_2', 'Textarea counter 2');
     $form->addElement('radio', 'rad1', 'Select a value 1:', array(), array(1 => 'een', 2 => 'twee'));
     $form->addElement('radio', 'rad2', 'Select a value 2:', array(), array(1 => 'een<br/>', 2 => 'twee'));
     $form->addElement('hidden', 'hid1', '');
     $form->addElement('hidden', 'hid2', '', array(), 'i am also hidden');
     $form->addElement('image', 'img1', '', array(), 'http://www.scripting.com/images/xml.gif');
     $form->addElement('password', 'pas1', 'Enter your password');
     $form->addElement('bbtextarea', 'bbt1', 'Enter your BBCode');
     $form->addElement('checkbox', 'chk1', 'Select me please');
     $form->addElement('checkbox', 'chk2', 'Select me please');
     $form->addElement('select', 'sel1', 'Select an option:', array(), array(1 => 'een', 2 => 'twee'));
     $form->addElement('span', 'span1', 'This is a span. The next element is an image (img).');
     $form->addElement('img', 'img2', 'http://www.scripting.com/images/xml.gif');
     $form->addElement('file', 'fil1', 'Select an file:');
     $form->addElement('submit', 'cmd1', 'Send');
     $form->addElement('reset', 'res1', 'Reset');
     $form->addFilter('__ALL__', 'upper');
     $form->addFilter('txt1', 'trim');
     $form->addFilter('txt2', 'reverse');
     $form->addRule('txt1', 'required', 'txt1 is required');
     $form->addRule('chk2', 'exact', 'chk2 is required', 1);
     $form->addFormRule(array(&$this, 'formrule'), 'txt1 is required');
     if (YDConfig::get('YD_DEBUG') == 1 || YDConfig::get('YD_DEBUG') == 2) {
         YDDebugUtil::dump($form->_regElements, 'Registered elements');
         YDDebugUtil::dump($form->_regRules, 'Registered rules');
         YDDebugUtil::dump($form->_regFilters, 'Registered filters');
         YDDebugUtil::dump($form->_filters, 'Filters');
         YDDebugUtil::dump($form->_rules, 'Rules');
         YDDebugUtil::dump($form->_formrules, 'Form Rules');
         YDDebugUtil::dump($form->getValue('txt1'), 'txt1');
         YDDebugUtil::dump($form->getValue('txt2'), 'txt2');
         YDDebugUtil::dump($_POST, '$_POST');
         YDDebugUtil::dump($_FILES, '$_FILES');
         YDDebugUtil::dump($form->toArray());
     }
     if ($form->validate()) {
         YDDebugUtil::dump($form->getModifiedValues(), 'Form modified values');
         YDDebugUtil::dump($form->getValues(), 'Form values');
     } else {
         $form->display();
     }
     // Create the form
     $form2 = new YDForm('form2');
     $form2->setDefaults(array('txt1' => 'First text'));
     $form2->addElement('text', 'txt1', 'Enter text 1:');
     $form2->addElement('text', 'txt2', 'Enter text 2:');
     $form2->addElement('submit', 'cmd1', 'Send');
     $form2->display();
 }
 function actionDefault()
 {
     // Set some variables
     YDConfig::set('MyConfigVar1', 'value cfg1');
     YDConfig::set('MyConfigVar2', 'value cfg2');
     YDConfig::set('MyConfigVar3', 'value cfg3');
     // Get the values
     YDDebugUtil::dump(YDConfig::get('MyConfigVar1'), 'get - MyConfigVar1');
     YDDebugUtil::dump(YDConfig::get('MyConfigVar2'), 'get - MyConfigVar2');
     YDDebugUtil::dump(YDConfig::get('MyConfigVar3'), 'get - MyConfigVar3');
     // Check if the variables exist or not
     YDDebugUtil::dump(YDConfig::exists('MyConfigVar1'), 'exists - MyConfigVar1');
     YDDebugUtil::dump(YDConfig::exists('MyConfigVar2'), 'exists - MyConfigVar2');
     YDDebugUtil::dump(YDConfig::exists('MyConfigVar3'), 'exists - MyConfigVar3');
     // Check an unexisting variable
     YDDebugUtil::dump(YDConfig::exists('xx'), 'exists - xx');
     // Set some variables, not overriding existing values
     YDConfig::set('MyConfigVar1', 'value cfg1 changed', false);
     YDConfig::set('MyConfigVar2', 'value cfg2 changed', false);
     YDConfig::set('MyConfigVar3', 'value cfg3 changed', false);
     // Get the values (should be unchanged)
     YDDebugUtil::dump(YDConfig::get('MyConfigVar1'), 'get - MyConfigVar1 - changed1');
     YDDebugUtil::dump(YDConfig::get('MyConfigVar2'), 'get - MyConfigVar2 - changed1');
     YDDebugUtil::dump(YDConfig::get('MyConfigVar3'), 'get - MyConfigVar3 - changed1');
     // Set some variables, overriding existing values
     YDConfig::set('MyConfigVar1', 'value cfg1 changed', true);
     YDConfig::set('MyConfigVar2', 'value cfg2 changed', true);
     YDConfig::set('MyConfigVar3', 'value cfg3 changed', true);
     // Get the values (should be changed)
     YDDebugUtil::dump(YDConfig::get('MyConfigVar1'), 'get - MyConfigVar1 - changed2');
     YDDebugUtil::dump(YDConfig::get('MyConfigVar2'), 'get - MyConfigVar2 - changed2');
     YDDebugUtil::dump(YDConfig::get('MyConfigVar3'), 'get - MyConfigVar3 - changed2');
     // Dump the contents of YDConfig
     YDConfig::dump();
 }
 function actionDefault()
 {
     // Get the ID from the query string
     $id = $this->getIdFromQS();
     // If there is nothing, show the list
     if ($id == -1) {
         // Get the count and number of requests
         $requests_count = $this->weblog->getBadBehaviorRequestsCount();
         $requests = $this->weblog->getBadBehaviorPostRequests();
         // Get the pagesize and current page from the URL
         $page = @$_GET['page'];
         // Create the YDRecordSet object
         $requests = new YDRecordSet($requests, $page, YDConfig::get('YD_DB_DEFAULTPAGESIZE', 20));
         // Assign it to the template
         $this->tpl->assign('requests_count', $requests_count);
         $this->tpl->assign('requests', $requests);
     } else {
         // Get the request data
         $request = $this->weblog->getBadBehaviorRequestById($id);
         // Redirect if nothing found
         if (!$request) {
             $this->redirectToAction();
         }
         // Add it to the template
         $this->tpl->assign('request', $request);
     }
     // Display the template
     $this->display();
 }
 /**
  *	@returns	The current locale.
  */
 function get()
 {
     // Set the default locale
     YDConfig::set(YD_LOCALE_KEY, 'en', false);
     // Return the setting
     return strtolower(YDConfig::get(YD_LOCALE_KEY));
 }
 /**
  *  This static function returns an YDCMStatistics module
  *
  *  @returns    an module object
  */
 function module($name)
 {
     // include lib
     // TODO: check if name is a valid lib name
     require_once YDConfig::get('YD_DBOBJECT_PATH') . '/' . $name . '.php';
     // return class
     return new $name();
 }
 function actionThumbnailSmall()
 {
     // Get the image name
     if (!isset($_GET['id'])) {
         die('No image selected.');
     }
     // Create a new image object
     $img = new YDFSImage(YDConfig::get('dir_uploads', '../uploads') . '/' . $_GET['id']);
     // Output the thumbnail
     $img->outputThumbnail(48, 48);
 }
 function actionShowLog()
 {
     $file = new YDFSFile(YDConfig::get('YD_LOG_FILE'));
     $data = $file->getContents();
     if (substr($data, 0, 5) == '<?xml') {
         header('Content-type: text/xml');
     } else {
         header('Content-type: text/plain');
     }
     echo $data;
     die;
 }
 /**
  *  This function returns the page form (form admin edition)
  *
  *  @returns    YDForm object
  */
 function getFormPage()
 {
     YDInclude('YDForm.php');
     // get template and language object
     $templates = YDCMComponent::module('YDCMTemplates');
     $languages = YDCMComponent::module('YDCMLanguages');
     // create access options
     $access = array(0 => t('public'), 1 => t('private'));
     // create 'template pack' options
     $template_pack = array(1 => t('use templatepack') . ' (' . $templates->template_pack() . ')', 0 => t('use custom template'));
     // create form object
     $form = new YDForm(YDConfig::get('YDCMPAGE_FORMPAGE'));
     $form->addElement('text', 'reference', t('page_reference'), array('size' => 25, 'maxlength' => 35));
     $form->addElement('text', 'title', t('page_title'), array('size' => 70, 'maxlength' => 70));
     $form->addElement('textarea', 'html', t('page_html'));
     $form->addElement('textarea', 'xhtml', t('page_xhtml'));
     $form->addElement('select', 'access', t('page_access'), array(), $access);
     $form->addElement('select', 'state', t('page_state'), array(), array(1 => t('yes'), 0 => t('no'), 2 => t('schedule')));
     $form->addElement('datetimeselect', 'published_date_start', t('page_startdate'));
     $form->addElement('datetimeselect', 'published_date_end', t('page_enddate'));
     $form->addElement('select', 'template_pack', '', array(), $template_pack);
     $form->addElement('select', 'template', t('page_template'), array(), $templates->visitors_templates());
     $form->addElement('select', 'metatags', t('page_metatags'), array(), array(0 => t('no'), 1 => t('yes')));
     $form->addElement('textarea', 'description', t('page_description'), array('cols' => 50, 'rows' => 5));
     $form->addElement('textarea', 'keywords', t('page_keywords'), array('cols' => 50, 'rows' => 5));
     $form->addElement('select', 'searcheable', t('page_search'), array(), array(0 => t('no'), 1 => t('yes')));
     $form->addElement('hidden', 'content_id');
     $form->addElement('hidden', 'parent_id');
     $form->addElement('hidden', 'language_id');
     // parent of new page is 0 by default
     $form->setDefault('content_id', 0);
     $form->setDefault('parent_id', 0);
     $form->setDefault('language_id', $languages->adminDefault());
     // add form rules
     $form->addRule('reference', 'required', t('reference_required'));
     $form->addRule('reference', 'alphanumeric', t('reference_alphanumeric'));
     $form->addRule('reference', 'maxwords', t('reference_maxwords'), 1);
     $form->addRule('reference', 'maxlength', t('reference_maxlength'), 100);
     $form->addRule('title', 'required', t('title_required'));
     $form->addRule('title', 'maxlength', t('title_maxlength'), 255);
     $form->addRule('content_id', 'required', t('content_id_required'));
     $form->addRule('content_id', 'numeric', t('content_id_numeric'));
     $form->addRule('parent_id', 'required', t('parent_id_required'));
     $form->addRule('parent_id', 'numeric', t('parent_id_numeric'));
     $form->addRule('html', 'maxlength', t('html_maxlength'), 50000);
     $form->addRule('xhtml', 'maxlength', t('xhtml_maxlength'), 50000);
     $form->addRule('template_pack', 'in_array', t('template_pack_invalid'), array(0, 1));
     $form->addRule('template', 'in_array', t('template_invalid'), array_keys($templates->visitors_templates()));
     $form->addRule('metatags', 'in_array', t('metatags_invalid'), array(0, 1));
     $form->addRule('description', 'maxlength', t('description_maxlength'), 2000);
     $form->addRule('keywords', 'maxlength', t('keywords_maxlength'), 2000);
     return $form;
 }
示例#11
0
 function actionDefault()
 {
     // Get the list of items
     $items = $this->weblog->getItems();
     // Get the pagesize and current page from the URL
     $page = @$_GET['page'];
     // Create the YDRecordSet object
     $items = new YDRecordSet($items, $page, intval(YDConfig::get('YD_DB_DEFAULTPAGESIZE', 20) / 2));
     // Assign it to the template
     $this->tpl->assign('items', $items);
     // Display the template
     $this->display();
 }
示例#12
0
 function actionDefault()
 {
     // Get the list of links
     $links = $this->weblog->getLinks();
     // Get the pagesize and current page from the URL
     $page = @$_GET['page'];
     // Create the YDRecordSet object
     $links = new YDRecordSet($links, $page, YDConfig::get('YD_DB_DEFAULTPAGESIZE', 20));
     // Assign it to the template
     $this->tpl->assign('links', $links);
     // Display the template
     $this->display();
 }
 /**
  *	This is the class constructor for the YDHttpClient class.
  *
  *	@param $host	The host name to connect to.
  *	@param $port	(optional) The port to connect to (default is 80).
  */
 function YDHttpClient($host, $port = 80)
 {
     // Initialize the HTTP client
     $this->HttpClient($host, $port);
     $this->user_agent = 'Mozilla/4.0 (compatible; ' . YD_FW_NAMEVERS . ')';
     $this->contenttype = '';
     if (YDConfig::get('YD_HTTP_USES_GZIP') == 1) {
         $this->useGzip(true);
     } else {
         $this->useGzip(false);
     }
     $this->setDebug(YDConfig::get('YD_DEBUG'));
 }
 /**
  *	This function will return the element as HTML.
  *
  *	@returns	The form element as HTML text.
  */
 function toHtml()
 {
     // Create the list of attributes
     $attribs = array('name' => $this->_form . '_' . $this->_name);
     $attribs = array_merge($this->_attributes, $attribs);
     // check if we are in a Javascript environment
     if (YDConfig::get('YD_FORMELEMENT_TEXTAREA_NL')) {
         $this->_value = preg_replace("/\r*\n/", "\\n", $this->_value);
         $this->_value = preg_replace("/\\//", "\\\\/", $this->_value);
         $this->_value = preg_replace("/'/", " ", $this->_value);
     }
     // Get the HTML
     return '<textarea' . YDForm::_convertToHtmlAttrib($attribs) . '>' . $this->_value . '</textarea>';
 }
 function install()
 {
     // Initialize the parent
     $this->YDRequest();
     // Initialize the template
     $this->tpl = new YDTemplate();
     // Get the shortcuts to the directories
     $this->dir_uploads = YDConfig::get('dir_uploads', 'uploads');
     $this->dir_skins = YDConfig::get('dir_skins', 'skins') . '/';
     // Error out if the YDFramework temp directory is not writeable
     $this->_checkWriteableDirectory(YD_DIR_TEMP);
     $this->_checkWriteableDirectory(dirname(__FILE__) . '/include');
     $this->_checkWriteableDirectory(dirname(__FILE__) . '/uploads');
 }
 function actionDefault()
 {
     // Get the list of categories
     $categories = $this->weblog->getCategories();
     // Get the pagesize and current page from the URL
     $page = @$_GET['page'];
     // Create the YDRecordSet object
     $categories = new YDRecordSet($categories, $page, YDConfig::get('YD_DB_DEFAULTPAGESIZE', 20));
     // Assign it to the template
     $this->tpl->assign('categories', $categories);
     // Assign the quick adds form to the template
     $this->tpl->assignForm('form', $this->form);
     // Display the template
     $this->display();
 }
示例#17
0
 function initCommentsFeed()
 {
     // Get the weblog items
     $comments = $this->weblog->getComments(null, 'CREATED DESC', YDConfig::get('max_syndicated_items', 15));
     // Initialize the feed
     $this->feed = new YDFeedCreator();
     $this->feed->setTitle(YDConfig::get('weblog_title', 'Untitled Weblog') . ' - ' . t('comments'));
     $this->feed->setDescription(YDConfig::get('weblog_description', 'Untitled Weblog Description'));
     $this->feed->setLink(YDUrl::makeLinkAbsolute('index.php'));
     // Add the items
     foreach ($comments as $comment) {
         $body = $comment['comment'] . "\n\n" . t('by') . ' ' . $comment['username'];
         $this->feed->addItem($comment['item_title'], YDTplModLinkItem($comment['item_id'], '#comment'), YDTplModBBCode($body));
     }
 }
示例#18
0
 function actionDefault()
 {
     // Get the ID from the query string
     $id = $this->getIdFromQS();
     if ($id != -1) {
         $this->redirect('item.php?id=' . $id);
     }
     // Get the weblog items and 5 older items
     $items = $this->weblog->getItems(YDConfig::get('weblog_entries_fp', 5));
     $old_items = $this->weblog->getItems(5, sizeof($items));
     // Assign them to the template
     $this->tpl->assign('items', $items);
     $this->tpl->assign('old_items', $old_items);
     // Display the template
     $this->display();
 }
 /**
  *	This is the method returns the JS initialization of the editor
  *
  */
 function JSinit($htmlID)
 {
     // start by creating an FCKeditor object
     $js = "oFCKeditor = new FCKeditor( '" . $htmlID . "' );";
     // set the editor path
     $js .= "oFCKeditor.BasePath = '" . YDConfig::get('YD_AJAXEDITOR_FCKEDITOR_Url') . "';";
     // set editor skin path
     $js .= "oFCKeditor.Config['SkinPath'] = oFCKeditor.BasePath + 'editor/skins/" . YDConfig::get('YD_AJAXEDITOR_FCKEDITOR_Skin') . "/';";
     // set toolbar expanded on start
     $js .= YDConfig::get('YD_AJAXEDITOR_FCKEDITOR_ToolbarStartExpanded') ? "oFCKeditor.Config['ToolbarStartExpanded'] = true;" : "oFCKeditor.Config['ToolbarStartExpanded'] = false;";
     // set toolbar scheme
     $js .= "oFCKeditor.ToolbarSet = '" . YDConfig::get('YD_AJAXEDITOR_FCKEDITOR_ToolbarSet') . "';";
     // on fckeditor we add a replace method (that will replace the textarea)
     $js .= "oFCKeditor.ReplaceTextarea();";
     return $js;
 }
 function actionDefault()
 {
     // Create the form
     $form = new YDForm('form1');
     // Add a first set of elements
     $elementDate = $form->addElement('dateselect', 'dateSelect1', 'Enter data:');
     $elementTime = $form->addElement('timeselect', 'timeSelect1', 'Enter data:');
     $elementDateTime = $form->addElement('datetimeselect', 'datetimeSelect1', 'Enter data:');
     // Add a second set of elements
     $form->addElement('dateselect', 'dateSelect2', 'Enter data:', array(), array('yearstart' => 1970, 'yearend' => '2050'));
     $form->addElement('timeselect', 'timeSelect2', 'Enter data:');
     $form->addElement('datetimeselect', 'datetimeSelect2', 'Enter data:', array(), array('yearstart' => 1970, 'yearend' => '2050'));
     $form->addElement('datetimeselect', 'datetimeSelect3', 'Enter data with seconds:', array(), array('seconds' => true));
     // Add the send button
     $form->addElement('submit', 'cmd1', 'Send');
     // Set the defaults
     $form->setDefaults(array('dateSelect1' => array('month' => 4, 'day' => 4, 'year' => 2002), 'dateSelect2' => strval(time()), 'timeSelect2' => strval(time()), 'datetimeSelect2' => time() + 3600 * 24));
     // Display the form
     $form->display();
     // Show the contents of the form
     if (YDConfig::get('YD_DEBUG') == 1) {
         YDDebugUtil::dump($form->_regElements, 'Registered elements');
         YDDebugUtil::dump($form->_regRules, 'Registered rules');
         YDDebugUtil::dump($form->_regFilters, 'Registered filters');
         YDDebugUtil::dump($form->_filters, 'Filters');
         YDDebugUtil::dump($form->_rules, 'Rules');
         YDDebugUtil::dump($form->_formrules, 'Form Rules');
         YDDebugUtil::dump($form->getValue('dateSelect1'), 'dateSelect1');
         YDDebugUtil::dump($form->getValue('timeSelect1'), 'timeSelect1');
         YDDebugUtil::dump($form->getValue('datetimeSelect1'), 'datetimeSelect1');
         YDDebugUtil::dump($form->getValues(), '$form->getValues()');
         YDDebugUtil::dump($_POST, '$_POST');
         YDDebugUtil::dump($_FILES, '$_FILES');
     }
     if ($form->validate()) {
         YDDebugUtil::dump($form->getValues(), '$form->getValues()');
         YDDebugUtil::dump($elementDate->getTimeStamp(), '$elementDate->getTimeStamp()');
         YDDebugUtil::dump($elementDate->getTimeStamp('%d/%m/%Y'), '$elementDate->getTimeStamp( "%d/%m/%Y" )');
         YDDebugUtil::dump(date('M-d-Y', $elementDate->getTimeStamp()), '$elementDate->gdate( getTimeStamp() )');
         YDDebugUtil::dump($elementTime->getTimeStamp(), '$elementTime->getTimeStamp()');
         YDDebugUtil::dump($elementTime->getTimeStamp('%H:%M'), '$elementTime->getTimeStamp( "%H:%M" )');
         YDDebugUtil::dump($elementDateTime->getTimeStamp(), '$elementDateTime->getTimeStamp()');
         YDDebugUtil::dump($elementDateTime->getTimeStamp('%d/%m/%Y %H:%M'), '$elementDateTime->getTimeStamp( "%H:%M" )');
         YDDebugUtil::dump(YDStringUtil::formatDate($elementDateTime, 'datetime', 'pt'), 'YDStringUtil::formatDate');
     }
 }
 /**
  *	This is the method returns the JS initialization of the editor
  *
  */
 function JSinit($htmlID)
 {
     // start by creating an FCKeditor object
     $js = "oFCKeditor = new FCKeditor( '" . $htmlID . "' );";
     // set the editor path
     $js .= "oFCKeditor.BasePath = '" . YDConfig::get('YD_AJAXEDITOR_FCKEDITOR_Url') . "';";
     // set editor skin path
     $js .= "oFCKeditor.Config['SkinPath'] = oFCKeditor.BasePath + 'editor/skins/" . YDConfig::get('YD_AJAXEDITOR_FCKEDITOR_Skin') . "/';";
     // set toolbar expanded on start
     $js .= YDConfig::get('YD_AJAXEDITOR_FCKEDITOR_ToolbarStartExpanded') ? "oFCKeditor.Config['ToolbarStartExpanded'] = true;" : "oFCKeditor.Config['ToolbarStartExpanded'] = false;";
     // set toolbar scheme
     $js .= 'oFCKeditor.ToolbarSet = "' . YDConfig::get('YD_AJAXEDITOR_FCKEDITOR_ToolbarSet') . '";';
     // set size and language
     $js .= "oFCKeditor.Height = 210;";
     $js .= 'oFCKeditor.Width = "90%";';
     $js .= 'oFCKeditor.Config["AutoDetectLanguage"] = false;';
     $js .= 'oFCKeditor.Config["DefaultLanguage"] = "' . YDConfig::get('YD_AJAXEDITOR_FCKEDITOR_DefaultLanguage') . '";';
     // on fckeditor we add a replace method (that will replace the textarea)
     $js .= "oFCKeditor.ReplaceTextarea();";
     return $js;
 }
示例#22
0
 function actionDefault()
 {
     // Get the ID from the query string
     $id = $this->getQueryStringParameterAsInt('id', -1);
     if ($id != -1) {
         $this->redirect('item.php?id=' . $id);
     }
     // Add support for itemid query strings
     $id = $this->getQueryStringParameterAsInt('itemid', -1);
     if ($id != -1) {
         $this->redirect('item.php?id=' . $id);
     }
     // Get the weblog items and 5 older items
     $items = $this->weblog->getPublicItems(YDConfig::get('weblog_entries_fp', 5));
     $old_items = $this->weblog->getPublicItems(YDConfig::get('weblog_entries_fp', 5), sizeof($items));
     // Assign the variables to the template
     $this->tpl->assign('items', $items);
     $this->tpl->assign('old_items', $old_items);
     // Display the template
     $this->display();
 }
 /**
  *  This function execute the SQL statement passed and adds it's
  *  results to the object.
  *
  *  @param $sql      The SQL statement.
  *  @param $slices   (optional) The slices of the query.
  *
  *  @returns  The number of records found.
  */
 function findSql($sql, $slices = array())
 {
     YDDebugUtil::debug(YDStringUtil::removeWhiteSpace($sql));
     $fetch = YDConfig::get('YD_DB_FETCHTYPE');
     YDConfig::set('YD_DB_FETCHTYPE', YD_DB_FETCH_NUM);
     $results = $this->_db->getRecords($sql);
     YDConfig::set('YD_DB_FETCHTYPE', $fetch);
     if (!sizeof($slices)) {
         $slices = array(0 => '');
     }
     reset($slices);
     $var = current($slices);
     while ($var !== false) {
         $curr_pos = key($slices);
         $next = next($slices);
         $next_pos = $next ? key($slices) : false;
         if (!$var) {
             $obj =& $this;
         } else {
             $obj =& $this->{$var};
         }
         $obj->resetResults();
         $obj->_count = $results ? sizeof($results) : 0;
         $select = $obj->_query->select;
         foreach ($results as $result) {
             if (!$next_pos) {
                 $next_pos = sizeof($result);
             }
             $length = $next_pos - $curr_pos;
             $res = array_slice($result, $curr_pos, $length);
             $new_res = array();
             for ($i = 0; $i < sizeof($res); $i++) {
                 $new_res[$select[$i]['alias']] = $res[$i];
             }
             $obj->_results[] = $new_res;
         }
         $obj->resetQuery();
         if ($obj->_count >= 1) {
             $obj->setValues($obj->_results[0]);
         }
         $var = current($slices);
     }
     return $this->_count;
 }
 /**
  *	This function will connect to the database, execute a query and will return the result handle.
  *
  *	@param $sql	The SQL statement to execute.
  *
  *  @returns    Handle to the result of the query. In case of an error, this function triggers an error.
  *
  *	@internal
  */
 function &_connectAndExec($sql)
 {
     // Add the table prefix
     $sql = str_replace(' #_', ' ' . YDConfig::get('YD_DB_TABLEPREFIX', ''), $sql);
     // Update the language placeholders
     $languageIndex = YDConfig::get('YD_DB_LANGUAGE_INDEX', null);
     if (!is_null($languageIndex)) {
         $sql = str_replace('_@', '_' . $languageIndex, $sql);
     }
     // Connect
     $result = $this->connect();
     // Handle errors
     if (!$result && $this->_failOnError === true) {
         $error = ocierror();
         trigger_error($error['message'], YD_ERROR);
     }
     // Record the start time
     $timer = new YDTimer();
     // Create statement
     $stmt = OCIParse($this->_conn, $sql);
     // Handle errors
     if (!$stmt && $this->_failOnError === true) {
         $error = ocierror($stmt);
         trigger_error($error['message'], YD_ERROR);
     }
     // Execute
     $result = @OCIExecute($stmt);
     // Handle errors
     if ($result === false && $this->_failOnError === true) {
         $error = ocierror($stmt);
         if (!empty($error['sqltext'])) {
             $error['message'] .= ' (SQL: ' . $error['sqltext'] . ')';
         }
         echo '<b>Stacktrace:</b> <pre>' . YDDebugUtil::getStackTrace() . '</pre>';
         echo '<b>SQL Statement:</b> <pre>' . $this->formatSql($sql) . '</pre>';
         trigger_error($error['message'], YD_ERROR);
     }
     // Log the statement
     $this->_logSql($sql, $timer->getElapsed());
     // Return the result
     return $stmt;
 }
        License as published by the Free Software Foundation; either
        version 2.1 of the License, or (at your option) any later version.
    This library is distributed in the hope that it will be useful,
        but WITHOUT ANY WARRANTY; without even the implied warranty of
        MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
        Lesser General Public License for more details.
    You should have received a copy of the GNU Lesser General Public
        License along with this library; if not, write to the Free Software
        Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
// Check if the framework is loaded
if (!defined('YD_FW_NAME')) {
    die('Yellow Duck Framework is not loaded.');
}
// set components path
YDConfig::set('YD_DBOBJECT_PATH', YD_DIR_HOME_ADD . '/YDCMComponent', false);
// include YDF libs
YDInclude('YDDatabaseObject.php');
YDInclude('YDResult.php');
// add translations directory for generic translations
YDLocale::addDirectory(dirname(__FILE__) . '/languages/');
class YDCMPermission extends YDDatabaseObject
{
    function YDCMPermission()
    {
        // init component as non default
        $this->YDDatabaseObject();
        // register database as default
        $this->registerDatabase();
        // register table for this component
        $this->registerTable('YDCMPermission');
 /**
  *	This is the class constructor of the YDXmlRpcClient class.
  *
  *	@param $url	The URL of the XML/RPC server.
  */
 function YDXmlRpcClient($url)
 {
     $this->_client = new YDXmlRpcClientCore($url);
     if (YDConfig::get('YD_DEBUG') == 1) {
         $this->_client->debug = true;
     } else {
         $this->_client->debug = false;
     }
 }
 function actionShowImage()
 {
     // Get the list of files
     $file = $this->getImage();
     $this->redirectIfMissing($file);
     // Redirect
     $this->redirect('../' . YDConfig::get('dir_uploads', 'uploads') . '/' . $file);
 }
示例#28
0
 /**
  *	This function will print a stack trace.
  *
  *	@static
  */
 function stackTrace()
 {
     if (YDConfig::get('YD_DEBUG') == 1 || YDConfig::get('YD_DEBUG') == 2) {
         $err = 'URI: ' . YD_SELF_URI . YD_CRLF . YDDebugUtil::getStackTrace();
         if (ini_get('display_errors') == 1) {
             echo '<pre>' . YD_CRLF . htmlentities($err) . '</pre>';
         }
         error_log($err, 0);
     }
 }
示例#29
0
 /**
  *	This function will log the specified text to the logfile, indicating the correct level.
  *
  *	@param $level	The level to show in the logfile
  *	@param $text	The text to show in the logfile
  *
  *	@internal
  */
 function _log($level, $text)
 {
     // Get the maximum linesize
     $maxlinesize = is_numeric(YDConfig::get('YD_LOG_MAX_LINESIZE')) ? intval(YDConfig::get('YD_LOG_MAX_LINESIZE')) : 80;
     $wraplines = is_bool(YDConfig::get('YD_LOG_WRAPLINES')) ? YDConfig::get('YD_LOG_WRAPLINES') : false;
     // Split the text up in parts if longer than the maximum linesize
     if (strlen($text) > $maxlinesize && $wraplines) {
         // The break character we are going to use
         $break = '__YD_LOG_BREAK__';
         // Wrap the text
         $text = YD_CRLF . "\t" . wordwrap($text, $maxlinesize, YD_CRLF . "\t");
     }
     // Get the current stack
     $stack = debug_backtrace();
     // Plain text logfile
     if (strtoupper(YDConfig::get('YD_LOG_FORMAT')) == 'TEXT') {
         // Get the template
         $msg = YDConfig::get('YD_LOG_TEXTFORMAT');
         // Fill in the variables
         $msg = str_replace('%date%', strftime('%Y-%m-%d %H:%M:%S'), $msg);
         $msg = str_replace('%level%', strtoupper($level), $msg);
         $msg = str_replace('%file%', $stack[1]['file'], $msg);
         $msg = str_replace('%basefile%', basename($stack[1]['file']), $msg);
         $msg = str_replace('%uri%', YD_SELF_URI, $msg);
         $msg = str_replace('%line%', $stack[1]['line'], $msg);
         $msg = str_replace('%function%', $stack[2]['class'] . $stack[2]['type'] . $stack[2]['function'], $msg);
         $msg = str_replace('%message%', $text, $msg);
         $msg = $msg . YD_CRLF;
         // Write to the file
         $f = fopen(YDConfig::get('YD_LOG_FILE'), 'a');
         fwrite($f, $msg);
         fclose($f);
     }
     // XML logfile
     if (strtoupper(YDConfig::get('YD_LOG_FORMAT')) == 'XML') {
         // Create the log entry
         $msg = '<entry>';
         $msg .= '<date>' . strftime('%Y-%m-%d %H:%M:%S') . '</date>';
         $msg .= '<level>' . htmlentities(strtoupper($level)) . '</level>';
         $msg .= '<file>' . htmlentities($stack[1]['file']) . '</file>';
         $msg .= '<basefile>' . htmlentities(basename($stack[1]['file'])) . '</basefile>';
         $msg .= '<uri>' . htmlentities(YD_SELF_URI) . '</uri>';
         $msg .= '<line>' . htmlentities($stack[1]['line']) . '</line>';
         $msg .= '<function>' . htmlentities($stack[2]['class'] . $stack[2]['type'] . $stack[2]['function']) . '</function>';
         $msg .= '<message>' . htmlentities($text) . '</message>';
         $msg .= '</entry>' . YD_CRLF;
         $msg .= '</log>';
         // Write to the file
         $f = fopen(YDConfig::get('YD_LOG_FILE'), 'a');
         fclose($f);
         $f = fopen(YDConfig::get('YD_LOG_FILE'), 'r+');
         clearstatcache();
         if (filesize(YDConfig::get('YD_LOG_FILE')) == 0) {
             fwrite($f, '<?xml version=\'1.0\'?>' . YD_CRLF . '<log creator="' . htmlentities(YD_FW_NAMEVERS) . '">' . YD_CRLF . '</log>');
         }
         fseek($f, -6, SEEK_END);
         fwrite($f, $msg);
         fclose($f);
     }
     // Use another function if not text or XML
     if (!in_array(strtoupper(YDConfig::get('YD_LOG_FORMAT')), array('XML', 'TEXT'))) {
         // Get the values
         $values = array();
         $values['date'] = time();
         //strftime( '%Y-%m-%d %H:%M:%S' );
         $values['level'] = strtoupper($level);
         $values['file'] = $stack[1]['file'];
         $values['basefile'] = basename($stack[1]['file']);
         $values['uri'] = YD_SELF_URI;
         $values['line'] = $stack[1]['line'];
         $values['function'] = $stack[2]['class'] . $stack[2]['type'] . $stack[2]['function'];
         $values['message'] = $text;
         // Log the values
         call_user_func('YDLogWrite_' . strtoupper(YDConfig::get('YD_LOG_FORMAT')), $values);
     }
 }
 /**
  *  This function will connect to the database, execute a query and will return the result handle.
  *
  *  @param $sql The SQL statement to execute.
  *
  *  @returns    Handle to the result of the query.
  *
  *  @internal
  */
 function &_connectAndExec($sql)
 {
     // Add the table prefix
     $sql = str_replace(' #_', ' ' . YDConfig::get('YD_DB_TABLEPREFIX', ''), $sql);
     $sql = str_replace(' `#_', ' `' . YDConfig::get('YD_DB_TABLEPREFIX', ''), $sql);
     // Connect
     $result = $this->connect();
     // Handle errors
     if (!$result && is_null($this->_conn) && $this->_failOnError === true) {
         trigger_error(mysql_error(), YD_ERROR);
     }
     if (!$result && !is_null($this->_conn) && $this->_failOnError === true) {
         trigger_error(mysql_error($this->_conn), YD_ERROR);
     }
     // Record the start time
     $timer = new YDTimer();
     // Execute the query
     $result = @mysql_query($sql, $this->_conn);
     // Handle errors
     if ($result === false && $this->_failOnError === true) {
         YDDebugUtil::error('[' . mysql_errno($this->_conn) . '] ' . mysql_error($this->_conn), $sql);
     }
     // Log the statement
     $this->_logSql($sql, $timer->getElapsed());
     // Return the result
     return $result;
 }