Jump to content

saltedm8

Members
  • Posts

    146
  • Joined

  • Last visited

Everything posted by saltedm8

  1. several ways really but since you have used inline styles, this is easyiest for you <div id="footer" style="float:right; width:100%; margin:0; padding:0;"> <span style="font-family: Arial, Helvetica, sans-serif"><a href="">Home</a> | <a href="">About Us</a> | <a href="">Site Mape</a> | <a href="">Terms & Conditions</a> | <a href=""> Contact</a> <br>Copyright 2009 JobJar.co.uk </span></div> </div> </body> </html> this will work as long as the footer is not wrapped in some kind of container.. if this don't work, please post a link to your site.
  2. could you do me a favour.. im having trouble visualising where you want everything to sit.. could you use paintshop or anything like that and just draw boxes of where everything should be and what is essential.. for example.. does it have to be floated left ? I have done this at my best guess <p class="searchbar"> <span style="float: left;"><a href="">View unanswered posts</a> | <a href="">View active topics</a></span> <div align="center"><img src="./styles/hestia/imageset/bars/donationbar.png" alt="Donations received so far"/></div> <span style="float: right;"><a href="">View new posts</a> | <a href="">View your posts</a></span> </p>
  3. thanks for the shot, but I am still none the wiser my end goal is for someone to submit a list of menu items to the database ( also with another text box to say what the menu div name is called ), for example I want the end result to be whatever they put in like this <div id="theirdivname"> <ul> <li><a href="/page.html"> menu item </a></li> <li><a href="/page.html"> menu item </a></li> <li><a href="/page.html"> menu item </a></li> <ul/> </div> so, they are defining the div's name and they are also defining the menu names and the amount of menu items, possibly using the database as an array sort of thing so it grabs all the menu items... maybe im not explaining myself very well... I hope you get what I am doing now then for this script to collect that info and use a single function command call($menu) in and it displays the menu
  4. its showing, but its not showing as it should.. I am now getting <div id="this"> <ul> <li>Resource id #5</li> <li>Resource id #5</li> <li>Resource id #5</li> <li>Resource id #5</li> <li>Resource id #5</li> </ul> </div>
  5. I know I keep asking questions, but I am still learning and have come across another issue I am trying to call info from a database, and display it as a menu, here is what I have <?php include("connections.php"); $chop = mysql_query("SELECT * FROM table1(field2,field3,field4,field5,)VALUES('$field2','$field3','$field4','$field5') "); $menu = array('item'=>$chop, 'div'=>'this', 'count'=>5); function call($menu) { $var1 = '<div id="'; $var1 .= $menu['div'] . '">' ."\n"; $var1 .= '<ul>'."\n"; for ($i=0;$i<$menu[count];$i++){ $var1 .= '<li>' . $menu[item] . '</li>'."\n"; } $var1 .= '</ul>' ."\n"; $var1 .= '</div>'; return $var1; } ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>Untitled Document</title> </head> <body> <?php echo call($menu); ?> </body> </html> unfortunately it does not seem to be working as I hoped, its displaying the html ok, and the loop is working... but its not getting the info from the database.. I even tried an array as a test first to see if this would work, and I could not even get the array working, the best I could get was the last word in the array repeating down the menu... would you mind showing me where I am going wrong for both methods... thank you
  6. thanks for that, I might try to give it a go lol... although I probebly have a long way to go before I completly understand what it going on there lol
  7. I am just learning php but I have messed with phpbb in the past and also one or 2 cms systems, .. I have seen this << my_command >> and also this { my_command } being used to call a script into a template so for example if I typed in { CALL_MENU } then the script will get the menu script I was wondering if anyone has any idea how this is done, Im not doing it for any project but it has just got me curious.. if you could give me a simple understandable explanation, I would love to see it thank you
  8. fantastic.. will work a treat, I suppose all I have to do when I change it is to use $menu = array('hi'=>$var1, 'menu'=>$var2, 'count'=>$var3); if that would work ? thanks again
  9. Hi I am pretty new to php and have hit an issue that I cant seem to solve on my own I want to create a menu, eventually the menu items will be called from the database which would have been sent there by user input ( hence the temporary variables ) I wanted to make the function I have below into a simpler form, instead of having to type in menu($hi, $count, $menu) every time I want my menu, all I want to have to do is call($menu); but I do need the variables to be set outside the function, as they are there so I can change the values once I do the forms etc ( eventually I want to make call($whatever) standard all over the sites I am making ) could you tell me how I can do that with this <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>Untitled Document</title> </head> <body> <?php $count = 5; $hi = 'hello'; $menu = 'this'; function menu($hi, $count, $menu) { echo '<div id="'; echo $menu . '">' ."\n"; echo '<ul>'."\n"; for ($i=0;$i<$count;$i++){ echo '<li>' . $hi . '</li>'."\n"; } echo '</ul>' ."\n"; echo '</div>'; } menu($hi, $count, $menu) ?> </body> </html> thank you... p.s.. please don't get too complex, because as I said, I am only just learning and hope to be able to understand what you do so I can use it again with other functions.... thanks
  10. sorry, I forgot to mention, I have tried changing it to exit() but all this is doing is making the homepage blank when it goes down, also I tried an echo of index.php and that makes it never work cheers
  11. I created a plugin for vbulletin and I was hoping someone would know enough about vbulletin to be able to give me a hand with an issue I am having I have this script <?php class myTwit{ var $user = false; // User to show public posts var $cacheFile = 'twitcache.txt'; // File to save local cache of Twitter update var $cachExpire = 300; // Seconds that cache is classed as "old" var $myTwitHeader = true; var $postLimit = 20; // 20 = max var $debug = false; function printError($message){ print htmlspecialchars($message); exit; } function debugMsg($message){ if ($this->debug == true) print htmlspecialchars($message).'<br />'; } function formatDays($val, $qty){ if ($val > 1) return $val.' '.$qty.'s ago'; else return $val.' '.$qty.' ago'; } function intoRelativeTime($seconds){ if (($seconds / 60 / 60 / 24) > 1) return $this->formatDays(round($seconds / 60 / 60 / 24), 'day'); elseif (($seconds / 60 / 60) > 1) return 'about '.$this->formatDays(round($seconds / 60 / 60), 'hour'); else if (($seconds / 60 ) > 1) return 'about '.$this->formatDays(round($seconds / 60), 'minute'); else return 'about '.round($seconds).' seconds ago'; } function linkURLs($text){ $in=array( '`((?:https?|ftp)://\S+[[:alnum:]]/?)`si', '`((?<!//)(www\.\S+[[:alnum:]]/?))`si' ); $out=array( '<a href="$1" target="_blank">$1</a> ', '<a href="http://$1" target="_blank">$1</a>' ); $text = preg_replace($in,$out,$text); $text = preg_replace('/@([a-zA-Z0-9-]+)/','@<a href="http://twitter.com/$1" target="_blank">$1</a>',$text); return $text; } function checkCacheFile(){ if ( (@filemtime($this->cacheFile) < (mktime() - $this->cachExpire) ) || (!is_file($this->cacheFile)) ){ $this->debugMsg('Cache file outdated'); $this->updateCache(); } else { $this->debugMsg('Cache file still valid'); } } function updateCache(){ $uri = 'http://twitter.com/statuses/user_timeline/'.$this->user.'.json'; $req = new HTTPRequest($uri); $tmpdata = $req->DownloadToString(); $resp = json_decode($tmpdata, true); if (isset($resp['error'])) $this->printError('Error getting information from Twitter ['.$resp['error'].']. Please check the username ('.$this->user.')'); elseif (!is_array($resp)) $this->printError('Error getting information from Twitter. File is not JSON.'); $handle = @fopen($this->cacheFile, 'w'); if (!$handle) $this->printError('Could not write to cache file: '.$this->cacheFile.'. Please check read/write permissions.'); fwrite($handle, $tmpdata); fclose($handle); $this->debugMsg('Updated cache file: '.$this->cacheFile); } function readCache(){ if( false == ($this->jsonData = @file_get_contents( $this->cacheFile ))) $this->printError('Could not read cache file: '.$this->cacheFile); } function initMyTwit(){ if (!is_string($this->user)) $this->printError('Please set a user.'); $this->checkCacheFile(); $this->readCache(); $this->jsonArray = json_decode($this->jsonData, true); $output = '<ul class="twitbox">'; if ($this->myTwitHeader && isset($this->jsonArray[0])){ $output .= ' <li class="mytwitHead"><img src="'.$this->jsonArray[0]['user']['profile_image_url'].'" alt="'.$this->user.'" /> <div><a href="http://twitter.com/'.$this->user.'" target="_blank">'.$this->user.'</a><br /> '.$this->jsonArray[0]['user']['followers_count'].' followers</div> </li>'; } for($x=0; $x < count($this->jsonArray) && $x < $this->postLimit; $x++){ $seconds_ago = mktime() - strtotime($this->jsonArray[$x]['created_at']); $ts = strtotime($this->jsonArray[$x]['created_at'])+$this->jsonArray[$x]['user']['utc_offset']; $cur_ts = mktime(); $output .= '<li class="twit">'.$this->linkURLs(htmlspecialchars($this->jsonArray[$x]['text'])). ' <span class="twhen">by <a href="http://twitter.com/'.$this->jsonArray[$x]['user']['screen_name'].'" target="_blank">'.$this->jsonArray[$x]['user']['screen_name'].'</a> '. $this->intoRelativeTime($seconds_ago)."</span></li>\n"; } $output .= '</ul>'; $this->myTwitData = $output; } } class HTTPRequest{ var $_fp; // HTTP socket var $_url; // full URL var $_host; // HTTP host var $_protocol; // protocol (HTTP/HTTPS) var $_uri; // request URI var $_port; // port // scan url function _scan_url(){ $req = $this->_url; $pos = strpos($req, '://'); $this->_protocol = strtolower(substr($req, 0, $pos)); $req = substr($req, $pos+3); $pos = strpos($req, '/'); if($pos === false) $pos = strlen($req); $host = substr($req, 0, $pos); if(strpos($host, ':') !== false) { list($this->_host, $this->_port) = explode(':', $host); }else{ $this->_host = $host; $this->_port = ($this->_protocol == 'https') ? 443 : 80; } $this->_uri = substr($req, $pos); if($this->_uri == '') $this->_uri = '/'; } // constructor function HTTPRequest($url){ $this->_url = $url; $this->_scan_url(); } // download URL to string function DownloadToString(){ $crlf = "\r\n"; // generate request $req = 'GET ' . $this->_uri . ' HTTP/1.0' . $crlf . 'Host: ' . $this->_host . $crlf . 'User-Agent: PHP' . $crlf . $crlf; // fetch $this->_fp = @fsockopen(($this->_protocol == 'https' ? 'ssl://' : '') . $this->_host, $this->_port); if ($this->_fp){ fwrite($this->_fp, $req); $response = ""; while(is_resource($this->_fp) && $this->_fp && !feof($this->_fp)) $response .= fread($this->_fp, 1024); fclose($this->_fp); // split header and body $pos = strpos($response, $crlf . $crlf); if($pos === false) return($response); $header = substr($response, 0, $pos); $body = substr($response, $pos + 2 * strlen($crlf)); // parse headers $headers = array(); $lines = explode($crlf, $header); foreach($lines as $line) if(($pos = strpos($line, ':')) !== false) $headers[strtolower(trim(substr($line, 0, $pos)))] = trim(substr($line, $pos+1)); // redirection? if(isset($headers['location'])){ $http = new HTTPRequest($headers['location']); return($http->DownloadToString($http)); } else{ return($body); } } else { return false; } } } ?> and I am calling it using this within vbulletins plugins ob_start(); include(DIR . '/twittercall.php'); $twitter = new myTwit(); $twitter->user = 'webprocafe'; $twitter->cacheFile = 'twitcache.txt'; $twitter->postLimit = 5; $twitter->initMyTwit(); print $twitter->myTwitData; $latest_twit = ob_get_contents(); ob_end_clean(); when it cant get the json file for any reason it displays but unfortunately its making the homepage blank with only that text when it is having issues getting the JSON.. I was wondering if anyone can work out how to make it switch off the plugin instead if it goes down, and then when it comes back up again to switch the plugin on or.. more preferred would be to make it so it does not make the homepage blank, and only display that message in the section that the feed is sitting in... - it should be under 'latest tweets' on our homepage - www.webprocafe.com ( yes I know its a web dev forum, but we are relatively new and seems no-one has vbulletin knowledge. ) thank you
×
×
  • 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.