Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php // I get the following error when replacing any content with [img] tags:
- // ( ! ) Notice: Undefined offset: 1 in C:\wamp64\www\inc\core.php on line 65
- $_SQL = mysqli_connect("localhost", "root", "l0ljklol", "main");
- session_start();
- if(!empty($_SESSION['uname'])) {
- $grabCurrentUser = $_SQL->query("SELECT * FROM users WHERE id = '".$_SESSION['uid']."'");
- $currentUser = $grabCurrentUser->fetch_assoc();
- $_USER['id'] = $_SESSION['uid'];
- $_USER['name'] = $_SESSION['uname'];
- $_USER['group'] = $_SESSION['group'];
- $_USER['email'] = $_SESSION['email'];
- $_USER['password'] = $_SESSION['password'];
- $_USER['img'] = $currentUser['avatar'];
- $_USER['slogan'] = $currentUser['slogan'];
- $_USER['alias'] = $currentUser['alias'];
- $_USER['theme'] = $currentUser['theme'];
- $_SESSION['theme'] = $_USER['theme'];
- }
- function isImage($url)
- {
- $params = array('http' => array(
- 'method' => 'HEAD'
- ));
- $ctx = stream_context_create($params);
- $fp = @fopen($url, 'rb', false, $ctx);
- if (!$fp)
- return false; // Problem with url
- $meta = stream_get_meta_data($fp);
- if ($meta === false)
- {
- fclose($fp);
- return false; // Problem reading data from url
- }
- $wrapper_data = $meta["wrapper_data"];
- if(is_array($wrapper_data)){
- foreach(array_keys($wrapper_data) as $hh){
- if (substr($wrapper_data[$hh], 0, 19) == "Content-Type: image") // strlen("Content-Type: image") == 19
- {
- fclose($fp);
- return true;
- }
- }
- }
- fclose($fp);
- return false;
- }
- function dateConvert($string) {
- return date('m-d-Y \a\t h:i:s', strtotime($string));
- }
- function bb_parse($string) {
- $tags = 'b|i|size|color|center|quote|url|img';
- while (preg_match_all('`\[('.$tags.')=?(.*?)\](.+?)\[/\1\]`', $string, $matches)) foreach ($matches[0] as $key => $match) {
- list($tag, $param, $innertext) = array($matches[1][$key], $matches[2][$key], $matches[3][$key]);
- switch ($tag) {
- case 'b': $replacement = "<strong>$innertext</strong>"; break;
- case 'u': $replacement = "<u>$innertext</u>"; break;
- case 'i': $replacement = "<em>$innertext</em>"; break;
- case 'size': $replacement = "<span style=\"font-size: $param;\">$innertext</span>"; break;
- case 'color': $replacement = "<span style=\"color: $param;\">$innertext</span>"; break;
- case 'center': $replacement = "<div class=\"centered\">$innertext</div>"; break;
- case 'quote': $replacement = "<blockquote>$innertext</blockquote>" . $param? "<cite>$innertext</cite>" : ''; break;
- case 'url': $replacement = '<a href="' . ($param? $param : $innertext) . "\">$innertext</a>"; break;
- case 'img':
- list($width, $height) = preg_split('`[Xx]`', $param);
- $replacement = "<img " .(isImage($innertext)? "src=\"$innertext\" " : '') . (is_numeric($width)? "width=\"$width\" " : '') . (is_numeric($height)? "height=\"$height\" " : '') . 'style="max-width:80%;" />';
- break;
- case 'video':
- $videourl = parse_url($innertext);
- parse_str($videourl['query'], $videoquery);
- if (strpos($videourl['host'], 'youtube.com') !== FALSE) $replacement = '<embed src="http://www.youtube.com/v/' . $videoquery['v'] . '" type="application/x-shockwave-flash" width="425" height="344"></embed>';
- if (strpos($videourl['host'], 'google.com') !== FALSE) $replacement = '<embed src="http://video.google.com/googleplayer.swf?docid=' . $videoquery['docid'] . '" width="400" height="326" type="application/x-shockwave-flash"></embed>';
- break;
- }
- $string = str_replace($match, $replacement, $string);
- }
- return $string;
- }
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement