Jump to content

Darghon

Members
  • Posts

    83
  • Joined

  • Last visited

Everything posted by Darghon

  1. Hi all I have about 150 virtual hosts configured in nginx. these hosts all have the same configuration with exception of the domain name, and the paths for said domain. each time I need to change a setting on one of the hosts, I need to replicate the change on ALL the domains. is there a way to "include" these configurations into the server block, to prevent me from changing each block? It needs to be includable cause there are other virtual hosts that deviate from the normal. and do not need those configurations. Thanks for any advice
  2. I've asked them if their product can supply what I need, but the pricing might be an issue, as my application is very cheap. For instance, about 500€ annually / client. Any other more "custom" solutions? I'm a senior developer myself (close to 10 years and counting) so I'm not afraid to code it myself, I just need to know what to code... Thx again
  3. Hello all. I am maintaining a php application which manages and creates contracts for internship jobs. (well that's part of it anyway) More and more of my clients start asking if there is any way they can digitally sign the contracts, to avoid printing everything out. So I've been doing some google work, been reading up on as much information as I can find, and have to conclude I have no idea how to get started on this. Hence this topic. To put everything in perspective. A student has to perform an internship at some company. Legally, we need a contract that's signed by the student (or their parent(s)), the school and the company. This document needs to be digitally available (in the application) and it needs to be visible and legally binding to all 3 parties. preferably visible that it's signed, and by whom. (~3 signatures) Right now this document is printed, and given to each of the parties. Once it's returned, it gets filed in a "binder" with all other physical documents of that student. (which the clients want to avoid) Is there any step-by-step guide for this? Correct me if I'm wrong, but I think I need to get a certificate for my application (a general one for the application itself, because each client has their own instance of this application (subdomain of the application: http://<clienttag>.applicationname.com)). Then I need to encrypt a signature of the user using this public key of the certificate, and sign the document (with PHPDocx for example). In the documents overview of this students file, it needs to list all attached and signed documents, which all parties that signed it. (with maybe the contracts converted to PDF's.) Any help for getting started with this is welcome. Thx in advance
  4. Hi all, I've been creating a somewhat responsive layout for an existing application. Some of the pages contains sets of data that have been grouped. I've added styles to show them as blocks next to each other as long as enough space is available. so full screen is shows 3 blocks next to eachother, on a smaller 2 blocks, or 1 block depending on the available width. If the content of one block exceeds the length allocated, I have an additional class "clipped" that turns the overflow hidden, and adds ellipses to the text. But as the title suggests, doing this pushes the next div down which looks ugly. Removing the overflow:hidden style fixes the issue, but makes the text run out of bounds. Listed below are the html uses, and the css related. Can anyone help me resolve this issue? (The additional style code in the full line value is to ensure that multi line texts are still positioned next to the label and not under it) Css: #wrapper label { float:left; font-weight:bold; text-align: right; width:200px; margin-right:10px; } #main #main_wrapper .group_content { display: block; } #main #main_wrapper .group_content .attribute_block { display: inline-block; min-width: 400px; margin-right: 20px; } #main #main_wrapper .group_content .attribute_block.full_line { display: block; min-width: 100%; } #main #main_wrapper .group_content .attribute_block input, #main #main_wrapper .group_content .attribute_block textarea { max-width: 300px; } #main #main_wrapper .group_content .attribute_block select { max-width: 322px; } .clipped { overflow:hidden;text-overflow:ellipsis;white-space:nowrap; } Html: <div class="group_content clearfix"> <div class="attribute_block full_line clearfix"> <div class="label"><label>Beschrijving</label></div> <div style="float: right; width: calc(100% - 210px);" class="value">Addendun voor een raamovereenkomst.</div> </div> <div class="attribute_block"> <div class="label"><label>Auteur</label></div> <div class="value clipped">Quickstage Support</div> </div> <div class="attribute_block"> <div class="label"><label>Aangemaakt op</label></div> <div class="value clipped">19/12/2012 10:14:54</div> </div> <div class="attribute_block"> <div class="label"><label>Laatste aanpassing op</label></div> <div class="value clipped">19/12/2012 10:14:54</div> </div> <div class="attribute_block"> <div class="label"><label>Gegevensbron</label></div> <div class="value clipped">Schooljaar - Klas - Leerling - Stageperiode</div> </div> <div class="attribute_block"> <div class="label"><label>Bestandsnaam</label></div> <div class="value clipped">Aanvullendbijraamovereenkomst.docx</div> </div> </div>
  5. There are a lot of topics that explain how to change the session lifetime for a application but for some reason I'm to stupid to make it work, and can't for the life of me figure out why... I want to extend the lifetime of a session with 2 hours of inactivity. So that the session remains active upto 2 hours after the last action of the user. I've tried this with .htaccess setting the lifetime and maxlifetime to 7200 which killed the session after exactly 2 hours (Not what I wanted) Removing the maxlifetime setting results in the same effect. I've added the ini_set params for lifetime to the same, also without effect. I've added a setcookie function to each request to reset the lifetime of the session, with no success... what am I doing wrong? and are there any other ways to resolve this? Thanks to anyone for advice on this matter.
  6. Hello all, I have a production server with 40+ virtual hosts on it (all part of a single application) and we've added a automatic generation script to that server to create new domains when a new request is registered. Now After adding the new db, virtual host and uploads folder (it all works on the same sourcecode) the server needs to do a graceful restart, because we don't want to kick any open connections. The system pops the command, and we send a email to the requester confirming that his/her application has been created. But for some reason the graceful restart does not always work. resulting in a "page not found" when the requester clicks on their received url. (happens about 10% of the time) Is there any way to confirm that the graceful restart was succesful? Or if anyone has any other idea's solutions for this problem? Thx
  7. Hi all, I'm developing a application with the Yii framework, and implemented a record security by adding 3 functions to all models (canIView, canIEdit and canIDelete). All models extend the same basemodel class, and all crud interfaces are simular. For some reason whenever I try to view the cruds of the models "Product" or "Order" I get a white page, and no logs anywhere... Debugging some I can echo lines upto the following line in code echo "before"; $model = Product::model(); echo "after"; Before is shown, but not after. The same code on a different model like "Division" does work... Both models extend the same class (AuditModel) which implements several security functions and populates audit fields etc... Can anyone help me debug this... or give an indication where I can find anything to point me towards any error in the code... Yii application log is empty Apache log is empty Thx
  8. I'm using netbeans, And a little insight on my class structure A object/model has 3 layers (mapped to a database record) a business layer with all functions to work with this object a datalayer with all raw variables mapped to the record in the database (with input validation etc) a finderlayer with statements that retrieve records from the database, and return initialised business objects to the requester. so the user table for instance has: a User class which extends globale business function from the businesslayer a DUser class which extends globale data functions from the datalayer, and is added as a protected variable in the business model a FUser class which extends globale finder functions from the finderlayer so lets say I add a method to find a user by email address (byEmail($email)) to the FUser I'll be able to retrieve all users with that email address by the following statement: $users = User::Find()->byEmail($email);
  9. Hello all, My question isn't about php, but the php docs. I have several php classes that extend a base class. This class has a static method that returns a object based on the extending class that calls this method How can I add php docs that my editor knows that when I call this function on 1 class, that I get a object of a specific class in return? Right now I'm passing the "super" class of that object, but it would to great to be more accurate. If the above explenation isn't clear, this is a example of what I want to do php class User extends BusinessClass php class FUser extends FinderClass when I call User::Find() => autocomplete shows info of FinderClass I want it to show info of FUser. current code: /** * Static function that creates a "Find" static function to each business object, which in turn is basicly a shortkey to get The Findertype, or when an ID is passed, to get the object by that ID * @return BusinessClass|FinderClass */ final public static function & Find($id = null) { Adding the following line above my User class result in the correct object types, but the function is no longer detected as available in autocomplete /** * @method User|FUser Find(Integer $id) Find a object by ID, or return the object finder. */ Autocomplete on "User::" no longer shows Find as a available function Thx for any help
  10. Well the 2 points in the end are basicly the things I've checked so... and I indeed have nested statements etc, but I have to. otherwise I won't be able to process my business rules that I have specified for each table/object. anyway, I managed to solve the issue. The cachegrind result was wrong basicly, and the request was taking 4x longer than reported. I tinkered somewhat with the loaded statements, and cached them inside the objects that called them, resulting in a speed gain. request now takes 3 seconds to load into the browser, and I'm happy with the results.
  11. Hi all, Not sure where to post my problem, so I hope I'll get some answers here. I have a basic LAMP setup. All works fine have APC installed tweaked somewhat with mysql cache sizes etc now I have 1 pageload in my application that takes +- 10 seconds to complete, and I can't seem to find out why... What I checked: I used firebug net view to see howlong the request takes, and it takes an average of 10 seconds, and is 25kb large (the response) xdebug on the server tells me that the request start to finish takes 2442ms (2.4s) (the request load is measured with xdebug off, if it's turned on the request takes 24+ seconds to complete...) what am I missing? why is that specific page request taking 10 seconds while the server sais it's done in 2.4. The page doesn't contain a lot of javascript, so that's ruled out... any other areas I can check? or does anyone else have an idea where the delay is located?
  12. Hi all, I'm "attempting" to make my application IPad compatible and so far I've been able to fix most problems but one. I have a bunch of clickable divs, which trigger specific events according to the order you click them. for instance, you click on several days and they're marked as selected You click on an event label, get a confirm box and all selected days are added to the event label. Now, once I do that, it doesn't matter where I click next, it registers my click at the last position. so lets say I "press" the screen at coordinates 50, 100, system returns a touchend at null, null next I press the screen at coordinates 100, 200, systems returns a touchend at 50,100 etc... This is very confusing and will result in unwanted actions. Does anyone have any clue why this is? is it IPAD related? or am I doing something wrong with my javascript (jquery) All "click" events are triggered as "touchend" incase of a IPAD Thx for any help
  13. I've just figured out that each time a ancher is added to the url, and the page is reloaded, that the favicon didn't show. so looking for that problem specific, I've found that it's an existing firefox issue. I've managed to solve this issue by adding the following javascript code after setting or reading the hash tag. $('link[type*=icon]').detach().appendTo('head'); Hopefully this'll be helpfull to others as well.
  14. Hi, I can't give the url's atm, cause I'm not at my work, but I can tell you that adding or removing the leading '/' does nothing. The page it mostly doesn't show the favicon is a page that uses a lot of drag & drop events, as well as a hash tag which defines what is currently shown. (its a kind of calendar with drag/drop event adder and a "current month" tracing through the hash tag => http://www.example.com/some/calendar#2012-10-23)
  15. Not sure if it's helpfull, but I used to make a "cached" single css file according to the requested page, and add the minified cached version instead of each seperate file. also means that you shrink the number of requests the browser has to make to load the page. which is an overall win in speed.
  16. very short code, but a bit harder to read => <?php $pcText = sprintf('<a href="%1$s">%1$s</a>',$_POST['pc'] == 0 ? 'http://www.yahoo.com' : 'http://www.google.com'); ?>
  17. Hi all, I have a favicon added to a global template in Yii, so the favicon is included in every page, and it also shows in every page. except in a few... There are a few pages in the project that don't display the favicon despite having the exact same layout files as all the others... part of the head tag of the template => <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <meta name="language" content="en" /> <meta http-equiv="X-UA-Compatible" content="IE=EmulateIE8" /> <link rel="icon" type="image/x-icon" href="images/favicon.ico" /> <link rel="shortcut icon" type="image/x-icon" href="images/favicon.ico" /> I've checked the source code and the header is exactly the same as all the other pages, with sometimes a few javascript includes more or less if I edit the favicon value using firebug the icon "reappears" even if I restore the original source (so removing or adding a "/" before the href) chrome always show the favicon, firefox doesn't (on a few pages). What could be a reason for this problem? googling has led me nowhere... If more info is needed, ask and i'll supply. unfortionatly the website I'm working on isn't public, so I can't share the links to the actual pages....
  18. Well the output buffering allows me to break the request "mid parse" and redirect through the header to a different page. It is indeed so that I use the "raw" values for module and action, but again they are only used after you have logged in as a valid user, so the only problem there is if one of my co-workers tries to f* it up, but then again, the tool allows for a lot more screwing up than the manager itself (since the tool allows you to run any sql statement over several servers/databases at the same time to name just 1 functionality) About the config::getIP() function, I use the following => public static function getIP(){ return $_SERVER['REMOTE_ADDR']; } Could possibly use "filter_var($_SERVER['REMOTE_ADDR'],FILTER_FLAG_IPV4)", but I don't think it's really needed, the IP address is only used to group attempts together, and also to link a user to a ip through email validation
  19. I do agree, and I've check each input field with an mysql real escape string. Also use a database wrapper, so I first retrieve a specific object, and match passwords afterwards, which in my oppinion is safer than escaping username and pass, and checking if a record with both values identical exists. I've also implemented a password policy. The internal application isn't as secure, and doesn't check each input field, because it's only for internal use. As long as I'm able to keep external people from loggin into the system, nothing can happen. The "application routing" that handles where your request takes you is the following: public function deploy(){ //render main part ob_start(); $db = new Database(); //check if last login attempt is at least 1 sec ago $db->setQuery(sprintf('SELECT * FROM failed_attempt WHERE ip="%s" and timestamp >= "%s"',Config::getIP(),date('Y-m-d H:i:s',strtotime('-1 days'))))->execute(); if($db->getNumRows() >= 10){ Route::deploy('login','ip_blocked'); } else{ //make sure every action is secure if(Session::get('_someinternalvarname/name',null) !== null && Session::get('_someinternalvarname/ip_valid', false) == true){ $module = isset($_GET['m']) ? $_GET['m'] : 'home'; $action = isset($_GET['a']) ? $_GET['a'] : 'index'; Route::deploy($module,$action); } else{ if(Session::get('_someinternalvarname/name',null) !== null && Session::get('_someinternalvarname/ip_valid', false) == false){ Route::deploy('login','registerip'); } else{ //redirect to login Route::deploy('login','index'); } } } $this->main_buffer = ob_get_contents(); @ob_clean(); $this->renderTemplate(); } I think this will block all unwanted requests
  20. Wow, thx to everyone for the wonderfull idea's about the security issue. So I'm using a username instead of a email, and the password has no pass policy. But no biggy because the application is for 3 people that know they need to make a complex password. The solution(s) that I'll be using are: The lockout procedure for starters. The 1 sec delay between login attempts Logging of failed logins / ip with ip blocking if a ip has more then x fails in x time linking an ip address to a user by adding a additional auth layer when a new IP is detected for that user. I especially like that last one. And I believe when all those are implemented, that the application will be as secure as it needs to be Thx for the responds.
  21. Hello all, I have this web application which is basicly a management tool for several servers. It has access to the applications on each server, manages the databases, has functionality for mass updates etc, even for validating sensitive information and force takeover of users on the other applications. Because of the functionality this application provides we need to make it as secure as possible. But we do not have a static IP address, so only allowing access from 1 or a few IP will eventually lock us out. The current security redirects all traffic to the login page, unless you are logged into the system. Passwords are encrypted with a salt. Any suggestions on what I can and should do to make this application as secure as possible? Thx in advance.
  22. Hi all, I'm pretty experience with OOP in PHP, but I'm looking for a good way to solve the next problem: I have a base entity. This entity is saved in a database somewhere and a php object can get filled with it's record data. This entity can have different properties defined with flags. For instance, entity is animal, and a specific animal has the flag "can_fly", so I want the entity to allow flight functions. Other animals might have a flag "can_swim", which invokes swimming functions. Some animals have multiple flags etc... so how can I best set this up, so that I can use record data to construct my object, with all needed functionality? Without having to create 100's of functions in the entity object and checking if the required flag is set or not. so a "extend on demand", or something along those lines. Any other solutions for this problem would be great as well. or tips about a design pattern that might resolves this. i'm reluctant to using stdclass in php, so if possible, I'd like a solution that doesn't build a generic class, or a reflection class. thx in advance
  23. Lol, why didn't I think of that. I've implemented a simular solution, and it works great. I now fill up an action que, if any entries exist in the que, it processes the que first, and returns to the global counter once its done. Thx for the idea
  24. Hello all, I'm working on a javascript page on which several timers are set. Each timer gets a tick every 10 milli seconds, but the amount added to each timer is different. Whenever a timer reaches its maximum the page needs to pause for any action that needs to be taken, and continue once it's done. Any idea's on how to do this? simple visualisation is, you have 5 people, each one has a different speed. so every 10 second the speed of each player is added to a que, once 1 of the players their queue is full (100%), they get to move. at which point the others need to wait until the player made his move. My code this far: the .bar element has a rel that contains sequence number, agil and name (=> <span class="bar" rel="<?php echo $i.'|'.$timer.'|Mob '.$i; ?>">) var timers = new Array(); var max = 4; var min = 1; var mod = 0.000; var max_agil = null; var min_agil = null; var t = null; //calculate pace of each timer function init(){ $('.bar').each(function(){ var v = $(this).attr('rel').split('|'); timers[v[0]] = 0; if(parseInt(v[1]) > max_agil || max_agil == null) max_agil = parseInt(v[1]); if(parseInt(v[1]) < min_agil || min_agil == null) min_agil = parseInt(v[1]); }); mod = parseFloat(Math.max(1,(max-min))/Math.max(1,(max_agil - min_agil))); animateBars(); } //fill the bar by agil * the calculated pace function animateBars() { var c = $('.filler').length; $('.filler').each(function(){ var v = $(this).parent().attr('rel').split('|'); var w = parseFloat($(this).width()); w += (parseFloat(parseFloat(mod)*parseInt(parseInt(parseInt(v[1]) - min_agil))) + parseInt(min)) * parseInt($(this).parent().width()) / 100; $(this).css({ width: w + 'px' }); if($(this).width() >= $(this).parent().width()){ var nw = Math.max(0,parseInt($(this).width()) - parseInt($(this).parent().width())); $(this).css({ width: nw + 'px' }); nw = null; makeMove($(this)); } v = null; w = 0; c--; if(c == 0){ t = setTimeout(animateBars,10); } }); } init(); function makeMove(that){ var v = $(that).parent().attr('rel').split('|'); var mob = $('#mob_' + v[0]); var column = $(mob).parent().attr('class').match(/(column-([\d])+)/gi); var row = $(mob).parent().attr('class').match(/(row-([\d])+)/gi); column = parseInt(column[0].replace('column-','')); row = parseInt(row[0].replace('row-','')); var pos = new Array(); if(column > 0 && $(mob).parent().parent().find('.column-' + (column-1) + '.row-' + (row)).text() == '') pos.push('w'); if(row > 0 && $(mob).parent().parent().find('.column-' + (column) + '.row-' + (row-1)).text() == '') pos.push('n'); if(column < 9 && $(mob).parent().parent().find('.column-' + (column+1) + '.row-' + (row)).text() == '') pos.push('e'); if(row < 9 && $(mob).parent().parent().find('.column-' + (column) + '.row-' + (row+1)).text() == '') pos.push('s'); var dir = pos[parseInt(Math.random() * pos.length)]; switch(dir){ case 'n': $(mob).parent().parent().find('.column-' + (column) + '.row-' + (row-1)).append(mob).delay(2000); break; case 'e': $(mob).parent().parent().find('.column-' + (column-1) + '.row-' + (row)).append(mob).delay(2000); break; case 's': $(mob).parent().parent().find('.column-' + (column) + '.row-' + (row+1)).append(mob).delay(2000); break; case 'w': $(mob).parent().parent().find('.column-' + (column+1) + '.row-' + (row)).append(mob).delay(2000); break; default: break; } } The code above does everything that it needs to do (a random move when a bar is full), but it doesn't wait for it to complete before it continues
  25. Hi all, I seem to be encountering the title error every time I initiate an object that extends my BusinessLayer object. The error means that I attempt to re-declare a final method, and that's not allowed, but I'm not redeclaring anything. Are there any potential other reasons that this error is triggered? The following 3 objects are the objects that I construct. User: <?php /** * This class is the user control for User. * Any custom actions to this database object need to be specified here. * * @author Darghon */ class User extends baseUser{ } ?> baseUser: <?php class baseUser extends BusinessLayer{ /** * Public get function that retrieves the ID * @return integer $ID */ public function getID(){ return $this->data->ID; } /** * Public set function that sets the ID * @param integer $ID */ public function setID($val){ $this->data->ID = $val; } /** * Public get function that retrieves the Name * @return string $Name */ public function getName(){ return $this->data->Name; } /** * Public set function that sets the Name * @param string $Name */ public function setName($val){ $this->data->Name = $val; } /** more getters and setters here, but have been cropped **/ /** * Public get function that retrieves the Record_Version * @return integer $Record_Version */ public function getRecordVersion(){ return $this->data->Record_Version; } /** * Public set function that sets the Record_Version * @param integer $Record_Version */ public function setRecordVersion($val){ $this->data->Record_Version = $val; } /** * Public get function that retrieves the Delflag * @return boolean $Delflag */ public function getDelflag(){ return $this->data->Delflag; } /** * Public set function that sets the Delflag * @param boolean $Delflag */ public function setDelflag($val){ $this->data->Delflag = $val; } /** * Magic to string method * @return String */ public function __toString(){ return $this->data->Name; } /** * Object validator, if this class returns true, the object can is valid and can be saved. * @return Boolean */ public function validate(){ return parent::validate(); } /** * Public Destructor, unset every used valiable * @return String */ public function __destroy(){ foreach($this as $key => $val) unset($this->$key); unset($this); } } ?> BusinessLayer: <?php abstract class BusinessLayer { /** * Dataobject that is embedded within the business object * @var DataLayer */ protected $data = null; /** * New objects require a new instance of */ public function __construct($data = null) { $class = 'D' . get_class($this); if (get_class($data) == $class) { $this->data = $data; } else { $this->data = new $class(); } } public function _set($var, $value) { $this->$var = $value; } public function fromArray($arr) { foreach ($arr as $field => $value) { $fun = "set" . Tools::strtocamelcase($field, true); if ($fun == "setId") $fun = "setID"; if (!method_exists($this, $fun)) continue; if (strpos($fun, "ID") > -1) { $this->$fun((int) $value); } else { $this->$fun($value); } } } public function toArray() { $result = array(); $fields = $this->data->getFields(); foreach ($fields as $field => $changed) { $result[$field] = $this->data->$field; } return $result; } public function validate() { return true; } /** MORE CODE CROPPING HERE **/ /** * Static function that creates a "Find" static function to each business object, which in turn is basicly a shortkey to get The Findertype, or when an ID is passed, to get the object by that ID * @return Finder */ final public static function & Find($id = null) { $caller = function_exists('get_called_class') ? get_called_class() : Tools::getCaller(); if ($id !== null) { $return = &Database::Find($caller)->byID($id); } else { $return = &Database::Find($caller); } return $return; } public static function is_a($class_name) { return (__CLASS__ == $class_name) ? true : false; } } ?> As you can see, the function isn't re-declared, so I have no clue why it triggers the error now... Using Ubuntu 12.04 and php 5.3 Thx for any help
×
×
  • 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.