示例#1
0
function addLessonTag($lesson_id, $reference_string, $bible_code = 'kjv', $relevant_words = '')
{
    # Add tag object
    $tag_object = addTag($reference_string, $bible_code, $relevant_words);
    # Add lesson tag object (if applicable)
    if ($tag_object) {
        $lesson_tag_object = new LessonTag();
        $lesson_tag_object->setLessonId($lesson_id)->setTag($tag_object)->save();
    }
}
function start($action)
{
    global $action, $userId, $tag;
    switch ($action) {
        case "addTag":
            return addTag($userId, $tag);
            break;
        case "removeTag":
            return removeTag($userId, $tag);
            break;
        case "getTagId":
            return getTagId($tag);
            break;
    }
}
function getTags()
{
    global $tags;
    $who = 'jbum';
    if (isset($_GET['who'])) {
        $who = $_GET['who'];
    }
    $who = preg_replace('/\\W/', '', $who);
    // remove troublesome characters from name
    if ($who == '') {
        return;
    }
    $delURL = "http://del.icio.us/rss/{$who}";
    require 'magpierss/rss_fetch.inc';
    $rss = fetch_rss($delURL);
    foreach ($rss->items as $item) {
        $tagstrings = preg_split('/ /', $item[dc][subject]);
        foreach ($tagstrings as $tagstring) {
            addTag($tagstring, "http://del.icio.us/{$who}/{$tagstring}");
        }
    }
}
function getTags()
{
    global $tags;
    $url = 'http://www.gutenberg.org/dirs/etext05/bib0110.txt';
    $ch = curl_init();
    $timeout = 30;
    // set to zero for no timeout
    curl_setopt($ch, CURLOPT_URL, $url);
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
    curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, $timeout);
    $txt = curl_exec($ch);
    curl_close($ch);
    $searches = array('/^.*\\*\\*\\* START OF THE PROJECT GUTENBERG[^\\n]*\\n/s', '/^.*(\\nBook 01)/s', '/\\*\\*\\* END OF THE PROJECT GUTENBERG.*$/s', '/[^\\w\'\\-]/s');
    $replaces = array('', '$1', '', ' ');
    $txt = preg_replace($searches, $replaces, $txt);
    $words = preg_split('/\\s+/', $txt);
    foreach ($words as $w) {
        if ($w == '' || preg_match('/[0-9]/', $w)) {
            continue;
        }
        addTag($w, 'http://dictionary.reference.com/search?q=' . $w);
    }
}
示例#5
0
function getTags($post)
{
    if ($post->attributes()->type) {
        echo "<category><![CDATA[" . $post->attributes()->type . "]]></category>\n";
        echo "\t\t<category domain=\"category\" nicename=\"" . $post->attributes()->type . "\"><![CDATA[" . $post->attributes()->type . "]]></category>\n";
    } else {
        echo "<category><![CDATA[Uncategorized]]></category>\n";
        echo "\t\t<category domain=\"category\" nicename=\"uncategorized\"><![CDATA[Uncategorized]]></category>\n";
    }
    if ($post->tag) {
        foreach ($post->tag as $tag) {
            echo "\t\t<category domain=\"tag\"><![CDATA[{$tag}]]></category>\n";
            echo "\t\t<category domain=\"tag\" nicename=\"" . removeWeirdChars($tag) . "\"><![CDATA[{$tag}]]></category>\n";
            addTag((string) $tag);
        }
    }
}
示例#6
0
        - 6 : Update personal data.
        - 7 : List all the tags
        - 8 : Meta search
  **********************************************/
switch ($_POST["action"]) {
    case '0':
        login($link);
        break;
    case '1':
        register($link);
        break;
    case '2':
        logout();
        break;
    case '3':
        addTag($link);
        break;
    case '4':
        modifyTag($link);
        break;
    case '5':
        deleteTag($link);
        break;
    case '6':
        updateData($link);
        break;
    case '7':
        listAllTags($link);
        break;
    case '8':
        //  metaSearch();
示例#7
0
function renameTag($blogid, $id, $name)
{
    // 1. If tag with new name already exists, skip the tag creation process.
    // 2. If tag with new name does not exist in this service, create new tag.
    // 3. Modify the tag relation information
    // 4. If older tag is not used anymore, drop the tag.
    $oldTagId = $id;
    $newTagId = addTag($blogid, $name);
    $query = DBModel::getInstance();
    $query->reset("TagRelations");
    $query->setAttribute('tag', $newTagId);
    $query->setQualifier('blogid', 'equals', $blogid);
    $query->setQualifier('tag', 'equals', $oldTagId);
    $query->update();
    deleteTagById($blogid, $oldTagId);
    return $newTagId;
}
示例#8
0
     $includegroups = optional_param('includegroups', false, PARAM_BOOL);
     $query = optional_param('q', "", PARAM_TEXT);
     $response = getUsersByGlobal($includegroups, $start, $max, $o, $s, $style, $query);
     break;
     /** TAGS **/
 /** TAGS **/
 case "gettag":
     $tagid = required_param('tagid', PARAM_ALPHANUMEXT);
     $response = getTag($tagid);
     break;
 case "getusertags":
     $response = getUserTags();
     break;
 case "addtag":
     $tagname = required_param('tagname', PARAM_TEXT);
     $response = addTag($tagname);
     break;
 case "edittag":
     $tagid = required_param('tagid', PARAM_ALPHANUMEXT);
     $tagname = required_param('tagname', PARAM_TEXT);
     $response = editTag($tagid, $tagname);
     break;
 case "deletetag":
     $tagid = required_param('tagid', PARAM_ALPHANUMEXT);
     $response = deleteTag($tagid);
     break;
 case "gettagsbyfirstcharacters":
     $query = required_param('q', PARAM_TEXT);
     $scope = optional_param('scope', 'my', PARAM_ALPHANUMEXT);
     $response = getTagsByFirstCharacters($query, $scope);
     break;
示例#9
0
     GalleryFooter();
     break;
 case 'cancel':
     echo $app->enqueueMessage(JText::_('COM_DATSOGALLERY_MSG_AFTER_CANCELED_ORDER'));
     GalleryHeader();
     echo dgCategories($catid);
     GalleryFooter();
     break;
 case 'notify':
     ppIpn();
     break;
 case 'vote':
     recordVote();
     break;
 case 'addtag':
     addTag();
     break;
 case 'removetag':
     removeTag();
     break;
 case 'showtags':
     showTags($id);
     break;
 case 'addtofavorites':
     addToFavorites();
     break;
 case 'editpic':
     GalleryHeader();
     editPic($uid);
     GalleryFooter();
     break;
示例#10
0
function addTagsToExperiment($eid, $tag_list)
{
    global $db;
    $zipped_list = array();
    foreach ($tag_list as $t) {
        if (!array_key_exists($t['value'], $zipped_list)) {
            $zipped_list[$t['value']] = $t['weight'];
        } else {
            // If the tag is already present with a lower weight, then replace with higher weight
            if ($zipped_list[$t['value']] < $t['weight']) {
                $zipped_list[$t['value']] = $t['weight'];
            }
        }
    }
    $tag_cache = array();
    foreach ($zipped_list as $k => $v) {
        $id = -1;
        if (!array_key_exists($k, $tag_cache)) {
            $id = getTagId($k);
            if ($id == -1) {
                $id = addTag($k, $v > 0 ? 1 : 0);
            }
            $tag_cache[$k] = $id;
        } else {
            $id = $tag_cache[$k];
        }
        addTagToExperiment($eid, $id, $v);
    }
    updateTimeModifiedForExperiment($eid);
    return true;
}
示例#11
0
    } else {
        $bool = true;
    }
    if (!$bool) {
        addTag($tag);
    }
}
$tags_en = explode(",", $tags_en);
foreach ($tags_en as $tag) {
    if ($tag) {
        $bool = getTag($tag, 'en');
    } else {
        $bool = true;
    }
    if (!$bool) {
        addTag($tag, '', 'en');
    }
}
// bet items must not be overwritten if coins have already been betted on the game
// so we need to prevent it by checking if total_placed_coin is 0
if (!$total_placed_coins) {
    $cachefile = $basedir . '/temp/bet_items_active.php';
    $cachedata = false;
    if (file_exists($cachefile)) {
        $temp = json_decode(file_get_contents($cachefile), true);
        // remove all bet items from this game
        foreach ($temp as $c) {
            if ($c['bi_game_id'] != $game_id) {
                $cachedata[] = $c;
            }
        }
示例#12
0
     $response = rateComment($_REQUEST['comment_id'], $_REQUEST['up']);
     break;
 case "register_new_user":
     $response = registerNewUser($_REQUEST['user'], $_REQUEST['password'], $_REQUEST['email']);
     break;
 case "update_page_rating":
     $response = updatePageRating($_REQUEST['url'], $_REQUEST['url_parameter'], $_REQUEST['username'], $_REQUEST['title'], $_REQUEST['rating']);
     break;
 case "get_page_rating":
     $response = getPageRating($_REQUEST['url'], $_REQUEST['url_parameter']);
     break;
 case "get_page_rating_bulk":
     $response = getPageRatingBulk($_REQUEST['url_string'], $_REQUEST['params_string'], $_REQUEST['username']);
     break;
 case "add_tag":
     $response = addTag($_REQUEST['url'], $_REQUEST['url_parameter'], $_REQUEST['tag']);
     break;
 case "get_page_tags":
     $response = getPageTags($_REQUEST['url'], $_REQUEST['url_parameter']);
     break;
 case "get_recommended_page_tags":
     $response = getRecommendedPageTags($_POST['url'], $_POST['url_parameter']);
     break;
 case "rate_tag":
     $response = rateTag($_REQUEST['url'], $_REQUEST['url_parameter'], $_REQUEST['tag'], $_REQUEST['up']);
     break;
 case "delete_tag":
     $response = deleteTag($_REQUEST['url'], $_REQUEST['url_parameter'], $_REQUEST['tag']);
     break;
 case "get_pages_with_tag":
     $response = getPagesWithTag($_REQUEST['tag']);
示例#13
0
文件: admin.php 项目: nickavv/iSENSE
         $name = preg_split("[\\s+]", $exp['name']);
         $desc = preg_split("[\\s+]", $exp['description']);
         foreach ($name as $n) {
             if (strlen($n) > 1) {
                 $tid = getTagId(safeString($n));
                 if ($tid == -1) {
                     $tid = addTag(safeString($n), 1);
                 }
                 addTagToExperiment($eid, $tid, 1);
             }
         }
         foreach ($desc as $n) {
             if (strlen($n) > 1) {
                 $tid = getTagId(safeString($n));
                 if ($tid == -1) {
                     $tid = addTag(safeString($n), 1);
                 }
                 addTagToExperiment($eid, $tid, 1);
             }
         }
     }
     break;
 case "migrateimgs":
     $s3 = new S3(AWS_ACCESS_KEY, AWS_SECRET_KEY);
     $url = "http://s3.amazonaws.com/isenseimgs/";
     $img_dir = PIC_DIR . 's3/';
     $dir = opendir($img_dir);
     while (($file = readdir($dir)) !== false) {
         $id = substr($file, 0, strpos($file, ".") + 1);
         $ext = substr($file, strpos($file, ".") + 1, 3);
         if (strlen($ext) < 3) {
示例#14
0
 // add tag
 $result = get_last_rc();
 if (mysqli_num_rows($result) == 1) {
     $news = mysqli_fetch_array($result, MYSQLI_ASSOC);
     $news_id = $news['news_id'];
 }
 // split tag
 $tags = explode(',', $tag);
 for ($i = 0; $i < count($tags); $i++) {
     $tag = trim($tags[$i]);
     // check tag exist
     $rs = get_tag_item_by_key($tag);
     // tag not exist
     if (mysqli_num_rows($rs) == 0) {
         // add tag
         $rsadd = addTag($tag);
         if (mysqli_affected_rows($dbc) == 1) {
             // add tag success
             // get tag id by last record
             $result = get_last_rc_tag();
             $last_tag = mysqli_fetch_array($result, MYSQLI_ASSOC);
             $tag_id = $last_tag['tag_id'];
             // add tag data
             $query = add_tag_data($news_id, $tag_id);
             if (mysqli_affected_rows($dbc) == 1) {
             } else {
                 $errors[] = 'tag_error';
             }
         } else {
             // add tag failed
             $errors[] = 'tag_error';
示例#15
0
function updateTags($b_id, $strTags)
{
    $strTags = trim($strTags);
    $tags = split(" ", $strTags);
    // Get each single tag
    //Remove tags if not there anymore
    //Get old tags
    $strOldTags = returnAllTags($b_id);
    $oldTags = split(" ", $strOldTags);
    // Get each single tag
    foreach ($oldTags as $old_tag) {
        $found = false;
        foreach ($tags as $new_tag) {
            if ($old_tag == $new_tag) {
                $found = true;
                break;
            }
        }
        if (!$found) {
            // Not there anymore, remove the link
            $result = unstoreTag($b_id, $old_tag);
        }
    }
    $nbChars = 0;
    //Add new tags if any
    foreach ($tags as $current_tag) {
        if (tagExists($current_tag)) {
            $tagID = returnTagID($current_tag);
            if (!returnTagLinked($b_id, $tagID)) {
                $result = storeTag($b_id, $current_tag);
            }
        } else {
            // Check max length (30) and if 150 chars have been added
            $nbChars += strlen($current_tag);
            if ($nbChars <= 150 && strlen(trim($current_tag)) <= 30) {
                $result = addTag($current_tag);
                $tagID = returnTagID($current_tag);
                $result2 = storeTag($b_id, $current_tag);
            }
        }
    }
}
示例#16
0
        $sqle = insertSql($save, "article");
        echo "does not exist. inserting... ";
    }
    // report
    if (!queryE($sqle)) {
        echo "fail\n";
    } else {
        echo "sucess\n";
        if ($mode == "insert" && ($article_id = mysql_insert_id())) {
            $tags = array("programming", "php", "javascript", "phpjs");
            foreach ($tags as $k => $tag_raw) {
                $tag = substr(addslashes(preg_replace('/[^A-z0-9_\\s]/', '', trim(preg_replace('/([\\s][\\s]*)/', " ", $tag_raw)))), 0, 50);
                if (!trim($tag)) {
                    continue;
                }
                $tag_id = addTag($tag);
                // add article tag combination
                queryE("\n                        INSERT INTO `" . $tbl_article_tag . "`\n                        SET\n                            `" . $tbl_article . "_id` = " . $article_id . ",\n                            `" . $tbl_tag . "_id` = " . $tag_id . ",\n                            `" . $tbl_site . "_id` = " . $info["site_id"] . "\n                    ");
            }
        }
    }
    flush();
}
/******************************************************************************
 *** save php.js
 ******************************************************************************/
$copyright_portions = " * Portions copyright " . implode(", ", $all_authors);
$copyright_portions = wordwrap($copyright_portions, 75, "\n * ", false);
// Determine version
$version_file = dirname(__FILE__) . "/pj_vers.dat";
$osource = file_get_contents($codedir . "/php.js");
示例#17
0
文件: Photos.php 项目: jsnshrmn/Suma
/**
 * 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();
        }
    }
}
示例#18
0
<?php

require_once dirname(__FILE__) . '/initApi.php';
$CUR_FILE = '';
$ACTION = '';
if (isset($_GET['file'])) {
    $CUR_FILE = urldecode($_GET['file']);
}
if (isset($_GET['action'])) {
    $ACTION = $_GET['action'];
}
if ($ACTION == 'remTag') {
    removeTag($CUR_FILE, $_GET['tag']);
} else {
    if ($ACTION == 'addTag') {
        addTag($CUR_FILE, $_GET['tag']);
    } else {
        if ($ACTION == 'getTags') {
            echo json_encode(extractTagsFromFile($CUR_FILE));
        } else {
            if ($ACTION == 'getGeoLoc') {
                echo json_encode(extractGps($CUR_FILE));
            }
        }
    }
}