PHP - Unable To Load Dynamic Library '/usr/lib64/php/modules/oci8.so'
hi all,
this is my setup
Apache/2.2.15 (Unix)
PHP 5.4.36 (cli) (built: Dec 19 2014 06:28:27)
CentOS release 6.6
i am having intermmittent issues whenever in install pdo_oci and oci8 for PHP following this procedure
http://shiki.me/blog...ntos-6-4-64bit/
this is the full error
[root@localhost ~]# php -v
PHP Warning: PHP Startup: Unable to load dynamic library '/usr/lib64/php/modules/oci8.so' - /usr/lib64/php/modules/oci8.so: undefined symbol: php_checkuid in Unknown on line 0 PHP Warning: PHP Startup: PDO_OCI: Unable to initialize module location of oci8 [root@localhost ~]# cd /usr/lib64/php/ [root@localhost php]# ll total 8 drwxr-xr-x. 2 root root 4096 Jan 6 20:16 build drwxr-xr-x. 2 root root 4096 Jan 6 20:16 modules [root@localhost php]# cd modules/ [root@localhost modules]# ll total 4052 -rwxr-xr-x. 1 root root 69304 Dec 19 13:32 curl.so -rwxr-xr-x. 1 root root 2708336 Dec 19 13:32 fileinfo.so -rwxr-xr-x. 1 root root 46152 Dec 19 13:32 gmp.so -rwxr-xr-x. 1 root root 41576 Dec 19 13:32 json.so -rwxr-xr-x. 1 root root 49288 Dec 19 13:32 mssql.so -rwxr-xr-x. 1 root root 482372 Jan 6 14:15 oci8.so<<<<<======== -rwxr-xr-x. 1 root root 20256 Dec 19 13:32 pdo_dblib.so -rwxr-xr-x. 1 root root 124216 Jan 6 13:32 pdo_oci.so -rwxr-xr-x. 1 root root 101784 Dec 19 13:32 pdo.so -rwxr-xr-x. 1 root root 25984 Dec 19 13:32 pdo_sqlite.so -rwxr-xr-x. 1 root root 265584 Dec 19 13:32 phar.so -rwxr-xr-x. 1 root root 45744 Dec 19 13:32 sqlite3.so -rwxr-xr-x. 1 root root 41008 Dec 19 13:32 sybase_ct.so -rwxr-xr-x. 1 root root 94808 Dec 19 13:32 zip.so [root@localhost modules]# [root@localhost modules]# cd /etc/php.d [root@localhost php.d]# ll total 56 -rw-r--r--. 1 root root 49 Dec 19 13:32 curl.ini -rw-r--r--. 1 root root 57 Dec 19 13:32 fileinfo.ini -rw-r--r--. 1 root root 47 Dec 19 13:32 gmp.ini -rw-r--r--. 1 root root 49 Dec 19 13:32 json.ini -rw-r--r--. 1 root root 51 Dec 19 13:32 mssql.ini -rw-r--r--. 1 root root 18 Jan 6 14:16 oci8.ini -rw-r--r--. 1 root root 59 Dec 19 13:32 pdo_dblib.ini -rw-r--r--. 1 root root 47 Dec 19 13:32 pdo.ini -rw-r--r--. 1 root root 22 Jan 6 13:59 pdo_oci.ini -rw-r--r--. 1 root root 61 Dec 19 13:32 pdo_sqlite.ini -rw-r--r--. 1 root root 49 Dec 19 13:32 phar.ini -rw-r--r--. 1 root root 55 Dec 19 13:32 sqlite3.ini -rw-r--r--. 1 root root 59 Dec 19 13:32 sybase_ct.ini -rw-r--r--. 1 root root 47 Dec 19 13:32 zip.ini [root@localhost php.d]# more oci8.ini extension=oci8.so but if i do this [root@localhost php.d]# rm -fr oci8.ini [root@localhost php.d]# ll total 52 -rw-r--r--. 1 root root 49 Dec 19 13:32 curl.ini -rw-r--r--. 1 root root 57 Dec 19 13:32 fileinfo.ini -rw-r--r--. 1 root root 47 Dec 19 13:32 gmp.ini -rw-r--r--. 1 root root 49 Dec 19 13:32 json.ini -rw-r--r--. 1 root root 51 Dec 19 13:32 mssql.ini -rw-r--r--. 1 root root 59 Dec 19 13:32 pdo_dblib.ini -rw-r--r--. 1 root root 47 Dec 19 13:32 pdo.ini -rw-r--r--. 1 root root 22 Jan 6 13:59 pdo_oci.ini -rw-r--r--. 1 root root 61 Dec 19 13:32 pdo_sqlite.ini -rw-r--r--. 1 root root 49 Dec 19 13:32 phar.ini -rw-r--r--. 1 root root 55 Dec 19 13:32 sqlite3.ini -rw-r--r--. 1 root root 59 Dec 19 13:32 sybase_ct.ini -rw-r--r--. 1 root root 47 Dec 19 13:32 zip.ini [root@localhost php.d]# php -v PHP Warning: PHP Startup: PDO_OCI: Unable to initialize module Module compiled with module API=20090626 PHP compiled with module API=20100525 These options need to match in Unknown on line 0 PHP 5.4.36 (cli) (built: Dec 19 2014 06:28:27) Copyright © 1997-2014 The PHP Group Zend Engine v2.4.0, Copyright © 1998-2014 Zend Technologies no errror on PHP Warning: PHP Startup: Unable to load dynamic library '/usr/lib64/php/modules/oci8.so' - /usr/lib64/php/modules/oci8.so: undefined symbol: php_checkuid in Unknown on line 0 [root@localhost php.d]# thanks in advance Edited by taliez, 06 January 2015 - 11:40 PM. Similar TutorialsI wonder whether someone may be able to help me please. I've put together the following script which saves user defined images to server folders using the Aurigma Image Uploader software. Code: [Select] <?php require_once 'Includes/gallery_helper.php'; require_once 'ImageUploaderPHP/UploadHandler.class.php'; $galleryPath = 'UploadedFiles/'; function onFileUploaded($uploadedFile) { global $galleryPath; $packageFields = $uploadedFile->getPackage()->getPackageFields(); $username=$packageFields["username"]; $locationid=$packageFields["locationid"]; $usernamefolder = preg_replace('/[^a-z0-9_\-\.()\[\]{}]/i', '_', $_POST['username']); $locationfolder = preg_replace('/[^a-z0-9_\-\.()\[\]{}]/i', '_', $_POST['locationid']); $dirName = preg_replace('/[^a-z0-9_\-\.()\[\]{}]/i', '_', $_POST['folder']); $absGalleryPath = realpath($galleryPath) . DIRECTORY_SEPARATOR . $usernamefolder . DIRECTORY_SEPARATOR . $locationfolder . DIRECTORY_SEPARATOR; $absThumbnailsPath = $absGalleryPath . 'Thumbnails' . DIRECTORY_SEPARATOR; if (!is_dir($absGalleryPath)) mkdir($absGalleryPath, 0777, true); chmod($absGalleryPath, 0777); if (!is_dir($absGalleryPath . $dirName)) mkdir($absGalleryPath . $dirName, 0777, true); chmod($absGalleryPath . $dirName, 0777); if ($uploadedFile->getPackage()->getPackageIndex() == 0 && $uploadedFile->getIndex() == 0) initGallery($absGalleryPath, $absThumbnailsPath, FALSE); $originalFileName = $uploadedFile->getSourceName(); $files = $uploadedFile->getConvertedFiles(); $sourceFileName = getSafeFileName($absGalleryPath, $originalFileName); $sourceFile = $files[0]; if ($sourceFile) $sourceFile->moveTo($absGalleryPath . $sourceFileName); $thumbnailFileName = getSafeFileName($absThumbnailsPath, $originalFileName); $thumbnailFile = $files[1]; if ($thumbnailFile) $thumbnailFile->moveTo($absThumbnailsPath . $thumbnailFileName); $descriptions = new DOMDocument('1.0', 'utf-8'); $descriptions->load($absGalleryPath . 'files.xml'); $xmlFile = $descriptions->createElement('file'); // <-- please check the following line $xmlFile->setAttribute('name', $_POST['folder'] . '/' . $originalFileName); $xmlFile->setAttribute('source', $sourceFileName); $xmlFile->setAttribute('size', $uploadedFile->getSourceSize()); $xmlFile->setAttribute('originalname', $originalFileName); $xmlFile->setAttribute('thumbnail', $thumbnailFileName); $xmlFile->setAttribute('description', $uploadedFile->getDescription()); $xmlFile->setAttribute('username', $username); $xmlFile->setAttribute('locationid', $locationid); $xmlFile->setAttribute('folder', $dirName); $descriptions->documentElement->appendChild($xmlFile); $descriptions->save($absGalleryPath . 'files.xml'); } $uh = new UploadHandler(); $uh->setFileUploadedCallback('onFileUploaded'); $uh->processRequest(); ?> This code saves the files in the following structu UploadedFiles (Pre-existing folder) 'username' (Subfolder created dynamically on image upload if it doesn't already exist. This folder contains the 'location' folder) 'location' (Subfolder created dynamically on image upload if it doesn't already exist. This contains original image, 'files.xml' and 'Thumbnails' folder) 'Thumbnails' (Subfolder created dynamically on image upload if it doesn't already exist. This contains thumbnail of original image) I'm now trying to put together a script which creates an image gallery, with those images pertinent to the current user and location. The code below is the piece of my script which deals with the loading of the images. Code: [Select] <?php $galleryPath = 'UploadedFiles/'; $thumbnailsPath = $galleryPath . 'Thumbnails/'; $absGalleryPath = realpath($galleryPath) . DIRECTORY_SEPARATOR; $descriptions = new DOMDocument('1.0'); $descriptions->load($absGalleryPath . 'files.xml'); ?> The initial problem I had, was resolved from guidance I received on this site, and that was to find the correct 'realpath' of the 'Thumbnails' folder and 'files.xml' These are as follows: Quote /homepages/2/d333603417/htdocs/development/UploadedFiles/IRHM73/1 and Quote /homepages/2/d333603417/htdocs/development/UploadedFiles/IRHM73/1/Thumbnails with 'IRHM73' being the 'username' value and '1' the 'location' value. The problem I now have lies within this line of code: `$absGalleryPath = realpath($galleryPath) . DIRECTORY_SEPARATOR;` Because the 'username' and 'location' are dynamic and hence contain different values for each user and location, I've found it impossible to find a way of creating the correct file path to open the 'Thumbnails' folder and 'files.xml'. I had tried this: Code: [Select] <?php $galleryPath = 'UploadedFiles/'; $absGalleryPath = realpath($galleryPath) . DIRECTORY_SEPARATOR . $usernamefolder . DIRECTORY_SEPARATOR . $locationfolder . DIRECTORY_SEPARATOR; $absThumbnailsPath = $absGalleryPath . 'Thumbnails' . DIRECTORY_SEPARATOR; $descriptions = new DOMDocument('1.0'); $descriptions->load($absGalleryPath . 'files.xml'); ?> But I receive the following error: DOMDocument::load() domdocument.load: I/O warning : failed to load external entity /homepages/2/d333603417/htdocs/development/UploadedFiles/'files.xml'; in /homepages/2/d333603417/htdocs/development/gallery.php on line 13 and line 13 is this: Code: [Select] $descriptions->load($absGalleryPath . 'files.xml'); I really am stumped with what to do next to get this to work. I appreciate that this is a fairly lengthy post, but thought it would be better to post all the information. I just wondered whether someone could perhaps take a look at this and let me know where I'm going wrong and how I can get it to work. Many thanks and regards I want to get the ibase_blob_echo function and I was told I need to uncomment the extension=php_interbase.dll in my php.ini. So I did and now I get the message: Unable to Load Dynamic Library in a pop-up window. I'm lost and don't know how to solve this Hi, I've a simple code which uses a class from here. When I execute it, I get this error QuoteFatal error: Uncaught Error: Class 'phpMQTT' not found in C:\Apache24\htdocs\mqtt\test.php:10 Stack trace: #0 {main} thrown in C:\Apache24\htdocs\mqtt\test.php on line 10 and I cannot understand why my code doesn't see the class. Both files, the class.php and test.php, are in the same folder. Any help is appreciated.
TIA <?php require("phpMQTT.php"); $server = "192.168.0.250"; // change if necessary $port = 1883; // change if necessary $username = ""; // set your username $password = ""; // set your password $client_id = "phpMQTT-publisher"; // make sure this is unique for connecting to sever - you could use uniqid() $mqtt = new phpMQTT($server, $port, $client_id); if ($mqtt->connect(true, NULL, $username, $password)) { echo 'hereeeee'; $mqtt->publish("room/lamp", "on" . date("r"), 0); $mqtt->close(); } else { echo "Time out!\n"; } ?>
I wonder whether someone may be able to help me please. I'm trying to put together a PHP within Aurigma Image Uploader which will create an image gallery. To do this I need to extract the image from a folder called 'Thumbnails' and image data from a file called 'files.xml'. The code below is an extract of the default script that performs this functionality and I've tested and it works without any issues. Code: [Select] <?php //This variable specifies relative path to the folder, where the gallery with uploaded files is located. //Do not forget about the slash in the end of the folder name. $galleryPath = 'UploadedFiles/'; $thumbnailsPath = $galleryPath . 'Thumbnails/'; $absGalleryPath = realpath($galleryPath) . DIRECTORY_SEPARATOR; $descriptions = new DOMDocument('1.0'); $descriptions->load($absGalleryPath . 'files.xml'); ?> I have now changed my folder and file structure to the following: UploadedFiles (Folder) username (Subfolder containing the 'location' folder) location (Subfolder containing 'Thumbnails folder and image, and 'files.xml') Please note that both the 'username' and 'location' folders are dynamically created when the user initially uploads the images. To try and accomodate the new file structure I changed my code to: Code: [Select] <?php //This variable specifies relative path to the folder, where the gallery with uploaded files is located. //Do not forget about the slash in the end of the folder name. $galleryPath = 'UploadedFiles/'; $absGalleryPath = realpath($galleryPath) . DIRECTORY_SEPARATOR . $usernamefolder . DIRECTORY_SEPARATOR . $locationfolder . DIRECTORY_SEPARATOR; $thumbnailsPath = $galleryPath . 'Thumbnails/'; $descriptions = new DOMDocument('1.0'); $descriptions->load($absGalleryPath . 'files.xml'); ?> But when I run this I receive the following error: Quote d333603417/htdocs/development/UploadedFiles/files.xml" in /homepages/2/d333603417/htdocs/development/gallery.php on line 14 Line 14 is this line: Code: [Select] $descriptions->load($absGalleryPath . 'files.xml'); I've been working on this for days and I just can't seem to find the answer. I just wondered whether someone could possibly look at this and let me know where I'm going wrong. If it helps, I've added the upload script below. Code: [Select] <?php require_once 'Includes/gallery_helper.php'; require_once 'ImageUploaderPHP/UploadHandler.class.php'; $galleryPath = 'UploadedFiles/'; function onFileUploaded($uploadedFile) { global $galleryPath; $packageFields = $uploadedFile->getPackage()->getPackageFields(); $username=$packageFields["username"]; $locationid=$packageFields["locationid"]; $username = preg_replace('/[^a-z0-9_\-\.()\[\]{}]/i', '_', $_POST['username']); $location = preg_replace('/[^a-z0-9_\-\.()\[\]{}]/i', '_', $_POST['locationid']); $dirName = preg_replace('/[^a-z0-9_\-\.()\[\]{}]/i', '_', $_POST['folder']); $absGalleryPath = realpath($galleryPath) . DIRECTORY_SEPARATOR . $username . DIRECTORY_SEPARATOR . $location . DIRECTORY_SEPARATOR; $absThumbnailsPath = $absGalleryPath . 'Thumbnails' . DIRECTORY_SEPARATOR; if (!is_dir($absGalleryPath)) mkdir($absGalleryPath, 0777, true); chmod($absGalleryPath, 0777); if (!is_dir($absGalleryPath . $dirName)) mkdir($absGalleryPath . $dirName, 0777, true); chmod($absGalleryPath . $dirName, 0777); if ($uploadedFile->getPackage()->getPackageIndex() == 0 && $uploadedFile->getIndex() == 0) initGallery($absGalleryPath, $absThumbnailsPath, FALSE); $originalFileName = $uploadedFile->getSourceName(); $files = $uploadedFile->getConvertedFiles(); $sourceFileName = getSafeFileName($absGalleryPath, $originalFileName); $sourceFile = $files[0]; if ($sourceFile) $sourceFile->moveTo($absGalleryPath . $sourceFileName); $thumbnailFileName = getSafeFileName($absThumbnailsPath, $originalFileName); $thumbnailFile = $files[1]; if ($thumbnailFile) $thumbnailFile->moveTo($absThumbnailsPath . $thumbnailFileName); $descriptions = new DOMDocument('1.0', 'utf-8'); $descriptions->load($absGalleryPath . 'files.xml'); $xmlFile = $descriptions->createElement('file'); // <-- please check the following line $xmlFile->setAttribute('name', $_POST['folder'] . '/' . $originalFileName); $xmlFile->setAttribute('source', $sourceFileName); $xmlFile->setAttribute('size', $uploadedFile->getSourceSize()); $xmlFile->setAttribute('originalname', $originalFileName); $xmlFile->setAttribute('thumbnail', $thumbnailFileName); $xmlFile->setAttribute('description', $uploadedFile->getDescription()); $xmlFile->setAttribute('username', $username); $xmlFile->setAttribute('locationid', $locationid); $xmlFile->setAttribute('folder', $dirName); $descriptions->documentElement->appendChild($xmlFile); $descriptions->save($absGalleryPath . 'files.xml'); } $uh = new UploadHandler(); $uh->setFileUploadedCallback('onFileUploaded'); $uh->processRequest(); ?> Many thanks Hello. If someone can help me, i'll be grateful So i have a foreach and an $output .= function that fills some infos in a table. Inside it i have a div for each line that when hovering your mouse should get some data .. Here i have a big problem, because for each line it should get some data and i don't know how to do it ... i'll post here some of my code for better understanding. Quote //some java here <?php require "class.php"; $server_list = query_group(); $misc = server_misc($server); foreach ($server_list as $server) { $misc = server_misc($server); $server = server_html($server); $idi = "{$server['o']['id']}"; $harta = "<a onmouseover=\"ShowContent('harta'); return true;\" onmouseout=\"HideContent('harta'); return true;\" href='".link($server['o']['id'])."' target=\"_self\">{$server['s']['map']}</a> <div style=\"position:absolute;\" id=\"harta\" class=\"FAQ\">file_get_contents('http://mysite/player.php?d={$idi}')</div> "; $output .= " <table> ........... some code..... <td> {$harta} </td> ....... so basicly when i hover my mouse over each row it should get data from the file for that id... The problem is that only one page can be loaded with file_get_contents. I read over the internet that some ajax functions can do it but i really don't know how. Please help me, i've been looking for 3 days already without any luck Ok, so I have some basic jquery allowing me to refresh and "hopefully" track _SESSION changes. I am running into a issue where only basic PHP functions and variables can be used inside. jQuery Code Loading PHP page Code: [Select] <script type="text/javascript"> var auto_refresh = setInterval( function () { $('#load_options').load('session_options.php'); }, 5000); // refresh every 10000 milliseconds </script> <div id="load_options" style="position:fixed; z-index:100; margin-left:700px; width:200px; padding:10px; background-color:#fff;"> <?php require("session_options.php"); ?> </div> session_options.php <p><?php echo $myNow = date("g:i:s A"); ?></p> <div class="cartinfo"> <h1><b><?php echo $_SESSION['dep_city']; ?>⇒<br /><?php echo $_SESSION['arr_city']; ?></b></h1> <p>Date: <b><?php echo $_SESSION['dep_date']; ?></b></p> <p>Passengers: <b><?php echo $_SESSION['passengers']; ?></b></p> <p>Cost: $<b><?php echo $_SESSION['total']; ?></b></p> <br /> ...blah blah blah What I end up seeing is the Time (WHICH DOES REFRESH PROPERLY) & the static text. HOWEVER, right before the 1st refresh takes place all the variables WORK.... but as soon as that refresh hits... poof "black hole of death". If i include the file with PHP it all works perfectly, but then it won't refresh and update . Hi All,
Am hoping someone can point out my perhaps obvious issue here.
I've a series of links that are dynamically created:
<a class="team-link" rel="<?php the_ID(); ?>" href="#">When a link is clicked, I'm trying to get content to load into this DIV: <div id="single-post-container"></div>I have the following jquery: <script> $(document).ready(function(){ $.ajaxSetup({cache:false}); $(".team-link").click(function(){ var post_id = $(this).attr("rel"); $.ajax({ url : "http://www.domain.co.uk/wp-content/themes/name/loop.php", data : {"the_team": post_id }, type : "POST", dataType : "html", success: function(response) { $("#single-post-container").html(response); } return false; }); }); </script>This is my loop.php file: require_once('../../../wp-load.php'); // Our variables $the_team = (isset($_GET['post_id'])) ? $_GET['post_id'] : 0; echo $the_team; query_posts(array( 'post_type' => 'work', 'meta_key' => 'author_name', 'meta_value' => $the_team )); // our loop if (have_posts()) { while (have_posts()){ the_post(); ?> <h1><?php the_title(); ?></h1> <?php the_content(); ?> <hr /> <?php } } wp_reset_query();However, when you click the link, nothing happens. I know loop.php works as I can specify a value and manually browse to it to see the content. I feel I'm missing something obvious as I'm new to AJAX. Your help/patience is very much appreciated hi gang, I just spent the better part of the day trying to find a way modularize my PHP code. I want to execute a php file and load the results into my main php program. I am not looking to include php source code into my prog and then execute it, I want to execute it and load the results into my prog. I know I can do this if I call a php file via apache: using file(http://ww.site.com/blah.php?parms) but is there a way to do it without using http ? The php file is local - in the same directory. I want something like this: $r = something.php?parms... how do I do this? regards, david This topic has been moved to Application Design. http://www.phpfreaks.com/forums/index.php?topic=332538.0 I'm having a problem and need an answer to why its happening and how to prevent it. Scenario: I begin load my home page which starts with a session_start(); .... Before it FULLY completes loading I try to navigate to another page and BOOM, that page will not load and any other page that begins with session_start(); will not load unless I close and restart the entire browser or wait about 10 minutes.... I will note my website makes ajax calls every 5 seconds or so, but I use setTimeout for them. Any help??? Thanks ahead! Hi, how i could do this with gdlibrary: I make image with imagecreatefrompng , and that is my pictures background. Then I add image there, and that is my bird flying in the background. that is only example, i wanna just add image to image What do I need to do in order to use the libssh2 library? Hi, I would like my users to create and save forms via mysql. They should be able to choose what field they want to use, and other users should be able to fill the forms into mysql. Any ideas on how to accomplish this? I'm trying to write a script that will copy images from one website (a supplier, in this case puma) and save them to the dealer's web server. I have already done this for other supplier's websites but puma uses png's instead of jpeg's and I believe that is what is causing my issues: The original image looks like this: The copied image some odd colors in the background like this: Here is the code: Code: [Select] $puma_image = "http://www.pumab2b.com/_static/images/styleColors/1234560002/" . str_replace(" ", "", $Item_Num) . "_1.png"; $image = imagecreatefrompng($puma_image); if ($image) { //Save image to Soccer Etc server (images folder): if (imagepng($image, "prod_images/" . $cur_Item['Item_Num'] . ".png", 0)) { //DO some other stuff here } } I just noticed after posting the original image on this forum, that it is actually transparent. I'm guessing this has something to do with my problems? Hi everyone. There are two nice script which are advanced for me to understand. There is a Knockout tournament scheduler class that makes image of the bracket. and there is a code that makes html of the bracket with jquery. I want to use the class with jquery. but I don't know how to do that and where to start. the class below needs to implement to this http://whileonefork.blogspot.com/2010/10/jquery-json-to-draw-elimination-single.html I attached the php script. please help me! Code: [Select] <?php class KnockoutGD extends Knockout { private $im = null; // GD-lib image resource. private $tc = 0; // Text color. public function getImage($tourName = '') { /* Returns a GD-lib image resource */ // Initial testing. if (empty($this->roundsInfo)) return null; // Dimensional parameters. $fh = imagefontheight(FONT); $fw = imagefontwidth(FONT); $lpad = 30; // Line (branch) padding before and after competitor names and after scores. $hpad = 20; // Outer horizontal image padding. $vpad = 60; // Outer vertical image padding. $lw = $this->getStrLen()*$fw + 3*$lpad; // Line (branch) width. Where getStrLen() gets the length of the longest string used in the image. // Initial calls. $dimensions = $this->getDimens($fh, $lw, $hpad, $vpad); $this->im = imagecreate($dimensions['x'], $dimensions['y']); $bg = imagecolorallocate($this->im, 255, 255, 255); // Set background color. $this->tc = imagecolorallocate($this->im, 0, 0, 0); // Text color. $this->mkStr($dimensions['x'] - $hpad - imagefontwidth(LFONT)*strlen($tourName), $dimensions['y'] - $vpad/2, $tourName, LFONT); // Print tournament name. // Initial positioning values from which drawing begins. $rx = $hpad; // Round X-position. $ry = $vpad; // Round Y-position. $depth = 1; // Branch depth. // Start drawing the tournament bracket/tree. foreach ($this->roundsInfo as $r => $info) { $n = $info[1]; // Number of expected players in round $r. // If a match is no yet created, then a placeholder is made so that the bracket structure is still printable. for ($m = 0; $m <= $n/2 - 1; $m++) { if (!$this->isMatchCreated($m, $r)) { $this->bracket[$r][$m]['c1'] = $this->bracket[$r][$m]['c2'] = null; $this->bracket[$r][$m]['s1'] = $this->bracket[$r][$m]['s2'] = -1; } } // Now we generate round branches. $x = $rx; $y = $ry; $bheight = pow(2, $depth) * $fh; // This is the height of a match-branch, which increases as the tree depth increases. ksort($this->bracket[$r]); foreach ($this->bracket[$r] as $m) { for ($i = 1; $i <= 2; $i++, $y += $bheight) { $this->mkStr($x+$lpad, $y, $m['s'.$i] == -1 ? 'Undecided' : $m['c'.$i]); $this->mkStr($x+$lw-$lpad, $y, $m['s'.$i] == -1 ? '?' : $m['s'.$i]); $this->mkLine($x, $y+$fh, $x+$lw, $y+$fh); } $this->mkLine($x+$lw, ($y+$fh)-$bheight, $x+$lw, ($y+$fh)-2*$bheight); } // Get ready for next loop. $rx += $lw; $ry += $bheight/2; $depth++; } // Add final branch/line for the tournament winner $fr = end(array_keys($this->roundsInfo)); // Final round. $s1 = $this->bracket[$fr][0]['s1']; $s2 = $this->bracket[$fr][0]['s2']; $winner = (!array_key_exists(0, $this->bracket[$fr]) || $s1 == -1 || $s2 == -1 || $s1 === $s2) ? '?' : (($s1 > $s2) ? $this->bracket[$fr][0]['c1'] : $this->bracket[$fr][0]['c2']); $this->mkStr($rx+$lpad, $ry, 'Winner: ' . $winner); $this->mkLine($rx, $ry+$fh, $rx+$lw, $ry+$fh); // Now, we print the round titles. array_push($this->roundsInfo, array('Champion', 1)); // Add fictitious round for printing purposes only. foreach (array_reverse($this->roundsInfo) as $r) { $this->mkStr($rx+$lpad, $vpad/3, $r[0], LFONT); $rx -= $lw; // Move back one round/column. } array_pop($this->roundsInfo); // Remove fictitious round entry again. return $this->im; } private function mkLine($x0, $y0, $x, $y) { /* Wrapper for function that creates a line. */ imageline($this->im, $x0, $y0, $x, $y, $this->tc); } private function mkStr($x, $y, $str, $font = false) { /* Wrapper for function that writes a string. */ imagestring($this->im, $font ? $font : FONT, $x, $y, $str, $this->tc); } private function getDimens($fontHeight, $lineWidth, $horizPad, $vertPad) { /* Returns image dimensions based on the tournament bracket. */ /* Vertically: Each match-branch is outputted like this: Team A ----------- Padding Team B ----------- Padding ... where "Padding" and "Team X" are of height $fontHeight, and "------" are branch lines with approximately no height. Horizontally: Each branch is outputted like this: ----- Team A ------ | ----- Team C ------ | ----- Team B ------ ... where "Team X" branch has an absolute length of $lineWidth. The above therefore illustrates a length of 2*$lineWidth. The image length, $x, must be: $horizPad + number_of_rounds * $lineWidth + $horizPad And the image height, $y, must be: $vertPad + number_of_matches_in_first_round * 4*$fontHeight + $vertPad ... since the first round contains the most matches. */ $frGames = count($this->bracket[1]); // Number of games in the first round. $playInExists = !empty($this->bracket[0]) ? true : false; /* The y-size of the image must be calculated accordingly to the above description. Though, if a play-in round exists, then the play-in round is potentially the round which requires the most vertical space to draw. In this case we scale the image as if the play-in round was the first round. Due to the nature of the tournament bracket, this means that there are twice as many games in that round. */ $y = 2*$vertPad + ($playInExists ? $frGames*2 : $frGames) * 4*$fontHeight; /* The x-size of the image is proportional to the number of rounds in the tournament, where the proportionality constant is the length of a branch, $lineWidth, ie. the width of a round. Since the number of players in the first round is equal to 2^R, where R is a whole number, and denotes the number of rounds required in the tournament, then R = log(players, 2), where "players" also can be found by 2 * matches_in_first_round (2 players pr. match). Like above, if a play-in round exists the x-size of the image must be changed. In this case, we merely add the length of a branch to the total x-size, since all branches are equal in length. Besides that, we add another whole branch length for the Winner/Champion branch, which technically is not a part of the tournament bracket, but is shown anyway. */ $x = 2*$horizPad + (log($frGames*2, 2) + ($playInExists ? 1 : 0) + 1) * $lineWidth; return array('x' => $x, 'y' => $y); } private function getStrLen() { /* Returns the length of longest string used in either rounds. This is done by looking in both play-in round and first round, since all competitors are to be found there. */ $len = 0; foreach (array_merge(array_key_exists(0, $this->bracket) ? $this->bracket[0] : array(), $this->bracket[1]) as $m) { if (($newlen = strlen($m['c1'])) > $len) $len = $newlen; if (($newlen = strlen($m['c2'])) > $len) $len = $newlen; } foreach ($this->roundsInfo as $arr) { if (($newlen = strlen($arr[0])) > $len) $len = $newlen; } return $len; } } ?> Suppose you have a ENORMOUS library class where you have collected - perhaps - validation functions. Suppose you also have a small php script that you wish to use one of these validation functions in. So, you include the class. Is there a lot of "overhead" involved in including a huge class of which you use only one function? Hello everyone, What is the best way to take HTML formatted text and overlay it on a image (presumably using php's GD functions)? Unfortunately, HTML tags are ignored and any kind of code is treated as plaintext by imagefttext(). However, I need this HTML DIV box pasted onto an image and I intend to get it done. To make things slightly worst, this is a dynamic, PHP generated DIV box. I had an idea of utilizing some kind of buffering to generate my DIV box, convert that DIV box to an image and finally paste it onto my image using the GD library. If that sounds like a reasonable idea, can someone please help me get started? Thanks in advance, guys!
How to implement the library
here's my code <?php include("../incs/config.php"); $result = mysqli_query($link, "SELECT * FROM press ORDER BY press_date DESC"); $result2 = mysqli_query($link, "SELECT * FROM event ORDER BY event_date DESC"); $result3 = mysqli_query($link, "SELECT * FROM galleries ORDER BY gallery_id DESC"); if (!isset($_COOKIE['user'])) { die("Identifiant invalide"); } ?> <!DOCTYPE html><html> <head><meta charset='UTF-8'> <meta name="robots" content="noindex"> </head> <html> <head> <link rel="stylesheet" href="../css/bootstrap.min.css"> <link rel="stylesheet" href="../css/jquery-ui.css"> <link href="../stylesheets/style.css" rel="stylesheet"> <link href="stylesheets/style.css" rel="stylesheet"> <script src="../js/jquery-migrate.min.js"></script> <script src="../js/jquery.min.js"></script> <script src="../js/jquery.ui.js"></script> <script src="../js/bootstrap.min.js"></script> <script src="../js/tinymce/js/tinymce/tinymce.min.js"></script> </head> <body> <!-- header --> <header> <!-- nav --> <nav class="navbar navbar-default"> <div class="container"> <div class="navbar-header"> <a class="navbar-brand" href="../index.php"><img src="../images/logo.png" alt="Louise Groux"></a> </div><!-- / navbar-header --> <div> <ul class="nav nav-pills navbar-nav" style="font-weight:bold; padding-left:25px;"> <li class="active"><a href="#presse-2" data-toggle="pill"><i class="fa fa-home"></i> Presse </a></li> <li><a href="#evenements-2" data-toggle="pill"><i class="fa fa-comments"></i> Événements </a></li> <li><a href="#galerie-2" data-toggle="pill"><i class="fa fa-cloud"></i> Galerie</a></li> </ul> </div><!--/ nav-collapse --> </div><!-- / container --> </nav> <!-- / nav --> </header> <!-- / header --> <!--<div class="container-fluid"> <div class="row"> <a class="navbar-brand" href="../index.php"><img src="../images/logo.png" alt="logo" width="50" height="50"></a> </div> </div> --> <div class="container content-sm"> <!-- Tab v3 --> <div class="row tab-v3"> <div class="col-sm-9"> <div class="tab-content"> <div class="tab-pane fade in active" id="presse-2"> <div class="container col-md-12""> <h1>Presse</h1> <div style="text-align:center;margin:40px;">Veuillez utiliser la page pour mettre à jour, ajouter et supprimer des articles de presse. Faites glisser pour changer l'ordre et n'oubliez pas de sauvegarder une fois terminé !</div> <ul class="list-unstyled"> <li class="panel panel-info"> <div class="panel-heading"> <h5></h5> </div> <div class="panel-body"> <form action="presse/add.php" method="post" name="form1" enctype="multipart/form-data"> <div class="form-horizontal"> <div class="form-group"> <label class="control-label col-sm-2" for="title">Tit </label> <div class="col-sm-10"> <input type="text" class="form-control" name='title' id="title" > </div> </div> </div> <div class="form-horizontal"> <div class="form-group"> <label class="control-label col-sm-2" for="sub_title">Sous-tit </label> <div class="col-sm-10"> <input type="text" class="form-control" name='sub_title' id="sub_title"> </div> </div> </div> <div class="form-horizontal"> <div class="form-group"> <label class="control-label col-sm-2" for="press_date">Date (invisible, pour l'ordre de la liste):</label> <div class="col-sm-10"> <input type="text" class="form-control datepicker" name='press_date' id="press_date"> </div> </div> </div> <div class="form-horizontal"> <div class="form-group"> <label class="control-label col-sm-2" for="type">Gen </label> <div class="col-sm-10"> <input type="text" class="form-control" name='type' id="type" > </div> </div> </div> <div class="form-horizontal"> <div class="form-group"> <label class="control-label col-sm-2" for="type">Lien:</label> <div class="col-sm-10"> <input type="text" class="form-control" name='link' id="link"> </div> </div> </div> <div class="form-horizontal"> <div class="form-group"> <label class="control-label col-sm-2" for="type">Image (150px x 150px): </label> <div class="col-sm-10"> <input class="input-group" type="file" name="image"/> </div> </div> </div> <input type="submit" name="Submit" class="btn btn-louisegroux pull-right" value="Ajouter"></button> </form> </div> </li> </ul> <?php if ($result->num_rows > 0) { //<button class="save btn btn-louisegroux">Sauvegarder l'ordre des éléments</button> } ?> <div id="accordion-resizer" class="ui-widget-content"> <div id="accordion"> <ul id="draggablePanelList" class="sortable press_sort list-unstyled"> <?php while ($res = mysqli_fetch_array($result)) { $title = $res['title']; $sub_title = $res['sub_title']; $press_date = $res['press_date']; $type = $res['type']; $news_link = $res['link']; $image = $res['image']; $id = $res['id']; $title = stripslashes($title); $sub_title = stripslashes($sub_title); ?> <li name='item' id='item-<?php echo "$id"; ?>' class="panel panel-info""> <div class="panel-heading"> <h3 class="panel-title pull-left"> <?php echo "$title"; ?><span>, </span><?php echo "$sub_title"; ?> </h3> <a href="presse/delete.php?id=<?php echo "$id"; ?>"; ><button class="btn btn-danger clickable pointer pull-right" data-effect="remove"><span class="glyphicon glyphicon-remove"></span></button></a> <div class="clearfix"></div> </div> <div class="panel-body"> <form name="form1" action=presse/edit.php?id="<?php echo "$id"; ?>" method="post" enctype="multipart/form-data"> <div class="col-md-3"> <div class="form-group"> <?php if ($image != "") { ?> <img src="../images/presse/<?php echo "$image"; ?>" class="img-responsive" style="max-height:150px; max-width:150px;"> <?php } ?> <div class="clearfix"></div> <input class="input-group" type="file" name="image"/> </div> </div> <div class="col-md-9"> <div class="form-horizontal"> <div class="form-group"> <label class="control-label col-sm-2" for="title">Tit </label> <div class="col-sm-10"> <input type="text" class="form-control" name='title' id="title" value="<?php echo "$title"; ?>"> </div> </div> </div> <div class="form-horizontal"> <div class="form-group"> <label class="control-label col-sm-2" for="title">Sous-tit </label> <div class="col-sm-10"> <input type="text" class="form-control" name='sub_title' id="sTitle" value="<?php echo "$sub_title"; ?>"> </div> </div> </div> <div class="form-horizontal"> <div class="form-group"> <label class="control-label col-sm-2" for="press_date">Date (invisible, pour l'ordre de la liste):</label> <div class="col-sm-10"> <input type="text" name="press_date" value="<?php echo "$press_date"; ?>"> </div> </div> </div> <div class="form-horizontal"> <div class="form-group"> <label class="control-label col-sm-2" for="type">Gen </label> <div class="col-sm-10"> <input type="text" class="form-control" name='type' id="type" value="<?php echo "$type"; ?>"> </div> </div> </div> <div class="form-horizontal"> <div class="form-group"> <label class="control-label col-sm-2" for="type">Lien:</label> <div class="col-sm-10"> <input type="text" class="form-control" name='link' id="link" value="<?php echo "$news_link"; ?>"> </div> </div> </div> </div> <input type="hidden" name="id" value="<?php echo "$id"; ?>"> <input type="hidden" name="old_image" value="<?php echo "$image"; ?>"> <button type="submit" name="update" class="btn btn-louisegroux pull-right">Mettre à jour</button> </form> </div> </li> <?php } ?> Edited October 16, 2019 by samplephp GD Library Pattern Background ? Hi all I have a simple page here that uses the GD Library to display text in a selected font and size etc. http://www.ttmt.org.uk/forum/ At moment the stripped background goes from the code. Is there a way to have an image as the background instead of the stripped background. PHP code Code: [Select] <?php header('Content-Type: image/png'); $im = imagecreatetruecolor(900, 215); $w = imagecolorallocate($im, 255, 255, 255); $c = imagecolorallocate($im, 220, 220, 220); $black = imagecolorallocatealpha($im, 0, 0, 0, 20); $style = array($w,$w,$w,$c,$c,$c); ImageSetStyle($im, $style); ImageLine($image, 100, 0, 50, 50, IMG_COLOR_STYLED); imagefilledrectangle($im, 0, 0, 900, 214, IMG_COLOR_STYLED); $text = $_GET['text']; $textSize = $_GET['size']; $font = $_GET['font']; imagefttext($im, $textSize, 0, 15, 165, $black, $font, $text); imagepng($im); imagedestroy($im); ?> hi, i'm using the fpdf library to generate PDF's from form input. It all worked well on my local host, but now that i have transferred to a web server it displays the following error when trying to generate a PDF. Warning: require(/fpdf16/fpdf.php) [function.require]: failed to open stream: No such file or directory in /home/ddgq0o2n/public_html/quote_builder/pdf.php on line 2 Fatal error: require() [function.require]: Failed opening required '/fpdf16/fpdf.php' (include_path='.:/usr/lib/php:/usr/local/lib/php') in /home/ddgq0o2n/public_html/quote_builder/pdf.php on line 2 i have searched for "include_path", but can't find it anywhere. i'm thinking it's a server problem, where the library may not be compatible or something needs to be switched on, as it worked fine on my local host. any help and suggestions welcome thanks. |