Search Results

Search found 410 results on 17 pages for 'explode'.

Page 11/17 | < Previous Page | 7 8 9 10 11 12 13 14 15 16 17  | Next Page >

  • Hibernate ScrollableResults Do Not Return The Whole Set of Results

    - by mlaverd
    Some of the queries we run have 100'000+ results and it takes forever to load them and then send them to the client. So I'm using ScrollableResults to have a paged results feature. But we're topping at roughly 50k results (never exactly the same amount of results). I'm on an Oracle9i database, using the Oracle 10 drivers and Hibernate is configured to use the Oracle9 dialect. I tried with the latest JDBC driver (ojdbc6.jar) and the problem was reproduced. We also followed some advice and added an ordering clause, but the problem was reproduced. Here is a code snippet that illustrates what we do: Criteria crit = sess.createCriteria(ABC.class); crit.add(Restrictions.eq("property", value)); crit.setFetchSize(pageSize); crit.addOrder(Order.asc("property")); ScrollableResults sr = crit.scroll(); ... ... do{ for (Object entry : page) sess.evict(entry); //to avoid having our memory just explode out of proportion page.clear(); for (int i =0 ; i < pageSize && ! metLastRow; i++){ if (resultSet.next()) page.add(sr.get(0)); else metLastRow = true; } metLastRow = metLastRow?metLastRow:sr.isLast(); sendToClient(page); }while(!metLastRow); So, why is it that I get the result set to tell me its at the end when it should be having so much more results?

    Read the article

  • Script working with mysql and php into a textarea and back

    - by Tribalcomm
    I am trying to write a custom script that will keep a list of strings in a textarea. Each line of the textarea will be a row from a table. The problem I have is how to work the script to allow for adding, updating, or deleting rows based on a submit. So, for instance, I currently have 3 rows in the database: john sue mark I want to be able to delete sue and add richard and it will delete the row with sue and insert a row for richard. My code so far is as follows: To query the db and list it in the textarea: $basearray = mysql_query("SELECT name FROM mytable ORDER BY name"); <textarea name="names" cols=6 rows=12>'); <?php foreach($basearray as $base){ echo $base->name."\n"; } ?> </textarea> After the submit, I have: <?php $namelist = $_REQUEST[names]; $newarray = explode("\n", $namelist); foreach($newarray as $name) { if (!in_array($name, $basearray)) { mysql_query(DELETE FROM mytable WHERE word='$name'"); } elseif (in_array($name, $basearray)) { ; } else { mysql_query("INSERT INTO mytable (name) VALUES ("$name")"); } } ?> Please tell me what I am doing wrong. I am not getting any functions to work when I edit the contents of the textarea. Thanks!

    Read the article

  • Reading a CSV with file_get_contents in PHP

    - by JPro
    I am reading a 'kind' of csv file and exploding it and storing it in array. The file I am reading has this structure Id,Log,Res,File mydb('Test1','log1','Pass','lo1.txt'). mydb('Test2','log2','Pass','lo2.txt'). mydb('Test3','log3','Pass','lo3.txt'). Now what I am trying to do is : reading the last record in my database, get the Name, lets say in this case 'Test1' and then I am searching through my file and where I can find the position of 'Test1' and get the next lines in the file, extract the ID,s and add it to database. I am getting the position of desired string in the file, but I am not sure how to get the next lines too. Here's my code so far. <?php mysql_connect("localhost", "root", "") or die(mysql_error()); mysql_select_db("testing") or die(mysql_error()); $result = mysql_query("select ID from table_1 order by S_no DESC limit 1") or die(mysql_error()); $row = mysql_fetch_array( $result ); $a = $row['ID']; echo 'Present Top Row is '.$a.'<br>'; $addresses = explode("\n", file_get_contents('\\\\fil1\\logs\\tes.pl')); foreach($addresses as $val) { $pos = strstr($val, $a); if ($pos === false) { } else { echo "The string <br> '$a' <br>was found in the string <br>'$val' <br>"; echo " and exists at position <br>$pos<br>"; } }

    Read the article

  • Help converting PHP eregi to preg_match

    - by Jason
    Hi all, I am wondering if someone could please help me convert a piece of PHP code that is now deprecated. Here is the single line I am trying to convert: if(eregi(trim ($request_url_handler[$x]),$this->sys_request_url) && $this->id_found == 0){ It is part of a function that return the configuration settings for a website. Below is the whole function. // GET CORRECT CONFIG FROM DATABASE function get_config($db) { global $tbl_prefix; $db->query("SELECT cid,urls FROM ".$tbl_prefix."sys_config ORDER BY cid"); while($db->next_record()){ $request_url_handler = explode("\n",$db->f("urls")); if(empty($request_url_handler[0])) { $request_url_handler[0] = "@"; $this->id_found = 2; } for($x=0; $x<count($request_url_handler); $x++) { if(empty($request_url_handler[$x])) { $request_url_handler[$x] = "@"; } if(eregi(trim($request_url_handler[$x]),$this->sys_request_url) && $this->id_found == 0) { $this->set_config($db,$db->f("cid")); $this->id_found = 1; } } if($this->id_found == 1) { return($this->sys_config_vars); } } $this->set_config($db,""); return($this->sys_config_vars); } Any help would be great ly appreciated. I only found the the eregi function was deprecated since I updated XAMPP to 1.7.3.

    Read the article

  • Get current PHP executable from within script?

    - by benizi
    I want to run a PHP cli program from within PHP cli. On some machines where this will run, both php4 and php5 are installed. If I run the outer program as php5 outer.php I want the inner script to be run with the same php version. In Perl, I would use $^X to get the perl executable. It appears there's no such variable in PHP? Right now, I'm using $_SERVER['_'], because bash (and zsh) set the environment variable $_ to the last-run program. But, I'd rather not rely on a shell-specific idiom. UPDATE: Version differences are but one problem. If PHP isn't in PATH, for example, or isn't the first version found in PATH, the suggestions to find the version information won't help. Additionally, csh and variants appear to not set the $_ environment variable for their processes, so the workaround isn't applicable there. UPDATE 2: I was using $_SERVER['_'], until I discovered that it doesn't do the right thing under xargs (which makes sense... zsh sets it to the command it ran, which is xargs, not php5, and xargs doesn't change the variable). Falling back to using: $version = explode('.', phpversion()); $phpcli = "php{$version[0]}";

    Read the article

  • Jquery and PHP function

    - by Sergio
    How can I this PHP function include in jquery .html? PHP function: function trim_text($string, $limit, $break="<", $pad=" ...") { $words = explode(' ', htmlentities(strip_tags($string))); $countr = count($words); if ($countr <= 8) { return $string; }else{ // return with no change if string is shorter than $limit if(strlen($string) <= $limit) return $string; $string = substr($string, 0, $limit); if(false !== ($breakpoint = strpos($string, $break, $limit))) { if($breakpoint < strlen($string) - 1) { $string = substr($string, 0, $breakpoint) . $pad; } } $last_space = strrpos(substr($string, 0, $limit), ' '); $string = substr($string, 0, $last_space); $string = strip_tags($string); return $string.$pad; } } And the Jquery part of code where I want to in ".html" part somehow call this function is: $(" .text").html('<div>'+ message +'</div>'); What I want to do is trim this "message" text using PHP function. Is it possible?

    Read the article

  • random data using php & mysql

    - by Prakash
    I have mysql database structure like below: CREATE TABLE test ( id int(11) NOT NULL auto_increment, title text NULL, tags text NULL, PRIMARY KEY (id) ); data on field tags is stored as a comma separated text like html,php,mysql,website,html etc... now I need create an array that contains around 50 randomly selected tags from random records. currently I am using rand() to select 15 random mysql data from database and then holding all the tags from 15 records in an array. Then I am using array_rand() for randomizing the array and selecting only 50 random records. $query=mysql_query("select * from test order by id asc, RAND() limit 15"); $tags=""; while ($eachData=mysql_fetch_array($query)) { $additionalTags=$eachData['tags']; if ($tags=="") { $tags.=$additionalTags; } else { $tags.=$tags.",".$additionalTags; } } $tags=explode(",", $tags); $newTags=array(); foreach ($tags as $tag) { $tag=trim($tag); if ($tag!="") { if (!in_array($tag, $newTags)) { $newTags[]=$tag; } } } $random_newTags=array_rand($newTags, 50); Now I have huge records on the database, and because of that; rand() is performing very slow and sometimes it doesn't work. So can anyone let me know how to handle this situation correctly so that my page will work normally.

    Read the article

  • Configurating JOOMLA's e-mail notification for new account

    - by Dion
    Dear all... I'm using Joomla 1.5 to create a local site for my office. The site will be accessed locally via intranet, and my PC will be the localhost for the site. I'm using a Login pluggin, so that anyone who wanted to enter the site should create an account. In JOOMLA, all user who created their account for the first time will receive a notification e-mail like : "Hello pras, You have been added as a User to Information Center by an Administrator. This e-mail contains your username and password to log in to http://localhost/yaddayadda/ Username: hadisuryo.prasetio Password: xxxx Please do not respond to this message as it is automatically generated and is for information purposes only." but if the user click the URL in the mail, which is, "localhost/yaddayadda/" they will not be directed to my site, but to their own PC's localhost.... My question is : How can I Modified the e-mail or the site configuration so that the URL will not be "localhost/yaddayadda/" anymore, but will be "(My-IP adress)/yaddayadda" I'm not going to host my site to a web hosting service, just using my PC as a host. I've been trying to trace on each config and .ini files...it seems that i have to do something with the "JURI" function or the "$mosConfig_live_site" on the backlink.php file $mosConfig_absolute_path = JPATH_SITE; $mosConfig_live_site = JURI :: base(); $url_array = explode('/', $_SERVER['REQUEST_URI']); Can anyone give me assistance ? Thank You

    Read the article

  • PHP autoloader: ignoring non-existing include

    - by Bart van Heukelom
    I have a problem with my autoloader: public function loadClass($className) { $file = str_replace(array('_', '\\'), '/', $className) . '.php'; include_once $file; } As you can see, it's quite simple. I just deduce the filename of the class and try to include it. I have a problem though; I get an exception when trying to load a non-existing class (because I have an error handler which throws exceptions). This is inconvenient, because it's also fired when you use class_exists() on a non-existing class. You don't want an exception there, just a "false" returned. I fixed this earlier by putting an @ before the include (supressing all errors). The big drawback with this, though, is that any parser/compiler errors (that are fatal) in this include won't show up (not even in the logs), resulting in a hard to find bug. What would be the best way to solve both problems at once? The easiest way would be to include something like this in the autoloader (pseudocode): foreach (path in the include_path) { if (is_readable(the path + the class name)) readable = true; } if (!readable) return; But I worry about the performance there. Would it hurt a lot? (Solved) Made it like this: public function loadClass($className) { $file = str_replace(array('_', '\\'), '/', $className) . '.php'; $paths = explode(PATH_SEPARATOR, get_include_path()); foreach ($paths as $path) { if (is_readable($path . '/' . $file)) { include_once $file; return; } } }

    Read the article

  • Stop Excel from changing cell contents, ever

    - by Enable Manual-Correct
    I work with card numbers, like credit card and ID numbers. We do not do any calculations with card numbers, obviously. They are "text." I format them as text, I type them like text. I know how that works. Excel doesn't care. 16 digit card numbers get their last digit turned into a zero, changed into scientific notation, stupid stuff that I did not tell Excel to do. I need to do things like Find/Remove spaces from cells in files downloaded from our currently imperfect web-system. The system sends me files with 16 digit numbers, cells formatted as text, but due to bugs there are spaces at the end. I do Find/Remove all spaces and all my card numbers are transformed into scientific notation and the last digit turned into a 0. THEY ARE TEXT, they are formatted as text, I yelled into the screen that they are text, why does Excel refuse to acknowledge that they are text? (I would rather find a way to stop Excel's action than find a way to tell our programmers to put an apostrophe in every cell) How do I make it so that Excel just STOPS doing anything that I didn't tell it to do? Or at least stop it from doing anything to numbers it doesn't like. Maybe I can write a macro for whenever it discovers "Uhoh I should change that number to something different!" I'll make it format that cell to text a thousand times instead. Give me an error when I try calculating with a number larger than 15 digits, make my computer explode violently, that's fine. Just stop changing the numbers. Is it possible? I have many thousands of numbers that need changing in many different scenarios. I just want to stop it from trying to help. I can't understand why that would be difficult. I have 2007, but answers for other versions would be great as well. Thank you!

    Read the article

  • PHP IP Validation Help

    - by Zubair1
    Hello, I am using this IP Validation Function that i came across while browsing, it has been working well until today i ran into a problem. For some reason the function won't validate this IP as valid: 203.81.192.26 I'm not too great with regular expressions, so would appreciate any help on what could be wrong. If you have another function, i would appreciate if you could post that for me. |--------------------------------------------| The code for the function is below: |--------------------------------------------| public static function validateIpAddress($ip_addr) { global $errors; $preg = '#^(?:(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.){3}' . '(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)$#'; if(preg_match($preg, $ip_addr)) { //now all the intger values are separated $parts = explode(".", $ip_addr); //now we need to check each part can range from 0-255 foreach($parts as $ip_parts) { if(intval($ip_parts) > 255 || intval($ip_parts) < 0) { $errors[] = "ip address is not valid."; return false; } return true; } return true; } else { $errors[] = "please double check the ip address."; return false; } }

    Read the article

  • Batch folder of images into grayscale using php

    - by James
    Can anyone spot where I'm going wrong here. It should be creating grayscale copies of images in one folder and saving them in another folder. Could it be to do with the way im referencing the file locations. Folder permissions on both folders are 777 function grayscalecopy($targetfile, $outputfile){ $size = GetImageSize($targetfile); $width = $size[1]; $height = $size[0]; $canvas = imagecreatetruecolor($width, $height); $sourceimage = imagecreatefromjpeg($targetfile); imagefilter($sourceimage, IMG_FILTER_GRAYSCALE); imagecopy($canvas, $sourceimage, 0, 0, 0, 0, $width, $height); imagejpeg($canvas, $outputfile, 95); imagedestroy($sourceimage); imagedestroy($canvas); echo "Converted ".$targetfile." to grayscale as ".$outputfile." ".$width."x".$height."<br/>"; } $serverfiles = glob("artworkimages/thumbs/*.*"); //$numbertocache = count($serverfiles); $numbertocache = 10; for ($i=0; $i<$numbertocache; $i++) { $serverfilesshort=explode("/",$serverfiles[$i]); $serverfilesshort=$serverfilesshort[count($serverfilesshort)-1]; grayscalecopy($serverfiles[$i], "artworkimages/thumbs/grays/".$serverfilesshort); }

    Read the article

  • Association and model data saving problem

    - by Zhlobopotam
    Developing with cakephp 1.3 (latest from github). There are 2 models bind with hasAndBelongsToMany: documents and tags. Document can have many tags in other words. I've add a new document submitting form there user can enter a list of tags separated with commas (new tag will be added, if not exist already). I looked at cakephp bakery 2.0 source code on github and found the solution. But it seems that something is wrong. class Document extends AppModel { public $hasAndBelongsToMany = array('Tag'); public function beforeSave($options = array()) { if (isset($this->data[$this->alias]['tags']) && !empty($this- >data[$this->alias]['tags'])) { $tagIds = $this->Tag->saveDocTags($this->data[$this->alias] ['tags']); unset($this->data[$this->alias]['tags']); $this->data[$this->Tag->alias][$this->Tag->alias] = $tagIds; } return true; } } class Tag extends AppModel { public $hasAndBelongsToMany = array ('Document'); public function saveDocTags($commalist = '') { if ($commalist == '') return null; $tags = explode(',',$commalist); if (empty($tags)) return null; $existing = $this->find('all', array( 'conditions' => array('title' => $tags) )); $return = Set::extract($existing,'/Tag/id'); if (sizeof($existing) == sizeof($tags)) { return $return; } $existing = Set::extract($existing,'/Tag/title'); foreach ($tags as $tag) { if (!in_array($tag, $existing)) { $this->create(array('title' => $tag)); $this->save(); $return[] = $this->id; } } return $return; } } So, new tags creation works well but document model can't save association data and tells: SQL Error: 1054: Unknown column 'Array' in 'field list' Query: INSERT INTO documents (title, content, shortnfo, date, status) VALUES ('Document with tags', '', '', Array, 1) Any ideas how to solve this problem?

    Read the article

  • Youbikey Integration with php

    - by kapil
    Hi , I am finding a problem during the youbi key integration: $apiKey = $youbekeyvalue; //this value is coming from my form. $message = 'id=1234&otp='.$key.'';//key has been i am saving in the database for a particular user. $signature = hash_hmac('sha1', $message, $apiKey, TRUE); $signature = base64_encode($signature); $url = 'http://api.yubico.com/wsapi/verify?'.$message.'&h='.$signature.''; // $url becomes http://api.yubico.com/wsapi/verify?id=1&otp=ddkwn3kdlsh3kglskeh3kld&h=ODK20DHD92LSHGKJLSL3KSL $ch = curl_init($url); curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE); $result = curl_exec($ch); print_r($result); curl_close($ch); $statusstring = stristr($result,"status="); $finalresponse = explode("=",$statusstring); if($finalresponse[1]=="OK") return 1; else return 0; Every time i am using this code it is giving me the response the bad signature. Can anyone please help me out to give me the working you bi key code where i can get the status ok.

    Read the article

  • "string" != "string"

    - by Misiur
    Hi. I'm doing some kind of own templates system. I want to change <title>{site('title')}</title> Into function "site" execution with parameter "title". Here's private function replaceFunc($subject) { foreach($this->func as $t) { $args = explode(", ", preg_replace('/\{'.$t.'\(\'([a-zA-Z,]+)\'\)\}/', '$1', $subject)); $subject = preg_replace('/\{'.$t.'\([a-zA-Z,\']+\)\}/', call_user_func_array($t, $args), $subject); } return $subject; } Here's site: function site($what) { global $db; $s = $db->askSingle("SELECT * FROM ".DB_PREFIX."config"); switch($what) { case 'title': return 'Title of page'; break; case 'version': return $s->version; break; case 'themeDir': return 'lolmao'; break; default: return false; } } I've tried to compare $what (which is for this case "title") with "title". MD5 are different. strcmp gives -1, "==", and "===" return false. What is wrong? ($what type is string. You can't change call_user_func_array into call_user_func, because later I'll be using multiple arguments)

    Read the article

  • Multiple items in a PHP shopping cart

    - by Nick
    I'm in the progress of making a shopping cart in PHP. To check if a user has selected multiple products, I put everything in an array ($contents). When I output it, I get something like "14,14,14,11,10". I'd like to have something like "3 x 14, 1 x 11, 1 x 10". What is the easiest way to do that? I really have no clue how to do it. This is the most important part of my code. $_SESSION["cart"] = $cart; if ( $cart ) { $items = explode(',', $cart); $contents = array(); $i = 0; foreach ( $items as $item ) { $contents[$item] = (isset($contents[$item])) ? $contents[$item] + 1 : 1; $i++; } $smarty->assign("amount",$i); echo '<pre>'; print_r($contents); echo '</pre>'; Thanks in advance.

    Read the article

  • Object Oriented Programming in AS3

    - by Jordan
    I'm building a game in as3 that has balls moving and bouncing off the walls. When the user clicks an explosion appears and any ball that hits that explosion explodes too. Any ball that then hits that explosion explodes and so on. My question is what would be the best class structure for the balls. I have a level system to control levels and such and I've already come up with working ways to code the balls. Here's what I've done. My first attempt was to create a class for Movement, Bounce, Explosion and finally Orb. These all extended each other in the order I just named them. I got it working but having Bounce extend Movement and Explosion extend Bounce, it just doesn't seem very object oriented because what if I wanted to add a box class that didn't move, but did explode? I would need a separate class for that explosion. My second attempt was to create Movement, Bounce and Explosion without extending anything. Instead I passed in a reference to the Orb class to each. Then the class stores that reference and does what it needs to do based on events that are dispatched by the Orb such as update, which was broadcast from Orb every enter frame. This would drive the movement and bounce and also the explosion when the time came. This attempt worked as well but it just doesn't seem right. I've also thought about using Interfaces but because they are more of an outline for classes, I feel like code reuse goes out the window as each class would need its own code for a specific task even if that task is exactly the same. I feel as if I'm searching for some form of multiple inheritance for classes that as3 does not support. Can someone explain to me a better way of doing what I'm attempting to do? Am I being to "Object Oriented" by having classed for Movement, Bounce, Explosion and Orb? Are Interfaces the way to go? Any feedback is appreciated!

    Read the article

  • User preferences using SQL and JavaScript

    - by Shyam
    Hi, I am using Server Side JavaScript - yes, I am actually using Server Side JavaScript. To complexify things even more, I use Oracle as a backend database (10g). With some crazy XSLT and mutant-like HTML generation, I can build really fancy web forms - yes, I am aware of Rails and other likewise frameworks and I choose the path of horror instead. I have no JQuery or other fancy framework at my disposal, just plain ol' JavaScript that should be supported by the underlying engine called Mozilla Rhino. Yes, it is insane and I love it. So, I have a bunch of tables at my disposal and some of them are filled with associative keys that link to values. As I am a people pleaser, I want to add some nifty user-preference driven solutions. My users have all an unique user_id and this user_id is available during the entire session. My initial idea is to have a user preference table, where I have "three" columns: user_id, feature and pref_string. Using a delimiter, such as : or - (haven't thought about a suitable one yet), I could like store a bunch of preferences as a list and store its elements inside an array using the .split-method (similar like the PHP-explode function). The feature column could be like the table name or some identifier for the "feature" i want to link preferences too. I hate hardcoding objects, especially as I want to be able to back these up and reuse this functionality application-wide. Of course I would love better ideas, just keep in mind I cannot just add a library that easily. These preferences could be like "joined" to the table, so I can query it and use its values. I hope it doesn't sounds too complex, because well.. its basically something really simple I need. Thanks!

    Read the article

  • php parsing speed optimization

    - by Arnaud
    I would like to add tooltip or generate link according to the element available in the database, for exemple if the html page printed is: to reboot your linux host in single-user mode you can ... I will use explode(" ", $row[page]) and the idea is now to lookup for every single word in the page to find out if they have a related referance in this exemple let's say i've got a table referance an one entry for reboot and one for linux reboot: restart a computeur linux: operating system now my output will look like (replaced < and by @) to @a href="ref/reboot"@reboot@/a@ your @a href="ref/linux"@linux@/a@ host in single-user mode you can ... Instead of have a static list generated when I saved the content, if I add more keyword in the future, then the text will become more interactive. My main concerne and question is how can I create a efficient enough process to do it ? Should I store all the db entry in an array and compare them ? Do an sql query for each word (seems to be crazy) Dump the table in a file and use a very long regex or a "grep -f pattern data" way of doing it? Or or or or I'm sure it must be a better way of doing it, just don't have a clue about it, or maybe this will be far too resource un-friendly and I should avoid doing such things. Cheers!

    Read the article

  • PHP Replace chars by functions

    - by user1860570
    I try change characters by functions <?php $string = "Hi everybody people [gal~images/articles~100~100~4] here other imagen [gal~images/products~100~100~3]"; $regex = "/\[(.*?)\]/"; preg_match_all($regex, $string, $matches); for($i=0; $i<count($matches[1]);$i++) { $match = $matches[1][$i]; $array = explode('~', $match); //$newValuet="gal("".$array[1]."","".$array[2]."","".$array[3]."","".$array[4]."")"; $newValue="gal(".$array[1].",".$array[2].",".$array[3].",".$array[4].")"; $string = str_replace($matches[0][$i],$newValue,$string); } echo $string; ?> The problem here : $newValue="gal(".$array[1].",".$array[2].",".$array[3].",".$array[4].")"; $string = str_replace($matches[0][$i],$newValue,$string); Function no give the right results i try differents methods but continue the problems , please i see all functions but no get this works if you can answer please put me some modification of this code for i can understand , thank´s a lot for all help

    Read the article

  • How to create custom pages (Drupal 6.x)

    - by jc70
    In the template.php file I inserted the code below: I found a tutorial online that gives the code, but I'm confused on how to get it to work. I copied the code below and inserted it into the template.php from the theme HTML5_base. I duplicated the page.tpl.php file and created custom pages -- page-gallery.tpl.php and page-articles.tpl.php. I inserted some text to the files just see that I've navigated to the pages w/ the changes. It looks like Drupal is not recognizing gallery.tpl.php and page-articles.tpl.php. In the template.php there are the following functions: html5_base_preprocess_page() html5_base_preprocess_node() html5_base_preprocess_block() In the tutorial it uses these functions: phptemplate_preprocess_page() phptemplate_preprocess_block() phptemplate_preprocess_node() function phptemplate_preprocess_page(&$vars) { //code block from the Drupal handbook //the path module is required and must be activated if(module_exists('path')) { //gets the "clean" URL of the current page $alias = drupal_get_path_alias($_GET['q']); $suggestions = array(); $template_filename = 'page'; foreach(explode('/', $alias) as $path_part) { $template_filename = $template_filename.'-'.$path_part; $suggestions[] = $template_filename; } $vars['template_files'] = $suggestions; } } function phptemplate_preprocess_node(&$vars) { //default template suggestions for all nodes $vars['template_files'] = array(); $vars['template_files'][] = 'node'; //individual node being displayed if($vars['page']) { $vars['template_files'][] = 'node-page'; $vars['template_files'][] = 'node-'.$vars['node']->type.'-page'; $vars['template_files'][] = 'node-'.$vars['node']->nid.'-page'; } //multiple nodes being displayed on one page in either teaser //or full view else { //template suggestions for nodes in general $vars['template_files'][] = 'node-'.$vars['node']->type; $vars['template_files'][] = 'node-'.$vars['node']->nid; //template suggestions for nodes in teaser view //more granular control if($vars['teaser']) { $vars['template_files'][] = 'node-'.$vars['node']->type.'-teaser'; $vars['template_files'][] = 'node-'.$vars['node']->nid.'-teaser'; } } } function phptemplate_preprocess_block(&$vars) { //the "cleaned-up" block title to be used for suggestion file name $subject = str_replace(" ", "-", strtolower($vars['block']->subject)); $vars['template_files'] = array('block', 'block-'.$vars['block']->delta, 'block-'.$subject); }

    Read the article

  • How to color HTML elements based on a user command string

    - by Anonymous the Great
    When you type something like "red:Hi:" it will type "Hi" in red. The following script does not work and I do not know why, (The one who made the sorting PHP function is Graphain, thanks again!) <?php function getit($raw) { # If the value was posted $raw = isset($raw) ? $raw : ""; # Split it based on ':' $parsed = explode(':', $raw); $colorClass = ""; $text = ""; if (count($parsed) >= 2) { $colorClass = $parsed[0]; $text = $parsed[1]; $text = "~~~" . $text . "~~~" . $colorClass; return $text; } } ?> <script type="text/javascript"> function postit() { var preview = document.getElementById("preview").value; var submit = document.getElementById("post").value; var text = <?php getit(submit); ?> var t = text[0]; preview = t; } </script> <textarea id="preview" cols=70 rows=5 readonly>Preview box</textarea> <p> <textarea id="post" cols=70 rows=5/>Submit box</textarea> <p> <input type="button" onclick="postit();" value="Submit"/>

    Read the article

  • Wrong colors when merging images with PHP

    - by OfficeJet
    Hi, I want to get images ID's and creat from files a merged image according to the given ID's. This code is called by ajax and return the image file name (which is the server time to prevent browser caching). code: if (isset($_REQUEST['items'])){ $req_items = $_REQUEST['items']; } else { $req_items = 'a'; } $items = explode(',',$req_items); $bg_img = imagecreatefrompng('bg.png'); for ($i=0; $i<count($items); $i++){ $main_img = $items[$i].'-large.png'; $image = imagecreatefrompng($main_img); $image_tc = imagecreatetruecolor(300, 200); imagecopy($image_tc,$image,0,0,0,0,300,200); $black = imagecolorallocate($image_tc, 0, 0, 0); imagecolortransparent($image_tc, $black); $opacity = 100; $bg_width = 300; $bg_height = 200; $dest_x = 0;//$image_size[0] - $bg_width - $padding; $dest_y = 0;//$image_size[1] - $bg_height - $padding; imagecopymerge($bg_img, $image_tc, $dest_x, $dest_y, 0, 0, $bg_width, $bg_height, $opacity) ; } $file = $_SERVER['REQUEST_TIME'].'.jpg'; imagejpeg($bg_img, $file, 100); echo $file; imagedestroy($bg_img); imagedestroy($image); die(); The images are shown exactly as I want but with wrong colors. I lately added the part with imagecreatetruecolor and imagecolortransparent, and still got wrong results. I also saved the PNG itself on a 24 bit format and also later as 8 bit - not helping. every ideas is very welcomed ! Thanks

    Read the article

  • Configurating JOOMLA's e-mail notification for new account

    - by Dion
    I'm using Joomla 1.5 to create a local site for my office. The site will be accessed locally via intranet, and my PC will be the localhost for the site. I'm using a Login pluggin, so that anyone who wanted to enter the site should create an account. In JOOMLA, all user who created their account for the first time will receive a notification e-mail like : "Hello pras, You have been added as a User to Information Center by an Administrator. This e-mail contains your username and password to log in to http://localhost/yaddayadda/ Username: hadisuryo.prasetio Password: xxxx Please do not respond to this message as it is automatically generated and is for information purposes only." but if the user click the URL in the mail, which is, "localhost/yaddayadda/" they will not be directed to my site, but to their own PC's localhost.... My question is : How can I Modified the e-mail or the site configuration so that the URL will not be "localhost/yaddayadda/" anymore, but will be "(My-IP adress)/yaddayadda" I'm not going to host my site to a web hosting service, just using my PC as a host. I've been trying to trace on each config and .ini files...it seems that i have to do something with the "JURI" function or the "$mosConfig_live_site" on the backlink.php file $mosConfig_absolute_path = JPATH_SITE; $mosConfig_live_site = JURI :: base(); $url_array = explode('/', $_SERVER['REQUEST_URI']); Can anyone give me assistance ? Thank You

    Read the article

  • Get location of element you just pushed into vector C++

    - by Satchmo Brown
    I am curious about how pushing back into a vector works. I want a way to push back an element and then be able to add it's location in the vector to a double array serving as a type of map. Something like this: // Create a bomb Bomb b; b.currentTime = SDL_GetTicks(); b.explodeTime = SDL_GetTicks() + 3000; b.owner = player; b.power = 2; b.x = x; b.y = y; bombVec.push_back(b); bombs[y][x] = THIS_IS_WHAT_I_WANT; This way when I explode the bomb, I can check the map and then have an ID in the vector to deal with. Every non bomb square will have a -1. Also, just curious. Imagine I have 3 elements in a vector. I delete the second one and then add another. Does the new element go in the same location as the one that was deleted? Thanks!

    Read the article

< Previous Page | 7 8 9 10 11 12 13 14 15 16 17  | Next Page >