• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

PHP stripSpace函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了PHP中stripSpace函数的典型用法代码示例。如果您正苦于以下问题:PHP stripSpace函数的具体用法?PHP stripSpace怎么用?PHP stripSpace使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了stripSpace函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的PHP代码示例。

示例1: import_mt_item

function import_mt_item($item, $section, $status, $invite)
{
    # Untested import code follows
    if (empty($item)) {
        return;
    }
    include_once txpath . '/lib/classTextile.php';
    $textile = new Textile();
    $title = $textile->TextileThis($item['TITLE'], 1);
    //nice non-english permlinks
    $url_title = stripSpace(dumbDown($title));
    $body = $item['BODY'][0]['content'] . (isset($item['EXTENDED_BODY']) ? "\n<!--more-->\n" . $item['EXTENDED_BODY'][0]['content'] : '');
    $body_html = $textile->textileThis($body);
    $excerpt = @$item['EXCERPT'][0]['content'];
    $excerpt_html = $textile->textileThis($excerpt);
    $date = strtotime($item['DATE']);
    $date = date('Y-m-d H:i:s', $date);
    if (isset($item['STATUS'])) {
        $post_status = $item['STATUS'] == 'Draft' ? 1 : 4;
    } else {
        $post_status = $status;
    }
    $category1 = @$item['PRIMARY CATEGORY'];
    if ($category1 and !safe_field("name", "txp_category", "name = '{$category1}'")) {
        safe_insert('txp_category', "name='" . doSlash($category1) . "', type='article', parent='root'");
    }
    $keywords = @$item['KEYWORDS'][0]['content'];
    $authorid = safe_field('user_id', 'txp_users', "name = '" . doSlash($item['AUTHOR']) . "'");
    if (!$authorid) {
        //		$authorid = safe_field('user_id', 'txp_users', 'order by user_id asc limit 1');
        //Add new authors
        safe_insert('txp_users', "name='" . doSlash($item['AUTHOR']) . "'");
    }
    if (!safe_field("ID", "textpattern", "Title = '" . doSlash($title) . "' AND Posted = '" . doSlash($date) . "'")) {
        safe_insert('textpattern', "Posted='" . doSlash($date) . "'," . "LastMod='" . doSlash($date) . "'," . "AuthorID='" . doSlash($item['AUTHOR']) . "'," . "LastModID='" . doSlash($item['AUTHOR']) . "'," . "Title='" . doSlash($title) . "'," . "Body='" . doSlash($body) . "'," . "Body_html='" . doSlash($body_html) . "'," . "Excerpt='" . doSlash($excerpt) . "'," . "Excerpt_html='" . doSlash($excerpt_html) . "'," . "Category1='" . doSlash($category1) . "'," . "AnnotateInvite='" . doSlash($invite) . "'," . "Status='" . doSlash($post_status) . "'," . "Section='" . doSlash($section) . "'," . "Keywords='" . doSlash($keywords) . "'," . "uid='" . md5(uniqid(rand(), true)) . "'," . "feed_time='" . substr($date, 0, 10) . "'," . "url_title='" . doSlash($url_title) . "'");
        $parentid = mysql_insert_id();
        if (!empty($item['COMMENT'])) {
            foreach ($item['COMMENT'] as $comment) {
                $comment_date = date('Y-m-d H:i:s', strtotime(@$comment['DATE']));
                $comment_content = $textile->TextileThis(nl2br(@$comment['content']), 1);
                if (!safe_field("discussid", "txp_discuss", "posted = '" . doSlash($comment_date) . "' AND message = '" . doSlash($comment_content) . "'")) {
                    safe_insert('txp_discuss', "parentid='" . doSlash($parentid) . "'," . "name='" . doSlash(@$comment['AUTHOR']) . "'," . "email='" . doSlash(@$comment['EMAIL']) . "'," . "web='" . doSlash(@$comment['URL']) . "'," . "ip='" . doSlash(@$comment['IP']) . "'," . "posted='" . doSlash($comment_date) . "'," . "message='" . doSlash($comment_content) . "'," . "visible='1'");
                }
            }
        }
        return $title;
    }
    return $title . ' already imported';
}
开发者ID:bgarrels,项目名称:textpattern,代码行数:49,代码来源:import_mt.php


示例2: search

/**
 * Performs searching and returns results.
 *
 * This is now performed by doArticles().
 *
 * @param      string $q
 * @deprecated in 4.0.4
 * @see        doArticles()
 */
function search($q)
{
    global $prefs;
    $url = $prefs['siteurl'];
    extract($prefs);
    $s_filter = filterSearch();
    $form = fetch('form', 'txp_form', 'name', 'search_results');
    // Lose this eventually - only used if search_results form is missing.
    $form = !$form ? legacy_form() : $form;
    $rs = safe_rows("*, ID AS thisid, UNIX_TIMESTAMP(Posted) AS posted, Title AS title,\n        MATCH (Title,Body) AGAINST ('{$q}') AS score", 'textpattern', "(Title RLIKE '{$q}' OR Body RLIKE '{$q}') {$s_filter}\n        AND Status = 4 AND Posted <= " . now('posted') . " ORDER BY score DESC LIMIT 40");
    if ($rs) {
        $result_rows = count($rs);
        $text = $result_rows == 1 ? gTxt('article_found') : gTxt('articles_found');
    } else {
        $result_rows = 0;
        $text = gTxt('articles_found');
    }
    $results[] = graf($result_rows . ' ' . $text);
    if ($result_rows > 0) {
        foreach ($rs as $a) {
            extract($a);
            $result_date = safe_strftime($archive_dateformat, $posted);
            $uTitle = $url_title ? $url_title : stripSpace($Title);
            $hurl = permlinkurl($a);
            $result_url = '<a href="' . $hurl . '">' . $hurl . '</a>';
            $result_title = '<a href="' . $hurl . '">' . $Title . '</a>';
            $result = preg_replace("/>\\s*</", "> <", $Body_html);
            preg_match_all("/\\s.{1,50}" . preg_quote($q) . ".{1,50}\\s/i", $result, $concat);
            $concat = join(" ... ", $concat[0]);
            $concat = strip_tags($concat);
            $concat = preg_replace('/^[^>]+>/U', "", $concat);
            $concat = preg_replace("/({$q})/i", "<strong>\$1</strong>", $concat);
            $result_excerpt = $concat ? "... " . $concat . " ..." : '';
            $glob['search_result_title'] = $result_title;
            $glob['search_result_excerpt'] = $result_excerpt;
            $glob['search_result_url'] = $result_url;
            $glob['search_result_date'] = $result_date;
            $GLOBALS['this_result'] = $glob;
            $thisresult = $form;
            $results[] = parse($thisresult);
        }
    }
    return is_array($results) ? join('', $results) : '';
}
开发者ID:scar45,项目名称:textpattern,代码行数:53,代码来源:search.php


示例3: search

function search($q)
{
    global $prefs;
    $url = $prefs['siteurl'];
    extract($prefs);
    $s_filter = filterSearch();
    $form = fetch('form', 'txp_form', 'name', 'search_results');
    // lose this eventually - only used if search_results form is missing
    $form = !$form ? legacy_form() : $form;
    $rs = safe_rows("*, ID as thisid, unix_timestamp(Posted) as posted, Title as title,\n\t\t\tmatch (Title,Body) against ('{$q}') as score", "textpattern", "(Title rlike '{$q}' or Body rlike '{$q}') {$s_filter}\n\t\t\tand Status = 4 and Posted <=now() order by score desc limit 40");
    if ($rs) {
        $result_rows = count($rs);
        $text = $result_rows == 1 ? gTxt('article_found') : gTxt('articles_found');
    } else {
        $result_rows = 0;
        $text = gTxt('articles_found');
    }
    $results[] = graf($result_rows . ' ' . $text);
    if ($result_rows > 0) {
        foreach ($rs as $a) {
            extract($a);
            $result_date = safe_strftime($archive_dateformat, $posted);
            $uTitle = $url_title ? $url_title : stripSpace($Title);
            $hurl = permlinkurl($a);
            $result_url = '<a href="' . $hurl . '">' . $hurl . '</a>';
            $result_title = '<a href="' . $hurl . '">' . $Title . '</a>';
            $result = preg_replace("/>\\s*</", "> <", $Body_html);
            preg_match_all("/\\s.{1,50}" . preg_quote($q) . ".{1,50}\\s/i", $result, $concat);
            $concat = join(" ... ", $concat[0]);
            $concat = strip_tags($concat);
            $concat = preg_replace('/^[^>]+>/U', "", $concat);
            $concat = preg_replace("/({$q})/i", "<strong>\$1</strong>", $concat);
            $result_excerpt = $concat ? "... " . $concat . " ..." : '';
            $glob['search_result_title'] = $result_title;
            $glob['search_result_excerpt'] = $result_excerpt;
            $glob['search_result_url'] = $result_url;
            $glob['search_result_date'] = $result_date;
            $GLOBALS['this_result'] = $glob;
            $thisresult = $form;
            $results[] = parse($thisresult);
        }
    }
    return is_array($results) ? join('', $results) : '';
}
开发者ID:bgarrels,项目名称:textpattern,代码行数:44,代码来源:search.php


示例4: search

function search($q)
{
    global $prefs;
    $url = $prefs['siteurl'];
    extract($prefs);
    $s_filter = filterSearch();
    $form = fetch('form', 'txp_form', 'name', 'search_results');
    // lose this eventually - only used if search_results form is missing
    $form = !$form ? legacy_form() : $form;
    $rs = safe_rows("ID, Title, Body_html, Section, unix_timestamp(Posted) as uPosted, \n\t\t\tmatch (Title,Body) against ('{$q}') as score", "textpattern", "Title rlike '{$q}' or Body rlike '{$q}' {$s_filter}\n\t\t\tand Status = 4 and Posted <=now() order by score desc limit 40");
    if ($rs) {
        $result_rows = count($rs);
        $text = $result_rows == 1 ? gTxt('article_found') : gTxt('articles_found');
    } else {
        $result_rows = 0;
        $text = gTxt('articles_found');
    }
    $results[] = graf($result_rows . ' ' . $text);
    if ($result_rows > 0) {
        foreach ($rs as $a) {
            extract($a);
            $result_date = date("j M Y", $uPosted);
            $hurl = $url_mode ? $siteurl . $path_from_root . $Section . '/' . $ID . '/' . stripSpace($Title) : $siteurl . $path_from_root . 'index.php?id=' . $ID;
            $result_url = '<a href="http://' . $hurl . '">' . $hurl . '</a>';
            $result_title = '<a href="http://' . $hurl . '">' . $Title . '</a>';
            $result = preg_replace("/>\\s*</", "> <", $Body_html);
            preg_match_all("/\\s.{0,50}" . $q . ".{0,50}\\s/i", $result, $concat);
            $concat = implode(" ... ", $concat[0]);
            $concat = strip_tags($concat);
            $concat = preg_replace('/^[^>]+>/U', "", $concat);
            $concat = preg_replace("/({$q})/i", "<strong>\$1</strong>", $concat);
            $result_excerpt = $concat ? "... " . $concat . " ..." : '';
            $glob['search_result_title'] = $result_title;
            $glob['search_result_excerpt'] = $result_excerpt;
            $glob['search_result_url'] = $result_url;
            $glob['search_result_date'] = $result_date;
            $GLOBALS['this_result'] = $glob;
            $thisresult = $form;
            $results[] = parse($thisresult);
        }
    }
    return is_array($results) ? join('', $results) : '';
}
开发者ID:bgarrels,项目名称:textpattern,代码行数:43,代码来源:search.php


示例5: _getMetaWeblogContents

 function _getMetaWeblogContents($struct, $publish, $txp)
 {
     global $gmtoffset, $is_dst;
     $contents = array('Body' => str_replace('\\n', n, $struct['description']), 'Status' => $publish ? '4' : '1', 'Title' => $struct['title']);
     if (!empty($struct['categories'])) {
         if (!empty($struct['categories'][0])) {
             $c = $txp->getCategoryTitle($struct['categories'][0]);
             $contents['Category1'] = $c['name'];
         }
         if (!empty($struct['categories'][1])) {
             $c = $txp->getCategoryTitle($struct['categories'][1]);
             $contents['Category2'] = $c['name'];
         }
     }
     if (isset($struct['date_created_gmt'])) {
         $struct['dateCreated'] = $struct['date_created_gmt'];
         $struct['dateCreated']->tz = 'Z';
         // force GMT timezone
     }
     if (isset($struct['dateCreated'])) {
         if ($struct['dateCreated']->tz == 'Z') {
             // GMT-based posting time; transform into server time zone
             $posted = $struct['dateCreated']->getTimestamp() - tz_offset() + $gmtoffset + ($is_dst ? 3600 : 0);
         } elseif (!$struct['dateCreated']->tz) {
             // posting in an unspecified time zone: Assume site time.
             $posted = $struct['dateCreated']->getTimestamp() - tz_offset();
         } else {
             // numeric time zone offsets
             if (preg_match('/([+-][0-9]{2})([0-9]{2})/', $struct['dateCreated']->tz, $t)) {
                 $tz = $t[1] * 3600 + $t[2] * 60;
                 $posted = $struct['dateCreated']->getTimestamp() - tz_offset() + $gmtoffset + ($is_dst ? 3600 : 0) - $tz;
             }
         }
     }
     if (isset($posted)) {
         $contents['Posted'] = date('Y-m-d H:i:s', $posted);
     }
     // MovableType Implementation Add ons
     if (isset($struct['mt_allow_comments'])) {
         $contents['Annotate'] = $struct['mt_allow_comments'];
     }
     if (isset($struct['mt_convert_breaks'])) {
         $contents['textile_body'] = $contents['textile_excerpt'] = intval($struct['mt_convert_breaks']);
     }
     if (isset($struct['mt_text_more'])) {
         $contents['Body'] .= n . n . str_replace('\\n', n, $struct['mt_text_more']);
     }
     if (isset($struct['mt_excerpt'])) {
         $contents['Excerpt'] = str_replace('\\n', n, $struct['mt_excerpt']);
     }
     if (isset($struct['mt_keywords'])) {
         $contents['Keywords'] = $struct['mt_keywords'];
     }
     if (isset($struct['mt_basename'])) {
         $contents['url_title'] = stripSpace($struct['mt_basename']);
     } elseif (isset($struct['wp_slug'])) {
         $contents['url_title'] = stripSpace($struct['wp_slug']);
     }
     return $contents;
 }
开发者ID:evanfarrar,项目名称:opensprints.org,代码行数:60,代码来源:TXP_RPCServer.php


示例6: import_blogger_item

function import_blogger_item($item, $section, $status, $invite)
{
    # Untested import code follows
    if (empty($item)) {
        return;
    }
    include_once txpath . '/lib/classTextile.php';
    $textile = new Textile();
    $title = $textile->TextileThis($item['TITLE'], 1);
    $url_title = stripSpace($title, 1);
    $body = $item['BODY'][0]['content'];
    $body_html = $textile->textileThis($body, 1);
    $date = strtotime($item['DATE']);
    $date = date('Y-m-d H:i:s', $date);
    if (isset($item['STATUS'])) {
        $post_status = $item['STATUS'] == 'Draft' ? 1 : 4;
    } else {
        $post_status = $status;
    }
    //Bogger can use special chars on author names. Strip them and check for realname
    $authorid = safe_field('user_id', 'txp_users', "RealName = '" . doSlash($item['AUTHOR']) . "'");
    if (!$authorid) {
        //		$authorid = safe_field('user_id', 'txp_users', 'order by user_id asc limit 1');
        //Add new authors
        safe_insert('txp_users', "name='" . doSlash(stripSpace($textile->TextileThis($item['AUTHOR'], 1))) . "', RealName='" . doSlash($item['AUTHOR']) . "'");
    }
    if (!safe_field("ID", "textpattern", "Title = '" . doSlash($title) . "' AND Posted = '" . doSlash($date) . "'")) {
        safe_insert('textpattern', "Posted='" . doSlash($date) . "'," . "LastMod='" . doSlash($date) . "'," . "AuthorID='" . doSlash($item['AUTHOR']) . "'," . "LastModID='" . doSlash($item['AUTHOR']) . "'," . "Title='" . doSlash($title) . "'," . "Body='" . doSlash($body) . "'," . "Body_html='" . doSlash($body_html) . "'," . "AnnotateInvite='" . doSlash($invite) . "'," . "Status='" . doSlash($post_status) . "'," . "Section='" . doSlash($section) . "'," . "uid='" . md5(uniqid(rand(), true)) . "'," . "feed_time='" . substr($date, 0, 10) . "'," . "url_title='" . doSlash($url_title) . "'");
        $parentid = mysql_insert_id();
        if (!empty($item['COMMENT'])) {
            foreach ($item['COMMENT'] as $comment) {
                $comment_date = date('Y-m-d H:i:s', strtotime(@$comment['DATE']));
                $comment_content = $textile->TextileThis(nl2br(@$comment['content']), 1);
                //Check for Comments authors
                if (preg_match('/<a href="(.*)">(.*)<\\/a>/', @$comment['AUTHOR'], $match)) {
                    @($comment['URL'] = $match[1]);
                    @($comment['AUTHOR'] = $match[2]);
                }
                if (!safe_field("discussid", "txp_discuss", "posted = '" . doSlash($comment_date) . "' AND message = '" . doSlash($comment_content) . "'")) {
                    safe_insert('txp_discuss', "parentid='" . doSlash($parentid) . "'," . "name='" . doSlash(strip_tags(@$comment['AUTHOR'])) . "'," . "web='" . doSlash(@$comment['URL']) . "'," . "posted='" . doSlash($comment_date) . "'," . "message='" . doSlash($comment_content) . "'," . "visible='1'");
                }
            }
        }
        return $title;
    }
    return $title . ' already imported';
}
开发者ID:bgarrels,项目名称:textpattern,代码行数:47,代码来源:import_blogger.php


示例7: doImportWP

function doImportWP($b2dblogin, $b2db, $b2dbpass, $b2dbhost, $wpdbprefix, $insert_into_section, $insert_with_status, $default_comment_invite)
{
    global $txpcfg;
    //Keep some response on some part
    $results = array();
    // let's go - Dean says ;-).
    $b2link = mysql_connect($b2dbhost, $b2dblogin, $b2dbpass, true);
    if (!$b2link) {
        return 'wp database values don&#8217;t work. Go back, replace them and try again';
    }
    mysql_select_db($b2db, $b2link);
    $results[] = 'connected to wp database. Importing Data';
    $a = mysql_query("\n\t\t        select\n\t\t        " . $wpdbprefix . "posts.ID as ID,\n\t\t        " . $wpdbprefix . "posts.post_date as Posted,\n\t\t        " . $wpdbprefix . "posts.post_title as Title,\n\t\t        " . $wpdbprefix . "posts.post_content as Body,\n\t\t        " . $wpdbprefix . "users.user_login as AuthorID\n\t\t        from " . $wpdbprefix . "posts\n\t\t        left join " . $wpdbprefix . "users on\n\t\t            " . $wpdbprefix . "users.ID = " . $wpdbprefix . "posts.post_author\n\t\t    ", $b2link) or $results[] = mysql_error();
    while ($b = mysql_fetch_array($a)) {
        //Clean ugly wp slashes before to continue
        $b = undoSlash(undoSlash($b));
        //Trap comments for each article
        $comments = array();
        $q = "\n\t\t\t        select\n\t\t\t        " . $wpdbprefix . "comments.comment_author_IP as ip,\n\t\t\t        " . $wpdbprefix . "comments.comment_author as name,\n\t\t\t        " . $wpdbprefix . "comments.comment_author_email as email,\n\t\t\t        " . $wpdbprefix . "comments.comment_author_url as web,\n\t\t\t        " . $wpdbprefix . "comments.comment_content as message,\n\t\t\t        " . $wpdbprefix . "comments.comment_date as posted\n\t\t\t        from " . $wpdbprefix . "comments where comment_post_ID='" . $b['ID'] . "'\n\t\t\t    ";
        $c = mysql_query($q, $b2link) or $results[] = mysql_error();
        while ($d = mysql_fetch_assoc($c)) {
            $d = undoSlash(undoSlash($d));
            $comments[] = $d;
        }
        $b['comments'] = $comments;
        unset($comments);
        //Post categories now
        $q = "\n\t\t\t      select\n\t\t\t        " . $wpdbprefix . "post2cat.category_id as catid,\n\t\t\t        " . $wpdbprefix . "categories.cat_name as catname\n\t\t\t        from " . $wpdbprefix . "post2cat\n\t\t\t        left join " . $wpdbprefix . "categories on\n\t\t\t          " . $wpdbprefix . "categories.cat_ID = " . $wpdbprefix . "post2cat.category_id where " . $wpdbprefix . "post2cat.post_id='" . $b['ID'] . "' limit 2        \n\t\t\t        ";
        $e = mysql_query($q, $b2link) or $results[] = mysql_error();
        while ($f = mysql_fetch_array($e)) {
            $categories[] = $f;
        }
        $b['Category1'] = !empty($categories[0]) ? $categories[0]['catname'] : '';
        $b['Category2'] = !empty($categories[1]) ? $categories[1]['catname'] : '';
        unset($categories);
        $articles[] = $b;
    }
    $a = mysql_query("\n\t\t      select\n\t\t        " . $wpdbprefix . "categories.cat_ID as catid,\n\t\t        " . $wpdbprefix . "categories.cat_name as catname,\n\t\t        " . $wpdbprefix . "categories.category_parent as catparent\n\t\t        from " . $wpdbprefix . "categories\n\t\t        ", $b2link) or $results[] = mysql_error();
    while ($b = mysql_fetch_array($a)) {
        $cats[] = $b;
    }
    mysql_close($b2link);
    //keep a handy copy of txpdb values, and do not alter Dean code
    // for now! ;-)
    $txpdb = $txpcfg['db'];
    $txpdblogin = $txpcfg['user'];
    $txpdbpass = $txpcfg['pass'];
    $txpdbhost = $txpcfg['host'];
    //Yes, we have to make a new connection
    //otherwise doArray complains
    $DB = new DB();
    $txplink =& $DB->link;
    mysql_select_db($txpdb, $txplink);
    include txpath . '/lib/classTextile.php';
    $textile = new Textile();
    if (!empty($articles)) {
        foreach ($articles as $a) {
            //Ugly, really ugly way to workaround the slashes WP gotcha
            $a['Body'] = str_replace('<!--more-->', '', $a['Body']);
            $a['Body_html'] = $textile->textileThis($a['Body']);
            extract($a);
            //can not use array slash due to way on which comments are selected
            $q = mysql_query("\n\t\t\t                insert into " . PFX . "textpattern set\n\t\t\t                Posted    = '" . addslashes($Posted) . "',\n\t\t\t                Title     = '" . addslashes($textile->TextileThis($Title, 1)) . "',\n\t\t\t                url_title = '" . stripSpace($Title) . "',\n\t\t\t                Body      = '" . addslashes($Body) . "',\n\t\t\t                Body_html = '" . addslashes($Body_html) . "',\n\t\t\t                AuthorID  = '" . addslashes($AuthorID) . "',\n\t\t\t                Category1 = '" . addslashes($Category1) . "',\n\t\t\t                Category2 = '" . addslashes($Category2) . "',\n\t\t\t                Section   = '{$insert_into_section}',\n\t\t\t                uid='" . md5(uniqid(rand(), true)) . "',\n\t\t\t\t\t\t\tfeed_time='" . substr($Posted, 0, 10) . "',\n\t\t\t                AnnotateInvite = '{$default_comment_invite}',\n\t\t\t                Status    = '{$insert_with_status}'\n\t\t\t            ", $txplink) or $results[] = mysql_error();
            if ($insertID = mysql_insert_id()) {
                $results[] = 'inserted wp_ entry ' . $Title . ' into Textpattern as article ' . $insertID . '';
                if (!empty($comments)) {
                    foreach ($comments as $comment) {
                        extract(array_slash($comment));
                        //The ugly workaroud again
                        $message = nl2br($message);
                        $r = mysql_query("insert into " . PFX . "txp_discuss set\t\t\t\t\t\n\t\t\t\t\t\t\t                parentid = '{$insertID}',\n\t\t\t\t\t\t\t                name = '{$name}',\n\t\t\t\t\t\t\t                email = '{$email}',\n\t\t\t\t\t\t\t                web = '{$web}',\n\t\t\t\t\t\t\t                ip = '{$ip}',\n\t\t\t\t\t\t\t                posted = '{$posted}',\n\t\t\t\t\t\t\t                message = '{$message}',\n\t\t\t\t\t\t\t                visible = 1", $txplink) or $results[] = mysql_error();
                        if ($commentID = mysql_insert_id()) {
                            $results[] = 'inserted wp_ comment <strong>' . $commentID . '</strong> into txp_discuss';
                        }
                    }
                }
            }
        }
    }
    if (!empty($cats)) {
        $right = 2;
        $left = 1;
        foreach ($cats as $cat) {
            extract(array_slash($cat));
            //Prevent repeated categories
            $rs = safe_row('id', 'txp_category', "name='{$catname}'");
            if (!$rs) {
                $left++;
                $right++;
                $q = mysql_query("\n\t\t\t\t            insert into " . PFX . "txp_category set\n\t\t\t\t             name = '{$catname}',\n\t\t\t\t             type = 'article',\n\t\t\t\t             parent = 'root',\n\t\t\t\t             lft = '{$left}',\n\t\t\t\t             rgt = '{$right}'", $txplink) or $results[] = mysql_error($q);
                if (mysql_insert_id()) {
                    $results[] = 'inserted wp_ category <strong>' . $catname . '</strong> into txp_category';
                }
            }
        }
    }
    return join('<br />', $results);
}
开发者ID:bgarrels,项目名称:textpattern,代码行数:98,代码来源:import_wp.php


示例8: import

    /**
     * Reads a CSV and inserts it into the textpattern table.
     *
     * @param resource $handle File opened with fopen()
     * @param int $status Article status.
     */
    public function import($handle, $status)
    {
        global $prefs, $txp_user;
        $row = 1;
        while (($csv = fgetcsv($handle, 0, ',')) !== FALSE) {
            $fields = count($csv);
            if ($row === 1) {
                for ($i = 0; $i < $fields; $i++) {
                    $header[$i] = $csv[$i];
                }
            } else {
                $insert = '';
                foreach ($header as $key => $value) {
                    // escape all fields
                    $csv[$key] = doSlash($csv[$key]);
                    if ($value === 'Title') {
                        $url_title = stripSpace($csv[$key], 1);
                    }
                    if ($value === 'Body' || $value === 'Excerpt') {
                        $insert .= "{$value}_html='{$csv[$key]}',";
                    }
                    $insert .= "{$value}='{$csv[$key]}',";
                }
                $uid = md5(uniqid(rand(), true));
                $insert .= <<<EOD
AuthorID='{$txp_user}',
LastModID='{$txp_user}',
AnnotateInvite='{$prefs['comments_default_invite']}',
url_title='{$url_title}',
uid='{$uid}',
feed_time=now(),
Posted=now(),
LastMod=now(),
Status={$status},
textile_body=0,
textile_excerpt=0
EOD;
                safe_insert('textpattern', $insert);
            }
            $row++;
        }
    }
开发者ID:jmdeldin,项目名称:jmd_csv,代码行数:48,代码来源:jmd_csv.php


示例9: _cbe_rndc_pop_art

 /**
  * _cbe_rndc_pop_art - Admin-side: Generate articles
  *
  * See "Rules for articles" in the helpfile
  *
  * @return  array
  */
 function _cbe_rndc_pop_art(&$message, &$html)
 {
     global $event, $comments_on_default, $comments_default_invite;
     $next_step = NULL;
     include_once txpath . '/lib/classTextile.php';
     $out = array();
     $globerrlevel = '';
     $message = gTxt(CBE_RNDC_LPFX . 'populate_end');
     if (($use_textile = get_pref('use_textile')) == USE_TEXTILE) {
         include_once txpath . '/lib/classTextile.php';
     }
     $authors = safe_column_num('name', 'txp_users', "`privs`<6");
     $posauthor = count($authors) - 1;
     $sections = safe_column_num('name', 'txp_section', "`on_frontpage`=1 AND `name`!='default'");
     $possection = count($sections) - 1;
     $categories = safe_column_num('name', 'txp_category', " `name`!='root' AND `type`='article'");
     $poscategory = count($categories) - 1;
     $stati = array(STATUS_LIVE, STATUS_LIVE, STATUS_DRAFT, STATUS_LIVE, STATUS_LIVE, STATUS_HIDDEN, STATUS_LIVE, STATUS_LIVE, STATUS_PENDING, STATUS_LIVE, STATUS_LIVE);
     $posstatus = count($stati) - 1;
     $rndnb = rand(10, 15);
     $aAids = array();
     $errlevel = "success";
     for ($i = 0; $i < $rndnb; $i++) {
         $seeddate = rand(time() - 300 * 24 * 60 * 60, time() + 60 * 24 * 60 * 60);
         $in = rand(0, 9);
         $status = $stati[rand(0, $posstatus)];
         $published = date("Y-m-d H:i:s", $seeddate);
         $lastmod = date("Y-m-d H:i:s");
         $expires = in_array($in, array(0, 4, 8)) ? '' : date("Y-m-d H:i:s", strtotime("+{$in} months", $seeddate));
         $feeddate = date("Y-m-d", $seeddate);
         $author = $authors[rand(0, $posauthor)];
         $section = $sections[rand(0, $possection)];
         $category1 = $categories[rand(0, $poscategory)];
         if (($category2 = $in == 0 ? '' : $categories[rand(0, $poscategory)]) == $category1) {
             $category2 = '';
         }
         $title = substr(_cbe_rndc_sentence(3, 5, 3, 6), 0, -1);
         $url_title = stripSpace($title, 1);
         $excerpt = _cbe_rndc_text(6, 10, 2, 8);
         $arrbody = array();
         $parag = rand(2, 5);
         for ($j = 0; $j < $parag; $j++) {
             $arrbody[] .= _cbe_rndc_text(6, 8, 5, 10) . n;
         }
         $body = join(n, $arrbody);
         switch ($use_textile) {
             case USE_TEXTILE:
                 $textile = new Textile(get_pref('doctype'));
                 $title = $textile->TextileThis($title, '', 1);
                 $body_html = $textile->TextileThis($body);
                 $excerpt_html = $textile->TextileThis($excerpt);
                 break;
             case LEAVE_TEXT_UNTOUCHED:
                 $body_html = trim($body);
                 $excerpt_html = trim($excerpt);
                 break;
             case CONVERT_LINEBREAKS:
                 $body_html = nl2br(trim($body));
                 $excerpt_html = nl2br(trim($excerpt));
                 break;
             default:
                 break;
         }
         if ($insertd = safe_insert("textpattern", "Title           = '{$title}',\n                                       Body            = '{$body}',\n                                       Body_html       = '{$body_html}',\n                                       Excerpt         = '{$excerpt}',\n                                       Excerpt_html    = '{$excerpt_html}',\n                                       Status          = '{$status}',\n                                       Posted          = '{$published}',\n                                       Expires         = '{$expires}',\n                                       AuthorID        = '{$author}',\n                                       LastMod         = '{$lastmod}',\n                                       LastModID       = '{$author}',\n                                       Section         = '{$section}',\n                                       Category1       = '{$category1}',\n                                       Category2       = '{$category2}',\n                                       textile_body    =  {$use_textile},\n                                       textile_excerpt =  {$use_textile},\n                                       Annotate        =  {$comments_on_default},\n                                       url_title       = '" . doSlash($url_title) . "',\n                                       AnnotateInvite  = '{$comments_default_invite}',\n                                       uid             = '" . md5(uniqid(rand(), true)) . "',\n                                       feed_time       = '{$feeddate}'")) {
             $aAids[] = $insertd;
         } else {
             $errlevel = "warning";
             $globerrlevel = E_ERROR;
         }
     }
     $out[] = graf(tag(gTxt(CBE_RNDC_LPFX . 'populate_end'), 'span', ' class="' . $errlevel . '"') . ': ' . join(", ", $aAids));
     if (!empty($globerrlevel)) {
         $message .= ' ' . gTxt(CBE_RNDC_LPFX . 'with_errors');
     }
     $back = tag(fInput('submit', 'submit', gTxt(CBE_RNDC_LPFX . 'go_back'), 'publish') . n . sInput(CBE_RNDC_SPFX . 'initiate') . n . eInput($event), 'div');
     $html = join(n, $out) . form($back);
     return $next_step;
 }
开发者ID:ClaireBrione,项目名称:cbe_rand_content,代码行数:85,代码来源:cbe_rand_content.php


示例10: related_articles

function related_articles($atts)
{
    if (is_array($atts)) {
        extract($atts);
    }
    global $pretext, $thisid;
    extract($pretext);
    $label = empty($label) ? "" : $label;
    $limit = empty($limit) ? 10 : $limit;
    $break = empty($break) ? br : $break;
    $wraptag = empty($wraptag) ? "" : $wraptag;
    if ($thisid) {
        $id = $thisid;
    }
    $cats = safe_row("Category1,Category2", "textpattern", "ID='{$id}' limit 1");
    if (!empty($cats[0]) or !empty($cats[1])) {
        $q = array("select * from " . PFX . "textpattern where Status = 4 and ID!='{$id}'", !empty($cats[0]) ? "and ((Category1='{$cats['0']}') or (Category2='{$cats['0']}'))" : '', !empty($cats[1]) ? "or ((Category1='{$cats['1']}') or (Category2='{$cats['1']}'))" : '', "and Status=4 and Posted <= now() order by Posted desc limit 0,{$limit}");
        $rs = getRows(join(' ', $q));
        if ($rs) {
            if ($label) {
                $out[] = $label;
            }
            foreach ($rs as $a) {
                extract($a);
                $conTitle = $url_title ? $url_title : stripSpace($Title);
                $out[] = $url_mode ? tag($Title, 'a', ' href="' . $pfr . $Section . '/' . $ID . '/' . $conTitle . '"') : tag($Title, 'a', ' href="' . $pfr . 'index.php?id=' . $ID . '"');
            }
            if (is_array($out)) {
                if ($break == 'li') {
                    return $wraptag ? tag("<li>" . join("</li>\n<li>", $out) . "</li>", $wraptag) : "<li>" . join("</li>\n<li>", $out) . "</li>";
                }
                return $wraptag ? tag(join($break . n, $out), $wraptag) : join($break . n, $out);
            }
        }
    }
    return '';
    unset($GLOBALS['thisid']);
}
开发者ID:bgarrels,项目名称:textpattern,代码行数:38,代码来源:taghandlers.php


示例11: formatHref

function formatHref($pfr, $Section, $ID, $Linktext, $Title, $class = "")
{
    global $url_mode;
    $class = $class ? ' class="' . $class . '"' : '';
    return $url_mode == 1 ? '<a href="' . $pfr . $Section . '/' . $ID . '/' . stripSpace($Title) . '"' . $class . '>' . $Linktext . '</a>' : '<a href="' . $pfr . 'index.php?id=' . $ID . '"' . $class . '>' . $Linktext . '</a>';
}
开发者ID:bgarrels,项目名称:textpattern,代码行数:6,代码来源:publish.php


示例12: atom

function atom()
{
    global $thisarticle;
    extract($GLOBALS['prefs']);
    define("t_texthtml", ' type="text/html"');
    define("t_text", ' type="text"');
    define("t_html", ' type="html"');
    define("t_xhtml", ' type="xhtml"');
    define('t_appxhtml', ' type="xhtml"');
    define("r_relalt", ' rel="alternate"');
    define("r_relself", ' rel="self"');
    $area = doSlash(gps('area'));
    extract(doSlash(gpsa(array('category', 'section', 'limit'))));
    $last = fetch('unix_timestamp(val)', 'txp_prefs', 'name', 'lastmod');
    $sitename .= $section ? ' - ' . $section : '';
    $sitename .= $category ? ' - ' . $category : '';
    $pub = safe_row("RealName, email", "txp_users", "privs=1");
    $out[] = tag($sitename, 'title', t_text);
    $out[] = tag($site_slogan, 'subtitle', t_text);
    $out[] = '<link' . r_relself . ' href="' . pagelinkurl(array('atom' => 1)) . '" />';
    $out[] = '<link' . r_relalt . t_texthtml . ' href="' . hu . '" />';
    $articles = array();
    //Atom feeds with mail or domain name
    $dn = explode('/', $siteurl);
    $mail_or_domain = $use_mail_on_feeds_id ? eE($blog_mail_uid) : $dn[0];
    $out[] = tag('tag:' . $mail_or_domain . ',' . $blog_time_uid . ':' . $blog_uid . ($section ? '/' . $section : '') . ($category ? '/' . $category : ''), 'id');
    $out[] = tag('Textpattern', 'generator', ' uri="http://textpattern.com/" version="' . $version . '"');
    $out[] = tag(gmdate("Y-m-d\\TH:i:s\\Z", $last), 'updated');
    $auth[] = tag($pub['RealName'], 'name');
    $auth[] = $include_email_atom ? tag(eE($pub['email']), 'email') : '';
    $auth[] = tag(hu, 'uri');
    $out[] = tag(n . t . t . join(n . t . t, $auth) . n, 'author');
    if (!$area or $area == 'article') {
        $sfilter = $section ? "and Section = '" . $section . "'" : '';
        $cfilter = $category ? "and (Category1='" . $category . "' or Category2='" . $category . "')" : '';
        $limit = $limit ? $limit : $rss_how_many;
        $limit = min($limit, max(100, $rss_how_many));
        $frs = safe_column("name", "txp_section", "in_rss != '1'");
        $query = array();
        foreach ($frs as $f) {
            $query[] = "and Section != '" . doSlash($f) . "'";
        }
        $query[] = $sfilter;
        $query[] = $cfilter;
        $rs = safe_rows_start("*, \n\t\t\t\tID as thisid, \n\t\t\t\tunix_timestamp(Posted) as uPosted,\n\t\t\t\tunix_timestamp(LastMod) as uLastMod", "textpattern", "Status=4 and Posted <= now() " . join(' ', $query) . "order by Posted desc limit {$limit}");
        if ($rs) {
            while ($a = nextRow($rs)) {
                extract($a);
                populateArticleData($a);
                $e = array();
                $a['posted'] = $uPosted;
                if ($show_comment_count_in_feed) {
                    $count = $comments_count > 0 ? ' [' . $comments_count . ']' : '';
                } else {
                    $count = '';
                }
                $thisauthor = get_author_name($AuthorID);
                $e['thisauthor'] = tag(n . t . t . t . tag(htmlspecialchars($thisauthor), 'name') . n . t . t, 'author');
                $e['issued'] = tag(gmdate('Y-m-d\\TH:i:s\\Z', $uPosted), 'published');
                $e['modified'] = tag(gmdate('Y-m-d\\TH:i:s\\Z', $uLastMod), 'updated');
                $escaped_title = escape_title($Title);
                $escaped_title = preg_replace("/&(?![#a-z0-9]+;)/i", '&amp;', $escaped_title);
                $escaped_title = str_replace('<', '&lt;', $escaped_title);
                $escaped_title = str_replace('>', '&gt;', $escaped_title);
                $e['title'] = tag($escaped_title . $count, 'title');
                $uTitle = $url_title ? $url_title : stripSpace($Title);
                $uTitle = htmlspecialchars($uTitle, ENT_NOQUOTES);
                $permlink = permlinkurl($a);
                $e['link'] = '<link' . r_relalt . t_texthtml . ' href="' . $permlink . '" />';
                $e['id'] = tag('tag:' . $mail_or_domain . ',' . $feed_time . ':' . $blog_uid . '/' . $uid, 'id');
                $e['category1'] = trim($Category1) ? '<category term="' . htmlspecialchars($Category1) . '" />' : '';
                $e['category2'] = trim($Category2) ? '<category term="' . htmlspecialchars($Category2) . '" />' : '';
                $Excerpt = fixup_for_feed($thisarticle['excerpt'], permlinkurl($a));
                if ($syndicate_body_or_excerpt == 0) {
                    $Body = fixup_for_feed($thisarticle['body'], permlinkurl($a));
                } else {
                    $Body = '';
                    // If there's no excerpt, use body as content instead of body as summary
                    if (!trim($Excerpt)) {
                        $Body = fixup_for_feed($thisarticle['body'], permlinkurl($a));
                    }
                }
                if (trim($Body)) {
                    $e['content'] = tag(n . $Body . n, 'content', t_html);
                }
                if (trim($Excerpt)) {
                    $e['summary'] = tag(n . $Excerpt . n, 'summary', t_html);
                }
                $articles[$ID] = tag(n . t . t . join(n . t . t, $e) . n, 'entry');
                $etags[$ID] = strtoupper(dechex(crc32($articles[$ID])));
                $dates[$ID] = $uLastMod;
            }
        }
    } elseif ($area == 'link') {
        $cfilter = $category ? "category='" . $category . "'" : '1';
        $limit = $limit ? $limit : $rss_how_many;
        $limit = min($limit, max(100, $rss_how_many));
        $rs = safe_rows_start("*", "txp_link", "{$cfilter} order by date desc limit {$limit}");
        if ($rs) {
            while ($a = nextRow($rs)) {
//.........这里部分代码省略.........
开发者ID:bgarrels,项目名称:textpattern,代码行数:101,代码来源:atom.php


示例13: _setArticle

 /**
  * Executes the real action for @see udpateArticleId and @see newArticle
  * @param array $incoming containing the desired article fields
  * @param mixed(string|integer) $article_id the ID of the article to update
  * @return mixed integer article id on success, false otherwise
  * @access private
  */
 function _setArticle($incoming, $article_id = null)
 {
     global $txpcfg;
     $prefs = get_prefs();
     extract($prefs);
     if (!empty($incoming['Section']) && !$this->getSection($incoming['Section'])) {
         return false;
     }
     if (!empty($incoming['Category1']) && !$this->getCategory($incoming['Category1'])) {
         return false;
     }
     if (!empty($incoming['Category2']) && !$this->getCategory($incoming['Category2'])) {
         return false;
     }
     if ($article_id !== null) {
         $article_id = assert_int($article_id);
     }
     //All validation rules assumed to be passed before this point.
     //Do content processing here
     $incoming_with_markup = $this->textile_main_fields($incoming, $use_textile);
     $incoming['Title'] = $incoming_with_markup['Title'];
     if (empty($incoming['Body_html']) && !empty($incoming['Body'])) {
         $incoming['Body_html'] = $incoming_with_markup['Body_html'];
     }
     if (empty($incoming['Excerpt_html']) && !empty($incoming['Excerpt'])) {
         $incoming['Excerpt_html'] = $incoming_with_markup['Excerpt_html'];
     }
     unset($incoming_with_markup);
     if (empty($incoming['Posted'])) {
         if ($article_id === null) {
             $when = !$article_id ? 'now()' : '';
             $incoming['Posted'] = $when;
         } else {
             # do not override post time for existing articles unless Posted is present
             unset($incoming['Posted']);
         }
     } else {
         $when = strtotime($incoming['Posted']) - tz_offset();
         $when = "from_unixtime({$when})";
     }
     if ($incoming['Title'] || $incoming['Body'] || $incoming['Excerpt']) {
         //Build SQL then and run query
         //Prevent data erase if not defined on the update action
         //but it was on the DB from a previous creation/edition time
         if ($article_id) {
             $old = safe_row('*', 'textpattern', "ID = {$article_id}");
             //Status should be defined previously. Be sure of that.
             if (!has_privs('article.publish', $this->txp_user) && $incoming['Status'] == 4 && $old['Status'] != 4) {
                 $incoming['Status'] = 3;
             }
             foreach ($old as $key => $val) {
                 if (!isset($incoming[$key])) {
                     $incoming[$key] = $val;
                 }
             }
         } else {
             //Status should be defined previously. Be sure of that.
             if (!has_privs('article.publish', $this->txp_user) && $incoming['Status'] == 4) {
                 $incoming['Status'] = 3;
             }
         }
         if (empty($incoming['Section']) && $article_id) {
             $incoming['Section'] = safe_field('Section', 'textpattern', "ID = {$article_id}");
         }
         $incoming = $this->_check_keys($incoming, array('AuthorID' => $this->txp_user, 'Annotate' => $comments_on_default, 'AnnotateInvite' => $comments_default_invite, 'textile_body' => $use_textile, 'textile_excerpt' => $use_textile, 'url_title' => stripSpace($incoming['Title'])));
         //Build the SQL query
         $sql = array();
         foreach ($incoming as $key => $val) {
             if ($key == 'Posted' && $val == 'now()') {
                 $sql[] = "{$key} = {$val}";
             } elseif ($key != 'ID' && $key != 'uid' && $key != 'feed_time' && $key != 'LastMod' && $key != 'LastModID') {
                 $sql[] = "{$key} = '" . doSlash($val) . "'";
             }
         }
         $sql[] = 'LastMod = now()';
         $sql[] = "LastModID = '" . doSlash($this->txp_user) . "'";
         if (!$article_id) {
             $sql[] = "uid = '" . doSlash(md5(uniqid(rand(), true))) . "'";
         }
         if (!$article_id) {
             if (empty($incoming['Posted'])) {
                 $sql[] = "feed_time = curdate()";
             } else {
                 $when = strtotime($incoming['Posted']) - tz_offset();
                 $when = strftime("%Y-%m-%d", $when);
                 $sql[] = "feed_time ='" . doSlash($when) . "'";
             }
         }
         $sql = join(', ', $sql);
         $rs = $article_id ? safe_update('textpattern', $sql, & 

鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
PHP stripSuffix函数代码示例发布时间:2022-05-23
下一篇:
PHP stripSlashesDeep函数代码示例发布时间:2022-05-23
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap