Jump to content

Hybride

Members
  • Posts

    286
  • Joined

  • Last visited

About Hybride

  • Birthday December 3

Contact Methods

  • MSN
    hybridephantom@hotmail.com
  • Website URL
    http://anekyu.com/
  • Yahoo
    hybride_phantom

Profile Information

  • Gender
    Not Telling

Hybride's Achievements

Member

Member (2/5)

0

Reputation

  1. Am currently trying to develop a SaaS, where each user gets their own subdomain with their application. Am wondering, though, with installation and subsequent updates: What is the best way to initiate an installation? The project is currently in a git repository. Is it better to simply pull the master branch per installation; or is zipping up the master branch, copying it to the new subdomain, then running the installation a better (secure?) method? What is the best way to initiate an update of code? If using the git repo, hat would deal with updated code, but not updated MySQL tables. Should the user be allowed to choose to update (so much like W$, a popup shows up that says there's an update; user can choose to update or ignore); or should all updates be forced (such as at a certain time)? I haven't seen much online with my searches, but I may be blind at this point. Any thoughts/comments appreciated!
  2. I have a multi-dimensional array (something as below). What am trying to do is find a specific value, and if that value has children, list only those children. So for example, if am searching for slug's "test", then all of "test's" children list on the page. "Test2" has no children, so none listed. If am searching for "/test/sub" (the slug), and since it has children, I wanted to show all of the children (eg. "sh", "rd", "co"). I have only a code for checking a multi-dimensional array, but am lost as to how to go beyond that. function in_array_r($needle, $haystack, $strict = true) { foreach ($haystack as $item) { if (($strict ? $item === $needle : $item == $needle) || (is_array($item) && in_array_r($needle, $item, $strict))) { return true; } } return false; } Array ( [test] => Array ( [children] => Array ( [2] => Array ( [parent] => 4 [title] => Sub [slug] => test/sub/ [id] => 2 [children] => Array ( [3] => Array ( [parent] => 2 [title] => sh [slug] => test/sub/sh [id] => 3 ) [27] => Array ( [parent] => 2 [title] => RD [slug] => test/sub/rd [id] => 27 ) [145] => Array ( [parent] => 2 [title] => cO [slug] => test/sub/co [id] => 145 ) ) ) [8] => Array ( [parent] => 4 [title] => sub2 [slug] => test/sub2 [id] => 8 ) [19] => Array ( [parent] => 4 [title] => sub3 [slug] => test/sub3 [id] => 19 [children] => Array ( [20] => Array ( [parent] => 19 [title] => child1 [slug] => test/sub3/child1 [id] => 20 ) [21] => Array ( [parent] => 19 [title] => child2 [slug] => test/sub3/child2 [id] => 21 ) ) )
  3. I figured it out, not sure if this is a bit brutish, so I would love a more elegant answer if possible: // and published = '1' //true $refs = array(); $list = array(); $result = full_query("SELECT id,title,slug,parent FROM `pages` WHERE title!='404' AND slug!='404'"); while($data = mysql_fetch_assoc($result)) { $thisref = &$refs[$data['id']]; $thisref['parent'] = $data['parent']; $thisref['title'] = $data['title'] = pages_data_lang2(unserialize($data['title'])); $thisref['slug'] = $data['slug']; $thisref['id'] = $data['id']; if($data['parent'] == 0) { $list[$data['title']] = &$thisref; } else { $refs[$data['parent']]['children'][$data['id']] = &$thisref; } } print "<div id='topmenu'><ul>"; foreach($list as $keys => $var) { if(($var['id'] == 4) || ($var['id'] == 6) || ($var['id'] == 7) || ($var['id'] == 11)) { print "<li><a href='".$var['slug']."'>$keys</a><ul>"; foreach($var['children'] as $vkey=>$vvar) { print "<li><a href='".$vvar['slug']."'>".$vvar['title']."</a></li>"; } print "</ul>"; } } echo "</ul></div>";
  4. I have a table that I want to create into a horizontal menu using lists/CSS in my header. I have the code that creates the menu, I just can't figure out the foreach loops to actually generate the menu. $refs = array(); $list = array(); $result = full_query("SELECT id,title,slug,parent FROM `page`"); while($data = mysql_fetch_assoc($result)) { $thisref = &$refs[$data['id']]; $thisref['parent'] = $data['parent']; $thisref['title'] = unserialize($data['title']); $thisref['slug'] = $data['slug']; if($data['parent'] == 0) { $list[$data['id']] = &$thisref; } else { $refs[$data['parent']]['children'][$data['id']] = &$thisref; } } // can't figure this part out foreach($list as $keys => $var) { foreach($var as $vkey => $vvar) { if(isset($vkey['children'])) { print $vkey; } } } Which, with my current data, results in this array: Array ( [4] => Array ( [children] => Array ( [1] => Array ( [parent] => 4 [title] => Child1 [id] => 1 [slug] => child1 ) ) [parent] => [title] => Parent1 [id] => 4 [slug] => parent1 ) [6] => Array ( [children] => Array ( [2] => Array ( [parent] => 6 [title] => child2 [id] => 2 [slug] => child2 ) [3] => Array ( [parent] => 6 [title] => child3 [id] => 3 [slug] => child3 ) [8] => Array ( [parent] => 6 [title] => child4 [id] => 8 [slug] => child4 ) ) [parent] => [title] => Parent2 [id] => 6 [slug] => parent2 ) [7] => Array ( [parent] => [title] => Parent3 [id] => 7 [slug] => parent3 ) [9] => Array ( [parent] => [title] => Parent4 [id] => 9 [slug] => parent4 ) ) Am trying to get the foreach to do this: Parent1 Child1 Parent2 Child2 Child3 Child4 Parent3 Parent4 But horizontally. Any help is greatly appreciated!
  5. Thanks, Psycho! I actually changed my regex to this: \^(.*)(|( )) And for now, looks like it's working. The '^' is at the beginning of each line that I need to do the regex on, but &nbsp may or may not be there (could be just a line break). Realizing this, I modded to include two '^' in case anyone used it within a paragraph (such as '^test this^'). The regex for that is ((\^(.*)\^))|\^(.*)(|( ))|
  6. I have a WYSIWYG editor that converts the text to HTML format after submitting. I have text that looks like this: Which would get converted to something ugly like this: <p> Test with:<br /> ^blah blah/XLR <br /> ^Another test/? <br /> Synonyms <br /> Some Syndrome <br /> ^ED test syndrome<br /> Synonyms/acronyms<br /> Test<br /> ^Another</p> Doing this regex \^(.*) Gets me the ^words that I need, but also gets me the &nbsps that I don't on the right hand side. How can I modify the regex to only get before and not including the ?
  7. Hi everyone, I have a file filled with categories (about 100K or so lines), each one by indentation (for illustration purposes, I added + instead). What am trying to is upload this file, and have it input into my table so jsTree can render it correctly. It correctly inserts most of the lines, but starts to get confused when reverting back to previous lines (in the above example, it will insert up to file 5 correctly, then get lost on the left/right on File 2.) Am using jsTree's create_node, but not sure why the render is failing? My (rather brute-force) upload script is below: $dataFile = fopen($file_dir . basename($_FILES['uploaded']['name']), "rb"); while (!feof($dataFile)) { $lines = array(); while (($line = fgets($dataFile)) !== false) { array_push($lines, rtrim($line)); } $count = count($lines); $res = preg_replace('/\t/i', "|", $lines); $final = preg_replace("/\s(\W)[^\w]/i", "|", $res); $i = 0; foreach($final as $string) { //$parent_id = $delimiter_count - 1; $delimiter_count = substr_count($string, '|'); //level $left = $i + 1; $right = $left + 1; preg_match("/(\|+)(\w.+)/i", $string, $match); if(isset($match[2])) { /* even this doesn't work, if I directly inject it into the tree $insert = $keysdb->query("INSERT INTO tree (`parent_id`, `position`, `left`, `right`, `level`, `title`, `type`, `post_syn_epon`, `post_author_id`) VALUES('$delimiter_count',0,'$left','$right','$delimiter_count','$match[2]','default','$match[2], ','user_id')"); */ $jstree->create_node(array( "id" => "$delimiter_count", "position" => 0, "title" => "$match[2]", "type" => "default" )); if(!$insert) { print "Failed!" . $keysdb->error; } } $i++; } } // all done close the file fclose($dataFile);
  8. I can't see the PHP code, but what it does look like to me is you printed out the pages before the "Next" in the first page; and after the Previous on the second.
  9. Ok, am fascinated - 1/2 the code, and works. Could you please explain what you did?
  10. What do you mean "what the other 5 should be set as"? If you want the other 5 to do as the same 1st one, why don't you just copy the layout/style/code of the first heading under the other ones?
  11. That's very not nice of you to talk that way to someone trying to help you - be respectful. In any case, you're not submitting the form when you press submit, your "if(isset)" is asking if there is a variable called "$_POST['recordPurchaseState']))". Change it to taking the "isset" of the submit button, and your form should submit correctly.
  12. I knew it was something simple! <input type='radio' name='select_degree' value='1' onChange='chooseDeg();document.getElementById("choosedestiny").submit()'>Undergraduate</input> I submit the form id automatically on change. Am sure there's a bit cleaning up to do, but that little line of voodoo/magic did what I needed to happen.
  13. I tried your suggestions, and started going in the right direction, but still have some issues. I changed the onClick to onChange now (I didn't realize CGI didn't allow -onChange for radios): sub chooseDegree{ my $radios = <<END; <input type='radio' name='select_degree' value='1' onChange='chooseDeg()'>Undergraduate</input> <input type='radio' name='select_degree' value='2' onChange='chooseDeg()'>Graduate</input> END print $radios; } And then I switched the JQuery a tad bit: function chooseDeg() { $(".msg_body").hide(); //will keep it from appending 2x var select_degree = $('input[name=select_degree]:checked').val(); $('.msg_body').toggle('slow', function() { $.ajax({ type: "POST", url: "../../functions.pl", // URL of the Perl script contentType: "application/json; charset=utf-8", dataType: "html", data: "select_degree=" + select_degree, // script call was *not* successful error: function(XMLHttpRequest, textStatus, errorThrown) { alert("Can't grab the degree - try again."); }, // error // script call was successful // data contains the JSON values returned by the Perl script success: function(data){ $('.msg_body').text(select_degree); } // success }); // ajax }); } Now, the code actually queries the function and displays on the page, BUT it can't actually seem to grab the onChange result (so basically, it queries MySQL with a blank ID). So if I try to print a "success" as a test, it will print "success" but the query itself is blank: my $sth = $dbc->prepare("select * from $tbl_prog where dept_program=?") or die "Select statement failed: $DBI::errstr\n"; $sth->execute($choose_degree); print "<div id='choose_degree'>"; while (my @data = $sth->fetchrow_array()) { ...} So $choose_degree isn't actually getting any variable associated with it. The question is, how do I return the onChange variable result?
  14. The two functions in functions.pl are called straight in the index, &chooseDegree; print "<div class='msg_body'>"; my $which_degree = param('select_degree'); #choose which program under under/graduate chooseProgram($dbc,$tbl_prog,$which_degree); Would it be possible to return the value from the JQuery call and automatically plug it into the Perl function?
  15. The reason the second one isn't working is because it's not in your while loop. $line[pass] is declared only to exist within the while loop; you can't use it outside of it. Change your structure to something like: echo '<table border="0" cellspacing="2" cellpadding="2">'; while ($line = mysql_fetch_array($result, MYSQL_ASSOC)) { echo "<tr><td>".$line['pass']."</td></tr>"; } echo "</table>"; ?> That should work.
×
×
  • 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.