Beispiel #1
0
function mx_mnfandir($page, $option, $action)
{
    global $mxdb, $mxuser;
    $mode = array('alpha' => _('Alphabetical'), 'genres' => _('By Genres'), 'subs' => _('Subscribers'), 'super' => _('SuperFans'), 'random' => _('Random Selection'));
    $selsub = '';
    if ($action) {
        if (preg_match('%([^:]+):?(.*)%', $action, $modes)) {
        }
        $selmode = $modes[1];
        $selsub = $modes[2];
    } else {
        $selmode = 'subs';
    }
    echo '<div class="directory">';
    echo '<table class="dirtabs"><tr>';
    foreach ($mode as $ord => $ordname) {
        $dis = false;
        if (substr($ord, 0, 1) == '-') {
            $dis = true;
        }
        $class = $ord == $selmode ? 'dirtabsel' : (substr($ord, 0, 1) == '-' ? 'dirtabdis' : 'dirtab');
        echo '<td class="' . $class . '">';
        if (!$dis) {
            echo '<a href="' . mx_actionurl($page, $option, $ord) . '">' . $ordname . '</a>';
        } else {
            echo $ordname;
        }
        echo '</td>';
    }
    //echo '<td class="dirtablast"></td>';
    echo '</tr>';
    echo '</table>';
    $fanfilter = '(a.acctype=' . MXACCOUNTFAN . ' OR 0 < (SELECT count(b.id) FROM mx_subscriptions b WHERE b.fanid=a.id' . ' AND b.subcat=' . MXARTSUB . ' AND b.subtype!=' . MXSUBLIKE . ' AND b.status!=' . MXEXPIREDSUB . ' AND b.status!=' . MXENDEDSUB . ') )';
    switch ($selmode) {
        case 'random':
            // pure fans or subscribers
            $filter = $fanfilter;
            // pure fan or subscriber
            break;
        case 'subs':
            // subs only
            $filter = '0 < (SELECT count(b.id) FROM mx_subscriptions b WHERE b.fanid=a.id' . ' AND b.subcat=' . MXARTSUB . ' AND b.subtype!=' . MXSUBLIKE . ' AND b.status!=' . MXEXPIREDSUB . ' AND b.status!=' . MXENDEDSUB . ')';
            break;
        case 'super':
            // 5 subs mini
            $filter = '4 < (SELECT count(b.id) FROM mx_subscriptions b WHERE b.fanid=a.id' . ' AND b.subcat=' . MXARTSUB . ' AND b.subtype!=' . MXSUBLIKE . ' AND b.status!=' . MXEXPIREDSUB . ' AND b.status!=' . MXENDEDSUB . ')';
            break;
        case 'genres':
            $genres = $mxdb->listgenres();
            $cats = array();
            $subgenres = array();
            foreach ($genres as $genre) {
                if (!$genre->cat) {
                    $cats[$genre->hash] = $genre->id;
                    $subgenres[$genre->id] = array();
                }
            }
            foreach ($genres as $genre) {
                if ($genre->cat) {
                    $subgenres[$cats[$genre->cat]][] = $genre->id;
                    $catgenre[$genre->id] = $cats[$genre->cat];
                }
            }
            /*
            $str='<script language="javascript">'.CRLF;
            $str.='var cats=new Array();'.CRLF;
            $str.='var subcats=new Array();'.CRLF;
            $str.='var subcatsndx=new Array();'.CRLF;
            foreach($cats as $cat) {
            	$n=1;
            	$str.='cats['.$cat.']=\''.$genres[$cat]->genre.'\';'.CRLF;
            	$str.='subcats['.$cat.']=new Array();'.CRLF;
            	$str.='subcatsndx['.$cat.']=new Array();'.CRLF;
            	$str.='subcats['.$cat.'][0]=\''._('Any').'\';'.CRLF;
            	$str.='subcatsndx['.$cat.'][0]='.$cat.';'.CRLF;
            	foreach($subgenres[$cat] as $subcat) {
            		$str.='subcats['.$cat.']['.$n.']=\''.$genres[$subcat]->genre.'\';'.CRLF;
            		$str.='subcatsndx['.$cat.']['.$n++.']=\''.$subcat.'\';'.CRLF;
            	}
            }
            $str.='</script>'.CRLF;
            echo $str;
            */
            if ($selsub && $genres[$selsub]->cat) {
                $cat = $catgenre[$selsub];
            } else {
                $cat = $selsub;
            }
            $subcat = $selsub;
            echo '<table class="dirgen"><tr>';
            echo '<td class="dirgencat"><table class="dirgencat">';
            foreach ($cats as $catid) {
                $class = $catid == $cat ? 'dirgensel' : 'dirgentab';
                echo '<tr><td class="' . $class . '"><a href="' . mx_actionurl($page, $option, $selmode . ':' . $catid) . '">' . $genres[$catid]->genre . '</a></td><td class="dirarrow">' . ($catid == $cat ? '&rarr;' : '') . '</td></tr>';
            }
            echo '</table></td>';
            echo '<td class="dirgenre"><div class="dirgenre"><table id="dirgenre" class="dirgenre">';
            if ($selsub) {
                echo _('<div class="genrehelp">&darr; Select a subcategory below [optional]</div>');
                $col = 0;
                foreach ($subgenres[$cat] as $subcatid) {
                    if (!$col) {
                        echo '<tr>';
                    }
                    $class = $subcatid == $selsub ? 'dirgensel' : 'dirgentab';
                    echo '<td class="' . $class . '"><a href="' . mx_actionurl($page, $option, $selmode . ':' . $subcatid) . '">' . $genres[$subcatid]->genre . '</a></td>';
                    $col = ++$col % 3;
                    if (!$col) {
                        echo '</tr>';
                    }
                }
                if ($col) {
                    echo '<td colspan="' . (3 - $col) . '"></td></tr>';
                }
            } else {
                echo '<tr><td><div class="genrehelp">' . _('&larr; Select a genre on the left<br/>to show subcategories') . '</div></td></tr>';
            }
            echo '</table></div></td>';
            echo '</tr></table>';
            if ($cat && $cat == $subcat) {
                // main cat
                $filter = array('mx_acc2tast c', 'c.genre=' . $selsub . ' AND a.id=c.userid AND ' . $fanfilter, sprintf(_('Listed in %s'), $genres[$cat]->genre));
                // sub cats
                $filter2 = array('mx_acc2tast c, mx_genres d', 'd.cat=\'' . $genres[$cat]->hash . '\' AND c.genre=d.id AND a.id=c.userid' . ' AND ' . $fanfilter, sprintf(_('Listed in subcategories of %s'), $genres[$cat]->genre));
            } else {
                if ($cat) {
                    // main subcat
                    $filter = array('mx_acc2tast c', 'c.genre=' . $selsub . ' AND a.id=c.userid AND ' . $fanfilter, sprintf(_('Listed in %s'), $genres[$selsub]->genre));
                    // top cat
                    $filter2 = array('mx_acc2tast c', 'c.genre=' . $cat . ' AND a.id=c.userid AND ' . $fanfilter, sprintf(_('Listed in %s'), $genres[$cat]->genre));
                    $filter3 = array('mx_acc2tast c, mx_genres d', '(d.cat=\'' . $genres[$cat]->hash . '\' AND d.id!=' . $selsub . ') AND c.genre=d.id AND a.id=c.userid AND ' . $fanfilter, sprintf(_('Listed in other subcategories of %s'), $genres[$cat]->genre));
                }
            }
            break;
        case 'alpha':
        default:
            $ndx = "ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789_";
            if (!$selsub) {
                $selsub = substr($ndx, rand(0, strlen($ndx) - 1), 1);
            }
            echo '<table class="diralpha"><tr>';
            for ($i = 0; $i < strlen($ndx); $i++) {
                $letter = substr($ndx, $i, 1);
                $class = $letter == $selsub ? 'diralphasel' : 'diralphatab';
                echo '<td class="' . $class . '"><a href="' . mx_actionurl($page, $option, $selmode . ':' . $letter) . '">' . ($letter == '_' ? _('Others') : $letter) . '</a></td>';
            }
            //echo '<td class="diralphalast"></td>';
            echo '</tr>';
            echo '</table>';
            if ($selsub == '_') {
                $selsub = '[^a-zA-Z0-9]';
            }
            $filter = $fanfilter . ' AND fullname RLIKE \'^' . $selsub . '.*\'';
            // 'OR lastname RLIKE \'^'.$selsub.'.*\'';
            break;
    }
    if ($filter) {
        $afilter[] = $filter;
    }
    if ($filter2) {
        $afilter[] = $filter2;
    }
    if ($filter3) {
        $afilter[] = $filter3;
    }
    foreach ($afilter as $flt) {
        if (is_array($flt)) {
            echo '<h5>' . $flt[2] . '</h5>';
        }
        $fansqr = $mxdb->fanlist($flt);
        echo '<table class="fanlist"><tr>';
        $c = 0;
        if ($fansqr['count'] == 30) {
            echo '<td colspan="6">' . _('(30 fans chosen at random...)') . '</td></tr><tr>';
        }
        for ($i = 0; $i < $fansqr['count']; $i++) {
            $fan = $mxdb->fanlist(null, $fansqr['mxq']);
            if ($fan) {
                echo '<td class="friend">';
                // onclick="window.location=\''.mx_actionurl('fans','fanprof',$fan->id).'\';">';
                echo '<a href="' . mx_actionurl('fans', 'fanprof', $fan->id) . '" title="' . mx_getname($fan) . ' - ' . _('See Page') . '" class="pictooltip">';
                echo '<img tag="' . $fan->id . '" class="dirpic" src="' . mx_fanpic($fan->id, 'square', $fan->gender) . '">';
                echo '</a>';
                echo '<br/>' . mx_getname($fan);
                echo '</td>';
                $c = ++$c % 6;
                if (!$c) {
                    echo '</tr><tr>';
                }
            }
        }
        if (!$i) {
            echo '<td colspan="6">' . _('No fan listed here.') . '</td>';
        }
        echo '</tr></table>';
    }
    echo '</div>';
}
Beispiel #2
0
function mx_xmlshow($msgid, $like = '0', $dislike = '0')
{
    global $mxdb, $mxuser;
    if ($like || $dislike) {
        if ($like && $dislike) {
            return;
        }
        $numlikes = $mxdb->setlikes($mxuser->id, $msgid, $like, $dislike);
        echo 'var totlikes=' . $numlikes->likes . '; var totdislikes=' . $numlikes->dislikes . '; //' . $like . ' / ' . $dislike;
        return;
    }
    $comments = $mxdb->getcomments($msgid);
    if (!$comments) {
        __('No comments.');
        return;
    }
    $str = '<table class="wcomment">';
    while ($comment = $mxdb->getcomments($msgid, $comments)) {
        $comment->mylikes = $mxuser->getlikes($comment->msgid);
        $str .= '<tr class="wcommentline">';
        $str .= '<td class="showspic"><img src="' . mx_fanpic($comment->authid) . '" /></td>';
        $str .= '<td>';
        $str .= $comment->body;
        $str .= '<div class="wclikes">';
        $str .= mx_likeicon($comment->msgid, MXLIKEIT, $comment->mylikes, $mxuser->id) . '<div name="ln_' . $comment->msgid . '">' . sprintf('%d', $comment->likes ? $comment->likes : 0) . '</div>' . mx_likeicon($comment->msgid, MXDISLIKEIT, $comment->mylikes, $mxuser->id) . '<div name="dn_' . $comment->msgid . '">' . sprintf('%d', $comment->dislikes ? $comment->dislikes : 0) . '</div>';
        $str .= '</div>';
        // wlikes
        $str .= '<div class="wcommentdate">' . mx_difftime($comment->date) . '</div>';
        $str .= '</td>';
        $str .= '</tr>';
    }
    $yrcomment = array(1, _('Your comment'), 'memo', 1, null, _('Speak your heart...'));
    $str .= '<tr class="wcommentline"><!-- <td class="showspic"><img src="' . mx_fanpic($mxuser->id) . '" /></td> -->' . '<td colspan="2">' . mx_formfield('mc_' . $msgid, '', $yrcomment) . '<br/>' . '<input class="sendcomment" type="button" onclick="sendcomment(' . $msgid . ');" value="' . _('Send') . '">' . '</td>' . '</tr>';
    $str .= '</table>';
    $str .= '<a class="close" href="javascript:switchcomments(\'' . $msgid . '\');">' . mx_icon('close', 'Close', '16px') . '</a>';
    echo $str;
}
Beispiel #3
0
function mx_sharetools($userid, $artist = true)
{
    global $s3, $mxdb;
    $user = mx_getuserpublicinfo($userid);
    mx_checkvalues($user);
    //die(print_r($user,true));
    if ($artist) {
        $name = $user->artistname;
        $page = 'artists';
        $opt = 'artprof';
    } else {
        $name = mx_getname($user);
        $page = 'fans';
        $opt = 'fanprof';
    }
    if (!$name) {
        return _('Available Soon');
    }
    //die(print_r($user,true));
    //if (!is_admin()) return _('Available Soon');
    // big badges
    $fmt = array('large' => '150px wide', 'small' => '100px wide', 'square' => '80px x 96px');
    // smaller on-musxpand badges
    $badgesize = array(_('Small') => '-small', _('Large') => '');
    $badgecolor = array(_('White') => '', _('Black') => '-black');
    if (!$user->badges) {
        // QR codes generation
        /*
        $xcard=new XMLWriter();
        $xcard->openMemory();
        $xcard->startDocument('1.0','UTF-8');
        $xcard->startElementNs(null,'vcards','urn:ietf:params:xml:ns:vcard-4.0');
        $xcard->startElement('vcard');
        
        $xcard->startElement('n'); // name
        $xcard->startElement('surname'); // family name
        $xcard->text($user->lastname);
        $xcard->endElement(); // surname
        $xcard->startElement('given'); // first name
        $xcard->text($user->firstname);
        $xcard->endElement(); // given
        $xcard->endElement(); // n
        
        $xcard->startElement('fn'); // fullname
        $xcard->startElement('text'); // text
        $xcard->text($name);
        $xcard->endElement(); // text
        $xcard->endElement(); // fn
        
        $xcard->startElement('org'); // org
        $xcard->startElement('text'); // text
        $xcard->text('MusXpand');
        $xcard->endElement(); // text
        $xcard->endElement(); // org
        
        $xcard->startElement('title'); // shortbio
        $xcard->startElement('text'); // text
        $xcard->text($user->about);
        $xcard->endElement(); // text
        $xcard->endElement(); // shortbio
        
        $xcard->startElement('photo'); // photo
        $xcard->startElement('uri'); // URI
        $xcard->text(mx_fanpic($user->id,'small',$user->gender,$isartist));
        $xcard->endElement(); // URI
        $xcard->endElement(); // photo
        
        $xcard->startElement('adr'); // address
        $xcard->startElement('parameters'); // parameters
        $xcard->startElement('type'); // type
        $xcard->text($isartist?'work':'home');
        $xcard->endElement(); // type
        $xcard->startElement('label'); // label
        $location='';
        if ($user->city) $location.=$user->city;
        if ($user->state) $location.=($location?', ':'').$user->state;
        if ($user->country) $location.=($location?'\n':'').mx_getcountryname($user->country);
        $xcard->text($location);
        $xcard->endElement(); // label
        $xcard->startElement('locality'); // locality
        $xcard->text($user->city);
        $xcard->endElement(); // locality
        $xcard->startElement('region'); // region
        $xcard->text($user->state);
        $xcard->endElement(); // region
        $xcard->startElement('country'); // country
        $xcard->text(mx_getcountryname($user->country));
        $xcard->endElement(); // country
        $xcard->endElement(); // parameters
        $xcard->endElement(); // address
        
        $xcard->startElement('email'); // country
        $xcard->startElement('text'); // text
        $xcard->text($user->email);
        $xcard->endElement(); // text
        $xcard->endElement(); // email
        
        $xcard->startElement('rev'); // revision
        $xcard->startElement('timestamp'); // date
        $xcard->text(gmdate('Ymd\THis\Z'));
        $xcard->endElement(); // date
        $xcard->endElement(); // rev
        
        $xcard->endElement(); // vcard
        $xcard->endElement(); // vcards
        
        $xvcard=$xcard->flush();
        */
        $saveart = $artist;
        foreach (array(true, false) as $artist) {
            $vcard = 'BEGIN:VCARD' . CRLF . 'VERSION:4.0' . CRLF;
            //$vcard.='SOURCE:'.mx_option('siteurl').'/vcf.php?a='.$user->id.CRLF;
            $vcard .= 'KIND:individual' . CRLF;
            //$vcard.='XML:'.$xvcard.CRLF;
            if ($artist) {
                $vcard .= 'FN:' . $name . CRLF;
                $vcard .= 'N:' . $user->lastname . ';' . $user->firstname . CRLF;
            } else {
                $vcard .= 'FN:' . $user->fullname . CRLF;
                $vcard .= 'N:' . $user->lastname . ';' . $user->firstname . CRLF;
            }
            $vcard .= 'PHOTO:' . mx_fanpic($user->id, 'small', $user->gender, $artist) . CRLF;
            if ($user->gender != MXNOSEX) {
                $vcard .= 'GENDER:' . ($user->gender == MXSEXMALE ? 'M' : 'F') . CRLF;
            }
            if ($user->birthdate) {
                $vcard .= 'BDAY:' . str_replace('-', '', $user->birthdate) . CRLF;
            }
            $vcard .= 'ADR;TYPE=' . ($artist ? 'work' : 'home') . ':;;;' . $user->city . ';' . $user->state . ';;' . mx_getcountryname($user->country) . CRLF;
            $vcard .= 'EMAIL:' . $user->email . CRLF;
            if ($user->timezone) {
                $vcard .= 'TZ:' . $user->timezone . CRLF;
            }
            if ($user->about) {
                $vcard .= 'TITLE:"' . $user->shortbio . '"' . CRLF;
            }
            $vcard .= 'LOGO:' . mx_option('logoURL') . CRLF;
            //$vcard.='ORG:'.CRLF;
            $vcard .= 'UID:urn:uuid:' . $user->hashdir . CRLF;
            $vcard .= 'URL:' . mx_actionurl($artist ? 'artists' : 'fans', $artist ? 'artprof' : 'fanprof', $user->id) . CRLF;
            $vcard .= 'REV:' . gmdate('Ymd\\THis\\Z') . CRLF;
            $vcard .= 'END:VCARD' . CRLF;
            QRcode::png($vcard, mx_option('usersdir') . '/tmp/' . $user->hashdir . '_QR' . ($artist ? 'a' : 'f') . '.png', 'L', 2, 4);
            $keyname = 'users/' . $user->hashdir . '/pics/qr_' . ($artist ? 'a' : 'f') . '.png';
            $res = $s3->create_object(MXS3BUCKET, $keyname, array('fileUpload' => mx_option('usersdir') . '/tmp/' . $user->hashdir . '_QR' . ($artist ? 'a' : 'f') . '.png', 'acl' => AmazonS3::ACL_PUBLIC));
            //@unlink(mx_option('usersdir').'/tmp/'.$user->hashdir.'_'.$value.'.jpg');
            file_put_contents(mx_option('usersdir') . '/tmp/' . $user->hashdir . '_vCard' . ($artist ? 'a' : 'f') . '.vcf', $vcard);
            $keyname = 'users/' . $user->hashdir . '/pics/vCard_' . ($artist ? 'a' : 'f') . '.vcf';
            $res = $s3->create_object(MXS3BUCKET, $keyname, array('fileUpload' => mx_option('usersdir') . '/tmp/' . $user->hashdir . '_vCard' . ($artist ? 'a' : 'f') . '.vcf', 'acl' => AmazonS3::ACL_PUBLIC));
            @unlink(mx_option('usersdir') . '/tmp/' . $user->hashdir . '_vCard' . ($artist ? 'a' : 'f') . '.vcf');
        }
        $artist = $saveart;
    }
    if (!$user->badges) {
        // badges generation
        ini_set('allow_url_fopen', 1);
        $keyname = 'users/' . $user->hashdir . '/pics/me_large.jpg';
        $picurl = mx_secureurl(gets3url($keyname, '2 minutes'));
        // load pic
        $pic = imagecreatefromjpeg($picurl);
        if (!$pic) {
            $pic = imagecreatefrompng(mx_fanpic($user->id, 'large', $user->gender, false));
        }
        $w = imagesx($pic);
        $h = imagesy($pic);
        $nhl = round($h * 150 / $w);
        $nhs = round($h * 100 / $w);
        $mwh = min($w, $h);
        $imlarge = imagecreatetruecolor(150, $nhl + 16);
        $imsmall = imagecreatetruecolor(100, $nhs + 16);
        $imsquare = imagecreatetruecolor(80, 80 + 16);
        $fgl = imagecolorallocate($imlarge, 255, 255, 255);
        $fgs = imagecolorallocate($imsmall, 255, 255, 255);
        $fgq = imagecolorallocate($imsquare, 255, 255, 255);
        $bgl = imagecolorallocate($imlarge, 0xff, 0xff, 0x99);
        $bgs = imagecolorallocate($imsmall, 0xff, 0xff, 0x99);
        $bgq = imagecolorallocate($imsquare, 0xff, 0xff, 0x99);
        //imagefill($imlarge,0,0,$fcl);
        //imagefill($imsmall,0,0,$fcs);
        //imagefill($imsquare,0,0,$fcq);
        //imagefilledrectangle($imlarge,1,$nhl,148,$nhl+14,$bgl);
        //imagefilledrectangle($imsmall,1,$nhs,98,$nhs+14,$bgs);
        //imagefilledrectangle($imsquare,1,80,78,80+14,$bgq);
        imageline($imlarge, 0, $nhl - 1, 150 - 1, $nhl - 1, $fgl);
        imageline($imsmall, 0, $nhs - 1, 100 - 1, $nhs - 1, $fgs);
        imageline($imsquare, 0, 80 - 1, 80 - 1, 80 - 1, $fgq);
        imageantialias($imlarge, true);
        imageantialias($imsmall, true);
        imageantialias($imsquare, true);
        imagecopyresampled($imlarge, $pic, 1, 1, 0, 0, 150 - 2, $nhl - 2, $w, $h);
        imagecopyresampled($imsmall, $pic, 1, 1, 0, 0, 100 - 2, $nhs - 2, $w, $h);
        imagecopyresampled($imsquare, $pic, 1, 1, $mwh == $h ? ($w - $mwh) / 2 : 0, $mwh == $w ? ($h - $mwh) / 2 : 0, 80 - 2, 80 - 2, $mwh, $mwh);
        // add artistname
        $font = mx_option('rootdir') . '/fonts/HoboStd.otf';
        $textl = $texts = $textq = strtoupper($name);
        while (($factl = 16 / max(array(16, strlen($textl)))) < 0.6) {
            $textl = substr($textl, 0, strrpos($textl, ' ')) . '...';
        }
        while (($facts = 12 / max(array(12, strlen($texts)))) < 0.6) {
            $texts = substr($texts, 0, strrpos($texts, ' ')) . '...';
        }
        while (($factq = 9 / max(array(9, strlen($textq)))) < 0.6) {
            $textq = substr($textq, 0, strrpos($textq, ' ')) . '...';
        }
        $szl = 9.4 * $factl;
        $szs = 9.4 * $facts;
        $szq = 9.4 * $factq;
        $txtl = imagettfbbox($szl, 0, $font, $textl);
        $txts = imagettfbbox($szs, 0, $font, $texts);
        $txtq = imagettfbbox($szq, 0, $font, $textq);
        imagettftext($imlarge, $szl, 0, (150 - $txtl[2] - $txtl[0]) / 2 - 1, $nhl + (16 - $txtl[1] - $txtl[7]) / 2, $fgl, $font, $textl);
        imagettftext($imsmall, $szs, 0, (100 - $txts[2] - $txts[0]) / 2 - 1, $nhs + (16 - $txts[1] - $txts[7]) / 2, $fgs, $font, $texts);
        imagettftext($imsquare, $szq, 0, (80 - $txtq[2] - $txtq[0]) / 2 - 1, 80 + (16 - $txtq[1] - $txtq[7]) / 2, $fgq, $font, $textq);
        /*
        $logo=imagecreatefrompng(mx_option('rootdir').'/images/general/musxpand-logo.png');
        $imlogo=imagerotate($logo,90,0);
        $lw=imagesx($imlogo);
        $lh=imagesy($imlogo);
        imagecopyresampled($imlarge,$imlogo,129,0,0,0,$lw/2,$lh/2,$lw,$lh);
        */
        imagejpeg($imlarge, mx_option('usersdir') . '/tmp/' . $user->hashdir . '_large.jpg');
        imagejpeg($imsquare, mx_option('usersdir') . '/tmp/' . $user->hashdir . '_square.jpg');
        imagejpeg($imsmall, mx_option('usersdir') . '/tmp/' . $user->hashdir . '_small.jpg');
        foreach ($fmt as $value => $desc) {
            $keyname = 'users/' . $user->hashdir . '/pics/badge_' . $value . '.jpg';
            $res = $s3->create_object(MXS3BUCKET, $keyname, array('fileUpload' => mx_option('usersdir') . '/tmp/' . $user->hashdir . '_' . $value . '.jpg', 'acl' => AmazonS3::ACL_PUBLIC));
            @unlink(mx_option('usersdir') . '/tmp/' . $user->hashdir . '_' . $value . '.jpg');
        }
        // mini-badges
        $keyname = 'users/' . $user->hashdir . '/pics/me_square.jpg';
        $picurl = mx_secureurl(gets3url($keyname, '2 minutes'));
        // load pic
        $pic = imagecreatefromjpeg($picurl);
        if (!$pic) {
            $pic = imagecreatefrompng(mx_fanpic($user->id, 'large', $user->gender, false));
        }
        $pw = imagesx($pic);
        $ph = imagesy($pic);
        $badgepref = 'badge-on-musxpand';
        foreach ($badgesize as $sname => $ssuf) {
            switch ($ssuf) {
                case '':
                    $offx = 9;
                    $offy = 1;
                    break;
                case '-small':
                default:
                    $offx = -2;
                    $offy = 1;
                    break;
            }
            foreach ($badgecolor as $cname => $csuf) {
                $badgemask = imagecreatefrompng(mx_option('rootdir') . '/images/badges/' . $badgepref . $ssuf . $csuf . '.png');
                $bw = imagesx($badgemask);
                $bh = imagesy($badgemask);
                $badge = imagecreatetruecolor($bw, $bh);
                //imagepalettecopy($badge, $badgemask);
                $transp = imagecolorallocatealpha($badge, 0, 0, 0, 127);
                imagefill($badge, 0, 0, $transp);
                imageantialias($badge, true);
                //imagealphablending($badge,false);
                //imagealphablending($badgemask,false);
                imagecopyresampled($badge, $pic, floor(($bh - 72) / 2) + $offx, floor(($bh - 72) / 2) + $offy, 0, 0, 72, 72, $pw, $ph);
                imagecopyresampled($badge, $badgemask, 0, 0, 0, 0, $bw, $bh, $bw, $bh);
                imagesavealpha($badge, true);
                $tmpfile = mx_option('usersdir') . '/tmp/' . $user->hashdir . '_mini' . $ssuf . $csuf . '.png';
                imagepng($badge, $tmpfile);
                $keyname = 'users/' . $user->hashdir . '/pics/minibadge' . $ssuf . $csuf . '.png';
                $res = $s3->create_object(MXS3BUCKET, $keyname, array('fileUpload' => $tmpfile, 'acl' => AmazonS3::ACL_PUBLIC));
                @unlink($tmpfile);
            }
        }
        ini_set('allow_url_fopen', 0);
        $user->badges = 1;
        $mxdb->updateuser($user, 'badges');
    }
    $str = '<div class="badges"><table><tr>';
    foreach ($fmt as $value => $desc) {
        $str .= '<th>' . sprintf(_('Badge %s'), $desc) . '</th>';
    }
    $str .= '</tr><tr>';
    foreach ($fmt as $value => $desc) {
        $keyname = 'users/' . $user->hashdir . '/pics/badge_' . $value . '.jpg';
        $str .= '<td><img src="' . mx_secureurl(gets3url($keyname)) . '" /></td>';
    }
    $str .= '</tr><tr>';
    foreach ($fmt as $value => $desc) {
        $str .= '<th>' . _('Code') . '</th>';
    }
    $str .= '</tr><tr>';
    foreach ($fmt as $value => $desc) {
        $keyname = 'users/' . $user->hashdir . '/pics/badge_' . $value . '.jpg';
        $str .= '<td>';
        $str .= '<textarea id="b_' . $value . '" onmouseover="this.select(); setcopybtn(\'bt_' . $value . '\',\'b_' . $value . '\');">';
        $str .= '<a href="' . mx_actionurl($page, $opt, $user->id) . '" alt="' . $name . '">' . '<img src="' . mx_secureurl(gets3url($keyname)) . '" />' . '</a>';
        $str .= '</textarea><br/>';
        $str .= '<a style="display:none;" href="#" class="toclipbtn" id="bt_' . $value . '">' . _('Copy') . '</a>';
        $str .= '</td>';
    }
    $str .= '</tr></table>';
    //$str.='<center><a href="'.mx_actionurl('artists','artprof',$user->id).'">'.$user->artistname.'</a></center>';
    $str .= '</div>';
    // smaller on-musxpand badges
    $str .= '<div class="badges"><table>';
    $i = 0;
    foreach ($badgesize as $sname => $ssuf) {
        $i++;
        $j = 0;
        foreach ($badgecolor as $cname => $csuf) {
            $j++;
            $value = $i . '_' . $j;
            $str .= '<tr><th>' . sprintf(_('MX Badge, %s, %s'), $sname, $cname) . '</th>' . '<th>' . _('Code') . '</th></tr>';
            $keyname = 'users/' . $user->hashdir . '/pics/minibadge' . $ssuf . $csuf . '.png';
            $str .= '<tr><td><img src="' . mx_secureurl(gets3url($keyname)) . '" /></td>';
            $str .= '<td>';
            $str .= '<textarea id="b_' . $value . '" onmouseover="this.select(); setcopybtn(\'bt_' . $value . '\',\'b_' . $value . '\');">';
            $str .= '<a href="' . mx_actionurl($page, $opt, $user->id) . '" alt="' . $name . '">' . '<img src="' . mx_secureurl(gets3url($keyname)) . '" />' . '</a>';
            $str .= '</textarea><br/>';
            $str .= '<a style="display:none;" href="#" class="toclipbtn" id="bt_' . $value . '">' . _('Copy') . '</a>';
            $str .= '</td>';
            $str .= '</tr>';
        }
    }
    $str .= '</table>';
    $str .= '</div>';
    return $str;
}
Beispiel #4
0
function mx_xmlsearch($query, $qtype = 'persons', $fld)
{
    global $mxdb, $mxuser;
    //echo 'Soon, you\'ll be able to find the results of your search for ['.$action.'] here...';
    $search = $mxdb->search($query);
    if (!$search) {
        __('No result found.');
        return;
    }
    if ($qtype == 'persons') {
        echo '<table class="searchresult">';
        $class = '';
        // class="selected"';
        if (count($search['persons']) > 0) {
            $i = 0;
            foreach ($search['persons'] as $result) {
                if ($i > 3) {
                    continue;
                }
                $i++;
                $foundstr = str_ireplace($query, '<span class="searchstring">' . $query . '</span>', $result->fullname);
                echo '<tr id="' . $result->id . '"' . $class . ' onmouseover="selresult(this);" onmouseout="unselresult(this);">' . '<td onclick="setfield(\'' . $fld . '\',\'' . $result->id . '\',\'' . $result->fullname . '\');">' . '<img src="' . mx_fanpic($result->id, 'square', $result->gender, false) . '"/> ' . $foundstr . ' <span class="resulttype">(' . _('Fan') . ')</span>' . '<input type="hidden" id="n_' . $result->id . '" value="' . $result->fullname . '"></td></tr>';
                $class = '';
            }
        }
        if (count($search['artists']) > 0) {
            $i = 0;
            foreach ($search['artists'] as $result) {
                if ($i > 3) {
                    continue;
                }
                $i++;
                $foundstr = str_ireplace($query, '<span class="searchstring">' . $query . '</span>', $result->artistname);
                echo '<tr id="' . $result->id . '"' . $class . ' onmouseover="selresult(this);" onmouseout="unselresult(this);">' . '<td onclick="setfield(\'' . $fld . '\',\'' . $result->id . '\',\'' . $result->artistname . '\');">' . '<img src="' . mx_fanpic($result->id, 'square', $result->gender, true) . '"> ' . $foundstr . ' <span class="resulttype">(' . ($result->acctype == MXACCOUNTBAND ? _('Band') : _('Artist')) . ')</span>' . '<input type="hidden" id="n_' . $result->id . '" value="' . $result->artistname . '"></td></tr>';
                $class = '';
            }
        }
        if (count($search['medias']) > 0) {
            $i = 0;
            foreach ($search['medias'] as $result) {
                if ($i > 3) {
                    continue;
                }
                $i++;
                $media = $mxuser->getmediainfo($result->id);
                $fanship = $mxuser->getfanship($media->owner_id, $media->id);
                mx_medialist($media, $fanship);
                $foundstr = sprintf('%s<br/>by %s', str_ireplace($query, '<span class="searchstring">' . $query . '</span>', $media->title), $media->artistname);
                echo '<tr id="' . $result->id . '"' . $class . ' onmouseover="selresult(this);" onmouseout="unselresult(this);">' . '<td onclick="setfield(\'' . $fld . '\',\'' . $result->id . '\',\'' . $result->title . '\');">' . '<img src="' . $media->pic . '"> ' . $foundstr . ' <span class="resulttype">(' . _('Media') . ')</span>' . '<input type="hidden" id="n_' . $result->id . '" value="' . $media->title . '"></td></tr>';
                $class = '';
            }
        }
        if ($fld != 'to') {
            echo '<tr id="default"' . $class . ' onmouseover="selresult(this);">' . '<td onclick="setfield(\'' . $fld . '\',\'default\',\'' . $query . '\');">' . '&rarr;' . _('More Results') . '<input type="hidden" id="n_default" value="' . $query . '"></td></tr>';
        }
        echo '</table>';
    }
}
Beispiel #5
0
 function picture($size = 'large')
 {
     $str = '<img title="' . $this->getname() . ' - ' . _('See Your Page') . '" tag="' . $this->id . '" class="profilepic pictooltip" style="cursor:pointer;" src="' . mx_fanpic($this->id, $size, $this->gender, is_artist()) . '"' . ($this->id ? 'onclick="window.location=\'' . mx_pageurl('account') . '\';"' : MXICONCLICK) . '>';
     if ($this->picture == 'fb') {
         return '<div class="userpic">' . '<div class="pending">' . mx_icon('working.gif', 'updating', '16px') . '</div>' . $str . '<script>$(window).load(function() {savefbpics();});</script>' . '</div>';
     }
     return '<div class="userpic"' . ($this->id && $this->status >= MXACCTSETUP ? ' onmouseover="showbutton(\'profilepic\');"' . ' onmouseout="hidebutton(\'profilepic\');"' : '') . '>' . '<div id="profilepic" class="picbutton" onclick="window.location=\'' . mx_actionurl('account', 'profile', 'edit', 'picinfo') . '\';">' . _('Update Pic') . '</div>' . $str . '</div>';
 }
Beispiel #6
0
function mx_metatags()
{
    global $mxuser;
    $page = mx_secureword($_GET['p']);
    $option = mx_secureword($_GET['o']);
    $action = $_REQUEST['a'];
    $updtime = '<meta property="og:updated_time" content="' . time() . '" />';
    if ($page != 'artists' && $page != 'fans' && $page != 'media') {
        echo '<meta property="og:title" content="MusXpand - ' . mx_option('title') . '" />' . '<meta name="title" content="MusXpand - ' . mx_option('title') . '" />' . '<meta property="og:type" content="website" />' . '<meta property="og:url" content="' . mx_option('basicsiteurl') . '" />' . '<meta property="og:image" content="' . mx_option('m-logoURL-48x48') . '" />' . '<meta property="og:site_name" content="MusXpand" />' . '<meta property="fb:app_id" content="' . FACEBOOK_APP_ID . '" />' . '<meta property="fb:admins" content="100001498041340" />' . $updtime . '<meta name="description" content="MusXpand is an open social network for artists and fans to share media, news and comments." />' . '<meta name="copyright" content="2010-2012 © MusXpand." />' . '<meta name="keywords" content="' . MXKEYWORDS . '" />' . '<link rel="canonical" href="http://www.example.com">';
        return;
    }
    if ($page == 'artists' && $option == 'artprof' && $action) {
        $user = $mxuser->getuserinfo($action);
        $artistname = mx_getartistname($user);
        $location = '';
        if ($user->city) {
            $location .= $user->city;
        }
        if ($user->state) {
            $location .= ($location ? ', ' : '') . $user->state;
        }
        if ($user->country) {
            $location .= ($location ? ', ' : '') . mx_getcountryname($user->country);
        }
        if ($location) {
            $location .= '. ';
        }
        $url = $user->username ? mx_option('basicsiteurl') . '/a/' . $user->username : mx_actionurl_prod($page, $option, $user->id, '', '', true);
        echo '<meta property="og:title" content="' . $artistname . '" />' . '<meta name="title" content="' . sprintf(_('%s on MusXpand'), $artistname) . '" />' . '<meta name="description" content="' . htmlentities($user->shortbio) . ' - ' . $artistname . ' is a MusXpand Artist." />' . '<meta name="copyright" content="2010-2012 © MusXpand & ' . $artistname . '" />' . '<meta name="keywords" content="' . MXKEYWORDS . ',' . $artistname . '" />' . '<meta property="og:type" content="musxpand:artist" />' . '<meta property="og:url" content="' . $url . '" />' . '<meta property="og:audio" content="' . $url . '" />' . '<meta property="og:audio:type" content="vnd.facebook.bridge" />' . '<meta property="og:image" content="' . mx_fanpic($user->id, 'large') . '" />' . '<meta property="og:site_name" content="MusXpand" />' . '<meta property="og:description" content="' . htmlentities($location . $user->shortbio) . '" />' . $updtime . '<meta property="fb:app_id" content="' . FACEBOOK_APP_ID . '" />' . ($user->fbid ? '<meta property="fb:admins" content="' . $user->fbid . '" />' : '') . '<link rel="canonical" href="' . mx_actionurl_prod($page, $option, $user->id, '', '', true) . '">';
        return;
    } else {
        if ($page == 'account' && $option == 'myartpage') {
            $artistname = $mxuser->getartistname();
            $location = '';
            if ($mxuser->city) {
                $location .= $mxuser->city;
            }
            if ($mxuser->state) {
                $location .= ($location ? ', ' : '') . $mxuser->state;
            }
            if ($mxuser->country) {
                $location .= ($location ? ', ' : '') . mx_getcountryname($mxuser->country);
            }
            if ($location) {
                $location .= '. ';
            }
            $url = $user->username ? mx_option('basicsiteurl') . '/a/' . $mxuser->username : mx_actionurl_prod('artists', 'artprof', $mxuser->id, '', '', true);
            echo '<meta property="og:title" content="' . $artistname . '" />' . '<meta name="title" content="' . sprintf(_('%s on MusXpand'), $artistname) . '" />' . '<meta name="description" content="' . htmlentities($mxuser->shortbio) . ' - ' . $artistname . ' is a MusXpand Artist." />' . '<meta name="copyright" content="2010-2012 © MusXpand & ' . $artistname . '" />' . '<meta name="keywords" content="' . MXKEYWORDS . ',' . $artistname . '" />' . '<meta property="og:type" content="musxpand:artist" />' . '<meta property="og:url" content="' . $url . '" />' . '<meta property="og:audio" content="' . $url . '" />' . '<meta property="og:audio:type" content="vnd.facebook.bridge" />' . '<meta property="og:image" content="' . mx_fanpic($mxuser->id, 'large') . '" />' . '<meta property="og:site_name" content="MusXpand" />' . '<meta property="og:description" content="' . htmlentities($location . $mxuser->shortbio) . '" />' . $updtime . '<meta property="fb:app_id" content="' . FACEBOOK_APP_ID . '" />' . ($mxuser->fbid ? '<meta property="fb:admins" content="' . $mxuser->fbid . '" />' : '') . '<link rel="canonical" href="' . mx_actionurl_prod('artists', 'artprof', $mxuser->id, '', '', true) . '">';
            return;
        } else {
            if ($page == 'fans' && $option == 'fanprof' && $action) {
                $user = $mxuser->getuserinfo($action);
                $fanname = mx_getname($user);
                $location = '';
                if ($user->city) {
                    $location .= $user->city;
                }
                if ($user->state) {
                    $location .= ($location ? ', ' : '') . $user->state;
                }
                if ($user->country) {
                    $location .= ($location ? ', ' : '') . mx_getcountryname($user->country);
                }
                $url = $user->username ? mx_option('basicsiteurl') . '/f/' . $user->username : mx_actionurl_prod($page, $option, $user->id, '', '', true);
                echo '<meta property="og:title" content="' . $fanname . '" />' . '<meta name="title" content="' . sprintf(_('%s on MusXpand'), $fanname) . '" />' . '<meta name="description" content="' . htmlentities($user->shortbio) . ' - ' . $fanname . ' is a MusXpand Fan." />' . '<meta name="copyright" content="2010-2012 © MusXpand & ' . $fanname . '" />' . '<meta name="keywords" content="' . MXKEYWORDS . ',' . $fanname . '" />' . '<meta property="og:type" content="profile" />' . '<meta property="og:url" content="' . $url . '" />' . '<meta property="og:image" content="' . mx_fanpic($user->id, 'large') . '" />' . '<meta property="og:site_name" content="MusXpand" />' . '<meta property="og:description" content="' . htmlentities($user->shortbio) . '" />' . $updtime . '<meta property="musxpand:location" content="' . $location . '" />' . '<meta property="fb:app_id" content="' . FACEBOOK_APP_ID . '" />' . ($user->fbid ? '<meta property="fb:admins" content="' . $user->fbid . '" />' : '') . '<link rel="canonical" href="' . mx_actionurl_prod($page, $option, $user->id, '', '', true) . '">';
                return;
            } else {
                if ($page == 'account' && $option == 'myfanpage') {
                    $fanname = $mxuser->getname();
                    $location = '';
                    if ($mxuser->city) {
                        $location .= $mxuser->city;
                    }
                    if ($mxuser->state) {
                        $location .= ($location ? ', ' : '') . $mxuser->state;
                    }
                    if ($mxuser->country) {
                        $location .= ($location ? ', ' : '') . mx_getcountryname($mxuser->country);
                    }
                    $url = $user->username ? mx_option('basicsiteurl') . '/f/' . $mxuser->username : mx_actionurl_prod('fans', 'fanprof', $mxuser->id, '', '', true);
                    echo '<meta property="og:title" content="' . $fanname . '" />' . '<meta name="title" content="' . sprintf(_('%s on MusXpand'), $fanname) . '" />' . '<meta name="description" content="' . htmlentities($mxuser->shortbio) . ' - ' . $fanname . ' is a MusXpand Fan." />' . '<meta name="copyright" content="2010-2012 © MusXpand & ' . $fanname . '" />' . '<meta name="keywords" content="' . MXKEYWORDS . ',' . $fanname . '" />' . '<meta property="og:type" content="profile" />' . '<meta property="og:url" content="' . $url . '" />' . '<meta property="og:image" content="' . mx_fanpic($mxuser->id, 'large') . '" />' . '<meta property="og:site_name" content="MusXpand" />' . '<meta property="og:description" content="' . htmlentities($mxuser->shortbio) . '" />' . $updtime . '<meta property="musxpand:location" content="' . $location . '" />' . '<meta property="fb:app_id" content="' . FACEBOOK_APP_ID . '" />' . ($mxuser->fbid ? '<meta property="fb:admins" content="' . $mxuser->fbid . '" />' : '') . '<link rel="canonical" href="' . mx_actionurl_prod('fans', 'fanprof', $mxuser->id, '', '', true) . '">';
                    return;
                } else {
                    if ($page == 'media' && $option == 'medprof' && $action) {
                        $media = $mxuser->getmediainfo($action);
                        $artistname = mx_getartistname($media);
                        $fanship = $mxuser->getfanship($media->owner_id, $media->id);
                        mx_medialist($media, $fanship, true);
                        $mediameta = '';
                        $mediadesc = $media->description;
                        $url = mx_option('basicsiteurl') . '/m/' . $action;
                        switch ($media->type) {
                            case MXMEDIAINSTR:
                            case MXMEDIASONG:
                                //$mediatype='music.song';
                                $mediatype = 'musxpand:media';
                                $mediaurl = mx_medialink($media->filename, $media->hashcode, $media->hashdir, '-preview');
                                $mediameta = '<meta property="music:duration" content="' . $media->duration . '" />' . '<meta property="og:audio" content="' . $mediaurl . '" />' . '<meta property="og:audio:secure_url" content="' . str_replace('http:', 'https:', $mediaurl) . '" />' . '<meta property="og:audio:type" content="audio/vnd.facebook.bridge" />' . '<meta property="music:musician" content="' . mx_actionurl('artists', 'artprof', $media->owner_id) . '" />' . '<meta property="music:album" content="' . mx_actionurl('media', 'medprof', $media->bundles[0]->id) . '" />' . '<meta property="og:audio:title" content="' . $media->title . ' (' . _('Sample') . ')" />' . '<meta property="og:audio:artist" content="' . $artistname . '" />' . '<meta property="og:audio:album" content="' . htmlentities($media->bundles[0]->title) . '" />' . '<meta property="og:video" content="' . mx_option('siteurl') . '/flash/xspf_player_slim.swf?' . 'player_title=' . htmlentities('Listen to music on MusXpand') . '&song_url=' . urlencode($mediaurl) . '&song_title=' . htmlentities($media->title) . '" />' . '<meta property="og:video:secure_url" content="' . mx_option('secure_siteurl') . '/flash/xspf_player_slim.swf?' . 'player_title=' . htmlentities('Listen to music on MusXpand') . '&song_url=' . urlencode($mediaurl) . '&song_title=' . htmlentities($media->title) . '" />' . '<meta property="og:video:height" content="17" />' . '<meta property="og:video:type" content="application/x-shockwave-flash" />';
                                //.'<meta property="og:video:title" content="'.$media->title.' ('._('Sample').')" />'
                                //.'<meta property="og:video:director" content="'.$artistname.'" />'
                                //.'<meta property="og:video:album" content="'.htmlentities($media->bundles[0]->title).'" />'
                                break;
                            case MXMEDIABG:
                            case MXMEDIAPIC:
                                $mediatype = 'musxpand:picture';
                                break;
                            case MXMEDIABASEBUNDLE:
                            case MXMEDIAREGULARBUNDLE:
                                $mediatype = 'musxpand:bundle';
                                /*$mediameta='<meta property="og:audio" content="'.$url.'" />'
                                		.'<meta property="og:audio:type" content="vnd.facebook.bridge" />';*/
                                break;
                            case MXMEDIAVIDEO:
                                //$mediatype='musxpand:videoclip';
                                $mediatype = 'musxpand:media';
                                $mediaurl = mx_medialink($media->filename, $media->hashcode, $media->hashdir, '');
                                $mediameta = '<meta property="og:video" content="' . $mediaurl . '" />' . '<meta property="og:video:secure_url" content="' . str_replace('http:', 'https:', $mediaurl) . '" />' . '<meta property="og:video:type" content="video/mp4" />';
                                break;
                            case MXMEDIADOC:
                                $mediatype = 'musxpand:document';
                                break;
                            default:
                                $mediatype = 'musxpand:media';
                        }
                        echo '<meta property="og:title" content="' . htmlentities(sprintf(_('%s by %s'), $media->title, $artistname)) . '" />' . '<meta name="title" content="' . htmlentities(sprintf(_('%s by %s'), $media->title, $artistname)) . '" />' . '<meta name="description" content="' . htmlentities($media->description) . '" />' . '<meta name="copyright" content="2010-2012 © MusXpand & ' . $artistname . '" />' . '<meta name="keywords" content="' . MXKEYWORDS . ',' . $artistname . ',' . $media->title . '" />' . '<meta property="og:type" content="' . $mediatype . '" />' . '<meta property="og:url" content="' . $url . '" />' . '<meta property="og:image" content="' . $media->pic . '" />' . $mediameta . '<meta property="musxpand:artist" content="' . mx_actionurl('artists', 'artprof', $media->owner_id) . '" />' . ($media->type != MXMEDIAREGULARBUNDLE && $media->type != MXMEDIABASEBUNDLE ? '<meta property="musxpand:bundle" content="' . mx_actionurl('media', 'medprof', $media->bundles[0]->id) . '" />' : '') . '<meta property="og:site_name" content="MusXpand" />' . '<meta property="og:description" content="' . htmlentities($mediadesc) . '" />' . $updtime . '<meta property="fb:app_id" content="' . FACEBOOK_APP_ID . '" />' . ($media->fbid ? '<meta property="fb:admins" content="' . $media->fbid . '" />' : '') . '<link rel="canonical" href="' . mx_actionurl_prod('media', 'medprof', $media->id, '', '', true) . '">';
                        return;
                    }
                }
            }
        }
    }
}
Beispiel #7
0
function mx_showmessages($action)
{
    global $mxuser;
    $listorder = mx_secureword($_GET['s']);
    if ($listorder != '') {
        $listorder .= ' asc';
    }
    $msgs = $mxuser->listmessages(null, $listorder);
    if (!$msgs) {
        __('Your message box is empty.');
        return;
    }
    $allmsgs = array();
    $msglist = array('msglist', 0, _('Message List'), sprintf(_('If you want to compose a new message, click %s.'), '<a href="javascript:tabswitch(\'inbox\',\'writemsg\');">' . _('here') . '</a>'), array('inbox' => array('delete_inbox' => _('Delete'), 'archive_inbox' => _('Archive')), 'outbox' => array('delete_outbox' => _('Delete'), 'archive_outbox' => _('Archive')), 'requests' => array('accept_requests' => _('Accept'), 'recuse_requests' => _('Recuse'), 'ignore_requests' => _('Ignore')), 'reqsent' => array('cancel_reqsent' => _('Cancel'), 'archive_reqsent' => _('Archive')), 'archives' => array('delete_archives' => _('Delete')), 'drafts' => array('delete_drafts' => _('Delete'), 'archive_drafts' => _('Archive')), 'writemsg' => array('send' => _('Send'), 'save' => _('Save'), 'clear' => _('Clear'))), array('inbox' => array(0, 'inbox' => array(-1, _('Inbox'), _('The messages you received')), 'select' => array(0, '<input name="checkallbox" type="checkbox" onclick="javascript:checkall(\'inbox\');">', 'text', 3), 'contact' => array(0, _('From'), 'text', 40), 'topic' => array(0, _('Topic'), 'text', 40), 'flags' => array(0, 0, 'hidden'), 'date' => array(0, _('Date'), 'timestamp', 12), 'a' => array(1, 'none', 'hidden'), 'k' => array(1, 'inbox', 'hidden')), 'outbox' => array(0, 'outbox' => array(-1, _('Outbox'), _('The messages you sent')), 'select' => array(0, '<input name="checkallbox" type="checkbox" onclick="javascript:checkall(\'outbox\');">', 'text', 3), 'contact' => array(0, _('To'), 'text', 40), 'topic' => array(0, _('Topic'), 'text', 40), 'flags' => array(0, 0, 'hidden'), 'date' => array(0, _('Date'), 'timestamp', 12), 'a' => array(1, 'none', 'hidden'), 'k' => array(1, 'outbox', 'hidden')), 'requests' => array(0, 'requests' => array(-1, _('Requests'), _('Checking your pending requests?')), 'select' => array(0, '<input name="checkallbox" type="checkbox" onclick="javascript:checkall(\'requests\');">', 'text', 3), 'contact' => array(0, _('From'), 'text', 60), 'flags' => array(0, _('Type'), 'msgflags', 20), 'date' => array(0, _('Date'), 'timestamp', 12), 'a' => array(1, 'none', 'hidden'), 'k' => array(1, 'requests', 'hidden')), 'reqsent' => array(0, 'reqsent' => array(-1, _('Sent Req.'), _('Do you want to cancel any requests you sent?')), 'select' => array(0, '<input name="checkallbox" type="checkbox" onclick="javascript:checkall(\'reqsent\');">', 'text', 3), 'contact' => array(0, _('From'), 'text', 60), 'flags' => array(0, _('Type'), 'msgflags', 20), 'date' => array(0, _('Date'), 'timestamp', 12), 'a' => array(1, 'none', 'hidden'), 'k' => array(1, 'reqsent', 'hidden')), 'archives' => array(0, 'archives' => array(-1, _('Archives'), _('Your arquived messages')), 'select' => array(0, '<input name="checkallbox" type="checkbox" onclick="javascript:checkall(\'archives\');">', 'text', 3), 'contact' => array(0, _('From | To'), 'text', 40), 'topic' => array(0, _('Topic'), 'text', 40), 'a' => array(1, 'none', 'hidden'), 'date' => array(0, _('Date'), 'timestamp', 12), 'flags' => array(0, 0, 'hidden'), 'k' => array(1, 'archives', 'hidden')), 'drafts' => array(0, 'drafts' => array(-1, _('Drafts'), _('Messages previously saved')), 'select' => array(0, '<input name="checkallbox" type="checkbox" onclick="javascript:checkall(\'drafts\');">', 'text', 3), 'contact' => array(0, _('To'), 'text', 40), 'topic' => array(0, _('Topic'), 'text', 40), 'date' => array(0, _('Date'), 'timestamp', 12), 'flags' => array(0, 0, 'hidden'), 'a' => array(1, 'none', 'hidden'), 'k' => array(1, 'drafts', 'hidden')), 'writemsg' => array(1, 'writemsg' => array(-1, _('Write Box'), _('Hey! Writing to friends?')), 'to' => array(1, _('To'), 'user', 40), 'subject' => array(1, _('Subject'), 'subject', 40), 'body' => array(1, _('Body'), 'memo', 10, null, _('Verba volant, scripta manent...'), 54), 'history' => array(0, _('Message History'), 'hiddenmemo', 5), 'flags' => array(1, 0, 'hidden'), 'a' => array(1, 'none', 'hidden'), 'priority' => array(1, 0, 'hidden'), 'refid' => array(1, 0, 'hidden'), 'k' => array(1, 'writemsg', 'hidden'))));
    /* new sorting method: buttons next/previous should work per msg category...
    	while ($msg=$mxuser->listmessages($msgs)) {
    		$buttons=null;
    		if ($msg->flags & MXREQUEST) {
    			if ($msg->sender==$mxuser->id) {
    				$buttons['cancel:'.$msg->msgid]=_('Cancel');
    				$buttons['archive:'.$msg->msgid]=_('Archive');
    			} else {
    				$buttons['accept:'.$msg->msgid]=_('Accept');
    				$buttons['recuse:'.$msg->msgid]=_('Recuse');
    				$buttons['ignore:'.$msg->msgid]=_('Ignore');
    				$buttons['sep4']=null;
    				$buttons['reply:'.$msg->msgid]=_('Reply');
    				$buttons['forward:'.$msg->msgid]=_('Forward');
    			}
    			$buttons['sep3']=null;
    		} else {
    			if ($msg->sender==$mxuser->id) {
    				$buttons['resend:'.$msg->msgid]=_('Resend');
    				$buttons['sep2']=null;
    			}
    			$buttons['delete:'.$msg->msgid]=_('Delete');
    			$buttons['archive:'.$msg->msgid]=_('Archive');
    			$buttons['sep1']=null;
    		}
    		if ($msg->prev) $buttons['previous:'.$msg->prev]=_('Previous');
    		else $buttons['-previous']=_('Previous');
    		if ($msg->next) $buttons['next:'.$msg->next]=_('Next');
    		else $buttons['-next']=_('Next');
    		$msg->select='<input type="checkbox" name="selmsg[]" value="'.$msg->msgid.'">';
    		$msg->select.='<div class="contentframe"><div id="'.$msg->msgid.'" class="msgcontent" style="display:none;">';
    		$msgform=array(
    			'msgform',0,_('Message read'),_('Details...'),
    			$buttons,
    			array(
    				'from'  => array(1,_('From:'),'text',40),
    				'h_from'  => array(1,0,'hidden',40),
    				'to'  => array(1,_('To:'),'text',40),
    				'h_to'  => array(1,0,'hidden',40),
    				'date'  => array(1,_('Date:'),'text',40),
    				'flags'  => array(1,_('Flags:'),'msgflags',40),
    				'subject' => array(0,_('Subject:'),'text',40),
    				'body' => array(0,_('Body:'),'text',60)
    			)
    		);
    		$msg->select.=mx_letterstr($msgform,array(
    			'from' => ($mxuser->id==$msg->sender)?_('Me'):($msg->fullname?$msg->fullname:$msg->artistname),
    			'to' => ($mxuser->id==$msg->receiver)?_('Me'):($msg->fullname?$msg->fullname:$msg->artistname),
    			'h_to' => ($mxuser->id==$msg->receiver)?$mxuser->id:$msg->receiver,
    			'h_from' => ($mxuser->id==$msg->sender)?$mxuser->id:$msg->sender,
    			'date' => $msg->date,
    			'subject' => $msg->subject,
    			'flags' => $msg->flags,
    			'body' => mx_msgformat($msg->body),
    			'msgid' => $msg->msgid
    			),false);
    		$msg->select.='<div class="msgclose"><a href="javascript:hidecontent('.$msg->msgid.')">'._('X').'</a>' .
    			'</div></div></div>';
    		$msg->contact='<div class="msgline"><img class="msgpic" src="'.mx_fanpic($msg->id,'square').'" />';
    		$msg->contact.=' '.(($mxuser->id==$msg->sender)?(_('Me').' &rarr;'):'');
    		$msg->contact.=' '.($msg->fullname?$msg->fullname:$msg->artistname);
    		$msg->contact.=' '.(($mxuser->id==$msg->sender)?'':('&rarr; '._('Me')));
    		$msg->contact.='</div>';
    		$msg->topic=$msg->subject.'<div class="bodyextract">&ldquo;'.(strlen($msg->body)>40?(substr($msg->body,0,40).'[&hellip;]'):$msg->body).'&rdquo;</div>';
    		$msg->read = ($msg->status & MXMSGREAD)?true:false;
    		//$msg->flags = ($msg->flags | MXMSGREQUEST)?'true':'false';
    		if (!$msg->level) $msg->level='';
    		$allmsgs['messages'][]=$msg;
    		if ($mxuser->id==$msg->receiver) { // receiver
    			if (!($msg->status & MXMSGDELETED)) {
    				if ($msg->status & MXMSGARCHIVED) $allmsgs['archives'][]=$msg;
    				else $allmsgs['inbox'][]=$msg;
    			}
    		}
    		if ($mxuser->id==$msg->sender) {
    			if (!($msg->sstatus & MXMSGDELETED)) {
    				if ($msg->sstatus & MXMSGARCHIVED) $allmsgs['archives'][]=$msg;
    				else $allmsgs['outbox'][]=$msg;
    				if ($msg->sstatus & MXMSGDRAFT) $allmsgs['drafts'][]=$msg;
    			}
    		}
    		if ($msg->flags & MXREQUEST) $allmsgs['requests'][]=$msg;
    		$msg=$nmsg;
    	}
    	*/
    /* old sorting method buttons next/previous are global :-( */
    $msg = null;
    while ($msgs && ($nmsg = $mxuser->listmessages($msgs)) || $msg) {
        //print_r($msg);
        if (!$msg) {
            $msg = $nmsg;
            $msg->prev = null;
            continue;
        } else {
            if ($nmsg) {
                $nmsg->prev = $msg->msgid;
            }
        }
        if (!$nmsg) {
            $msg->next = null;
            $msgs = null;
        } else {
            $msg->next = $nmsg->msgid;
        }
        $buttons = null;
        if ($msg->flags & MXREQUEST) {
            if ($msg->sender == $mxuser->id) {
                $buttons['cancel:' . $msg->msgid] = _('Cancel');
                $buttons['archive:' . $msg->msgid] = _('Archive');
            } else {
                $buttons['accept:' . $msg->msgid] = _('Accept');
                $buttons['recuse:' . $msg->msgid] = _('Recuse');
                $buttons['ignore:' . $msg->msgid] = _('Ignore');
                $buttons['sep4'] = null;
                $buttons['reply:' . $msg->msgid] = _('Reply');
                $buttons['forward:' . $msg->msgid] = _('Forward');
            }
            $buttons['sep3'] = null;
        } else {
            if ($msg->sender == $mxuser->id) {
                $buttons['resend:' . $msg->msgid] = _('Resend');
                $buttons['sep2'] = null;
            } else {
                $buttons['reply:' . $msg->msgid] = _('Reply');
                $buttons['forward:' . $msg->msgid] = _('Forward');
                $buttons['sep2'] = null;
            }
            $buttons['delete:' . $msg->msgid] = _('Delete');
            $buttons['archive:' . $msg->msgid] = _('Archive');
            $buttons['sep1'] = null;
        }
        if ($msg->prev) {
            $buttons['previous:' . $msg->prev] = _('Previous');
        } else {
            $buttons['-previous'] = _('Previous');
        }
        if ($msg->next) {
            $buttons['next:' . $msg->next] = _('Next');
        } else {
            $buttons['-next'] = _('Next');
        }
        $msg->select = '<input type="checkbox" name="selmsg[]" value="' . $msg->msgid . '">';
        $msg->select .= '<div class="contentframe"><div id="' . $msg->msgid . '" class="msgcontent" style="display:none;">';
        $msgform = array('msgform', 0, _('Message read'), _('Details...'), $buttons, array('from' => array(1, _('From:'), 'text', 40), 'h_from' => array(1, 0, 'hidden', 40), 'to' => array(1, _('To:'), 'text', 40), 'h_to' => array(1, 0, 'hidden', 40), 'date' => array(1, _('Date:'), 'date', 40), 'flags' => array(1, _('Flags:'), 'msgflags', 40), 'subject' => array(0, _('Subject:'), 'text', 40), 'body' => array(0, _('Body:'), 'text', 60)));
        $msg->select .= mx_letterstr($msgform, array('from' => $mxuser->id == $msg->sender ? _('Me') : ($msg->fullname ? $msg->fullname : $msg->artistname), 'to' => $mxuser->id == $msg->receiver ? _('Me') : ($msg->fullname ? $msg->fullname : $msg->artistname), 'h_to' => $mxuser->id == $msg->receiver ? $mxuser->id : $msg->receiver, 'h_from' => $mxuser->id == $msg->sender ? $mxuser->id : $msg->sender, 'date' => $msg->date, 'subject' => $msg->subject, 'flags' => $msg->flags, 'body' => mx_msgformat($msg->body), 'msgid' => $msg->msgid), false);
        $msg->select .= '<div class="msgclose"><a href="javascript:hidecontent(' . $msg->msgid . ')">' . _('X') . '</a>' . '</div></div></div>';
        $msg->contact = '<div class="msgline"><img class="msgpic" src="' . mx_fanpic($msg->id, 'square', $msg->gender, $msg->acctype == MXACCOUNTARTIST) . '" />';
        $msg->contact .= ' ' . ($mxuser->id == $msg->sender ? _('Me') . ' &rarr;' : '');
        $msg->contact .= ' ' . ($msg->fullname ? $msg->fullname : $msg->artistname);
        $msg->contact .= ' ' . ($mxuser->id == $msg->sender ? '' : '&rarr; ' . _('Me'));
        $msg->contact .= '</div>';
        $msg->topic = $msg->subject . '<div class="bodyextract">&ldquo;' . (strlen($msg->body) > 40 ? substr($msg->body, 0, 40) . '[&hellip;]' : $msg->body) . '&rdquo;</div>';
        $msg->read = $msg->status & MXMSGREAD ? true : false;
        $msg->ignored = $msg->status & MXREQIGNORED ? true : false;
        $msg->cancelled = $msg->status & MXREQCANCELLED ? true : false;
        //$msg->flags = ($msg->flags | MXMSGREQUEST)?'true':'false';
        if (!$msg->level) {
            $msg->level = '';
        }
        $allmsgs['messages'][] = $msg;
        if ($mxuser->id == $msg->receiver) {
            // receiver
            if (!($msg->status & (MXMSGDELETED | MXREQCANCELLED | MXREQIGNORED))) {
                if ($msg->status & MXMSGARCHIVED) {
                    $allmsgs['archives'][] = $msg;
                } else {
                    if ($msg->flags & MXREQUEST) {
                        $allmsgs['requests'][] = $msg;
                    } else {
                        $allmsgs['inbox'][] = $msg;
                    }
                }
            }
        }
        if ($mxuser->id == $msg->sender) {
            if (!($msg->sstatus & (MXMSGDELETED | MXREQCANCELLED))) {
                if ($msg->sstatus & MXMSGARCHIVED) {
                    $allmsgs['archives'][] = $msg;
                } else {
                    if ($msg->flags & MXREQUEST) {
                        $allmsgs['reqsent'][] = $msg;
                    } else {
                        if ($msg->sstatus & MXMSGDRAFT) {
                            $allmsgs['drafts'][] = $msg;
                        } else {
                            $allmsgs['outbox'][] = $msg;
                        }
                    }
                }
            }
        }
        $msg = $nmsg;
    }
    /* end old sorting method */
    if (preg_match('%^(af:(.+))$%', $action, $actionarg) > 0) {
        $user = $mxuser->getuserinfo($actionarg[2]);
        $allmsgs['writemsg'] = array('to' => $user->id, 'subject' => _('Friendship Request'), 'flags' => MXFRIENDREQUEST, 'body' => _('Hi there. Could you please accept this request for friendship...?'));
        //error_log(print_r($allmsgs['writemsg'],true));
    }
    //error_log($action);
    if (preg_match('%^(sm:(.+))$%', $action, $actionarg) > 0) {
        $user = $mxuser->getuserinfo($actionarg[2]);
        $allmsgs['writemsg'] = array('to' => $user->id, 'subject' => '', 'body' => '');
    }
    mx_showlist($msglist, $allmsgs, 'messages', true, true);
    if (preg_match('%(rp:([0-9]+))%', $action, $actionarg) > 0) {
        ?>
		<script language="javascript">buttonclick('reply:<?php 
        echo $actionarg[2];
        ?>
');</script>
		<?php 
    }
}