Example #1
0
/**
 * blah
 *
 * @param int $id id of the banner
 *
 * @return null
 */
function BannerImage_drawForm($id = 0)
{
    if (!$id) {
        $fdata = array('id' => 0, 'html' => '', 'name' => 'banner');
    } else {
        $fdata = dbRow("select * from banners_images where id={$id}");
    }
    echo '<form method="post" action="/ww.admin/plugin.php?_plugin=banner-ima' . 'ge&amp;_page=index" enctype="multipart/form-data"><input type="hidden' . '" name="id" value="' . (int) $fdata['id'] . '" />';
    echo '<table>';
    // {
    echo '<tr><th>Name</th><td><input name="name" value="' . htmlspecialchars($fdata['name']) . '" /></td></tr>';
    // }
    // { what pages should this be applied to
    echo '<tr><th>Pages</th><td>This banner will only be shown on the <select' . ' name="pages_' . $fdata['id'] . '[]" multiple="multiple" style="max-width' . ':200px;height:500px">';
    $ps = dbAll('select * from banners_pages where bannerid=' . $fdata['id']);
    $pages = array();
    if (count($ps)) {
        foreach ($ps as $p) {
            $pages[] = $p['pageid'];
        }
    }
    BannerImage_selectKiddies(0, 1, $pages);
    echo '</select> pages. <span style="color:red;font-weight:bold">If no pag' . 'es are specified, then the banner will be shown on all pages.</span><' . '/td></tr>';
    // }
    // { show HTML form
    echo '<tr><th>Banner</th><td><div id="banner_image_html">' . ckeditor('html_' . $fdata['id'], Core_unfixImageResizes($fdata['html']), 0, '', 180) . '</div></td></tr>';
    // }
    // { show submit button and end form
    echo '<tr><td><a href="./plugin.php?_plugin=banner-image&_page=index&dele' . 'te_banner=' . $fdata['id'] . '" onclick="return confirm(\'are you sure yo' . 'u want to remove this banner?\');" title="remove banner">[x]</a></td>' . '<td><input type="submit" name="save_banner" value="Update" /></td></tr>';
    // }
    echo '</table></form>';
}
Example #2
0
/**
 * register, and login
 *
 * @return array status
 */
function Privacy_register()
{
    $password = $_REQUEST['password'];
    $token = $_REQUEST['token'];
    $reg = @$_SESSION['privacy']['registration'];
    $email = @$reg['email'];
    $custom = @$reg['custom'];
    if (!is_array($custom)) {
        $custom = array();
    }
    $sql = 'select id from user_accounts where email="' . addslashes($email) . '"';
    if (dbOne($sql, 'id')) {
        return array('error' => __('already registered'));
    }
    if ($token && $token == @$reg['token']) {
        $latlngsql = '';
        if (@$custom['_location']) {
            $latlng = dbRow('select lat,lng from locations where id=' . (int) $custom['_location']);
            if ($latlng) {
                $latlngsql = ',location_lat=' . $latlng['lat'] . ',location_lng=' . $latlng['lng'];
            }
        }
        $sql = 'insert into user_accounts set email="' . addslashes($email) . '",' . 'password=md5("' . addslashes($password) . '"),active=1,date_created=now(),' . 'extras="' . addslashes(json_encode($custom)) . '"' . $latlngsql;
        dbQuery($sql);
        return array('ok' => 1);
    } else {
        return array('error' => __('token does not match'));
    }
}
Example #3
0
function createUser()
{
    if (isset($_POST['register'])) {
        $username = filter_var($_POST['username'], FILTER_SANITIZE_SPECIAL_CHARS);
        $f_name = filter_var($_POST['f_name'], FILTER_SANITIZE_SPECIAL_CHARS);
        $l_name = filter_var($_POST['l_name'], FILTER_SANITIZE_SPECIAL_CHARS);
        $email = filter_var($_POST['email'], FILTER_VALIDATE_EMAIL);
        $re_email = filter_var($_POST['re_email'], FILTER_VALIDATE_EMAIL);
        $pass = filter_var($_POST['pass'], FILTER_SANITIZE_SPECIAL_CHARS);
        $pass = md5($pass);
        /* OBS att jag är medveten om att bara md5 inte är bra... */
        $re_pass = filter_var($_POST['re_pass'], FILTER_SANITIZE_SPECIAL_CHARS);
        $count = dbRow("SELECT COUNT(*) AS count FROM litter_users\n\t\t\tWHERE username = '******'");
        if ($username == "" || $f_name == "" || $l_name == "" || $pass == "") {
            print "<h4>You didn't complete the form!</h4>";
        } elseif ($count['count'] > 0) {
            print "<h4>This username is allreday taken!</h4>";
        } elseif ($email !== $re_email) {
            print "<h4>The two e-mails didn't match!</h4>";
        } elseif ($email === false || $re_email === false) {
            print "<h4>This is not a valid e-mail</h4>";
        } elseif ($pass !== md5($re_pass)) {
            print "<h4>The two passwords didn't match!</h4>";
        } else {
            dbAdd("INSERT INTO litter_users \n\t\t(username, f_name, l_name, email, pass)\n\t\tVALUES('@{$username}', '{$f_name}', '{$l_name}', '{$email}', '{$pass}')");
            $new_id = dbRow("SELECT user_id FROM litter_users\n\t\t\t\tWHERE username = '******'");
            mkdir('userIMG/' . $new_id['user_id']);
            session_start();
            $_SESSION['error'] = 'Your account has been created! Lets go:';
            header('Location: form.php');
        }
    } else {
        print "<h4>Something went wrong... Please try again later!</h4>";
    }
}
Example #4
0
/**
 * get an issue type's details
 *
 * @return array list
 */
function IssueTracker_adminTypeGet()
{
    $id = (int) $_REQUEST['id'];
    $r = dbRow('select * from issuetracker_types where id=' . $id);
    $r['fields'] = json_decode($r['fields']);
    return $r;
}
Example #5
0
 /**
  * instantiate a User object
  *
  * @param int     $id      the user id
  * @param array   $r       a pre-defined array to fill in the values
  * @param boolean $enabled whether to only instantiate users that are enabled
  *
  * @return null
  */
 function __construct($id, $r = false, $enabled = true)
 {
     $id = (int) $id;
     if (!$id) {
         return;
     }
     $filter = $enabled ? ' and active' : '';
     if (!$r) {
         $r = Core_cacheLoad('user_accounts', $id . '|' . $filter, -1);
         if ($r === -1) {
             $r = dbRow("select * from user_accounts where id={$id} {$filter} limit 1");
             Core_cacheSave('user_accounts', $id . '|' . $filter, $r);
         }
     }
     if (!count($r) || !is_array($r)) {
         return false;
     }
     foreach ($r as $k => $val) {
         $this->{$k} = $val;
     }
     if (!isset($this->id)) {
         return false;
     }
     $this->dbVals = $r;
     self::$instances[$this->id] =& $this;
 }
Example #6
0
/**
 * show ads
 *
 * @param array $params parameters
 *
 * @return ads HTML
 */
function Ads_widget($params)
{
    if (!isset($params->{'ad-type'})) {
        return 'missing ad type';
    }
    $type_id = (int) $params->{'ad-type'};
    $howmany = (int) $params->{'how-many'};
    $type = dbRow('select * from ads_types where id=' . $type_id);
    $ads = array();
    $i = 0;
    if ($howmany > 1) {
        $sql = 'select id,image_url,target_type,poster from ads' . ' where type_id=' . $type_id . ' and is_active and cdate>date_add(now(), interval -2 day) order by rand()' . ' limit ' . $howmany;
        $adsNew = dbAll($sql);
        for (; $i < count($adsNew); ++$i) {
            $ads[] = $adsNew[$i];
        }
    }
    $adsOld = dbAll('select id,image_url,target_type,poster from ads' . ' where type_id=' . $type_id . ' and is_active order by rand()' . ' limit ' . $howmany);
    for ($j = 0; $j < $howmany - $i && $j < count($adsOld); ++$j) {
        $ads[] = $adsOld[$j];
    }
    $html = '<div class="ads-wrapper type-' . $type_id . '">';
    foreach ($ads as $ad) {
        $html .= Ads_adShow($ad, $type);
        dbQuery('insert into ads_track set ad_id=' . $ad['id'] . ', view=1, cdate=now()');
    }
    $html .= '</div>';
    WW_addScript('ads/j/js.js');
    WW_addCSS('/ww.plugins/ads/css.css');
    return $html;
}
Example #7
0
/**
 * get info about a mailing list
 *
 * @return info
 */
function Mailinglists_adminListDetails()
{
    $id = (int) $_REQUEST['id'];
    $row = dbRow('select * from mailinglists_lists where id=' . $id);
    if (!$row['meta']) {
        $row['meta'] = '{}';
    }
    $row['meta'] = json_decode($row['meta']);
    return $row;
}
Example #8
0
function show_banner($vars)
{
    $banner = false;
    if (!is_array($vars) && @$vars->id) {
        $b = Core_cacheLoad('banner-images', 'id' . $vars->id);
        if ($b === false) {
            $b = dbRow('select * from banners_images where id=' . $vars->id);
            if ($b && count($b) && !$b['html']) {
                $b['html'] = BannerImage_getImgHtml($vars->id);
                dbQuery('update banners_pages set html="' . addslashes($b['html']) . '" where id=' . $vars->id);
            }
            Core_cacheSave('banner-images', 'id' . $vars->id, $b);
        }
    } elseif ($GLOBALS['PAGEDATA']->id) {
        $b = Core_cacheLoad('banner-images', 'bypage' . $GLOBALS['PAGEDATA']->id);
        if ($b === false) {
            $b = dbAll('select * from banners_pages,banners_images where pageid=' . $GLOBALS['PAGEDATA']->id . ' and bannerid=id');
            Core_cacheSave('banner-images', 'bypage' . $GLOBALS['PAGEDATA']->id, $b);
        }
        $i = rand(0, count($b) - 1);
        $b = isset($b[$i]) ? $b[$i] : false;
        if ($b && count($b) && !$b['html']) {
            $b['html'] = BannerImage_getImgHtml($b['id']);
            dbQuery('update banners_pages set html="' . addslashes($b['html']) . '" where id=' . $b['id']);
        }
    }
    if (!isset($b) || $b === false || !count($b)) {
        $b = Core_cacheLoad('banner-image', 'all');
        if ($b === false) {
            $b = dbAll('select * from banners_images');
            Core_cacheSave('banner-image', 'all', $b);
        }
        $i = rand(0, count($b) - 1);
        $b = isset($b[$i]) ? $b[$i] : false;
    }
    if ($b && count($b)) {
        $banner = $b['html'];
        if (!$banner) {
            $banner = BannerImage_getImgHtml($vars->id);
        }
    }
    if (!$banner) {
        if (is_array($vars) && @$vars['default']) {
            $banner = $vars['default'];
        } else {
            $banner = '';
        }
    }
    if (!$banner) {
        return '';
    }
    return '<style type="text/css">#banner{background:none}</style>' . $banner;
}
Example #9
0
 function __construct($v, $byField = 0, $fromRow = 0, $pvq = 0)
 {
     # byField: 0=ID; 1=Name; 3=special
     if (!$byField && is_numeric($v)) {
         // by ID
         $r = $fromRow ? $fromRow : ($v ? dbRow("select * from pages where id={$v} limit 1") : array());
     } else {
         if ($byField == 1) {
             // by name
             $name = strtolower(str_replace('-', '_', $v));
             $fname = 'page_by_name_' . md5($name);
             $r = dbRow("select * from pages where name like '" . addslashes($name) . "' limit 1");
         } else {
             if ($byField == 3 && is_numeric($v)) {
                 // by special
                 $fname = 'page_by_special_' . $v;
                 $r = dbRow("select * from pages where special&{$v} limit 1");
             } else {
                 return false;
             }
         }
     }
     if (!count($r || !is_array($r))) {
         return false;
     }
     if (!isset($r['id'])) {
         $r['id'] = 0;
     }
     if (!isset($r['type'])) {
         $r['type'] = 0;
     }
     if (!isset($r['special'])) {
         $r['special'] = 0;
     }
     if (!isset($r['name'])) {
         $r['name'] = 'NO NAME SUPPLIED';
     }
     foreach ($r as $k => $v) {
         $this->{$k} = $v;
     }
     $this->urlname = $r['name'];
     $this->dbVals = $r;
     self::$instances[$this->id] =& $this;
     self::$instancesByName[preg_replace('/[^a-z0-9]/', '-', strtolower($this->urlname))] =& $this;
     self::$instancesBySpecial[$this->special] =& $this;
     if (!$this->vars) {
         $this->vars = '{}';
     }
     $this->vars = json_decode($this->vars);
 }
Example #10
0
 /**
  * get a page variable by its name and value
  *
  * @param string  $name           name of the variable you're searching for
  * @param string  $value          value of the variable you're searching for
  * @param boolean $includePageRow whether to also return the page row
  *
  * @return PageVars object
  */
 function getByNameAndValue($name, $value, $includePageRow = false)
 {
     if (!array_key_exists($name, self::$instancesByNameAndValue) || !array_key_exists($value, self::$instancesByNameAndValue[$name])) {
         if (!array_key_exists($name, self::$instancesByNameAndValue)) {
             self::$instancesByNameAndValue[$name] = array();
         }
         if ($includePageRow) {
             self::$instancesByNameAndValue[$name][$value] = dbRow("SELECT * FROM page_vars,pages WHERE page_vars.name='" . addslashes($name) . "' AND value='" . addslashes($value) . "' AND pages.id=page_vars.page_id LIMIT 1");
         } else {
             self::$instancesByNameAndValue[$name][$value] = dbRow("SELECT * FROM page_vars WHERE name='" . addslashes($name) . "' AND value='" . addslashes($value) . "' LIMIT 1");
         }
     }
     return self::$instancesByNameAndValue[$name][$value];
 }
Example #11
0
function Menu_getHtml()
{
    global $DBVARS;
    require_once SCRIPTBASE . 'ww.incs/menus.php';
    require_once SCRIPTBASE . 'ww.incs/common.php';
    $vars = null;
    if (isset($_REQUEST['vars'])) {
        $vars = json_decode($_REQUEST['vars']);
    }
    if ($vars && isset($vars->id) && $vars->id) {
        $id = $vars->id;
        $vars = Core_cacheLoad('menus', $id, -1);
        if ($vars === -1) {
            $vars = dbRow('select * from menus where id=' . $id);
            Core_cacheSave('menus', $id, $vars);
        }
        if ($vars['cache']) {
            header('Cache-Control: max-age=' . $vars['cache'] . ', public');
            header('Expires: Fri, 1 Jan 2500 01:01:01 GMT');
            header('Expires-Active: On');
            header('Pragma:');
            header('Last-modified: ' . gmdate('D, d M Y H:i:s', time()));
        }
        if ($vars['parent'] == '-1') {
            global $PAGEDATA;
            $pid = $PAGEDATA->id;
            if ($pid) {
                $n = dbOne('select id from pages where parent=' . $pid . ' limit 1', id);
                if (!$n) {
                    $pid = (int) $PAGEDATA->parent;
                    if (!$pid) {
                        return '';
                    }
                }
            }
            $vars['parent'] = $pid;
        }
    }
    header('Content-type: text/javascript');
    echo 'document.write("' . addslashes(Core_menuShowFg($vars)) . '");';
    echo join(';', $GLOBALS['scripts_inline']);
    $cdn = isset($DBVARS['cdn']) ? '//' . $DBVARS['cdn'] : '';
    foreach ($GLOBALS['scripts'] as $r) {
        echo 'document.write("<script src=\\"' . $cdn . $r . '\\"></script>");';
    }
    foreach ($GLOBALS['css_urls'] as $r) {
        echo 'document.write("<link rel=\\"stylesheet\\" type=\\"text/css\\" href=\\"' . $cdn . $r . '\\"/>");';
    }
    exit;
}
/**
 * retrieve HTML summary for a set page
 *
 * @param int $id ID of the page
 *
 * @return string HTML summary for a set page
 */
function PageSummaries_getHtml($id)
{
    $PAGEDATA = Page::getInstance($id);
    global $sitedomain;
    $r = dbRow('select * from page_summaries where page_id="' . $PAGEDATA->id . '"');
    if (!count($r)) {
        return '<em>This page is marked as a page summary, but there is no ' . 'information on how to handle it.</em>';
    }
    if ($r['rss']) {
        return PageSummaries_rssToHtml($r['rss']);
    }
    // { build rss
    $title = $PAGEDATA->title == '' ? $sitedomain : htmlspecialchars($PAGEDATA->title);
    $rss = '<' . '?xml version="1.0" ?' . '><rss version="2.0"><channel><title>' . $title . '</title>';
    $rss .= '<link>' . $_SERVER['REQUEST_URI'] . '</link><description>RSS for ' . $PAGEDATA->name . '</description>';
    $category = $PAGEDATA->category ? ' and category="' . $PAGEDATA->category . '"' : '';
    $containedpages = PageSummaries_getContainedPages($r['parent_id']);
    if (count($containedpages)) {
        $q2 = dbAll('select edate,name,title,body from pages where id in (' . join(',', $containedpages) . ')' . $category . ' order by cdate desc limit 20');
        foreach ($q2 as $r2) {
            $rss .= '<item>';
            if (!$r2['title']) {
                $r2['title'] = $r2['name'];
            }
            $rss .= '<title>' . htmlspecialchars($r2['title']) . '</title>';
            $rss .= '<pubDate>' . date_m2h($r2['edate']) . '</pubDate>';
            // { build body
            if ($r['amount_to_show'] == 0 || $r['amount_to_show'] == 1) {
                $length = $r['amount_to_show'] == 0 ? 300 : 600;
                $body = str_replace('  ', ' ', preg_replace('/<[^>]*>/', ' ', str_replace(array('&amp;', '&nbsp;', '&lsquo;'), array('&', ' ', '&apos;'), $r2['body'])));
                $body = substr($body, 0, $length) . '...';
            } else {
                $body = $r2['body'];
            }
            $body = str_replace('&euro;', '&#8364;', $body);
            // }
            $rss .= '<description>' . $body . '</description>';
            $rss .= '<link>http://' . $_SERVER['HTTP_HOST'] . '/' . urlencode(str_replace(' ', '-', $r2['name'])) . '</link>';
            $rss .= '</item>';
        }
    }
    $rss .= '</channel></rss>';
    dbQuery('update page_summaries set rss="' . addslashes($rss) . '" where page_id="' . $PAGEDATA->id . '"');
    // }
    return PageSummaries_rssToHtml($rss);
}
 function __construct($v, $byField = 0, $fromRow = 0, $pvq = 0)
 {
     if (!$byField && is_numeric($v)) {
         $r = $fromRow ? $fromRow : ($v ? dbRow("SELECT * FROM pages WHERE id={$v} LIMIT 1") : array());
     } else {
         if ($byField == 1) {
             $name = strtolower(str_replace('-', '_', $v));
             $fname = 'page_by_name_' . md5($name);
             $r = dbRow("SELECT * FROM pages WHERE name LIKE '" . $name . "' LIMIT 1");
         } else {
             if ($byField == 3 && is_numeric($v)) {
                 $fname = 'page_by_special_' . $v;
                 $r = dbRow("SELECT * FROM pages WHERE special&{$v} limit 1");
             } else {
                 return false;
             }
         }
     }
     if (!count($r || !is_array($r))) {
         return false;
     }
     if (!isset($r['id'])) {
         $r['id'] = 0;
     }
     if (!isset($r['type'])) {
         $r['type'] = 0;
     }
     if (!isset($r['special'])) {
         $r['special'] = 0;
     }
     if (!isset($r['name'])) {
         $r['name'] = 'NO NAME SUPPLIED';
     }
     foreach ($r as $k => $v) {
         $this->{$k} = $v;
     }
     $this->urlname = $r['name'];
     $this->dbVals = $r;
     self::$instances[$this->id] =& $this;
     self::$instancesByName[preg_replace('/[^a-z0-9]/', '-', strtolower($this->urlname))] =& $this;
     self::$instancesBySpecial[$this->special] =& $this;
     if (!$this->vars) {
         $this->vars = '{}';
     }
     $this->vars = json_decode($this->vars);
 }
Example #14
0
/**
  * get a list of posts for an RSS feed
  *
  * @param Object $PAGEDATA The page
  *
  * @return array array of articles
**/
function Forum_rssHandler($PAGEDATA)
{
    $items = array();
    $posts = dbAll('select id,thread_id,author_id,created_date,body from forums_posts' . ' where moderated order by created_date desc limit 10');
    $threads = array();
    $authors = array();
    foreach ($posts as $post) {
        if (!isset($authors[$post['author_id']])) {
            $authors[$post['author_id']] = dbRow('select name from user_accounts where id=' . $post['author_id']);
        }
        if (!isset($threads[$post['thread_id']])) {
            $threads[$post['thread_id']] = dbRow('select forum_id,name from forums_threads where id=' . $post['thread_id']);
        }
        $items[] = array('title' => 'post by ' . $authors[$post['author_id']]['name'] . ' in "' . $threads[$post['thread_id']]['name'] . '"', 'description' => $post['body'], 'link' => 'http://' . $_SERVER['HTTP_HOST'] . $PAGEDATA->getRelativeURL() . '?forum-f=' . $threads[$post['thread_id']]['forum_id'] . '&amp;forum-t=' . $post['thread_id'] . '#forum-c-' . $post['id'], 'guid' => 'post-' . $post['id'], 'pubDate' => Core_dateM2H($post['created_date'], 'rfc822'));
    }
    return array('title' => 'Posts for ' . $PAGEDATA->getRelativeURL(), 'link' => 'http://' . $_SERVER['HTTP_HOST'] . $PAGEDATA->getRelativeURL(), 'description' => 'Posts for ' . $PAGEDATA->getRelativeURL(), 'generator' => 'WebME CMS', 'items' => $items);
}
Example #15
0
function poll_display()
{
    WW_addScript('polls');
    $poll = dbRow('select * from poll where enabled limit 1');
    if (!count($poll)) {
        return '<div class="polls-wrapper"><em>No polls available.</em></div>';
    }
    $id = $poll['id'];
    $html = '<div class="polls-wrapper" poll-id="' . $id . '">';
    $html .= '<div class="question">' . $poll['body'] . '</div><ul class="answers">';
    $answers = dbAll("select * from poll_answer where poll_id={$id} order by num");
    foreach ($answers as $answer) {
        $html .= '<li><input type="radio" name="poll_answer" value=' . '"' . $answer['num'] . '" />' . htmlspecialchars($answer['answer']) . '</li>';
    }
    $html .= '</ul><input type="button" class="polls-vote" value="Vote" /><inpu' . 't type="button" class="polls-results" value="View Results" />';
    $html .= '</div>';
    return $html;
}
Example #16
0
 function __construct($v, $r = false, $values = false, $enabled = true)
 {
     $v = (int) $v;
     if (!$v) {
         return;
     }
     $filter = $enabled ? ' and enabled ' : '';
     if (!$r) {
         $r = dbRow("select * from poll where id={$v} {$filter} limit 1");
     }
     if (!count($r)) {
         return false;
     }
     foreach ($r as $k => $val) {
         $this->{$k} = $val;
     }
     $this->dbVals = $r;
     self::$instances[$this->id] =& $this;
 }
Example #17
0
/**
 * subscribe to a mailinglist
 *
 * @return status
 */
function Mailinglists_subscribe()
{
    $list = (int) $_REQUEST['list'];
    $email = $_REQUEST['email'];
    if (!filter_var($email, FILTER_VALIDATE_EMAIL)) {
        return array('error' => __('Not an email address'));
    }
    $sql = 'select * from mailinglists_lists';
    if ($list) {
        $sql .= ' where id=' . $list;
    }
    $list = dbRow($sql);
    if (!$list) {
        return array('error' => __('No such mailing list'));
    }
    $listMeta = json_decode($list['meta'], true);
    switch ($listMeta['engine']) {
        case 'Ubivox':
            // {
            $apiusername = $listMeta['ubivox-apiusername'];
            $apipassword = $listMeta['ubivox-apipassword'];
            $listId = preg_replace('/\\|.*/', '', $listMeta['ubivox-list']);
            $response = Mailinglists_xmlrpcClient($apiusername, $apipassword, xmlrpc_encode_request('ubivox.create_subscription', array($email, array($listId), true)));
            $data = xmlrpc_decode(trim($response));
            break;
            // }
        // }
        default:
            // {
            $apikey = $listMeta['mailchimp-apikey'];
            require_once dirname(__FILE__) . '/MCAPI.class.php';
            $api = new MCAPI($apikey);
            $data = $api->lists();
            $api->listSubscribe(preg_replace('/\\|.*/', '', $listMeta['mailchimp-list']), $email);
            if ($api->errorCode) {
                return array('error' => $api->errorCode, 'message' => $api->errorMessage);
            }
            // }
    }
    return array('ok' => true);
}
function showshortcuts($id, $parent)
{
    $q = dbAll('select id,name from pages where parent="' . $parent . '" order by ord desc,name');
    if (count($q)) {
        echo '<ul>';
        foreach ($q as $r) {
            echo '<li>';
            echo wInput('shortcuts[' . $r['id'] . ']', 'checkbox');
            $r2 = dbRow('select id,name from pagelinks where fromid="' . $id . '" and toid="' . $r['id'] . '"');
            if (count($r2)) {
                echo ' checked="checked"';
                $r['name'] = $r2['name'];
            }
            echo ' />';
            echo wInput('shortcutsName[' . $r['id'] . ']', 'text', htmlspecialchars($r['name']));
            showshortcuts($id, $r['id']);
            echo '</li>';
        }
        echo '</ul>';
    }
}
Example #19
0
 function __construct($v, $r = false, $enabled = true)
 {
     $v = (int) $v;
     if (!$v) {
         return;
     }
     $filter = $enabled ? ' and active' : '';
     if (!$r) {
         $r = dbRow("select * from user_accounts where id={$v} {$filter} limit 1");
     }
     if (!count($r) || !is_array($r)) {
         return false;
     }
     foreach ($r as $k => $val) {
         $this->{$k} = $val;
     }
     if (!isset($this->id)) {
         return false;
     }
     $this->dbVals = $r;
     self::$instances[$this->id] =& $this;
 }
Example #20
0
/**
 * show frontend widget
 *
 * @param array $vars settings
 *
 * @return string html
 */
function MP3_frontendWidget($vars = null)
{
    $db = dbRow('select fields,template from mp3_plugin where id=' . $vars->id);
    $files = json_decode($db['fields'], true);
    if (count($files) == 0) {
        return 'No files yet';
    }
    // { if template doesnt exist, create it
    $template = USERBASE . '/ww.cache/mp3/';
    if (!is_dir($template)) {
        mkdir($template);
    }
    $template .= $vars->id;
    if (!file_exists($template)) {
        file_put_contents($template, $db['template']);
    }
    // }
    // { display the template
    require_once SCRIPTBASE . 'ww.incs/vendor/Smarty-3.1.19/libs/Smarty.class.php';
    $smarty = new Smarty();
    $smarty->compile_dir = USERBASE . '/ww.cache/templates_c';
    if (!file_exists(USERBASE . '/ww.cache/templates_c')) {
        mkdir(USERBASE . '/ww.cache/templates_c');
    }
    if (!file_exists(USERBASE . '/ww.cache/templates_c/image-gallery')) {
        mkdir(USERBASE . '/ww.cache/templates_c/image-gallery');
    }
    $smarty->registerPlugin('function', 'LIST', 'MP3_list');
    $smarty->registerPlugin('function', 'PLAY', 'mp3_play');
    $smarty->registerPlugin('function', 'PROGRESS', 'MP3_progress');
    $smarty->left_delimiter = '{{';
    $smarty->right_delimiter = '}}';
    $smarty->smarty->tpl_vars['mp3_files']->value = $files;
    $html = $smarty->fetch(USERBASE . '/ww.cache/mp3/' . $vars->id);
    WW_addScript('mp3/frontend/jwplayer.js');
    WW_addScript('mp3/frontend/widget.js');
    // }
    return $html;
}
Example #21
0
 /**
  * The constructor function
  *
  * @param int $num The id of the quiz
  *
  * @return null if the id doesn't exist
  * 		The quiz otherwise
  *
  */
 function __construct($num)
 {
     $this->id = (int) $num;
     $id = $this->id;
     $this->score = 0;
     $quiz = dbRow("SELECT * FROM quiz_quizzes WHERE id = '" . $id . "'");
     $rows = dbAll("SELECT * \n\t\t\t\tFROM quiz_questions \n\t\t\t\tWHERE quiz_id = '{$id}' \n\t\t\t\tAND question IS NOT NULL");
     if (count($rows) != 0) {
         // I want the questions to be in an indexed array
         $this->allQuestions = array();
         $i = 0;
         foreach ($rows as $row) {
             $this->allQuestions[$i] = $row;
             $i++;
         }
         $this->numQuestionsToBeAnswered = $quiz['number_of_questions'];
         $this->numQuestions = count($rows);
         if ($this->numQuestionsToBeAnswered > $this->numQuestions) {
             $this->numQuestionsToBeAnswered = ceil($this->numQuestions / 2);
         }
     } else {
         return null;
     }
 }
Example #22
0
/**
 * get visibility of panel
 *
 * @return array
 */
function Panels_adminVisibilityGet()
{
    $visible = array();
    $hidden = array();
    if (isset($_REQUEST['id'])) {
        $id = (int) $_REQUEST['id'];
        $r = dbRow("select visibility,hidden from panels where id={$id}");
        if (is_array($r) && count($r)) {
            if ($r['visibility']) {
                $visible = json_decode($r['visibility']);
            }
            if ($r['hidden']) {
                $hidden = json_decode($r['hidden']);
            }
        }
    }
    if (isset($_REQUEST['visibility']) && $_REQUEST['visibility']) {
        $visible = explode(',', $_REQUEST['visibility']);
    }
    if (isset($_REQUEST['hidden']) && $_REQUEST['hidden']) {
        $hidden = explode(',', $_REQUEST['hidden']);
    }
    return array('visible' => Panels_selectChildPages(0, 1, $visible, 0), 'hidden' => Panels_selectChildPages(0, 1, $hidden, 0));
}
/**
 * delete a page
 *
 * @return array status of the deletion
 */
function Core_adminPageDelete()
{
    $id = (int) $_REQUEST['id'];
    if (!$id) {
        return array('error' => 'no ID provided');
    }
    $r = dbRow("SELECT COUNT(id) AS pagecount FROM pages");
    if ($r['pagecount'] < 2) {
        return array('error' => 'there must always be at least one page.');
    }
    $q = dbQuery('select parent from pages where id="' . $id . '"');
    if ($q->rowCount()) {
        $r = dbRow('select parent from pages where id="' . $id . '"');
        dbQuery('delete from page_vars where page_id="' . $id . '"');
        dbQuery('delete from pages where id="' . $id . '"');
        dbQuery('update pages set parent="' . $r['parent'] . '" where parent="' . $id . '"');
        Core_cacheClear();
        dbQuery('update page_summaries set rss=""');
        return array('ok' => 1);
    }
    return array('error' => 'page does not exist');
}
//var_dump(isset($user['groups']['_superadmin']));
if (isset($user['groups']['_validators'])) {
    echo '<li><a href="/cms.user/index.php?feature=settings&amp;settings=validator">Reviewer Profile</a></li>';
    echo '<li><a href="/cms.user/index.php?feature=tutorials&amp;review=all">My Reviews</a></li>';
}
?>
                    </ul>
                </div>
    
                <div class = "innerColumn">
                    <h3>My Recent Additions</h3>
                    <ul>
<?php 
$tp = $DBVARS['tp'];
$id = (int) $_SESSION['userdata']['uid'];
$author = dbRow('SELECT * FROM ' . $tp . 'author a WHERE a.uid=' . $id . ' LIMIT 1;');
if ($author == false) {
    echo '<li>No Recent Posts</li>';
} else {
    //$posts = dbAll('SELECT t.id,t.title FROM '.$tp.'tutorial_author a, '.$tp.'tutorial t WHERE a.tutorial_id = t.id AND a.auth_id='.$author['id'].' LIMIT 5;');
    //$posts = dbAll('SELECT * FROM '.$tp.'tutorial t WHERE t.id='.$author['tutorial_id'].' ORDER BY t.ts LIMIT 5;');
    $posts = dbAll('select t.id,t.title from ' . $tp . 'tutorial_author a, ' . $tp . 'tutorial t WHERE a.tutorial_id=t.id AND a.auth_id=' . $author['id'] . ' ORDER BY t.ts DESC LIMIT 5;');
    ?>
    
<?php 
    if (!count($posts) || !is_array($posts)) {
        echo '<li>No Recent Posts</li>';
    } else {
        foreach ($posts as $post) {
            echo '<li><a href="index.php?feature=tutorials&amp;view=one&amp;id=' . $post['id'] . '">' . $post['title'] . '</a></li>';
        }
echo '<tr><th>' . __('Name') . '</th><th>' . __('ISO code') . ' <a href="http://www.iso.org/iso/support/faqs/faqs_widely_used_standards/widely_used_standards_other/currency_codes/currency_codes_list-1.htm" class="external">&nbsp;</a></th><th>Symbol</th><th>Value</th></tr>';
// { draw existing currencies
$r = dbRow("SELECT * FROM site_vars WHERE name='currencies'");
if (!count($r)) {
    $r = array('value' => '[{"name":"Euro","iso":"eur","symbol":"€","value":1}]');
}
$curs = json_decode($r['value']);
for ($i = 0; $i < count($curs); ++$i) {
    echo '<tr><td><input name="cur_name[' . $i . ']" value="' . htmlspecialchars($curs[$i]->name) . '" /></td>' . '<td><input name="cur_iso[' . $i . ']" value="' . htmlspecialchars($curs[$i]->iso) . '" /></td>' . '<td><input name="cur_symbol[' . $i . ']" value="' . htmlspecialchars($curs[$i]->symbol) . '" /></td>';
    echo '<td><input name="cur_value[' . $i . ']" value="' . htmlspecialchars($curs[$i]->value) . '" /></td></tr>';
}
// }
echo '</table><a href="javascript:addCurrency()">' . __('Add Currency') . '</a></td></tr>';
// }
// { user discounts
$r = dbRow("SELECT * FROM site_vars WHERE name='user_discount'");
echo '<tr><th>' . __('User discount') . '</th><td>' . __('What discount percentage should new user registrants be set to?') . '<br /><input name="user_discount" value="' . (double) $r['value'] . '" /></td></tr>';
// }
echo '<tr><td colspan="2" style="text-align:right"><input type="submit" name="action" value="Save" /></td></tr></table></form>';
// }
// { javascripts
?>
<script type="text/javascript">
	function addLanguage(){
		var t=$M('siteoptions_languages'),r,c,langs,cs=0;
		langs=t.rows.length;
		r=t.insertRow(langs);
		c=r.insertCell(cs++);
		c.appendChild(new Element('input',{ 'name':'lang_name['+(langs-1)+']', }));
		c=r.insertCell(cs++);
		c.appendChild(new Element('input',{ 'name':'lang_iso['+(langs-1)+']', }));
Example #26
0
/**
 * retrieve an image from the database
 *
 * @return null
 */
function ImageGallery_img()
{
    global $DBVARS;
    $id = (int) $_REQUEST['id'];
    $width = @(int) $_REQUEST['w'];
    $height = @(int) $_REQUEST['h'];
    $sql = 'select * from image_gallery where id=' . $id;
    $r = dbRow($sql);
    $meta = json_decode($r['meta']);
    $url = (isset($DBVARS['cdn']) && $DBVARS['cdn'] ? '//' . $DBVARS['cdn'] : '') . '/a/f=getImg/w=' . $width . '/h=' . $height . '/image-galleries/' . 'imagegallery-' . $r['gallery_id'] . '/' . $meta->name;
    header('Location: ' . $url);
    Core_quit();
}
Example #27
0
        if (isset($_REQUEST['groups'])) {
            foreach ($_REQUEST['groups'] as $k => $n) {
                dbQuery("insert into users_groups set user_accounts_id={$id},groups_id=" . (int) $k);
            }
        }
        echo '<em>users updated</em>';
        if (isset($_REQUEST['email-to-send'])) {
            $site = preg_replace('/www\\./', '', $_SERVER['HTTP_HOST']);
            Core_mail($_REQUEST['email'], '[' . $site . '] user status update', $_REQUEST['email-to-send'], 'no-reply@' . $site);
        }
        Core_cacheSave('user-session-resets', $id, true);
    }
}
// }
// { form
$r = dbRow("select * from user_accounts where id={$id}");
if (!is_array($r) || !count($r)) {
    $r = array('id' => -1, 'email' => '', 'name' => '', 'contact' => '{}', 'active' => 0, 'address' => '[]', 'parent' => $_SESSION['userdata']['id']);
}
// { table of contents
echo '<div id="tabs"><ul>' . '<li><a href="#details">User Details</a></li>' . '<li><a href="#locations">Locations</a></li>' . '<li><a href="#custom">Custom Data</a></li>' . '</ul> <form action="siteoption' . 's.php?page=users&amp;id=' . $id . '" method="post">';
echo '<input type="hidden" name="id" value="' . $id . '" />';
if (!isset($r['extras'])) {
    $r['extras'] = '';
}
// }
// { user details
echo '<div id="details"><table class="wide">' . '<tr><th>Main</th><th>Contact Details</th></tr>' . '<tr>';
// { main details
echo '<td><table>';
// { name
Example #28
0
<?php

/**
 * vote
 *
 * PHP version 5.2
 *
 * @category None
 * @package  None
 * @author   Kae Verens <*****@*****.**>
 * @license  GPL 2.0
 * @link     http://kvsites.ie/
 */
require_once $_SERVER['DOCUMENT_ROOT'] . '/ww.incs/basics.php';
$id = (int) $_REQUEST['id'];
$vote = (int) $_REQUEST['vote'];
$ip = $_SERVER['REMOTE_ADDR'];
header('Content-type: text/json');
$r = dbRow('select * from poll_vote where poll_id=' . $id . ' and ip="' . $ip . '"');
if ($r) {
    echo json_encode(array('status' => 1, 'message' => 'You have already voted in this poll'));
    Core_quit();
}
dbQuery('insert into poll_vote set poll_id=' . $id . ',ip="' . $ip . '",num=' . $vote);
echo json_encode(array('status' => 0));
Example #29
0
 * PHP version 5.2
 *
 * @category None
 * @package  None
 * @author   Kae Verens <*****@*****.**>
 * @license  GPL 2.0
 * @link     http://kvsites.ie/
 */
require $_SERVER['DOCUMENT_ROOT'] . '/ww.incs/basics.php';
if (!Core_isAdmin()) {
    die('access denied');
}
if (isset($_REQUEST['get_messaging_notifier'])) {
    $id = (int) $_REQUEST['get_messaging_notifier'];
    if ($id) {
        $r = dbRow('select * from messaging_notifier where id=' . $id);
    } else {
        $r = array('id' => 0, 'messages_to_show' => 10, 'data' => '[]');
    }
    $r['data'] = json_decode($r['data']);
    echo json_encode($r);
    Core_quit();
}
if (isset($_REQUEST['action']) && $_REQUEST['action'] == 'save') {
    $id = (int) $_REQUEST['id'];
    $id_was = $id;
    $data = json_decode($_REQUEST['data']);
    foreach ($data as $k => $r) {
        if ($r->type == 'Twitter') {
            $regex = 'http://twitter.com/statuses/user_timeline/[0-9]*.rss';
            $regex = '/https.*api.twitter.com.*statuses/';
<?php

//to be changed.....................................
function boolConvert($var)
{
    if ($var == 0) {
        return "False";
    }
    return "True";
}
$tp = $DBVARS['tp'];
$user = $_SESSION['userdata'];
$author = dbRow('SELECT * from ' . $tp . 'author a WHERE a.uid=' . $user['uid'] . ';');
$tutorials = array();
if ($author != false) {
    global $tutorials;
    $tutorials = dbAll('SELECT t.* FROM ' . $tp . 'tutorial t, ' . $tp . 'tutorial_author ta WHERE t.id=ta.tutorial_id AND ta.auth_id=' . $author['id'] . ';');
}
?>

<!-- <article class = "main">
                <div class = "innerColumn">-->
<?php 
echo '<h1> My Tutorials</h1>';
echo '<table style="width:100%">
<tr><th>Id</th><th>Posted By</th><th>Title</th><th>Validated</th></tr>';
if (count($tutorials) == 0) {
    echo '<tr><th colspan="4">No Records Found</th></tr>';
    echo '</table>';
} else {
    foreach ($tutorials as $tutorial) {