Esempio n. 1
0
function mediashare_randomblock_update($blockinfo)
{
    $vars = array('type' => FormUtil::getPassedValue('mstype'), 'albumId' => (int) FormUtil::getPassedValue('msalbumId'), 'cacheTime' => (int) FormUtil::getPassedValue('cacheTime'), 'html' => FormUtil::getPassedValue('mshtml'));
    $blockinfo['content'] = pnBlockVarsToContent($vars);
    return $blockinfo;
}
Esempio n. 2
0
/**
 * update block settings
 */
function template_firstblock_update($blockinfo)
{
    $vars['numitems'] = pnVarCleanFromInput('numitems');
    $blockinfo['content'] = pnBlockVarsToContent($vars);
    return $blockinfo;
}
Esempio n. 3
0
function blocks_menu_update($row)
{
    list($vars['displaymodules'], $vars['displaywaiting'], $vars['style']) = pnVarCleanFromInput('displaymodules', 'displaywaiting', 'style');
    // Defaults
    if (empty($vars['displaymodules'])) {
        $vars['displaymodules'] = 0;
    }
    if (empty($vars['displaywaiting'])) {
        $vars['displaywaiting'] = 0;
    }
    if (empty($vars['style'])) {
        $vars['style'] = 1;
    }
    // User links
    $content = array();
    $c = 1;
    if (isset($row['linkname'])) {
        list($linkurl, $linkname, $linkdesc) = pnVarCleanFromInput('linkurl', 'linkname', 'linkdesc');
        foreach ($row['linkname'] as $v) {
            if (!isset($row['linkdelete'][$c])) {
                $content[] = "{$linkurl[$c]}|{$linkname[$c]}|{$linkdesc[$c]}";
            }
            if (isset($row['linkinsert'][$c])) {
                $content[] = "||";
            }
            $c++;
        }
    }
    if ($row['new_linkname']) {
        $content[] = pnVarCleanFromInput('new_linkurl') . '|' . pnVarCleanFromInput('new_linkname') . '|' . pnVarCleanFromInput('new_linkdesc');
    }
    $vars['content'] = implode("LINESPLIT", $content);
    $row['content'] = pnBlockVarsToContent($vars);
    return $row;
}
Esempio n. 4
0
function blocks_rss_refresh($row, $forceupdate = 0)
{
    list($dbconn) = pnDBGetConn();
    $pntable = pnDBGetTables();
    // Get arguments
    $args = pnBlockVarsFromContent($row['content']);
    // Check for URL
    if (empty($args['rssurl'])) {
        return $row;
    }
    $past = time() - $row['refresh'];
    if (!$forceupdate && $row['unix_update'] > $past) {
        return $row;
    }
    $rss = parse_url($args['rssurl']);
    if (!isset($rss['port'])) {
        $rss['port'] = 80;
    }
    if (!isset($rss['query'])) {
        $rss['query'] = '';
    }
    // retrive the rss file
    $fp = fsockopen($rss['host'], $rss['port'], $errno, $errstr, 10);
    if (!$fp) {
        $next_try = time() + 600;
        $column =& $pntable['blocks_column'];
        $sql = "UPDATE {$pntable['blocks']}\n                SET {$column['last_update']}=" . pnVarPrepForStore($next_try) . "\n                WHERE {$column['bid']}=" . pnVarPrepForStore($row['bid']);
        $result = $dbconn->Execute($sql);
        $row['title'] .= ' *';
        return $row;
    }
    fputs($fp, 'GET ' . $rss['path'] . '?' . $rss['query'] . " HTTP/1.0\r\n");
    // cocomp 2002/07/13 Added Referer & User-Agent as some sites won't give RSS
    // feed otherwise
    fputs($fp, 'HOST: ' . $rss['host'] . "\r\n");
    fputs($fp, 'Referer: ' . pnGetBaseURL() . "\r\n");
    fputs($fp, 'User-Agent: ' . pnConfigGetVar('Version_ID') . ': ' . pnConfigGetVar('Version_Sub') . ': ' . pnConfigGetVar('Version_Num') . "\r\n\r\n");
    $rss_file = '';
    $start_time = time();
    while (!feof($fp)) {
        $line = fgets($fp, 4096);
        if (empty($go)) {
            if ($line[0] == '<') {
                $go = true;
            }
            /*
             * Fix on SF-bug #566489
             */
            if (preg_match("/[\n]?[\r]{1}[^\n]{1}/", $line)) {
                $line = preg_replace("/([\n]?[\r]{1})([^\n]{1})/", "\n\\2", $line);
                $lines = explode("\n", $line);
                $first = true;
                foreach ($lines as $line) {
                    if ($first) {
                        $first = !$first;
                    } else {
                        $rss_file[] = trim($line);
                    }
                }
            }
            /*
             * End of fix
             */
        } else {
            /*
             * Fix on SF-bug #566489
             */
            if (preg_match("/[\n]?[\r]{1}[^\n]{1}/", $line)) {
                $line = preg_replace("/([\n]?[\r]{1})([^\n]{1})/", "\n\\2", $line);
                $lines = explode("\r\n", $line);
                foreach ($lines as $line) {
                    $rss_file[] = trim($line);
                }
            } else {
                $rss_file[] = trim($line);
            }
            /*
             * End of fix
             */
        }
        if (time() - $start_time == 5) {
            // if the source server is too slow, we give up. 5 seconds is more then enough time
            fputs($fp, "Connection: close\r\n\r\n");
            fclose($fp);
            $column =& $pntable['blocks_column'];
            $sql = "UPDATE {$pntable['blocks']}\n                    SET {$column['last_update']}=0\n                    WHERE {$column['bid']}=" . pnVarPrepForStore($row['bid']);
            $result = $dbconn->Execute($sql);
            return $row;
        }
    }
    fputs($fp, "Connection: close\r\n\r\n");
    fclose($fp);
    $struct = rss_parse_array($rss_file);
    // parse the file
    $channel_data = '';
    $image_data = '';
    $item_data = array();
    $search_data = '';
    $total_items = 0;
    $cur_block = '';
    foreach ($struct as $v) {
        if (!is_array($v)) {
            continue;
        }
        if ($v['type'] == 'open') {
            switch ($v['tag']) {
                case 'channel':
                    $cur_block = 'channel';
                    break;
                case 'image':
                    $cur_block = 'image';
                    break;
                case 'item':
                    $cur_block = 'item';
                    break;
                case 'textinput':
                    $cur_block = 'textinput';
                    break;
            }
        } elseif ($v['type'] == 'close') {
            switch ($v['tag']) {
                case 'channel':
                    $cur_block = '';
                    break;
                case 'image':
                    $cur_block = '';
                    break;
                case 'item':
                    $cur_block = '';
                    $total_items++;
                    break;
                case 'textinput':
                    $cur_block = '';
                    break;
            }
        } elseif ($v['type'] == 'complete') {
            $tag = $v['tag'];
            switch ($cur_block) {
                case 'channel':
                    $channel_data[$tag] = $v['value'];
                    break;
                case 'image':
                    $image_data[$tag] = $v['value'];
                    break;
                case 'item':
                    $item_data[$total_items][$tag] = $v['value'];
                    break;
                case 'textinput':
                    $search_data[$tag] = $v['value'];
                    break;
            }
        }
    }
    // start generating content
    $content = '';
    // image & link
    if (!empty($args['showimage'])) {
        // cocomp 2002/07/13 - prevent E_ALL errors check for $image_data
        if (isset($image_data) && is_array($image_data)) {
            if (isset($image_data['url']) && $image_data['url'] != 'http://yoursite.com/images/logo.gif') {
                if (!$image_data['link']) {
                    $image_data['link'] = $channel_data['link'];
                }
                if (!$image_data['title']) {
                    $image_data['title'] = $channel_data['title'];
                }
                if (!isset($image_data['description'])) {
                    if ($channel_data['description']) {
                        $image_data['description'] = $channel_data['description'];
                    } else {
                        $image_data['description'] = 'No description provided...';
                    }
                }
                if (!isset($image_data['width'])) {
                    $image_data['width'] = 88;
                }
                if (!isset($image_data['height'])) {
                    $image_data['height'] = 31;
                }
                if ($args['altstyle']) {
                    $content .= "<a class=\"pn-normal\" href=\"{$image_data['link']}\" target=\"_blank\" title=\"{$image_data['description']}\">\n" . "<img src=\"{$image_data['url']}\" border=\"0\" alt=\"{$image_data['title']}\" width=\"{$image_data['width']}\" height=\"{$image_data['height']}\"></a>\n" . "<br>\n";
                } else {
                    $content .= "<div align=\"center\" style=\"text-align:center\"><a class=\"pn-normal\" href=\"{$image_data['link']}\" target=\"_blank\" title=\"{$image_data['description']}\">\n" . "<img src=\"{$image_data['url']}\" border=\"0\" alt=\"{$image_data['title']}\" width=\"{$image_data['width']}\" height=\"{$image_data['height']}\"></a>\n" . "</div>";
                }
            }
        }
    }
    // pub date
    if (isset($channel_data['pubDate'])) {
        $content .= "<div align=\"center\" style=\"text-align:center\">\n" . "<b>({$channel_data['pubDate']})</b></div>";
    }
    // items
    if ($total_items > $args['maxitems']) {
        // we don't want a bunch of empty item spaces
        $total_items = $args['maxitems'];
    }
    for ($i = 0; $i < $total_items; $i++) {
        if ($i) {
            if ($args['altstyle']) {
                $content .= "\n";
            } else {
                $content .= "<hr noshade size=\"1\" width=\"50%\">\n";
            }
        }
        if (empty($item_data[$i]['title'])) {
            $item_data[$i]['title'] = '<i>[no title]</i>';
        }
        // cocomp 2002/07/13 prevent E_ALL errors check for $item_data[$i]['link']
        if (isset($item_data[$i]['link'])) {
            if ($args['altstyle']) {
                $content .= '<font class="pn-normal"><strong><big>&middot;</big></strong>&nbsp;</font><a class="pn-normal" href="' . $item_data[$i]['link'] . '" title="' . $item_data[$i]['title'] . '" target="_blank">' . $item_data[$i]['title'] . '</a><br>';
            } else {
                $content .= '<a href="' . $item_data[$i]['link'] . '" title="' . $item_data[$i]['title'] . '" target="_blank" class="pn-normal">' . $item_data[$i]['title'] . '</a><br>';
            }
        }
        if (!empty($args['showdescriptions']) && isset($item_data[$i]['description'])) {
            $content .= '<font class="pn-normal"><i>' . $item_data[$i]['description'] . '</i></font><br>';
        }
    }
    // search
    if (!empty($args['showsearch'])) {
        if (isset($search_data['link']) && isset($search_data['name']) && isset($search_data['title'])) {
            if ($args['altstyle']) {
                $content .= '<br>';
            } else {
                $content .= '<hr noshade size="1" width="50%">';
            }
            $content .= "<center><form method=\"get\" action=\"{$search_data['link']}\" target=\"_blank\">\n";
            if ($search_data['description']) {
                $content .= htmlspecialchars($search_data['description']) . '<br>';
            }
            $content .= "<input type=\"text\" name=\"{$search_data['name']}\" size=\"15\"><br><input type=\"submit\" value=\"{$search_data['title']}\"></form></center>\n";
        }
        // copyright
        if (isset($channel_data['copyright'])) {
            $content .= "<font class=\"pn-normal\">{$channel_data['copyright']}</font>\n";
        }
        // done with rdf file
        if ($args['altstyle']) {
            $content .= "<br><a class=\"pn-normal\" href=\"{$channel_data['link']}\" target=\"_blank\"><b>_RSSREADMORE</b></a>\n";
        } else {
            $content .= "<div align=\"right\" style=\"text-align:right\"><a class=\"pn-normal\" href=\"{$channel_data['link']}\" target=\"_blank\"><b>_RSSREADMORE</b></a></div>\n";
        }
        $content = "<font class=\"pn-normal\">{$content}</font>\n";
    }
    $args['headlines'] = $content;
    $row['content'] = pnBlockVarsToContent($args);
    $column =& $pntable['blocks_column'];
    // cocomp 2002/07/13 cross db compatibility - changed now() to DBTimestamp
    $sql = "UPDATE {$pntable['blocks']}\n            SET {$column['content']}='" . pnVarPrepForStore($row['content']) . "',\n                {$column['last_update']}=" . $dbconn->DBTimestamp(time()) . "\n            WHERE {$column['bid']}=" . pnVarPrepForStore($row['bid']);
    $result = $dbconn->Execute($sql);
    if ($dbconn->ErrorNo() != 0) {
        $row['title'] .= ' *';
    }
    return $row;
}
Esempio n. 5
0
function blocks_past_update($row)
{
    $vars['limit'] = pnVarCleanFromInput('limit');
    $row['content'] = pnBlockVarsToContent($vars);
    return $row;
}
Esempio n. 6
0
function blocks_stories_update($row)
{
    list($vars['storiestype'], $vars['topic'], $vars['category'], $vars['limit']) = pnVarCleanFromInput('storiestype', 'topic', 'category', 'limit');
    $row['content'] = pnBlockVarsToContent($vars);
    return $row;
}