Jump to content

Demonic

Members
  • Posts

    562
  • Joined

  • Last visited

    Never

Everything posted by Demonic

  1. any programming language. There was a website that I visited years ago that gave you like problems to solve with a programming language like for example: Write a PHP app that gives you every odd number between 200-300. I just forget the name of the website and wondering if someone remember or currently visits that website.
  2. Yeah, not a fan of Doctrine. Found RapidDataMapper.com looks promising.
  3. I just practically completed what I think is a tiny framework I don't want to create a complete database library or orm library just to work with my framework. Anyone recommend anything?
  4. Will this work, I've never used a subselect before: SELECT * FROM users WHERE user_id NOT IN ( SELECT user_id FROM groups WHERE group_id = 1 )
  5. I find classical music is great, I recommend you try it some time . It's like programming at the library xD quiet, no one to bother you peaceful.
  6. I'm downloading this mega pack of relaxing music and some relaxing classical music to see if it helps me program in a more relaxing way. (Might even help sooth my headache) [it's warez so I can't post it contact me if your interested, just not on the forums PM is fine] Do you listen to relaxing music when you program?
  7. http://leftblank.nl/how-to-redirect-www-to-no-www-or-vice-versa-on-your-website-274.html http://wordpress.org/extend/plugins/no-www/
  8. Not really. $url outputs an array, and if I passed $url, I would have to treat the parameter like an array. Heres my default action: public function _default($test) { echo $test; $this->template->load( array( array( "admin/modules/folio/manage", array('results' => $this->instance->folio_model->get_array()), ), ),"admin"); } If I don't have any actions created for the parameter I provided, it will be come a function parameter. http:// localhost/portfolio/admin/module/folio/test If the function "test" isn't created in the url, that will become the first parameter in the default function _default("test") If there are more url segments it will automatically become the next parameter in the function: http://localhost/portfolio/admin/module/folio/test/test2 _default("test","test2") thats only if I haven't created a function named "test". If I created a function named test: it'll look like: test("test") What I'm trying to figure out is if theres an alternative to "eval" to executing that function with the parameters. Heres what I got so far: /** * Plugin Modules * * This function is used to load built in and user created * modules. Plug and play system for easibility. * * @param string module name * @param string module sub page * @return void */ public function module($module=null,$action=null) { switch( $module ) { case "groups": if( !$this->perms->has("main_admin_groups")) return redirect("admin/no_permissions"); return $this->_module_groups(); break; case "manage": if( !$this->perms->has("main_admin_modules")) return redirect("admin/no_permissions"); return $this->_module_manage(); break; } $perms =& $this->perms; //check if module exists and try loading it $class_name = "module_" . $module; if( $this->module_model->exists($class_name) ) { $file = str_replace("\\","/",APPPATH) . "modules/module_" . $module . EXT; if( file_exists($file)) { require_once $file; if( class_exists($class_name)) { $class = new $class_name; if( !is_null($action) && method_exists($class,$action) && !preg_match("/^_/i",$action)) { //does this action require permissions and does user have them if they do? if( ($this->perms->exists("main_" . $class_name . "_" . $action) && $this->perms->has("main_" . $class_name . "_" . $action)) OR !$this->perms->exists("main_" . $class_name . "_" . $action)) { $url = $this->uri->segment_array(); $rurl = array(); for($x=5;$x<sizeof($url)+1;$x++) $rurl[] = $url[$x]; if( sizeof($rurl) > 0 ) { $params = "'" . implode("','",$rurl) . "'"; return eval("call_user_func(array(\$class,\$action),{$params});"); } else { return call_user_func(array($class,$action)); } //return call_user_func(array($class,$action)); } else { //user has no permissions return $this->error("You have no permissions"); } } else { $action = $this->default_action; //show default action if( method_exists($class,$action)) { if( ($this->perms->exists("main_" . $class_name . $action) && $this->perms->has("main_" . $class_name . $action)) OR !$this->perms->exists("main_" . $class_name . $action)) { $url = $this->uri->segment_array(); $rurl = array(); for($x=4;$x<sizeof($url)+1;$x++) $rurl[] = $url[$x]; if( sizeof($rurl) > 0 ) { $params = "'" . implode("','",$rurl) . "'"; return eval("call_user_func(array(\$class,\$action),{$params});"); } else { return call_user_func(array($class,$action)); } } else { //user has no permissions return $this->error("You have no permissions"); } } else { //return error saying default module does not exists return $this->error("Default Action does not exists!"); } } } else { //warn user module is missing return $this->error("The module class is missing!"); } } } else { return $this->error("Module does not exists!"); } }
  9. Okay, heres the thing, I'm building my semi cms, its used for a majority of my projects just to get me started with a basic of everything I need. Backend wise and what not. It's built off of codeigniter and I'm trying to manipulate a feature that they have in my system. I've created a semi module system which acts just like the controller system codeigniter has, but what I don't have is the extra parameters being passed to my class function. $action = '_default'; //show default action if( method_exists($class,$action)) { if( ($this->perms->exists("main_" . $class_name . $action) && $this->perms->has("main_" . $class_name . $action)) OR !$this->perms->exists("main_" . $class_name . $action)) { $url = $this->uri->segment_array(); return call_user_func(array($class,$action),'test'); } else { //user has no permissions return $this->error("You have no permissions"); } } else { //return error saying default module does not exists return $this->error("Default Action does not exists!"); } Heres a snipet from my code. Above you see $url, that grabs all the urls, Basically I want to pass the results of the urls to the current class function withing using an array, you see how I have "test", thats exactly how I want the parameters to output not: Array().. How can I pass the array (with a foreach) statement to that call_user_func, without "eval"? $params = "'" . implode("','",$url) . "'"; eval("call_user_func(array(\$class,\$action),{$params});"); Is the only way I can see it being done.
  10. IF you can't get allow_url_fopen enabled, use cURL to grab the content them parse it.
  11. Just a note: echo "var randomAnimals=new Array(\"" . implode('"',$myarray) . "\");"; Would output what your expecting.
  12. Yes its possible, just echo the data out like normal.
  13. Since I can't edit my post forgot to mention my db table is something like: CREATE TABLE `groups` ( id INT NOT NULL AUTO_INCREMENT, PRIMARY KEY(id), group_name VARCHAR(255), main_admin_groups INT(11), main_admin_modules INT(11), main_admin_access INT(11), ); After I create my modules, it adds another field named after each action. main_module_modulename_action Then it loads the users permissions to see if they have access to that action, it also checks if that action exists, it none exists anyone can access.
  14. Well before I've read your post, I've constructed something like I had at the end of my previous post. Since I'm using a framework, I've created a CI Library which is called "Permissions". My permissions library has a function like yours which checks if user has role, but my module system is a bit different. Since most of the module stuff is mainly for the ACP, the permission system is actually used just about throughout the acp and not the website. Since the website will have it's own functions, mainly readibility and commenting on news, things like that. (Users wont really need to many permissions, since all the main CORE website management will be ALL located in the acp using a module of some sort) Anyways, I have a built in module and permission column which allows me to install modules. (How does this really tie into what I did? Continue) So when I install a module. It's built like the following: class module_modulename - var instance - used to get code igniters instance so we can use their built in classes, modules will act like controllers in a way - var install - an array variable used to install permissions for each action, actions are sub pages to each module, if we don't assign a action to this variable, it will declare that..that action in perticular will not have any access permissions, any admin can freely access that page. Each function besides "_default" that starts with a "_" is a private function, everything else is a action. So..when you install that module it will add columns in the groups table then you must enable permissions to that group to access them pages. By default there are only 2 modules in acp, "groups" and "manage_modules", used to manage the user groups and modules. What I'm trying to do is make it very light weight: 1. User login 2. User register 3. User logout 4. User forgot password 4. Admin Login 6. Admin Module System - Manage groups, add/edit/delete groups, admin group has default permissions that can't be changed - install/uninstall modules - which creates permissions for the module on its own to be accessed or not and what not. Allowing me to fork the system and be able to create basic sites that require a user system (admin backend) with minimum features. I'll post the code when I'm finished. (Today to show in detail how I did it) and its not bad, because you can install sql on installation with the built in "_install" and "_uninstall" functions that does exactly what it says. Run then functions when installing or uninstall modules. In short, I think I've created everything I needed to create every other project. In 2-3 days with just code igniter.
  15. History of project: Alright, I'm building a simple cms with code igniter (because code igniter has a lot of features that is already created, especially the form validation functions which speeds up some code) So I got a basic user system, users can login, register logout. Then a basic permission system which allows users to login to the admin page, using the regular login form with "admin" at the end of the url segment. Coded so it knows what type of login its dong. So right, I'm building a basic module system where you upload module files to the correct folder: What I got: What I have right now are 2 built in modules, group management and module management (install/uninstall modules) Well right now theres only one permission per module. Which allows you to access that whole module as long as you have access to it. Heres the question: Would you recommend me to have permissions for each module page? (Ex. User module:: edit users, add users, ban users, etc..) More History/Overview: My module is basic right now. There is a db table which shows all installed modules. Then when accessing a module it checks default installed modules first. Then checks to see if the module we're accessing is installed, then we include the class (require_once), initialize it. Heres another question: How would I set it up so it will automatically check if each module "action" we try to access has permissions? Would it be best to create a abstract class, module extends this class, which we use to access each action (called: load_action), then do multiple checks seeing if the function exists, then checking if the action has a permission in the groups table, if it does not just run the function anyway? pseudo if module exists include module file initiate class if module action has permissions and we have permissions OR action has no permissions load module action if there is one (domain.com/admin/module/module_name/action) else tell them they dont have permissions else tell them this module does not exists. Your thoughts?
  16. Check this snippet out http://www.bytemycode.com/snippets/snippet/445/ and google.
  17. He wants to actually embed the code straight into the page, not a snapshot, if he wants a snapshot then your reply is correct.
  18. Use the explode function, and explode the spaces. test test exploding space would split that into 2 arrays, subtract 1 from the total: function real_strlen( $string ) { $count = count(@explode($string," ")); $count = strlen($string) - ( $count - 1 ); return $string; } Make that into a function,
  19. Basically it would require some prior regular expression knowledge. Check if its a youtube link with regex. Then if true, take the id from the link, and grab the data straight from the youtube page itself and parse the corresponding information that you are wanting to show. Pretty simple. Just regular expressions, file_get_contents OR cURL.
  20. Just making sure that was clear, as when I read your response I wasn't aware that you were.
  21. You need to upload the image to the server first, grab the image content from the file, then converting it to base64 and deleting it from the server and then insert the datab into the db when necessary. http://fundisom.com/phparadise/php/image_handling/base64_image_encode @sloth456 - the $_FILES array does not contain the actual image, just the information about the image.
  22. Use a switch statement per user group: $group = 1;//by default their a student //select your data example for students //...query here if( @mysql_num_rows( $query ) > 0 ) { $group = 1; } //...query for teachers ^same as above just update the group variable to the teacher group 2 //add a switch function switch( $group ) { case 1: //student break; case 2: //teacher break; //etc.. default: //echo 'sorry you need to login'; break; }
  23. Depends, what is your root directory? Windows or Linux. If your folder is located /home/vars/public_html/main/se/pass/ here and if your script is located here /home/vars/public_html/main/se/pass/pat/join/ you would need to do $filename = "../../onwards/control/{$dirname}/"; to access another directory up use "../" and you get the point I hope. I do warn you that you might need to validate that their inserting a directory name only allow alphanumeric characters.
  24. I'm work on a small forum and trying something new with the MVC, I got the basics down for the Controller and Views, I'm just having a hard time thinking of a way to create the model class. http://code.google.com/p/cforums/ Been reading all day, once I get a basic idea of how I'll have the model class setup I can move on the error handling. Thinking about taking a CodeIgniter Approach to Models http://codeigniter.com/user_guide/general/models.html
×
×
  • 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.