Jump to content

Nico Knoll

PW-Moderators
  • Posts

    1,835
  • Joined

  • Last visited

  • Days Won

    21

Everything posted by Nico Knoll

  1. Just for inspiration: My version of an URL-Shortener (kind of older code previously featured on my blog): require_once('database.class.php'); $db = new database('localhost', '', '', ''); $pass = '123'; $base_url = 'http://go.nico.is/'; function is_url($url) { if(!preg_match("#^http(s)?://[a-z0-9-_.]+\.[a-z]{2,4}#i", $url)) { return false; } else { return true; } } function url_encrypt($id) { $codeset = "0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"; $base = strlen($codeset); $converted = ""; while ($id > 0) { $converted = substr($codeset, ($id % $base), 1) . $converted; $id = floor($id/$base); } return $converted; } function url_decrypt($converted) { $codeset = "0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"; $base = strlen($codeset); $c = 0; for ($i = strlen($converted); $i; $i--) { $c += strpos($codeset, substr($converted, (-1 * ( $i - strlen($converted) )),1)) * pow($base,$i-1); } return $c; } if($_GET['do'] != '' && isset($_GET['url']) && $_GET['pass'] == $pass) { $url = rawurldecode($_GET['url']); if($_GET['do'] == 'remove') { if($db->delete('urls', '`url`=\''.$url.'\'')) { $note = 'true'; } else { $note = 'false'; } } elseif($_GET['do'] == 'stats') { $note = (($db->get_element('urls', 'stats', '`url`=\''.$url.'\'')) ? $db->get_element('urls', 'stats', '`url`=\''.$url.'\'') : '0'); } elseif($_GET['do'] == 'add') { if(!$db->get_element('urls', 'converted', '`url`=\''.$url.'\'')) { $id = $db->get_next_id('urls'); if($db->insert('urls', array('id' => $id, 'url' => $url, 'converted' => $converted, 'stats' => 0))) { $note = $base_url.url_encrypt($id); } else { $note = 'false'; } } else { $note = $base_url.$db->get_element('urls', 'converted', '`url`=\''.$url.'\''); } } } elseif(isset($_GET['converted'])) { $id = url_decrypt($_GET['converted']); $url = $db->get_element('urls', 'url', '`id`=\''.$id.'\''); $db->update('urls', array('stats' => ((int)$db->get_element('urls', 'stats', '`id`=\''.$id.'\'') + 1)), '`id`=\''.$id.'\''); header('HTTP/1.1 301 Moved Permanently'); header('Location: '.$url); exit; } if($note != '') { echo $note; }
  2. Nico Knoll

    New pw site

    Really nice! I like German sites But I may would make the navigation background kind of another color. Like #fff for example...
  3. Hey, congrats to every EU member of this forum. We won the "Nobel Peace Prize" Sorry american guys but maybe you sometime will win some kind of Nobel Prize too
  4. I think some parts of config.php should be "translatable" in a language file. So if you're using the german pack the default timezone, etc. should change automatically
  5. I'm just looking for a better way for my preview solution
  6. Hey, there are a lot of good posts that I would love to like but I "have reached my like limit" in this forum for today... Could someone - Pete - change this? / Nico
  7. I would help to because I need a shopping solution for a german client too
  8. Nico Knoll

    Mootools

    I've used MooTools before jQuery like Pete. But jQuery is much nicer I guess. And easier to handle
  9. Hey, is it possible to save the whole pagearray for a page in $session? Or at least a whole regular array? Greets, Nico
  10. What I need is a sticker for my MacBook
  11. I should hide a secret in my profile picture too
  12. Nice. Thank you guys for quick infos
  13. Nico Knoll

    Speed test

    Hey, I once saw a post about some extreme tests with processwire like more than 100,000 pages etc. But I can't find it anymore so my questions are: - how fast is processwire with like 1,000,000 pages - is it possible to split it on two servers (when the traffic should be to huge for one) - ... I'm working on a network about music videos (@renobird knows what I'm talking about ) and it might get really huge... / Nico
  14. Oh, ok, then I guess something has to be changed in the core by ryan. Alternatively you could use a regular text field for it...
  15. Instead of using $_GET you should use $input->get->. It's like: $_GET['title'] //same as $input->get->title The difference is that $input->get is safe. So no mysql injections and that stuff Edit: I think I misunderstood you're question
  16. Hi, I created a field called "files" with the pagetype "file" (or so). I added "exe" to the allowed upload formats ("Valid File Extensions"). But if I'm trying to upload .exe it says: - seminare.exe - Invalid file extension, please use one of: pdf, doc, docx, xls, xlsx, gif, jpg, jpeg, png, mov, exe, zip, m4v, dmg How can I solve this? / Nico
  17. OK. I will release a new version in the next week. Because I have holidays - means enough time - then
  18. Hi, I'm getting this error: Is there a way to raise the max file size? Greets, Nico
  19. Added it to the module-section: http://modules.processwire.com/modules/markup-shortcodes/
  20. I would love to have prefixes... Or at least the opportunity to chose if I want them or not in the "config.php"...
  21. Hey, one client of mine has a host with only one database but wants to run two different sites on different subdomains. I would love to use processwire for him but it isn't possible to use database tables with prefixes I think... That's why I would love to have the option - for example in config.php - to chose a prefix if needed... Greets, Nico
×
×
  • Create New...