function update_info($root)
{
    $info_files = scan_info_files($root);
    if (!$info_files) {
        echo json_encode(["ERROR" => $root . " has no resources"], JSON_UNESCAPED_SLASHES);
        return false;
    }
    $photo_files = generate_photo_files($info_files);
    $thumbnail_files = generate_thumbnail_files($info_files);
    if (!$info_files) {
        return false;
    }
    $photoInfoObj = new PhotoInfo("");
    $i = 0;
    foreach ($info_files as $info) {
        $jsonStr = file_get_contents($info, FILE_TEXT);
        // 往原始的json数据中添加新的信息
        if (substr($jsonStr, 0, 3) == pack("CCC", 0xef, 0xbb, 0xbf)) {
            $jsonStr = substr($jsonStr, 3);
        }
        $filename = $photo_files[$i];
        $thumbnail_filename = $thumbnail_files[$i];
        ++$i;
        $json_obj = json_decode($jsonStr, true);
        $json_obj["filename"] = pathinfo($filename, PATHINFO_BASENAME);
        $json_obj["thumbnail_filename"] = pathinfo($thumbnail_filename, PATHINFO_BASENAME);
        // 往原始的json数据中添加新的信息
        $photoInfoObj->decode_json_info(json_encode($json_obj));
        //        var_dump($photoInfoObj->get_info());
        $title = $photoInfoObj->getTitle();
        $photographer = $photoInfoObj->getPhotographer();
        $model = $photoInfoObj->getModel();
        $timestamp = $photoInfoObj->getTime();
        $location = $photoInfoObj->getLocation();
        $tag_list = $photoInfoObj->getTags();
        // 保存一份tag_str到数据库中
        $tag_json = json_encode($tag_list);
        $ratio = $photoInfoObj->getRatio();
        $filename = $photoInfoObj->getFilename();
        $thumbnail_filename = $photoInfoObj->getThumbnailFilename();
        // 增加模特信息
        $model_id = insert_model($model);
        // tag 信息
        $tag_id_list = array();
        foreach ($tag_list as $tag) {
            $tag_id_list[] = insert_tag($tag);
        }
        echo "处理照片: " . $filename . "<br>";
        // 添加照片信息到数据库
        insert_photo($filename, $thumbnail_filename, $model_id, $title, $photographer, $model, $timestamp, $location, $ratio, $tag_id_list, $tag_json);
    }
}
function insert_tags($tags, $topic_id)
{
    $outcome = array('added' => 0, 'dups' => 0);
    $tag_array = explode(',', $tags);
    for ($i = 0; $i < sizeof($tag_array); $i++) {
        if (insert_tag(str_replace('"', '', trim($tag_array[$i])), $topic_id)) {
            $outcome['added']++;
        } else {
            $outcome['dups']++;
        }
    }
    return $outcome;
}
/**
* @ignore
*/

function insert_tags($tags, $topic_id){
	
	$outcome 	= array('added' => 0, 'dups' => 0);
	$tag_array  = split(',', $tags);
	
	for($i = 0; $i < sizeof($tag_array); $i++)
	{
		if(insert_tag(trim($tag_array[$i]), $topic_id)){
			$outcome['added']++;
		}else{
			$outcome['dups']++;
		}
		
	}
	
	return $outcome;
	 
	
		
}
Exemple #4
0
<p>The Yoursite forums supports a number of <i>BB tags</i> which you can embed to modify how your posts are displayed.</p>

<form method=post action=?>
<textarea name=test cols=60 rows=3><?php 
print $test ? safechar($test) : "";
?>
</textarea>
<input type=submit value="Test this code!" style='height: 23px; margin-left: 5px'>
</form>
<?php 
if ($test != "") {
    print "<p><hr>" . format_comment($test) . "<hr></p>\n";
}
insert_tag("Bold", "Makes the enclosed text bold.", "[b]<i>Text</i>[/b]", "[b]This is bold text.[/b]", "");
insert_tag("Italic", "Makes the enclosed text italic.", "[i]<i>Text</i>[/i]", "[i]This is italic text.[/i]", "");
insert_tag("Underline", "Makes the enclosed text underlined.", "[u]<i>Text</i>[/u]", "[u]This is underlined text.[/u]", "");
insert_tag("Color (alt. 1)", "Changes the color of the enclosed text.", "[color=<i>Color</i>]<i>Text</i>[/color]", "[color=blue]This is blue text.[/color]", "What colors are valid depends on the browser. If you use the basic colors (red, green, blue, yellow, pink etc) you should be safe.");
insert_tag("Color (alt. 2)", "Changes the color of the enclosed text.", "[color=#<i>RGB</i>]<i>Text</i>[/color]", "[color=#0000ff]This is blue text.[/color]", "<i>RGB</i> must be a six digit hexadecimal number.");
insert_tag("Size", "Sets the size of the enclosed text.", "[size=<i>n</i>]<i>text</i>[/size]", "[size=4]This is size 4.[/size]", "<i>n</i> must be an integer in the range 1 (smallest) to 7 (biggest). The default size is 2.");
insert_tag("Font", "Sets the type-face (font) for the enclosed text.", "[font=<i>Font</i>]<i>Text</i>[/font]", "[font=Impact]Hello world![/font]", "You specify alternative fonts by separating them with a comma.");
insert_tag("Hyperlink (alt. 1)", "Inserts a hyperlink.", "[url]<i>URL</i>[/url]", "[url]http://torrentbits.org/[/url]", "This tag is superfluous; all URLs are automatically hyperlinked.");
insert_tag("Hyperlink (alt. 2)", "Inserts a hyperlink.", "[url=<i>URL</i>]<i>Link text</i>[/url]", "[url=http://torrentbits.org/]TorrentBits[/url]", "You do not have to use this tag unless you want to set the link text; all URLs are automatically hyperlinked.");
insert_tag("Image (alt. 1)", "Inserts a picture.", "[img=<i>URL</i>]", "[img=http://torrentbits.org/pic/logo.gif]", "The URL must end with <b>.gif</b>, <b>.jpg</b> or <b>.png</b>.");
insert_tag("Image (alt. 2)", "Inserts a picture.", "[img]<i>URL</i>[/img]", "[img]http://torrentbits.org/pic/logo.gif[/img]", "The URL must end with <b>.gif</b>, <b>.jpg</b> or <b>.png</b>.");
insert_tag("Quote (alt. 1)", "Inserts a quote.", "[quote]<i>Quoted text</i>[/quote]", "[quote]The quick brown fox jumps over the lazy dog.[/quote]", "");
insert_tag("Quote (alt. 2)", "Inserts a quote.", "[quote=<i>Author</i>]<i>Quoted text</i>[/quote]", "[quote=John Doe]The quick brown fox jumps over the lazy dog.[/quote]", "");
insert_tag("List", "Inserts a list item.", "[*]<i>Text</i>", "[*] This is item 1\n[*] This is item 2", "");
insert_tag("Preformat", "Preformatted (monospace) text. Does not wrap automatically.", "[pre]<i>Text</i>[/pre]", "[pre]This is preformatted text.[/pre]", "");
end_frame();
end_main_frame();
stdfoot();
Exemple #5
0
        $htmlout .= "<tr><td>{$lang['tags_remarks']}</td><td>{$remarks}</td></tr>\n";
    }
    $htmlout .= "</table>\n";
    return $htmlout;
}
$HTMLOUT = '';
$HTMLOUT .= begin_main_frame();
$HTMLOUT .= begin_frame("Tags");
$test = isset($_POST["test"]) ? $_POST["test"] : '';
$HTMLOUT .= "{$lang['tags_title']}\r\n\r\n    <form method='post' action='?'>\r\n    <textarea name='test' cols='60' rows='3'>" . ($test ? htmlspecialchars($test) : "") . "</textarea>\r\n    <input type='submit' value='{$lang['tags_test']}' style='height: 23px; margin-left: 5px' />\r\n    </form>";
if ($test != "") {
    $HTMLOUT .= "<p><hr>" . format_comment($test) . "<hr></p>\n";
}
$HTMLOUT .= insert_tag($lang['tags_bold1'], $lang['tags_bold2'], $lang['tags_bold3'], $lang['tags_bold4'], "");
$HTMLOUT .= insert_tag($lang['tags_italic1'], $lang['tags_italic2'], $lang['tags_italic3'], $lang['tags_italic4'], "");
$HTMLOUT .= insert_tag($lang['tags_underline1'], $lang['tags_underline2'], $lang['tags_underline3'], $lang['tags_underline4'], "");
$HTMLOUT .= insert_tag($lang['tags_color1'], $lang['tags_color2'], $lang['tags_color3'], $lang['tags_color4'], $lang['tags_color5']);
$HTMLOUT .= insert_tag($lang['tags_color6'], $lang['tags_color7'], $lang['tags_color8'], $lang['tags_color9'], $lang['tags_color10']);
$HTMLOUT .= insert_tag($lang['tags_size1'], $lang['tags_size2'], $lang['tags_size3'], $lang['tags_size4'], $lang['tags_size5']);
$HTMLOUT .= insert_tag($lang['tags_fonts1'], $lang['tags_fonts2'], $lang['tags_fonts3'], $lang['tags_fonts4'], $lang['tags_fonts5']);
$HTMLOUT .= insert_tag($lang['tags_hyper1'], $lang['tags_hyper2'], $lang['tags_hyper3'], $lang['tags_hyper4'], $lang['tags_hyper5']);
$HTMLOUT .= insert_tag($lang['tags_hyper6'], $lang['tags_hyper7'], $lang['tags_hyper8'], $lang['tags_hyper9'], $lang['tags_hyper10']);
$HTMLOUT .= insert_tag($lang['tags_image1'], $lang['tags_image2'], $lang['tags_image3'], $lang['tags_image4'], $lang['tags_image5']);
$HTMLOUT .= insert_tag($lang['tags_image6'], $lang['tags_image7'], $lang['tags_image8'], $lang['tags_image9'], $lang['tags_image10']);
$HTMLOUT .= insert_tag($lang['tags_quote1'], $lang['tags_quote2'], $lang['tags_quote3'], $lang['tags_quote4'], "");
$HTMLOUT .= insert_tag($lang['tags_quote5'], $lang['tags_quote6'], $lang['tags_quote7'], $lang['tags_quote8'], "");
$HTMLOUT .= insert_tag($lang['tags_list1'], $lang['tags_list2'], $lang['tags_list3'], $lang['tags_list4'], "");
$HTMLOUT .= insert_tag($lang['tags_preformat1'], $lang['tags_preformat2'], $lang['tags_preformat3'], $lang['tags_preformat4'], "");
$HTMLOUT .= end_frame();
$HTMLOUT .= end_main_frame();
print stdhead("{$lang['tags_tags']}") . $HTMLOUT . stdfoot();
Exemple #6
0
function update_tag($tid, $tags)
{
    global $db;
    $tags = " {$tags} ";
    $tagids = array();
    $query = $db->query("SELECT * FROM pw_tagdata td LEFT JOIN pw_tags t USING(tagid) WHERE td.tid=" . S::sqlEscape($tid));
    while ($rt = $db->fetch_array($query)) {
        if (strpos($tags, " {$rt['tagname']} ") === false) {
            $tagids[] = $rt['tagid'];
        } else {
            $tags = str_replace(" {$rt['tagname']} ", " ", $tags);
        }
    }
    if ($tagids) {
        $tagids = S::sqlImplode($tagids);
        $db->update("DELETE FROM pw_tagdata WHERE tid=" . S::sqlEscape($tid) . "AND tagid IN({$tagids})");
        $db->update("UPDATE pw_tags SET num=num-1 WHERE tagid IN({$tagids})");
    }
    if ($tags = trim($tags)) {
        insert_tag($tid, $tags);
    }
}
Exemple #7
0
);

insert_tag(
	"Listar",
	"Setur inn atriðalista.",
	"[*]<i>Texti</i>",
	"[*] Þetta er atriði 1\n[*] Þetta er atriði 2",
	""
);

insert_tag(
	"Þverlína",
	"Setur inn þverlínu.",
	"<i>[hr]</i>",
	"[hr]",
	""
);

insert_tag(
	"Forsniðinn texti",
	"Forsniðinn (monospace) texti. Er ekki skipt sjálfkrafa milli lína.",
	"[pre]<i>Texti</i>[/pre]",
	"[pre]Þessi texti hefur verið forsniðinn.[/pre]",
	""
);

end_frame();
end_main_frame();
stdfoot();
?>
Exemple #8
0
<?php

// page title - if undefined the site title is displayed by default
$page_title = 'Tags';
// process post actions
// insert tag
if (isset($_POST['insert_tag']) && $_POST['insert_tag'] == 'add') {
    $insert_status = insert_tag();
    if (is_int($insert_status)) {
        header('Location: ' . $_SERVER["PHP_SELF"] . '?page_name=tags&tag_id=' . $insert_status);
    } else {
        $insert_error = $insert_status;
    }
}
// update tag
if (isset($_POST['update_tag']) && $_POST['update_tag'] == 'update') {
    $tag_id = (int) $_GET['tag_id'];
    $update_status = update_tag($tag_id);
    if ($update_status === true) {
        header('Location: ' . $url);
    } else {
        $error = $update_status;
    }
}
// delete tag
if (isset($_POST['confirm_delete_tag']) && $_POST['confirm_delete_tag'] == 'Yes') {
    $tag_id = (int) $_GET['tag_id'];
    $delete_status = delete_tag($tag_id);
    if ($delete_status === true) {
        header('Location: ' . $_SERVER["PHP_SELF"] . '?page_name=tags');
    } else {
Exemple #9
0
insert_tag($lang_tags['text_code'], $lang_tags['text_code_description'], $lang_tags['text_code_syntax'], $lang_tags['text_code_example'], "");
/*
insert_tag(
	$lang_tags['text_you'],
	$lang_tags['text_you_description'],
	$lang_tags['text_you_syntax'],
	$lang_tags['text_you_example'],
	$lang_tags['text_you_remarks']
);
*/
insert_tag($lang_tags['text_site'], $lang_tags['text_site_description'], $lang_tags['text_site_syntax'], $lang_tags['text_site_example'], "");
insert_tag($lang_tags['text_siteurl'], $lang_tags['text_siteurl_description'], $lang_tags['text_siteurl_syntax'], $lang_tags['text_siteurl_example'], "");
insert_tag($lang_tags['text_flash'], $lang_tags['text_flash_description'], $lang_tags['text_flash_syntax'], $lang_tags['text_flash_example'], "");
insert_tag($lang_tags['text_flash_two'], $lang_tags['text_flash_two_description'], $lang_tags['text_flash_two_syntax'], $lang_tags['text_flash_two_example'], "");
insert_tag($lang_tags['text_flv_one'], $lang_tags['text_flv_one_description'], $lang_tags['text_flv_one_syntax'], $lang_tags['text_flv_one_example'], "");
insert_tag($lang_tags['text_flv_two'], $lang_tags['text_flv_two_description'], $lang_tags['text_flv_two_syntax'], $lang_tags['text_flv_two_example'], "");
/*
insert_tag(
	$lang_tags['text_youtube'],
	$lang_tags['text_youtube_description'],
	$lang_tags['text_youtube_syntax'],
	$lang_tags['text_youtube_example'],
	""
);

insert_tag(
	$lang_tags['text_youku'],
	$lang_tags['text_youku_description'],
	$lang_tags['text_youku_syntax'],
	$lang_tags['text_youku_example'],
	""
function add_picture_tags($picture_id, $tags)
{
    global $TABLE_PREFIX;
    $tags = parse_tags($tags);
    $picture_id = intval($picture_id);
    /* Process any tags for the picture */
    $existing_tags = $existing_rels = array();
    if (sizeof($tags) > 0) {
        $tagsql = join('", "', $tags);
        $sql = 'SELECT * FROM ' . $TABLE_PREFIX . 'tags WHERE `tag` IN ("' . $tagsql . '")';
        $result = mysql_query($sql);
        while ($tag_row = mysql_fetch_assoc($result)) {
            $existing_tags[$tag_row['tag']] = $tag_row['id'];
        }
        $sql = 'SELECT * FROM ' . $TABLE_PREFIX . 'tag2picture WHERE `picture_id` ="' . $picture_id . '"';
        $result = mysql_query($sql);
        while ($tag_row = mysql_fetch_assoc($result)) {
            $existing_rels[$tag_row['tag_id']] = $tag_row['picture_id'];
        }
    }
    $added_tag_ids = array();
    foreach ($tags as $tag) {
        if (!isset($existing_tags[$tag])) {
            // Must be a new tag, register it
            $existing_tags[$tag] = insert_tag($tag);
            $added_tag_ids[] = $existing_tags[$tag];
        }
        if (!isset($existing_rels[$existing_tags[$tag]])) {
            // No connection between tag and picture? create if
            $sql = 'INSERT INTO ' . $TABLE_PREFIX . 'tag2picture (`picture_id`,`tag_id`,`tagdate`)
			VALUES ("' . $picture_id . '", "' . $existing_tags[$tag] . '", NOW())';
            mysql_query($sql);
        }
    }
    // Make sure that adding the tags 'onetwo' and 'one two' doesn't produce conflicts!
    return $added_tag_ids;
}
Exemple #11
0
?>
</p>

<form method=post action=?>
<textarea name="test" cols="60" rows="3"><?php 
print $test ? htmlspecialchars($test) : "";
?>
</textarea>
<input type=submit value="Test this code!" />
</form>
<?php 
if ($test != "") {
    print "<p><b>TEST PREVIEW:</b><hr />" . format_comment($test) . "<hr /></p>\n";
}
insert_tag("Bold", "Makes the enclosed text bold.", "[b]<i>Text</i>[/b]", "[b]This is bold text.[/b]", "");
insert_tag("Italic", "Makes the enclosed text italic.", "[i]<i>Text</i>[/i]", "[i]This is italic text.[/i]", "");
insert_tag("Underline", "Makes the enclosed text underlined.", "[u]<i>Text</i>[/u]", "[u]This is underlined text.[/u]", "");
insert_tag("Color (alt. 1)", "Changes the color of the enclosed text.", "[color=<i>Color</i>]<i>Text</i>[/color]", "[color=blue]This is blue text.[/color]", "What colors are valid depends on the browser. If you use the basic colors (red, green, blue, yellow, pink etc) you should be safe.");
insert_tag("Color (alt. 2)", "Changes the color of the enclosed text.", "[color=#<i>RGB</i>]<i>Text</i>[/color]", "[color=#0000ff]This is blue text.[/color]", "<i>RGB</i> must be a six digit hexadecimal number.");
insert_tag("Size", "Sets the size of the enclosed text.", "[size=<i>n</i>]<i>text</i>[/size]", "[size=4]This is size 4.[/size]", "<i>n</i> must be an integer in the range 1 (smallest) to 7 (biggest). The default size is 2.");
insert_tag("Font", "Sets the type-face (font) for the enclosed text.", "[font=<i>Font</i>]<i>Text</i>[/font]", "[font=Impact]Hello world![/font]", "You specify alternative fonts by separating them with a comma.");
insert_tag("Hyperlink (alt. 1)", "Inserts a hyperlink.", "[url]<i>URL</i>[/url]", "[url]" . $site_config["SITEURL"] . "[/url]", "This tag is superfluous; all URLs are automatically hyperlinked.");
insert_tag("Hyperlink (alt. 2)", "Inserts a hyperlink.", "[url=<i>URL</i>]<i>Link text</i>[/url]", "[url=" . $site_config["SITEURL"] . "]" . $site_config["SITENAME"] . "[/url]", "You do not have to use this tag unless you want to set the link text; all URLs are automatically hyperlinked.");
insert_tag("Image (alt. 1)", "Inserts a picture.", "[img=<i>URL</i>]", "[img=" . $site_config["SITEURL"] . "/images/banner.jpg]", "The URL must end with <b>.gif</b>, <b>.jpg</b> or <b>.png</b>.");
insert_tag("Image (alt. 2)", "Inserts a picture.", "[img]<i>URL</i>[/img]", "[img]" . $site_config["SITEURL"] . "/images/banner.jpg[/img]", "The URL must end with <b>.gif</b>, <b>.jpg</b> or <b>.png</b>.");
insert_tag("Quote (alt. 1)", "Inserts a quote.", "[quote]<i>Quoted text</i>[/quote]", "[quote]The quick brown fox jumps over the lazy dog.[/quote]", "");
insert_tag("Quote (alt. 2)", "Inserts a quote.", "[quote=<i>" . T_("AUTHOR") . "</i>]<i>Quoted text</i>[/quote]", "[quote=John Doe]The quick brown fox jumps over the lazy dog.[/quote]", "");
insert_tag("List", "Inserts a list item.", "[*]<i>Text</i>", "[*] This is item 1\n[*] This is item 2", "");
insert_tag("Spoiler (alt. 1)", "Inserts a spoiler.", "[spoiler]<i>Text</i>[/spoiler]", "[spoiler]The quick brown fox jumps over the lazy dog.[/spoiler]", "");
insert_tag("Spoiler (alt. 2)", "Inserts a spoiler.", "[spoiler=<i>Heading</i>]<i>Text</i>[/spoiler]", "[spoiler=Heading]The quick brown fox jumps over the lazy dog.[/spoiler]", "");