'); } function ShowErrors ($_ERRORS) { if (sizeof($_ERRORS)>0) { $color = 'ff0000'; $ErrorCount = sizeof($_ERRORS)==1?'the following ERROR has been detected':'the following ERRORS have been detected'; // main error table $ErrorList = ''."\n"; $ErrorList .= ''."\n"; $ErrorList .= ''."\n"; $ErrorList .= ''."\n"; $ErrorList .= ''."\n"; $ErrorList .= '
'.$ErrorCount.':

    '."\n"; foreach ($_ERRORS as $error) { $ErrorList .= '
  • '.$error.'
  • '."\n"; } $ErrorList .= '
'."\n"; } return $ErrorList; } ?>'.$text.''; } function do_bbcode_event ($action, $attributes, $content, $params, $node_object) { $EID = $attributes['default']; $option = strtolower($content); if ($action == 'validate') { if (substr ($option, 0, 5) == 'data:' || substr ($option, 0, 5) == 'file:' || substr ($option, 0, 11) == 'javascript:' || substr ($option, 0, 4) == 'jar:') { return false; } return true; } if ($EID!='') { #------------------------------> GET EVENTDATA $result = safe_query("SELECT * FROM events WHERE ID='$EID' LIMIT 1"); while ($row = mysql_fetch_assoc($result)){ $event = $row; } #------------------------------> BUILD DATA $event_time = date('jS M Y H:i', $event['start']).'-'.date('H:i P', $event['end']).' GMT'; #------------------------------> QUERY RESULT OPTIONS #---------------> IMAGE if ($option=='img') { $return = ' Event Image: '.$event['ID'].''; } #---------------> ARTISTS elseif ($option=='artists') { $art_num = 3; $AIDS = explode('#@#', $event['AIDS']); $AIDcombine = explode('#@#', $event['AIDcombine']); foreach ($AIDS as $nr => $AID) { $result = safe_query("SELECT name FROM artists WHERE AID='$AID' LIMIT 1"); while ($row = mysql_fetch_assoc($result)){ $_ARTISTS[$nr] = $row; } } $tmp_artists = array (); for ($i=0;$i<$art_num;$i++) { $artistlist[] = $_ARTISTS[$i]['name']; if ($i != ($art_num-1)) { $artistlist[] = $AIDcombine[$i]; } } $return = implode(' ', $artistlist); } #---------------> GENRE elseif ($option=='genre') { $gen_num = 4; $GIDS = explode('#@#', $event['GIDS']); $GIDcombine = explode('#@#', $event['GIDcombine']); foreach ($GIDS as $nr => $GID) { $result = safe_query("SELECT genre FROM genre WHERE GID='$GID' LIMIT 1"); while ($row = mysql_fetch_assoc($result)){ $_GENRE[$nr] = $row; } } for ($i=0;$i<$gen_num;$i++) { $genrelist[] = $_GENRE[$i]['genre']; if ($i != ($gen_num-1)) { $genrelist[] = $GIDcombine[$i]; } } $return = implode(' ', $genrelist); } #---------------> TIME elseif ($option=='time') { $return = $event_time; } elseif ($option=='date') { $return = date('jS F Y', $event['start']); } elseif ($option=='start') { $return = date('H:i P', $event['start']).' GMT'; } elseif ($option=='end') { $return = date('H:i P', $event['end']).' GMT'; } elseif ($option=='title') { $return = $event['title']; } elseif ($option=='text') { $return = '

'.$event['text'].'

'; } elseif ($option=='link') { $return = ' '.$event['image'].'_thumb.png'; } else { $return = '

'; } } else { $return = '

'; } return ($return); } function do_bbcode_artist ($action, $attributes, $content, $params, $node_object) { if (!isset ($attributes['default'])) { $AID = $content; $type = $attributes['type']; $post = $attributes['post'];; } else { $url = $attributes['default']; $text = $content; } if ($action == 'validate') { if (substr ($url, 0, 5) == 'data:' || substr ($url, 0, 5) == 'file:' || substr ($url, 0, 11) == 'javascript:' || substr ($url, 0, 4) == 'jar:') { return false; } return true; } $value = $_VALUES[$type][$post]; if (isset ($AID)) { $result = safe_query("SELECT * FROM artists WHERE AID='$AID' LIMIT 1"); while ($row = mysql_fetch_assoc($result)){ $data=$row; } } if ($type=='img') { if ($post=='news') { $return = ' '.$data['img_news'].''; } elseif ($post=='support') { $return = ' '.$data['support_img'].''; } elseif ($post=='list') { $return = ' '.$data['img_artist'].''; } else { $return = '

'; } } elseif ($type=='link') { if ($post=='support') { $return = ' '.$data['support_img'].''; } elseif ($post=='page') { $return = ' '.$data['img_artist'].''; } else { $return = '

'; } } else { $return = '

'; } # $_VALUES = array ( # 'img' => array ('suport' => 'support_img', 'news' => 'img_news','list' => 'img_artist'), # 'url' => array ('support' => 'suppprt_url', 'site' => ''), return $return; } function do_bbcode_size ($action, $attributes, $content, $params, $node_object) { if (!isset ($attributes['default'])) { $size = $content; $text = htmlspecialchars ($content); } else { $size = $attributes['default']; $text = $content; } if ($action == 'validate') { if (substr ($size, 0, 5) == 'data:' || substr ($size, 0, 5) == 'file:' || substr ($size, 0, 11) == 'javascript:' || substr ($size, 0, 4) == 'jar:') { return false; } return true; } $return = ''.$text.''; return $return; } function do_bbcode_color ($action, $attributes, $content, $params, $node_object) { if (!isset ($attributes['default'])) { $color = $content; $text = htmlspecialchars ($content); } else { $color = $attributes['default']; $text = $content; } if ($action == 'validate') { if (substr ($color, 0, 5) == 'data:' || substr ($color, 0, 5) == 'file:' || substr ($color, 0, 11) == 'javascript:' || substr ($color, 0, 4) == 'jar:') { return false; } return true; } return ''.$text.''; } function do_bbcode_align ($action, $attributes, $content, $params, $node_object) { if (!isset ($attributes['default'])) { $style = $content; $text = htmlspecialchars ($content); } else { $style = $attributes['default']; $text = $content; } if ($action == 'validate') { if (substr ($style, 0, 5) == 'data:' || substr ($style, 0, 5) == 'file:' || substr ($style, 0, 11) == 'javascript:' || substr ($style, 0, 4) == 'jar:') { return false; } return true; } return '
'.$text.'
'; } function do_bbcode_valign ($action, $attributes, $content, $params, $node_object) { if (!isset ($attributes['default'])) { $style = $content; $text = htmlspecialchars ($content); } else { $style = $attributes['default']; $text = $content; } if ($action == 'validate') { if (substr ($style, 0, 5) == 'data:' || substr ($style, 0, 5) == 'file:' || substr ($style, 0, 11) == 'javascript:' || substr ($style, 0, 4) == 'jar:') { return false; } return true; } return '
'.$text.'
'; } function do_bbcode_label ($action, $attributes, $content, $params, $node_object) { if (!isset ($attributes['default'])) { $label = $content; $text = htmlspecialchars ($content); } else { $label = $attributes['default']; $text = $content; } if ($action == 'validate') { if (substr ($label, 0, 5) == 'data:' || substr ($label, 0, 5) == 'file:' || substr ($label, 0, 11) == 'javascript:' || substr ($label, 0, 4) == 'jar:') { return false; } return true; } # return '
'.$text.'
'; return ''.$text.''; } function do_bbcode_youtube ($action, $attributes, $content, $params, $node_object) { if (!isset ($attributes['default'])) { $size = $content; $youtube = htmlspecialchars ($content); } else { $size = $attributes['default']; $youtube = $content; } if ($action == 'validate') { if (substr ($size, 0, 5) == 'data:' || substr ($size, 0, 5) == 'file:' || substr ($size, 0, 11) == 'javascript:' || substr ($size, 0, 4) == 'jar:') { return false; } return true; } $width = $size=='wide'?'580':'445'; $height = $size=='wide'?'360':'364'; $width = $size=='small'?'333':$width; $height = $size=='small'?'273':$height; $width = $size=='wide;small'?'435':$width; $height = $size=='wide;small'?'270':$height; $width = $size=='tiny'?'222':$width; $height = $size=='tiny'?'182':$height; $width = $size=='wide;tiny'?'290':$width; $height = $size=='wide;tiny'?'180':$height; $youtube = substr($youtube, strpos($youtube, '?v=')+3); $return = ''; return $return; } function do_bbcode_soundcloud ($action, $attributes, $content, $params, $node_object) { if (!isset ($attributes['default'])) { $mixID = $content; $soundcloud = htmlspecialchars ($content); } else { $mixID = $attributes['default']; $soundcloud = $content; } if ($action == 'validate') { if (substr ($mixID, 0, 5) == 'data:' || substr ($mixID, 0, 5) == 'file:' || substr ($mixID, 0, 11) == 'javascript:' || substr ($mixID, 0, 4) == 'jar:') { return false; } return true; } $height = '81'; $width = '100%'; $soundcloud = strstr($soundcloud, '#')?substr($soundcloud, 0, strrpos($soundcloud, '#')):$soundcloud; $song_link = $soundcloud; $song_name = str_replace('-', ' - ', substr($soundcloud, strrpos($soundcloud, '/')+1)); $artist_link = substr($soundcloud, 0, strrpos($soundcloud, '/')); $artist_name = str_replace('-', ' ', substr($artist_link, strrpos($artist_link, '/')+1, strlen($artist_link))); $return = '
'.$song_name.' by '.$artist_name.'
'; return $return; } function do_bbcode_mixcloud ($action, $attributes, $content, $params, $node_object) { if (!isset ($attributes['default'])) { $size = $content; $mixcloud = htmlspecialchars ($content); } else { $size = $attributes['default']; $tmp = explode('###', $content); $mixcloud = $tmp[0]; $title = $tmp[1]<>''?$tmp[1]:'this liveshow'; } if ($action == 'validate') { if (substr ($size, 0, 5) == 'data:' || substr ($size, 0, 5) == 'file:' || substr ($size, 0, 11) == 'javascript:' || substr ($size, 0, 4) == 'jar:') { return false; } return true; } $width = $size=='wide'?'480':'300'; $height = $size=='wide'?'300':'300'; $width = $size=='big'?'360':$width; $height = $size=='big'?'360':$height; $width = $size=='small'?'240':$width; $height = $size=='small'?'240':$height; $width = $size=='wide;big'?'580':$width; $height = $size=='wide;big'?'360':$height; $width = $size=='wide;small'?'386':$width; $height = $size=='wide;small'?'240':$height; $width = $size=='tiny'?'180':$width; $height = $size=='tiny'?'180':$height; $width = $size=='wide;tiny'?'290':$width; $height = $size=='wide;tiny'?'180':$height; $return = '

'.$title.' by Psychoradio on Mixcloud

'; return $return; } function do_bbcode_float ($action, $attributes, $content, $params, $node_object) { if (!isset ($attributes['default'])) { $option = $content; $text = htmlspecialchars ($content); } else { $option = $attributes['default']; $text = $content; } if ($action == 'validate') { if (substr ($option, 0, 5) == 'data:' || substr ($option, 0, 5) == 'file:' || substr ($option, 0, 11) == 'javascript:' || substr ($option, 0, 4) == 'jar:') { return false; } return true; } $position=explode(';', $option); $pos_x=16; $pos_y=16; $left=0; $right=$pos_x; $top=0; $bottom=$pos_y; if ($position[0] == 'left') { $left=0; $right=$pos_x; } if ($position[0] == 'right') { $left=$pos_x; $right=0; } if ($position[1] == 'top') { $top=0; $bottom=$pos_y; } if ($position[1] == 'middle') { $top=$pos_y; $bottom=$pos_y; } if ($position[1] == 'bottom') { $top=$pos_y; $bottom=0; } return '
'.$text.'
'; } function do_bbcode_smileys ($action, $attributes, $content, $params, $node_object) { if ($action == 'validate') { if (substr ($content, 0, 5) == 'data:' || substr ($content, 0, 5) == 'file:' || substr ($content, 0, 11) == 'javascript:' || substr ($content, 0, 4) == 'jar:') { return false; } return true; } $result = safe_query("SELECT * FROM smileys WHERE shortcut='$content' LIMIT 1"); $smiley = mysql_fetch_assoc($result); $return = ''.$smiley['desc'].''; return ($return); } function do_bbcode_icons ($action, $attributes, $content, $params, $node_object) { if (!isset ($attributes['default'])) { $size = $content; $name = htmlspecialchars ($content); } else { $size = $attributes['default']; $name = $content; } if ($action == 'validate') { if (substr ($size, 0, 5) == 'data:' || substr ($size, 0, 5) == 'file:' || substr ($size, 0, 11) == 'javascript:' || substr ($size, 0, 4) == 'jar:') { return false; } return true; } $size = !$size?'16':$size; $result = safe_query("SELECT * FROM icons WHERE name='$name' AND size='$size' LIMIT 1"); $icon = mysql_fetch_assoc($result); $return = $return = ''.$icon['image'].''; return ($return); } function do_bbcode_img ($action, $attributes, $content, $params, $node_object) { if ($action == 'validate') { if (substr ($content, 0, 5) == 'data:' || substr ($content, 0, 5) == 'file:' || substr ($content, 0, 11) == 'javascript:' || substr ($content, 0, 4) == 'jar:') { return false; } return true; } return ''; } function do_bbcode_shoutbox ($action, $attributes, $content, $params, $node_object) { $action =='validate'; # $content = htmlspecialchars ($content); if ($action == 'validate') { if (substr ($content, 0, 5) == 'data:' || substr ($content, 0, 5) == 'file:' || substr ($content, 0, 11) == 'javascript:' || substr ($content, 0, 4) == 'jar:') { return false; } return true; } $search = array('ganja',':-$', 'rofl'); $replace = array( 'smoke_ganja.gif', 'motz.gif', 'rofl.gif'); $in=array( '`((?:https?|ftp)://\S+[[:alnum:]]/?)`si', '`((?«link» ', '«link»'); $content = preg_replace($in,$out,$content); $content = str_replace($search, $replace, $content); $return = $content; return $return; } function do_bbcode_code ($action, $attributes, $content, $params, $node_object) { if (!isset ($attributes['default'])) { $code_type = $content; $code_content = htmlspecialchars ($content); } else { $code_type = $attributes['default']; $code_content = $content; } if ($action == 'validate') { if (substr ($code_type, 0, 5) == 'data:' || substr ($code_type, 0, 5) == 'file:' || substr ($code_type, 0, 11) == 'javascript:' || substr ($code_type, 0, 4) == 'jar:') { return false; } return true; } return '
CODE: '.$code_type.'
'; } $bbcode = new StringParser_BBCode (); #$bbcode->addFilter (STRINGPARSER_FILTER_PRE, 'convertlinebreaks'); $bbcode->addParser (array ('block', 'inline', 'link', 'listitem'), 'htmlspecialchars'); $bbcode->addParser (array ('block', 'inline', 'link', 'listitem'), 'nl2br'); $bbcode->addParser ('list', 'bbcode_stripcontents'); $bbcode->addCode ('b', 'simple_replace', null, array ('start_tag' => '', 'end_tag' => ''), 'inline', array ('listitem', 'block', 'inline', 'link'), array ()); $bbcode->addCode ('i', 'simple_replace', null, array ('start_tag' => '', 'end_tag' => ''), 'inline', array ('listitem', 'block', 'inline', 'link'), array ()); $bbcode->addCode ('u', 'simple_replace', null, array ('start_tag' => '', 'end_tag' => ''), 'inline', array ('listitem', 'block', 'inline', 'link'), array ()); $bbcode->addCode ('s', 'usecontent', 'do_bbcode_smileys', array (), 'inline', array ('listitem', 'block', 'inline', 'link'), array ()); $bbcode->addCode ('icon', 'usecontent?', 'do_bbcode_icons', array ('usecontent_param' => 'default'), 'inline', array ('listitem', 'block', 'inline'), array ('link')); $bbcode->addCode ('size', 'usecontent?', 'do_bbcode_size', array ('usecontent_param' => 'default'), 'inline', array ('listitem', 'block', 'inline'), array ('link')); $bbcode->addCode ('float', 'usecontent?', 'do_bbcode_float', array ('usecontent_param' => 'default'), 'inline', array ('listitem', 'block', 'inline'), array ('link')); $bbcode->addCode ('label', 'usecontent?', 'do_bbcode_label', array ('usecontent_param' => 'default'), 'inline', array ('listitem', 'block', 'inline'), array ('link')); $bbcode->addCode ('align', 'usecontent?', 'do_bbcode_align', array ('usecontent_param' => 'default'), 'inline', array ('listitem', 'block', 'inline'), array ('link')); $bbcode->addCode ('valign', 'usecontent?', 'do_bbcode_valign', array ('usecontent_param' => 'default'), 'inline', array ('listitem', 'block', 'inline'), array ('link')); $bbcode->addCode ('color', 'usecontent?', 'do_bbcode_color', array ('usecontent_param' => 'default'), 'inline', array ('listitem', 'block', 'inline'), array ('link')); $bbcode->addCode ('youtube', 'usecontent?', 'do_bbcode_youtube', array ('usecontent_param' => 'default'), 'inline', array ('listitem', 'block', 'inline'), array ('link')); $bbcode->addCode ('mixcloud', 'usecontent?', 'do_bbcode_mixcloud', array ('usecontent_param' => 'default'), 'inline', array ('listitem', 'block', 'inline'), array ('link')); $bbcode->addCode ('soundcloud', 'usecontent?', 'do_bbcode_soundcloud', array ('usecontent_param' => 'default'), 'inline', array ('listitem', 'block', 'inline'), array ('link')); $bbcode->addCode ('artist', 'usecontent?', 'do_bbcode_artist', array ('usecontent_param' => array('type','post')), 'inline', array ('listitem', 'block', 'inline'), array ('link')); $bbcode->addCode ('event', 'usecontent?', 'do_bbcode_event', array ('usecontent_param' => 'default'), 'inline', array ('listitem', 'block', 'inline'), array ('link')); $bbcode->addCode ('code', 'usecontent?', 'do_bbcode_code', array ('usecontent_param' => 'default'), 'link', array ('listitem', 'block', 'inline'), array ('link')); $bbcode->addCode ('shoutbox', 'usecontent?', 'do_bbcode_shoutbox', array ('usecontent_param' => 'default'), 'link', array ('listitem', 'block', 'inline'), array ('link')); $bbcode->addCode ('url', 'usecontent?', 'do_bbcode_url', array ('usecontent_param' => 'default'), 'inline', array ('listitem', 'block', 'inline'), array ('link')); $bbcode->addCode ('link', 'callback_replace_single', 'do_bbcode_url', array (), 'link', array ('listitem', 'block', 'inline'), array ('link')); $bbcode->addCode ('img', 'usecontent', 'do_bbcode_img', array (), 'image', array ('listitem', 'block', 'inline', 'link'), array ()); $bbcode->addCode ('bild', 'usecontent', 'do_bbcode_img', array (), 'image', array ('listitem', 'block', 'inline', 'link'), array ()); $bbcode->setOccurrenceType ('img', 'image'); $bbcode->setOccurrenceType ('bild', 'image'); $bbcode->setMaxOccurrences ('image', 8); $bbcode->addCode ('list', 'simple_replace', null, array ('start_tag' => ''), 'list', array ('block', 'listitem'), array ()); $bbcode->addCode ('*', 'simple_replace', null, array ('start_tag' => '
  • ', 'end_tag' => '
  • '), 'listitem', array ('list'), array ()); $bbcode->setCodeFlag ('*', 'closetag', BBCODE_CLOSETAG_OPTIONAL); $bbcode->setCodeFlag ('*', 'paragraphs', true); $bbcode->setCodeFlag ('list', 'paragraph_type', BBCODE_PARAGRAPH_BLOCK_ELEMENT); $bbcode->setCodeFlag ('list', 'opentag.before.newline', BBCODE_NEWLINE_DROP); $bbcode->setCodeFlag ('list', 'closetag.before.newline', BBCODE_NEWLINE_DROP); $bbcode->setRootParagraphHandling (true); #function BBcode($source,$length_max=40) # { # $coTime = str_replace(' ', '', microtime()); # preg_match_all('/\[code\](.+)\[\/code\]/Uis', $source, $result); # $source = bbcode_code_start ($source, $coTime, $result); # # bbcode einheitlicher machen zum bessern pruefen. # $s = bbcode_simple_prev ($s); # # #$s = preg_replace ("/(\015\012|\015|\012)/", " \\1", $s); # # # autoumbruch nach x zeichen # #$s = bbcode_autonewline($s, $coTime, $maxLength); # # $s = htmlentities($s); # # # speziell bilder # $s = bbcode_images ($s); # # # speziell zitate ersetzten. # $s = bbcode_quote ($s); # # # replace simple # $s = bbcode_simple ($s); # # # smilies umwandeln # $s = bbcode_smiles ($s); # # $s = preg_replace ("/\015\012|\015|\012/", "\n
    ", $s); # # # code zurueck ersetzten # $s = bbcode_code_end ($s, $coTime, $result); # # return ($s); # } function bbcode_code_start ($source, $coTime, $result) { for ($i=0;$iset_get ('BBCODE', $codereplace, 0); $source = str_replace('#'.$coTime.'#'.$i.'#'.$coTime.'#',$newstring,$source); } } unset($tpl); return ($source); } function bbcode_images ($image) { global $_BB_IMAGES; $ext = array ( '1' => 'gif', '2' => 'jpg', '3' => 'png'); $max_width = 0; preg_match_all('/\[img\](http|https):\/\/([^\ \?&=\#\"\n\r\t<>]+)\.(gif|jpeg|jpg|png)\[\/img\]/Ui', $image, $result); if (isset($_SETTINGS['bbcode_img_width_max'])) { $width_max = $_SETTINGS['bbcode_img_width_max']; } if ( isset ($imgRs[0][0]) ) { for($i=0;$i'; if ( $width > $width_max ) { $height_new = intval($height*$width_max/$width); $width_new = $width_max; $code = ''; } } $image = str_replace($result[0][$i],$code,$image); } } return($image); } ?> '); } ######################################################################### # # FUNCTIONS # --------- # # cmp_count($row1, $row2) # redirect ($link,$time,$info) # stats_open_get ($host, $port) # LogWrite ($Content) # GetCountry($ip) # -- # CreatePassword ($length=8,$level=2) # CheckNewPassword ($pw1, $pw2, $MinLength=8) # -- # CreateRegistrationKey ($length=16) # GetRegistrationKeys () # DeleteRegistrationKey ($key) # CheckRegistrationKey ($RegistrationKey) # -- # CreateActivationKey ($length=32) # SendActivationKey ($name, $email, $text) # CheckActivationKey ($ActivationKey) # # ######################################################################### function changeAmpersand ($string) { $return = str_replace('&', '&', $string); return $return; } function changeAmpersandUnicode ($string) { $return = str_replace('&', '&', $string); return $return; } function cmp_count($row1, $row2) { $first = -1 *strcasecmp(($row1['count']/10000), ($row2['count']/10000)); if ( $first ) { return $first; } } function redirect ($link="maintenance.html",$time='0.5',$info) { echo ''; if ($info!='') { echo '

    '.$info.'



    '; } } function stats_open_get ($host, $port) { // connection data $fp = @fsockopen($host, $port, $errno, $errstr, 30); // open connection if($fp) { // get data fwrite($fp,"GET /7.html HTTP/1.0\r\nUser-Agent: XML Reader(Mozilla Compatible)\r\n\r\n"); // put data to VAR while(!feof($fp)) { $dataset .= fgets($fp, 1000); } //close connection fclose($fp); $dataset1 = $dataset; $headerinfo = ereg_replace(".*","",$dataset); $dataset = ereg_replace(".*", "", $dataset); $dataset = ereg_replace(".*", ",", $dataset); $datas = explode(",",$dataset); return $datas; } } function LogWrite ($Content) { $IP = user_ip(); $UserID = $_SESSION['userid']; $Name = $_SESSION['usernick']; $Time = date("Y-m-d H:i:s"); $FileSize = 1024*1024*1024; // MiB / KiB / B if (defined(ADMIN)) { $Filename = 'admin'; } elseif (defined(ARTIST)) { $Filename = 'artist'; } elseif (defined(USER)) { $Filename = 'user'; } else { $Filename = 'occupy'; } // set content $Content = "$Time | $UserID - $Name | $Content\n"; // set file $File = $_PATH['log'].$Filename.'.log'; // check filesize and backup if necessary if (filesize($File)>$FileSize) { $Backup = $_PATH['log'].$Filename.'_'.$Time.'.log'; copy($File, $Backup); } // open file if (!$handle = fopen($Filename, 'a')) { return "Cannot open file ($Filename)"; } // write to file if (fwrite($Filename, $Content) === FALSE) { return "Cannot write to file ($Filename)"; } // close file fclose($handle); return TRUE; } function LogMailToAdmin ($Subject, $Content) { // VARs $ToName = 'PsychoRadio Admins'; $ToMail = $_SESSION['AdminMail']<>''?$_SESSION['AdminMail']:'radio@psychoradio.org'; $FromName = 'PsychoRadio'; $FromMail = 'noreply@psychoradio.org'; $Footer = 'USER'; // send email to admin if ($MailQuery = SendMail ($FromName, $FromMail, $ToName, $ToMail, $Subject, $Content, $Footer)) { return TRUE; // email not send } else { return 'email not send'; } } function GetCountry($ip) { $gi = geoip_open("include/func/geoip/GeoIP.dat", GEOIP_STANDARD); $country = geoip_country_name_by_addr($gi, $ip); $code = geoip_country_code_by_addr($gi, $ip); geoip_close($gi); $_COUNTRY['name'] = $country; $_COUNTRY['code'] = strtolower($code); return $_COUNTRY; } function CreatePassword ($length=8,$level=2) { list($usec, $sec) = explode(' ', microtime()); srand((float) $sec + ((float) $usec * 100000)); $validchars[1] = "0123456789abcdfghjkmnpqrstvwxyz"; $validchars[2] = "0123456789abcdfghjkmnpqrstvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"; $validchars[3] = "0123456789_!@#$%&*()-=+/abcdfghjkmnpqrstvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ_!@#$%&*()-=+/"; $password = ''; $counter = 0; while ($counter < $length){ $actChar = substr($validchars[$level], rand(0, strlen($validchars[$level])-1), 1); if (!strstr($password, $actChar)) { $password .= $actChar; $counter++; } } return $password; } ######################################### # # LOG # - creation # - registrationtrys # - acitvation # ######################################### #------------------------------> CHECK NEW PASSWORD function CheckNewPassword ($pw1, $pw2, $MinLength=8) { // check password length if (strlen($_POST['pw1'])<=$MinLength OR strlen($_POST['pw2'])<=$MinLength) { return 'password too short (<'.$MinLength.')'; } else { // check equal passwords if ($_POST['pw2']!=$_POST['pw1']) { return 'passwords are not equal'; } else { // positive answer return TRUE; } } } #------------------------------> CREATE REGISTRATION KEY function CreateRegistrationKey ($UserLevel=0, $DateExpire=10, $KeyLength=16) { $Admin = $_USER['ID']; $DateCreate = time(); $DaysExpire = $DateExpire*24*60*60; $DateEnd = $DateCreate+$DaysExpire; // generate new RegistrationKey if ($RegistrationKey = CreatePassword($KeyLength,2)) { // save new RegistrationKey to db if ( safe_query("INSERT INTO register (RID, byAdmin, date_create, date_register, date_end, email, UserLevel, AuthCode, AuthCodeSend, AuthCodeTrys) VALUES ('', '$Admin', '$DateCreate', 0, '$DateEnd', '$Email', '$UserLevel', '$RegistrationKey', 0 ,0) ") ) { return $RegistrationKey; //error saving new RegistrationKey } else { # return 'new registrationkey could not be set'; return false; } //error genereating RegistrationKey } else { # return 'error while creating password'; return false; } } //** // SEND NEW REGISTRATION KEY // ------------------------- // // @public create a new REGISTRATION KEY and send it to a new user // // @return TRUE or ERROR-Description // //** function SendNewRegistrationKey ($Email, $UserLevel=0,$DateExpire=10,$KeyLength=10) { // VARs $ToName = ' '; $ToMail = $Email; $Admin = ADMIN; $AuthCodeTrys = 0; // email settings $FromName = 'PsychoRadio'; $FromMail = 'noreply@psychoradio.org'; $Footer = 'USER'; $Subject = 'your authentication code'; // create new AuthCode if ($AuthCode = CreateRegistrationKey($UserLevel, $DateExpire, $KeyLength) ) { // email text $Message = ' You are invited to register with psychorradio.org. Please use the following link wich includes your authentication code: https://www.psychoradio.org/index.php?psycho=register&ac='.$AuthCode.' The registration is SSL encrypted. If you get an certification-error you should add the Certification-Authority(CAcert) to bour Browser: http://www.cacert.org/index.php?id=3 If the you want to authenticate manualy please visit https://www.psychoradio.org/index.php?psycho=register and use this authentication code: '.$AuthCode.' Take in mind, that the authentication code will expire on '.date('d.m.Y H:i', $DateEnd).'. This email is generated automaticaly, so do not reply.'; // get last register-db entry $result = safe_query("SELECT RID FROM register ORDER BY date_create DESC LIMIT 1"); $row = mysql_fetch_assoc($result); $RID = $row['RID']; if ($RID) { // save data to DB if (safe_query("UPDATE register SET byAdmin='$Admin',email='$Email',UserLevel='$UserLevel' WHERE RID='$RID' ") ){ // send email with AuthCode if (SendMail ($FromName, $FromMail, $ToName, $ToMail, $Subject, $Message, $Footer)) { //VARs $AuthCodeSend = time(); // save to DB if (safe_query("UPDATE register SET AuthCodeSend='$AuthCodeSend' WHERE RID='$RID' ") ){ return TRUE; // error save send date } else { return 'error save sending date'; } //error send email with AuthCode } else { return 'error while sending mail'; } // error save to DB } else { return 'error while saving data to db'; } // error finding empty AuthCode } else { return 'error finding empty AuthCode'; } //error creating AuthCode } else { return 'error creating AuthCode'; } } //** // SEND AUTHENTICATION CODE // ------------------------ // // @public send an existant AUTHENTICATION CODE to a new user // // @return TRUE or ERROR-Description // //** function SendAuthCode ($RID) { // get Data $result = safe_query("SELECT * FROM register WHERE RID='$RID' LIMIT 1 "); $_REG = mysql_fetch_assoc($result); // VARs $ToName = ' '; $ToMail = $_REG['email']; $AuthCode = $_REG['AuthCode']; $DateEnd = $_REG['date_end']; // email settings $FromName = 'PsychoRadio'; $FromMail = 'noreply@psychoradio.org'; $Footer = 'USER'; $Subject = 'resend your authentication code'; // email text $Message = 'We do resend the authentication code to register with psychorradio.org: '.$AuthCode.' Please go to https://www.psychoradio.org/index.php?psycho=register to register. Take in mind, that the authentication code will expire on '.date('d.m.Y H:i', $DateEnd).'. '.$_SESSION['text']['MailEncryption'].' This email is generated automaticaly, so do not reply.'; if ( is_array($_REG) AND $ToMail<>'') { // send email with AuthCode if (SendMail ($FromName, $FromMail, $ToName, $ToMail, $Subject, $Message, $Footer)) { //VARs $AuthCodeSend = time(); // save to DB if (safe_query("UPDATE register SET AuthCodeSend='$AuthCodeSend' WHERE RID='$RID' ") ){ return TRUE; // error save send date } else { return 'error save sending date'; } //error send email with AuthCode } else { return 'error while sending mail'; } // no auth code found } else { return 'error no code found'; } } #------------------------------> GET REGISTRATION KEY function GetRegistrationKeys () { $result = safe_query("SELECT * FROM register WHERE active='0' ORDER BY DateCreation DESC "); while ($row = mysql_fetch_assoc($result)){ $_RETURN[$row['ID']]=$row; } return $_RETURN; } //** // DELETE AUTHENTICATION CODE // -------------------------- // // @public delete a AUTHENTICATION CODE // // @return TRUE or ERROR-Description // //** function DeleteAuthCode ($RID) { if (safe_query("DELETE FROM register WHERE RID='$RID' ")) { return TRUE; } else { return 'AuthCode not deleted'; } } #------------------------------> CHECK REGISTRATION KEY function CheckRegistrationKey ($RegistrationKey) { // Settings $LoginTrys = 3; $KeyLength = 12; //VARs $IP = user_ip(); $TimeUsed = time(); // check input $check = $RegistrationKey<>''?substr($RegistrationKey,0,$KeyLength):''; $check = preg_replace("\\|%|<|>|\*|\^|\$|\[|\]|\{|\}|\|]", "", $check); $CheckedKey = preg_match("/[^a-zA-Z0-9]/", $check); if(strlen($CheckedKey)==$KeyLength) { // check key $result = safe_query("SELECT ID,used,TimeUsed,IP,active FROM register WHERE RegistrationKey='$RegistrationKey' LIMIT 1 "); $row = mysql_fetch_assoc($result); if($row['ID'] AND $row['active']==0) { if($row['used']>=$LoginTrys) { $ID =$row['ID']; if (safe_query("UPDATE register SET used=used+1 WHERE ID='$ID'")) { // account registered return TRUE; } else { // account not registered return 'account not registered'; } } else { // too much trys return 'too much login trys'; } } else { // still activated return 'wrong registrationkey'; } } else { // not active registration key return 'wrong registrationkey'; } } //** // CREATE ACTIVATION KEY // ----------- // // @public create a new actication-key // // @return key or false // //** function CreateActivationKey ($LengthSet=32) { if ($NewKey = CreatePassword ($LengthSet,2)) { return $NewKey; } else { return FALSE; } } //** // HANDLE ACTIVATION KEY // --------------------- // // @public creates, check and send a new ActivationKey // all Data must be set. otherwise there will be a check-error // // @return true or error-message // //** function ActivationKeyHandle ($name, $email) { // Settings $activation_hint = 'To your given email-adress we will send an activation-link, wich you have to click for the verification of your account.'; # $activation_type = 'Administrator'; # $activation_time = 24; # $activation_hint = 'The host-administrator will enable your account in the next '.$activation_time.' hours.'; # !!! ActivationKeyTrys !!! // create new key $NewActivationKey = CreateActivationKey(32); // check key if ($ActivationKey = CheckActivationKey($email, $NewActivationKey)) { // VARs $SendTime = time(); $FromName = 'PsychoRadio'; $FromMail = 'noreply@psychoradio.org'; $ToName = $name; $ToMail = $email; $Subject = 'new account registered'; $Footer = 'USER'; $Message = 'Thank you for registering! Please go to this address to activate your account: https://www.psychoradio.org/index.php?psycho=activation&key='.$ActivationKey.' After the account is activated you can login with your data: loginname: '.$email.' password: your selected password '.$_SESSION['text']['MailEncryption'].' This email is generated automaticaly, so do not reply. '; // send key by email if ($MailQuery = SendMail ($FromName, $FromMail, $ToName, $ToMail, $Subject, $Message, $Footer)) { // safe sending date safe_query("UPDATE user SET ActivationKeySend='$SendTime' WHERE loginname='$email' LIMIT 1 "); return TRUE; # return $MailQuery; // email not send } else { return 'could not send email'; } //no key created } else { return 'could not create ActivationKey'; } } #------------------------------> ACTIVATION KEY function CheckActivationKey ($email, $ActivationKey) { // check if key is in use $result = safe_query("SELECT * FROM user WHERE ActivationKey='$ActivationKey' LIMIT 1 "); $row = mysql_num_rows($result); // key is not used if($row==0) { // set ActivationKey to DB safe_query("UPDATE user SET ActivationKey='$ActivationKey' WHERE loginname='$email' "); return $ActivationKey; # return $row.' - '.$ActivationKey.' - '.$email; // key is used } else { $NewActivationKey = CreateActivationKey(32); CheckActivationKey($email, $NewActivationKey); } } #------------------------------> ACTIVATION KEY function ActivateActivationKey ($ActivationKey) { // check input $check = $ActivationKey<>''?substr($ActivationKey,0,64):''; $check = preg_replace("\\|%|<|>|\*|\^|\$|\[|\]|\{|\}|\|]", "", $check); $CheckedKey = preg_match("/[^a-zA-Z0-9]/", $check); if(strlen($CheckedKey)==32) { // check key $result = safe_query("SELECT UID FROM user WHERE ActivationKey='$ActivationKey' LIMIT 1 "); $row = mysql_fetch_assoc($result); // key found if($row['UID']) { $UID =$row['UID']; $Time = time(); // activate key if (safe_query("UPDATE user SET active='1',ActivationKeyActivation='$Time' WHERE UID='$UID' LIMIT 1 ")) { return TRUE; // key not activated } else { return FALSE; } // key not found } else { return FALSE; } } } ?> '); } // HELP-PAGE // - save samples (no edir, delete) function HelpBBcode() { // BBcode SETTINGS $_HelpBBcodeData = array( '1' => array( 'active' => TRUE, 'code' => '[b]...[/b]', 'do' => 'set characters bold', 'options' => '', 'notes' => ''), '2' => array( 'active' => TRUE, 'code' => '[i]...[/i]', 'do' => 'set characters italic', 'options' => '', 'notes' => ''), '3' => array( 'active' => TRUE, 'code' => '[u]...[/u]', 'do' => 'underlines characters', 'options' => '', 'notes ' => ''), '4' => array( 'active' => TRUE, 'code' => '[icon="<SIZE>"]<NAME>[/icon]', 'do' => 'puts an icon into text', 'options' => 'SIZE: 16/32/64/128 pixel', 'notes' => 'still in development and not implemented yet'), '5' => array( 'active' => FALSE, 'code' => '[size][/size]', 'do' => '', 'options' => '', 'notes' => ''), '6' => array( 'active' => TRUE, 'code' => '[float="<horizontalɚ<vertical>"]...[/float]', 'do' => 'text float', 'options' => 'default: "left;top"
    hotizontal: left/right
    vertical: top/middle/bottom', 'notes' => 'Default settings are used if no options are set. Using custom option, both horitontal AND vertical must be set.'), '7' => array( 'active' => TRUE, 'code' => '[label="<NAME>"]...[/label]', 'do' => 'labels a row', 'options' => 'labelname', 'notes' => ''), '8' => array( 'active' => TRUE, 'code' => '[align="<OPTION>"] [/align]', 'do' => 'alines a text or paragraph', 'options' => 'left / center / middle', 'notes' => ''), '9' => array( 'active' => FALSE, 'code' => '[valign] [/valign]', 'do' => '', 'options' => '', 'notes' => ''), '10' => array( 'active' => TRUE, 'code' => '[color="<OPTION>"] [/color]', 'do' => 'set color', 'options' => '', 'notes' => 'use hex-color-codes starting with #'), '11' => array( 'active' => FALSE, 'code' => '[artist] [/artist]', 'do' => '', 'options' => '', 'notes' => ''), '12' => array( 'active' => TRUE, 'code' => '[event="<EVENTNUMBER>"]<OPTION>[/event]', 'do' => 'puts eventdata from Database to BBcode', 'options' => 'EVENTNUMBER: number of the event
    OPTIONS: title/artists/genre/date/start/end', 'notes' => 'pay attention that the Eventnumber will be create after your request'), '13' => array( 'active' => TRUE, 'code' => '[youtube="<OPTION>"]<VIDEO_NUMBER>[/youtube]', 'do' => 'embeds a youtube video', 'options' => 'default: normal
    normal -> 4:3 (445x364)
    small -> 4:3 (333x273)
    tiny -> 4:3 (222x182)
    wide -> 16:9 (580x360)
    wide;small -> 16:9 (435x270)
    wide;tiny -> 16:9 (290x180)', 'notes' => 'VIDEO_NUMBER: http://www.youtube.com/watch?v=ehkMBaYxpHs

    <VIDEONUMBER> -> ehkMBaYxpHs '), '14' => array( 'active' => TRUE, 'code' => '[mixcloud] [/mixcloud]', 'do' => 'embeds a mixcloud audio file', 'options' => '', 'notes' => ''), '15' => array( 'active' => TRUE, 'code' => '[soundcloud] [/soundcloud]', 'do' => 'embeds a soundcloud audio file', 'options' => '', 'notes' => ''), '16' => array( 'active' => FALSE, 'code' => '[code] [/code]', 'do' => '', 'options' => '', 'notes' => ''), '17' => array( 'active' => FALSE, 'code' => '[link] [/link]', 'do' => '', 'options' => '', 'notes' => ''), '18' => array( 'active' => TRUE, 'code' => '[url="<URL>"]<NAME>[/url] ', 'do' => 'name and link to a specific URL', 'options' => 'URL: full URL NAME: custom name of the given URL', 'notes' => ''), '19' => array( 'active' => FALSE, 'code' => '[bild] [/bild]', 'do' => '', 'options' => '', 'notes' => ''), '20' => array( 'active' => TRUE, 'code' => '[FALSE]...[/list]', 'do' => 'makes a list of objects', 'options' => '[*]object', 'notes' => 'each row of the list needs a tag'), '21' => array( 'active' => TRUE, 'code' => '[img<URL>[/img]', 'do' => 'puts in an image from the given URL', 'options' => 'URL: URL of the image', 'notes' => ''), '22' => array( 'active' => FALSE, 'code' => '[s]<SMILEY>[/s]', 'do' => 'puts in a smiley from list', 'options' => 'SMILEY: name of the implemented smiley', 'notes' => '') ); // PRINT HELP TABLE $_HelpBBcode = ''."\n"; $_HelpBBcode .= ''."\n"; $_HelpBBcode .= ''."\n"; $_HelpBBcode .= ''."\n"; $_HelpBBcode .= ''."\n"; $_HelpBBcode .= ''."\n"; $_HelpBBcode .= ''."\n"; foreach ($_HelpBBcodeData as $key => $data) { if ($data['active']==TRUE) { $_HelpBBcode .= ''."\n"; $_HelpBBcode .= ''."\n"; $_HelpBBcode .= ''."\n"; $_HelpBBcode .= ''."\n"; $_HelpBBcode .= ''."\n"; $_HelpBBcode .= ''."\n"; } } $_HelpBBcode .= '
    BB-Code Help
    '.$data['code'].'
    '.$data['do'].''.$data['options'].''.$data['notes'].'
    '."\n"; return $_HelpBBcode; } #======================================================================================================== #echo '
    ';
    #print_r ($_HelpBBcodeData);
    #echo '
    '; #echo '#############################################
    '; #echo '
    ';
    #print_r ($_HelpBBcode);
    #echo '
    '; #======================================================================================================== ?>