Jump to content

Hybride

Members
  • Posts

    286
  • Joined

  • Last visited

Everything posted by Hybride

  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.
  16. Please use the code tags next time. For all of your input, you need to use the actual input name when echoing the value to retain the input value. So, your <input tabindex="1" class="itemContent" type="text" name="guestName" value='<?php echo $_POST['Name']; ?>' /> becomes <input tabindex="1" class="itemContent" type="text" name="guestName" value='<?php echo $_POST['guestName']; ?>' /> Or, your <input tabindex="2" class="itemContent" type="text" name="cityState" /> becomes <input tabindex="2" class="itemContent" type="text" name="cityState" value='<?php echo $_POST['cityState']; ?>' />
  17. Am working on a project that am teaching myself JQuery for the first time, integrating it with Perl (am trying to advance my abilities in Perl, which is why I chose that instead of PHP, so bear with me, please.) I've got the query working almost how I want it, except... not exact. Basically what happens is, I have the following JQuery: This guy is in folder /js_jquery/lament_functions.js function chooseDeg() { $(".msg_body").hide(); //will keep it from appending 2x var under_or_grad = $('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: "json", data: "select_degree=" + under_or_grad, // script call was *not* successful error: function(XMLHttpRequest, textStatus, errorThrown) { alert("Failed query."); }, // error // script call was successful // data contains the JSON values returned by the Perl script success: function(data){ $('.msg_body').text(under_or_grad); } // success }); // ajax }); } Which queries the database correctly, but only if you type in through the URL the actual ID number. So, if you go to http://lament.anekyu.com and click on either two radio buttons, it will correctly display either 1 or 2 (undergrad/graduate), but not query the database. If you go to http://lament.anekyu.com/index.pl?select_degree=1 or http://lament.anekyu.com/index.pl?select_degree=2, the correct result will show. I would like to have the index page able to do that without having to add the GET query. This is my index page: print $q->header, $q->start_html( -title=> "LAMENT:: LOCUS, A Monstrously Exhausting Non-working Tripe", -base=> "true", -style=>{'src'=>'../style.css'}, #-script=>$JSCRIPT, -script=>[ { -type => 'text/javascript', -src => 'jquery_js/jquery-1.5.1.min.js'}, { -type => 'text/javascript', -src => 'jquery_js/lament_functions.js'}]), h1('Choose your (CS) destiny.'),br, start_form(-name=>'choosedestiny', -id=>'choosedestiny'); print "<div id='box'>"; &chooseDegree; print "<div class='msg_body'>"; my $which_degree = param('select_degree'); #choose which program under under/graduate chooseProgram($dbc,$tbl_prog,$which_degree); And the functions page, in same folder as index.pl (called "functions.pl"): ################################################################################ # Undergrad, Graduate or PhD; # 1 & 2 are selectable now. ################################################################################# sub chooseDegree{ print radio_group( -name=>'select_degree', -values=>[qw/1 2/], -labels=>{'1'=>'Undergraduate','2'=>'Graduate'}, -default=>'-', -onClick=>"chooseDeg()", #this is for the JQuery drop-down ),br, br; } ####################################################### # SHOW ALL AVAILABLE PROGRAMS RELATED TO DEPARTMENT ####################################################### sub chooseProgram { my ($dbc,$tbl_prog,$choose_degree) = @_; 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()) { print radio_group( -name=>'select_program', -values=> $data[0], #this is the program's unique id -labels=> {$data[0]=>$data[3]}, #map the value/id to the this is the program name, ie: 1=>Software Development -default=>'', -linebreak=>'yes', -onClick=> "" ); }; print $choose_degree; print "</div>"; }
  18. What way is it that you're doing that is not working? Try htaccess redirects.
  19. There should be a / before the 500.php, so ErrorDocument 500 /500.php
  20. Contact form and send email. Mod it to your need.
  21. Take a look at Server variables, particularly Request_URI and Script_name.
  22. If you have something set completely to 0, such as margins: margin:0px 0px 0px 0px You can simply combine it to: margin:0 This also works for padding, borders,etc. Example shorthand of margin: margin: top right bottom left //v1 margin: 1px 2px 3px 4px margin: top sides bottom //v2 margin: 1px 3px 2px, which means margin: 1px 3px 2px 3px margin: x y //v3 margin: 5px 3px, which means margin: 5px 3px 5px 3px margin: all //v3 margin: 10px, which means margin: 10px 10px 10px 10px If you can combine classes and ids, do so, to save space, look cleaner, and be more efficient. You can also write things on one line, so you can change: #gtxtr { color: red; } 3 lines, to 1 line: #gtxtr{color:red} The last entry in the id or class does not require the semi-colon, so #gtxt { float: left; margin: 30px 0px 0px 10px; } can be rewritten as #gtxt {float: left; margin: 30px 0px 0px 10px} Whew. Need more help, feel free to ask.
  23. If you're using Paypal, why do you need a custom script? Custom Paypal payment
  24. What is the first database? You can probably just use the database itself to export as SQL statements, and then import into MySQL.
  25. You can combine a some of your ids, like this one all the way at the end: #rlevel{...}, #rkills{...}, #rwins{...},#rbank{...} #rbounty { float: left; background: #171717; border: 1px dotted grey; color: yellow; margin: 20px 0px 0px -665px; padding: 10px; width: 300px; height: 310px; -webkit-border-radius: 10px; -moz-border-radius: 10px; } #rbountyk { float: left; background: #171717; border: 1px dotted grey; color: yellow; margin: -330px 0px 0px 560px; padding: 10px; width: 300px; height: 310px; -webkit-border-radius: 10px; -moz-border-radius: 10px; } could be changed to: #rlevel,#rbank,#rwins,#rkills, #rbounty,#rbountyk { float: left; background: #171717; border: 1px dotted grey; color: yellow; margin: 20px 0px 0px -665px; padding: 10px; width: 300px; height: 310px; -webkit-border-radius: 10px; -moz-border-radius: 10px; } #rlevel {margin: -120px 0px 0px 215px} #rkills {margin: -330px 0px 0px 560px} #rbountyk {margin: -330px 0px 0px 560px} #rbank {margin: -470px 0px 0px 215px} #rwins {margin: -470px 0px 0px 560px} Since all of those #ids are the same except for margins, you can combine your classes/ids as such, with making a new #id with the one or two line variation. Also, use the shorthand version of codes, such as in your borders: #loginstory2 { float: left; background: #171717; border-bottom: 1px dotted grey; border-right: 1px dotted grey; border-left: 1px dotted grey; height: auto; width: 930px; margin: -10px 10px 10px 10px; } could be changed to #loginstory2 { float: left; background: #171717; border: 1px dotted grey; border-top:0; height: auto; width: 930px; margin: -10px 10px 10px; /* top left+right bottom */ }
×
×
  • 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.