News Feed
  • DrugHub has agreed to fully refund all users who lost money in the SuperMarket exit scam.  
  • Retro Market has gone offline. Circumstances of the closure unknown.  
  • SuperMarket has closed following an exit scam by one of the admins.  
  • The admin of Incognito Market, Pharoah, has been arrested by the FBI several months after exit scamming.  
  • Silk RoadTorhoo mini logo
  • darknet markets list
  • Popular P2P exchange LocalMonero has announced it is closing.  

Dread Programming Challenge: POST COMMENTS/WIKI PAGES : programming | Torhoo darknet markets

There is an issue with our BBCODE implementation; it's fucking complex and prone to bugs. One of the main parts of the BBCODE process is the ability to easily parse text like https://torhoo.cc/go.php?u=TDNCdmMzUXZPREZsTkRWbE4yRTBObU5sWTJGbE5XSTFORGs9# and have it go to the page. However when you add in a comment permalink (like https://torhoo.cc/go.php?u=TDNCdmMzUXZPREZsTkRWbE4yRTBObU5sWTJGbE5XSTFORGs9#/#c-532179bdc2f3a30da5 ) that seamlessness goes away. It only parses the /post/[hash] not the /post/[hash]/#c-[hash]

So here's the task. Help us solve this BBCODE issue and get $200, a star trophy (no more captchas after login), and enough dread store credit for a year of membership. The first one to do it and post the solution, in PHP, for the following input output wins it. Try to use regex for matching and don't match just the specific text itself.

IN:
This is an example post which has a valid post https://torhoo.cc/go.php?u=TDNCdmMzUXZPREZsTkRWbE4yRTBObU5sWTJGbE5XSTFORGs9# (hexadecimal hash [0-9a-fA-F] of 20 chars), an invalid post /post/thisisnotarealpost, a post with comment https://torhoo.cc/go.php?u=TDNCdmMzUXZPREZsTkRWbE4yRTBObU5sWTJGbE5XSTFORGs9#/#c-532179bdc2f3a30da5 (comment hextadecimal hash of 18 chars [0-9a-fA-F]), a couple invalid post comment https://torhoo.cc/go.php?u=TDNCdmMzUXZPREZsTkRWbE4yRTBObU5sWTJGbE5XSTFORGs9#/#c-notrealcommenthere /post//#c-notrealcommenthere 

This is an example wikipage https://torhoo.cc/go.php?u=TDJRdlJISmxZV1F2ZDJscmFUOXBaRDB3WmpBMU1UbGhZZz09# (wiki hexadecimal hash of 8 chars [0-9a-fA-F]), This here are a few invalid wikipages https://torhoo.cc/go.php?u=TDJRdlJISmxZV1F2#wiki?id=notreal /d//wiki?id=0f0519ab https://torhoo.cc/go.php?u=TDJRdlJISmxZV1F2#wiki
OUT:
This is an example post which has a valid post <a href="https://torhoo.cc/go.php?u=TDNCdmMzUXZPREZsTkRWbE4yRTBObU5sWTJGbE5XSTFORGs9#">https://torhoo.cc/go.php?u=TDNCdmMzUXZPREZsTkRWbE4yRTBObU5sWTJGbE5XSTFORGs9#</a> (hexadecimal hash [0-9a-fA-F] of 20 chars), an invalid post /post/thisisnotarealpost, a post with comment <a href="https://torhoo.cc/go.php?u=TDNCdmMzUXZPREZsTkRWbE4yRTBObU5sWTJGbE5XSTFORGs9#/#c-532179bdc2f3a30da5">https://torhoo.cc/go.php?u=TDNCdmMzUXZPREZsTkRWbE4yRTBObU5sWTJGbE5XSTFORGs9#/#c-532179bdc2f3a30da5</a> (comment hextadecimal hash of 18 chars [0-9a-fA-F]), a couple invalid post comment https://torhoo.cc/go.php?u=TDNCdmMzUXZPREZsTkRWbE4yRTBObU5sWTJGbE5XSTFORGs9#/#c-notrealcommenthere /post//#c-notrealcommenthere 

This is an example wikipage <a href="https://torhoo.cc/go.php?u=TDJRdlJISmxZV1F2ZDJscmFUOXBaRDB3WmpBMU1UbGhZZz09#">https://torhoo.cc/go.php?u=TDJRdlJISmxZV1F2ZDJscmFUOXBaRDB3WmpBMU1UbGhZZz09#</a> (wiki hexadecimal hash of 8 chars [0-9a-fA-F]), This here are a few invalid wikipages https://torhoo.cc/go.php?u=TDJRdlJISmxZV1F2#wiki?id=notreal /d//wiki?id=0f0519ab https://torhoo.cc/go.php?u=TDJRdlJISmxZV1F2#wiki

/u/BigBossChefOfArchetyp P
2 points
1 year ago
I have sent you a PM.

The regex is basically just this:
~\/post\/([0-9a-fA-F]{20})((\/\#c\-[0-9a-fA-F]{18}))?~s
/u/Fyodor-MD
2 points
1 year ago
goodmorning pairs i love you
/u/Pneumonia P
1 points
1 year ago
Has this been solved already or can still submit some work around?
It's all solved.
/u/AbraCadaver P
1 points
1 year ago

1
Awards Received
Doge
1
Im still getting strange links. Was just in /d/test4pay and the links to the info pages are not working. They are like
/post/<hash>
and this is what the link contents look like:
http://<url>.onion/post/<a href=
. Not sure if regex related but wanted to let you know.
/u/Paris 📢 A ⎝⎝✧GͥOͣDͫ✧⎠⎠
2 points
1 year ago

1
Awards Received
Diamond
1
Oh that's because they are wrapping it in a URL tag. Didn't even think someone would put in that kind of effort. I'll add in a capture group to prevent doubling up href tags.
/u/UKDistribution
0 points
1 year ago*
The problem is that the regex is counting the # as a delimiter you need to adjust your regex accordingly,

For example.

<?php

$input = "This is an example post which has a valid post https://torhoo.cc/go.php?u=TDNCdmMzUXZPREZsTkRWbE4yRTBObU5sWTJGbE5XSTFORGs9#, an invalid post /post/thisisnotarealpost, a post with comment https://torhoo.cc/go.php?u=TDNCdmMzUXZPREZsTkRWbE4yRTBObU5sWTJGbE5XSTFORGs9#/#c-532179bdc2f3a30da5, and a few invalid post comments https://torhoo.cc/go.php?u=TDNCdmMzUXZPREZsTkRWbE4yRTBObU5sWTJGbE5XSTFORGs9#/#c-notrealcommenthere /post//#c-notrealcommenthere.

Also, here's an example wikipage https://torhoo.cc/go.php?u=TDJRdlJISmxZV1F2ZDJscmFUOXBaRDB3WmpBMU1UbGhZZz09# and a few invalid ones: https://torhoo.cc/go.php?u=TDJRdlJISmxZV1F2#wiki?id=notreal /d//wiki?id=0f0519ab https://torhoo.cc/go.php?u=TDJRdlJISmxZV1F2#wiki.";
$output = preg_replace('~\/post\/([0-9a-fA-F]{20}/#c-[0-9a-fA-F]{18})~', '<a href="/post/$1">/post/$1</a>', $input);
$output = preg_replace('~\/post\/([0-9a-fA-F]{20})~', '<a href="/post/$1">/post/$1</a>', $output);
$output = preg_replace('~\/d\/Dread\/wiki\?id=([0-9a-fA-F]{8})~', '<a href="https://torhoo.cc/go.php?u=TDJRdlJISmxZV1F2#wiki?id=$1">https://torhoo.cc/go.php?u=TDJRdlJISmxZV1F2#wiki?id=$1</a>', $output);

echo $output;

?>


And it will output correctly the full hyperlink of it.

This is an example post which has a valid post <a href="https://torhoo.cc/go.php?u=TDNCdmMzUXZPREZsTkRWbE4yRTBObU5sWTJGbE5XSTFORGs9#">https://torhoo.cc/go.php?u=TDNCdmMzUXZPREZsTkRWbE4yRTBObU5sWTJGbE5XSTFORGs9#</a>, an invalid post /post/thisisnotarealpost, a post with comment <a href="https://torhoo.cc/go.php?u=TDNCdmMzUXZPREZsTkRWbE4yRTBObU5sWTJGbE5XSTFORGs9#/#c-532179bdc2f3a30da5">https://torhoo.cc/go.php?u=TDNCdmMzUXZPREZsTkRWbE4yRTBObU5sWTJGbE5XSTFORGs9#/#c-532179bdc2f3a30da5</a>, and a few invalid post comments https://torhoo.cc/go.php?u=TDNCdmMzUXZPREZsTkRWbE4yRTBObU5sWTJGbE5XSTFORGs9#/#c-notrealcommenthere /post//#c-notrealcommenthere.

Also, here's an example wikipage <a href="https://torhoo.cc/go.php?u=TDJRdlJISmxZV1F2ZDJscmFUOXBaRDB3WmpBMU1UbGhZZz09#">https://torhoo.cc/go.php?u=TDJRdlJISmxZV1F2ZDJscmFUOXBaRDB3WmpBMU1UbGhZZz09#</a> and a few invalid ones: https://torhoo.cc/go.php?u=TDJRdlJISmxZV1F2#wiki?id=notreal /d//wiki?id=0f0519ab https://torhoo.cc/go.php?u=TDJRdlJISmxZV1F2#wiki.
Very close to getting the $200. Just got to correct your wiki preg_replace to not match the the specific dread wiki text itself. /d/[subdreadname]/wiki?id=[wikiid]
/u/UKDistribution
1 points
1 year ago*
Here you go boss, this should now do as you desire!

<?php

$input = "This is an example post which has a valid post https://torhoo.cc/go.php?u=TDNCdmMzUXZPREZsTkRWbE4yRTBObU5sWTJGbE5XSTFORGs9#, an invalid post /post/thisisnotarealpost, a post with comment https://torhoo.cc/go.php?u=TDNCdmMzUXZPREZsTkRWbE4yRTBObU5sWTJGbE5XSTFORGs9#/#c-532179bdc2f3a30da5, and a few invalid post comments https://torhoo.cc/go.php?u=TDNCdmMzUXZPREZsTkRWbE4yRTBObU5sWTJGbE5XSTFORGs9#/#c-notrealcommenthere /post//#c-notrealcommenthere.

Also, here's an example wikipage https://torhoo.cc/go.php?u=TDJRdlJISmxZV1F2ZDJscmFUOXBaRDB3WmpBMU1UbGhZZz09# and a few invalid ones: https://torhoo.cc/go.php?u=TDJRdlJISmxZV1F2#wiki?id=notreal /d//wiki?id=0f0519ab https://torhoo.cc/go.php?u=TDJRdlJISmxZV1F2#wiki.";

$output = preg_replace('~\/post\/([0-9a-fA-F]{20}/#c-[0-9a-fA-F]{18})~', '<a href="/post/$1">/post/$1</a>', $input);
$output = preg_replace('~\/post\/([0-9a-fA-F]{20})~', '<a href="/post/$1">/post/$1</a>', $output);
$output = preg_replace('~\/d\/([^\/]+)/wiki\?id=([0-9a-fA-F]{8})~', '<a href="/d/$1/wiki?id=$2">/d/$1/wiki?id=$2</a>', $output);

echo $output;

?>
It's close enough for the solution. Pass me your XMR address.
/u/UKDistribution
1 points
1 year ago
Messaged 🤙
/u/codeless Moderator
1 points
1 year ago*
I believe with this solution you're going to end up with output of "<a href="<a href="/post/..." on the post comment links because they get changed to the link, but then the second preg_replace() doesn't know it's been changed into a link and it does a replace on /post/XX again. It will also create a second link for it, because of the copy of it between the <a> tags.

This should sort it out:

$output = preg_replace('/\/post\/([0-9a-fA-F]{20}\/#c-[0-9a-fA-F]{18})/', '<a href="/post/$1">/post/$1</a>', $output);
$output = preg_replace('/([\s.,!0-0a-fA-F])\/post\/([0-9a-fA-F]{20})/', '$1<a href="/post/$2">/post/$2</a>', $output);
This checks that there is either a space, full stop, comma, exclamation mark, number, or letter before "/post". Because after the first conversion there is a " and > before it so we don't want that. It then puts that character that got matched at the start back where it was before the <a. Also the wiki regex has a bug and if you write something with spaces like "/d/ invalid /wiki?id=123456ab" it will turn it into a link. Better to filter with letters/numbers like:
$output = preg_replace('/\/d\/([0-9a-zA-Z]+)\/wiki\?id=([0-9a-fA-F]{8})/', '<a href="/d/$1/wiki?id=$2">/d/$1/wiki?id=$2</a>', $output);
/u/BigBossChefOfArchetyp P
2 points
1 year ago
Or just use my regex which is obviously the best regex posted because it's literally just one (1) regex instead of two, which means we save time on every single execution.

~\/post\/([0-9a-fA-F]{20})((\/\#c\-[0-9a-fA-F]{18}))?~s

((\/\#c\-[0-9a-fA-F]{18}))? -> can exist or not so both will work:

/post/id
/post/id/#c-id

/u/Paris, where is my gold star
/u/codeless Moderator
1 points
1 year ago
Yes indeed:

$output = preg_replace('/\/post\/([0-9a-fA-F]{20})((\/\#c\-[0-9a-fA-F]{18}))?/', '<a href="/post/$1$2">/post/$1$2</a>', $output);
/u/UKDistribution
1 points
1 year ago
Just sent you a dm to solve the /d/Dread ones not hyperlinking.
/u/codeless Moderator
1 points
1 year ago
I just noticed in this comment /post/b13e7f50da740d751b4d/#c-f19e982c9bf0eaffd5 they posted a link to a comment in the formst /?p=1#c- .. not sure how they ended up with a page number in there, but if that needs to be checked for and allowed to turn into a link the regex would need to be updated to check for that with an or:

$output = preg_replace('/\/post\/([0-9a-fA-F]{20})(\?p=[1-9]\#c\-[0-9a-fA-F]{18}|\/\#c\-[0-9a-fA-F]{18})?/', '<a href="/post/$1$2">/post/$1$2</a>', $input);
Comments shouldn't have pagination anymore. But in the past there was some so I should probably update it to include that case.

/\/post\/([0-9a-fA-F]{20})(\/)?(\?p=[0-9]+)?(\#c\-[0-9a-fA-F]{18})?/

should cover all cases.
/u/codeless Moderator
1 points
1 year ago
Cool, yes and it wasn't even a thread that would be long enough for any pagination.
/u/BigDaddy2K
2 points
1 year ago
Nice Dub
/u/UKDistribution
2 points
1 year ago
Still waiting on my credits and captchaless 😜 had the $200 though so can't complain