/** *编辑商品 * @param int $id * @return string */ function editUser($id) { $arr = $_POST; $path = "../uploads"; $uploadFiles = uploadFile($path); $where = "id={$id}"; $totalCap = getCityCapById(getcIdById($id)) - getCapById($id) + $arr['capacity']; //减去旧的,加上新的 $sql = "update biogas_city set totalCap=" . $totalCap . " where id=" . getcIdById($id); mysql_query($sql); //更新城市的总池容 $res = update("biogas_user", $arr, $where); $uid = $id; if ($res && $uid) { if ($uploadFiles && is_array($uploadFiles)) { foreach ($uploadFiles as $uploadFile) { $arr1['uid'] = $uid; $arr1['albumPath'] = $uploadFile['name']; addAlbum($arr1); } } $mes = "<p>编辑成功!</p><a href='listUser.php' target='mainFrame'>查看用户列表</a>"; } else { $mes = "<p>编辑失败!</p><a href='listUser.php' target='mainFrame'>重新编辑</a>"; } return $mes; }
function newAlbum($ip, $nick, $email, $albumName, $access, $coverPath) { if (!addAlbum($nick, $albumName, $access, $coverPath)) { return false; } addAction($nick, $email, $ip, 'new_album'); return true; }
/** *编辑商品 * @param int $id * @return string */ function editPro($id) { $arr = $_POST; $path = "./uploads"; $uploadFiles = uploadFile($path); if (is_array($uploadFiles) && $uploadFiles) { foreach ($uploadFiles as $key => $uploadFile) { thumb($path . "/" . $uploadFile['name'], "../image_50/" . $uploadFile['name'], 50, 50); thumb($path . "/" . $uploadFile['name'], "../image_220/" . $uploadFile['name'], 220, 220); thumb($path . "/" . $uploadFile['name'], "../image_350/" . $uploadFile['name'], 350, 350); thumb($path . "/" . $uploadFile['name'], "../image_800/" . $uploadFile['name'], 800, 800); } } $where = "id={$id}"; $res = update("imooc_pro", $arr, $where); $pid = $id; if ($res && $pid) { if ($uploadFiles && is_array($uploadFiles)) { foreach ($uploadFiles as $uploadFile) { $arr1['pid'] = $pid; $arr1['albumPath'] = $uploadFile['name']; addAlbum($arr1); } } $mes = "<p>编辑成功!</p><a href='listPro.php' target='mainFrame'>查看商品列表</a>"; } else { if (is_array($uploadFiles) && $uploadFiles) { foreach ($uploadFiles as $uploadFile) { if (file_exists("../image_800/" . $uploadFile['name'])) { unlink("../image_800/" . $uploadFile['name']); } if (file_exists("../image_50/" . $uploadFile['name'])) { unlink("../image_50/" . $uploadFile['name']); } if (file_exists("../image_220/" . $uploadFile['name'])) { unlink("../image_220/" . $uploadFile['name']); } if (file_exists("../image_350/" . $uploadFile['name'])) { unlink("../image_350/" . $uploadFile['name']); } } } $mes = "<p>编辑失败!</p><a href='listPro.php' target='mainFrame'>重新编辑</a>"; } return $mes; }
/** * Gets song matches by querying the Grooveshark API for matches. * * @param search The phrase that is being searched for. Typically contains * the song, artist, and/or album. * * @return An array containing all of the song objects that matched the search * phrase. */ function getGroovesharkResults($search) { $songs = findSongs($search); foreach ($songs as $song) { if (!songIsInDb($song->id)) { if (!albumIsInDb($song->albumId)) { if (!artistIsInDb($song->artistId)) { addArtist($song->artistId, $song->artist); } $location = $song->arturl; addAlbum($song->albumId, $song->album, $song->artistId, $location, $song->arturl); } addSong($song->id, $song->title, $song->albumId, $song->track, $song->popularity, $song->duration); } } return $songs; }
/** * Processes loading of this sample code through a web browser. Uses AuthSub * authentication and outputs a list of a user's albums if succesfully * authenticated. * * @return void */ function processPageLoad() { global $_SESSION, $_GET; if (!isset($_SESSION['sessionToken']) && !isset($_GET['token'])) { requestUserLogin('Please login to your Google Account.'); } else { $client = getAuthSubHttpClient(); if (!empty($_REQUEST['command'])) { switch ($_REQUEST['command']) { case 'retrieveSelf': outputUserFeed($client, "default"); break; case 'retrieveUser': outputUserFeed($client, $_REQUEST['user']); break; case 'retrieveAlbumFeed': outputAlbumFeed($client, $_REQUEST['user'], $_REQUEST['album']); break; case 'retrievePhotoFeed': outputPhotoFeed($client, $_REQUEST['user'], $_REQUEST['album'], $_REQUEST['photo']); break; } } // Now we handle the potentially destructive commands, which have to // be submitted by POST only. if (!empty($_POST['command'])) { switch ($_POST['command']) { case 'addPhoto': addPhoto($client, $_POST['user'], $_POST['album'], $_FILES['photo']); break; case 'deletePhoto': deletePhoto($client, $_POST['user'], $_POST['album'], $_POST['photo']); break; case 'addAlbum': addAlbum($client, $_POST['user'], $_POST['name']); break; case 'deleteAlbum': deleteAlbum($client, $_POST['user'], $_POST['album']); break; case 'addComment': addComment($client, $_POST['user'], $_POST['album'], $_POST['photo'], $_POST['comment']); break; case 'addTag': addTag($client, $_POST['user'], $_POST['album'], $_POST['photo'], $_POST['tag']); break; case 'deleteComment': deleteComment($client, $_POST['user'], $_POST['album'], $_POST['photo'], $_POST['comment']); break; case 'deleteTag': deleteTag($client, $_POST['user'], $_POST['album'], $_POST['photo'], $_POST['tag']); break; default: break; } } // If a menu parameter is available, display a submenu. if (!empty($_REQUEST['menu'])) { switch ($_REQUEST['menu']) { case 'user': displayUserMenu(); break; case 'photo': displayPhotoMenu(); break; case 'album': displayAlbumMenu(); break; case 'logout': logout(); break; default: header('HTTP/1.1 400 Bad Request'); echo "<h2>Invalid menu selection.</h2>\n"; echo "<p>Please check your request and try again.</p>"; } } if (empty($_REQUEST['menu']) && empty($_REQUEST['command'])) { displayMenu(); } } }
/** ** Home **/ Flight::map('notFound', function () { include 'views/404.html'; }); // ADD new album Flight::route('GET|POST /album/create', function () { $request = Flight::request(); if ($request->method == "GET") { Flight::render('createAlbum', array(), 'body_content'); Flight::render('layout', array('Titre' => 'Ajouter un album')); } if ($request->method == "POST") { $album = json_encode($_POST); $result = json_decode(addAlbum($album)); if (isset($result->IDalbum)) { Flight::redirect('http://localhost/php/App/track/' . $result->IDalbum . '/create'); } else { Flight::render('createAlbum', array("flash" => $result), 'body_content'); Flight::render('layout', array('Titre' => 'Ajouter un album')); } } }); Flight::route('/', function () { // home Flight::render('home', array(), 'body_content'); Flight::render('layout', array('Titre' => 'List albums')); }); Flight::route('GET /albums', function () { // view home
$ifLogin = 0; $userName = ""; $userID = ""; if (isset($_SESSION['UserName'])) { $userName = $_SESSION['UserName']; $userID = $_SESSION['UserID']; $ifLogin = 1; } if (isset($_POST['cmd'])) { $cmd = $_POST['cmd']; switch ($cmd) { case 'newAlbum': if ($ifLogin) { $albumName = $_POST['AlbumName']; $albumDes = $_POST['AlbumDes']; addAlbum($userID, $albumName, $albumDes, time()); } break; case 'getPic': $picNum = (int) $_POST['picNum']; $groupNum = (int) $_POST['groupNum']; $sortType = $_POST['sortType']; $selectType = $_POST['selectType']; $index = $picNum * $groupNum; $sql = ""; switch ($selectType) { case "All": $sql = "SELECT * FROM PicTable ORDER BY {$sortType} LIMIT {$index},{$picNum}"; break; case "AllRange": $latMax = (double) $_POST['latMax'];
function addUser($userName, $password, $email, $gender) { if (checkUser($userName, $email) > 0) { return; } $sql = "INSERT INTO UserInfoTable (UserName,Password,Email,Gender) VALUES('{$userName}','{$password}','{$email}','{$gender}')"; if (!exeSQL($sql)) { return; } //printf("add user $userName failed\n"); $sql = "SELECT UserID from UserInfoTable WHERE UserName='******'"; $res = exeSQL($sql); $row = mysql_fetch_array($res); $id = $row[0]; addAlbum($id, "Face", "The user face album", time()); addAlbum($id, "Default", "The default user album", time()); $sql = "SELECT AlbumID FROM AlbumTable WHERE UserID={$id} AND AlbumName='Face'"; $res = exeSQL($sql); $row = mysql_fetch_array($res); $albumID = $row[0]; addPic($id, "DefaultFace.gif", 200, 200, "DefaultFace.gif", "/images/DefaultFace.gif", time(), time(), 0, 0, 0, $albumID); }
/* * ********************************************** If we're signed in we can go ahead and retrieve data * ********************************************** */ set_time_limit('10000'); if (isset($_SESSION['google_token'])) { $client = Zend_Gdata_AuthSub::getHttpClient($_SESSION['google_token']); $userInfo = $_SESSION['google_userInfo']; $album_ids = explode(',', $_GET['album_ids']); foreach ($album_ids as $album_id) { $singleAlbum = fetchSingleAlbums($album_id); if (!file_exists(ABSOLUTE_PATH . "/assets/images/archive")) { mkdir(ABSOLUTE_PATH . "/assets/images/archive"); } $filepath = $album_id; if (!file_exists(ABSOLUTE_PATH . "/assets/images/albums/{$filepath}")) { mkdir(ABSOLUTE_PATH . "/assets/images/albums/{$filepath}"); } $result = addAlbum($client, 'Test Album'); $albumId = $result->getGphotoId()->getText(); foreach ($singleAlbum as $photo) { $url = $photo->source; $destination_path = ABSOLUTE_PATH . '/assets/images/albums/' . $filepath . '/' . $photo->id . '.jpg'; downloadImage($url, $destination_path); addPhoto($client, $userInfo->user_id, $albumId, $photo->id, $destination_path); } } echo '<p class="bg-success"> Your album has been move to your picasa account successfully.</p>'; } else { echo 'first login via google inorder to move your album to picasa account'; }
/** * Add photos */ function addPhotos() { $arr = $_POST; $id = $_SESSION['user_id']; $path = "uploads/House_Album/user_id_" . $id; $uploadFiles = uploadFile($path); if (is_array($uploadFiles) && $uploadFiles) { foreach ($uploadFiles as $key => $uploadFile) { thumb($path . "/" . $uploadFile['name'], "image_50/user_id_" . $id . "/" . $uploadFile['name'], 50, 50); } } $album_id = $id; //闁跨喐鏋婚幏绌抦g_path 闁跨喐鏋婚幏閿嬪闁跨噦鎷穞g_house_img闁跨喐鏋婚幏锟� if ($album_id) { $sql = "delete from tg_house_img where album_id={$album_id} and img_path IS NULL"; mysql_query($sql); if ($uploadFiles && is_array($uploadFiles)) { foreach ($uploadFiles as $uploadFile) { $arr1['album_id'] = $album_id; $arr1['img_path'] = $uploadFile['name']; addAlbum($arr1); } } } }
/** *�༭��Ʒ * @param int $id * @return string */ function editHouse($id) { $arr = $_POST; $arr['update_time'] = date("Y-m-d H:i:s"); $sql = "select house_id from tg_host_house where id={$id}"; $row = fetchOne($sql); //��house_id������album_id $album_id = $row['house_id']; $path = "../uploads/House_Album/user_id_" . $album_id; //����û�жϾ��ϴ�ͼƬ���ļ��У�ͼƬ��ݲ�һ���ɹ�������ݿ� $uploadFiles = uploadFile($path); if (is_array($uploadFiles) && $uploadFiles) { foreach ($uploadFiles as $key => $uploadFile) { thumb($path . "/" . $uploadFile['name'], "../image_50/user_id_" . $album_id . "/" . $uploadFile['name'], 50, 50); } } //����host_house����� $where = "house_id={$id}"; $res = update("tg_host_house", $arr, $where); //ע�⣺����ֻ�ܸ�����ݱ������е��ֶΣ����post�����ݸ�table����ֶβ�ƥ�䣬����ʧ�ܣ����� $house_id = $row['house_id']; //����ȡ�� house_id ����Ӧ album_id $sql_img = "select i.album_id from tg_house_img as i left join tg_host_house h on h.house_id=i.album_id where i.album_id={$house_id}"; $row_img = fetchOne($sql_img); //��img_path ��ӵ� tg_house_img�� if ($res && $house_id) { if ($uploadFiles && is_array($uploadFiles)) { foreach ($uploadFiles as $uploadFile) { $arr1['album_id'] = $house_id; $arr1['img_path'] = $uploadFile['name']; //print_r($arr1['img_path']);exit; addAlbum($arr1); } } $mes = "<p>Edit success!</p><a href='listHouse.php' target='mainFrame'>View house list</a>"; } else { if (is_array($uploadFiles) && $uploadFiles) { foreach ($uploadFiles as $uploadFile) { if (file_exists("../image_50/user_id_" . $_SESSION['user_id'] . "/" . $uploadFile['name'])) { unlink("../image_50/user_id_" . $_SESSION['user_id'] . "/" . $uploadFile['name']); } if (file_exists("../uploads/House_Album/user_id_" . $_SESSION['user_id'] . "/" . $uploadFile['name'])) { unlink("../uploads/House_Album/user_id_" . $_SESSION['user_id'] . "/" . $uploadFile['name']); } } } $mes = "<p>Failed!</p><a href='listHouse.php' target='mainFrame'>Edit again</a>"; } return $mes; }
if ($value == $parameter) { echo "album supprimé: " . $key . "\n"; removeAlbum($key); } else { //echo " ne correspond pas au genre demandé"; } } echo "suppression des albums"; break; case 'loadGenre': //supprime la playlist et ajoute tous les albums correspondant au genre indiqué -> exemple: $parameter=Rock ->ok $mySqueezeCLI = new SqueezeCLI(loadGenre($parameter)); break; case 'addAlbum': //ajoute l'album indiqué en paramètre a la fin de la playlist -> exemple :addAlbum_8 Mile ->ok addAlbum($parameter); break; case 'loadAlbum': //supprime la playlist et ajoute l'album indiqué en paramètre -> exemple: loadAlbum_8 Mile ->ok $mySqueezeCLI = new SqueezeCLI(loadAlbum($parameter)); break; case 'addTitle': //ajoute le titre en paramètre a la fin de la playlist -> exemple :addTitle_02 No Woman No Cry.mp3 ->ok $mySqueezeCLI = new SqueezeCLI(addTitle($parameter)); break; case 'loadTitle': //supprime la playlist, ajoute le titre en paramètre -> exemple :loadTitle_02 No Woman No Cry.mp3 ->ok $mySqueezeCLI = new SqueezeCLI(addTitle($parameter)); break; case 'deleteTitle': //retire un titre de la playlist, attention ici il s'agit des ID de l'index, 0 étant le titre en cour de la playlist-> exemple : deleteTitle_1 ->ok
function addImgs($id) { $path = "../uploads/House_Album/user_id_" . $id; $uploadFiles = uploadFile($path); if (is_array($uploadFiles) && $uploadFiles) { foreach ($uploadFiles as $key => $uploadFile) { thumb($path . "/" . $uploadFile['name'], "image_50/user_id_" . $id . "/" . $uploadFile['name'], 50, 50); } } $album_id = $id; if ($album_id) { $sql = "delete from tg_house_img where album_id={$album_id} and img_path IS NULL"; mysql_query($sql); if ($uploadFiles && is_array($uploadFiles)) { foreach ($uploadFiles as $uploadFile) { $arr1['album_id'] = $album_id; $arr1['img_path'] = $uploadFile['name']; addAlbum($arr1); } } } }