/** * Bind the given Tag2All-values to the given DELETE-statement. * @param Tag2All $Tag2All * @param mysqli_stkmt $stmt */ public static function BindParamsToDeleteT2A(&$Tag2All, &$stmt) { if ($Tag2All->getDeleteBindValues()) { $bind_names[] = $Tag2All->getDeleteBindPattern(); $params = $Tag2All->getDeleteBindValues(); for ($i = 0; $i < count($params); $i++) { $bind_name = 'bind' . $i; ${$bind_name} = $params[$i]; $bind_names[] =& ${$bind_name}; } call_user_func_array(array($stmt, 'bind_param'), $bind_names); } }
} /* @var $Video2Process Video */ $Video2Process = $VideoInDb ? $VideoInDb : new Video(); $Video2Process->setSet($Set2Process); $Video2Process->setFileName((string) $Video->attributes()->name); $Video2Process->setFileExtension((string) $Video->attributes()->extension); $Video2Process->setFileSize((int) $Video->attributes()->filesize); $Video2Process->setFileCheckSum((string) $Video->attributes()->checksum); $Video2Process->setFileCRC32((string) $Video->attributes()->crc32); if ($Video2Process->getID()) { Video::Update($Video2Process, $CurrentUser); } else { Video::Insert($Video2Process, $CurrentUser); } $videotags = Tag::GetTagArray((string) $Video->attributes()->tags); $Tag2AllThisVideo = Tag2All::Filter($Tag2AllThisSet, NULL, $Model2Process->getID(), $Set2Process->getID(), NULL, $Video2Process->getID()); Tag2All::HandleTags($videotags, $Tag2AllThisVideo, $TagsInDB, $CurrentUser, $Model2Process->getID(), $Set2Process->getID(), NULL, $Video2Process->getID(), FALSE); } } } } if ($fileToProcess != 'setup_data.xml') { unlink(realpath($fileToProcess)); } $infoSuccess = new Info($lang->g('MessageXMLImported')); Info::AddInfo($infoSuccess); if (isset($argv) && $argc > 0) { $bi->Finish(); } } HTMLstuff::RefererRedirect();
$TagID = Utils::SafeIntFromQS('tag_id'); $DeleteTag = array_key_exists('hidTagToDelete', $_POST) && $TagID && $_POST['hidTagToDelete'] == $TagID; $Tags = Tag::GetTags(); $Tag = Tag::Filter($Tags, $TagID); $Tag = $TagID && $Tag ? $Tag[0] : new Tag(); $Tagcount = 0; $TagList = NULL; $DisableControls = $DeleteTag || !$CurrentUser->hasPermission(RIGHT_TAG_EDIT) && !is_null($TagID) || !$CurrentUser->hasPermission(RIGHT_TAG_ADD) && is_null($TagID); $DisableDefaultButton = !$CurrentUser->hasPermission(RIGHT_TAG_DELETE) && !is_null($TagID) && $DeleteTag || !$CurrentUser->hasPermission(RIGHT_TAG_EDIT) && !is_null($TagID) && !$DeleteTag || !$CurrentUser->hasPermission(RIGHT_TAG_ADD) && is_null($TagID); if (array_key_exists('hidAction', $_POST) && $_POST['hidAction'] == 'TagView') { $Tag->setName(Utils::NullIfEmpty($_POST['txtName'])); if ($Tag->getID()) { if ($DeleteTag) { if ($CurrentUser->hasPermission(RIGHT_TAG_DELETE) && Tag::Delete($Tag, $CurrentUser)) { $t2as = Tag2All::GetTag2Alls(new Tag2AllSearchParameters($Tag->getID())); Tag2All::DeleteMulti($t2as, $CurrentUser); header('location:' . $_SERVER['PHP_SELF']); exit; } } else { if ($CurrentUser->hasPermission(RIGHT_TAG_EDIT) && Tag::Update($Tag, $CurrentUser)) { header('location:' . $_SERVER['PHP_SELF']); exit; } } } else { if ($CurrentUser->hasPermission(RIGHT_TAG_ADD) && Tag::Insert($Tag, $CurrentUser)) { header('location:' . $_SERVER['PHP_SELF']); exit; } }
/** * Handles * a) the adding of new Tags to the database, * b) the deleting of all existing Tag2All for this Model|Set|Image|Video and * c) inserting the appropriate Tag2All records for this Model|Set|Image|Video * @param array(string) $newTags * @param array(Tag2All) $Tag2AllsThisItem * @param array(Tag) $TagsInDB, passed by reference * @param User $CurrentUser * @param int $ModelID * @param int $SetID * @param int $ImageID * @param int $VideoID * @param bool $DeleteOldTag2Alls determines whether to delete or merge existing Tag2Alls */ public static function HandleTags($newTags, $Tag2AllsThisItem, &$TagsInDB, $CurrentUser, $ModelID = NULL, $SetID = NULL, $ImageID = NULL, $VideoID = NULL, $DeleteOldTag2Alls = TRUE) { global $db; foreach (array_unique($newTags) as $string) { $tInDB = Tag::Filter($TagsInDB, NULL, $string); if (!$tInDB) { $tNew = new Tag(); $tNew->setName(trim($string)); if (Tag::Insert($tNew, $CurrentUser)) { $TagsInDB[] = $tNew; } } } if ($DeleteOldTag2Alls) { self::DeleteMulti($Tag2AllsThisItem, $CurrentUser); } foreach (array_unique($newTags) as $string) { $tInDB = Tag::Filter($TagsInDB, NULL, $string); if (!$DeleteOldTag2Alls) { $ttits = self::Filter($Tag2AllsThisItem, $tInDB[0]->getID(), $ModelID, $SetID, $ImageID, $VideoID); if ($ttits) { continue; } } $t2a = new Tag2All(); $t2a->setTag($tInDB[0]); if (!is_null($ModelID)) { $t2a->setModelID($ModelID); } if (!is_null($SetID)) { $t2a->setSetID($SetID); } if (!is_null($ImageID)) { $t2a->setImageID($ImageID); } if (!is_null($VideoID)) { $t2a->setVideoID($VideoID); } if ($t2a->getModelID() || $t2a->getSetID() || $t2a->getImageID() || $t2a->getVideoID()) { Tag2All::Insert($t2a, $CurrentUser); } } }
<input type="text" id="txtImageHeight" name="txtImageHeight" maxlength="10" value="<?php echo $Image->getImageHeight(); ?> "<?php echo HTMLstuff::DisabledStr($DisableControls); ?> /> </div> <div class="FormRow"> <label for="txtTags"><?php echo $lang->g('LabelTags'); ?> (CSV):</label> <input type="text" id="txtTags" name="txtTags" maxlength="400" class="TagsBox" value="<?php echo Tag2All::Tags2AllCSV($TagsThisImage); ?> "<?php echo HTMLstuff::DisabledStr($DisableControls); ?> /> </div> <div class="FormRow"><label> </label> <input type="submit" class="FormButton" value="<?php echo $DeleteImage ? $lang->g('ButtonDelete') : $lang->g('ButtonSave'); ?> "<?php echo HTMLstuff::DisabledStr($DisableDefaultButton); ?> />
<input type="text" id="txtFileCRC32" name="txtFileCRC32" maxlength="8" value="<?php echo $Video->getFileCRC32(); ?> "<?php echo HTMLstuff::DisabledStr($DisableControls); ?> /> </div> <div class="FormRow"> <label for="txtTags"><?php echo $lang->g('LabelTags'); ?> (CSV):</label> <input type="text" id="txtTags" name="txtTags" maxlength="400" class="TagsBox" value="<?php echo Tag2All::Tags2AllCSV($TagsThisVideo); ?> "<?php echo HTMLstuff::DisabledStr($DisableControls); ?> /> </div> <div class="FormRow"><label> </label> <input type="submit" class="FormButton" value="<?php echo $DeleteVideo ? $lang->g('ButtonDelete') : $lang->g('ButtonSave'); ?> "<?php echo HTMLstuff::DisabledStr($DisableDefaultButton); ?> />
<?php include 'cd.php'; ini_set('max_execution_time', '3600'); $CurrentUser = Authentication::Authenticate(); if ($CurrentUser->hasPermission(RIGHT_TAG_CLEANUP)) { $Tags = Tag::GetTags(); /* @var $t Tag */ foreach ($Tags as $t) { $t2as = Tag2All::GetTag2Alls(new Tag2AllSearchParameters($t->getID())); if (!$t2as) { Tag::Delete($t, $CurrentUser); } } $infoSuccess = new Info($lang->g('MessageTagsCleaned')); Info::AddInfo($infoSuccess); } else { $e = new Error(RIGHTS_ERR_USERNOTALLOWED); Error::AddError($e); } HTMLstuff::RefererRedirect();
foreach ($DatesThisSet as $Date) { if ($Date->getDateKind() == DATE_KIND_VIDEO || $Date->getDateKind() == DATE_KIND_UNKNOWN) { if (!$DeleteSet || $Date->getTimeStamp() > 0) { echo HTMLstuff::DateFormField($Date->getID(), Date::FormatDates(array($Date), 'Y-m-d'), DATE_KIND_VIDEO, $DisableControls); } } } ?> <div class="FormRow"> <label for="txtTags"><?php echo $lang->g('LabelTags'); ?> (CSV):</label> <input type="text" id="txtTags" name="txtTags" maxlength="400" class="TagsBox" value="<?php echo Tag2All::Tags2AllCSV($TagsThisSet); ?> "<?php echo HTMLstuff::DisabledStr($DisableControls); ?> /> </div> <div class="FormRow"> <label> </label> <input type="submit" class="FormButton" value="<?php echo $DeleteSet ? $lang->g('ButtonDelete') : $lang->g('ButtonSave'); ?> "<?php echo HTMLstuff::DisabledStr($DisableDefaultButton); ?>
continue 2; } } if (!is_null($imageid)) { $ImageIDsToShow[] = $imageid; } } /* Video-filtering */ $AllVideoIDs = array(); foreach ($Tag2Alls as $t2a) { $AllVideoIDs[] = $t2a->getVideoID(); } $VideoIDsToShow = array(); foreach (array_unique($AllVideoIDs) as $videoid) { foreach ($filteredTagIDs as $ftid) { if (count(Tag2All::Filter($Tag2Alls, $ftid, FALSE, FALSE, FALSE, $videoid)) == 0) { continue 2; } } if (!is_null($videoid)) { $VideoIDsToShow[] = $videoid; } } switch ($searchMode) { case 'MODEL': if (!$ModelIDsToShow) { break; } $ToShow = Model::GetModels(new ModelSearchParameters(FALSE, $ModelIDsToShow), NULL, sprintf("%1\$d, %2\$d", $from, $max_results)); $Total = count(Model::GetModels(new ModelSearchParameters(FALSE, $ModelIDsToShow))); break;
function XmlOutputModel($Model, $TaggedOnly) { global $xmlw, $Sets, $Dates, $Tag2Alls, $IncludeImages, $IncludeVideos; $xmlw->startElement('Model'); $xmlw->writeAttribute('firstname', $Model->getFirstName()); $xmlw->writeAttribute('lastname', $Model->getLastName()); $xmlw->writeAttribute('birthdate', $Model->getBirthdate() > 0 ? date('Y-m-d', $Model->getBirthdate()) : NULL); $TagsThisModel = Tag2All::Filter($Tag2Alls, NULL, $Model->getID(), FALSE, FALSE, FALSE); $TagsThisModelOnly = Tag2All::Filter($TagsThisModel, NULL, $Model->getID(), NULL, NULL, NULL); $xmlw->writeAttribute('tags', Tag2All::Tags2AllCSV($TagsThisModelOnly)); $SetsThisModel = Set::Filter($Sets, $Model->getID()); if ($SetsThisModel) { $xmlw->startElement('Sets'); $DatesThisModel = Date::FilterDates($Dates, NULL, $Model->getID()); if ($Model->getFirstName() == 'VIP') { usort($SetsThisModel, array('Set', 'CompareASC')); } foreach ($SetsThisModel as $Set) { $PicDatesThisSet = Date::FilterDates($DatesThisModel, NULL, NULL, $Set->getID(), DATE_KIND_IMAGE); $VidDatesThisSet = Date::FilterDates($DatesThisModel, NULL, NULL, $Set->getID(), DATE_KIND_VIDEO); $TagsThisSet = Tag2All::Filter($TagsThisModel, NULL, $Model->getID(), $Set->getID(), NULL, NULL); $xmlw->startElement('Set'); if ($Model->getFirstName() == 'VIP' && !is_numeric($Set->getName())) { $xmlw->writeAttribute('name', sprintf('SP_%1$s', $Set->getName())); } else { $xmlw->writeAttribute('name', $Set->getName()); } $xmlw->writeAttribute('date_pic', Date::FormatDates($PicDatesThisSet, 'Y-m-d', FALSE, ' ')); $xmlw->writeAttribute('date_vid', Date::FormatDates($VidDatesThisSet, 'Y-m-d', FALSE, ' ')); $xmlw->writeAttribute('tags', Tag2All::Tags2AllCSV($TagsThisSet)); if ($IncludeImages) { $ImagesThisSet = Image::GetImages(new ImageSearchParameters(FALSE, FALSE, $Set->getID(), FALSE, $Model->getID())); if ($ImagesThisSet) { $xmlw->startElement('Images'); /* @var $Image Image */ foreach ($ImagesThisSet as $Image) { $TagsThisImage = Tag2All::Filter($TagsThisModel, NULL, $Model->getID(), $Set->getID(), $Image->getID(), NULL); if ($TaggedOnly === TRUE && $TagsThisImage || $TaggedOnly === FALSE) { $xmlw->startElement('Image'); $xmlw->writeAttribute('name', $Image->getFileName()); $xmlw->writeAttribute('extension', $Image->getFileExtension()); $xmlw->writeAttribute('filesize', $Image->getFileSize()); $xmlw->writeAttribute('height', $Image->getImageHeight()); $xmlw->writeAttribute('width', $Image->getImageWidth()); $xmlw->writeAttribute('checksum', $Image->getFileCheckSum()); $xmlw->writeAttribute('crc32', $Image->getFileCRC32()); $xmlw->writeAttribute('tags', Tag2All::Tags2AllCSV($TagsThisImage)); $xmlw->endElement(); } } $xmlw->endElement(); $xmlw->flush(); ob_flush(); flush(); unset($ImagesThisSet); } } if ($IncludeVideos) { $VideosThisSet = Video::GetVideos(new VideoSearchParameters(FALSE, FALSE, $Set->getID(), FALSE, $Model->getID())); if ($VideosThisSet) { $xmlw->startElement('Videos'); /* @var $Video Video */ foreach ($VideosThisSet as $Video) { $TagsThisVideo = Tag2All::Filter($TagsThisModel, NULL, $Model->getID(), $Set->getID(), NULL, $Video->getID()); if ($TaggedOnly === TRUE && $TagsThisVideo || $TaggedOnly === FALSE) { $xmlw->startElement('Video'); $xmlw->writeAttribute('name', $Video->getFileName()); $xmlw->writeAttribute('extension', $Video->getFileExtension()); $xmlw->writeAttribute('filesize', $Video->getFileSize()); $xmlw->writeAttribute('checksum', $Video->getFileCheckSum()); $xmlw->writeAttribute('crc32', $Video->getFileCRC32()); $xmlw->writeAttribute('tags', Tag2All::Tags2AllCSV($TagsThisVideo)); $xmlw->endElement(); } } $xmlw->endElement(); $xmlw->flush(); ob_flush(); flush(); unset($VideosThisSet); } } $xmlw->endElement(); } $xmlw->endElement(); $xmlw->flush(); ob_flush(); flush(); if ($Model->getRemarks()) { $xmlw->startElement('Remarks'); $xmlw->text($Model->getRemarks()); $xmlw->endElement(); } } $xmlw->endElement(); $xmlw->flush(); ob_flush(); flush(); }
<?php /* This file needs to be put in the application's root directory */ include 'cd.php'; ini_set('max_execution_time', '3600'); $CurrentUser = Authentication::Authenticate(); $TagsInDb = Tag::GetTags(); function NotComment($line) { return !preg_match('/^\\s*;/i', $line); } if (isset($argv) && $argc > 0) { $f = sprintf('%1$s/misc/tag_list.txt', dirname($_SERVER['PHP_SELF'])); } else { $f = 'misc/tag_list.txt'; } $fc = file_get_contents($f); $lines = preg_split('/\\n/i', $fc, NULL, PREG_SPLIT_NO_EMPTY); $lines = array_filter($lines, 'NotComment'); Tag2All::HandleTags($lines, array(), $TagsInDb, $CurrentUser);
<input type="text" id="txtBirthDate" name="txtBirthDate" class="DatePicker" maxlength="10" value="<?php echo $Model->getBirthDate() > 0 ? date('Y-m-d', $Model->getBirthDate()) : NULL; ?> "<?php echo HTMLstuff::DisabledStr($DisableControls); ?> /> </div> <div class="FormRow"> <label for="txtTags"><?php echo $lang->g('LabelTags'); ?> (CSV):</label> <input type="text" id="txtTags" name="txtTags" maxlength="400" class="TagsBox" value="<?php echo Tag2All::Tags2AllCSV($TagsThisModel); ?> "<?php echo HTMLstuff::DisabledStr($DisableControls); ?> /> </div> <div class="FormRow"> <label for="txtRemarks"><?php echo $lang->g('LabelRemarks'); ?> :</label> <textarea id="txtRemarks" name="txtRemarks" cols="42" rows="16" <?php echo HTMLstuff::DisabledStr($DisableControls); ?>
function XmlOutputModel($Model) { global $xmlw, $Sets, $Dates, $Tag2Alls, $IncludeImages, $IncludeVideos; $xmlw->startElement('Model'); $xmlw->writeAttribute('firstname', $Model->getFirstName()); $xmlw->writeAttribute('lastname', $Model->getLastName()); $xmlw->writeAttribute('birthdate', $Model->getBirthdate() > 0 ? date('Y-m-d', $Model->getBirthdate()) : NULL); $TagsThisModel = Tag2All::Filter($Tag2Alls, NULL, $Model->getID(), FALSE, FALSE, FALSE); $TagsThisModelOnly = Tag2All::Filter($TagsThisModel, NULL, $Model->getID(), NULL, NULL, NULL); $xmlw->writeAttribute('tags', Tag2All::Tags2AllCSV($TagsThisModelOnly)); $SetsThisModel = Set::Filter($Sets, $Model->getID()); if ($SetsThisModel) { $xmlw->startElement('Sets'); $DatesThisModel = Date::FilterDates($Dates, NULL, $Model->getID()); if ($Model->getFirstName() == 'VIP') { usort($SetsThisModel, array('Set', 'CompareASC')); } foreach ($SetsThisModel as $Set) { $PicDatesThisSet = Date::FilterDates($DatesThisModel, NULL, NULL, $Set->getID(), DATE_KIND_IMAGE); $VidDatesThisSet = Date::FilterDates($DatesThisModel, NULL, NULL, $Set->getID(), DATE_KIND_VIDEO); $TagsThisSet = Tag2All::Filter($TagsThisModel, NULL, $Model->getID(), $Set->getID(), NULL, NULL); $xmlw->startElement('Set'); if ($Model->getFirstName() == 'VIP' && !is_numeric($Set->getName())) { $xmlw->writeAttribute('name', sprintf('SP_%1$s', $Set->getName())); } else { $xmlw->writeAttribute('name', $Set->getName()); } $xmlw->writeAttribute('date_pic', Date::FormatDates($PicDatesThisSet, 'Y-m-d', FALSE, ' ')); $xmlw->writeAttribute('date_vid', Date::FormatDates($VidDatesThisSet, 'Y-m-d', FALSE, ' ')); $xmlw->writeAttribute('tags', Tag2All::Tags2AllCSV($TagsThisSet)); $xmlw->endElement(); } $xmlw->endElement(); $xmlw->flush(); ob_flush(); flush(); if ($Model->getRemarks()) { $xmlw->startElement('Remarks'); $xmlw->text($Model->getRemarks()); $xmlw->endElement(); } } $xmlw->endElement(); $xmlw->flush(); ob_flush(); flush(); }