php函数代码无法正常工作 [英] php function code not working

查看:61
本文介绍了php函数代码无法正常工作的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

<?php 
mysql_connect('localhost','ajay_wp','youmint');
mysql_select_db('ajay_wp');

class Addcoupons {

function Addcoupons(){

function get_cat_ID($ catname =''){

$ catsql =SELECT * FROM`wp_terms`其中`name` ='。addslashes($ catname)。'';;
$ allcategory = mysql_query($ catsql);
$ allcategories = mysql_fetch_array($ allcategory);
$ cateid = $ allcategories ['term_id'];

if(!empty($ cateid)){
return $ cateid;
}
其他
{
$ cateid = 0;
返回$ cateid;
}


}
函数get_store_ID($ storename){
$ store = get_term_by('name',$ storename,'store');
if($ store){
return $ store-> term_id;
}其他
{
返回0;
}
}

函数wp_insert_category($ catname ='')
{
$ slag = str_replace(',,htmlentities( $ catname));
$ slag = strtolower(str_replace(,,,$ slag));
$ slag = strtolower(str_replace(,_,$ slag));
$ catname = addslashes(ucwords($ catname));

if(!empty($ catname)){
$ term_insert = mysql_query(insert into`wp_terms` set`name` ='$ catname',`slug` ='$ slag ,'term_group` = 0\" );
$ catid = mysql_insert_id();
$ term_taxonomy = mysql_query(插入`wp_term_taxonomy`设置`term_id` ='$ catid',`taxonomy` ='category',`description` ='$ catname',`parent` = 0,`count `= 1\" );
$ taxonomyid = mysql_insert_id();
返回$ taxonomyid;
}
}

函数wp_insert_store($ storename ='',$ description ='')
{
$ slag = str_replace(' ヶ辆($ STORENAME));
$ slag = strtolower(str_replace(,_,$ slag));
$ slag = strtolower(str_replace(。,_,$ slag));
$ storename = addslashes(ucwords($ storename));
//$slag=$slag.\".com;
if(!empty($ storename)){
$ term_insert = mysql_query(insert into`wp_terms` set`name` ='$ storename',`slug` ='$ slag',`term_group `= 0\" );
$ storeid = mysql_insert_id();
$ term_taxonomy = mysql_query(插入`wp_term_taxonomy`设置`term_id` ='$ storeid',`taxonomy` ='store',`description` ='$ description',`parent` = 0,`count `= 1\" );
$ taxonomyid = mysql_insert_id();
返回$ taxonomyid;
}
}

函数remove_specila_char($ catname)
{
$ slag = str_replace(',,$ catname);
$ slag = str_replace(,_,$ catname);
返回$ slag;
}

}


函数TaxonomyIdArray($ categories ='')
{

$ categoryArray = array_filter(爆炸( - ,$类别));
$ categoryIdArray = array();
foreach($ categoryArray as $ catname)
{
$ catname = trim(stripslashes($ catname));
$ my_cat_id1 = get_cat_ID($ catname);
if($ my_cat_id1 == 0){
$ categoryId = wp_insert_category($ catname);
array_push($ categoryIdArray,$ categoryId);
}
其他
{
$ categoryId = $ my_cat_id1;
$ taxodetails = mysql_fetch_array(mysql_query(SELECT * FROM`wp_term_taxonomy`
WHERE`term_id` = $ categoryId));
$ taxonomyid = $ taxodetails ['term_taxonomy_id'];
mysql_query(update`wp_term_taxonomy` set`count` =`count` + 1,其中`term_taxonomy_id` = $ taxonomyid);
array_push($ categoryIdArray,$ taxonomyid);
}
}

返回$ categoryIdArray;
}

函数TaxonomyIdStoreArray($ stores ='',$ description ='')
{

// $ storeArray = array_filter(explode( - ,$店));
$ storeIdArray = array();
// foreach($ storeArray as $ storename)
// {
$ storename = trim(stripslashes($ stores));
$ my_store_id1 = get_cat_ID($ storename);
if($ my_store_id1 == 0){
$ storeId = wp_insert_store($ storename,$ description);
array_push($ storeIdArray,$ storeId);
}
其他
{
$ storeId = $ my_store_id1;
$ taxodetails = mysql_fetch_array(mysql_query(SELECT * FROM`wp_term_taxonomy`
WHERE`term_id` = $ storeId));
$ taxonomyid = $ taxodetails ['term_taxonomy_id'];
mysql_query(update`wp_term_taxonomy` set`count` =`count` + 1,`description` ='$ description',其中`term_taxonomy_id` = $ taxonomyid);
array_push($ storeIdArray,$ taxonomyid);
}
//}

返回$ storeIdArray;
}

函数InsertCoupons($ category ='',$ store ='',$ offerid ='',$ title ='',$ offertype ='',$ description =' ',$ merchanturl ='',$ imagesrc ='',$ code ='',$ startdate ='',$ enddate ='')
{

$ allmetakey = mysql_query( SELECT * FROM`wp_postmeta` WHERE`meta_key` ='ID'和'meta_value` ='$ offerid');

if(mysql_num_rows($ allmetakey)== 0)
{
$ postName = str_replace(',,htmlentities($ title));
$ postName = str_replace(。,,htmlentities($ postName));
$ postName = str_replace(,,,htmlentities($ postName));
$ postName = str_replace(%,,htmlentities($ postName));
$ postName = strtolower(str_replace(,_,htmlentities($ postName)));


mysql_query(插入`wp_posts` set`post_title` ='{$ title}',`post_content` ='{$ description}',`post_excerpt` ='{$标题} ''post_author` = 1,`post_status` = '发布','post_date` = NOW(),`post_date_gmt` = NOW(),`post_type` = '后',`post_name` ='{$ postName }');
$ id = mysql_insert_id();
$ Url = $ merchanturl;
$ Image = $ imagesrc;
$ Code = $ code;
foreach(array_filter($ category)as $ texonomyid)
{
mysql_query(插入`wp_term_relationships`设置`object_id` = $ id,`term_taxonomy_id` = $ texonomyid,`term_order` = 0\" );
}

foreach(array_filter($ store)as $ texonomystoreid)
{
mysql_query(插入`wp_term_relationships`设置`object_id` = $ id,` term_taxonomy_id` = $ texonomystoreid,`term_order` = 0\" );
}

mysql_query(INSERT INTO wp_postmeta(post_id,meta_key,meta_value)VALUES('{$ id}','ID','{$ offerid}'));

mysql_query(INSERT INTO wp_postmeta(post_id,meta_key,meta_value)VALUES('{$ id}','image','{$ Image}'));

mysql_query(INSERT INTO wp_postmeta(post_id,meta_key,meta_value)VALUES('{$ id}','type','{$ offertype}'));

mysql_query(INSERT INTO wp_postmeta(post_id,meta_key,meta_value)VALUES('{$ id}','url','{$ Url}'));

mysql_query(INSERT INTO wp_postmeta(post_id,meta_key,meta_value)VALUES('{$ id}','code','{$ Code}'));
mysql_query(INSERT INTO wp_postmeta(post_id,meta_key,meta_value)VALUES('{$ id}','starts','{$ startdate}'));
mysql_query(INSERT INTO wp_postmeta(post_id,meta_key,meta_value)VALUES('{$ id}','expires','{$ enddate}'));
mysql_query(INSERT INTO wp_postmeta(post_id,meta_key,meta_value)VALUES('{$ id}','featured','no'));

返回$ id;


}
}

功能UpdateCoupons($ category ='',$ store ='',$ offerid ='',$ title = '',$ offertype ='',$ description ='',$ merchanturl ='',$ imagesrc ='',$ code ='',$ startdate ='',$ enddate ='')
{
$ allmetakey = mysql_fetch_array(mysql_query(SELECT`post_id` FROM`wp_postmeta` WHERE`meta_key` ='ID'和'meta_value` ='$ offerid'));
$ Postid = $ allmetakey ['post_id'];
if($ Postid!= 0){
mysql_query(update`wp_postmeta` set`meta_value` ='$ imagesrc',WHERE`post_id` ='$ Postid'和'meta_key` ='image );
mysql_query(更新`wp_postmeta`设置'meta_value` ='$ offertype',WHERE`post_id` ='$ Postid'和'meta_key` ='type');
mysql_query(更新`wp_postmeta`设置'meta_value` ='$ merchanturl',WHERE`post_id` ='$ Postid'和'meta_key` ='url');
mysql_query(更新`wp_postmeta`设置'meta_value` ='$ code',WHERE`post_id` ='$ Postid'和'meta_key` ='code');
mysql_query(更新`wp_postmeta`设置'meta_value` ='$ startdate',WHERE`post_id` ='$ Postid'和'meta_key` ='starts');
mysql_query(更新`wp_postmeta`设置'meta_value` ='$ enddate',WHERE`post_id` ='$ Postid'和'meta_key` ='expires');
返回$ Postid;
}
}

}

?>





无法通过wordpress运行文件我猜有些功能是坏人请帮助

解决方案

catname =''){


< blockquote> catsql =SELECT * FROM`wp_terms`其中`name` ='。addslashes(


catname)。';


<?php
mysql_connect('localhost','ajay_wp','youmint');
mysql_select_db('ajay_wp');

	class Addcoupons {

		function Addcoupons(){
		
			function get_cat_ID($catname=''){

			$catsql="SELECT * FROM `wp_terms` where `name`='".addslashes($catname)."'";
			$allcategory=mysql_query($catsql);
			$allcategories=mysql_fetch_array($allcategory);
			$cateid=$allcategories['term_id'];

		if(!empty($cateid)){
			return $cateid;
			}
				else
			{
			$cateid=0;
			return $cateid;
			}

			
		}
              function get_store_ID( $storename ) {
	        $store = get_term_by( 'name', $storename, 'store' );
	        if ( $store ){
                return $store->term_id;
			}else
	{
	        return 0;
	}
	}                

		function wp_insert_category($catname='')
		{
		$slag=str_replace("'","",htmlentities($catname));
		$slag=strtolower(str_replace(",","",$slag));
		$slag=strtolower(str_replace(" ","_",$slag));
		$catname=addslashes(ucwords($catname));
		
		if(!empty($catname)){
		$term_insert=mysql_query("insert into `wp_terms` set `name`='$catname',`slug`='$slag',`term_group`=0");
		$catid= mysql_insert_id();
		$term_taxonomy=mysql_query("insert into `wp_term_taxonomy` set `term_id`='$catid',`taxonomy`='category',`description`='$catname',`parent`=0,`count`=1");
		$taxonomyid= mysql_insert_id();
		return $taxonomyid;
		}
		}

		function wp_insert_store($storename='',$description='')
		{
			$slag=str_replace("'","",htmlentities($storename));
			$slag=strtolower(str_replace(" ","_",$slag));
	                $slag=strtolower(str_replace(".","_",$slag));
			$storename=addslashes(ucwords($storename));
			//$slag=$slag.".com";
			if(!empty($storename)){
				$term_insert=mysql_query("insert into `wp_terms` set `name`='$storename',`slug`='$slag',`term_group`=0");
				$storeid= mysql_insert_id();
				$term_taxonomy=mysql_query("insert into `wp_term_taxonomy` set `term_id`='$storeid',`taxonomy`='store',`description`='$description',`parent`=0,`count`=1");
				$taxonomyid= mysql_insert_id();
				return $taxonomyid;
			}
		}
		
		function remove_specila_char($catname)
		{
			$slag=str_replace("'","",$catname);
		$slag=str_replace(" ","_",$catname);
		return $slag;
		}

		}
		

		  function TaxonomyIdArray($categories='')
		{
			
			$categoryArray=array_filter(explode("-",$categories));
			$categoryIdArray=array();
			foreach($categoryArray as $catname)
			{
				$catname=trim(stripslashes($catname));
				$my_cat_id1 = get_cat_ID($catname); 
			if($my_cat_id1==0){
					$categoryId=wp_insert_category($catname);
					array_push($categoryIdArray,$categoryId);
					}
					else
						{
					$categoryId=$my_cat_id1;
					$taxodetails=mysql_fetch_array(mysql_query("SELECT * FROM `wp_term_taxonomy`
WHERE `term_id` =$categoryId"));
					$taxonomyid=$taxodetails['term_taxonomy_id'];
					mysql_query("update `wp_term_taxonomy` set `count`=`count`+1 where `term_taxonomy_id`=$taxonomyid");
					array_push($categoryIdArray,$taxonomyid);
						}
			}
			
			return $categoryIdArray;
		}

		  function TaxonomyIdStoreArray($stores='',$description='')
		{
			
			//$storeArray=array_filter(explode("-",$stores));
			$storeIdArray=array();
			//foreach($storeArray as $storename)
			//{
				$storename=trim(stripslashes($stores));
				$my_store_id1 = get_cat_ID($storename); 
			if($my_store_id1==0){
					$storeId=wp_insert_store($storename,$description);
					array_push($storeIdArray,$storeId);
					}
					else
						{
					$storeId=$my_store_id1;
					$taxodetails=mysql_fetch_array(mysql_query("SELECT * FROM `wp_term_taxonomy`
WHERE `term_id` =$storeId"));
					$taxonomyid=$taxodetails['term_taxonomy_id'];
					mysql_query("update `wp_term_taxonomy` set `count`=`count`+1, `description`='$description'  where `term_taxonomy_id`=$taxonomyid");
					array_push($storeIdArray,$taxonomyid);
						}
			//}
			
			return $storeIdArray;
		}
	       
function InsertCoupons($category='',$store='',$offerid='',$title='',$offertype='',$description='',$merchanturl='',$imagesrc='',$code='',$startdate='',$enddate='')	
		{

		$allmetakey=mysql_query("SELECT * FROM `wp_postmeta` WHERE `meta_key` = 'ID' AND `meta_value` = '$offerid'");
			 
			if(mysql_num_rows($allmetakey)==0)
			{
				$postName=str_replace("'","",htmlentities($title));
				$postName=str_replace(".","",htmlentities($postName));
				$postName=str_replace(",","",htmlentities($postName));
				$postName=str_replace("%","",htmlentities($postName));
				$postName=strtolower(str_replace(" ","_",htmlentities($postName)));

  
  mysql_query("insert into `wp_posts` set `post_title`='{$title}', `post_content`='{$description}',`post_excerpt`='{$title}',`post_author`=1,`post_status`='publish',`post_date`=now(),`post_date_gmt`=now(),`post_type`='post',`post_name`='{$postName}'");
   		$id=mysql_insert_id();
		$Url=$merchanturl;
		$Image=$imagesrc;
		$Code=$code;
		foreach(array_filter($category) as $texonomyid)
			{
				mysql_query("insert into `wp_term_relationships` set `object_id`=$id,`term_taxonomy_id`=$texonomyid,`term_order`=0");
			}

			foreach(array_filter($store) as $texonomystoreid)
			{
				mysql_query("insert into `wp_term_relationships` set `object_id`=$id,`term_taxonomy_id`=$texonomystoreid,`term_order`=0");
			}

	  mysql_query("INSERT INTO wp_postmeta (post_id,meta_key,meta_value) VALUES ('{$id}','ID','{$offerid}')");

	  mysql_query("INSERT INTO wp_postmeta (post_id,meta_key,meta_value) VALUES ('{$id}','image','{$Image}')");

	  mysql_query("INSERT INTO wp_postmeta (post_id,meta_key,meta_value) VALUES ('{$id}','type','{$offertype}')");

	  mysql_query("INSERT INTO wp_postmeta (post_id,meta_key,meta_value) VALUES ('{$id}','url','{$Url}')");

	  mysql_query("INSERT INTO wp_postmeta (post_id,meta_key,meta_value) VALUES ('{$id}','code','{$Code}')");
	   mysql_query("INSERT INTO wp_postmeta (post_id,meta_key,meta_value) VALUES ('{$id}','starts','{$startdate}')");
	   mysql_query("INSERT INTO wp_postmeta (post_id,meta_key,meta_value) VALUES ('{$id}','expires','{$enddate}')");
	    mysql_query("INSERT INTO wp_postmeta (post_id,meta_key,meta_value) VALUES ('{$id}','featured','no')");

		return $id;
		
	   
	}
		}

		 function UpdateCoupons($category='',$store='',$offerid='',$title='',$offertype='',$description='',$merchanturl='',$imagesrc='',$code='',$startdate='',$enddate='')	
		{
		$allmetakey=mysql_fetch_array(mysql_query("SELECT `post_id` FROM `wp_postmeta` WHERE `meta_key` = 'ID' AND `meta_value` = '$offerid'"));
		$Postid=$allmetakey['post_id'];
		if($Postid!=0){
			mysql_query("update `wp_postmeta` set `meta_value` ='$imagesrc', WHERE `post_id` = '$Postid' and `meta_key` = 'image'");
			mysql_query("update `wp_postmeta` set `meta_value` ='$offertype', WHERE `post_id` = '$Postid' and `meta_key` = 'type'");
			mysql_query("update `wp_postmeta` set `meta_value` ='$merchanturl', WHERE `post_id` = '$Postid' and `meta_key` = 'url'");
			mysql_query("update `wp_postmeta` set `meta_value` ='$code', WHERE `post_id` = '$Postid' and `meta_key` = 'code'");
			mysql_query("update `wp_postmeta` set `meta_value` ='$startdate', WHERE `post_id` = '$Postid' and `meta_key` = 'starts'");
			mysql_query("update `wp_postmeta` set `meta_value` ='$enddate', WHERE `post_id` = '$Postid' and `meta_key` = 'expires'");
			return $Postid;
		}
		}
		
	}

?>



cannot run the file thru wordpress i guess some function is bad guys please help

解决方案

catname=''){


catsql="SELECT * FROM `wp_terms` where `name`='".addslashes(


catname)."'";


这篇关于php函数代码无法正常工作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆