Example #1
0
/**
 * Echo records in desired format to stdout
 *
 * @param array $records
 * @return null
 */
function printRecords($records)
{
    foreach ($records as $format => $recordsByFormat) {
        echo "\n" . $format . "\n" . '***' . "\n";
        usort($recordsByFormat, function ($a, $b) {
            return strcasecmp($a['artist'], $b['artist']);
        });
        foreach ($recordsByFormat as $record) {
            echo (array_key_exists('price', $record) ? (int) $record['price'] . ' e ' : '') . getArtist($record['artist']) . ' - ' . $record['title'] . getFormatModifiers($record['format']) . "\n";
        }
    }
    return null;
}
    global $artistList;
    $limit_start = $counter;
    $limit_stop = $counter + 20;
    $conn = db_connect();
    $conn->set_charset("utf8");
    // 指定数据库字符编码
    $result = $conn->query("select artist.id, artist.name, artist.avatar, company.name as company, artist.comments_number, artist.score from decoration_artist as artist, decoration_company as company WHERE artist.company = company.id LIMIT {$limit_start}, {$limit_stop} ");
    if (!$result) {
        throw new Exception('Search user score failed.');
    }
    $num_result = $result->num_rows;
    $artistList['total'] = $num_result;
    //数据库查询出来的字段全部是字符串,另外json定义跟数据库定义可能不一致,所以需要做相应地转换
    for ($i = 0; $i < $num_result; $i++) {
        $row_db = $result->fetch_assoc();
        $converted_row = array();
        //保存转换后的单条记录
        $converted_row['id'] = intval(stripslashes($row_db['id']));
        $converted_row['name'] = stripslashes($row_db['name']);
        $converted_row['avatar'] = stripslashes($row_db['avatar']);
        $converted_row['company'] = stripslashes($row_db['company']);
        $converted_row['comments'] = intval(stripslashes($row_db['comments_number']));
        $converted_row['score'] = intval(stripslashes($row_db['score']));
        $artistList["row"][$i] = $converted_row;
    }
    $result->free();
    $conn->close();
    return json_encode($artistList);
}
$jsonStr = getArtist($param_counter);
print "{$jsonStr}";
Example #3
0
while ($review = mysql_fetch_array($result)) {
    $albumNo = $review['album_code'];
    $albumID = $review['albumID'];
    $title = $review['album_name'];
    $general_genreID = $review['general_genreID'];
    $review_query = "SELECT review, reviewer FROM libreview WHERE albumID = {$albumID}";
    $rev = mysql_query($review_query);
    $review_array = mysql_fetch_array($rev);
    $reviewtext = $review_array['review'];
    $reviewtext = str_replace(array("\r", "\r\n", "\n"), ' ', $reviewtext);
    $reviewtext = str_replace(array("      ", "     ", "    ", "   ", "  "), ' ', $reviewtext);
    $reviewer = $review_array['reviewer'];
    $reccs = getRecc($albumID);
    $noairs = getNoAir($albumID);
    $silence = getSilenceAfter($albumID);
    $artist = getArtist($review['artistID']);
    $genre = $review['genre'];
    $general_genre = getGeneralGenre($general_genreID);
    $pdf->LabelLayout($x, $y, $albumNo, $title, $artist, $genre, $reviewtext, $reviewer, $reccs, $noairs, $silence, $general_genre);
    if ($section == 1) {
        $x = 4.0 + $topx;
        //110,11
        $y = $topy;
    } else {
        if ($section == 2) {
            $x = $topx;
            //0,152
            $y = 5 + $topy;
        } else {
            if ($section == 3) {
                $x = 4.0 + $topx;
Example #4
0
function postArtist($overwriteIfExists, $artist, $albums)
{
    // TODO: IMPLEMENT
    ob_start();
    print_r($albums);
    $albumStr = ob_get_clean();
    $id = requestStarted(__METHOD__, $overwriteIfExists ? "overwrite" : "no-overwrite" . "{$artist}|{$albumStr}");
    $retVal = array('artist' => $artist, 'dataUsed' => false, 'message' => 'Not implemented yet.  This would give info on whether some of the data, none, or all of it was used');
    global $SHUT_DOWN_API;
    if ($SHUT_DOWN_API) {
        global $SHUT_DOWN_API_REASON;
        $retVal['message'] = $SHUT_DOWN_API_REASON;
    } else {
        global $wgUser;
        if (!$wgUser->isLoggedIn()) {
            // If this is a SOAP request, the credentials may be in the SOAP headers.
            global $funcsOnly;
            if ($funcsOnly) {
                // Not a SOAP request, so we have to already be logged in.
                $retVal['message'] = "Must be logged in to use postArtist().";
            } else {
                lw_tryLogin();
            }
        }
        $artistName = lw_getTitle($artist);
        $pageTitle = Title::newFromDBkey(utf8_decode(htmlspecialchars_decode($artistName)));
        $pageExists = $pageTitle && $pageTitle->exists();
        // call here and store the result to check after page is created to determine if it was an overwrite
        if ($pageExists) {
            // TODO: REMOVE
            if (false) {
                $currData = getArtist($artist);
                $currAlbums = $currData['albums'];
                $content = lw_getPage($artistName);
                // Find the appropriate place chronologically for the album and insert it.
                for ($cnt = 0; $cnt < count($albums); $cnt++) {
                    $activeAlbum = $albums[$cnt];
                    // the album we are going to insert
                    $activeAlbum = $activeAlbum['albums'];
                    // weird side-effect... every album is wrapped in an 'albums' array.
                    if (strtolower($activeAlbum['album']) == "other songs") {
                        $activeAlbum['year'] = 0;
                    }
                    /*if($artist == "Sahara Hotnights"){
                    			print "Active album:\n";
                    			print_r($activeAlbum);
                    			print "\nAll albums:\n";
                    			print_r($albums);
                    		}
                    		print (($artist!="Sahara Hotnights")?"":"Active album: *".$activeAlbum['album']."*\n");
                    		*/
                    // Find correct order to insert in.
                    $insertBefore = -1;
                    $doneAdding = false;
                    for ($index = 0; $index < count($currAlbums); $index++) {
                        $comparisonAlbum = $currAlbums[$index];
                        if ($activeAlbum['year'] < $comparisonAlbum['year'] && strtolower($activeAlbum['album']) != "other songs") {
                            $insertBefore = $index;
                            $index = count($currAlbums);
                            // stop looping
                        } else {
                            if ($activeAlbum['year'] == $comparisonAlbum['year']) {
                                if (strtolower($activeAlbum['album']) == strtolower($comparisonAlbum['album'])) {
                                    // Album already exists, just merge the track listings.
                                    $doneAdding = true;
                                    // album already exists, don't add whole album to the code
                                    $additionalTracks = array();
                                    $tracks = $activeAlbum['songs'];
                                    $tracksFound = $comparisonAlbum['songs'];
                                    foreach ($tracks as $currTrack) {
                                        $found = false;
                                        for ($trackNum = 0; $trackNum < count($tracksFound) && !$found; $trackNum++) {
                                            if ($currTrack == $tracksFound[$trackNum]) {
                                                $found = true;
                                            }
                                        }
                                        if (!$found) {
                                            $additionalTracks[] = $currTrack;
                                        }
                                    }
                                    // If there were extra tracks, add them to the end of the track listing
                                    if (count($additionalTracks) > 0) {
                                        $wikiCode = lw_tracksToWiki($artistName, $additionalTracks);
                                        $wikiCode = trim($wikiCode);
                                        $albumName = $comparisonAlbum['album'];
                                        $albumYear = $comparisonAlbum['year'];
                                        $albumName = str_replace(" ", "_", $albumName);
                                        $albumName = str_replace("_", "[_ ]", $albumName);
                                        $artistReg = str_replace(" ", "_", $artistName);
                                        $artistReg = str_replace("_", "[_ ]", $artistReg);
                                        if (strtolower($activeAlbum['album']) == "other songs") {
                                            //print (($artist!="Sahara Hotnights")?"":"Other songs merged\n");
                                            $content = preg_replace("/(==\\s*\\[\\[{$artistReg}:{$albumName}(\\|.*?\\]\\]|\\]\\])\\s*==\\s*.*?)(\n[^#*{])/si", "\$1\n{$wikiCode}\$3", $content);
                                        } else {
                                            //print (($artist!="Sahara Hotnights")?"":"Normal album merged\n");
                                            $content = preg_replace("/(==\\s*\\[\\[{$artistReg}:{$albumName}" . "[_ ]\\({$albumYear}\\)(\\|.*?\\]\\]|\\]\\])\\s*==\\s*.*?)(\n[^#*{])/si", "\$1\n{$wikiCode}\$3", $content);
                                        }
                                    }
                                }
                            }
                        }
                    }
                    // Search for a match in the code of where this album goes.
                    if (!$doneAdding) {
                        //print (($artist!="Sahara Hotnights")?"":"Still looking for album\n");
                        if ($insertBefore == -1) {
                            //print (($artist!="Sahara Hotnights")?"":"Album goes at end\n");
                            // Insert after the last album (if there is an Other Songs album, do it before that but after the last real album).
                            $wikiCode = lw_albumDataToWiki($artist, $activeAlbum);
                            if (count($currAlbums) > 0) {
                                $lastAlbum = $currAlbums[count($currAlbums) - 1];
                                if (strtolower($lastAlbum['album']) == "other songs" && count($currAlbums) > 1) {
                                    $lastAlbum = $currAlbums[count($currAlbums) - 2];
                                    // put new album after last REAL album.
                                }
                                $lastAlbumName = $lastAlbum['album'];
                                $lastAlbumYear = $lastAlbum['year'];
                                $wikiCode = trim($wikiCode) . "\n";
                                // only needs one new line-break, not the traditional two
                                $lastAlbumName = str_replace(" ", "_", $lastAlbumName);
                                $lastAlbumName = str_replace("_", "[_ ]", $lastAlbumName);
                                $artistReg = str_replace(" ", "_", $artistName);
                                $artistReg = str_replace("_", "[_ ]", $artistReg);
                                $content = preg_replace("/(==\\s*\\[\\[{$artistReg}:{$lastAlbumName}" . "[_ ]\\({$lastAlbumYear}\\)(\\|.*?\\]\\]|\\]\\])\\s*==\\s*.*?\n[^#*{])/si", "\$1{$wikiCode}", $content);
                            } else {
                                //print (($artist!="Sahara Hotnights")?"":"No albums existed\n");
                                $content = $wikiCode . $content;
                                // if there were no albums yet, just throw the new album on the beginning.
                            }
                        } else {
                            //print (($artist!="Sahara Hotnights")?"":"Album goes before $insertBefore\n");
                            $beforeAlbum = $currAlbums[$insertBefore]['album'];
                            $beforeYear = $currAlbums[$insertBefore]['year'];
                            $albumWiki = lw_albumDataToWiki($artist, $activeAlbum);
                            $origContent = $content;
                            $beforeAlbum = str_replace(" ", "_", $beforeAlbum);
                            $beforeAlbum = str_replace("_", "[_ ]", $beforeAlbum);
                            $artistReg = str_replace(" ", "_", $artistName);
                            $artistReg = str_replace("_", "[_ ]", $artistReg);
                            $content = preg_replace("/(==\\s*\\[\\[{$artistReg}:{$beforeAlbum}" . "[_ ]\\({$beforeYear}\\))/si", "{$albumWiki}\$1", $content);
                            if ($origContent == $content) {
                                //print (($artist!="Sahara Hotnights")?"":"That didn't work... just throwing on top.\n");
                                // Couldn't find place... stuff it at top of the file to minimize damage; a human can sort it out later.
                                $content = $albumWiki . $content;
                            }
                        }
                    }
                }
                // TODO: OMG REMOVE!
                /*if($artist == "Sahara Hotnights"){
                			print "Exiting because this is a test.\n";
                			exit;
                		}*/
                // Send the updated code here.
                $content = "[[Category:Review_Me]]\n" . $content;
                // TODO: REMOVE AFTER UBERBOT SUBMISSIONS
                $summary = "Page " . ($pageExists ? "edited" : "created") . " using [[LyricWiki:SOAP|LyricWiki's SOAP Webservice]]";
                $editWorked = lw_createPage($pageTitle, $content, $summary);
                $retVal['dataUsed'] = true;
                if ($editWorked !== true) {
                    $retVal['message'] = "Error from EditPage: {$editWorked}";
                } else {
                    if (isset($pageTitle) && $pageExists) {
                        $retVal['message'] = "Page overwritten. ";
                    } else {
                        $retVal['message'] = "Page created. ";
                    }
                }
            }
        } else {
            // The artist page doesn't exist yet... create it.
            $content = "";
            $content .= "[[Category:Review_Me]]\n";
            // TODO: REMOVE AFTER UBERBOT SUBMISSIONS
            $content .= "{{Wikipedia}}\n\n";
            // Build the page-content.
            foreach ($albums as $albumWrapper) {
                $currAlbum = $albumWrapper['albums'];
                // weird side-effect... every album is wrapped in an 'albums' array.
                $content .= lw_albumDataToWiki($currAlbum);
            }
            $content .= "{{Artist}}\n\n";
            $fLetter = lw_fLetter($artistName);
            $content .= "[[Category:Artists {$fLetter}]]\n";
            $summary = "Page " . ($pageExists ? "edited" : "created") . " using [[LyricWiki:SOAP|LyricWiki's SOAP Webservice]]";
            $returnStr = lw_createPage($pageTitle, $content, $summary);
            $retVal['dataUsed'] = true;
            if (isset($pageTitle) && $pageExists) {
                $retVal['message'] = "Page overwritten. " . ($returnStr == "" ? "" : "({$returnStr})");
            } else {
                $retVal['message'] = "Page created. " . ($returnStr == "" ? "" : "({$returnStr})");
            }
            // Also create pages for all of the albums that appeared on this page.
            $numUsed = $numSkipped = 0;
            foreach ($albums as $albumWrapper) {
                $currAlbum = $albumWrapper['albums'];
                $albumName = $currAlbum['album'];
                $year = $currAlbum['year'];
                $asin = $currAlbum['amazonLink'];
                $songs = $currAlbum['songs'];
                $albumResponse = postAlbum($overwriteIfExists, $artistName, $albumName, $year, $asin, $songs);
                if ($albumResponse['dataUsed']) {
                    $numUsed++;
                } else {
                    $numSkipped++;
                }
            }
            if ($numUsed > 0 || $numSkipped > 0) {
                $retVal['message'] .= " - album pages: {$numUsed} made, {$numSkipped} skipped";
            }
        }
    }
    requestFinished($id);
    return $retVal;
}
Example #5
0
 /**
  * REST endpoint for the getArtist() LyricWiki API function.  Calls the LyricWiki SOAP function which
  * is currently in /extensions/3rdparty/LyricWiki/server.php.
  */
 function rest_getArtist($artist, $fmt)
 {
     if (empty($fmt)) {
         $fmt = 'html';
     }
     switch ($fmt) {
         case 'php':
             print serialize(getArtist($artist));
             break;
         case 'text':
             $result = getArtist($artist);
             // This is just a raw line-delimited list of tracks.
             $artist = getVal($result, 'artist');
             $albums = $result['albums'];
             foreach ($albums as $currAlbum) {
                 $albumName = getVal($currAlbum, 'album');
                 $year = getVal($currAlbum, 'year');
                 $amznLink = getVal($currAlbum, 'amazonLink');
                 $songs = getVal($currAlbum, 'songs');
                 sort($songs);
                 foreach ($songs as $currSong) {
                     if (strpos($currSong, ":") !== false) {
                         print "{$currSong}\n";
                         // a track listing that already has the artist in it
                     } else {
                         print "{$artist}:{$currSong}\n";
                     }
                 }
             }
             break;
         case "json":
         case "realjson":
             $result = getArtist($artist);
             $this->writeRealJSON($result);
             break;
         case "xml":
             header('Content-Type: application/xml', true);
             print "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n";
             //print "<getArtistResponse>\n";
             $result = getArtist($artist);
             $result = array("getArtistResponse" => $result);
             $this->dumpXml_hacky($result);
             //print "</getArtistResponse>\n";
             break;
         case 'html':
         default:
             $this->htmlHead("{$artist}");
             $result = getArtist($artist);
             $artist = getVal($result, 'artist');
             $albums = $result['albums'];
             print "<h3><a href='{$this->root}" . $this->linkEncode($artist) . "'>{$artist}</a></h3>\n";
             if (count($albums) > 0) {
                 print "<ul class='albums'>\n";
                 foreach ($albums as $currAlbum) {
                     $albumName = getVal($currAlbum, 'album');
                     $year = getVal($currAlbum, 'year');
                     $amznLink = getVal($currAlbum, 'amazonLink');
                     $songs = getVal($currAlbum, 'songs');
                     print "<li><a href='{$this->root}" . $this->linkEncode("{$artist}:{$albumName}" . ($year == "" ? "" : "_({$year})")) . "'>{$albumName}" . ($year == "" ? "" : "_({$year})") . "</a>";
                     if ($amznLink != "") {
                         print " - (at <a href='{$amznLink}' title=\"{$albumName} at amazon\">amazon</a>)";
                     }
                     if (count($songs) > 0) {
                         print "<ul class='songs'>\n";
                         foreach ($songs as $currSong) {
                             if (strpos($currSong, ":") !== false) {
                                 print "<li><a href='{$this->root}" . $this->linkEncode($currSong) . "'>{$currSong}</a></li>\n";
                             } else {
                                 print "<li><a href='{$this->root}" . $this->linkEncode("{$artist}:{$currSong}") . "'>{$currSong}</a></li>\n";
                             }
                         }
                         print "</ul>\n";
                     }
                     print "</li>\n";
                 }
                 print "</ul>\n";
             }
             // Make it extensible by displaying any extra data in a UL.
             unset($result['artist']);
             unset($result['albums']);
             if (count($result) > 0) {
                 print "<hr/>Additional Info:\n";
                 print "<ul>\n";
                 foreach ($result as $keyName => $val) {
                     if (0 < preg_match("/^http:\\/\\//", $val)) {
                         $val = "<a href='" . str_replace(" ", "_", $val) . "' title='{$keyName}'>{$val}</a>\n";
                         print "<li><strong>{$keyName}: </strong>{$val}</li>\n";
                     } else {
                         print "<li><strong>{$keyName}: </strong>{$val}</li>\n";
                     }
                 }
                 print "</ul>\n";
             }
             print "</body>\n</html>\n";
             break;
     }
 }
Example #6
0
<?php

require_once "models/config.php";
if (!isUserLoggedIn()) {
    header("Location: http://localhost/nurrap/admin/login.php");
    die;
}
if (!securePage($_SERVER['PHP_SELF'])) {
    die;
}
require_once "functions/general.php";
require_once "models/header.php";
include "models/left-nav.php";
$artistId = $_GET['artistId'];
$artist = getArtist($artistId);
$relatedArtists = getRelatedArtists($artistId);
?>
    <div class="col-md-9">
            <form name="artist" method="POST" action="functions/artistFunctions.php?action=updateArtist&artistId=<?php 
echo $artistId;
?>
">
             <div class="row">
                <div class="col-md-9">
                     <h3>Artist bearbeiten <input type="submit" class="btn btn-default" value="&Auml;nderungen speichern" id="speichern" /><a class="pull-right" href="functions/artistFunctions.php?action=deleteArtist&artistId=<?php 
echo $artistId;
?>
"><button type="button" class="btn btn-danger" value="Artist l&ouml;schen" id="loeschen">Artist l&ouml;schen</button></a></h3>
                </div>
             </div>
             <div class="row">
Example #7
0
 //+++++++++++++++++++++++++++++++++++Bilder löschen+++++++++++++++++++++++++++++++++++++++
 //+++++++++++++++++++++++++++++++++++Artists für Startseite aufrufen, wenn in URL action = getArtists+++++++++++++++++++++++++++++++++++++++
 case 'getArtists':
     $artists = getArtists();
     $rows = count($artists);
     $draw = 1;
     $json = array("draw" => $draw, "recordsTotal" => $rows, "recordsFiltered" => $rows, "data" => $artists);
     echo json_encode($json);
     break;
     //+++++++++++++++++++++++++++++++++++Artists für Startseite aufrufen, wenn in URL action = getArtists+++++++++++++++++++++++++++++++++++++++
     //+++++++++++++++++++++++++++++++++++Artist updaten, wenn in URL action = updateArtist+++++++++++++++++++++++++++++++++++++++
 //+++++++++++++++++++++++++++++++++++Artists für Startseite aufrufen, wenn in URL action = getArtists+++++++++++++++++++++++++++++++++++++++
 //+++++++++++++++++++++++++++++++++++Artist updaten, wenn in URL action = updateArtist+++++++++++++++++++++++++++++++++++++++
 case 'updateArtist':
     global $artistIdGet;
     $artist_db = getArtist($artistIdGet);
     $artist = array("Artists_Name" => htmlspecialchars($_POST['ArtistName']), "Artists_RealName" => htmlspecialchars($_POST['ArtistRealName']), "Artists_URL" => htmlspecialchars($_POST['ArtistUrl']), "Artists_Facebook" => htmlspecialchars($_POST['ArtistFacebook']), "Artists_Twitter" => htmlspecialchars($_POST['ArtistTwitter']), "Artists_Instagram" => htmlspecialchars($_POST['ArtistInstagram']), "Artists_YouTube" => htmlspecialchars($_POST['ArtistYouTube']), "Artists_Soundcloud" => htmlspecialchars($_POST['ArtistSoundcloud']), "Artists_MySpace" => htmlspecialchars($_POST['ArtistMySpace']), "Artists_Home" => htmlspecialchars($_POST['ArtistHome']), "Artists_District" => htmlspecialchars($_POST['ArtistDistrict']), "Artists_Start" => date('Y-m-d', strtotime($_POST['ArtistStart'])), "Artists_End" => date('Y-m-d', strtotime($_POST['ArtistEnd'])), "Artists_DeathReason" => htmlspecialchars($_POST['ArtistDeathReason']), "Artists_Type" => htmlspecialchars($_POST['ArtistType']), "Artists_Wikipedia" => htmlspecialchars($_POST['ArtistWiki']), "Artists_WikiBio" => htmlspecialchars($_POST['ArtistWikiBio']), "Artists_LastUpdatedBy" => $loggedInUser->displayname, "Artists_LastUpdated" => date("Y-m-d H:i:s"));
     //aktuelle Werte mit Änderungen vergleichen und ersetzen
     $artistUpdate = array_replace_recursive($artist_db['Artist'], $artist);
     // Artistupdate in DB schreiben
     $where = "Artists_ID = " . $artistIdGet;
     //Artistupdate
     $insertArtistData = updateData("artists", $artistUpdate, $where);
     // vorhandene Pseudonyme löschen
     deleteData("artistpseudos", $where);
     // und die neuen Pseudonyme auslesen und speichern
     if (isset($_POST['ArtistPseudo'])) {
         foreach ($_POST['ArtistPseudo'] as $ArtistPseudo) {
             $artistPseudos = array("Artists_ID" => $artistIdGet, "ArtistPseudos_Name" => $ArtistPseudo);
             insertData("artistpseudos", $artistPseudos);
         }