Changeset 5775
- Timestamp:
- 04/19/08 00:50:05 (9 months ago)
- Location:
- trunk
- Files:
-
- 1 removed
- 53 modified
-
components/Needlworks.DBMS.MySQL.php (modified) (6 diffs)
-
components/Textcube.Core.php (modified) (10 diffs)
-
components/Textcube.Data.Attachment.php (modified) (3 diffs)
-
components/Textcube.Data.BlogStatistics.php (modified) (2 diffs)
-
components/Textcube.Data.Category.php (modified) (3 diffs)
-
components/Textcube.Data.Comment.php (modified) (3 diffs)
-
components/Textcube.Data.CommentNotified.php (modified) (3 diffs)
-
components/Textcube.Data.CommentNotifiedSiteInfo.php (modified) (3 diffs)
-
components/Textcube.Data.DailyStatistics.php (modified) (3 diffs)
-
components/Textcube.Data.DataMaintenance.php (modified) (2 diffs)
-
components/Textcube.Data.Feed.php (modified) (6 diffs)
-
components/Textcube.Data.Filter.php (modified) (3 diffs)
-
components/Textcube.Data.GuestComment.php (modified) (3 diffs)
-
components/Textcube.Data.Keyword.php (modified) (4 diffs)
-
components/Textcube.Data.Link.php (modified) (3 diffs)
-
components/Textcube.Data.Notice.php (modified) (4 diffs)
-
components/Textcube.Data.PluginSetting.php (modified) (3 diffs)
-
components/Textcube.Data.Post.php (modified) (8 diffs)
-
components/Textcube.Data.RefererLog.php (modified) (3 diffs)
-
components/Textcube.Data.RefererStatistics.php (modified) (3 diffs)
-
components/Textcube.Data.ServiceSetting.php (modified) (3 diffs)
-
components/Textcube.Data.SkinSetting.php (modified) (2 diffs)
-
components/Textcube.Data.SubscriptionLog.php (modified) (3 diffs)
-
components/Textcube.Data.SubscriptionStatistics.php (modified) (3 diffs)
-
components/Textcube.Data.Trackback.php (modified) (4 diffs)
-
components/Textcube.Data.TrackbackLog.php (modified) (3 diffs)
-
components/Textcube.Data.User.php (modified) (1 diff)
-
components/Textcube.Data.UserSetting.php (modified) (3 diffs)
-
components/Textcube.Data.php (modified) (1 diff)
-
components/Textcube.Model.PluginCustomConfig.php (modified) (1 diff)
-
interface/owner/setting/account/index.php (modified) (6 diffs)
-
lib/blog.skin.php (modified) (5 diffs)
-
lib/includeForBlog.php (modified) (2 diffs)
-
lib/includeForBlogOwner.php (modified) (1 diff)
-
lib/model/blog.entry.php (modified) (5 diffs)
-
lib/model/blog.skin.php (modified) (1 diff)
-
lib/model/blog.tag.php (modified) (1 diff)
-
lib/model/blog.teamblog.php (deleted)
-
lib/model/blog.trackback.php (modified) (4 diffs)
-
lib/model/blog.trash.php (modified) (2 diffs)
-
lib/model/common.legacysupport.php (modified) (1 diff)
-
lib/model/common.plugin.php (modified) (1 diff)
-
lib/model/reader.common.php (modified) (8 diffs)
-
lib/view/view.php (modified) (12 diffs)
-
plugins/CT_RecentPS_Default/index.php (modified) (3 diffs)
-
plugins/CT_RecentRP_Default/index.php (modified) (1 diff)
-
plugins/EAS/index.php (modified) (3 diffs)
-
plugins/FM_Modern/index.xml (modified) (2 diffs)
-
plugins/FM_TTML/index.xml (modified) (2 diffs)
-
plugins/MT_Meta_RecentPS_Default/index.php (modified) (1 diff)
-
plugins/MT_Meta_RecentPS_Default/index.xml (modified) (2 diffs)
-
plugins/PN_Subscription_Default/index.php (modified) (5 diffs)
-
plugins/PN_Subscription_Default/index.xml (modified) (2 diffs)
-
setup.php (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/components/Needlworks.DBMS.MySQL.php
r5482 r5775 4 4 /// See the GNU General Public License for more details. (/doc/LICENSE, /doc/COPYRIGHT) 5 5 6 // DBQuery version 1.7 for MySQL 7 6 8 global $cachedResult; 7 9 global $fileCachedResult; 8 10 global $__gEscapeTag; 9 11 global $__dbProperties; 12 global $__gLastQueryType; 10 13 $cachedResult = $__dbProperties = array(); 11 14 $__gEscapeTag = null; … … 66 69 /*@static@*/ 67 70 function queryCount($query) { 71 global $__gLastQueryType; 68 72 $count = 0; 69 73 $query = trim($query); 70 74 if ($result = DBQuery::query($query)) { 71 75 $operation = strtolower(substr($query, 0,6)); 76 $__gLastQueryType = $operation; 72 77 switch ($operation) { 73 78 case 'select': … … 150 155 /*@static@*/ 151 156 function queryAll ($query, $type = MYSQL_BOTH, $count = -1) { 157 if($type == 'assoc') $type = MYSQL_ASSOC; 158 else if ($type == 'num') $type = MYSQL_NUM; 152 159 return DBQuery::queryAllWithCache($query, $type, $count); 153 160 //return DBQuery::queryAllWithoutCache($query, $type, $count); // Your choice. :) … … 202 209 /*@static@*/ 203 210 function query($query) { 211 global $__gLastQueryType; 204 212 if( function_exists( '__tcSqlLogBegin' ) ) { 205 213 __tcSqlLogBegin($query); … … 209 217 $result = mysql_query($query); 210 218 } 219 $__gLastQueryType = strtolower(substr($query, 0,6)); 211 220 if( stristr($query, 'update ') || 212 221 stristr($query, 'insert ') || … … 253 262 global $fileCachedResult; 254 263 } 264 265 /* Raw functions (to easier adoptation) */ 266 /*@static@*/ 267 function num_rows($handle = null) { 268 global $__gLastQueryType; 269 switch($__gLastQueryType) { 270 case 'select': 271 return mysql_num_rows($handle); 272 break; 273 default: 274 return mysql_affected_rows($handle); 275 break; 276 } 277 return null; 278 } 279 /*@static@*/ 280 function free($handle = null) { 281 mysql_free_result($handle); 282 } 283 284 /*@static@*/ 285 function fetch($handle = null, $type = 'assoc') { 286 if($type == 'array') return mysql_fetch_array($handle); // Can I use mysql_fetch_row instead? 287 else if ($type = 'row') return mysql_fetch_row($handle); 288 else return mysql_fetch_assoc($handle); 289 } 290 291 /*@static@*/ 292 function error($err = null) { 293 return mysql_error($err); 294 } 255 295 } 256 296 -
trunk/components/Textcube.Core.php
r5774 r5775 4 4 /// See the GNU General Public License for more details. (/doc/LICENSE, /doc/COPYRIGHT) 5 5 6 /* This component contains 'User' and 'Transaction' class. */ 7 8 requireComponent( "Textcube.Control.Auth" ); 6 /* This component contains 'User', 'Blog' and 'Transaction' class. 7 NOTE : Classes described below are actually not object. Usually they are static.*/ 8 9 requireComponent('Textcube.Control.Auth'); 9 10 10 11 // for Global Cache … … 181 182 } 182 183 184 /*@static@*/ 183 185 function authorName($blogid = null,$entryId){ 184 186 if( is_null($blogid) ) { 185 187 $blogid = getBlogId(); 186 188 } 187 global $database, $entry;188 189 189 190 // Read userId of entry from relation table. … … 196 197 } 197 198 199 /*@static@*/ 198 200 function changeBlog(){ 199 201 global $database, $blogURL, $blog, $service; … … 216 218 return $changeBlogView; 217 219 } 218 220 221 /*@static@*/ 219 222 function changeSetting($userid, $email, $nickname) { 220 223 global $database; … … 232 235 } 233 236 } 234 237 238 /*@static@*/ 235 239 function add($email, $name) { 236 240 global $database, $service, $user, $blog; … … 244 248 $loginid = POD::escapeString(UTF8::lessenAsEncoding($email, 64)); 245 249 $name = POD::escapeString(UTF8::lessenAsEncoding($name, 32)); 246 $password = generatePassword();247 $authtoken = md5( generatePassword());250 $password = User::__generatePassword(); 251 $authtoken = md5(User::__generatePassword()); 248 252 249 253 if (POD::queryExistence("SELECT * FROM `{$database['prefix']}Users` WHERE loginid = '$loginid'")) { … … 262 266 } 263 267 264 /* TO DO : library 의존성 없애야 함. 함수를 사용하고 있습니다.*/268 /*@static@*/ 265 269 function remove($userid) { 266 270 global $database; … … 273 277 POD::execute($sql); 274 278 foreach ($blogs as $ownedBlog) { 275 changeBlogOwner($ownedBlog,1); // 관리자 uid로 변경279 Blog::changeOwner($ownedBlog,1); // 관리자 uid로 변경 276 280 } 277 281 $blogs = User::getBlogs($userid); 278 282 foreach ($blogs as $joinedBlog) { 279 deleteTeamblogUser($userid,$joinedBlog);283 Blog::deleteUser($joinedBlog, $userid); 280 284 } 281 285 User::removePermanent($userid); … … 283 287 } 284 288 289 /*@static@*/ 285 290 function removePermanent($userid) { 286 291 global $database; … … 291 296 } 292 297 } 298 299 /* private functions */ 300 /*@private static@*/ 301 function __generatePassword() { 302 return strtolower(substr(base64_encode(rand(0x10000000, 0x70000000)), 3, 8)); 303 } 293 304 } 294 305 306 class Blog { 307 /*@static@*/ 308 function changeOwner($blogid,$userid) { 309 global $database; 310 POD::execute("UPDATE `{$database['prefix']}Teamblog` SET acl = 3 WHERE blogid = ".$blogid." and acl = " . BITWISE_OWNER); 311 312 $acl = POD::queryCell("SELECT acl FROM {$database['prefix']}Teamblog WHERE blogid='$blogid' and userid='$userid'"); 313 314 if( $acl === null ) { // If there is no ACL, add user into the blog. 315 POD::query("INSERT INTO `{$database['prefix']}Teamblog` 316 VALUES('$blogid', '$userid', '".BITWISE_OWNER."', UNIX_TIMESTAMP(), '0')"); 317 } else { 318 POD::execute("UPDATE `{$database['prefix']}Teamblog` SET acl = ".BITWISE_OWNER." 319 WHERE blogid = ".$blogid." and userid = " . $userid); 320 } 321 return true; 322 } 323 324 /*@static@*/ 325 /* TODO : remove model dependency (addBlog, sendInvitationMail) */ 326 function addUser($email, $name, $comment, $senderName, $senderEmail) { 327 requireModel('blog.user'); 328 requireModel('blog.blogSetting'); 329 global $database,$service,$blogURL,$hostURL,$user,$blog; 330 331 $blogid = getBlogId(); 332 if(empty($email)) 333 return 1; 334 if(!preg_match('/^[^@]+@([-a-zA-Z0-9]+\.)+[-a-zA-Z0-9]+$/',$email)) 335 return array( 2, _t('이메일이 바르지 않습니다.') ); 336 337 $isUserExists = User::getUserIdByEmail($email); 338 if(empty($isUserExists)) { // If user is not exist 339 User::add($email,$name); 340 } 341 $userid = User::getUserIdByEmail($email); 342 $result = addBlog(getBlogId(), $userid, null); 343 if($result === true) { 344 return sendInvitationMail(getBlogId(), $userid, User::getName($userid), $comment, $senderName, $senderEmail); 345 } 346 return $result; 347 } 348 349 /*@static@*/ 350 function deleteUser($blogid = null, $userid, $clean = true) { 351 global $database; 352 if ($blogid == null) { 353 $blogid = getBlogId(); 354 } 355 POD::execute("UPDATE `{$database['prefix']}Entries` 356 SET userid = ".User::getBlogOwner($blogid)." 357 WHERE blogid = ".$blogid." AND userid = ".$userid); 358 359 // Delete ACL relation. 360 if(!POD::execute("DELETE FROM `{$database['prefix']}Teamblog` WHERE blogid='$blogid' and userid='$userid'")) 361 return false; 362 // And if there is no blog related to the specific user, delete user. 363 if($clean && !POD::queryAll("SELECT * FROM `{$database['prefix']}Teamblog` WHERE userid = '$userid'")) { 364 User::removePermanent($userid); 365 } 366 return true; 367 } 368 369 /*@static@*/ 370 function changeACLofUser($blogid, $userid, $ACLtype, $switch) { // Change user priviledge on the blog. 371 global $database; 372 if(empty($ACLtype) || empty($userid)) 373 return false; 374 $acl = POD::queryCell("SELECT acl 375 FROM {$database['prefix']}Teamblog 376 WHERE blogid='$blogid' and userid='$userid'"); 377 if( $acl === null ) { // If there is no ACL, add user into the blog. 378 $name = User::getName($userid); 379 POD::query("INSERT INTO `{$database['prefix']}Teamblog` 380 VALUES('$blogid', '$userid', '0', UNIX_TIMESTAMP(), '0')"); 381 $acl = 0; 382 } 383 $bitwise = null; 384 switch( $ACLtype ) { 385 case 'admin': 386 $bitwise = BITWISE_ADMINISTRATOR; 387 break; 388 case 'editor': 389 $bitwise = BITWISE_EDITOR; 390 break; 391 default: 392 return false; 393 } 394 if( $switch ) { 395 $acl |= $bitwise; 396 } else { 397 $acl &= ~$bitwise; 398 } 399 return POD::execute("UPDATE `{$database['prefix']}Teamblog` 400 SET acl = ".$acl." 401 WHERE blogid = ".$blogid." and userid = ".$userid); 402 } 403 } 295 404 296 405 class Transaction { -
trunk/components/Textcube.Data.Attachment.php
r5285 r5775 31 31 $sort = 'ORDER BY ' . $sort; 32 32 $this->close(); 33 $this->_result = mysql_query("SELECT $fields FROM {$database['prefix']}Attachments WHERE blogid = $blogid $filter $sort");33 $this->_result = POD::query("SELECT $fields FROM {$database['prefix']}Attachments WHERE blogid = $blogid $filter $sort"); 34 34 if ($this->_result) { 35 if ($this->_count = mysql_num_rows($this->_result))35 if ($this->_count = POD::num_rows($this->_result)) 36 36 return $this->shift(); 37 37 else 38 mysql_free_result($this->_result);38 POD::free($this->_result); 39 39 } 40 40 unset($this->_result); … … 44 44 function close() { 45 45 if (isset($this->_result)) { 46 mysql_free_result($this->_result);46 POD::free($this->_result); 47 47 unset($this->_result); 48 48 } … … 53 53 function shift() { 54 54 $this->reset(); 55 if ($this->_result && ($row = mysql_fetch_assoc($this->_result))) {55 if ($this->_result && ($row = POD::fetch($this->_result))) { 56 56 foreach ($row as $name => $value) { 57 57 if ($name == 'blogid') -
trunk/components/Textcube.Data.BlogStatistics.php
r5285 r5775 17 17 global $database; 18 18 $this->reset(); 19 if ($result = mysql_query("SELECT visits FROM {$database['prefix']}BlogStatistics WHERE blogid = ".getBlogId())) {20 if ($row = mysql_fetch_assoc($result)) {19 if ($result = POD::query("SELECT visits FROM {$database['prefix']}BlogStatistics WHERE blogid = ".getBlogId())) { 20 if ($row = POD::fetch($result)) { 21 21 foreach ($row as $name => $value) { 22 22 if ($name == 'owner') … … 24 24 $this->$name = $value; 25 25 } 26 mysql_free_result($result);26 POD::free($result); 27 27 return true; 28 28 } 29 mysql_free_result($result);29 POD::free($result); 30 30 } 31 31 return false; -
trunk/components/Textcube.Data.Category.php
r5285 r5775 35 35 $sort = 'ORDER BY ' . $sort; 36 36 $this->close(); 37 $this->_result = mysql_query("SELECT $fields FROM {$database['prefix']}Categories WHERE blogid = ".getBlogId()." $filter $sort");37 $this->_result = POD::query("SELECT $fields FROM {$database['prefix']}Categories WHERE blogid = ".getBlogId()." $filter $sort"); 38 38 if ($this->_result) 39 $this->_count = mysql_num_rows($this->_result);39 $this->_count = POD::num_rows($this->_result); 40 40 return $this->shift(); 41 41 } … … 43 43 function close() { 44 44 if (isset($this->_result)) { 45 mysql_free_result($this->_result);45 POD::free($this->_result); 46 46 unset($this->_result); 47 47 } … … 52 52 function shift() { 53 53 $this->reset(); 54 if ($this->_result && ($row = mysql_fetch_assoc($this->_result))) {54 if ($this->_result && ($row = POD::fetch($this->_result))) { 55 55 foreach ($row as $name => $value) { 56 56 if ($name == 'blogid') -
trunk/components/Textcube.Data.Comment.php
r5285 r5775 35 35 $sort = 'ORDER BY ' . $sort; 36 36 $this->close(); 37 $this->_result = mysql_query("SELECT $fields FROM {$database['prefix']}Comments WHERE blogid = ".getBlogId()." $filter $sort");37 $this->_result = POD::query("SELECT $fields FROM {$database['prefix']}Comments WHERE blogid = ".getBlogId()." $filter $sort"); 38 38 if ($this->_result) { 39 if ($this->_count = mysql_num_rows($this->_result))39 if ($this->_count = POD::num_rows($this->_result)) 40 40 return $this->shift(); 41 41 else 42 mysql_free_result($this->_result);42 POD::free($this->_result); 43 43 } 44 44 unset($this->_result); … … 48 48 function close() { 49 49 if (isset($this->_result)) { 50 mysql_free_result($this->_result);50 POD::free($this->_result); 51 51 unset($this->_result); 52 52 } … … 57 57 function shift() { 58 58 $this->reset(); 59 if ($this->_result && ($row = mysql_fetch_assoc($this->_result))) {59 if ($this->_result && ($row = POD::fetch($this->_result))) { 60 60 foreach ($row as $name => $value) { 61 61 if ($name == 'blogid') -
trunk/components/Textcube.Data.CommentNotified.php
r5627 r5775 40 40 $sort = 'ORDER BY ' . $sort; 41 41 $this->close(); 42 $this->_result = mysql_query("SELECT $fields FROM {$database['prefix']}CommentsNotified WHERE blogid = ".getBlogId()." $filter $sort");42 $this->_result = POD::query("SELECT $fields FROM {$database['prefix']}CommentsNotified WHERE blogid = ".getBlogId()." $filter $sort"); 43 43 if ($this->_result) { 44 if ($this->_count = mysql_num_rows($this->_result))44 if ($this->_count = POD::num_rows($this->_result)) 45 45 return $this->shift(); 46 46 else 47 mysql_free_result($this->_result);47 POD::free($this->_result); 48 48 } 49 49 unset($this->_result); … … 53 53 function close() { 54 54 if (isset($this->_result)) { 55 mysql_free_result($this->_result);55 POD::free($this->_result); 56 56 unset($this->_result); 57 57 } … … 62 62 function shift() { 63 63 $this->reset(); 64 if ($this->_result && ($row = mysql_fetch_assoc($this->_result))) {64 if ($this->_result && ($row = POD::fetch($this->_result))) { 65 65 foreach ($row as $name => $value) { 66 66 if ($name == 'blogid') -
trunk/components/Textcube.Data.CommentNotifiedSiteInfo.php
r5285 r5775 25 25 $sort = 'ORDER BY ' . $sort; 26 26 $this->close(); 27 $this->_result = mysql_query("SELECT $fields FROM {$database['prefix']}CommentsNotifiedSiteInfo WHERE $filter $sort");27 $this->_result = POD::query("SELECT $fields FROM {$database['prefix']}CommentsNotifiedSiteInfo WHERE $filter $sort"); 28 28 if ($this->_result) { 29 if ($this->_count = mysql_num_rows($this->_result))29 if ($this->_count = POD::num_rows($this->_result)) 30 30 return $this->shift(); 31 31 else 32 mysql_free_result($this->_result);32 POD::free($this->_result); 33 33 } 34 34 unset($this->_result); … … 38 38 function close() { 39 39 if (isset($this->_result)) { 40 mysql_free_result($this->_result);40 POD::free($this->_result); 41 41 unset($this->_result); 42 42 } … … 47 47 function shift() { 48 48 $this->reset(); 49 if ($this->_result && ($row = mysql_fetch_assoc($this->_result))) {49 if ($this->_result && ($row = POD::fetch($this->_result))) { 50 50 foreach ($row as $name => $value) { 51 51 $this->$name = $value; -
trunk/components/Textcube.Data.DailyStatistics.php
r5285 r5775 23 23 $sort = 'ORDER BY ' . $sort; 24 24 $this->close(); 25 $this->_result = mysql_query("SELECT $fields FROM {$database['prefix']}DailyStatistics WHERE blogid = ".getBlogId()." $filter $sort");25 $this->_result = POD::query("SELECT $fields FROM {$database['prefix']}DailyStatistics WHERE blogid = ".getBlogId()." $filter $sort"); 26 26 if ($this->_result) { 27 if ($this->_count = mysql_num_rows($this->_result))27 if ($this->_count = POD::num_rows($this->_result)) 28 28 return $this->shift(); 29 29 else 30 mysql_free_result($this->_result);30 POD::free($this->_result); 31 31 } 32 32 unset($this->_result); … … 36 36 function close() { 37 37 if (isset($this->_result)) { 38 mysql_free_result($this->_result);38 POD::free($this->_result); 39 39 unset($this->_result); 40 40 } … … 45 45 function shift() { 46 46
