Search Results

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

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

  • pager problem with drupal and taxonomy

    - by andersandersson666
    Ok, so this is probably a silly question, but i thought i'd put it out there anyway: I know it's a strange solution to a simple problem, but i needed to control the listing of the nodes in the taxonomy pages, which i didn't feel i got the traditional way. So i went ahead and created a module that fetches the nodes based on taxonomy (taxonomy_select_nodes()), and i wanted a pager to go along with that. Here's the code: function theModule_recipeList(){ $path = drupal_get_path_alias($_GET['q']); $args = explode("/",$path); $themePath = drupal_get_path("theme", "theTheme"); $term = taxonomy_get_term_by_name($args[1]); $tid = $term[0]->tid; $nodes = taxonomy_select_nodes(array($tid)); $output = "<div id='recipeListWrapper'>"; while($row = db_fetch_object($nodes)){ $node = node_load($row->nid); if($node->uid != 1){ $userClass="user"; } else{ $userClass="admin"; } $output .= " <div class='receptThumbnailWrapper'> <div class='wrapper'> <img src='".base_path().$themePath."/graphics/recept-default-small.png' /> <h3><a href='".base_path() . $node->path."'>".$node->title."</a></h3> <div class='recipeType $userClass'></div> </div> </div> "; } $output .= "</div>"; return $output; } Now, the module works as i planned and all (even though it is a duct tape sort of solution, i know), and the pager prints and works. The problem is that the pager prints before anything else. I suspect that it is because i call taxonomy_select_nodes before $output is returned, but i need it to get the nodes i want. Please, any suggestions is greatly appreciated. /Anders

    Read the article

  • For loop from assembly to C

    - by FranXh
    I have a bomb project where I need to defuse certain phases by finding "pas phrases" that will defuse the bomb. Right now I have been working with phase_2, for which the assembly code is shown below. Phase_2 requires as an input 6 numbers, which I need to find in order to defuse this phase. I analyzed this assembly, and I came up with the C code below, that covers lines from 40101c to 401044. It is basically a for loop that makes sure that elements t[0]==t[3], t[1]==t[4] and t[2]==t[5] that the user inputs, are equal. According to my logic, the user can input any 6 numbers as long as the above condition is satisfied. Say 1, 2, 3, 1, 2, 3 would be a valid "pas phrase". However this solution does not convince me for some reason. Am I doing something wrong? 0000000000400ffc <phase_2>: 400ffc: 48 89 5c 24 e0 mov %rbx,-0x20(%rsp) 401001: 48 89 6c 24 e8 mov %rbp,-0x18(%rsp) 401006: 4c 89 64 24 f0 mov %r12,-0x10(%rsp) 40100b: 4c 89 6c 24 f8 mov %r13,-0x8(%rsp) 401010: 48 83 ec 48 sub $0x48,%rsp 401014: 48 89 e6 mov %rsp,%rsi 401017: e8 65 0a 00 00 callq 401a81 <read_six_numbers> 40101c: 48 89 e5 mov %rsp,%rbp 40101f: 4c 8d 6c 24 0c lea 0xc(%rsp),%r13 401024: 41 bc 00 00 00 00 mov $0x0,%r12d 40102a: 48 89 eb mov %rbp,%rbx 40102d: 8b 45 0c mov 0xc(%rbp),%eax 401030: 39 45 00 cmp %eax,0x0(%rbp) 401033: 74 05 je 40103a <phase_2+0x3e> 401035: e8 2d 09 00 00 callq 401967 <_GLOBAL_RESET_> 40103a: 44 03 23 add (%rbx),%r12d 40103d: 48 83 c5 04 add $0x4,%rbp 401041: 4c 39 ed cmp %r13,%rbp 401044: 75 e4 jne 40102a <phase_2+0x2e> 401046: 45 85 e4 test %r12d,%r12d 401049: 75 05 jne 401050 <phase_2+0x54> 40104b: e8 17 09 00 00 callq 401967 <_GLOBAL_RESET_> 401050: 48 8b 5c 24 28 mov 0x28(%rsp),%rbx 401055: 48 8b 6c 24 30 mov 0x30(%rsp),%rbp 40105a: 4c 8b 64 24 38 mov 0x38(%rsp),%r12 40105f: 4c 8b 6c 24 40 mov 0x40(%rsp),%r13 401064: 48 83 c4 48 add $0x48,%rsp 401068: c3 for (int i=0; i<3; i++){ if(t[i] != t[i+3]){ explode(); } }

    Read the article

  • How does session_start lock in PHP?

    - by Morgan Cheng
    Originally, I just want to verify that session_start locks on session. So, I create a PHP file as below. Basically, if the pageview is even, the page sleeps for 10 seconds; if the pageview is odd, it doesn't. And, session_start is used to obtain the page view in $_SESSION. I tried to access the page in two tabs of one browser. It is not surprising that the first tab takes 10 seconds since I explicitly let it sleep. The second tab would not sleep, but it should be blocked by sessiont_start. That works as expected. To my surprise, the output of the second page shows that session_start takes almost no time. Actually, the whole page seems takes no time to load. But, the page does take 10 seconds to show in browser. obtained lock Cost time: 0.00016689300537109 Start 1269739162.1997 End 1269739162.1998 allover time elpased : 0.00032305717468262 The page views: 101 Does PHP extract session_start out of PHP page and execute it before other PHP statements? This is the code. <?php function float_time() { list($usec, $sec) = explode(' ', microtime()); return (float)$sec + (float)$usec; } $allover_start_time = float_time(); $start_time = float_time(); session_start(); echo "obtained lock<br/>"; $end_time = float_time(); $elapsed_time = $end_time - $start_time; echo "Cost time: $elapsed_time <br>"; echo "Start $start_time<br/>"; echo "End $end_time<br/>"; ob_flush(); flush(); if (isset($_SESSION['views'])) { $_SESSION['views'] += 1; } else { $_SESSION['views'] = 0; } if ($_SESSION['views'] % 2 == 0) { echo "sleep 10 seconds<br/>"; sleep(10); } $allover_end_time = float_time(); echo "allover time elpased : " . ($allover_end_time - $allover_start_time) . "<br/>"; echo "The page views: " . $_SESSION['views']; ?>

    Read the article

  • php , SimpleXML, while loop

    - by Michael
    I'm trying to get some information from ebay api and store it in database . I used simple xml to extract the information but I have a small issue as the information is not displayed for some items . if I make a print to the simple_xml I can see very well that the information is provided by ebay api . I have $items = "220617293997,250645537939,230485306218,110537213815,180519294810"; $number_of_items = count(explode(",", $items)); $xml = $baseClass->getContent("http://open.api.ebay.com/shopping?callname=GetMultipleItems&responseencoding=XML&appid=Morcovar-c74b-47c0-954f-463afb69a4b3&siteid=0&version=525&IncludeSelector=ItemSpecifics&ItemID=$items"); writeDoc($xml, "api.xml"); //echo $xml; $getvalues = simplexml_load_file('api.xml'); // print_r($getvalue); $number = "0"; while($number < 6) { $item_number = $getvalues->Item[$number]->ItemID; $location = $getvalues->Item[$number]->Location; $title = $getvalues->Item[$number]->Title; $price = $getvalues->Item[$number]->ConvertedCurrentPrice; $manufacturer = $getvalues->Item[$number]->ItemSpecifics->NameValueList[3]->Value; $model = $getvalues->Item[$number]->ItemSpecifics->NameValueList[4]->Value; $mileage = $getvalues->Item[$number]->ItemSpecifics->NameValueList[5]->Value; echo "item number = $item_number <br>localtion = $location<br>". "title = $title<br>price = $price<br>manufacturer = $manufacturer". "<br>model = $model<br>mileage = $mileage<br>"; $number++; } the above code returns item number = localtion = title = price = manufacturer = model = mileage = item number = 230485306218 localtion = Coventry, Warwickshire title = 2001 LAND ROVER RANGE ROVER VOGUE AUTO GREEN price = 3635.07 manufacturer = Land Rover model = Range Rover mileage = 76000 item number = 220617293997 localtion = Crawley, West Sussex title = 2004 CITROEN C5 HDI LX RED price = 3115.77 manufacturer = Citroen model = C5 mileage = 76000 item number = 180519294810 localtion = London, London title = 2000 VOLKSWAGEN POLO 1.4 SILVER 16V NEED GEAR BOX price = 905.06 manufacturer = Right-hand drive model = mileage = Standard Car item number = localtion = title = price = manufacturer = model = mileage = As you can see the information is not retrieved for a few items ... If I replace the $number manually like " $item_number = $getvalues-Item[4]-ItemID;" works well for any number .

    Read the article

  • How hard programming is? Really. [closed]

    - by Bubba88
    Hi! The question is about your perception of programming activity. How hard/exacting this task is? There is much buzz about programming nowadays, people say that programmers are smart, very technical and abstract at a time, know much about world, psychology etc.. They say, that programmers got really powerful brain thing, cause there is much to keep in consideration simultaneously again with much information folded into each other associatively (up 10 levels of folding they say))) Still, there are some terms to specify at our own.. So that is the question: What do you think about programming in general? Is it hard? Is it 'for everyone' or for the particular kind of people only? How much non-CS background do you need to program (just to program, really; enterprise applications for example)? How long is the learning curve? (again, for programming in general) And another bunch of random questions: - If you were not to like/love programming, would that be a serious trouble bothering your current employment? - If you were to start from the beginning, would you chose that direction this time? - What other areas (jobs or maybe hobbies) are comparable to programming in the way they can explode someone's lovely brain? - Is 'non turing-complete programming' (SQL, XML, etc.) comparable to what we do or is it really way easier, less requiring, cheap and akin to cooking :)? Well, the essence is: How would you describe programming activity WRT to its difficulty? Or, on the other hand: Did you ever catch yourself thinking at some point: OMG, it's sooo hard! I don't know how would I ever program, even carried away this way and doing programming just for fun? It's very interesting to know your opinion, your'e the programmers after all. I mean much people must be exaggerating/speculating about the thing they do not really know about. But that musn't be the case here on SO :) P.S.: I'll try my best to update this post later, and you please edit it too. At least I'll get decent English in my question text :)

    Read the article

  • PHP script loading took over 10 seconds

    - by Misiur
    My again. I've promised to not come back today, but I've got another trouble. http://www.misiur.com/me/ - it took over 10 seconds to load. Whole site code: <!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" xml:lang="pl" lang="pl"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>{site('title')}</title> <link rel="stylesheet" type="text/css" href="{site('themeDir')}/global.css" /> </head> <body> <div id="site"> <div id="footer"> <p>Site Managment System {site('version')} by <a href="http://www.misiur.com">Misiur</a>. Copyright &copy; 2010-{$currYear}.</p> </div> </div> </body> I think the trouble is in this piece of code: private function replaceFunc($subject) { foreach($this->func as $t) { preg_match_all('/\{'.$t.'\([a-zA-Z,\']+\)\}/i', $subject, $res); for($j = 0; $j < sizeof($res[0]); $j++) { preg_match('/\([a-zA-Z,\']+\)/i', $res[0][$j], $match); if($match > 0) { $prep = explode(", ", substr($match[0], 1, -1)); $args = array(); for($i = 0; $i < sizeof($prep); $i++) { $args[] = substr($prep[$i], 1, -1); } } else { $args = array(); } $subject = preg_replace('/\{'.$t.preg_quote($match[0]).'\}/i', call_user_func_array($t, $args), $subject); } } return $subject; } It has to find functions from array ($this-func), cut out arguments, and call function with them. I think that I've messed up. Help.

    Read the article

  • Set the Dropdown box as selected in Javascript

    - by Aruna
    I am using Javascript in my app. In my table, I have a column named industry which contains value like id 69 name :aruna username :aruna email :[email protected] password: bd09935e199eab3d48b306d181b4e3d1:i0ODTgVXbWyP1iFOV type : 3 industry: | Insurance | Analytics | EIS and Process Engineering actually this industry value is inserted from a dropdown box multi select.. now i am trying like on load to make my form as to contain these values where industry is dropdown box <select id="ind1" moslabel="Industry" onClick="industryfn();"mosreq="0" multiple="multiple" size="3" class="inputbox" name="industry1[]">'+ <option value="Banking and Financial Services">Banking and Financial Services</option> <option value="Insurance">Insurance</option> <option value="Telecom">Telecom</option> <option value="Government ">Government </option> <option value="Healthcare &amp; Life sciences">Healthcare & Life sciences</option> <option value="Energy">Energy</option> <option value="Retail &amp;Consumer products">Retail &Consumer products</option> <option value="Energy, resources &amp; utilities">Energy, resources & utilities</option> <option value="Travel and Hospitality">Travel and Hospitality</option> <option value="Manufacturing">Manufacturing</option> <option value="High Tech">High Tech</option> <option value="Media and Information Services">Media and Information Services</option> </select> How to keep the industry values(| Insurance | Analytics | EIS and Process Engineering ) as selected? EDIT: Window.onDomReady(function(){ user-get('industry'); $s=explode('|', $str) ? var selectedFields = new Array(); <?php for($i=1;$i<count($s);$i++){?> selectedFields.push("<?php echo $s[$i];?>"); <?php }?> for(i=1;i<selectedFields.length;i++) { var select=selectedFields[i]; for (var ii = 0; ii < document.getElementById('ind1').length; ii++) { var value=document.getElementById('ind1').options[ii].value; alert(value); alert(select); if(value==select) { document.getElementById('ind1').options[ii].selected=selected; }//If } //inner For }//outer For </script> i have tried the above the alert functions are working correctly. But the if loop didnt works correctly .. Why so ..Please help me....

    Read the article

  • Write Scheme data structures so they can be eval-d back in, or alternative

    - by Jesse Millikan
    I'm writing an application (A juggling pattern animator) in PLT Scheme that accepts Scheme expressions as values for some fields. I'm attempting to write a small text editor that will let me "explode" expressions into expressions that can still be eval'd but contain the data as literals for manual tweaking. For example, (4hss->sexp "747") is a function call that generates a legitimate pattern. If I eval and print that, it becomes (((7 3) - - -) (- - (4 2) -) (- (7 2) - -) (- - - (7 1)) ((4 0) - - -) (- - (7 0) -) (- (7 2) - -) (- - - (4 3)) ((7 3) - - -) (- - (7 0) -) (- (4 1) - -) (- - - (7 1))) which can be "read" as a string, but will not "eval" the same as the function. For this statement, of course, what I need would be as simple as (quote (((7 3... but other examples are non-trivial. This one, for example, contains structs which print as vectors: pair-of-jugglers ; --> (#(struct:hand #(struct:position -0.35 2.0 1.0) #(struct:position -0.6 2.05 1.1) 1.832595714594046) #(struct:hand #(struct:position 0.35 2.0 1.0) #(struct:position 0.6 2.0500000000000003 1.1) 1.308996938995747) #(struct:hand #(struct:position 0.35 -2.0 1.0) #(struct:position 0.6 -2.05 1.1) -1.3089969389957472) #(struct:hand #(struct:position -0.35 -2.0 1.0) #(struct:position -0.6 -2.05 1.1) -1.8325957145940461)) I've thought of at least three possible solutions, none of which I like very much. Solution A is to write a recursive eval-able output function myself for a reasonably large subset of the values that I might be using. There (probably...) won't be any circular references by the nature of the data structures used, so that wouldn't be such a long job. The output would end up looking like `(((3 0) (... ; ex 1 `(,(make-hand (make-position ... ; ex 2 Or even worse if I could't figure out how to do it properly with quasiquoting. Solution B would be to write out everything as (read (open-input-string "(big-long-s-expression)")) which, technically, solves the problem I'm bringing up but is... ugly. Solution C might be a different approach of giving up eval and using only read for parsing input, or an uglier approach where the s-expression is used as directly data if eval fails, but those both seem unpleasant compared to using scheme values directly. Undiscovered Solution D would be a PLT Scheme option, function or library I haven't located that would match Solution A. Help me out before I start having bad recursion dreams again.

    Read the article

  • Anyway that I can get the values of a PHP array through ajax?

    - by Jerry
    Hi All, I am trying to build a shopping cart site. When a user click add to cart image on the product page, The product title will show a "The product is in your cart" text without reloading the page. I am using session and ajax but no luck so far. I appreciate any helps. My html cold <table id="<?php echo $productId; ?>" width="594" border="0" cellpadding="5" cellspacing="0"> <tr> <td><img src="<?php echo "$brandImage"; ?></td> <td <?php echo $productName; ?> //The "The product is in your cart" will be showed here</td> </tr> <tr> <td><a class="addToCart" href="javascript:void(0);" onclick="addToCart(<?php echo $productId?>)"> </td> My Javascript file (addToCart.js) function addToCart(productId){ var url="addToCart.php"; url=url+"?productId="+productId; url=url+"&sid="+Math.random(); $.post( url, function(responseText){ alert(responseText); //I wish I can get productData value from addToCart.php }, "html" ) My php file (addToCart.php) <?php SESSION_START(); $productId=$_GET['productId']; $cart=$_SESSION['cart']; if(isset($cart)){ $cart.=",".$productId; $product=explode(',',$cart); $totalItem=count($product); }else{ $cart=$productId; $totalItem=1; }; $productData=array(); foreach($product as $id){ $productData[$id]=(isset($productData[$id])) ? $productData[$id]+1 :1; }; $_SESSION['cart']=$cart; //print_r($productData); echo $productData; //Not sure what to do to send $productData back to my addToCart.js variable ?> I tried to make the code look simple. Any suggestion will be a great help. Thanks

    Read the article

  • How to use Wordpress' http.php in external projects?

    - by NJTechGuy
    I am trying to parse data from a pipe-delimited text file hosted on another server which in turn will be inserted in a database. My host (1and1) disabled allow_url_fopen in php.ini I guess. Error message : Warning: fopen() [function.fopen]: URL file-access is disabled in the server configuration in Code : <? // make sure curl is installed if (function_exists('curl_init')) { // initialize a new curl resource $ch = curl_init(); // set the url to fetch curl_setopt($ch, CURLOPT_URL, 'http://abc.com/data/output.txt'); // don't give me the headers just the content curl_setopt($ch, CURLOPT_HEADER, 0); // return the value instead of printing the response to browser curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); // use a user agent to mimic a browser curl_setopt($ch, CURLOPT_USERAGENT, 'Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.7.5) Gecko/20041107 Firefox/1.0'); $content = curl_exec($ch); // remember to always close the session and free all resources curl_close($ch); } else { // curl library is not installed so we better use something else } //$contents = fread ($fd,filesize ($filename)); //fclose ($fd); $delimiter = "|"; $splitcontents = explode($delimiter, $contents); $counter = ""; ?> <font color="blue" face="arial" size="4">Complete File Contents</font> <hr> <? echo $contents; ?> <br><br> <font color="blue" face="arial" size="4">Split File Contents</font> <hr> <? foreach ( $splitcontents as $color ) { $counter = $counter+1; echo "<b>Split $counter: </b> $colorn<br>"; } ?> Wordpress has this cool http.php file. Is there a better way of doing it? If not, how do I use http.php for this task? Thank you guys..

    Read the article

  • Need Help on OAuthException Code 2500

    - by Deepak
    I am trying to develop an Facebook application (apps.facebook.com/some_app) using PHP where I need to present some information based on user's music interests. I found that its under "user_likes games". My problems are as follows: To gain access, I have implemented the oauth dialog method as suggested in API in my index page. $auth_url = "http://www.facebook.com/dialog/oauth?client_id=" . $app_id . "&redirect_uri=" . urlencode($canvas_page) ."&scope=user_likes"; After successful authorization I come back to index page with "code" as parameters. http://MY_CANVAS_PAGE/?code=some base64 encoded letters Firstly I don't know if I need access_token just to read user's music interests but I have tried all the methods suggested. I couldn't move forward from this point I have a code like this (in my index page), which redirects for authorization if code parameters is not set. if(empty($code) && !isset($_REQUEST['error'])) { $_SESSION['state'] = md5(uniqid(rand(), TRUE)); //CSRF protection echo("<script> top.location.href='" . $auth_url . "'</script>"); } Currently I am just trying to get user's public information here but with no success. I have tried the signed_request method as suggested but no success $signed_request = $_REQUEST["signed_request"]; list($encoded_sig, $payload) = explode('.', $signed_request, 2); $data = json_decode(base64_decode(strtr($payload, '-_', '+/')), true); echo ("Welcome User: " . $data["user_id"]); Also tried the code found in http://developers.facebook.com/blog/post/500/ but I am getting error when trying to get the debug info using print_r($decoded_response); stdClass Object ( [error] => stdClass Object ( [message] => An active access token must be used to query information about the current user. [type] => OAuthException [code] => 2500 ) ) To get user's public info, I have tried also the suggested example in PHP SDK $facebook = new Facebook(array( 'appId' => MY_APP_ID, //registered facebook APP ID 'secret' => MY_SECRET, //secret key for APP )); $fb_user = $facebook->getUser(); if($fb_user){ try { $user_profile = $facebook->api('/me'); echo $user_profile['email']; } catch(FacebookApiException $e) { $fb_user = null; } } But no success. Can somebody explain me why I am getting this error and how to access the user's music interest properly. Probably I misunderstood the API. Thanks Deepak

    Read the article

  • PHP max_execution_time not timing out

    - by Joey Ezekiel
    This is not one of the regular questions if sleep is counted for timeout or stuff like that. Ok, here's the problem: I've set the max_execution_time for PHP as 15 seconds and ideally this should time out when it crosses the set limit, but it doesn't. Apache has been restarted after the change to the php.ini file and an ini_get('max_execution_time') is all fine. Sometimes the script runs for upto 200 seconds which is crazy. I have no database communication whatsoever. All the script does is looking for files on the unix filesystem and in some cases re-directing to another JSP page. There is no sleep() on the script. I calculate the total execution time of the PHP script like this: At the start of the script I set : $_mtime = microtime(); $_mtime = explode(" ",$_mtime); $_mtime = $_mtime[1] + $_mtime[0]; $_gStartTime = $_mtime; and the end time($_gEndTime) is calculated similarly. The total time is calculated in a shutdown function that I've registered: register_shutdown_function('shutdown'); ............. function shutdown() { .............. .............. $_total_time = $_gEndTime - $_gStartTime; .............. switch (connection_status ()) { case CONNECTION_NORMAL: .... break; .... case CONNECTION_TIMEOUT: .... break; ...... } } Note: I cannot use $_SERVER['REQUEST_TIME'] because my PHP version is incompatible. That sucks - I know. 1) Well, my first question obviously is is why is my PHP script executing even after the set timeout limit? 2) Apache has the Timeout directive which is 300 seconds but the PHP binary does not read the Apache config and this should not be a problem. 3) Is there a possibility that something is sending PHP into a sleep mode? 4) Am I calculating the execution time in a wrong way? Is there a better way to do this? I'm stumped at this point. PHP Wizards - please help.

    Read the article

  • Turning Floats into Their Closest (UTF-8 Character) Fraction.

    - by Mark Tomlin
    I want to take any real number, and return the closest number, with the closest fraction as available in the UTF-8 character set, appropriate. 0/4 = 0.00 = # < .125 1/4 = 0.25 = ¼ # > .125 & < .375 2/4 = 0.50 = ½ # > .375 & < .625 3/4 = 0.75 = ¾ # > .625 & < .875 4/4 = 1.00 = # > .875 I made this function to do that task: function displayFraction($realNumber) { if (!is_float($realNumber)) { return $realNumber; } list($number, $decimal) = explode('.', $realNumber); $decimal = '.' . $decimal; switch($decimal) { case $decimal < 0.125: return $number; case $decimal > 0.125 && $decimal < 0.375: return $number . '¼'; # 188 ¼ &#188; case $decimal > 0.375 && $decimal < 0.625: return $number . '½'; # 189 ½ &#189; case $decimal > 0.625 && $decimal < 0.875: return $number . '¾'; # 190 ¾ &#190; case $decimal < 0.875: return ++$number; } } What are the better / diffrent way to do this? echo displayFraction(3.1) . PHP_EOL; # Outputs: 3 echo displayFraction(3.141593) . PHP_EOL; # Outputs: 3¼ echo displayFraction(3.267432) . PHP_EOL; # Outputs: 3¼ echo displayFraction(3.38) . PHP_EOL; # Outputs: 3½ Expand my mind!

    Read the article

  • Text Obfuscation using base64_encode()

    - by user271619
    I'm playing around with encrypt/decrypt coding in php. Interesting stuff! However, I'm coming across some issues involving what text gets encrypted into. Here's 2 functions that encrypt and decrypt a string. It uses an Encryption Key, which I set as something obscure. I actually got this from a php book. I modified it slightly, but not to change it's main goal. I created a small example below that anyone can test. But, I notice that some characters show up as the "encrypted" string. Characters like "=" and "+". Sometimes I pass this encrypted string via the url. Which may not quite make it to my receiving scripts. I'm guessing the browser does something to the string if certain characters are seen. I'm really only guessing. is there another function I can use to ensure the browser doesn't touch the string? or does anyone know enough php bas64_encode() to disallow certain characters from being used? I'm really not going to expect the latter as a possibility. But, I'm sure there's a work-around. enjoy the code, whomever needs it! define('ENCRYPTION_KEY', "sjjx6a"); function encrypt($string) { $result = ''; for($i=0; $i<strlen($string); $i++) { $char = substr($string, $i, 1); $keychar = substr(ENCRYPTION_KEY, ($i % strlen(ENCRYPTION_KEY))-1, 1); $char = chr(ord($char)+ord($keychar)); $result.=$char; } return base64_encode($result)."/".rand(); } function decrypt($string){ $exploded = explode("/",$string); $string = $exploded[0]; $result = ''; $string = base64_decode($string); for($i=0; $i<strlen($string); $i++) { $char = substr($string, $i, 1); $keychar = substr(ENCRYPTION_KEY, ($i % strlen(ENCRYPTION_KEY))-1, 1); $char = chr(ord($char)-ord($keychar)); $result.=$char; } return $result; } echo $encrypted = encrypt("reaplussign.jpg"); echo "<br>"; echo decrypt($encrypted);

    Read the article

  • Dynamic Form Help for PHP and MySQL

    - by Tony
    The code below works as far as inserting records from a file into MySQL, but it only does so properly if the columns in the file are already ordered the same way as in the database. I would like for the user to be able to select the drop down the corresponds to each column in their file to match it up with the columns in the database (the database has email address, first name, last name). I am not sure how to accomplish this. Any ideas? <?php $lines =file('book1.csv'); foreach($lines as $data) { list($col1[],$col2[],$col3[]) = explode(',',$data); } $i = count($col1); if (isset($_POST['submitted'])) { DEFINE ('DB_USER', 'root'); DEFINE ('DB_PASSWORD', 'password'); DEFINE ('DB_HOST', 'localhost'); DEFINE ('DB_NAME', 'csvimport'); // Make the connection: $dbc = @mysqli_connect (DB_HOST, DB_USER, DB_PASSWORD, DB_NAME); for($d=1; $d<$i; $d++) { $q = "INSERT into contacts (email, first, last) VALUES ('$col3[$d]', '$col1[$d]', '$col2[$d]')"; $r = @mysqli_query ($dbc, $q); } } echo "<form action =\"handle2.php\" method=\"post\">Email<br /> <select name =\"email\"> <option value='col1'>$col1[0]</option> <option value='col2'>$col2[0]</option> <option value='col3'>$col3[0]</option> </select><br /><br /> First Name <br /> <select name=\"field2\"> <option value='col1'>$col1[0]</option> <option value='col2'>$col2[0]</option> <option value='col3'>$col3[0]</option> </select><br /><br /> Last Name <br /> <select name=\"field3\"> <option value='col1'>$col1[0]</option> <option value='col2'>$col2[0]</option> <option value='col3'>$col3[0]</option> </select><br /><br /> <input type=\"submit\" name=\"submit\" value=\"Submit\" /> <input type=\"hidden\" name=\"submitted\" value=\"TRUE\" /> </form>"; ?>

    Read the article

  • Php algorithm - How to achieve that without eval

    - by Marcelo
    I have a class that keeps data stores/access data by using words.separated.by.dots keys and it behaves like the following: $object = new MyArray() $object->setParam('user.name','marcelo'); $object->setParam('user.email','[email protected]'); $object->getParams(); /* array( 'user' => array( 'name' => 'marcelo', 'email' => '[email protected]' ) ); */ It is working, but the method unsetParam() was horribly implemented. That happened because i didn't know how to achieve that without eval() function. Although it is working, I found that it was a really challenging algorithm and that you might find fun trying to achieve that without eval(). class MyArray { /** * @param string $key * @return Mura_Session_Abstract */ public function unsetParam($key) { $params = $this->getParams(); $tmp = $params; $keys = explode('.', $key); foreach ($keys as $key) { if (!isset($tmp[$key])) { return $this; } $tmp = $tmp[$key]; } // bad code! $eval = "unset(\$params['" . implode("']['", $keys) . "']);"; eval($eval); $this->setParams($params); return $this; } } The test method: public function testCanUnsetNestedParam() { $params = array( '1' => array( '1' => array( '1' => array( '1' => 'one', '2' => 'two', '3' => 'three', ), '2' => array( '1' => 'one', '2' => 'two', '3' => 'three', ), ) ), '2' => 'something' ); $session = $this->newSession(); $session->setParams($params); unset($params['1']['1']['1']); $session->unsetParam('1.1.1'); $this->assertEquals($params, $session->getParams()); $this->assertEquals($params['1']['1']['2'], $session->getParam('1.1.2')); }

    Read the article

  • Php miniserver downloader bandwidth

    - by snikolov
    $httpsock = @socket_create_listen("9090"); if (!$httpsock) { print "Socket creation failed!\n"; exit; } while (1) { $client = socket_accept($httpsock); $input = trim(socket_read ($client, 4096)); $input = explode(" ", $input); $input = $input[1]; $fileinfo = pathinfo($input); switch ($fileinfo['extension']) { default: $mime = "text/html"; } if ($input == "/") { $input = "index.html"; } $input = ".$input"; if (file_exists($input) && is_readable($input)) { echo "Serving $input\n"; $contents = file_get_contents($input); $output = "HTTP/1.0 200 OK\r\nServer: APatchyServer\r\nConnection: close\r\nContent-Type: $mime\r\n\r\n$contents"; } else { //$contents = "The file you requested doesn't exist. Sorry!"; //$output = "HTTP/1.0 404 OBJECT NOT FOUND\r\nServer: BabyHTTP\r\nConnection: close\r\nContent-Type: text/html\r\n\r\n$contents"; $filename = "dada"; $file = fopen($filename, 'r'); $filesize = filesize($filename); $buffer = fread($file, $filesize); $send = array("Output"=$buffer,"filesize"=$filesize,"filename"=$filename); $file = $send['filename']; $filesize = $send['filesize']; $output = 'HTTP/1.0 200 OK\r\n'; $output .= "Content-type: application/octet-stream\r\n"; $output .= 'Content-Disposition: attachment; filename="'.$file.'"\r\n'; $output .= "Content-Length:$filesize\r\n"; $output .= "Accept-Ranges: bytes\r\n"; $output .= "Cache-Control: private\n\n"; $output .= $send['Output']; $output .= "Content-Transfer-Encoding: binary"; $output .= "Connection: Keep-Alive\r\n"; } socket_write($client, $output); socket_close ($client); } socket_close ($httpsock); Hello i have create a code here to work as a webserver downloader the client can request files and download, i got it working at last however, i would like to know if the webserver can show much bandwidth the user request via sockets, perl has the same option as php but its more hardcore than php, i dont understand much about perl, i even saw that a miniwebserver can show much the client user pulls from the server would it be possible that you can assist me with this coding, i much aprreciate it thank you guys.

    Read the article

  • properies profile when writing word file

    - by avani-nature
    Hai frnds i am new to php i am having following problems in my coding... 1.Actually i am opening word document with com object and storing it in textarea. 2.when content gets opened in textarea i am editing that content and saving the document 3.actually when i edited that file and done save after that if i open word document then file properties-custom the old content getting removed i wannt to retain that even if i edited the word document..please do the needful i am using below code <?php $filename = 'C:/xampp/htdocs/mts/sites/default/files/a.doc'; //echo $filename; if(isset($_REQUEST['Save'])){ $somecontent = stripslashes($_POST['somecontent']); // Let's make sure the file exists and is writable first. if (is_writable($filename)) { // In our example we're opening $filename in append mode. // The file pointer is at the bottom of the file hence // that's where $somecontent will go when we fwrite() it. if (!$handle = fopen($filename, 'w')) { echo "Cannot open file ($filename)"; exit; } // Write $somecontent to our opened fi<form action="" method="get"></form>le. if (fwrite($handle, $somecontent) === FALSE) { echo "Cannot write to file ($filename)"; exit; } echo "Success, wrote ($somecontent) to file ($filename) <a href=".$_SERVER['PHP_SELF']."> - Continue - "; fclose($handle); } else { echo "The file $filename is not writable"; } } else{ // get contents of a file into a string $handle = fopen($filename, "r"); $somecontent = fread($handle, filesize($filename)); $word = new COM("word.application") or die ("Could not initialise MS Word object."); $word->Documents->Open(realpath("$filename")); // Extract content. $somecontent = (string) $word->ActiveDocument->Content; //echo $somecontent; $word->ActiveDocument->Close(false); $word->Quit(); $word = null; unset($word); fclose($handle); } ?> <h6>Edit file --------><? $filenam=explode("/",$filename);$filename=$filename[7]; echo $filename ;?></h6> <form name="form1" method="post" action=""> <p> <textarea name="somecontent" cols="100" rows="20"><? echo $somecontent ;?></textarea> </p> <div style='padding-left:250px;'><input type="submit" name="Save" value="Save"></div> </p> </form> <? } ?>

    Read the article

  • java.util.zip - ZipInputStream v.s. ZipFile

    - by lucho
    Hello, community! I have some general questions regarding the java.util.zip library. What we basically do is an import and an export of many small components. Previously these components were imported and exported using a single big file, e.g.: <component-type-a id="1"/> <component-type-a id="2"/> <component-type-a id="N"/> <component-type-b id="1"/> <component-type-b id="2"/> <component-type-b id="N"/> Please note that the order of the components during import is relevant. Now every component should occupy its own file which should be externally versioned, QA-ed, bla, bla. We decided that the output of our export should be a zip file (with all these files in) and the input of our import should be a similar zip file. We do not want to explode the zip in our system. We do not want opening separate streams for each of the small files. My current questions: Q1. May the ZipInputStream guarantee that the zip entries (the little files) will be read in the same order in which they were inserted by our export that uses ZipOutputStream? I assume reading is something like: ZipInputStream zis = new ZipInputStream(new BufferedInputStream(fis)); ZipEntry entry; while((entry = zis.getNextEntry()) != null) { //read from zis until available } I know that the central zip directory is put at the end of the zip file but nevertheless the file entries inside have sequential order. I also know that relying on the order is an ugly idea but I just want to have all the facts in mind. Q2. If I use ZipFile (which I prefer) what is the performance impact of calling getInputStream() hundreds of times? Will it be much slower than the ZipInputStream solution? The zip is opened only once and ZipFile is backed by RandomAccessFile - is this correct? I assume reading is something like: ZipFile zipfile = new ZipFile(argv[0]); Enumeration e = zipfile.entries();//TODO: assure the order of the entries while(e.hasMoreElements()) { entry = (ZipEntry) e.nextElement(); is = zipfile.getInputStream(entry)); } Q3. Are the input streams retrieved from the same ZipFile thread safe (e.g. may I read different entries in different threads simultaneously)? Any performance penalties? Thanks for your answers!

    Read the article

  • Problem with files consists of spaces and single quotes?

    - by Vijay
    I'using the following code to create thumbnails using ffmpeg but it was working fine for the files which have no spaces or any quotes.. But when the file has a space (like 'sachin knock.flv') or files which have quotes (like sachin's_double_cent.mp4) it doesn't work.. What can i do to get those files work accurately? One restriction is that i can't rename files as they are lump some.. My code is <?php error_reporting(E_ALL); extension_loaded('ffmpeg') or die('Error in loading ffmpeg'); $link = mysql_connect('localhost', 'root', ''); if (!$link) { die('Not connected : ' . mysql_error()); } $db_selected = mysql_select_db('db', $link); $max_width = 120; $max_height = 72; $path ="/home/rootuser/public_html/temp/"; $qry="select id, input_file, output_file from videos where thumbnail='' or thumbnail is null;"; $res=mysql_query($qry); while($row = mysql_fetch_array($res,MYSQL_ASSOC)) { $orig_str = array(" "); $rep_str = array("\ "); $outfile = $row[output_file]; // $infile = $row[input_file]; $infile1 = str_replace($orig_str, $rep_str, $outfile); $tmp = explode(".",$infile1); $tmp_name = $tmp[0]; $imgname = $tmp_name.".png"; $srcfile = "/home/rootuser/public_html/uploaded_vids/".$outfile; echo exec("ffmpeg -i ".$srcfile." -r 1 -ss 00:00:05 -f image2 -s 120x72 ".$path.$imgname); $nname = "./temp/".$imgname; $fileo = fopen($nname,"rb"); if($fileo) { $imgData = addslashes(file_get_contents($nname)); echo $imgdata; $qryy="update videos set thumbnail='{$imgData}' where input_file='$outfile'"; $ress=mysql_query($qryy); } else echo "Could not open<br><br>"; unlink('$nname'); } ?>

    Read the article

  • PHP miniwebsever file download

    - by snikolov
    $httpsock = @socket_create_listen("9090"); if (!$httpsock) { print "Socket creation failed!\n"; exit; } while (1) { $client = socket_accept($httpsock); $input = trim(socket_read ($client, 4096)); $input = explode(" ", $input); $input = $input[1]; $fileinfo = pathinfo($input); switch ($fileinfo['extension']) { default: $mime = "text/html"; } if ($input == "/") { $input = "index.html"; } $input = ".$input"; if (file_exists($input) && is_readable($input)) { echo "Serving $input\n"; $contents = file_get_contents($input); $output = "HTTP/1.0 200 OK\r\nServer: APatchyServer\r\nConnection: close\r\nContent-Type: $mime\r\n\r\n$contents"; } else { //$contents = "The file you requested doesn't exist. Sorry!"; //$output = "HTTP/1.0 404 OBJECT NOT FOUND\r\nServer: BabyHTTP\r\nConnection: close\r\nContent-Type: text/html\r\n\r\n$contents"; function openfile() { $filename = "a.pl"; $file = fopen($filename, 'r'); $filesize = filesize($filename); $buffer = fread($file, $filesize); $array = array("Output"=$buffer,"filesize"=$filesize,"filename"=$filename); return $array; } $send = openfile(); $file = $send['filename']; $filesize = $send['filesize']; $output = 'HTTP/1.0 200 OK\r\n'; $output .= "Content-type: application/octet-stream\r\n"; $output .= 'Content-Disposition: attachment; filename="'.$file.'"\r\n'; $output .= "Content-Length:$filesize\r\n"; $output .= "Accept-Ranges: bytes\r\n"; $output .= "Cache-Control: private\n\n"; $output .= $send['Output']; $output .= "Content-Transfer-Encoding: binary"; $output .= "Connection: Keep-Alive\r\n"; } socket_write($client, $output); socket_close ($client); } socket_close ($httpsock); Hello, I am snikolov i am creating a miniwebserver with php and i would like to know how i can send the client a file to download with his browser such as firefox or internet explore i am sending a file to the user to download via sockets, but the cleint is not getting the filename and the information to download can you please help me here,if i declare the file again i get this error in my server Fatal error: Cannot redeclare openfile() (previously declared in C:\User s\fsfdsf\sfdsfsdf\httpd.php:31) in C:\Users\hfghfgh\hfghg\httpd.php on li ne 29, if its possible, i would like to know if the webserver can show much banwdidth the user request via sockets, perl has the same option as php but its more hardcore than php i dont understand much about perl, i even saw that a miniwebserver can show much the client user pulls from the server would it be possible that you can assist me with this coding, i much aprreciate it thank you guys.

    Read the article

  • adding other parameter to function

    - by Ronnie Chester Lynwood
    hello. i got a function that listing downloads in a table with foreach. it's also lists searched term, search type. public function fetchDownloads($displaySite=true) { $downloads = array(); $sqlWhere = ""; if(isset($this->q)) { if(strlen($this->q) <= $this->recents_length && !empty($this->q)) { $insertRecent = $this->processDataHook("insertRecent",$this->q); if($insertRecent) { if(!@mysql_query("INSERT INTO wcddl_recents (query) VALUES ('".$this->qSQL."')")) { @mysql_query("UPDATE wcddl_recents SET searches = searches+1 WHERE query = '".$this->qSQL."'"); } } } if($this->search_type == "narrow") { $sqlWhere = " WHERE title LIKE '%".mysql_real_escape_string(str_replace(" ","%",$this->q))."%'"; } elseif($this->search_type == "wide") { $qExp = explode(" ",$this->q); $sqlWhere = array(); foreach($qExp as $fq) $sqlWhere[] = "title LIKE '%".mysql_real_escape_string($fq)."%'"; $sqlWhere = implode(" OR ",$sqlWhere); $sqlWhere = " WHERE (".$sqlWhere.")"; } } if(isset($this->type)) { if(!empty($sqlWhere)) { $sqlWhere .= " AND type = '".$this->typeSQL."'"; } else { $sqlWhere = " WHERE type = '".$this->typeSQL."'"; } } $sqlWhere = $this->processDataHook("fetchDownloadsSQLWhere",$sqlWhere); $this->maxPages = mysql_query("SELECT COUNT(*) FROM wcddl_downloads".$sqlWhere.""); $this->maxPages = mysql_result($this->maxPages,0); $this->numRows = $this->maxPages; $this->maxPages = ceil($this->maxPages/$this->limit); $sqlMain = "SELECT id,sid,title,type,url,dat,views,rating FROM wcddl_downloads".$sqlWhere." ORDER BY ".(isset($this->sqlOrder) ? mysql_real_escape_string($this->sqlOrder) : "id DESC")." LIMIT ".$this->pg.",".$this->limit.""; $sqlMain = $this->processDataHook("whileFetchDownloadsSQL",$sqlMain); $sqlMain = mysql_query($sqlMain); $this->processHook("whileFetchDownloads"); while($row = mysql_fetch_assoc($sqlMain)) { if($displaySite) { $downloadSite = mysql_query("SELECT name as sname, url as surl, rating as srating FROM wcddl_sites WHERE id = '".$row['sid']."'"); $downloadSite = mysql_fetch_assoc($downloadSite); $row = array_merge($row,$downloadSite); } $downloads_current = $this->mapit($row,array("stripslashes","strip_tags")); $downloads_current = $this->processDataHook("fetchDownloadsRow",$downloads_current); $downloads[] = $downloads_current; } $this->pageList = $this->getPages($this->page,$this->maxPages); $this->processHook("endFetchDownloads"); return $downloads; } I want to add if $_REQUEST['site'] is set, order downloads by sname that catching from wcddl_sites.

    Read the article

  • PHP Parse Error unexpected '{'

    - by Laxmidi
    Hi, I'm getting a "Parse error: syntax error, unexpected '{' in line 2". And I don't see the problem. <?php class pointLocation {     var $pointOnVertex = true; // Check if the point sits exactly on one of the vertices     function pointLocation() {     }                   function pointInPolygon($point, $polygon, $pointOnVertex = true) {         $this->pointOnVertex = $pointOnVertex;                  // Transform string coordinates into arrays with x and y values         $point = $this->pointStringToCoordinates($point);         $vertices = array();          foreach ($polygon as $vertex) {             $vertices[] = $this->pointStringToCoordinates($vertex);          }                  // Check if the point sits exactly on a vertex         if ($this->pointOnVertex == true and $this->pointOnVertex($point, $vertices) == true) {             return "vertex";         }                  // Check if the point is inside the polygon or on the boundary         $intersections = 0;          $vertices_count = count($vertices);              for ($i=1; $i < $vertices_count; $i++) {             $vertex1 = $vertices[$i-1];              $vertex2 = $vertices[$i];             if ($vertex1['y'] == $vertex2['y'] and $vertex1['y'] == $point['y'] and $point['x'] > min($vertex1['x'], $vertex2['x']) and $point['x'] < max($vertex1['x'], $vertex2['x'])) { // Check if point is on an horizontal polygon boundary                 return "boundary";             }             if ($point['y'] > min($vertex1['y'], $vertex2['y']) and $point['y'] <= max($vertex1['y'], $vertex2['y']) and $point['x'] <= max($vertex1['x'], $vertex2['x']) and $vertex1['y'] != $vertex2['y']) {                  $xinters = ($point['y'] - $vertex1['y']) * ($vertex2['x'] - $vertex1['x']) / ($vertex2['y'] - $vertex1['y']) + $vertex1['x'];                  if ($xinters == $point['x']) { // Check if point is on the polygon boundary (other than horizontal)                     return "boundary";                 }                 if ($vertex1['x'] == $vertex2['x'] || $point['x'] <= $xinters) {                     $intersections++;                  }             }          }          // If the number of edges we passed through is even, then it's in the polygon.          if ($intersections % 2 != 0) {             return "inside";         } else {             return "outside";         }     }               function pointOnVertex($point, $vertices) {         foreach($vertices as $vertex) {             if ($point == $vertex) {                 return true;             }         }          }                   function pointStringToCoordinates($pointString) {         $coordinates = explode(" ", $pointString);         return array("x" => $coordinates[0], "y" => $coordinates[1]);     }           } $pointLocation = new pointLocation(); $points = array("30 19", "0 0", "10 0", "30 20", "11 0", "0 11", "0 10", "30 22", "20 20"); $polygon = array("10 0", "20 0", "30 10", "30 20", "20 30", "10 30", "0 20", "0 10", "10 0"); foreach($points as $key => $point) { echo "$key ($point) is " . $pointLocation->pointInPolygon($point, $polygon) . "<br>"; } ?> Does anyone see the problem? Thanks, -Laxmidi

    Read the article

  • Does CakePHP treat all INT fields as ID's for join tables?

    - by Jonnie
    I am trying to save a User, their Profile, and some tags and my join table that links the profile and the tags keeps getting messed up. The profile model is called Instructor, the tag model is called Subject. The Instructor has a phone number and a zip code and for some reason CakePHP thinks these are the fields it should use when creating entries in my join table. My Join table always comes out as: id | instructor_id | subject_id | 1 | 90210 | 1 | // thinks that the zip code is an instructor_id 2 | 1112223333 | 1 | // thinks that the phone number is an instructor_id 3 | 1 | 1 | // thinks that user_id is an instructor_id 4 | 1 | 1 | // the actual instructor_id, this one's correct 5 | 90210 | 2 | 6 | 1112223333 | 2 | 3 | 1 | 2 | 4 | 1 | 2 | My Models: class Instructor extends AppModel { var $name = 'Instructor'; var $belongsTo = array('User', 'State'); var $hasAndBelongsToMany = array( 'Subject' = array( 'className' = 'Subject', 'joinTable' = 'instructors_subjects', 'foreignKey' = 'instructor_id', 'associationForeignKey' = 'subject_id', 'unique' = true, 'conditions' = '', 'fields' = '', 'order' = '', 'limit' = '', 'offset' = '', 'finderQuery' = '', 'deleteQuery' = '', 'insertQuery' = '' ) ); } class Subject extends AppModel { var $name = 'Subject'; var $hasAndBelongsToMany = array( 'Instructor' = array( 'className' = 'Instructor', 'joinTable' = 'instructors_subjects', 'foreignKey' = 'subject_id', 'associationForeignKey' = 'instructor_id', 'unique' = true, 'conditions' = '', 'fields' = '', 'order' = '', 'limit' = '', 'offset' = '', 'finderQuery' = '', 'deleteQuery' = '', 'insertQuery' = '' ) ); } My Model Associations: User hasOne Instructor Instructor belongsTo User Instructor hasAndBelongsToMany Subject Subject hasAndBelongsToMany Instructor My form data looks like: Array ( [User] = Array ( [username] = MrInstructor [password] = cddb06c93c72f34eb9408610529a34645c29c55d [group_id] = 2 ) [Instructor] = Array ( [name] = Jimmy Bob [email] = [email protected] [phone] = 1112223333 [city] = Beverly Hills [zip_code] = 90210 [states] = 5 [website] = www.jimmybobbaseballschool.com [description] = Jimmy Bob is an instructor. [user_id] = 1 [id] = 1 ) [Subject] = Array ( [name] = hitting, pitching ) ) My function for processing the form looks like: function instructor_register() { $this-set('groups', $this-User-Group-find('list')); $this-set('states', $this-User-Instructor-State-find('list')); if (!empty($this-data)) { // Set the group to Instructor $this-data['User']['group_id'] = 2; // Save the user data $user = $this-User-save($this-data, true, array( 'username', 'password', 'group_id' )); // If the user was saved, save the instructor's info if (!empty($user)) { $this-data['Instructor']['user_id'] = $this-User-id; $instructor = $this-User-Instructor-save($this-data, true, array( 'user_id', 'name', 'email', 'phone', 'city', 'zip_code', 'state_id', 'website', 'description' )); // If the instructor was saved, save the rest if(!empty($instructor)) { $instructorId = $this-User-Instructor-id; $this-data['Instructor']['id'] = $instructorId; // Save each subject seperately $subjects = explode(",", $this-data['Subject']['name']); foreach ($subjects as $_subject) { // Get the correct subject format $_subject = strtolower(trim($_subject)); $this-User-Instructor-Subject-create($this-data); $this-User-Instructor-Subject-set(array( 'name' = $_subject )); $this-User-Instructor-Subject-save(); echo ''; print_r($this-data); echo ''; } } } } }

    Read the article

  • Wordpress Events List Date Problem

    - by Roger
    Hi, I'm having a problem displaying events in the correct order in wordpress. I think the problem is because wordpress is treating the date as a string and ordering it by the day because it's in british date format. The goal is to display a list of future events with the most current event at the top of the list. But I must use the british date format of dd/mm/yyyy. Do I need to go back to the drawing board or is there a way of converting the date to achieve the result I need? Thanks in advance :) <ul> <?php // Get today's date in the right format $todaysDate = date('d/m/Y');?> <?php query_posts('showposts=50&category_name=Training&meta_key=date&meta_compare=>=&meta_value=' . $todaysDate . '&orderby=meta_value&order=ASC'); ?> <?php if (have_posts()) : while (have_posts()) : the_post(); ?> <li> <h3><a href="<?php the_permalink(); ?>"> <?php the_title(); ?> </a></h3> <?php $getDate = get_post_meta($post->ID, 'date', TRUE); $dateArray = explode('/', $getDate); ?> <?php if($getDate != '') { ?> <div class="coursedate rounded"><?php echo date('d F Y', mktime(0, 0, 0, $dateArray[1], $dateArray[0], $dateArray[2])); ?></div> <?php } ?> <p><?php get_clean_excerpt(140, get_the_content()); ?>...</p> <p><strong><a class="link" href="<?php the_permalink(); ?>">For further details and booking click here</a></strong></p> </li> <?php endwhile; ?> <?php else : ?> <li>Sorry, no upcoming events!</li> <?php endif; ?>

    Read the article

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