Jump to content

Dragen

Members
  • Posts

    1,154
  • Joined

  • Last visited

    Never

Everything posted by Dragen

  1. Hi, I'm currently using my own BBCode to create bullet point liists (<ul><li>). I've got two preg replace calls to turn the code into the HTML lists: (\[list\](<br />)*(.+?)\[/list\](<br />)*)s which finds the [list][/list] block and replaces it with <ul></ul> (\[\*\](.+?)(<br />)+) which finds [*] and the following text and creates the <li></li> For example, the following text: [list] [*]list item 1 [*]list item 2 [*]list item 3 [/list] would become: <ul> <li>list item 1</li> <li>list item 2</li> <li>list item 3</li> </ul> The problem I've got is that I need to be able to capture any newline characters within the BBCode [*] section. At the moment, if I try to add a newline in the list it doesn't create the <li></li> properly, it adds the </li> at the newline, when I only want the </li> added on the last newline character: [list] [*]item list 1 [/list] currently creates: <ul> <li>item</li> list 1 </ul> When it should be: <ul> <li>item<br /> list 1</li> </ul> I've got another part which changes all newlines to <br />, I just need the list part to ignore all, but the last newline in the [*] section. I need to somehow change this regex to do this: (\[\*\](.+?)(<br />)+) I've been working on it for ages and it's just evaded me, any help would be brilliant!!
  2. Hi, I've just tried it on my Vista laptop in ie and it works fine. It must be a problem on your end with ie. Perhaps you have ajax disabled or similar?
  3. ah okies. I tested it on xp, but I'll give it a go on my Vista machine later and let you know!
  4. Thanks for the feedback! I've fixed that problem and a couple of others that you found, such as an item not being displayed if it contains strange characters in the name. Can anyone find any other problems?
  5. Hi, After a very long time working on my online shop I'm finally ready to release it, but need to see how secure it is first. Can anyone please see if the site has any sql etc exploits or anything. I've currently got error_reporting set to 'E_ALL' for testing purposes, but that will be changed on release. Here's the uri: http://www.gimpcrafts.co.uk/ If you don't want to register your own account, you can use these details: username: dummy Password: Account1 (Note the capital 'A')
  6. I really need some help on this, if anyone has any suggestions?
  7. do you mean something like this? for($i = 0; $i < 10; $i++){ echo $_POST[$i] . '<br />'; } Or: foreach($_POST as $k => $v){ echo $k . ' = ' . $v . '<br />'; }
  8. <li class="<?php ((1 == $comment->user_id) ? echo 'authcomment' : 'othrcomment'); ?>" id="comment-<?php comment_ID() ?>"> <li class="<?php ((1 != $comment->user_id) ? echo 'authcomment' : 'othrcomment'); ?>" id="comment-<?php comment_ID() ?>"> EDIT: Barand got their first..
  9. can anyone help me with this? I've asked on the Paypal Developers forum, but none of the moderators (or members) seem to know or have a definite answer. None of them could even tell me if using Curl should work or not.. EDIT: If anyone's interested in my Curl code: <?php $paypal = 'dragen@gimppro.co.uk'; $vars = 'upload=1&cmd=_cart&business=' . $paypal . '&currency_code=GBP'; $i = 1; foreach($_SESSION['basket']['pay_sec'][$_POST['id']]['items'] as $id => $items){ $vars .= '&item_name_' . $i . '=' . $items['name']; $vars .= '&amount_' . $i . '=' . $items['price']; $vars .= '&quantity_' . $i . '=' . $items['quantity']; $i++; } $vars = urlencode($vars); $ch = curl_init(); curl_setopt($ch,CURLOPT_URL, 'https://www.paypal.com/cgi-bin/webscr'); curl_setopt($ch, CURLOPT_FAILONERROR, false); curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0); curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0); curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); curl_setopt($ch, CURLOPT_HTTPHEADER, array("Content-type: text/html")); curl_setopt($ch, CURLOPT_POST, true); curl_setopt($ch, CURLOPT_POSTFIELDS, $vars); $res = curl_exec($ch); curl_close($ch); if($res === false){ echo 'false'; }else{ echo 'true'; print_r($res); } ?> And that just outputs the Paypal homepage for some reason, when it should output the checkout page. I am aware that displaying the paypal page inside my own makes it seems like a phising site, but I'm only displaying it for testing purposes. My aim is to upload my items and re-direct to the Paypal page.
  10. Hi, I'm trying to integrate my custom shop with paypals payment options. What I'm trying is to use the shopping cart 'upload' facility: https://www.paypal.com/IntegrationCenter/ic_standard_home.html#individual Unfortunately Paypal seem to have a block on using Curl or Fopen etc, by checking that the url is from Paypal. To try and get around this I was looking into the Header and found this topic: http://www.pdncommunity.com/pdn/board/message?board.id=basicpayments&message.id=3393 I've been trying to get this to work, but instead it just tries to download a file instead. Here's the code I'm using: <?php $paypal = 'dragen@gimppro.co.uk'; $vars = 'upload=1&cmd=_cart&business=' . $paypal . '&currency_code=GBP'; $i = 1; foreach($_SESSION['basket']['pay_sec'][$_POST['id']]['items'] as $id => $items){ $vars .= '&item_name_' . $i . '=' . $items['name']; $vars .= '&amount_' . $i . '=' . $items['price']; $vars .= '&quantity_' . $i . '=' . $items['quantity']; $i++; } $host = "www.paypal.com";//'www.sandbox.paypal.com'; $path = "/cgi-bin/webscr"; $vars = urlencode($vars); header("POST " . $path . " HTTP/1.1"); header("Host: " . $host); header("Content-Type: application/x-www-form-urlencoded"); header("Content-length: " . strlen($vars)); header("Connection: close"); header($vars); ?>
  11. thanks. Looks good, I'll definitely bookmark it
  12. brilliant! thank you. Do you know of any sites that list all of the regex modifiers? I've tried googling and didn't really find anything.
  13. oh, okay. So does the e modifier just allow the use of functions and things then?
  14. thanks kev. It's similar to what I'm now using, although it does something quite different (mainly replacing < and > instead of [ and ]). I think my code is better for my needs and works fine. Thanks for the info though!
  15. Okay I've got it working without using a separate function and a couple of preg_replaces: <?php function create($text, $order = 'id'){ $text = nl2br(htmlentities(trim($text))); if(is_array($codes = $this->collect())){ //this collects the bbcode regex from a database foreach($codes as $code){ //loops through each regex if($code['title'] == 'formatted text'){ //if it's the [code] then... preg_match_all($code['regex'], $text, $return, PREG_PATTERN_ORDER); //finds all the text within code blocks if(isset($return[1]) && is_array($return[1])){ for($i = 0; $i < count($return[1]); $i++){ $r[1] = str_replace(array('[', ']'), array('&#91;', '&#93;'), $return[1][$i]); //then replaces all of the bbcode brackets inside $r[0] = str_replace(array('[', ']'), array('\[', '\]'), $return[1][$i]); //and adds slashes to the found text so I can use it in a regex to replace the text $text = preg_replace('|(\[code\])('.$r[0].')(\[/code\])|', '$1'.$r[1].'$3', $text, -1, $c); } } } $text = preg_replace($code['regex'], $code['replace'], $text); } }else{ $text = 'ERROR COLLECTING BBCODE!<br />' . $text; } return $text; } ?> [/code]
  16. thanks for the idea wildteen. I've been mucking about with that idea, but it seems as thouygh you can't pass a function through the replacement in preg_repace. If I use something like this: <?php function replace($text){ return str_replace(array('[', ']'), array('& #91;', '& #93;'), $text); } $text = '[ code]Add code here no [b]bbcode[/b] should get parsed[ /code]'; $text = preg_replace('(\[code\](.+?)\[/code\])s', "replace('$1')", $text); ?> what it actually outputs is this: ('Add code here no [b]bbcode[/b] should get parsed') Not it removes the function name, but keeps the brackets and ' for it and also doesn't call the function itself. I've tried several different variations of calling the function, including: $text = preg_replace('(\[code\](.+?)\[/code\])s', replace("$1"), $text); but that just passes the literal value $1 and not the preg_replace $1.
  17. htmlspecialchars isn't going to stop the bbcode being changed to html though. For example any [b]hello[/b] inside of a code tag will be changed to: <b>hello</b> unlike on this forum where it doesn't change bbcode placed within a code tag
  18. <? $title = 'this is a title..'; include("header.pho"); //page info here include("footer.pho"); ?>
  19. do it the other way around. Have each page include the header and footer. That way you can store the title ina variable on each page: <? include("header.pho"); ?> $title = 'this is a title..'; <? include("footer.pho"); ?> then in header.php: <html><head> <title><? echo $title; ?></title> </head> <body> SOME STATIC CONTENT HERE <div> and footer.php: </div> </body> </html>
  20. Okay, I'm trying to create a bbcode function, which I've got working perfectly except for the code box. At the moment I'm using this regex for it: (\[code\](.+?)\[/code\])s replacing it with this: <div class="code"><div class="head">code:</div><pre>$1</pre></div> Which works fine. The problem is that if the code text has any bbcode formatting inside it, it still formats it. For example: [code]hello this is [b]bold[/b] and this is a [link=google.com]link[/link] [/code] would create the code box, but also format the bold text and create the url link. How would I go about displaying them as text inside the code box, instead of formatting them, like it is with this website?
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.