Example #1
0
function CreateGroup($user)
{
    if (isset($_POST["group_title"])) {
        $title = escape($_POST["group_title"]);
        $body = escape($_POST["group_body"]);
        if (isset($_POST["group_private"])) {
            $is_private = 1;
        } else {
            $is_private = 0;
        }
        $time = time();
        $query = "INSERT INTO groups (group_name,description,owner_id,time,is_private)";
        $query .= " VALUES ('{$title}','{$body}',{$user},{$time},{$is_private})";
        query($query);
        //tag processor
        $tags = escape($_POST["group_tags"]);
        if (!empty($tags)) {
            $query = "SELECT group_id FROM groups WHERE time= {$time}";
            //getting id of last added post
            $result = query($query);
            $row = mysqli_fetch_array($result);
            AddTag($tags, $row["group_id"], "group");
        }
        ?>
    <div class="alert alert-success alert-dismissible fade in">
      <button type="button" class="close" data-dismiss="alert">×</button>
      <span class="glyphicon glyphicon-ok glyphicon-pad"></span> Group successfully created!
    </div>
<?php 
    }
}
Example #2
0
/**
 * Copy URL to TAGS
 */
function CopyUrlToTags($f_iUrlId, $f_szTags = "")
{
    if (empty($f_szTags)) {
        exit('No tags, no copy!');
    }
    global $db;
    $arrTags = unaliasTags(explode(" ", str_replace('/', ' ', str_replace('+', ' ', valid_tags($f_szTags)))));
    $iUrlId = (int) $f_iUrlId;
    $iAdded = 0;
    foreach ($arrTags as $szTag) {
        // Add tag
        $iTagId = AddTag($szTag);
        // Insert relation
        $arrInsert = array('url_id' => $iUrlId, 'tag_id' => $iTagId, 'utc_added' => time());
        try {
            $iAdded += (int) $db->insert('l_links', $arrInsert);
        } catch (db_exception $ex) {
        }
    }
    exit('OK' . $iAdded);
}
Example #3
0
/**
 * Add a LINK between TAGS and a URL
 */
function _AddLink($f_szUrl, $f_szTitle, $f_szTags)
{
    global $db;
    $szUrl = trim($f_szUrl);
    $arrTags = unaliasTags(explode(' ', str_replace('/', ' ', valid_tags($f_szTags))));
    $szTitle = trim($f_szTitle);
    if (!$arrTags || !$szUrl) {
        return 'ERROR:' . __LINE__;
    }
    // Add url
    $iUrlId = AddUrl($szUrl, $szTitle);
    foreach ($arrTags as $szTag) {
        // Add tag
        $iTagId = AddTag($szTag);
        // Insert relation
        try {
            $db->insert('l_links', array('url_id' => $iUrlId, 'tag_id' => $iTagId, 'utc_added' => time()));
        } catch (db_exception $ex) {
        }
    }
    return 'OK';
}
Example #4
0
<?php 
require_once "../../includes/header.php";
?>
  <div class="container">
    <h1 class="page-header"><span class="glyphicon glyphicon-sort-by-alphabet glyphicon-pad"></span> Survey Format</h1>
<?php 
require_once "../../includes/breadcrumb.php";
$title = $_POST["survey_title"];
$body = $_POST["survey_body"];
$time = time();
$query = "INSERT INTO survey VALUES (NULL,'{$title}','{$body}',{$USERID},{$time},0)";
query($query);
$survey_key = GetDbId();
//tag processor
$tags = $_POST["survey_tags"];
AddTag($tags, $survey_key, "survey");
?>
    <div class="row clearfix">
      <div class="col-lg-10 col-lg-offset-1 col-md-10 col-md-offset-1 col-sm-10 col-sm-offset-1">
        <form action="/survey/create/content/?id=<?php 
echo $survey_key;
?>
" method="post" class="form-horizontal">
          <div class="form-group">
            <label for="survey_mcq_no" class="col-sm-2 control-label">MCQ(s)</label>
            <div class="col-sm-10">
              <input type="number" class="form-control" name="survey_mcq_no" id="survey_mcq_no" min="1" placeholder="4">
            </div>
          </div>
          <div class="form-group">
            <label for="survey_option_no" class="col-sm-2 control-label">Options per MCQ</label>
Example #5
0
function ExportPosts()
{
    global $wpdb, $from;
    $urlmap = turlmap::i();
    $urlmap->lock();
    $posts = tposts::i();
    $posts->lock();
    if (dbversion) {
        $r = $wpdb->get_results("SELECT max(ID) as autoid FROM {$wpdb->posts} ");
        $autoid = (int) $r[0]->autoid;
        echo "{$autoid} = auto id posts\n";
        $posts->db->exec(sprintf('ALTER TABLE %s AUTO_INCREMENT = %d', $posts->thistable, $autoid));
    }
    $categories = tcategories::i();
    $categories->loadall();
    $categories->lock();
    $tags = ttags::i();
    $tags->loadall();
    $tags->lock();
    if ($from == 0) {
        echo "import categories\n";
        ExportCategories();
        echo "import pages\n";
        ExportPages();
    }
    $cron = tcron::i();
    $cron->disableadd = true;
    //$list = $wpdb->get_results("SELECT * FROM $wpdb->posts WHERE post_type = 'post'");
    $list = $wpdb->get_results("SELECT ID FROM {$wpdb->posts} \r\nWHERE post_type = 'post'\r\nand ID > {$from}\r\nlimit 500\r\n");
    echo count($list), " = countposts\n";
    foreach ($list as $index => $idresult) {
        //$itemres= $wpdb->get_results("SELECT * FROM $wpdb->posts WHERE ID = $idresult");
        $itemres = $wpdb->get_results("SELECT * FROM {$wpdb->posts} WHERE ID = {$idresult->ID}");
        $item =& $itemres[0];
        $post = new tpost();
        $post->id = (int) $item->ID;
        echo $post->id, " = id post\n";
        $post->posted = strtotime(mysql2date('Ymd\\TH:i:s', $item->post_date));
        $post->title = $item->post_title;
        $post->categories = wp_get_post_categories($item->ID);
        $taglist = array();
        $wptags = wp_get_post_tags($item->ID);
        foreach ($wptags as $wptag) {
            AddTag($tags, (int) $wptag->term_id, 0, $wptag->name, get_tag_link($wptag->term_id));
            $taglist[] = (int) $wptag->term_id;
        }
        $post->tags = $taglist;
        $UrlArray = parse_url(@get_permalink($item->ID));
        $url = $UrlArray['path'];
        if (!empty($UrlArray['query'])) {
            $url .= '?' . $UrlArray['query'];
        }
        $post->url = $url;
        $post->idurl = litepublisher::$urlmap->add($post->url, get_class($post), $post->id);
        $post->content = $item->post_content;
        $post->commentsenabled = 'open' == $item->comment_status;
        $post->pingenabled = 'open' == $item->ping_status;
        $post->password = $item->post_password;
        $post->status = $item->post_status == 'publish' ? 'published' : 'draft';
        savepost($post);
        $categories->itemsposts->setitems($post->id, $post->categories);
        $tags->itemsposts->setitems($post->id, $post->tags);
        ExportComments($post);
        $post->free();
    }
    $cron->unlock();
    //$CommentManager->SubscribtionEnabled = true;
    //$CommentManager->NotifyModerator = true;
    $tags->unlock();
    $categories->unlock();
    $posts->UpdateArchives();
    $posts->addrevision();
    $posts->unlock();
    $urlmap->clearcache();
    $arch = tarchives::i();
    $arch->postschanged();
    $urlmap->unlock();
    if (count($list) < 500) {
        return false;
    }
    return $item->ID;
}
Example #6
0
                $db->rollback();
                exit('<pre>' . $ex . '</pre>');
            }
        }
        $db->commit();
        header('Location: aliases.php?_' . rand(0, 999));
    }
    exit;
} else {
    if (isset($_POST['from'], $_POST['to'])) {
        $from = $_POST['from'];
        $to = $_POST['to'];
        $message = '';
        $fromTagId = $db->select_one('l_tags', 'id', array('tag' => $from));
        if ($fromTagId) {
            $toTagId = AddTag($to);
            $db->begin();
            try {
                // Copy links
                $db->execute('INSERT INTO l_links SELECT url_id, ?, `utc_added` FROM l_links l WHERE tag_id = ? AND NOT EXISTS (SELECT * FROM l_links WHERE url_id = l.url_id AND tag_id = ?)', array($toTagId, $fromTagId, $toTagId));
                $movedTags = $db->affected_rows();
                // Delete old links
                $db->execute('DELETE FROM l_links WHERE tag_id = ?', array($fromTagId));
                // Delete old tag
                $db->execute('DELETE FROM l_tags WHERE id = ?', array($fromTagId));
                $db->commit();
                $message = 'Moved+' . $movedTags . '+tags';
                // Add alias
                try {
                    $db->insert('l_aliases', array('alias' => $from, 'tag_id' => $toTagId));
                } catch (db_exception $ex) {