Beispiel #1
0
/**
 *
 *
 * @param unknown $bBlog (reference)
 */
function admin_plugin_rss_run(&$bBlog)
{
    $pole = "";
    for ($i = 1; $i < 10; $i++) {
        if (isset($_POST['sending']) && $_POST['sending'] == "true") {
            $id = $_POST[id . $i];
            $ch = $_POST[ch . $i];
            $update_query = "UPDATE " . T_RSS . " SET `url` = '" . $id . "',`input_charset` = '" . $ch . "' WHERE `id` = '" . $i . "' LIMIT 1 ;";
            $bBlog->query($update_query);
        }
        $query = "select * from " . T_RSS . " where id=" . $i . ";";
        $row = $bBlog->get_row($query);
        $rssurl = $row->url;
        $w1250 = "";
        if ($row->input_charset == "W1250") {
            $w1250 = " selected";
        }
        $utf8 = "";
        if ($row->input_charset == "UTF8") {
            $utf8 = " selected";
        }
        if ($i / 2 == floor($i / 2)) {
            $class = 'high';
        } else {
            $class = 'low';
        }
        $pole .= '<tr class="' . $class . '"><td>' . $i . '</td><td><input type="text" name="id' . $i . '" size="20" value="' . $rssurl . '" class="text" /></td><td><select name="ch' . $i . '">';
        $pole .= '<option>I88592</option>';
        $pole .= '<option' . $w1250 . '>W1250</option>';
        $pole .= '<option' . $utf8 . '>UTF8</option>';
        $pole .= '</select></td></tr>';
    }
    $bBlog->assign('pole', $pole);
}
Beispiel #2
0
 /**
  * Возвращает сырой коннект к БД
  */
 public function getRawDbConnect()
 {
     if (!$this->rawDbConnect) {
         $this->rawDbConnect = new \mysqli($this->dbConnect->DBHost, $this->dbConnect->DBLogin, $this->dbConnect->DBPassword, $this->dbConnect->DBName);
         $this->rawDbConnect->query('SET NAMES utf8');
     }
     return $this->rawDbConnect;
 }
Beispiel #3
0
 /**
  * 提交SQL
  * @return bool|\PDOStatement
  * @throws UpaddException
  */
 public function query()
 {
     $this->log();
     $result = $this->_linkID->query($this->_sql);
     if ($result) {
         return $result;
     }
     return false;
 }
Beispiel #4
0
/**
 * Inserts users into the DB.
 *
 * @param unknown $db_conn
 * @param unknown $json_obj
 */
function insert_default_users($db_conn, $json_obj)
{
    $sql = "insert into user(\nfirst_name, last_name, email, password_enc, group_name, active, created_date, \nupdated_date, facebook_id, twitter_id\n)\nvalues %s;";
    $user_strgs = array();
    foreach ($json_obj->users as $user) {
        $user_strgs[] = sprintf("('%s', '%s', '%s', '%s', '%s', %d, '%s', '%s', \n'%s', '%s')", $user->first_name, $user->last_name, $user->email, $user->password_enc, $user->group_name, $user->active, $user->created_date, $user->updated_date, $user->facebook_id, $user->twitter_id);
    }
    $sql = sprintf($sql, join($user_strgs, ","));
    $res = $db_conn->query($sql);
}
Beispiel #5
0
/**
 *
 *
 * @param unknown $bBlog (reference)
 * @return unknown
 */
function saveEdit(&$bBlog)
{
    $rval = true;
    if (!is_numeric($_POST['commentid'])) {
        $rval = false;
    }
    $title = my_addslashes($_POST['title']);
    $author = my_addslashes($_POST['author']);
    $email = my_addslashes($_POST['email']);
    $websiteurl = my_addslashes($_POST['websiteurl']);
    $body = my_addslashes($_POST['body']);
    if ($rval === true) {
        $q = "update " . T_COMMENTS . " set title='{$title}', postername='{$author}', posterwebsite='{$websiteurl}', posteremail='{$email}', commenttext='{$body}' where commentid='{$_POST['commentid']}'";
        if ($bBlog->query($q) === true) {
            $bBlog->assign('message', 'Comment <em>' . $title . '</em> saved');
        }
    }
    return $rval;
}
Beispiel #6
0
 /**
  * 提交SQL
  */
 public function query($sql)
 {
     $this->log($sql);
     return $this->_linkID->query($sql);
 }
Beispiel #7
0
/**
 *
 *
 * @param unknown $bBlog (reference)
 */
function admin_plugin_sections_run(&$bBlog)
{
    // Again, the plugin API needs work.
    if (isset($_GET['sectdo'])) {
        $sectdo = $_GET['sectdo'];
    } elseif (isset($_POST['sectdo'])) {
        $sectdo = $_POST['sectdo'];
    } else {
        $sectdo = '';
    }
    switch ($sectdo) {
        case 'new':
            // sections are being editied
            $bBlog->query("insert into " . T_SECTIONS . "\n\t\t\tset nicename='" . my_addslashes($_POST['nicename']) . "',\n\t\t\tname='" . my_addslashes($_POST['urlname']) . "'");
            $insid = $bBlog->insert_id;
            $bBlog->get_sections();
            // update the section cache
            break;
        case "Delete":
            // delete section
            // have to remove all references to the section in the posts
            $sect_id = $bBlog->sect_by_name[$_POST['sname']];
            if ($sect_id > 0) {
                //
                $posts_in_section_q = $bBlog->make_post_query(array("sectionid" => $sect_id));
                $posts_in_section = $bBlog->get_posts($posts_in_section_q, TRUE);
                if ($posts_in_section) {
                    foreach ($posts_in_section as $post) {
                        unset($tmpr);
                        $tmpr = array();
                        $tmpsections = explode(":", $post->sections);
                        foreach ($tmpsections as $tmpsection) {
                            if ($tmpsection != $sect_id) {
                                $tmpr[] = $tmpsection;
                            }
                        }
                        $newsects = implode(":", $tmpr);
                        // update the posts to remove the section
                        $bBlog->query("update " . T_POSTS . " set sections='{$newsects}'\n                                \twhere postid='{$post->postid}'");
                    }
                    // end foreach ($post_in_section as $post)
                }
                // end if($posts_in_section)
                // delete the section
                //$bBlog->get_results("delete from ".T_SECTIONS." where sectionid='$sect_id'");
                $bBlog->query("delete from " . T_SECTIONS . " where sectionid='{$sect_id}'");
                //echo "delete from ".T_SECTIONS." where sectionid='$sect_id'";
                $bBlog->get_sections();
                //$bBlog->debugging=TRUE;
            }
            // else show error
        // else show error
        case "Save":
            $sect_id = $bBlog->sect_by_name[$_POST['sname']];
            if ($sect_id < 1) {
                break;
            }
            $bBlog->query("update " . T_SECTIONS . " set nicename='" . my_addslashes($_POST['nicename']) . "'\n                        where sectionid='{$sect_id}'");
            $bBlog->get_sections();
            // update section cache
            break;
        default:
            // show form
            break;
    }
    $bBlog->assign('esections', $bBlog->sections);
}
Beispiel #8
0
/**
 *
 *
 * @param unknown $bBlog (reference)
 */
function admin_plugin_links_run(&$bBlog)
{
    if (isset($_GET['linkdo'])) {
        $linkdo = $_GET['linkdo'];
    } elseif (isset($_POST['linkdo'])) {
        $linkdo = $_POST['linkdo'];
    } else {
        $linkdo = '';
    }
    switch ($linkdo) {
        case "New":
            // add new link
            $maxposition = $bBlog->get_var("select position from " . T_LINKS . " order by position desc limit 0,1");
            $position = $maxposition + 10;
            $bBlog->query("insert into " . T_LINKS . "\n            set nicename='" . my_addslashes($_POST['nicename']) . "',\n            url='" . my_addslashes($_POST['url']) . "',\n            category='" . my_addslashes($_POST['category']) . "',\n\t    position='{$position}'");
            break;
        case "Delete":
            // delete link
            $bBlog->query("delete from " . T_LINKS . " where linkid=" . $_POST['linkid']);
            break;
        case "Save":
            // update an existing link
            $bBlog->query("update " . T_LINKS . "\n            set nicename='" . my_addslashes($_POST['nicename']) . "',\n            url='" . my_addslashes($_POST['url']) . "',\n            category='" . my_addslashes($_POST['category']) . "'\n            where linkid=" . $_POST['linkid']);
            break;
        case "Up":
            $bBlog->query("update " . T_LINKS . " set position=position-15 where linkid=" . $_POST['linkid']);
            reorder_links();
            break;
        case "Down":
            $bBlog->query("update " . T_LINKS . " set position=position+15 where linkid=" . $_POST['linkid']);
            reorder_links();
            break;
        default:
            // show form
            break;
    }
    if (isset($_GET['catdo'])) {
        $catdo = $_GET['catdo'];
    } elseif (isset($_POST['catdo'])) {
        $catdo = $_POST['catdo'];
    } else {
        $catdo = '';
    }
    switch ($catdo) {
        case "New":
            // add new category
            $bBlog->query("insert into " . T_CATEGORIES . "\n            set name='" . my_addslashes($_POST['name']) . "'");
            break;
        case "Delete":
            // delete category
            // have to remove all references to the category in the links
            $bBlog->query("update " . T_LINKS . "\n            set linkid=0 where linkid=" . $_POST['categoryid']);
            // delete the category
            $bBlog->query("delete from " . T_CATEGORIES . " where categoryid=" . $_POST['categoryid']);
            break;
        case "Save":
            // update an existing category
            $bBlog->query("update " . T_CATEGORIES . "\n            set name='" . my_addslashes($_POST['name']) . "'\n            where categoryid=" . $_POST['categoryid']);
            break;
        default:
            // show form
            break;
    }
    $bBlog->assign('ecategories', $bBlog->get_results("select * from " . T_CATEGORIES));
    $bBlog->assign('elinks', $bBlog->get_results("select * from " . T_LINKS . " order by position"));
}