function smarty_function_init_language($params, &$smarty) { global $site, $leht; $content_template =& $leht->content_template; ################## # default values extract($params); if (!isset($name)) { $name = "language"; } # / default values ################### $sql = $site->db->prepare("SELECT keel_id AS id, nimi AS name, extension FROM keel WHERE on_kasutusel"); $sth = new SQL($sql); $sth->debug->msg($sth->debug->get_msgs()); while ($result = $sth->fetch()) { // if not in editor and use aliases has been enabled if (!$site->in_editor && $site->CONF['use_aliases']) { $result['href'] = $site->CONF['wwwroot'] . '/' . $result['extension']; } else { $result['href'] = $site->CONF['wwwroot'] . ($site->in_editor ? '/editor' : '') . '/?lang=' . $result['extension']; } $result['home_id'] = $site->alias(array('key' => 'rub_home_id', 'keel' => $result['id'])); $language[] = $result; } ############## # assign to template variables $smarty->assign(array($name => $language)); }
/** * list comments * * @param resource the SQL result * @return string the rendered text * * @see layouts/layout.php **/ function layout($result) { global $context; // empty list if (!SQL::count($result)) { $output = array(); return $output; } // we return an array of ($url => $attributes) $items = array(); // process all items in the list include_once $context['path_to_root'] . 'comments/comments.php'; while ($item = SQL::fetch($result)) { // url to view the comment $url = Comments::get_url($item['id']); // initialize variables $prefix = $label = $suffix = $icon = ''; // the title as the label if ($item['create_name']) { $label .= ucfirst($item['create_name']) . ' '; } // time of creation $label .= Skin::build_date($item['create_date']); // text beginning if ($text = Skin::strip($item['description'], 10, NULL, NULL)) { $suffix = ' - ' . $text; } // list all components for this item $items[$url] = array($prefix, $label, $suffix, 'comment', $icon); } // end of processing SQL::free($result); return $items; }
/** * list sections * * @param resource the SQL result * @return string the rendered text * * @see layouts/layout.php **/ function layout($result) { global $context; // empty list if (!SQL::count($result)) { $output = array(); return $output; } // we return some text $text = ''; // process all items in the list while ($item = SQL::fetch($result)) { // we want to make it visual if (!$item['thumbnail_url']) { continue; } // a title for the image --do not force a title if (isset($item['title'])) { $title = $item['title']; } else { $title = ''; } // the url to view this item $url = Sections::get_permalink($item); // use the skin to shape it $text .= Skin::build_image('thumbnail', $item['thumbnail_url'], $title, $url); } // end of processing SQL::free($result); return $text; }
/** * list users * * @param resource the SQL result * @return array of ($nick_name => $more) * * @see layouts/layout.php **/ function layout($result) { global $context; // we return an array of ($nick_name => $more) $items = array(); // empty list if (!SQL::count($result)) { return $items; } // process all items in the list while ($item = SQL::fetch($result)) { // unique identifier $key = $item['nick_name']; // use the full name, if nick name is not part of it $more = ''; if ($item['full_name'] && !preg_match('/\\b' . preg_quote($item['nick_name'], '/') . '\\b/', $item['full_name'])) { $more = ucfirst($item['full_name']) . ' '; } // else use e-mail address, if any --but only to authenticated surfer if ($item['email'] && Surfer::is_logged()) { if ($more) { $more .= '<' . $item['email'] . '>'; } else { $more .= $item['email']; } } elseif ($item['introduction']) { $more .= $item['introduction']; } // record this item $items[$key] = $more; } // end of processing SQL::free($result); return $items; }
/** * list images * * @param resource the SQL result * @return string the rendered text * * @see layouts/layout.php **/ function layout($result) { global $context; // empty list if (!SQL::count($result)) { $output = array(); return $output; } // we return an array of ($url => $attributes) $items = array(); // process all items in the list while ($item = SQL::fetch($result)) { // url to view the image $url = Images::get_url($item['id']); // initialize variables $prefix = $suffix = ''; // flag new images if ($item['edit_date'] >= $context['fresh']) { $suffix .= NEW_FLAG; } // image title or image name $label = Skin::strip($item['title'], 10); if (!$label) { $name_as_title = TRUE; $label = ucfirst($item['image_name']); } $label = str_replace('_', ' ', str_replace('%20', ' ', $label)); // list all components for this item $items[$url] = array($prefix, $label, $suffix, 'basic', NULL); } // end of processing SQL::free($result); return $items; }
/** * list sections * * @param resource the SQL result * @return an array of $url => (NULL, $title, NULL, 'section_123', NULL, 'visit this section') * * @see layouts/layout.php **/ function layout($result) { global $context; // empty list if (!SQL::count($result)) { $output = array(); return $output; } // no hovering label $href_title = ''; // we return an array of ($url => $attributes) $items = array(); // process all items in the list while ($item = SQL::fetch($result)) { // the url to view this item $url = Sections::get_permalink($item); // initialize variables $prefix = $suffix = ''; // list all components for this item $items[$url] = array($prefix, ucfirst(Skin::strip($item['index_title'], 30)), $suffix, 'section_' . $item['id'], NULL, $href_title); } // end of processing SQL::free($result); return $items; }
/** * list links * * @param resource the SQL result * @return array of resulting items, or NULL * * @see layouts/layout.php **/ function layout($result) { global $context; // we return an array of ($url => $attributes) $items = array(); // empty list if (!SQL::count($result)) { return $items; } // process all items in the list while ($item = SQL::fetch($result)) { // url is the link itself $url = $item['link_url']; // initialize variables $prefix = $suffix = ''; // flag links that are dead, or created or updated very recently if ($item['edit_date'] >= $context['fresh']) { $suffix .= NEW_FLAG; } // make a label $label = Links::clean($item['title'], $item['link_url'], 30); // list all components for this item $items[$url] = array($prefix, $label, $suffix, 'basic', NULL); } // end of processing SQL::free($result); return $items; }
/** * list links * * @param resource the SQL result * @return array of resulting items, or NULL * * @see layouts/layout.php **/ function layout($result) { global $context; // we return an array of ($url => $attributes) $items = array(); // empty list if (!SQL::count($result)) { return $items; } // process all items in the list while ($item = SQL::fetch($result)) { // get the main anchor $anchor = Anchors::get($item['anchor']); // url is the link itself -- hack for xhtml compliance $url = str_replace('&', '&', $item['link_url']); // initialize variables $prefix = $suffix = ''; // flag links that are dead, or created or updated very recently if ($item['edit_date'] >= $context['fresh']) { $suffix = NEW_FLAG; } // make a label $label = Links::clean($item['title'], $item['link_url']); // the main anchor link if (is_object($anchor)) { $suffix .= ' - <span class="details">' . sprintf(i18n::s('in %s'), Skin::build_link($anchor->get_url(), ucfirst($anchor->get_title()))) . '</span>'; } // list all components for this item $items[$url] = array($prefix, $label, $suffix, 'basic', NULL); } // end of processing SQL::free($result); return $items; }
/** * list users * * @param resource the SQL result * @return string the rendered text * * @see layouts/layout.php **/ function layout($result) { global $context; // empty list if (!SQL::count($result)) { $output = array(); return $output; } // we return an array of ($url => $attributes) $items = array(); // process all items in the list while ($item = SQL::fetch($result)) { // we need some address if (!$item['email']) { continue; } // do not write to myself // if($item['id'] == Surfer::get_id()) // continue; $label = ucfirst(trim(Codes::beautify(strip_tags($item['full_name'], '<br><div><img><p><span>')))); if (!$label) { $label = ucfirst($item['nick_name']); } // one entry per address $items[trim($item['email'])] = $label; } // end of processing SQL::free($result); return $items; }
/** * list users * * @param resource the SQL result * @return string the rendered text * * @see layouts/layout.php **/ function layout($result) { global $context; // we return some text $text = ''; // empty list if (!($delta = SQL::count($result))) { return $text; } // flag idle users $idle = gmstrftime('%Y-%m-%d %H:%M:%S', time() - 600); // process all items in the list $count = 0; $items = array(); while ($item = SQL::fetch($result)) { // url to view the user $url = Users::get_permalink($item); // initialize variables $prefix = $suffix = ''; // signal restricted and private users if (isset($item['active']) && $item['active'] == 'N') { $prefix .= PRIVATE_FLAG; } elseif (isset($item['active']) && $item['active'] == 'R') { $prefix .= RESTRICTED_FLAG; } // signal locked profiles if (isset($item['capability']) && $item['capability'] == '?') { $prefix .= EXPIRED_FLAG; } // item title if (isset($item['full_name']) && $item['full_name']) { $label = ucfirst(Skin::strip($item['full_name'], 10)); $hover = $item['nick_name']; } else { $label = ucfirst(Skin::strip($item['nick_name'], 10)); $hover = $item['full_name']; } // flag idle users if (!isset($item['click_date']) || $item['click_date'] < $idle) { $class = 'idle user'; } else { $class = 'user'; } // list all components for this item $items[$url] = array($prefix, $label, $suffix, $class, NULL, $hover); // provide only some results if (++$count >= 5) { break; } } // end of processing SQL::free($result); // turn this to some text $text = Skin::build_list($items, 'comma'); // some indications on the number of connections if ($delta -= $count) { $text .= ', ...'; } return $text; }
/** * list tables * * Recognize following variants: * - 'no_anchor' to list items attached to one particular anchor * * @param resource the SQL result * @return string the rendered text * * @see layouts/layout.php **/ function layout($result) { global $context; // we return an array of ($url => $attributes) $items = array(); // empty list if (!SQL::count($result)) { return $items; } // process all items in the list while ($item = SQL::fetch($result)) { // initialize variables $prefix = $suffix = $icon = ''; // the url to view this item $url = Tables::get_url($item['id']); // flag tables created or updated very recently if ($item['create_date'] >= $context['fresh']) { $suffix .= NEW_FLAG; } elseif ($item['edit_date'] >= $context['fresh']) { $suffix .= UPDATED_FLAG; } $label = Skin::strip($item['title'], 10); // list all components for this item $items[$url] = array($prefix, $label, $suffix, 'table', $icon); } // end of processing SQL::free($result); return $items; }
/** * list versions * * @param resource the SQL result * @return string the rendered text * * @see layouts/layout.php **/ function layout($result) { global $context; // empty list if (!SQL::count($result)) { $output = array(); return $output; } // we return an array of ($url => $attributes) $items = array(); // process all items in the list while ($item = SQL::fetch($result)) { // initialize variables $prefix = $suffix = $icon = ''; // the url to view this item $url = '_' . $item['id']; // Versions::get_url($item['id']); // version description $label = sprintf(i18n::s('edited by %s %s'), ucfirst($item['edit_name']), Skin::build_date($item['edit_date'])); // command to view this version $suffix .= ' ' . Skin::build_link(Versions::get_url($item['id'], 'view'), i18n::s('compare to current version'), 'button'); // list all components for this item $items[$url] = array($prefix, $label, $suffix, 'version', $icon); } // end of processing SQL::free($result); return $items; }
/** * list servers * * @param resource the SQL result * @return string the rendered text * * @see layouts/layout.php **/ function layout($result) { global $context; // empty list if (!SQL::count($result)) { $output = array(); return $output; } // we return an array of ($url => $attributes) $items = array(); // process all items in the list while ($item = SQL::fetch($result)) { // initialize variables $prefix = $suffix = $icon = ''; // the url to view this item $url = Servers::get_url($item['id']); // use the title as a label $label = Skin::strip($item['title'], 10); // list all components for this item $items[$url] = array($prefix, $label, $suffix, 'server', $icon); } // end of processing SQL::free($result); return $items; }
function TreeSearch($searches, $classes, $language_id = 0) { global $site; $this->classes = (array) $classes; foreach ($this->classes as $i => $class) { $this->classes[$i] = "'" . mysql_real_escape_string($class) . "'"; } $sql = 'select tyyp_id from tyyp where klass in (' . implode(',', $this->classes) . ');'; $result = new SQL($sql); $this->classes = array(); while ($row = $result->fetch('ASSOC')) { $this->classes[] = $row['tyyp_id']; } $where = 'tyyp_id in (' . implode(',', $this->classes) . ') and keel = ' . mysql_real_escape_string($language_id) . ' '; foreach ($searches as $field => $keyword) { $where .= ' and ' . mysql_real_escape_string($field); if ($field == 'objekt_id' || $field == 'ttyyp_id' || $field == 'page_tyyp_id' || $field == 'kesk') { $where .= ' = ' . (int) $keyword; } else { $where .= " like '%" . mysql_real_escape_string($keyword) . "%' "; } } $sql = 'select objekt_id from objekt where ' . $where . ';'; //printr($sql); $result = new SQL($sql); while ($row = $result->fetch('ASSOC')) { $this->found_object_ids[] = $row['objekt_id']; } }
/** * list articles * * @param resource the SQL result * @return string the rendered text * * @see layouts/layout.php **/ function layout($result) { global $context; // we return some text $text = ''; // empty list if (!SQL::count($result)) { return $text; } // clear flows $text .= '<br style="clear: left" />'; // process all items in the list while ($item = SQL::fetch($result)) { // get the related overlay $overlay = Overlay::load($item, 'article:' . $item['id']); // the url to view this item $url = Articles::get_permalink($item); // use the title to label the link if (is_object($overlay)) { $title = Codes::beautify_title($overlay->get_text('title', $item)); } else { $title = Codes::beautify_title($item['title']); } // the hovering title if ($item['introduction'] && $context['skins_with_details'] == 'Y') { $hover = strip_tags(Codes::beautify_introduction($item['introduction'])); } else { $hover = i18n::s('View the page'); } // title is a link to the target article $title =& Skin::build_link($url, $title, 'basic', $hover); // use the thumbnail for this article if ($icon = trim($item['thumbnail_url'])) { // fix relative path if (!preg_match('/^(\\/|http:|https:|ftp:)/', $icon)) { $icon = $context['url_to_root'] . $icon; } // use parameter of the control panel for this one $options = ''; if (isset($context['classes_for_thumbnail_images'])) { $options = 'class="' . $context['classes_for_thumbnail_images'] . '" '; } // build the complete HTML element $icon = '<img src="' . $icon . '" alt="" title="' . encode_field($hover) . '" ' . $options . ' />'; // use default icon if nothing to display } else { $icon = MAP_IMG; } // use the image as a link to the target page $icon =& Skin::build_link($url, $icon, 'basic', $hover); // add a floating box $text .= Skin::build_box($title, $icon, 'floating'); } // clear flows $text .= '<br style="clear: left" />'; // end of processing SQL::free($result); return $text; }
/** * list categories * * @param resource the SQL result * @return string the rendered text * * @see layouts/layout.php **/ function layout($result) { global $context; // empty list if (!SQL::count($result)) { $output = array(); return $output; } // process all items in the list $items = array(); $total = 0; $minimum = 10000; $maximum = 0; while ($item = SQL::fetch($result)) { // this will be sorted alphabetically $items[$item['title']] = array('importance' => (int) $item['importance'], 'href' => Categories::get_permalink($item)); // assess the scope if ($minimum > (int) $item['importance']) { $minimum = (int) $item['importance']; } if ($maximum < (int) $item['importance']) { $maximum = (int) $item['importance']; } } // end of processing SQL::free($result); // sort the array alphabetically ksort($items); // scale items $text = ''; foreach ($items as $title => $item) { switch ((string) ceil((1 + $item['importance'] - $minimum) * 6 / (1 + $maximum - $minimum))) { default: case 1: $item['style'] = 'font-size: 0.8em'; break; case 2: $item['style'] = 'font-size: 0.9em'; break; case 3: $item['style'] = 'font-size: 1.3em'; break; case 4: $item['style'] = 'font-size: 1.5em'; break; case 5: $item['style'] = 'font-size: 1.7em'; break; case 6: $item['style'] = 'font-size: 2em'; break; } $text .= '<span style="' . $item['style'] . '">' . Skin::build_link($item['href'], $title, 'basic') . '</span> '; } // final packaging $text = '<p class="cloud">' . rtrim($text) . '</p>'; // return by reference return $text; }
/** * list images * * @param resource the SQL result * @return string the rendered text * * @see layouts/layout.php **/ function layout($result) { global $context; // empty list if (!SQL::count($result)) { $output = array(); return $output; } // we return an array of ($url => $attributes) $items = array(); // process all items in the list while ($item = SQL::fetch($result)) { // get the anchor for this image if ($item['anchor']) { $anchor = Anchors::get($item['anchor']); } // url to view the image $url = $context['url_to_home'] . $context['url_to_root'] . Images::get_url($item['id']); // time of last update $time = SQL::strtotime($item['edit_date']); // the title as the label if ($item['title']) { $label = ucfirst($item['title']) . ' (' . $item['image_name'] . ')'; } else { $label = $item['image_name']; } // the section $section = ''; if (is_object($anchor)) { $section = ucfirst($anchor->get_title()); } // the author(s) is an e-mail address, according to rss 2.0 spec $author = $item['create_address'] . ' (' . $item['create_name'] . ')'; if ($item['create_address'] != $item['edit_address']) { if ($author) { $author .= ', '; } $author .= $item['edit_address'] . ' (' . $item['edit_name'] . ')'; } // the description $description = Codes::beautify($item['description']); // cap the number of words $description = Skin::cap($description, 300); // fix image references $description = preg_replace('#"/([^">]+?)"#', '"' . $context['url_to_home'] . '/$1"', $description); $introduction = $description; // other rss fields $extensions = array(); // url for enclosure $type = Files::get_mime_type($item['image_name']); $extensions[] = '<enclosure url="' . $context['url_to_home'] . $context['url_to_root'] . Files::get_path($item['anchor'], 'images') . '/' . $item['image_name'] . '"' . ' length="' . $item['image_size'] . '"' . ' type="' . $type . '" />'; // list all components for this item $items[$url] = array($time, $label, $author, $section, NULL, $introduction, $description, $extensions); } // end of processing SQL::free($result); return $items; }
function smarty_function_init_folders($params, &$smarty) { global $site, $leht, $class_path; include_once $class_path . 'adminpage.inc.php'; ############## # default values extract($params); if (!isset($name)) { $name = 'folders'; } if (!isset($parent) && !isset($parent_dir)) { # default parent for file (folder "public/"): get folder ID of "public/" $sql = $site->db->prepare("SELECT objekt_id, relative_path FROM obj_folder WHERE relative_path = ? LIMIT 1", $site->CONF['file_path']); $sth = new SQL($sql); $folder = $sth->fetch(); $parent_dir = $folder['relative_path']; $parent = $folder['objekt_id']; } elseif (isset($parent)) { # get parent folder info $parent = (int) $parent; if ($parent) { $sql = $site->db->prepare("SELECT objekt_id, relative_path FROM obj_folder WHERE objekt_id = ?", $parent); $sth = new SQL($sql); } else { return; } } elseif (isset($parent_dir)) { $parent_dir = preg_replace('#^/#', '', $parent_dir); $parent_dir = preg_replace('#/$#', '', $parent_dir); $sql = $site->db->prepare("SELECT objekt_id, relative_path FROM obj_folder WHERE relative_path = ? LIMIT 1", '/' . $parent_dir); $sth = new SQL($sql); if ($sth->rows == 1) { $folder = $sth->fetch(); $parent_dir = $folder['relative_path']; $parent = $folder['objekt_id']; } } else { return; } $folders = array(); $folders_from_fm = get_subfolders($parent); foreach ($folders_from_fm as $folder) { $obj = new stdClass(); # Bug #2318 $obj->title = $folder['title']; $obj->path = $folder['relative_path']; $obj->id = $folder['objekt_id']; # current folder ID $obj->parent_id = $folder['parent_id']; ## parent folder ID?? $obj->fullpath = $site->absolute_path . $folder['relative_path']; # absolute path of the folder $obj->file_count = $folder['file_count']; $folders[] = $obj; } $smarty->assign($name, $folders); return; }
/** * list servers * * @param resource the SQL result * @return string the rendered text * * @see layouts/layout.php **/ function layout($result) { global $context; // empty list if (!SQL::count($result)) { $output = array(); return $output; } // we return an array of ($url => $attributes) $items = array(); // process all items in the list while ($item = SQL::fetch($result)) { // initialize variables $prefix = $suffix = $icon = ''; // the url to view this item $url = Servers::get_url($item['id']); // use the title as a label $label = Skin::strip($item['title'], 10); // flag files uploaded recently if ($item['edit_date'] >= $context['fresh']) { $prefix = NEW_FLAG . $prefix; } // description if ($item['description']) { $suffix .= ' ' . ucfirst(trim($item['description'])); } // the menu bar for associates and poster if (Surfer::is_empowered() || Surfer::is($item['edit_id'])) { $menu = array(Servers::get_url($item['id'], 'edit') => i18n::s('Edit'), Servers::get_url($item['id'], 'delete') => i18n::s('Delete')); $suffix .= ' ' . Skin::build_list($menu, 'menu'); } // add a separator if ($suffix) { $suffix = ' - ' . $suffix; } // append details to the suffix $suffix .= BR . '<span class="details">'; // details $details = array(); // item poster if ($item['edit_name']) { $details[] = sprintf(i18n::s('edited by %s %s'), Users::get_link($item['edit_name'], $item['edit_address'], $item['edit_id']), Skin::build_date($item['edit_date'])); } // the edition date $details[] = Skin::build_date($item['edit_date']); // all details if (count($details)) { $suffix .= ucfirst(implode(', ', $details)) . "\n"; } // end of details $suffix .= '</span>'; // list all components for this item $items[$url] = array($prefix, $label, $suffix, 'server', $icon); } // end of processing SQL::free($result); return $items; }
/** * list comments as successive notes in a thread * * @param resource the SQL result * @return string the rendered text **/ function layout($result) { global $context; // we return formatted text $text = ''; // empty list if (!SQL::count($result)) { return $text; } // build a list of comments while ($item = SQL::fetch($result)) { // automatic notification if ($item['type'] == 'notification') { $text = '<dd class="thread_other" style="font-style: italic;">' . ucfirst(trim($item['description'])) . '</dd>' . $text; } else { // link to user profile -- open links in separate window to enable side browsing of participant profiles if ($item['create_id']) { if ($user = Users::get($item['create_id']) && $user['full_name']) { $hover = $user['full_name']; } else { $hover = NULL; } $author = Users::get_link($item['create_name'], $item['create_address'], $item['create_id'], TRUE, $hover); } else { $author = Users::get_link($item['edit_name'], $item['edit_address'], $item['edit_id'], TRUE); } // differentiate my posts from others if (Surfer::get_id() && $item['create_id'] == Surfer::get_id()) { $style = ' class="thread_me"'; } else { $style = ' class="thread_other"'; } // a clickable label $stamp = '#'; // flag old items on same day if (!strncmp($item['edit_date'], gmstrftime('%Y-%m-%d %H:%M:%S', time()), 10)) { $stamp = Skin::build_time($item['edit_date']); } else { $stamp = Skin::build_date($item['edit_date']); } // append this at the end of the comment $stamp = ' <div style="float: right; font-size: x-small">' . Skin::build_link(Comments::get_url($item['id']), $stamp, 'basic', i18n::s('Edit')) . '</div>'; // package everything --change order to get oldest first $text = '<dt' . $style . '>' . $author . '</dt><dd' . $style . '>' . $stamp . ucfirst(trim($item['description'])) . '</dd>' . $text; } } // end of processing SQL::free($result); // finalize the returned definition list if ($text) { $text = '<dl>' . $text . '</dl>'; } // process yacs codes $text = Codes::beautify($text); return $text; }
/** * This source file is is part of Saurus CMS content management software. * It is licensed under MPL 1.1 (http://www.opensource.org/licenses/mozilla1.1.php). * Copyright (C) 2000-2010 Saurused Ltd (http://www.saurus.info/). * Redistribution of this file must retain the above copyright notice. * * Please note that the original authors never thought this would turn out * such a great piece of software when the work started using Perl in year 2000. * Due to organic growth, you may find parts of the software being * a bit (well maybe more than a bit) old fashioned and here's where you can help. * Good luck and keep your open source minds open! * * @package SaurusCMS * @copyright 2000-2010 Saurused Ltd (http://www.saurus.info/) * @license Mozilla Public License 1.1 (http://www.opensource.org/licenses/mozilla1.1.php) * */ function smarty_function_save_mailinglist($params, &$smarty) { global $site; extract($params); $user_id = (int) $user; if (!$user_id) { $user_id = $site->user->user_id; } ################### # salvestame mailinglistide valik # muide, kui kasutaja e-mail salvestati tühjana, siis ei lisata ka ühtegi meili-listi ja kustutatakse vanadki if ($user_id) { // get user data $sql = $site->db->prepare('select * from users where user_id = ?', $user_id); $result = new SQL($sql); $user_data = $result->fetch('ASSOC'); ################### # salvestame mailinglistide valik # ja lisada uued mailinglistid ################### # kustutada vanad mailinglistid $sql = $site->db->prepare("SELECT user_mailinglist.objekt_id FROM user_mailinglist LEFT JOIN objekt ON user_mailinglist.objekt_id = objekt.objekt_id WHERE user_mailinglist.user_id = ? AND objekt.keel=?", $user_id, $site->keel); $sth = new SQL($sql); $site->debug->msg($sth->debug->get_msgs()); $del_obj = array(); while ($del_obj_id = $sth->fetchsingle()) { $del_obj[] = $del_obj_id; } $sql = $site->db->prepare("DELETE FROM user_mailinglist WHERE user_id=? AND FIND_IN_SET(objekt_id,?)", $user_id, join(",", $del_obj)); $sth = new SQL($sql); $site->debug->msg($sth->debug->get_msgs()); # ja lisada uued (NB! aga ainult siis kui kasutaja e-mail ei ole tühi) if (trim($site->user->all['email'] != '') && is_array($fields)) { # rubrigide ID kontroll # kas on seal meilinglist, kas on rubriik avaldatud $sql = $site->db->prepare("SELECT obj_rubriik.objekt_id FROM obj_rubriik,objekt WHERE obj_rubriik.objekt_id=objekt.objekt_id AND objekt.on_avaldatud='1' AND obj_rubriik.on_meilinglist = '1' AND find_in_set(obj_rubriik.objekt_id, ?)", join(",", $fields)); $sth = new SQL($sql); $site->debug->msg($sth->debug->get_msgs()); $values = array(); while ($objekt_id = $sth->fetchsingle()) { $values[] = $site->db->prepare("(?,?)", $user_id, $objekt_id); } if (sizeof($values)) { $sql = "INSERT INTO user_mailinglist (user_id, objekt_id) VALUES " . join(",", $values); $sth = new SQL($sql); $site->debug->msg($sth->debug->get_msgs()); } } # if mõni meilinglist oli chekitud } # kui kasutaja lisati edukalt # / salvestame mailinglistide valik ################### }
/** * list dates * * @param resource the SQL result * @return string the rendered text * * @see layouts/layout.php **/ function layout($result) { global $context; // build the calendar $text = 'BEGIN:VCALENDAR' . CRLF . 'VERSION:2.0' . CRLF . 'PRODID:YACS' . CRLF . 'METHOD:PUBLISH' . CRLF; // organization, if any if (isset($context['site_name']) && $context['site_name']) { $text .= 'X-WR-CALNAME:' . $context['site_name'] . CRLF; } // process all items in the list while ($item = SQL::fetch($result)) { // one event at a time $text .= 'BEGIN:VEVENT' . CRLF; // the event spans limited time if (isset($item['duration']) && $item['duration']) { $text .= 'DTSTART:' . gmdate('Ymd\\THis\\Z', SQL::strtotime($item['date_stamp'])) . CRLF; $text .= 'DTEND:' . gmdate('Ymd\\THis\\Z', SQL::strtotime($item['date_stamp']) + $item['duration'] * 60) . CRLF; // a full-day event } else { $text .= 'DTSTART;VALUE=DATE:' . date('Ymd', SQL::strtotime($item['date_stamp'])) . CRLF; $text .= 'DTEND;VALUE=DATE:' . date('Ymd', SQL::strtotime($item['date_stamp']) + 86400) . CRLF; } // url to view the date $text .= 'URL:' . Articles::get_permalink($item) . CRLF; // organization, if any if (isset($item['introduction']) && $item['introduction']) { $text .= 'DESCRIPTION:' . str_replace(array("\n", "\r"), ' ', strip_tags($item['introduction'])) . CRLF; } // build a valid title if (isset($item['title']) && $item['title']) { $text .= 'SUMMARY:' . Codes::beautify_title($item['title']) . CRLF; } // required by Outlook 2003 if (isset($item['id']) && $item['id']) { $text .= 'UID:' . $item['id'] . CRLF; } // date of creation if (isset($item['create_date']) && $item['create_date']) { $text .= 'CREATED:' . gmdate('Ymd\\THis\\Z', SQL::strtotime($item['create_date'])) . CRLF; } // date of last modification if (isset($item['edit_date']) && $item['edit_date']) { $text .= 'DTSTAMP:' . gmdate('Ymd\\THis\\Z', SQL::strtotime($item['edit_date'])) . CRLF; } // next event $text .= 'SEQUENCE:0' . CRLF . 'END:VEVENT' . CRLF; } // date of last update $text .= 'END:VCALENDAR' . CRLF; // end of processing SQL::free($result); return $text; }
/** * list profiles * * @param int the offset from the start of the list; usually, 0 or 1 - default is 0 * @param int the number of items to display - default is 10 */ public static function list_by_hits($offset = 0, $count = 10) { global $context; // the list of profiles $query = "SELECT * FROM " . SQL::table_name('profiles') . " " . "ORDER BY total_hits DESC LIMIT " . $offset . ', ' . $count; if ($result = SQL::query($query)) { while ($row = SQL::fetch($result)) { $rows[] = array('left=' . $row['url'], 'left=' . $row['total_hits'], 'left=' . round($row['total_time'] / $row['total_hits'], 3), 'left=' . $row['minimum_time'], 'left=' . $row['maximum_time'], 'left=' . $row['total_time']); } } return $rows; }
/** * list files * * @param resource the SQL result * @return array of resulting items, or NULL * * @see layouts/layout.php **/ function layout($result) { global $context; // we return an array of ($url => $attributes) $items = array(); // empty list if (!SQL::count($result)) { return $items; } // sanity check if (!isset($this->layout_variant)) { $this->layout_variant = 'full'; } // process all items in the list while ($item = SQL::fetch($result)) { // get the main anchor $anchor = Anchors::get($item['anchor']); // download the file directly $url = Files::get_url($item['id'], 'fetch', $item['file_name']); // initialize variables $prefix = $suffix = ''; // flag files that are dead, or created or updated very recently if ($item['create_date'] >= $context['fresh']) { $suffix .= NEW_FLAG; } elseif ($item['edit_date'] >= $context['fresh']) { $suffix .= UPDATED_FLAG; } // signal restricted and private files if ($item['active'] == 'N') { $prefix .= PRIVATE_FLAG; } elseif ($item['active'] == 'R') { $prefix .= RESTRICTED_FLAG; } // file title or file name $label = Codes::beautify_title($item['title']); if (!$label) { $label = ucfirst(str_replace(array('%20', '-', '_'), ' ', $item['file_name'])); } // the main anchor link, except on user profiles if (is_object($anchor) && $anchor->get_reference() != $this->focus) { $suffix .= ' - <span class="details">' . sprintf(i18n::s('in %s'), Skin::build_link($anchor->get_url(), ucfirst($anchor->get_title()))) . '</span>'; } // list all components for this item $items[$url] = array($prefix, $label, $suffix, 'basic', NULL); } // end of processing SQL::free($result); return $items; }
/** * list links * * @param resource the SQL result * @return array of resulting items, or NULL * * @see layouts/layout.php **/ function layout($result) { global $context; // we return an array of ($url => $attributes) $items = array(); // empty list if (!SQL::count($result)) { return $items; } // process all items in the list while ($item = SQL::fetch($result)) { // get the anchor for this link if ($item['anchor']) { $anchor = Anchors::get($item['anchor']); } // url is the link itself $url = $item['link_url']; // time of last update $time = SQL::strtotime($item['edit_date']); // the title as the label if ($item['title']) { $label = $item['title']; } else { $label = $url; } // the section $section = ''; if (is_object($anchor)) { $section = ucfirst($anchor->get_title()); } // the author(s) is an e-mail address, according to rss 2.0 spec $author = $item['edit_address'] . ' (' . $item['edit_name'] . ')'; // the description $description = Codes::beautify($item['description']); // cap the number of words $description = Skin::cap($description, 300); // fix image references $description = preg_replace('#"/([^">]+?)"#', '"' . $context['url_to_home'] . '/$1"', $description); $introduction = $description; // other rss fields $extensions = array(); // list all components for this item $items[$url] = array($time, $label, $author, $section, NULL, $introduction, $description, $extensions); } // end of processing SQL::free($result); return $items; }
/** * list dates * * @param resource the SQL result * @return string the rendered text * * @see layouts/layout.php **/ function layout($result) { global $context; // we return an array of ($url => $attributes) $items = array(); // empty list if (!SQL::count($result)) { return $items; } // process all items in the list while ($item = SQL::fetch($result)) { // the url to use $url = Articles::get_permalink($item); // initialize variables $prefix = $suffix = $icon = ''; // signal restricted and private dates/articles if (!isset($item['publish_date']) || $item['publish_date'] <= NULL_DATE) { $prefix .= DRAFT_FLAG; } // signal restricted and private dates/articles if (!isset($item['active'])) { } elseif ($item['active'] == 'N') { $prefix .= PRIVATE_FLAG; } elseif ($item['active'] == 'R') { $prefix .= RESTRICTED_FLAG; } // flag new dates/articles if ($item['edit_date'] >= $context['fresh']) { $suffix .= NEW_FLAG; } // build a valid label if (isset($item['title'])) { $label = Codes::beautify_title($item['title']); if (isset($item['date_stamp'])) { $label .= ' [' . Skin::build_date($item['date_stamp'], 'day') . ']'; } } else { $label = Skin::build_date($item['date_stamp'], 'day'); } // may have variant overlay for links $link_type = $this->has_variant('overlaid') ? 'overlaid' : 'basic'; // list all components for this item $items[$url] = array($prefix, $label, $suffix, $link_type, NULL, $item['date_stamp']); } // end of processing SQL::free($result); return $items; }
/** * list sections * * @param resource the SQL result * @return string the rendered text * * @see layouts/layout.php **/ function layout($result) { global $context; // empty list if (!SQL::count($result)) { $output = array(); return $output; } // sanity check if (!isset($this->layout_variant)) { $this->layout_variant = 'articles/edit.php?anchor=section:'; } // we return some text $text = ''; // stack of items $items = array(); // process all items in the list include_once $context['path_to_root'] . 'comments/comments.php'; include_once $context['path_to_root'] . 'links/links.php'; $family = ''; while ($item = SQL::fetch($result)) { // strip locked sections, except to associates and editors if (isset($item['locked']) && $item['locked'] == 'Y' && !Surfer::is_empowered()) { continue; } // change the family if ($item['family'] != $family) { // flush current stack, if any if (count($items)) { $text .= Skin::build_list($items, '2-columns'); } $items = array(); // show the family $family = $item['family']; $text .= '<h3 class="family">' . $family . '</h3>' . "\n"; } // format one item $items = array_merge($items, $this->one($item)); } // flush the stack if (count($items)) { $text .= Skin::build_list($items, '2-columns'); } // end of processing SQL::free($result); return $text; }
function check_compability_444() { global $called_from_another_script, $class_path, $site; $errors = array(); ########################## # otsi SAPI malle, mille moodulid on kas aktiivsed v�i mis pole seotud mooduliga �ldse $sql = $site->db->prepare("SELECT templ_tyyp.ttyyp_id,templ_tyyp.nimi,templ_tyyp.templ_fail\n\t\tFROM templ_tyyp\n\t\tWHERE \n\t\t\ttempl_tyyp.ttyyp_id >= 1000 AND templ_tyyp.ttyyp_id < 2000 \n\t\tORDER BY templ_tyyp.nimi"); $sth = new SQL($sql); while ($tpl = $sth->fetch()) { $data = ''; $file_path = $class_path . 'smarty/templates/' . $tpl['templ_fail']; if (file_exists($file_path) && ($fp = fopen($file_path, 'r'))) { while (!feof($fp)) { $data .= fgets($fp, 4096); } fclose($fp); // get all smarty tags content if (preg_match_all("/\\{\\s*(.*?)\\s*\\}/", $data, $matches)) { foreach ($matches[1] as $match) { if (preg_match("/position(\\s*)=(\\s*)(\"|'?)(\\s*)([\\d,]*)(?<=(\\s|,|=|\"|'))[9|5]{1}(?!(\\d))/", $match)) { $errors[] = 'Warning: Found Saurus API code with position=9 or position=5 in template "<b>' . $tpl['nimi'] . '</b>".'; } } } if (preg_match("/asukoht(\"|')(\\s*)=>(\\s*)(\"|'?)(\\s*)([\\d,]*)(?<=(\\s|,|=|\"|'))[9|5]{1}(?!(\\d))/", $data) && !in_array('Warning: Found Saurus API code with position=9 or position=5 in template "<b>' . $tpl['nimi'] . '</b>".', $errors)) { $errors[] = 'Warning: Found Saurus API code with position=9 or position=5 template "<b>' . $tpl['nimi'] . '</b>".'; } } # fopen OK } # while tpl if (count($errors)) { $errors[] = 'Warning: Sections\' default positions are re-designed and may cause backwards compability issues because because 4.4.4 version update converts position values 9 and 5 to 0. The converted object ID\'s will be logged in the Site log after the update is completed.'; } ############### PRINT WARNINGS if (sizeof($errors) > 0) { echo '<font color=red>'; print join('<br>', $errors); echo '<br><br><b>NB! If any of these templates are in active use on the website, please cancel the version update process and contact your site developer for further instructions.</b>'; echo '</font>'; echo '<br><br>'; } else { if (!$called_from_another_script) { echo "Compability check passed OK. Sleep peacefully.<br><br>"; } } }
/** * list users * * @param resource the SQL result * @return array a bare list of item ids * * @see layouts/layout.php **/ function layout($result) { global $context; // we return an array of ids $items = array(); // empty list if (!SQL::count($result)) { return $items; } // process all items in the list while ($item = SQL::fetch($result)) { // just remember the id $items[] = $item['id']; } // end of processing SQL::free($result); return $items; }
/** * list files * * @param resource the SQL result * @return array of resulting items, or NULL * * @see layouts/layout.php **/ function layout($result) { global $context; // we return an array of ($url => $attributes) $items = array(); // empty list if (!SQL::count($result)) { return $items; } // process all items in the list while ($item = SQL::fetch($result)) { // include all available attributes for this item $items[$item['id']] = $item; } // end of processing SQL::free($result); return $items; }