Jump to content

mentalist

Members
  • Posts

    291
  • Joined

  • Last visited

  • Days Won

    1

mentalist last won the day on October 27 2013

mentalist had the most liked content!

Profile Information

  • Gender
    Not Telling

mentalist's Achievements

Member

Member (2/5)

1

Reputation

  1. Hi, I'm sort of up-skilling this week and am playing with Zend... I'm after the quickest n simplest way to get going, for now... (ideally install local to project, so can test over time with diff versions etc...?) To start with I followed the full instructions here: https://framework.zend.com/downloads Which were basically: composer require zendframework/zendframework I executed that within a directory within (say) public_html (no virtual hosts here! /var/www/html/demo/) Is that right, or am I supposed to install that in a non public directory? Where usual (CentOS 7)? Is the next step to create a project, like this: https://framework.zend.com/downloads/skeleton-app composer create-project -n -sdev zendframework/skeleton-application path/to/install i.e. is this in the same directory as before, or in its own public directory, etc? All tips welcome Thanks
  2. But because there are two forms on the page, I feel have to use the # id identifier too? My problem seems to be that both forms use the first forms' current values, whereas the second form should use its own values.
  3. This should be really simple... basically its a class which generates a search / filter form for a list. If I just use it once this works fine, but when I try to do two implementations the second form uses the information from the first form. See in the "this.view_recalc" function in the "GET SELECT OPTION" part: <!doctype html> <head> <script src="jquery-1.11.2.min.js"></script> <style> td{vertical-align:top;} .myform{border:1px solid black;} .mylist{border:1px solid red;} .mylist .nub_items_title,.mylist .nub_items{} .mylist .nub_items_title:after,.mylist .nub_items:after{content:'';display:block;clear:both;} .mylist span[itemprop="title"]{width:100px;float:left;font-weight:bold;} .mylist span[itemprop="name"]{width:100px;float:left;} .mylist span[itemprop="type"]{width:100px;float:left;} .mylist span[itemprop="logo"]{width:100px;float:left;} } </style> <script> var listfilter = function (id_form,id_list,v) { var self = this; this.idname = id_form; this.idlist = id_list; //this.vals = v; var vals = v; this.init = function(){ console.log('Initialising list: '+this.idname); this.add_form(); } this.add_form = function(){ //console.log('Initialising list: '+this.idname); // CREATE FORM var data = "<form class='nub_list_form'>"; for(i=0;i<vals.length;i++){ data += "<select class='target_nublist' name='"+vals[i][0]+"' />"; } data += "</form>"; // ADD FORM $("#"+this.idname+"").each(function(i){ $(this).html("hello: "+data); }); // GET FORM HANDLE var obj_form = $("#"+this.idname+" form")[0]; // LOOP ITEMS for(i=0;i<vals.length;i++){ // GET & FILL SELECT var o = $(obj_form).children("select[name='"+vals[i][0]+"']");//[0]; // [0]; for (j = 0; j < v[i][2].length; j++){ $(o).append($('<option/>', { value: vals[i][2][j][0], text : vals[i][2][j][1] })); } // SET DEFAULT / SELECTED $(obj_form).children("select[name='"+vals[i][0]+"']").val(vals[i][1]); } // ADD CHANGE HANDLERS $(obj_form).children("select").change(function(){ // REDRAW self.view_recalc(); }); } this.view_recalc = function(){ var vt = vals; //alert("#"+self.idlist+" .nub_items"); // LOOP ITEMS $("#"+self.idlist+" .nub_items").each(function(i){ var o=this; var flag = 0; for(i=0;i<vt.length;i++){ // GET SELECT OPTION //var v = $("#"+this.idlist+" select[name='"+this.vals[i][0]+"']").val(); //var v = $("#"+self.idlist+" select[name='"+vt[i][0]+"']").val(); //var v = $("#"+self.idlist+" select[name='"+vt[i][0]+"']").val(); //var v = $(o+" select[name='"+vt[i][0]+"']").val(); var v = $("select[name='"+vt[i][0]+"']").val(); /*var v = "Any"; $(this).find("select[name='"+vt[i][0]+"']").each(function(ii){ v=$(o).val(); });*/ /*var v = "Any"; $(this).children("select[name='"+vt[i][0]+"']").each(function(ii){ v=$(this).val(); });*/ if(v!="Any"){ // SEARCH $(this).find('span').each(function(ii){ if($(this).attr('itemprop')==vt[i][0]){ if($(this).text()==v){ flag+=1; //return false; // break; } } }); }else{ // PASS flag+=1; } } // DECIDE if(flag==vt.length){ $(this).css("display","block"); }else{ $(this).css("display","none"); } }); } }; $(function() { var listfilter1 = new listfilter('myform1','mylist1', [ ["type","Female",[["Any","All"],["Male","Men"],["Female","Woman"]]], ["name","Bob",[["Any","All"],["Alice","Alice"],["Bob","Bob"]]], ["logo","Logo B",[["Any","All"],["Logo A","Logo aa"],["Logo B","Logo bb"],["Logo C","Logo cc"]]] ]); var listfilter2 = new listfilter('myform2','mylist2', [ ["type","Female",[["Any","All"],["Male","Men"],["Female","Woman"]]], ["name","Bob",[["Any","All"],["Alice","Alice"],["Bob","Bob"]]], ["logo","Any",[["Any","All"],["Logo A","Logo aa"],["Logo B","Logo bb"],["Logo C","Logo cc"]]] ]); listfilter1.init(); listfilter2.init(); }); </script> </head> <body> <table><tr><td style='width:240px;'> <div id='myform1' class='myform'> </div> <div id='myform2' class='myform'> </div> </td> <td style=''> <div id='mylist1' class='mylist'> <div class='nub_items_title'> <span itemprop='title'>Title</span> <span itemprop='name'>Name</span> <span itemprop='type'>Type</span> <span itemprop='logo'>Logo</span> </div> <div class='nub_items'> <span itemprop='title'>Miss</span> <span itemprop='name'>Alice</span> <span itemprop='type'>Female</span> <span itemprop='logo'>Logo A</span> </div> <div class='nub_items'> <span itemprop='title'>Mr</span> <span itemprop='name'>Bob</span> <span itemprop='type'>Male</span> <span itemprop='logo'>Logo B</span> </div> <div class='nub_items'> <span itemprop='title'>Mz</span> <span itemprop='name'>Eve</span> <span itemprop='type'>Female</span> <span itemprop='logo'>Logo C</span> </div> </div> <div id='mylist2' class='mylist'> <div class='nub_items_title'> <span itemprop='title'>Title</span> <span itemprop='name'>Name</span> <span itemprop='type'>Type</span> <span itemprop='logo'>Logo</span> </div> <div class='nub_items'> <span itemprop='title'>Miss</span> <span itemprop='name'>Alice</span> <span itemprop='type'>Female</span> <span itemprop='logo'>Logo A</span> </div> <div class='nub_items'> <span itemprop='title'>Mr</span> <span itemprop='name'>Bob</span> <span itemprop='type'>Male</span> <span itemprop='logo'>Logo B</span> </div> <div class='nub_items'> <span itemprop='title'>Mz</span> <span itemprop='name'>Eve</span> <span itemprop='type'>Female</span> <span itemprop='logo'>Logo C</span> </div> </div> </td> </tr> </table> <div style='clear:both;'></div> <br /><br /> <a href='index.html'>INDEX</a> <br /><br /> </div> </body> </html> Thanks
  4. Does anybody know why this code is adding itself (i.e. an empty zip file of same name, full path) to the zip file? $fn="data/test_01.zip"; $zip = new ZipArchive(); if($zip->open($fn,ZipArchive::OVERWRITE)!==TRUE){ echo "cannot open ".$fn; } $zip->addFromString("myfile.txt","Some content"); $zip->addEmptyDir("testdir"); $zip->close(); I've fully updated my system and restarted services
  5. That was my sentiment last night, not enough code to replicate the issue...
  6. I have this accordion code from somewhere, however when you come from the right hand-side all the elements shrink even though you're over the purple / last one... How to fix please? The CSS: <style> .accordionH { margin: 30px auto; padding: 0; list-style-type: none; overflow: hidden; width: 800px; height: 200px; } .accordionH li { margin: 0; padding: 0; overflow: hidden; -webkit-backface-visibility: hidden; backface-visibility: hidden; -webkit-transition: all 0.2s ease-in; -moz-transition: all 0.2s ease-in; transition: all 0.2s ease-in; } .accordionH li { width: 160px; height: 200px; float: left; } .accordionH:hover li { width: 50px; } .accordionH li:hover { width: 600px; } </style> The HTML: <ul class="accordionH"> <li style="background-color:#f00;"> <p>Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.</p> </li> <li style="background-color:#0f0;"> <p>Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.</p> </li> <li style="background-color:#00f;"> <p>Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.</p> </li> <li style="background-color:#0ff;"> <p>Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.</p> </li> <li style="background-color:#f0f;"> <p>Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.</p> </li> </ul> Also, the purple one flickers at times, especially when bringing the mouse in from the top or bottom? Supposedly "backface-visibility" is supposed to fix it, or suggested was to use 3D transition instead, but prefer not...!? Cheers
  7. Burgers got in the way yum yum function do_incode($s){ $a=array("blog"); foreach($a as $e){ $re="/\[".$e."(.+?)\]/"; if(preg_match_all($re, $s, $matches, PREG_OFFSET_CAPTURE | PREG_SPLIT_NO_EMPTY)){ $n=0; foreach($matches[0] as $ee){ //$va=str_getcsv(trim($matches[1][$n][0])," "); $re='/"(.*?)"|(=)|\'(.*?)\'| +/'; $va=preg_split($re, trim($matches[0][$n][0],"[]"), -1, PREG_SPLIT_DELIM_CAPTURE | PREG_SPLIT_NO_EMPTY); $replace=blog_incode($va); $re="/".preg_quote($ee[0])."/"; $s=preg_replace($re,$replace,$s,1); // USE 1 TO LIMIT TO FIRST MATCH, FOR DUPLICATES...??? $n++; } } } return $s; } Good enough for now... Cheers for pointing out my daftness lol
  8. In reality it can of arbitrary length and either quoted or not, or even nothing at all. It does work as required when " are used, its just the ' case which doesn't...... Oops forgot that was the reason it was extracting the strings... no wonder the regex wasn't acting as expected I'll be back ... thankyou
  9. Hi, this works with double quotes but fails on single quotes... I've been stuck on the wrong issue for a while so my heads boxed now lol Any help much appreciated. //$s='Test string [blog "xx yy" zz] one two three'; $s="Test string [blog 'xx yy' zz] one two three"; echo do_incode($s); function do_incode($s){ $a=array("blog"); foreach($a as $e){ $re="/\[".$e."(.+?)\]/"; //$re='/\['.$e.'"(?:\\\\.|[^\\\\"])*"|\S+\]/'; //$re='/\['.$e.' (`"([^"]*)"`)\]/'; if(preg_match_all($re, $s, $matches, PREG_OFFSET_CAPTURE)){ //$func=$this->api_register_get($e,'incode'); $n=0; foreach($matches[0] as $ee){ $va=str_getcsv(trim($matches[1][$n][0])," "); //$replace=$func($va); $replace=blog_incode($va); $re="/".preg_quote($ee[0])."/"; $s=preg_replace($re,$replace,$s,1); // USE 1 TO LIMIT TO FIRST MATCH, FOR DUPLICATES...??? $n++; } } } return $s; } function blog_incode($v){ //$s="<b>*** INCODE [ :".$v[0].": ".(isset($v[1])?$v[1]:"")." ] WORKED ***</b>"; $s="<b>*** INCODE [ :".$v[0].": ] WORKED ***</b>"; return $s; }
  10. I also needed the default count to be 0 to make the ordering correct, again COALESCE came in handy: $sql="SELECT t1.id,t1.post,t1.uid,t2.uname,COALESCE(SUM(num),0) AS n FROM ".$tn." AS t1 LEFT OUTER JOIN ".$tn2." AS t2 ON t1.uid=t2.id LEFT OUTER JOIN ".$tn3." AS t3 ON t1.id=t3.pid GROUP BY COALESCE(t3.pid,t1.id) ORDER BY n DESC ";
  11. Ooooh... $sql="SELECT t1.id,t1.post,t1.uid,t2.uname,SUM(num) as n FROM ".$tn." AS t1 LEFT OUTER JOIN ".$tn2." AS t2 ON t1.uid=t2.id LEFT OUTER JOIN ".$tn3." AS t3 ON t1.id=t3.pid GROUP BY COALESCE(t3.pid,t1.id) "; I think the COALESCE did the trick...
  12. I've made this into a demo, basically there's 3 tables, one which has posts, the second is user info and the third holds rating information. I'm after bringing back all the posts (with username) and their rating. However some posts have no rating, and those get grouped together and come back as one, how to stop that from happening. I've also tried UNION, UNION ALL, but am either getting it wrong or its not doing what I'm expecting it too. To recap, return all posts individually and not group the posts without ratings. Cheers <?php echo "<h2>TESTS</h2>"; include("db.php"); // DB SETUP $prefix="tests_"; $host="localhost"; $uname="user"; $pass="password"; $dbname="dbtest"; $db=new cDB($prefix,$host,$uname,$pass,$dbname); // INSTALL do_install($db); // GET TABLE $tn=$db->prefix."post"; // id,post,uid $tn2=$db->prefix."user"; // id,uname $tn3=$db->prefix."rate"; // id,pid,num $sql="SELECT t1.id,t1.post,t1.uid,t2.uname,SUM(num) as n FROM ".$tn." AS t1 LEFT OUTER JOIN ".$tn2." AS t2 ON t1.uid=t2.id LEFT OUTER JOIN ".$tn3." AS t3 ON t1.id=t3.pid GROUP BY t3.pid "; $a=$db->raw($sql); echo "<table>"; foreach($a as $e){ echo "<tr><td>".$e['id']."</td><td>".$e['post']."</td><td>".$e['uname']."</td><td>".$e['n']."</td></tr>\n"; } echo "</table>"; function do_install($db){ // tests_post $tn=$db->prefix."post"; // id,post,uid $s="`id` INT NOT NULL AUTO_INCREMENT PRIMARY KEY, `post` TEXT NOT NULL, `uid` INT NOT NULL"; $db->table_drop($tn); $db->table_create($tn, $s); $db->table_insert($tn, "'','Tell me all about it',1"); // 1 $db->table_insert($tn, "'','I bet its interesting',2"); // 2 $db->table_insert($tn, "'','Today is yesterday tomorrow',3"); // 3 $db->table_insert($tn, "'','Tomorrow is yesterday in a couple of days',4"); // 4 $db->table_insert($tn, "'','Another day is yet to pass',1"); // 5 $db->table_insert($tn, "'','Another day is yet to pass again',1"); // 6 // tests_user $tn=$db->prefix."user"; // id,uname $s="`id` INT NOT NULL AUTO_INCREMENT PRIMARY KEY, `uname` VARCHAR(32) NOT NULL"; $db->table_drop($tn); $db->table_create($tn, $s); $db->table_insert($tn, "'','Alice'"); // 1 $db->table_insert($tn, "'','Bob'"); // 2 $db->table_insert($tn, "'','Carol'"); // 3 $db->table_insert($tn, "'','Derrick'"); // 4 // tests_rate $tn=$db->prefix."rate"; // id,pid,num $s="`id` INT NOT NULL AUTO_INCREMENT PRIMARY KEY, `pid` INT NOT NULL, `num` INT NOT NULL"; $db->table_drop($tn); $db->table_create($tn, $s); $db->table_insert($tn, "'',1,1"); $db->table_insert($tn, "'',2,-1"); $db->table_insert($tn, "'',1,1"); $db->table_insert($tn, "'',3,1"); $db->table_insert($tn, "'',4,1"); $db->table_insert($tn, "'',4,-1"); $db->table_insert($tn, "'',1,1"); $db->table_insert($tn, "'',3,-1"); /* 1: 1,1,1=3 2: -1=-1 3: 1,-1=0 4: 1,-1=0 */ } ?>
  13. You seem to be loading the files using a filename and not with saved data?
  14. My main issue is how to read image data from a database into GD using imagecreatefromstring()or similar. I have an upload mechanism in place which stores images (and files) into a database entry, and allows viewing (not shown). 1. File upload handling and DB storage function: function do_upload($db,$tag,$uid,$plugin,$path,$redirect=true,$fn=""){ if(isset($_POST[$tag]) && $_FILES['userfile']['size'] > 0){ // GET UPLOAD INFO $fileName = $_FILES['userfile']['name']; $tmpName = $_FILES['userfile']['tmp_name']; $fileSize = $_FILES['userfile']['size']; $fileType = $_FILES['userfile']['type']; // READ TEMP FILE $fp = fopen($tmpName, 'r'); $content = fread($fp, filesize($tmpName)); $content = addslashes($content); fclose($fp); // DETAILS if($fn!=""){ $fileName=$fn; } if(!get_magic_quotes_gpc()){ $fileName = addslashes($fileName); } $fullpath=$plugin."/".$path."/".$fileName; $ref=md5($uid.$fileName.time()); // STORE TO DB $tn=$db->prefix."datastore"; // id,uid,plugin,ref,name,path,fullpath,type,size,data,visible,status,force $a=$db->table_get($tn,"fullpath='".$fullpath."'"); if(count($a)>0){ // UPDATE ENTRY $db->table_update($tn,"type='".$fileType."', size='".$fileSize."', data='".$content."'","id=".$a[0]['id']); }else{ // CREATE ENTRY $db->table_insert($tn, "'',".$uid.",'".$plugin."','".$ref."','".$fileName."', '".$path."', '".$fullpath."', '".$fileType."', '".$fileSize."', '".$content."',1,1,0"); } if($redirect){ // REDIRECT TO CLEAR header("Location: ".rx_path_self()); exit(); } } } Next I try to feed the image data into GD: $a=$db->table_get($tn,"fullpath='tmp/tmp/img.png'"); if(count($a)>0){ $e=$a[0]; $img2 = imagecreatefromstring(stripslashes($e['data'])); I've tried it with and without stripslashes, decode64, etc... How to read stored data into GD?
  15. Thankyou I only seem to be getting a single group (also the COUNT indicates that too), so i'm going to have my supper and then build a demo to test properly and get to grips with it all.
×
×
  • Create New...

Important Information

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