Jump to content

liam1412

Members
  • Posts

    170
  • Joined

  • Last visited

    Never

Profile Information

  • Gender
    Not Telling

liam1412's Achievements

Member

Member (2/5)

0

Reputation

  1. Hi All Just wondering if anyone has any experience of using this hook, I am using the wpvb-threads plugin that uses the vbulletin data manager to auto post to a vbulletin forum. It works fine unless the post is scheduled, in which case it is not added to the forum I have found an action publish_future_post() but can't find any documentation for it at all Tried adding add_action('publish_future_post', 'wpvbt_exec'); to the action hooks of the plugin but it is not posting. I don't really know what data it is carrying or under what variable names to be able to get it to work. Anyone any ideas. Thanks <?php /* Plugin Name: Wordpress-vBulletin Threads Plugin URI: http://dev.whatniche.com/ Description: Allows automatic posting of certain WP content into a vB forum Version: 1.0 Author: WhatNiche Author URI: http://dev.whatniche.com/ License: GPL2 */ /* Copyright 2010 WhatNiche (email : webmaster@whatniche.com) This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License, version 2, as published by the Free Software Foundation. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ // Action Hooks and Definitions add_action('admin_menu', 'wpvbt_admin_menu'); add_action('admin_init', 'wpvbt_settings'); add_action('publish_post', 'wpvbt_exec'); add_action('publish_future_post', 'wpvbt_exec'); // Needed for some random vB reason define('THIS_SCRIPT', 'wpvbthreads'); // Admin Functions function wpvbt_admin_menu() { add_submenu_page('options-general.php', 'Wordpress-vBulletin Threads Settings', 'WPvB-Threads', 'activate_plugins', 'wpvb-threads-options', 'wpvbt_settings_page'); } function wpvbt_settings() { register_setting('wpvbt-settings', 'wpvbt_categories'); register_setting('wpvbt-settings', 'wpvbt_user', 'intval'); register_setting('wpvbt-settings', 'wpvbt_post'); register_setting('wpvbt-settings', 'wpvbt_forum_path'); } function wpvbt_settings_page() { ?> <div class="wrap"> <h2>Wordpress-vBulletin Threads</h2> <form method="post" action="options.php"> <?php settings_fields('wpvbt-settings'); ?> <table class="form-table"> <tr valign="top"> <th scope="row">Forum User (Used to Post Threads)</th> <td><input type="text" name="wpvbt_user" value="<?php echo get_option('wpvbt_user'); ?>" /></td> </tr> <tr valign="top"> <th scope="row">Categories (Separate by comma, in format WP_CAT:VB_CAT, WP_CAT may be *)</th> <td><input type="text" name="wpvbt_categories" value="<?php echo get_option('wpvbt_categories'); ?>" /></td> </tr> <tr valign="top"> <th scope="row">Post Template<br />May contain vB BBCODE<br />Tags: {date}, {content}, {title}, {excerpt}, {slug}</th> <td><textarea name="wpvbt_post" rows="8" cols="60"><?php echo get_option('wpvbt_post'); ?></textarea></td> </tr> <tr valign="top"> <th scope="row">Forum Path (e.g. forums/)</th> <td><input type="text" name="wpvbt_forum_path" value="<?php echo get_option('wpvbt_forum_path'); ?>" /></td> </tr> </table> <p class="submit"> <input type="submit" class="button-primary" value="<?php _e('Save Changes') ?>" /> </p> </form> </div> <?php } // Main Functions // Copy of WP's excerpt code // Seems there isn't a function/method to // generate an excerpt from a string // Correct me if i'm wrong. // Which makes me wonder, // why on earth it has a $text parameter. function wpvbt_excerpt($txt) { $txt = strip_shortcodes($txt); $txt = str_replace(']=]=>', ']]>', $txt); $txt = strip_tags($txt); $len = 55; $more = ' [...]'; $words = preg_split("/[\n\r\t ]+/", $txt, $len+1, PREG_SPLIT_NO_EMPTY); if(count($words) > $len) { array_pop($words); $txt = implode(' ', $words); $txt = $txt.$more; } else { $txt = implode(' ', $words); } return $txt; } // Exec function, does everything important function wpvbt_exec($pid) { global $vbulletin; // Updating? if($_POST['original_post_status'] == 'publish') return; // vB Require if(!$wpvbt_fp = get_option('wpvbt_forum_path')) return; $cwd = getcwd(); chdir($wpvbt_fp); require_once('./global.php'); require_once('./includes/functions_newpost.php'); require_once('./includes/class_dm.php'); require_once('./includes/class_dm_threadpost.php'); require_once('./includes/functions_databuild.php'); chdir($cwd); // Get WP Post $post = get_post($pid); // Set Thread Options $uid = get_option('wpvbt_user'); $fids = get_option('wpvbt_categories'); // No forum IDs? if(empty($fids)) return; // Parse them $fids = explode(",", $fids); // array('1:2','4:3') $forums = array(); foreach($fids as $fid) { if(strpos($fid, ":") === false) continue; $fid_exp = explode(":",$fid); if($fid_exp[0] == $post->post_category || $fid_exp[0] == '*') $forums[] = $fid_exp[1]; } // No Forums? if(empty($forums)) return; // Parse Message $vbpost_message = get_option('wpvbt_post'); $vbpost_message = str_replace( array('{date}', '{content}', '{title}', '{excerpt}', '{slug}'), array( $post->post_date, $post->post_content, $post->post_title, (empty($post->post_excerpt) ? wpvbt_excerpt($post->post_content) : strip_tags($post->excerpt)), $post->post_name ), $vbpost_message ); //Append originally posted $vbpost_message .= ' Originally posted at [url=http://"'.get_permalink($post->ID).'"]'.$post->post_title.'[/url]'; // User Info $uinfo = fetch_userinfo($uid); $vbulletin->userinfo = $uinfo; // Loop Through foreach($forums as $forum_id) { // Forum Info $finfo = fetch_foruminfo($forum_id); // TDM Settings $tdm =& datamanager_init('Thread_FirstPost', $vbulletin, ERRTYPE_ARRAY,'threadpost'); $tdm->setr('userid', $uinfo['userid']); $tdm->setr('title', $post->post_title); $tdm->setr('pagetext', $vbpost_message); $tdm->set('allowsmilie', 1); $tdm->set('visible', 1); $tdm->set_info('forum', $finfo); $tdm->setr('forumid', $forum_id); $tdm->set('dateline', time()); $tdm->save(); } build_thread_counters($tdm); build_forum_counters('7'); $fields_array = $tdm->thread; $thread_id = $fields_array['threadid']; $postMeta = add_post_meta($post->ID,'related_thread',$thread_id, true); } ?>
  2. Turns out its the DB class I am using. Doesn't like the $this->db->connect(); to be called twice.
  3. Hey there I am fairly new to OOP and am a little confused as to some behavior with a script I am writing. Here is the class forum.class.php class forum { function __construct() { require_once('config.php'); $this->db = new mysql(DB_SERVER, DB_USER, DB_PASS, DB_DATABASE); } function get_categories() { $this->db->connect(); $sql = "SELECT * FROM bb_categories ORDER BY category_disp_order"; $rows = $this->db->fetch_all_array($sql); return $rows; $this->db->close(); } function get_forums($id) { $this->db->connect(); $sql = "SELECT * FROM bb_forums WHERE forum_belongs_to='".$this->db->escape($id)."' ORDER BY forum_disp_order"; $rows = $this->db->fetch_all_array($sql); return $rows; $this->db->close(); } } and here is the page running it <?php session_start(); include 'functions.php'; $user = new user; $forum = new forum; $categories = $forum->get_categories(); include 'header.php'; ?> <div class="centrecol"> <div class="paddingleft"> <div class="contentbox"> <div class="contenthead"> <h3>Webmaster Forums</h3> </div> <div class="contentbody"> <div id="forumtop"> Forum Home </div> </div> </div> <?php foreach($categories as $category_details) { if($category_details['category_is_private'] == 0) { ?> <div class="contentbox"> <div class="contenthead"> <h3><?php echo $category_details['category_name']; ?></h3> </div> <div class="contentbody"> <table class="forum" cellspacing="0" cellpadding="0" border="0"> <?php $forums = $forum->get_forums($category_details['category_id']); foreach($forums as $forum_details) { ?> <tr> <td class="forumdets"> <div class="cellpadding"> <a href="viewforum.php?forumid=<?php echo $forum_details['forum_id']; ?>"><?php echo $forum_details['forum_name']; ?></a> </div> </td> <td class="forumlastpost"> <div class="cellpadding"> <br /> </div> </td> <td class="forumcounter1" align="center"> <br /> </td> <td class="forumcounter2" align="center"> <br /> </td> </tr> <?php } ?> </table> </div> </div> <?php } } ?> </div> </div> <?php include 'footer.php'; ?> When I try to run the script it calls the categories fine, but when trying to get the forums within each category it is giving failed to connect to DB error. This is resolved by including this line again, just before the 2nd query. $forum = new forum; Why is that even though the class has been declared once I have to declare it again before using it in another query. I know I could just use joins to get all this in 1 query but I really want to keep it as simple as possible? I was of the opinion to class was available till the script stopped running.
  4. Hi There I am reasonably new to OOP and am trying to build a very basic MVC for use in my own work; the ones available are just way to bloated for the sites I build. I have got my function to load a controller working, but how do I get it to load the method I want, or if no selected method exists autoload the index() method. Here is my current loadController(); function loadController($controller,$default_controller) { if(!empty($controller)) { $controllerpath = 'controllers/'.$controller.'Controller.php'; if(file_exists($controllerpath)) { include $controllerpath; } else { header("location:views/errors/404.html"); exit(); } } else { include 'controllers/'.$default_controller.'Controller.php'; } } Thanks for your help
  5. Hi I am trying to streamline my coding practices and am looking at OOP/MVC If I have 3 tables Categories Forums Posts I could acheive a forum structure quite easily by getting the categories the searching for all forums with that catid and then searching for all posts with that forumid. Obviously this is very clumsy and hard to implement in MVC I need a way to get all this in a multi dimensional array with as few queries as possible. Please go easy on me. I am very new to this. I have been using php for some time, but only at a basic level. The array would need to hold A list of categories > within each category it would need to hold a list of forums that have that catid > then I would need a post/thread count using each forumid. can I do this with joins and if so How do I do it without having sub queries in my view. Thanks again
  6. WHat would be the syntax for. That, and is there an identifier so I know what part of the array I am to perform certain checks.
  7. Hi there people. My head doesn't seem to be working today I'm wondering if someone could help me at least with Psuedo code I have the following data collected from a form. PHP Code: $set_warehouse_id = $_POST['warehouse_id']; $set_dam_location = sanitizeInput($_POST['location']); $set_location_empty = $_POST['location_empty']; $set_no_positions = sanitizeInput($_POST['num_positions_affected']); $set_reported_by = $_SESSION['ses_userid']; $set_reported_time = $timenow; $set_report_comment = sanitizeInput($_POST['comments']); $damage_level_1 = $_POST['damage_level_1']; $action_1 = santizeInput($_POST['action_1']; $completed_1 = $_POST['completed_1']; $comp_req_1 = sanitizeInput($_POST['comp_req_1']); $comp_cost_1 = $_POST['comp_cost_1']; $cost_1 = $_POST['cost_1']; $damage_level_2 = $_POST['damage_level_2']; $action_2 = santizeInput($_POST['action_2']; $completed_2 = $_POST['completed_2']; $comp_req_2 = sanitizeInput($_POST['comp_req_2']); $comp_cost_2 = $_POST['comp_cost_2']; $cost_2 = $_POST['cost_2']; $damage_level_3 = $_POST['damage_level_3']; $action_3 = santizeInput($_POST['action_3']; $completed_3 = $_POST['completed_3']; $comp_req_3 = sanitizeInput($_POST['comp_req_3']); $comp_cost_3 = $_POST['comp_cost_3']; $cost_3 = $_POST['cost_3']; $damage_level_4 = $_POST['damage_level_4']; $action_4 = santizeInput($_POST['action_4']; $completed_4 = $_POST['completed_4']; $comp_req_4 = sanitizeInput($_POST['comp_req_4']); $comp_cost_4 = $_POST['comp_cost_4']; $cost_4 = $_POST['cost_4']; $damage_level_5 = $_POST['damage_level_5']; $action_5 = santizeInput($_POST['action_5']; $completed_5 = $_POST['completed_5']; $comp_req_5 = sanitizeInput($_POST['comp_req_5']); $comp_cost_5 = $_POST['comp_cost_5']; $cost_5 = $_POST['cost_5']; $damage_level_6 = $_POST['damage_level_6']; $action_6 = santizeInput($_POST['action_6']; $completed_6 = $_POST['completed_6']; $comp_req_6 = sanitizeInput($_POST['comp_req_6']); $comp_cost_6 = $_POST['comp_cost_6']; $cost_6 = $_POST['cost_6']; $damage_level_7 = $_POST['damage_level_7']; $action_7 = santizeInput($_POST['action_7']; $completed_7 = $_POST['completed_7']; $comp_req_7 = sanitizeInput($_POST['comp_req_7']); $comp_cost_7 = $_POST['comp_cost_7']; $cost_7 = $_POST['cost_7']; $damage_level_8 = $_POST['damage_level_8']; $action_8 = santizeInput($_POST['action_8']; $completed_8 = $_POST['completed_8']; $comp_req_8 = sanitizeInput($_POST['comp_req_8']); $comp_cost_8 = $_POST['comp_cost_8']; $cost_8 = $_POST['cost_8']; $damage_level_9 = $_POST['damage_level_9']; $action_9 = santizeInput($_POST['action_9']; $completed_9 = $_POST['completed_9']; $comp_req_9 = sanitizeInput($_POST['comp_req_9']); $comp_cost_9 = $_POST['comp_cost_9']; $cost_9 = $_POST['cost_9']; $damage_level_10 = $_POST['damage_level_10']; $action_10 = santizeInput($_POST['action_10']; $completed_10 = $_POST['completed_10']; $comp_req_10 = sanitizeInput($_POST['comp_req_10']); $comp_cost_10 = $_POST['comp_cost_10']; $cost_10 = $_POST['cost_10']; $damage_level_11 = $_POST['damage_level_11']; $action_11 = santizeInput($_POST['action_11']; $completed_11 = $_POST['completed_11']; $comp_req_11 = sanitizeInput($_POST['comp_req_11']); $comp_cost_11 = $_POST['comp_cost_11']; $cost_11 = $_POST['cost_11']; $damage_level_12 = $_POST['damage_level_12']; $action_12 = santizeInput($_POST['action_12']; $completed_12 = $_POST['completed_12']; $comp_req_12 = sanitizeInput($_POST['comp_req_12']); $comp_cost_12 = $_POST['comp_cost_12']; $cost_12 = $_POST['cost_12']; $damage_level_13 = $_POST['damage_level_13']; $action_13 = santizeInput($_POST['action_13']; $completed_13 = $_POST['completed_13']; $comp_req_13 = sanitizeInput($_POST['comp_req_13']); $comp_cost_13 = $_POST['comp_cost_13']; $cost_13 = $_POST['cost_13']; $damage_level_14 = $_POST['damage_level_14']; $action_14 = santizeInput($_POST['action_14']; $completed_14 = $_POST['completed_14']; $comp_req_14 = sanitizeInput($_POST['comp_req_14']); $comp_cost_14 = $_POST['comp_cost_14']; $cost_14 = $_POST['cost_14']; Is there any easy way to check if the values of action_*, comp_req_*, and comp_cost_* and cost_* are empty in each group, without haveing to resort to a checking each of the 4 fields in each of the 14 groups. Basically if the 4 fields are empty I want to ignore the entire group and move on the next to perform checking and insert in DB If it makes things easier I actually use a mysql db to generate all these form fields by having a table with a list of each item (item_no,item_name) then a use a while loop from the db ie while($getdbshizny) { //create that particular group of fields. } Maybe when submitting the form I could put all the results in an array, but I wouldn't have a clue what to do with it after that. My head hurts. Thanks
  8. Is there a more efficient way of checking if a mysql cell contains a certain string without extracting the data and exploding into an array. I am trying to use the scriptlance data feed and I am going to input this data into a mysql DB. I want to keep the Categories as is so they will be in the mysql field as php | mysql | data entry. I want to then allow people to search by category, so If they select php I want to perform a search of the DB by category and extract any line where the category field contains the string PHP Thanks for you help
  9. You coould just use the following $script = htmlentities($script); $script = addslashes($script); This will prevent the script from causing any problems in the db Then when you call it from the db you need use $script = stripslashes($script); $script = html_entity_decode($script); before running it.
  10. Sounds like your trying to open it in the same was as you would an html file. You need to place it in your document root file and browse to it using http://localhost/text.php
  11. you can't actually explore a php file in the same way you can an html file. In the xamp istallation folder there should be a folder in there called www You need to place everything you want to be processed by php in this folder You then type http://localhost/test.php in your browser (localhost refers to the www folder.) This shoudl now be working
  12. $variable = 'what to be added'; $link = $variable.'www.linkishere.com'; Thsi will add the variable to the beginning of the link
  13. Just put it ina an if statement just use an ! if(!isset($uploadedimg)){ supply old photo } else { add new image } You could however just ignore the processing completely ie not supply the old image again. Not too much of an issue but just extra load on the server. But as you said thats how you do it the way you wan. replace is_null with ! Thanks
  14. Unfortunately the port that my cpanel resides on with my host is blocked on my corporate network. Ill check out the link. Thanks
  15. Hi I am at work and need to get a sql dump of my website. i have all the passwords and ftp to my site so is there a command to get a full sql dump of my site that i can then upload to phpmyadmin locally Thanks
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.