function add_bookmark($uname, $title, $folderid, $url, $description, $tags = "", $newPublic = false, $date = NULL) { $resultArr = array(); $resultArr['success'] = false; include 'conn.php'; require_once dirname(__FILE__) . '/protection.php'; if ($date != "") { $date = "'{$date}'"; } else { $date = "now()"; } // Cut data to respect maximum length if (!empty($title)) { $title = substr($title, 0, 100); } if (!empty($description)) { $description = substr($description, 0, 150); } //$Query = sprintf("INSERT INTO " . TABLE_PREFIX . "favourites (Name , Title , FolderID , Url , Description, ADD_DATE) " . "values('" . $uname . "', %s,'" . $folderid . "', %s, %s, $date) ", quote_smart($title), quote_smart($url), quote_smart($description)); $Query = "INSERT INTO " . TABLE_PREFIX . "favourites (Name , Title , FolderID , Url , Description, ADD_DATE) values(?, ?, ?, ?, ?, {$date})"; $sth = $dblink->prepare($Query); $dataBookmark = array($uname, $title, $folderid, $url, $description); $AffectedRows = $sth->execute($dataBookmark); $rec_id = $dblink->lastInsertID(TABLE_PREFIX . "favourites", 'ID'); if (PEAR::isError($AffectedRows)) { $resultArr['success'] = true; //echo 'ERROR: '. $AffectedRows->getMessage(). ' :: ' . $AffectedRows->getUserInfo(); } else { $resultArr['success'] = true; $tags = trim($tags); if (TAGS && $tags != "") { require_once dirname(__FILE__) . '/tags_functions.php'; //Remove any commas, dots, quotes, plus signs since the user might use commas to seperate tags rather than spaces $toRemove = array('"', "'", ",", "+"); $tags = str_replace($toRemove, "", $tags); $tags = filter($tags); if ($tags != null && $newPublic) { // cut tags if too long > 150 chars $tags = substr($tags, 0, 150); //Add the tags addTags($tags); //Store the tags with the bookmark storeTags($rec_id, $tags); } if (USE_SCREENSHOT && CURL_AVAILABLE) { require_once dirname(__FILE__) . '/curl.php'; $newc = new curl(); $urlScreenshot = sprintf(SCREENSHOT_URL, $url); //echo $urlScreenshot; $fd = $newc->getFile($urlScreenshot); } } } return $resultArr; }
/** * Handles Image bulk actions * @param $album */ function processImageBulkActions($album) { $action = sanitize($_POST['checkallaction']); $result = zp_apply_filter('processBulkImageSave', NULL, $action, $album); $ids = sanitize($_POST['ids']); $total = count($ids); if ($action != 'noaction') { if ($total > 0) { if ($action == 'addtags') { $tags = bulkTags(); } if ($action == 'moveimages' || $action == 'copyimages') { $dest = sanitize($_POST['massalbumselect']); $folder = sanitize($_POST['massfolder']); if (!$dest || $dest == $folder) { return "&mcrerr=2"; } } if ($action == 'changeowner') { $newowner = sanitize($_POST['massownerselect']); } $n = 0; foreach ($ids as $filename) { $n++; $imageobj = newImage($album, $filename); if (is_null($result)) { switch ($action) { case 'deleteall': $imageobj->remove(); break; case 'showall': $imageobj->setShow(1); break; case 'hideall': $imageobj->setShow(0); break; case 'commentson': $imageobj->set('commentson', 1); break; case 'commentsoff': $imageobj->set('commentson', 0); break; case 'resethitcounter': $imageobj->set('hitcounter', 0); break; case 'addtags': addTags($tags, $imageobj); break; case 'cleartags': $imageobj->setTags(array()); break; case 'copyimages': if ($e = $imageobj->copy($dest)) { return "&mcrerr=" . $e; } break; case 'moveimages': if ($e = $imageobj->move($dest)) { return "&mcrerr=" . $e; } break; case 'changeowner': $imageobj->setOwner($newowner); break; default: $action = call_user_func($action, $imageobj); break; } } else { $imageobj->set($action, $result); } $imageobj->save(); } return $action; } } return false; }
function set_attribute($ttid, $attribute, $value) { // NOTE: // This will set value for an EXISTING attribute to 0, but it will NOT create a NEW attribute // when $value is 0. This is because 0 is meant to represent 'no attribute'. // This keeps the table size down and ALSO means import functions // can cause new tracks to be added just by tring to set Rating to 0. global $album_created, $artist_created, $returninfo; // We're setting an attribute. // If we're setting it on a hidden track we have to: // 1. Work out if this will cause a new artist and/or album to appear in the collection // 2. Unhide the track $unhidden = false; if (track_is_hidden($ttid)) { $unhidden = true; debuglog("Setting attribute on a hidden track", "MYSQL", 6); if ($artist_created == false && $prefs['sortcollectionby'] == 'artist') { // See if this means we're revealing a new artist if ($result = generic_sql_query("SELECT COUNT(AlbumArtistindex) AS num FROM Albumtable LEFT JOIN Tracktable USING\n\t\t\t\t(Albumindex) WHERE AlbumArtistindex IN\n\t\t\t\t(SELECT AlbumArtistindex FROM Albumtable JOIN Tracktable USING (Albumindex)\n\t\t\t\tWHERE TTindex = " . $ttid . ") AND Hidden = 0 AND Uri IS NOT NULL")) { $obj = $result->fetch(PDO::FETCH_OBJ); if ($obj->num == 0) { if ($result = generic_sql_query("SELECT AlbumArtistindex FROM Tracktable LEFT JOIN\n\t\t\t\t\t\tAlbumtable USING (Albumindex) WHERE TTindex = " . $ttid)) { while ($obj = $result->fetch(PDO::FETCH_OBJ)) { $artist_created = $obj->AlbumArtistindex; debuglog("Revealing Artist Index " . $artist_created, "MYSQL", 6); } } } } } if ($artist_created == false && $album_created == false) { // See if this means we're revealing a new album if ($result = generic_sql_query("SELECT COUNT(TTindex) AS num FROM Tracktable WHERE Albumindex = (SELECT Albumindex " . "FROM Tracktable WHERE TTindex = " . $ttid . ") AND Hidden = 0 AND Uri IS NOT NULL")) { $obj = $result->fetch(PDO::FETCH_OBJ); if ($obj->num == 0) { if ($result = generic_sql_query("SELECT Albumindex FROM Tracktable WHERE TTindex = " . $ttid)) { while ($obj = $result->fetch(PDO::FETCH_OBJ)) { $album_created = $obj->Albumindex; debuglog("Revealing Album Index " . $album_created, "MYSQL", 6); } } } } } generic_sql_query("UPDATE Tracktable SET Hidden=0 WHERE TTindex=" . $ttid); } // Similarly, if it's a search result of type 2, it needs to become a type 1 if (track_is_searchresult($ttid)) { $unhidden = true; debuglog("Setting attribute on a search result track", "MYSQL", 6); if ($artist_created == false && $album_created == false && $prefs['sortcollectionby'] == 'artist') { // See if this means we're revealing a new artist if ($result = generic_sql_query("SELECT COUNT(AlbumArtistindex) AS num FROM Albumtable\n\t\t\t\tLEFT JOIN Tracktable USING (Albumindex) WHERE AlbumArtistindex IN\n\t\t\t\t(SELECT AlbumArtistindex FROM Albumtable JOIN Tracktable USING (Albumindex) WHERE\n\t\t\t\tTTindex = " . $ttid . ") AND Hidden = 0 AND Uri IS NOT NULL AND isSearchResult < 2")) { $obj = $result->fetch(PDO::FETCH_OBJ); if ($obj->num == 0) { if ($result = generic_sql_query("SELECT AlbumArtistindex FROM Tracktable LEFT JOIN\n\t\t\t\t\t\tAlbumtable USING (Albumindex) WHERE TTindex = " . $ttid)) { while ($obj = $result->fetch(PDO::FETCH_OBJ)) { $artist_created = $obj->AlbumArtistindex; debuglog("Revealing Artist Index " . $artist_created, "MYSQL", 6); } } } } } if ($artist_created == false && $album_created == false) { // See if this means we're revealing a new album if ($result = generic_sql_query("SELECT COUNT(TTindex) AS num FROM Tracktable WHERE\n\t\t\t\tAlbumindex = (SELECT Albumindex FROM Tracktable WHERE TTindex = " . $ttid . ") AND\n\t\t\t\tHidden = 0 AND Uri IS NOT NULL AND isSearchResult < 2")) { $obj = $result->fetch(PDO::FETCH_OBJ); if ($obj->num == 0) { if ($result = generic_sql_query("SELECT Albumindex FROM Tracktable WHERE TTindex = " . $ttid)) { while ($obj = $result->fetch(PDO::FETCH_OBJ)) { $album_created = $obj->Albumindex; debuglog("Revealing Album Index " . $album_created, "MYSQL", 6); } } } } } // NOTE we must set LastModified to NULL if it's a search result, otherwise // we don't get the cross next to it and a collection update will remove it. generic_sql_query("UPDATE Tracktable SET isSearchResult = 1,\n\t\t\tLastModified = NULL WHERE TTindex=" . $ttid); } if ($unhidden) { if ($result = generic_sql_query("SELECT Uri, Albumindex, AlbumArtistindex FROM\n\t\t\tTracktable JOIN Albumtable USING (Albumindex) WHERE Tracktable.TTindex = " . $ttid)) { $obj = $result->fetch(PDO::FETCH_OBJ); $returninfo['displaynewtrack'] = array('artistindex' => $obj->AlbumArtistindex, 'albumindex' => $obj->Albumindex, 'trackuri' => rawurlencode($obj->Uri)); } } if ($attribute == 'Tags') { return addTags($ttid, $value); } else { debuglog("Setting " . $attribute . " to " . $value . " on " . $ttid, "MYSQL", 8); if ($stmt = sql_prepare_query("UPDATE " . $attribute . "table SET " . $attribute . "=? WHERE TTindex=?", $value, $ttid)) { if ($stmt->rowCount() == 0 && $value !== 0) { debuglog(" Update affected 0 rows, creating new value", "MYSQL", 8); if ($stmt = sql_prepare_query("INSERT INTO " . $attribute . "table (TTindex, " . $attribute . ") VALUES (?, ?)", $ttid, $value)) { debuglog(" New Value Created", "MYSQL", 8); } else { // NOTE - we could get here if the attribute we are setting already exists // (eg setting Rating to 5 on a track that already has rating set to 5). // We don't check that because the database is set up such that this // can't happen twice - because the rating table uses TWO indices to keep things unique. // Hence an error here is probably not a problem, so we ignore them. // debuglog(" Error Executing mySql", "MYSQL"); } } } else { return false; } return true; } }
$timer_start = empty($timer_start) ? $empty_time : $timer_start; $timer_end = empty($timer_end) ? $empty_time : $timer_end; //ha tobbnyelvu az oldal, akkor a kivalasztott nyelvet adjuk hozza if (!empty($_SESSION['site_multilang'])) { $languages = $form->getSubmitValue('languages'); } else { $languages = $_SESSION['site_deflang']; } $content_id = $mdb2->extended->getBeforeID('iShark_Contents', 'content_id', TRUE, TRUE); $query = "\n INSERT INTO iShark_Contents\n (content_id, type, title, lead, content, content2, add_user_id, add_date,\n mod_user_id, mod_date, is_active, timer_start, timer_end, lang, heading_color)\n VALUES\n ({$content_id}, '1', '" . $title . "', '" . $lead . "', '" . $content . "', '" . $content2 . "', " . $_SESSION['user_id'] . ", NOW(),\n " . $_SESSION['user_id'] . ", NOW(), '1', '{$timer_start}', '{$timer_end}', '" . $languages . "', '" . $heading_color . "')\n "; $mdb2->exec($query); $last_content_id = $mdb2->extended->getAfterID($content_id, 'iShark_Contents', 'content_id'); //ha letezik a $tags tomb, akkor felvisszuk a kapcsolotablaba if (!empty($tags)) { include_once $include_dir . '/function.tags.php'; addTags($tags, 'contents', $last_content_id); } // Kapcsolodo tartalmak mentese if (isset($a_contents)) { $contents_selected = $a_contents->getSelected(); if (is_array($contents_selected)) { foreach ($contents_selected as $k) { $query = "\n INSERT INTO iShark_Contents_Contents \n (content_id, a_content_id) \n VALUES \n ({$last_content_id}, {$k})\n "; $mdb2->exec($query); } } } // Kapcsolodo galeria mentese if (isset($galleries)) { $gallery_selected = $galleries->getSelected(); if (is_array($gallery_selected)) {
$tags = str_replace($toRemove, "", $tags); $tags = filter($tags); // cut tags if too long > 150 chars $tags = substr($tags, 0, 150); if ($tags != null) { //Check if the book was public $public = checkIfPublic($id); //Was public and still is (P P) if ($public && $newPublic) { //Make the changes to the tags, if any updateTags($id, $tags); } //Was not public, and now is (~ P) if (!$public && $newPublic) { //Add the tags addTags($tags); //Store the tags with the bookmark storeTags($id, $tags); } //Was public, and now is not (P ~) if ($public && !$newPublic) { //Remove (unstore) all the tags attached to this bookmark in table tags_books unstoreTags($id); } } } // update the favourites table $Query = sprintf("UPDATE " . TABLE_PREFIX . "favourites SET title=%s, url=%s, description=%s, LAST_MODIFIED = NOW() WHERE ID =" . $id, quote_smart($title), quote_smart($url), quote_smart($description)); $AffectedRows = $dblink->exec($Query); if ($AffectedRows == 1) { echo "<p class=\"success\">" . T_("The bookmark has been updated") . ".</p>";
function changeTags($uid, $pid, $add, $remove) { mysql_query('START TRANSACTION'); addTags($uid, $pid, $add); removeTags($uid, $pid, $remove); mysql_query('COMMIT'); }
<script>$(".alert-box").hide().prependTo("#queryAlert").slideDown(800, "swing");</script> '; } if (isset($_POST['btnDeleteLocation'])) { // update entry $queryResult = deleteTags($link, 'location'); // assign message to query result $message = $queryResult ? '<span class="fi-asterisk alertHeader" aria-hidden="true"></span><h2>Success!</h2> Location has been deleted!' : '<span class="fi-asterisk alertHeader" aria-hidden="true"></span><h2>Warning!</h2> Location was not deleted. Please try again.'; $messageSpanClass = $queryResult ? 'info' : 'alert'; // display query result message $queryAlert = '<div data-alert class="alert-box ' . $messageSpanClass . '"> <span class="queryMessage">' . $message . '</span> <a href="#" class="close">×</a> </div> <script>$(".alert-box").hide().prependTo("#queryAlert").slideDown(800, "swing");</script> '; } if (isset($_POST['btnAddLocation'])) { // update entry $queryResult = addTags($link, 'location'); // assign message to query result $message = $queryResult ? '<span class="fi-asterisk alertHeader" aria-hidden="true"></span><h2>Success!</h2> Location has been added!' : '<span class="fi-asterisk alertHeader" aria-hidden="true"></span><h2>Warning!</h2> Location was not added. Please try again.'; $messageSpanClass = $queryResult ? 'info' : 'alert'; // display query result message $queryAlert = '<div data-alert class="alert-box ' . $messageSpanClass . '"> <span class="queryMessage">' . $message . '</span> <a href="#" class="close">×</a> </div> <script>$(".alert-box").hide().prependTo("#queryAlert").slideDown(800, "swing");</script> '; }
$picture_id = $mdb2->extended->getBeforeID('iShark_Pictures', 'picture_id', TRUE, TRUE); $description = $form_sendnews->getSubmitValue('pic_' . $i . '_desc'); if (empty($description)) { $description = ""; } $name = $form_sendnews->getSubmitValue('pic_' . $i . '_name'); if (empty($name)) { $name = "VideĆ³ " . $i + 1; } $query = "\n\t\t\t\t\t\t\t\tINSERT INTO iShark_Pictures\n\t\t\t\t\t\t\t\t(picture_id, realname, name, add_user_id, add_date, description)\n\t\t\t\t\t\t\t\tVALUES\n\t\t\t\t\t\t\t\t({$picture_id}, '{$filename}', '{$name}', {$user_id}, now(), '" . $description . "')\n\t\t\t\t\t\t\t"; $mdb2->exec($query); $last_picture_id = $mdb2->extended->getAfterID($picture_id, 'iShark_Pictures', 'picture_id'); $tags = $form_sendnews->getSubmitValue('pic_' . $i . '_tags'); if (!empty($tags)) { include_once $include_dir . '/function.tags.php'; addTags($tags, 'picture', $last_picture_id); } $query = "\n\t\t\t\t\t\t\t\tINSERT INTO iShark_Galleries_Pictures\n\t\t\t\t\t\t\t\t(gallery_id, picture_id)\n\t\t\t\t\t\t\t\tVALUES\n\t\t\t\t\t\t\t\t({$last_gallery_id}, {$last_picture_id})\n\t\t\t\t\t\t\t"; $mdb2->exec($query); @unlink($_FILES['file_' . $i]['tmp_name']); } } } if (!$pic) { //$form_sendnews->setElementError('fileupl', $locale->get('error_news_picupload')); } //"fagyasztjuk" a form-ot $form_sendnews->freeze(); //visszadobjuk a lista oldalra header('Location: index.php?success=feedback_send&link='); exit;
function renameTag($username, $old, $new) { //TODO: Complete the function for the API tags_rename if (is_null($userid) || is_null($old) || is_null($new)) { return false; } // Find bookmarks with old tag $bookmarksInfo =& $bookmarkservice->getBookmarks(0, NULL, $userid, $old); $bookmarks =& $bookmarksInfo['bookmarks']; // Delete old tag $this->deleteTag($old); // Attach new tags foreach (array_keys($bookmarks) as $key) { $row =& $bookmarks[$key]; //Add the tags addTags($tags); //Store the tags with the bookmark storeTags($rec_id, $tags); $this->attachTags($row['bId'], $new, $fromApi, NULL, false); } return true; }
include 'dbsetup.php'; include 'util.php'; if ($_GET['event'] == 'delete-tag') { deleteTag($_GET['tag'], $_GET['highlight']); } else { if ($_GET['event'] == 'delete-note') { deleteNote($_GET['note'], $_GET['highlight']); } else { if ($_GET['event'] == 'edit-note') { editNote($_GET['note'], mysql_real_escape_string($_GET['text'])); } else { if ($_GET['event'] == 'add-note') { addNote(mysql_real_escape_string($_GET['text']), $_GET['highlight'], $_GET['user']); } else { if ($_GET['event'] == 'add-tags') { addTags(mysql_real_escape_string($_GET['tags']), $_GET['highlight'], $_GET['user']); } else { if ($_GET['event'] == 'delete-annotation') { deleteAnnotation($_GET['highlight']); } } } } } } /** delete a tag **/ function deleteTag($tagID, $highlightID) { $query = "DELETE from highlight_xref_tag WHERE tag_id =" . $tagID . " AND highlight_id = " . $highlightID . ";"; $result = mysql_query($query) or die("<b>A fatal MySQL error occured</b>.\n\t\t<br/> Query: " . $query . "\n\t\t<br/> Error: (" . mysql_errno() . ") " . mysql_error()); echo json_encode(array('error' => 'no-error'));
if ($imagechecked) { $totag['newImage'] = $images; } if ($albumchecked) { $totag['newAlbum'] = array_merge($albums); } if ($articlechecked) { $totag['newArticle'] = $articles; } if ($pagechecked) { $totag['newPage'] = $pages; } foreach ($totag as $instantiate => $list) { foreach ($list as $item) { $obj = $instantiate($item); addTags($tags, $obj); $obj->save(); } } } ?> <form class="dirtylistening" onReset="setClean('tagitems_form');" id="tagitems_form" action="?tagitems" method="post" > <?php XSRFToken('tagitems'); ?> <input type="hidden" name="words" value="<?php echo html_encode($words); ?> " /> <?php foreach ($fields as $display => $key) {