| 1 |  |  | <?php | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3 |  |  |  | 
            
                                                                                                            
                                                                
            
                                    
            
            
                | 4 |  |  |  | 
            
                                                                        
                            
            
                                                                    
                                                                                                        
            
            
                | 5 |  | View Code Duplication | function createBlogs($N) { | 
            
                                                                        
                            
            
                                    
            
            
                | 6 |  |  |     if ($N < 1){ | 
            
                                                                        
                            
            
                                    
            
            
                | 7 |  |  |         echo "usage: .../gen-content/blogs/N  where N > 0  ... your N wasn't > 0 was it"; | 
            
                                                                        
                            
            
                                    
            
            
                | 8 |  |  |         return 1; | 
            
                                                                        
                            
            
                                    
            
            
                | 9 |  |  |     } | 
            
                                                                        
                            
            
                                    
            
            
                | 10 |  |  |     $dbprefix = elgg_get_config('dbprefix'); | 
            
                                                                        
                            
            
                                    
            
            
                | 11 |  |  |     // create N filler blogs quickly | 
            
                                                                        
                            
            
                                    
            
            
                | 12 |  |  |  | 
            
                                                                        
                            
            
                                    
            
            
                | 13 |  |  |     // entities | 
            
                                                                        
                            
            
                                    
            
            
                | 14 |  |  |     $vals = array(); | 
            
                                                                        
                            
            
                                    
            
            
                | 15 |  |  |     $subtype = get_subtype_id('object', 'blog'); | 
            
                                                                        
                            
            
                                    
            
            
                | 16 |  |  |     $owner = get_data("select guid from {$dbprefix}users_entity limit 1");      // these will all belong to the first user we see | 
            
                                                                        
                            
            
                                    
            
            
                | 17 |  |  |     $ownerid = $owner[0]->guid; | 
            
                                                                        
                            
            
                                    
            
            
                | 18 |  |  |  | 
            
                                                                        
                            
            
                                    
            
            
                | 19 |  |  |     $maxid = get_data("select max(guid)+1 as start from {$dbprefix}entities")[0]->start;  // get the max id to start from | 
            
                                                                        
                            
            
                                    
            
            
                | 20 |  |  |     for ($i=$maxid; $i < $maxid + $N; $i++) { | 
            
                                                                        
                            
            
                                    
            
            
                | 21 |  |  |         $vals[] = "('{$i}','object',$subtype,$ownerid,1,$ownerid,2,1506567954,1506567954,1506567954,'yes',NULL)"; | 
            
                                                                        
                            
            
                                    
            
            
                | 22 |  |  |     } | 
            
                                                                        
                            
            
                                    
            
            
                | 23 |  |  |     $entityvals = implode(',', $vals); | 
            
                                                                        
                            
            
                                    
            
            
                | 24 |  |  |     $entities = "INSERT INTO {$dbprefix}entities values {$entityvals}"; | 
            
                                                                        
                            
            
                                    
            
            
                | 25 |  |  |     //echo $entities . "<br />\n<hr />"; | 
            
                                                                        
                            
            
                                    
            
            
                | 26 |  |  |     echo insert_data($entities); | 
            
                                                                        
                            
            
                                    
            
            
                | 27 |  |  |  | 
            
                                                                        
                            
            
                                    
            
            
                | 28 |  |  |     // objects | 
            
                                                                        
                            
            
                                    
            
            
                | 29 |  |  |     $vals = array(); | 
            
                                                                        
                            
            
                                    
            
            
                | 30 |  |  |     for ($i=$maxid; $i < $maxid + $N; $i++) { | 
            
                                                                        
                            
            
                                    
            
            
                | 31 |  |  |         $vals[] = "('{$i}','Super Blog ($i)','HI! TEST BLOG {$i} HERE! There are Literally {$N} of us!!!1!')"; | 
            
                                                                        
                            
            
                                    
            
            
                | 32 |  |  |     } | 
            
                                                                        
                            
            
                                    
            
            
                | 33 |  |  |     $objectvals = implode(',', $vals); | 
            
                                                                        
                            
            
                                    
            
            
                | 34 |  |  |     $objects = "INSERT INTO {$dbprefix}objects_entity values {$objectvals}"; | 
            
                                                                        
                            
            
                                    
            
            
                | 35 |  |  |     //echo $objects . "<br />\n<hr />"; | 
            
                                                                        
                            
            
                                    
            
            
                | 36 |  |  |     echo insert_data($objects); | 
            
                                                                        
                            
            
                                    
            
            
                | 37 |  |  |  | 
            
                                                                        
                            
            
                                    
            
            
                | 38 |  |  |     // metadata, if needed | 
            
                                                                        
                            
            
                                    
            
            
                | 39 |  |  | } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 40 |  |  |  | 
            
                                                                                                            
                            
            
                                                                    
                                                                                                        
            
            
                | 41 |  | View Code Duplication | function createWire($N) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 42 |  |  |     if ($N < 1){ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 43 |  |  |         echo "usage: .../gen-content/wire/N  where N > 0  ... your N wasn't > 0 was it"; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 44 |  |  |         return 1; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 45 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 46 |  |  |     $dbprefix = elgg_get_config('dbprefix'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 47 |  |  |     // create N filler wire quickly | 
            
                                                                                                            
                            
            
                                    
            
            
                | 48 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 49 |  |  |     // entities | 
            
                                                                                                            
                            
            
                                    
            
            
                | 50 |  |  |     $vals = array(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 51 |  |  |     $subtype = get_subtype_id('object', 'thewire'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 52 |  |  |     $owner = get_data("select guid from {$dbprefix}users_entity limit 1");      // these will all belong to the first user we see | 
            
                                                                                                            
                            
            
                                    
            
            
                | 53 |  |  |     $ownerid = $owner[0]->guid; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 54 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 55 |  |  |     $maxid = get_data("select max(guid)+1 as start from {$dbprefix}entities")[0]->start;  // get the max id to start from | 
            
                                                                                                            
                            
            
                                    
            
            
                | 56 |  |  |     for ($i=$maxid; $i < $maxid + $N; $i++) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 57 |  |  |         $vals[] = "('{$i}','object',$subtype,$ownerid,1,$ownerid,2,1506567954,1506567954,1506567954,'yes',NULL)"; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 58 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 59 |  |  |     $entityvals = implode(',', $vals); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 60 |  |  |     $entities = "INSERT INTO {$dbprefix}entities values {$entityvals}"; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 61 |  |  |     //echo $entities . "<br />\n<hr />"; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 62 |  |  |     echo insert_data($entities); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 63 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 64 |  |  |     // objects | 
            
                                                                                                            
                            
            
                                    
            
            
                | 65 |  |  |     $vals = array(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 66 |  |  |     for ($i=$maxid; $i < $maxid + $N; $i++) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 67 |  |  |         $vals[] = "('{$i}','Super Wire post ($i)','HI! TEST WIRE POST {$i} HERE! There are Literally {$N} of us!!!1!')"; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 68 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 69 |  |  |     $objectvals = implode(',', $vals); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 70 |  |  |     $objects = "INSERT INTO {$dbprefix}objects_entity values {$objectvals}"; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 71 |  |  |     //echo $objects . "<br />\n<hr />"; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 72 |  |  |     echo insert_data($objects); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 73 |  |  |  | 
            
                                                                                                            
                                                                
            
                                    
            
            
                | 74 |  |  |     // metadata, if needed | 
            
                                                        
            
                                    
            
            
                | 75 |  |  | } |