Пример #1
0
 public static function handle($select, $sql, $rsnum)
 {
     if (empty(self::$num)) {
         self::$num = CORE::$cfg["item_num"];
     }
     if (!empty($rsnum) && $rsnum > self::$num) {
         $offset = 0;
         list($offset, $oldNum) = explode(',', $select['limit']);
         self::$all = ceil($rsnum / self::$num);
         # 總頁數
         if (empty(self::$now)) {
             self::$now = 1;
         }
         if (self::$now < 0 || self::$now > self::$all) {
             self::$now = 1;
         }
         self::$start = $limit_start = self::$num * self::$now - self::$num + $offset;
         # limit 開始資料列數
         $new_limit = $limit_start . "," . self::$num;
         # limit 組合完成
         $select['limit'] = $new_limit;
         $sql_page = DB::select($select);
         $page = array($sql_page, DB::num($sql_page));
         self::row();
     } else {
         self::$now = 1;
         $page = array($sql, $rsnum);
     }
     SESS::write('PAGE', self::$now);
     return $page;
 }
Пример #2
0
 private static function page_handle(array $uri_array)
 {
     $origin_args = $uri_array;
     $last_args = array_pop($uri_array);
     if (preg_match('/page-/', $last_args)) {
         PAGE::$now = preg_replace('/page-([0-9]+)/', "\$1", $last_args);
         # 載入頁次參數
         $return_args = $uri_array;
     } else {
         $return_args = $origin_args;
     }
     self::$uri = implode("/", $return_args);
     return $return_args;
 }
Пример #3
0
/**
 * widget for blog stuff
 *
 * @param array $vars variables
 *
 * @return html
 */
function Blog_widget2($vars = null)
{
    $c = '';
    global $PAGEDATA;
    $entry_ids = array();
    if ($vars->tag) {
        $rs = dbAll('select entry_id from blog_tags where tag="' . addslashes($vars->tag) . '"');
        foreach ($rs as $r) {
            $entry_ids[] = $r['entry_id'];
        }
    }
    $blog_author = '';
    $excerpts_offset = isset($vars->excerpts_offset) && $vars->excerpts_offset ? $vars->excerpts : 0;
    $excerpts_per_page = isset($vars->excerpts) && $vars->excerpts ? $vars->excerpts : 2;
    $links_prefix = $PAGEDATA->getRelativeURL();
    if ($PAGEDATA->type != 'blog|blog') {
        $page = PAGE::getInstanceByType('blog');
        $links_prefix = $page->getRelativeURL();
    }
    /** @noinspection PhpUnusedLocalVariableInspection */
    $excerpt_length = 100;
    /** @noinspection PhpUnusedLocalVariableInspection */
    $nobottomlinks = true;
    if (!isset($vars->widgetType)) {
        $vars->widgetType = '0';
    }
    switch ($vars->widgetType) {
        case '1':
            // { featured posts
            require dirname(__FILE__) . '/featured-posts.php';
            break;
            // }
        // }
        default:
            // {
            if (isset($vars->imageSizeX) && $vars->imageSizeX) {
                /** @noinspection PhpUnusedLocalVariableInspection */
                $excerptImageSizeX = (int) $vars->imageSizeX;
            }
            if (isset($vars->imageSizeY) && $vars->imageSizeY) {
                /** @noinspection PhpUnusedLocalVariableInspection */
                $excerptImageSizeY = (int) $vars->imageSizeY;
            }
            require dirname(__FILE__) . '/excerpts.php';
            break;
            //}
    }
    return $c;
}
Пример #4
0
<?php

include 'inc/pre.inc';
include 'inc/classes.inc';
include 'inc/mi_functions.inc';
$page = new PAGE('TuiT Demo');
include 'inc/lookandfeel.inc';
$page->add_to_head($style_in_head);
$page->set_top('Specialist dictionaries');
#@mysql_select_db('dict');
$dicts = array();
@($res = mysql_query("select * from dicts"));
while (@($row = mysql_fetch_array($res))) {
    $dicts[$row['d_id']] = $row['d_name'];
}
asort($dicts);
if (is_numeric($dict)) {
    $tab = new TABLE();
    if (!is_numeric($offset) or $offset < 0) {
        $offset = 0;
    }
    if (!is_numeric($limit) or $limit < 1) {
        $limit = 20;
    }
    @($res = mysql_query("select count(*) as cnt from vocab where v_d_id={$dict}"));
    @($row = mysql_fetch_array($res));
    $cnt = $row['cnt'];
    $tab->add_row(array(array('attr' => 'colspan=5', 'cont' => pnav($cnt, $offset, $limit, "?dict={$dict}&") . "<br><br>")));
    @($res = mysql_query("select * from vocab where v_d_id={$dict} order by v_english limit {$offset},{$limit}"));
    while (@($row = mysql_fetch_array($res))) {
        $tab->add_row(array($row['v_english'], "<i>" . $row['v_latin'] . "</i>", $row['v_czech'], $row['v_slovak'], $row['v_german']));
Пример #5
0
/*                                                                           */
/*                      version 0.2.1, september 2001                        */
/*                                                                           */
/* written from a scratch, resembles previous system now called version 0.1, */
/* which was perl-based with no external database support. version 0.2 is    */
/* entirely based on PHP and MySQL, except for a few soon-to-be-written      */
/* scripts for transplatation of v0.1 files..                                */
/*                                                                           */
/*****************************************************************************/
error_reporting(0);
#error_reporting(2047);
$inc_path = "inc";
include "{$inc_path}/pre.inc";
include "{$inc_path}/classes.inc";
include "{$inc_path}/base.inc";
$page = new PAGE('TuiT Demo');
include "{$inc_path}/lookandfeel.inc";
$page->add_to_head($style_in_head);
/*
   compare the contents of received cookie with database and if both
   are the same, then treat user as already logged. the IP is also compared
   for 'safety'..
   if we don't get a cookie or get '***' (which we send after logout),
   user can only see login and acct_request sections..
*/
if (isset($udata)) {
    $udata = array();
}
if (isset($bisquit) and strcmp($bisquit, "***")) {
    @($res = mysql_query("select id,login,name,email,send_note,admin from users where ip='{$REMOTE_ADDR}' and cookie='{$bisquit}'"));
    if (!@($udata = mysql_fetch_array($res))) {
Пример #6
0
 /**
  * Log in and store the user on the client.
  * Does not perform any password checking and replaces the login user stored
  * on the local client. Use this function only for a legitimate login. To
  * change the logged-in user when performing tasks, use {@link set_login()}.
  * To log in using a name and password, use {@link impersonate()}.
  * @param USER $user Log in as this user
  * @param boolean $remember Remember this login between sessions?
  */
 public function log_in($user, $remember)
 {
     if (isset($user) && !$user->is_allowed(Privilege_set_global, Privilege_login)) {
         $this->page->raise_security_violation('You are not allowed to log in.');
     }
     /** @var APPLICATION_STORAGE_OPTIONS $storage_options */
     $storage_options = $this->storage_options;
     $storage = $this->_get_login_storage();
     // user wants the password stored between sessions
     if ($remember) {
         $storage->expire_in_n_days($storage_options->login_duration);
     } else {
         $storage->expire_when_session_ends();
     }
     $storage->set_value($storage_options->login_user_name, $this->_encode_user($user));
     $this->set_login($user);
 }
Пример #7
0
 public static function dataFetch($tb_name, $sk = false, $fetch = false, $sort = false, $limit = false, $page = false)
 {
     list($sql, $rsnum, $select) = self::dataNum($tb_name, $sk, $fetch, $sort, $limit, true);
     if ($page) {
         if (is_numeric($page) && $page > 0) {
             PAGE::$num = $page;
         }
         list($sql, $rsnum) = PAGE::handle($select, $sql, $rsnum);
     }
     switch ($rsnum) {
         case 0:
             break;
         case 1:
             self::$data[0] = self::content_handle(DB::fetch($sql), true);
             break;
         default:
             while ($row = DB::fetch($sql)) {
                 $all_row[] = self::content_handle($row, true);
             }
             self::$data = $all_row;
             break;
     }
     return $rsnum;
 }
Пример #8
0
/**
 * show the image transition
 *
 * @param array $vars array of variables
 *
 * @return HTML of the widget
 */
function ImageTransition_show($vars)
{
    global $cdnprefix;
    if (!is_array($vars) && isset($vars->id) && $vars->id) {
        $r = Core_cacheLoad('image-transitions', 'id' . $vars->id);
        if ($r === false) {
            $r = dbRow('select * from image_transitions where id=' . $vars->id);
            Core_cacheSave('image-transitions', 'id' . $vars->id, $r);
        }
        if ($r && is_array($r)) {
            $width = (int) $r['width'];
            $height = (int) $r['height'];
            $imgs = array();
            $dir = USERBASE . '/f' . $r['directory'];
            if (!file_exists($dir) || !is_dir($dir)) {
                return '<!-- ' . $dir . ' -->';
            }
            $fs = new DirectoryIterator($dir);
            $max = array($width, $height);
            foreach ($fs as $f) {
                if ($f->isDot() || !preg_match('/\\.(jpg|.jpeg|png|gif)$/i', $f->getFilename())) {
                    continue;
                }
                list($iw, $ih) = getimagesize(USERBASE . '/f' . $r['directory'] . '/' . $f->getFilename());
                if (!$iw || !$ih) {
                    // not an image
                    continue;
                }
                if (!$width) {
                    // no size predefined
                    if ($iw > $max[0]) {
                        $max[0] = $iw;
                    }
                    if ($ih > $max[1]) {
                        $max[1] = $ih;
                    }
                }
                $imgs[] = $f->getFilename();
            }
            $width = $max[0];
            $height = $max[1];
            asort($imgs);
            if (!count($imgs)) {
                return '<em>' . __('No images in selected directory.') . '</em>';
            }
            $html = '';
            if ($r['trans_type'] == '3dCarousel') {
                $html .= '<div id="k3dCarousel' . $vars->id . '" style="height:' . ($height + 30) . 'px"><img style="display:none" src="' . $cdnprefix . '/a/f=getImg/w=' . $width . '/h=' . $height . $r['directory'] . '/' . join('" /><img style="display:none" src="' . $cdnprefix . '/a/f=getImg/w=' . $width . '/h=' . $height . $r['directory'] . '/', $imgs) . '" />';
                $html .= '</div>';
                WW_addScript('/ww.plugins/image-transition/frontend/k3dCarousel/' . 'jquery.k3dCarousel.js');
                WW_addInlineScript('$(window).load(function(){' . '$("#k3dCarousel' . $vars->id . '").k3dCarousel();' . '});');
            } else {
                if ($r['url']) {
                    $url = PAGE::getInstance($r['url'])->getRelativeUrl();
                    $html .= '<a href="' . $url . '"';
                } else {
                    $html .= '<div';
                }
                $html .= ' style="display:block;width:' . $width . 'px;height:' . $height . 'px;" id="image_transitions_' . $vars->id . '">' . '<div style="width:' . $width . 'px;height:' . $height . 'px;background:' . 'url(\'' . $cdnprefix . '/a/f=getImg/w=' . $width . '/h=' . $height . $r['directory'] . '/' . join('\') no-repeat center center">&nbsp;</div><div style="width:' . $width . 'px;height:' . $height . 'px;display:none;background:' . 'url(\'' . $cdnprefix . '/a/f=getImg/w=' . $width . '/h=' . $height . $r['directory'] . '/', $imgs) . '\') no-repeat center center">&nbsp;</div>';
                if ($r['url']) {
                    $html .= '</a>';
                } else {
                    $html .= '</div>';
                }
                WW_addScript('/j/jquery.cycle.all.js');
                WW_addInlineScript('$(window).load(function(){$("#image_transitions_' . $vars->id . '").cycle({fx:"' . $r['trans_type'] . '",speed:' . $r['pause'] . '})});');
            }
            return $html;
        }
    }
    return '<p>' . __('This Image Transition is not yet defined.') . '</p>';
}
Пример #9
0
<?php

error_reporting(0);
include 'inc/pre.inc';
include 'inc/classes.inc';
include 'inc/mi_functions.inc';
include 'ex_classes.inc';
define('MAX_EXPL_IN_LIST', 5);
$page = new PAGE('TuiT Demo');
include 'inc/lookandfeel.inc';
$page->add_to_head($style_in_head);
$page->set_top('Language exercises');
$page->add_to_middle("<form action=\"{$PHP_SELF}\" method=\"post\">\n");
function show_expls($nav_expl, $expls, $ex)
{
    $cont = '';
    reset($expls);
    while (list($k, $v) = each($expls)) {
        $nav_expl->add_item($v['ex_name'], "?section=exercise_display&exercise={$v['ex_id']}");
    }
    //$cont = "<h4>".$ex->parameters['ex_name']."</h4>";
    if ($nav_expl->how_many()) {
        if ($ex->parameters['ex_type'] == EXPLANATION) {
            $cont .= "Exercises: ";
        } else {
            $cont .= "Explanations: ";
        }
        $cont .= $nav_expl->prepare();
    }
    return $cont;
}
Пример #10
0
 /**
  * Called after an icon path has been changed.
  * This event is called if an alias registered with {@link add_icon_alias()}
  * is changed.
  * @param RESOURCE_MANAGER $resource_manager Affected resource manager.
  * @param string $alias Affected alias.
  * @param string $path New path.
  * @access private
  */
 public function _on_icon_alias_changed($resource_manager, $alias, $path)
 {
     parent::_on_icon_alias_changed($resource_manager, $alias, $path);
     if (isset($this->default_theme)) {
         $resource_manager->add_to_path($alias, $this->default_theme->icon_set);
         $resource_manager->set_extension($alias, $this->default_theme->icon_extension);
     }
 }
Пример #11
0
 /**
  * @param PAGE $page
  */
 public function __construct($page)
 {
     $this->page = $page;
     $class_name = $page->final_class_name('PAGE_TITLE', 'webcore/gui/page_title.php');
     $this->title = new $class_name($page);
     $this->title->prefix = '';
     $this->title->suffix = '';
 }
Пример #12
0
/**
 * get category url
 *
 * @param int $cid category id
 *
 * @return string
 */
function ClassifiedAds_getCategoryUrl($cid)
{
    if ((int) $cid === 0) {
        return PAGE::getInstanceByType('classified-ads')->getRelativeUrl();
    }
    if (!isset($GLOBALS['ClassifiedAdsUrls'])) {
        $GLOBALS['ClassifiedAdsUrls'] = array();
    }
    if (isset($GLOBALS['ClassifiedAdsUrls'][$cid])) {
        return $GLOBALS['ClassifiedAdsUrls'][$cid];
    }
    $r = dbRow('select name,parent from classifiedads_categories where id=' . $cid);
    $url = ClassifiedAds_getCategoryUrl($r['parent']) . '/' . preg_replace('/[^a-z0-9A-Z]/', '-', $r['name']);
    $GLOBALS['ClassifiedAdsUrls'][$cid] = $url;
    return $url;
}