Friday, November 8, 2013

add login for owncloud with your system - developer

1.why

   our project need implement cloud store,then we found owncloud and found there are many same requirement with our needs.

   but owncloud is one private cloud store program,there is not easy way to used in our project.our project have ourself user back-end.

2.Finding solutions

   by search engine,there is only asked for how to used openid plugin in owncloud,no other people can answer it perfect.

3.draft solution 1 – openid plugin

this set of solution is the subjective ideals,no confirm it can worked.

3.1 our project access the owncloud's open id url a,this url have username and password param,and it can register and verify login in background.

3.2 our log

      login in owncloud with administrate account,and create one new user by manual,with browser trace,we found it access "owncloud/index.php/settings/ajax/createuser.php", look this source file,found "OC_User::createUser" keywords,the search "createUser" keyword in owncloud\ director,we only found some create user login and some hook logics.

4.design our sourtion 2 – write code

4.1 ideas

    createuser.php

         params:

    username: string eg:"abc"

    passsword: string eg:"password"

description: program background create user and password

    login.php

          params:

    username: string eg:"abc"

    passsword: string eg:"password"

description:program backoung login

4.2 implememts:

index.php

<?php

// this value need same as in your owncloud\config\config.php key:instanceid
session_name("5257a5ababba4");

session_start();

// this value need same as createuser.htm find string "requesttoken"
$_SESSION['requesttoken'] = "a68ad041fd5e5f1ac439";

if(isset($_GET["type"]) && ($_GET["type"]=="login")){
// this value need same as your admin account
unset($_SESSION['user_id']);
}else{
// this value need same as your admin account
$_SESSION['user_id'] = "admin";
include( "createuser.htm" );
}

?>




createuser.htm:

<!DOCTYPE html>
<head>
<title>ownCloud</title>

<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />

<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.7/jquery.js"></script>
<script src="http://malsup.github.com/jquery.form.js"></script>

</head>

<body id="body-login">
<div>
<pre>
This sample is only to test for owncloud's register and login system.
1.change the source file "createuser.htm",find and replace "../owncloud2" to your owncloud path.
change the source file "index.php",find and change "session_name","user_id" by your owncloud setting.
2.write new user name and password,then click regist, this step can register one new account for your owncloud.
3.then click login,this step can used your writed user name and password to login in owncloud.
Write by pkrss,mail to:liandeliang@gmail.com
</pre>
</div>
<div id="register">
<form id="myForm" method="post" action="../owncloud2/index.php/settings/ajax/createuser.php">
<fieldset>
<ul>
</ul>
<p class="infield grouptop">
<label for="user" class="infield" for="username">User name</label>
<input type="text" name="username" id="username" placeholder="" value="" autofocus autocomplete="on" required/>
</p>

<p class="infield groupbottom">
<label for="password" class="infield" for="password">Password</label>
<input type="password" name="password" id="password" value="" placeholder="" required />
<input type="hidden" name="requesttoken" id="requesttoken" value="a68ad041fd5e5f1ac439" placeholder="" required />
</p>
<input type="submit" id="submit" value="Register"/> &nbsp;&nbsp;
</fieldset>
</form>

<input type="submit" id="refresh" value="Refresh"/> &nbsp;&nbsp;
<input type="submit" id="submit2" value="Login"/>
</div>

<div style="display:none">
<form id="loginForm" method="post" action="../owncloud2/">
<input type="hidden" name="user" id="username2" required/>
<input type="password" name="password" id="password2" required style="display:none"/>
<input type="hidden" name="remember_login" value="1" id="remember_login" checked="true" original-title="">
<input type="hidden" name="timezone-offset" value="8" required/>
<input type="hidden" name="requesttoken" value="a68ad041fd5e5f1ac439" placeholder="" required />
<input type="submit" id="submit3" value="Login" style="display:none"/>
</form>
</div>

<script type="text/javascript">
$(document).ready(function() {
$('
#refresh').click(function(){
location.reload();
return false;
});
$('
#submit2').click(function(){
$.ajax({
type: "POST",
url: "index.php?type=login",
complete: function(msg){
$("#username2").val($("#username").val());
$("#password2").val($("#password").val());
setTimeout(function(){
// return;
if(1){
$('
#submit3').click();
}else if(1){
$('
#loginForm').ajaxForm();
}else{
$.ajax({
type: "POST",
url: "../owncloud2/",
data: {
"username":$("#username").val(),
"password":$("#password").val(),
"remember_login":1,
"timezone-offset":8
}
});
}
});
}
});
// 1. index.php?type=login
// 2. http://localhost/t/owncloud2/
return false;
});
$('
#myForm').ajaxForm(function(data) {
alert(data.data.message || "Operator OK");
});
});
</script>
</body>
</html>




about this code:

                This sample is only to test for owncloud's register and login system.
1.change the source file "createuser.htm",find and replace "../owncloud2" to your owncloud path.
change the source file "index.php",find and change "session_name","user_id" by your owncloud setting.
2.write new user name and password,then click regist, this step can register one new account for your owncloud.
3.then click login,this step can used your writed user name and password to login in owncloud.
Write by pkrss,mail to:liandeliang@gmail.com

34 comments:

online said...

Woah! I'm really digging the template/theme of this website.
It's simple, yet effective. A lot of times it's difficult to get that
"perfect balance" between user friendliness and
visual appearance. I must say that you've done a awesome
job with this. Also, the blog loads extremely quick for me on Firefox.
Excellent Blog!

Pure Logic said...

Incredible! Keep writing. :-D

Prince Turki Bin Abdullah Al Saud said...

Hey there this is somewhat of off topic but I was wanting to know if blogs use WYSIWYG editors or
if you have to manually code with HTML. I'm starting a blog soon but have no coding
skills so I wanted to get guidance from
someone with experience. Any help would be enormously appreciated!

free classified in nigeria said...

I like the valuable info you provide on your articles.
I'll bookmark your blog and check once more here frequently.
I am rather certain I will be informed lots of new stuff right right here!
Good luck for the next!

Mortgage refinance texas va said...

I would like to show some appreciation for your efforts to build up this
helpful online site.

Cellulit said...

I know this if off topic but I'm looking into starting my own blog and was curious what all is required
to get setup? I'm assuming having a blog like yours would cost a
pretty penny? I'm not very web savvy so I'm not 100% positive.

Any suggestions or advice would be greatly appreciated. Kudos

pkrss said...

no money need.your can register one free php web hoster in phpcloud.com or openshift.com
or your can register one free wordpress account in wordpress.com and start your first timer,it is simply!

http://www.animalbazar.it said...

We are a group of volunteers and starting a new scheme in our community.

Your website provided us with valuable information to work on.

You've done an impressive activity and our entire community
will likely be thankful to you.

content spinner said...

Actuallƴ no matter if sߋmeone doesn't be аware of after
that its uup to other vοewers that they will help, so
here it tɑkes place.

cheap bio oil said...

My brother suggested I might like this website.
He was totally right. This post truly made my
day. You cann't imagine simply how much time I had spent
for this information! Thanks!

สมัครงานพาร์ทไทม์ said...

Hey I am so excited I found your blog page, I really found you by error, while I was browsing on Digg
for something else, Anyhow I am here now and would just like to say thank you for a marvelous post and a
all round entertaining blog (I also love the theme/design), I don’t have
time to read through it all at the minute but I have saved it
and also included your RSS feeds, so when I
have time I will be back to read more, Please do keep up the excellent jo.

อาชีพเสริมหลังเลิกงาน said...

I like the valuable info you provide in your articles.
I'll bookmark your weblog and check again here
regularly. I'm quite certain I'll learn a lot of new stuff right
here! Good luck for the next!

งาน Part Time 2557 said...

I needed to thank you for this great read!! I certainly enjoyed every little bit of it.
I have got you saved as a favorite to check out new things you post…

Jamison said...

Hey there! I know this is somewhat off topic but I was wondering
which blog platform are you using for this site? I'm getting tired of Wordpress because I've had problems with hackers and I'm looking at alternatives for another platform.
I would be great if you could point me in the direction of a good platform.

sarah haley spence diamonds said...

Hi there, of course this paragraph is really pleasant and
I have learned lot of things from it about blogging. thanks.

Jasa SEO Semarang said...

Spot on with this write-up, I absolutely believe this website needs a
lot more attention. I'll probably be back again to see more, thanks
for the information!

Food Guide For Cats said...

After I originally commented I seem to have clicked
on the -Notify me when new comments are added- checkbox
and now whenever a comment is added I receive 4 emails with the exact same comment.

Perhaps there is an easy method you are able to remove me from that service?
Appreciate it!

website said...

Hi, i think that i saw you visited my site so i came to
“return the favor”.I'm trying to find things to enhance my web site!I
suppose its ok to use some of your ideas!!

http://Meemi.com/agonizingzero3492/12162710 said...

Splendide post : j'espère en discuter après avec certains de mes potes

Zac said...

Un poste vraiment plein de bon sens

งานพิเศษ said...

I don't know if it's just me or if perhaps everyone
else experiencing issues with your site. It appears as if some of the text in your content are running off the screen. Can someone else please provide feedback and
let me know if this is happening to them as well?
This might be a issue with my browser because I've had this happen previously.
Many thanks

bed linen said...

Right here is the perfect web site for everyone who hopes to find out
about this topic. You know a whole lot its almost hard to argue with you (not that I really would want to…HaHa).
You certainly put a new spin on a subject that has been written about for ages.
Great stuff, just excellent!

http://www.blackplanet.com/your_page/blog/view_posting.html?pid=1715219&profile_id=64696485&profile_name=toughhardware6802&user_id=64696485&username=toughhardware6802 said...

J'écris un petit commentaire simplement pour remercier son auteur

สมัครงานพาร์ทไทม์ said...

I was curious if you ever thought of changing
the structure of your site? Its very well written; I love what youve got to say.
But maybe you could a little more in the way of content so people could connect with it better.
Youve got an awful lot of text for only having one or two images.
Maybe you could space it out better?

X marmite said...

Je souhaiterai vous dire que c'est continuellement du plaisir de
venir sur votre site internet

Nur Alam KPK said...

Thanks for ones marvelous posting! I really enjoyed
reading it, you happen to be a great author.I will
remember to bookmark your blog and will come back someday.
I want to encourage that you continue your great job,
have a nice evening!

Jordan said...

Hey I know this is off topic but I was wondering if you
knew of any widgets I could add to my blog that automatically tweet my newest twitter updates.

I've been looking for a plug-in like this for quite some time and was hoping maybe
you would have some experience with something like this.

Please let me know if you run into anything. I truly
enjoy reading your blog and I look forward to your new updates.

http://Issuu.com/ said...

Poste incroyablement captivant !!!

chiropractic seo said...

We have less of the fluid the body needs to remain supple
and strong. Your health is something to play around with and should not be taken lightly.
In my experience, chiropractic care can be very effective in treating Repetitive Stress Injuries.

sex poule said...

Magnifique article, pour ne rien changer

meuf sex-toy said...

Les posts sont véritablement intéressants

air jordan 18 ogame pl said...

I like the valuable info you provide in your articles. I'll bookmark your
weblog and check again here frequently. I'm quite certain I'll learn a lot of new stuff right here!
Best of luck for the next!

Pokemon X Y PC said...

Basically online shopping gives you opportunity to compare price of the
product through various online sites and after clearing doubts about the product, then see the
features & specification. New R4i 3DS cards are the advanced version of R4i Gold
V1. One of the pre launch Nintendo 3DS games,
is Dead or Alive Dimensions developed by Siliconera There
still aren't a lot of Nintendo 3DS games available at the
launch date, we are hearing about some great new tools and plenty
to keep you busy while other titles are being released.

Here is my homepage :: Pokemon X Y PC

Gabriella said...

Here are some insightful quotes I like... Lemme know if you
like them:

"Imagination is more important than knowledge. For knowledge is limited, whereas imagination embraces the entire world, stimulating progress, giving birth to evolution."

"I, at any rate, am convinced that He (God) doesn't throw dice."

"The significant matter isn't to stop questioning; curiosity has its own reason for existing."

"Science without religion is lame, religion without science is blind."

"Two things are infinite: the universe and human stupidity; and I am not certain about the universe."

"Falling in love isn't at all the most dumb thing that people do -- but gravitation cannot be held responsible for it."

"The most beautiful experience we can have is the mysterious. It is the fundamental emotion that stands at the cradle of true art and true science."

"Anyone who hasn't made a mistake has never tried anything new."


"Try not to become a man of success, but instead try to become a man of value"