The OPer has left the building... :)
Very funny ;)
The OPer has left the building... :)
Very funny ;)
I'd like to agree - I hate blobs. However, some of the very popular BBs use them, so I don't know how heavy they are.
the rule of thumb is if it fits your need use it and when it become too much migrate to something more feasible!
Otherwise, an useful thing to do is to rename the image on upload, e.g. username_time.ext (ardav_1318622004.jpg). You then store this name in the DB.
I think this is the best than Blob. Blobs are heavy and will make DB grow fast especially if images limit are big
For simplicity I would add a table with image_id and image name (given that images folder is fixed). Then in users I will add user_image_id which will tell me what avatar user belongs to. The rest is simple!
It might not be the best (I rushed to answer with no deep thinking/scrutiny) but it should work!
After some reading I re wrote everything into below class. I have give a sample template and an example. So far it is very simple and I wonder how can I implement caching to increase the speed and performance!
template Engine class
<?php
/**
* The Template engine of your application
* Loads the templates and no compiling
*/
class HTemplate{
private $tfile;//full path to the template file
private $values; //array of values in the file
private $templates_path = "templates/";//path to system templates
public function __construct($file){
$this->tfile = $this->templates_path.$file;
}
public function set($key, $value){
$this->values[$key]=$value;
}
public function render(){
//get file contents
if(!file_exists($this->tfile)){
return "Error: Template File ".$this->tfile." could not be found";
}
$file_contents = file_get_contents($this->tfile);
$tags = array_keys($this->values);
$tags = array_map(array($this, "add_tags"), $tags);
$replacer = array_values($this->values);
return str_replace($tags, $replacer, $file_contents);
}
private function add_tags($key){
return "{@".$key."}";
}
}
/*End of file*/
Sample template layout.tpl
<!DOCTYPE html>
<html>
<head>
<title>{@title}</title>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
</head>
<body>
<div>
<h3 style="color:red;">{@heading}</h3>
</div>
<div>
{@body}
</div>
</body>
</html>
Sample view (note that data comes from controller which gets it from DB)
<?php
$layout = new HTemplate("layout.tpl");
$layout->set("title", $id);
$layout->set("heading", $heading);
$layout->set("body", $body);
echo $layout->render();
?>
Just a note, if you have little knowledge in OOP, PDO is great!
Okay. So I can use Qt, I just can't change anything within the library itself and distribute my "updated" version of the library or static link the library in my app without buying a commercial license. But I can distribute the original library dlls with my app and place it in the same directory, correct?
I think the answer is yes....but I'm no lawayer ;)
@ChaosKnight11:
Careful! Iirc the LGPL allows you to freely link to Qt dynamically.
So you have to either use the DLL(or *nix equivalent)-version of Qt or deliver your object files, so the user could link your program with another Version of Qt.
That is why I gave wxOption. Free to link shared static modify sources....full freedom!
EWS combines the functionality that is included in WebDAV and CDOEX, and provides logic that makes common scenarios such as calendaring workflows easy to implement. EWS is a SOAP-based XML Web service that can be accessed remotely from any operating system and any language that can send requests over HTTPS.
This is quote from them yet I cannot find a single example using non C#/.Net. Is there anything I'm missing?
If you need a "Don't worry licence" go for wxWidgets!
But there are no fatal errors! I dont know why :?:
use this on top of page
ini_set("display_errors", 1);
But I dont want to use session variable bcoz to update a session variable we need to submit a form.
What do you mean by this?
Hi,
Is there a way I can access the Exchange Mails/Calendars/Addressbook without .NET or non cross platform thing? I want to access them with C++ but on both MS and Linux
I was looking at EWS but it seems it is tied to MS and .NET
Please share with me if there is any way
Thanks!
I am completely stuck on this assignment I'm not sure what I should be getting. Can anybody take a look at my code and please help me. I need to complete this assignment asap. thanks
Direction: Design, implement, and test a class that represents a phone number. The number should be represented by a country code, an area code, a number, and a type. The first three values can be integers. The type member is an enumeration of HOME, OFFICE, FAX, CELL, and PAGER. The class should provide a default constructor that sets all of the values to zero and type to HOME. A constructor that enables all of the values to be set should be provided as well. You should also provide a constructor that takes just the number and type as arguments, and sets the country and area codes to those of your location. The class will have observers that enable each data member to be retrieved, and transformers that allow each data member to be changed. An additional observer should be provided that compares two phone numbers for equality.
post your codes here!
AFAICS, all these should be class attributes and only you need getters and setters. Call those setter for attributes in question on constructor.
So how exactly would I write a dll and implementation file for the three blocks of code in my first post in this thread?
For exporting classes, it is better to create and destroy objects in DLL itself to avoid compiler crash (if main app is compiled differently from DLL(s)). So export method for creating object and destroying objects in DLL as C-style.
something like:
class Library{
//all methods goes here
}
extern "C"{
Library* createObject(){
return new Library();
}
destroyObject(Library* lib){
delete lib;
lib=NULL;
}
}
Check MSDN entry on making DLLs
Build and runs fine here:
java version "1.6.0_23"
OpenJDK Runtime Environment (IcedTea6 1.11pre) (6b23~pre10-0ubuntu5)
OpenJDK Server VM (build 20.0-b11, mixed mode)
So I think it is better you uninstall and re install your jdk. may be it is corrupt
I am a newbie with php and was hoping someone can help me out. I am creating my first dynamic site in php and have gotten stuck. I have one page with 100's of links. I need all these links to load the same page but I need the server to load it so that it is a different URL.
Example:
link - clicks through to index1.php?123
link - clicks through to index1.php?456
link - clicks through to index1.php?789Thanks
Mh! and what have you done so far?
so i got this but its not working
<?php if ($HTTP_POST_FILES['type']!="jpg"){ echo "jpg only allowed";} else { $file_name = $HTTP_POST_FILES['ufile']['name']; $random_digit=rand(00000,99999); $desh = "."; $new_file_name=$random_digit.$desh.$file_name; $path= "upload/".$new_file_name; if($ufile !=none) { if(move_uploaded_file($HTTP_POST_FILES['ufile']['tmp_name'], $path)) { echo "Successful<BR/>"; echo "File Name :".$new_file_name."<BR/>"; echo "File Size :".$HTTP_POST_FILES['ufile']['size']."<BR/>"; echo "File Type :".$HTTP_POST_FILES['ufile']['type']."<BR/>"; echo "<img src=\"$path\" width=\"150\" height=\"150\">"; } else { echo "Error"; } } } ?>
Didn't I give a link with everything you have asked?
Are you trying to build something that is compatible with Joomla, or are you using Joomla as a reference for how they have solved a certain problem?
I'm not trying to emulate Joomla, it was the only reference I was having. After reading a bit I have little clear understanding a bit. I will modify the class you have given me and post back.
Yes its a plugin to show a list of users
see files attached last page
Which shots?
don't forget to mark it solved!
I am trying to create a python program but i have a question about a certain part of the loop for example i have
question = input("press 1 or 2") if statement == 1: print "somthing" elif statement == 2: print "abc"
ok my question now is for example the user were to press 10, python would just skip the whole if loop, how can i make the message reappear and make the user chose the correct options?
First if is not a loop, it is control structure.
Secondly you need to get a book and learn Python. see one of many free PyBooks here
It seems the code is for some sort of plugin. What is it?
You absolutely get what you pay for. Steer far away from unlimited hosting, unless of course you can show me an unlimited hard drive, or a NIC with an infinite port speed.
Good logic! Loved it!
A few weeks now. Im sure its not that hard IF you understand php, alas, I dont!
I do know I cant do this client side with javascript since its calling data from mysql.
Is there any code or info I can supply that will help YOU understand how my software works?
Im working off a plugin that shows a list of users,(first code posted this thread)
I don't think I can help with the script as it is complex and I'm not ready to poke around. Simplest thing I would suggest is you post your schema and someone writes script to pull total users. The downside of this is you are adding security weakpoint!
Last snippet is just logging activity, yes I got it elsewhere, waiting on support from Author.
What can I post you to help you with my quest?
whats OOP ?
How long have you been waiting for support? May be you are being a little impatient?
Id like to show total number of users elsewhere on my site, and dont know which part of the following code calls that.
I want to have 'some text[number of users here], and counting!'
I need to strip out only the minimum code to display the total number within another php page. please help, I have no idea of php.
<?php if (!defined('APPLICATION')) exit(); class UserListModule extends Gdn_Module { public function __construct(&$Sender = '') { parent::__construct($Sender); } public function GetData() { $SQL = Gdn::SQL(); $Session = Gdn::Session(); $Random = Gdn::Config('UserList.Random'); $Limit = Gdn::Config('UserList.Limit'); $NoPhoto = Gdn::Config('UserList.NoPhoto'); $Select='u.UserID, u.Name, u.Photo'; $From='User u'; $Where=array('u.Deleted'=>0,'r.RoleID>'=>7); if($Random && $NoPhoto) { $Order='RAND()'; } else if((!$NoPhoto) && ($Random)) { $Where['u.Photo >']=0; $Order='RAND()'; } else if(!$NoPhoto) { $Where['u.Photo >']=0; $Order='u.UserID'; } else { $Order='u.UserID'; } $this->Users = $SQL ->Select($Select) ->From($From) ->Join('UserRole r','u.UserID = r.UserID') ->Where($Where) ->Get(); $this->All_Users = $SQL ->Select('u.UserID') ->From('User u') ->Join('UserRole r', 'u.UserID = r.UserID') ->Where(array('u.Deleted'=>0,'r.RoleID>'=>7)) ->Get(); } public function AssetTarget() { return 'Panel'; } public function ToString() { $String = ''; $Session = Gdn::Session(); $permissions=$Session->User->Permissions; $admin=preg_match('/Garden.Settings.Manage/',$permissions); ob_start(); $Limit = Gdn::Config('UserList.Limit'); $Photo = Gdn::Config('UserList.Photo'); $Title = Gdn::Config('UserList.Title'); $ShowNumUsers = Gdn::Config('UserList.ShowNumUsers'); if(empty($Title)) { $Title="Members"; } if($Photo) { ?> <style type="text/css"> #UserList ul.PanelInfo li { border: 0!important; float: left; width: 25%; padding: 5px 0 0 0; } #UserList img { height: 48px; width: 48px; } #UserList ul.PanelInfo li { text-align: center!important; } </style> <?php } ?> <style type="text/css"> #UserList ul.PanelInfo li a { float: none; } #UserList ul.PanelInfo li { text-align: left; } </style> <div id="UserList" class="Box"> <h4><?php …
Hi Ev, good answer - I saw a few things about carrying over a session var with just id and then getting the whole caboodle again. I was just thinking about having to include a shed full of classes for what would be a trivial update. My fault, I need to seriously get my head out of my derriere and start thinking OOP instead of procedural.
As for persisting with persistence, I think I can safely let that idea slip now. Still, I feel like I'm looking up at Everest from sea level.
Thanks for the links.
Glad that I was of help,
enjoy!
The best way would be wrapping these into class and do it in two line:
$liker = new LikerClass(true);//true for like(default) and false for dislike
$liker->action();//do like/unlike
$liker->getLikes();
$liker->getDislikes();
I have made small demo for you. Play around it to fit your needs.
Schema:
CREATE TABLE `likesys` (
`id` INT NOT NULL AUTO_INCREMENT,
`liked` INT(1) NOT NULL,
PRIMARY KEY (`id`)
)
ENGINE = MyISAM;
PHP file
<html>
<head>
</head>
<body>
<?php
ini_set("display_errors", 1);//error mgt
try{
$db = new PDO("mysql:host=localhost;dbname=test", "test_user", "__put_password_here__");
}catch(PDOException $e){
echo $e->getMessage();
}
$stmt=$db->prepare("INSERT INTO likesys(liked) VALUES(:like)");
$stmt2=$db->prepare("SELECT SUM(liked) AS likes FROM likesys WHERE liked=:like");
$display=false;
if(isset($_POST["like"])){
$stmt->execute(array(":like"=>"1"));
$display=true;
}
if(isset($_POST["dislike"])){
$stmt->execute(array(":like"=>"-1"));
$display=true;
}
$stmt->closeCursor();
//if($display){
$stmt2->execute(array(":like"=>"1"));
$res = $stmt2->fetch(PDO::FETCH_ASSOC);
echo "<p>Likes: ". $res['likes']."</p>";
$stmt2->execute(array(":like"=>"-1"));
$res = $stmt2->fetch(PDO::FETCH_ASSOC);
echo "<p>Dislikes: ". abs($res['likes'])."</p>";
// }
$db=null;
?>
<form action=<?php echo $_SERVER["PHP_SELF"];?> method="POST" >
<input name="like" type="submit" value="Like" />
<input name="dislike" type="submit" value="Dislike" />
</form>
</body>
</html>
Tried the Joomla forum?
Meanwhile s/he can check
http://net.tutsplus.com/tutorials/other/creating-your-first-joomla-template/
or maybe its sort of an browser addon?
Try another browser or use same browser with all addons disabled
Hi all,
Trying to get my head around OOP at long last. Finally got to the beggar on my to-do list.
Welcome to the world of beasts ;)
Just a quick question:
I was looking for a way to persist the object across pages, but on further research, I got the idea that this is a bad idea and that objects should be created anew on every page. Does this also apply to Ajax calls (I assume it does)? Seems like a lot of work for a straightforward part-of-page-update. I haven't got a specific use in mind, still at the concept stage.
Why would you want to persists objects across the page? Since technically AJAX call is just like other calls with no reloading of page then things goes just like the non Ajax page. I think that should be avoided and alternative is given below. If you persist on testing the concept, check serialize/unserialize and this one
Just thinking of all the include files req'd by a simple php script on a round trip from the client. Any thoughts on this? I'm noob^infinity on OOP.
I think the best way would be storing in session key (like ID) to a table containing info necessary to create an object. Then query the info and create an object that will persist per each page.
I just tried google and here is an interesting thread
Generally the templating functionality would be rolled into the "view" component of your MVC architecture, at least in some fashion. The code you have provided looks a lot more like a registry to me.
However to better understand your design, I'd really like to see how you envision other classes extending this base class and what their unique functionality would be.
From what you provided I see some changes that would make like easier.
First, if this class will always be extended and should not be used by itself, making it an abstract class would make sense. Also I think given what I have seen so far, by extending the SPL ArrayObject you'll gain a lot of useful functionality in sense of being able to work with your template as if it was an array.Also I think you can drastically refactor your class and make it more flexible.
<?php abstract class TemplateBase extends ArrayObject { /** * Constructs a new TemplateBase object * If an array is provided it is passed to the ArrayObject constructor * * @param $options array */ public function __construct( $options = array() ) { if( is_array( $options ) ){ parent::__construct( $array() ); } } /** * Adds an area to the template class * * @param $area string * @param $content mixed * @return self */ public function setArea( $area, $content = null ) { $this[$area] = $content; return $this; } /** * Returns and area if it has previously been set. * If …
You could probably get them from Notepad++ files. I think it has a number of 'language' files.
Oh! Thanks a lot!
Hi Stefano,
I was able to fix my problem. All I had to do was "Not append the object to the array" but to assign it to the array variable.
Thanks for your time. I shall post the corrected code soon.
Thanks,
Harsha
Enjoy, mark it solved then!
Since I decided to reinvert the wheel and write a growing MVC, I though having a template class will be cool. Now I have never done any complex templating apart from simple include kind of templating. Now I wrote this base class and here is my concept is explained below. Is this right way/concept of writing web page templates?
Concept
"Any Template class will extend this class. The Controller will modify single part or all. If controller will modify the content only using set action, then the page will change only one component and other parts will remain the same just like including header/footer would do"
Another question is,how do I pass same page object so that non changed parts are cached in the object (since http is stateless protocol)? Should I start session and store it object in session? Should parent be a singleton?
Thanks!
<?php
class TemplateBase{
//variables corresponding to part of web page
private $header;
private $footer;
private $body;
private $menu;
private $left_side;
private $right_side;
private $menu_header;//between menu and header
private $menu_content;//between menu and content
public function __construct(){
//no inits for now
}
//header
public function header_func($action, $value=null){
if($action=="get"){
return $this->header;
}
if($action=="set"){
$this->header = $value;
}
}
//footer
public function footer_func($action, $value=null){
if($action=="get"){
return $this->footer;
}
if($action=="set"){
$this->footer = $value;
}
}
//body
public function contents_func($action, $value=null){
if($action=="get"){
return $this->body;
}
if($action=="set"){
$this->body = $value;
}
}
//left side
public function left_bar_func($action, $value=null){
if($action=="get"){
return $this->left_side;
}
if($action=="set"){
$this->left_side = $value;
} …
I did Python long ago so there might be other better method, but fixing index is really bad option. Use object meta data like length of list et al
here is a sample code illustrating that!
a = ["Juma", "Roza", "Manenge" ,"Mandawa" "Siku ya Gulio Katerero"]
for name in a:
print name #add whatever you want to be done here like adding in another thing
#alternatively
for i in range(0, len(a)):
print a[i]
I have decided when I have free of free time I will be playing around small php editor.
I was wondering where I can get a list of keyword for mentioned languages, preferably in csv or like format
Thanks!
EDIT:
I forgot CSS
Yes, thank you, of course image not a button as you said ( wrote it late at night ). I know JS doesn't need href. The point was: <a href='index.php?id=$value'> is passing them when you click the image that also calls JS. Ajax calls a php script that deletes the entries based on those values from <a href> and this php script is included in index.php.
So I wanted to stop the refresh when the image is pressed and ajax is called. I know a bit intricate so I've decided to re-program this now...but thanks a lot.P.S. ...also the id or name need to pass a dynamic value from php to a href from a while loop. I just haven't included all script.
id should be added during creation of contents/comments from server. for example if your comments are in a div then add id of a button/image the same as id of the comment in database. Catch onclick events for all buttons/images, take an id and send it to delete.php (or whatever delete comments) via ajax.
Did you understand?............English isn't so good - yet.
Sorry I have no idea yet as to what you want to do!
The only help for now is:
http://docs.python.org/tutorial/
http://www.mindview.net/Books/Python/ThinkingInPython.html
"You should present students with a menu where they can repeatedly choose to practice addition, subtraction, multiplication, and division problems or to exit the program."
Where is your code?
Hi,
I want to authenticate user if he/she successfully logged in before or not, in every pages. Obviously on top of the pages I have to call a function or another page to run that function to carry out checks but, I really don't know what kind of code I have to use in function.
I read a lot of codes about sessions with hash, salt, session id, ip, timestamp etc but all blame each others code. I know nothing is perfect but at least I need someone to tell me "use this one" so I can use it so I need your help.
What do I set in session when logged in successfully and how do I validate those values in authentication function?
Thanks in advance
PHPAcademy Have that in the list of videos. Note, it is a tutorial not for production
since you have noted problematic part, post only relevant part!