From f1ab5c8fbee1ccacf077c7845ad954152f1188bb Mon Sep 17 00:00:00 2001 From: dev-chiefworks Date: Wed, 4 Jan 2023 06:58:40 -0500 Subject: [PATCH] Adding chiefsoft data --- app/Config/Routes.php | 5 + app/Controllers/Chiefsoft.php | 63 ++++++-- app/Models/chiefSoftData.php | 290 ++++++++++++++++++++++++++++++++++ 3 files changed, 347 insertions(+), 11 deletions(-) create mode 100644 app/Models/chiefSoftData.php diff --git a/app/Config/Routes.php b/app/Config/Routes.php index 6405cfe..6f4ea75 100644 --- a/app/Config/Routes.php +++ b/app/Config/Routes.php @@ -35,11 +35,16 @@ $routes->get('/', 'Home::index'); $routes->get('/wp/', 'Dengine::index'); $routes->get('/merms/wp/', 'Merms::index'); +//CHIEFSOFT WEBSITE +$routes->get('/chiefsoft/site/blogdata', 'Chiefsoft::blogdata'); // when no limit is sent +$routes->post('/chiefsoft/site/contact', 'Chiefsoft::contact'); //MERMS MYFIT $routes->get('/mermsmemr/myfit/country', 'Myfit::country'); $routes->get('/mermsmemr/myfit/blogdata/(:any)', 'Myfit::blogdata/$1'); +$routes->get('/mermsmemr/myfit/blogdata', 'Myfit::blogdata'); // when no limit is sent $routes->post('/mermsmemr/myfit/contact', 'Myfit::contact'); +$routes->post('/mermsmemr/myfit/pricing', 'Myfit::pricing'); diff --git a/app/Controllers/Chiefsoft.php b/app/Controllers/Chiefsoft.php index ed67677..a3f0df2 100644 --- a/app/Controllers/Chiefsoft.php +++ b/app/Controllers/Chiefsoft.php @@ -5,6 +5,8 @@ namespace App\Controllers; use CodeIgniter\API\ResponseTrait; +use CodeIgniter\HTTP\RequestInterface; + class Chiefsoft extends BaseController { @@ -57,25 +59,64 @@ class Chiefsoft extends BaseController } - $this->renderSitePage('blog', $data); + // $this->renderSitePage('blog', $data); + // return $this->response->setJson($data); + } + + public function blogdata(){ + // return $this->response->setJson([]); + $this->db = \Config\Database::connect($this->con_name); + $data = array(); + + try { + $mysql = "SELECT id, post_title, post_content,post_date,comment_count FROM wp_posts WHERE post_type='post' AND post_status = 'publish' ORDER BY post_date DESC LIMIT 9"; + $mysql = "SELECT p1.id AS id, p1.*, wm2.meta_value FROM wp_posts p1 LEFT JOIN wp_postmeta wm1 + ON (wm1.post_id = p1.id AND wm1.meta_value IS NOT NULL AND wm1.meta_key = '_thumbnail_id' ) + LEFT JOIN + wp_postmeta wm2 + ON (wm1.meta_value = wm2.post_id AND wm2.meta_key = '_wp_attached_file' AND wm2.meta_value IS NOT NULL ) + WHERE + p1.post_status='publish' + AND p1.post_type='post' + ORDER BY p1.post_date DESC LIMIT 9"; + + + $query = $this->db->query($mysql); + + $row = $query->result_array(); + + $data["blog_array"] = $row; + } catch (Exception $ex) { + + } + return $this->response->setJson([]); + // featured + try { + $mysql = "SELECT id, post_title, post_content,post_date,comment_count + FROM wp_posts WHERE post_type='post' AND post_status = 'publish' AND id = 263"; + $query = $this->db->query($mysql); + + $rowF = $query->result_array(); + // print_r( $rowF ); + // $r = $this->db->query($mysql); + $data["blog_featured"] = $rowF[0]; + } catch (Exception $ex) { + + } + + return $this->response->setJson($data); + } + + public function contact(){ + } public function index() { $rawData = $this->apiData(); - - - - - - $res1= $rawData[0]['payload']; - - // var_dump($res1); - return $this->response->setJson($res1); - } } \ No newline at end of file diff --git a/app/Models/chiefSoftData.php b/app/Models/chiefSoftData.php new file mode 100644 index 0000000..a06fc87 --- /dev/null +++ b/app/Models/chiefSoftData.php @@ -0,0 +1,290 @@ +db = \Config\Database::connect($this->con_name); + } + + + public function getSiteCountries($in) + { + + return array( + "AF" => "Afghanistan", + "AL" => "Albania", + "DZ" => "Algeria", + "AS" => "American Samoa", + "AD" => "Andorra", + "AO" => "Angola", + "AI" => "Anguilla", + "AQ" => "Antarctica", + "AG" => "Antigua and Barbuda", + "AR" => "Argentina", + "AM" => "Armenia", + "AW" => "Aruba", + "AU" => "Australia", + "AT" => "Austria", + "AZ" => "Azerbaijan", + "BS" => "Bahamas", + "BH" => "Bahrain", + "BD" => "Bangladesh", + "BB" => "Barbados", + "BY" => "Belarus", + "BE" => "Belgium", + "BZ" => "Belize", + "BJ" => "Benin", + "BM" => "Bermuda", + "BT" => "Bhutan", + "BO" => "Bolivia", + "BA" => "Bosnia and Herzegovina", + "BW" => "Botswana", + "BV" => "Bouvet Island", + "BR" => "Brazil", + "BQ" => "British Antarctic Territory", + "IO" => "British Indian Ocean Territory", + "VG" => "British Virgin Islands", + "BN" => "Brunei", + "BG" => "Bulgaria", + "BF" => "Burkina Faso", + "BI" => "Burundi", + "KH" => "Cambodia", + "CM" => "Cameroon", + "CA" => "Canada", + "CT" => "Canton and Enderbury Islands", + "CV" => "Cape Verde", + "KY" => "Cayman Islands", + "CF" => "Central African Republic", + "TD" => "Chad", + "CL" => "Chile", + "CN" => "China", + "CX" => "Christmas Island", + "CC" => "Cocos [Keeling] Islands", + "CO" => "Colombia", + "KM" => "Comoros", + "CG" => "Congo - Brazzaville", + "CD" => "Congo - Kinshasa", + "CK" => "Cook Islands", + "CR" => "Costa Rica", + "HR" => "Croatia", + "CU" => "Cuba", + "CY" => "Cyprus", + "CZ" => "Czech Republic", + "CI" => "Côte d’Ivoire", + "DK" => "Denmark", + "DJ" => "Djibouti", + "DM" => "Dominica", + "DO" => "Dominican Republic", + "NQ" => "Dronning Maud Land", + "DD" => "East Germany", + "EC" => "Ecuador", + "EG" => "Egypt", + "SV" => "El Salvador", + "GQ" => "Equatorial Guinea", + "ER" => "Eritrea", + "EE" => "Estonia", + "ET" => "Ethiopia", + "FK" => "Falkland Islands", + "FO" => "Faroe Islands", + "FJ" => "Fiji", + "FI" => "Finland", + "FR" => "France", + "GF" => "French Guiana", + "PF" => "French Polynesia", + "TF" => "French Southern Territories", + "FQ" => "French Southern and Antarctic Territories", + "GA" => "Gabon", + "GM" => "Gambia", + "GE" => "Georgia", + "DE" => "Germany", + "GH" => "Ghana", + "GI" => "Gibraltar", + "GR" => "Greece", + "GL" => "Greenland", + "GD" => "Grenada", + "GP" => "Guadeloupe", + "GU" => "Guam", + "GT" => "Guatemala", + "GG" => "Guernsey", + "GN" => "Guinea", + "GW" => "Guinea-Bissau", + "GY" => "Guyana", + "HT" => "Haiti", + "HM" => "Heard Island and McDonald Islands", + "HN" => "Honduras", + "HK" => "Hong Kong SAR China", + "HU" => "Hungary", + "IS" => "Iceland", + "IN" => "India", + "ID" => "Indonesia", + "IR" => "Iran", + "IQ" => "Iraq", + "IE" => "Ireland", + "IM" => "Isle of Man", + "IL" => "Israel", + "IT" => "Italy", + "JM" => "Jamaica", + "JP" => "Japan", + "JE" => "Jersey", + "JT" => "Johnston Island", + "JO" => "Jordan", + "KZ" => "Kazakhstan", + "KE" => "Kenya", + "KI" => "Kiribati", + "KW" => "Kuwait", + "KG" => "Kyrgyzstan", + "LA" => "Laos", + "LV" => "Latvia", + "LB" => "Lebanon", + "LS" => "Lesotho", + "LR" => "Liberia", + "LY" => "Libya", + "LI" => "Liechtenstein", + "LT" => "Lithuania", + "LU" => "Luxembourg", + "MO" => "Macau SAR China", + "MK" => "Macedonia", + "MG" => "Madagascar", + "MW" => "Malawi", + "MY" => "Malaysia", + "MV" => "Maldives", + "ML" => "Mali", + "MT" => "Malta", + "MH" => "Marshall Islands", + "MQ" => "Martinique", + "MR" => "Mauritania", + "MU" => "Mauritius", + "YT" => "Mayotte", + "FX" => "Metropolitan France", + "MX" => "Mexico", + "FM" => "Micronesia", + "MI" => "Midway Islands", + "MD" => "Moldova", + "MC" => "Monaco", + "MN" => "Mongolia", + "ME" => "Montenegro", + "MS" => "Montserrat", + "MA" => "Morocco", + "MZ" => "Mozambique", + "MM" => "Myanmar [Burma]", + "NA" => "Namibia", + "NR" => "Nauru", + "NP" => "Nepal", + "NL" => "Netherlands", + "AN" => "Netherlands Antilles", + "NT" => "Neutral Zone", + "NC" => "New Caledonia", + "NZ" => "New Zealand", + "NI" => "Nicaragua", + "NE" => "Niger", + "NG" => "Nigeria", + "NU" => "Niue", + "NF" => "Norfolk Island", + "KP" => "North Korea", + "VD" => "North Vietnam", + "MP" => "Northern Mariana Islands", + "NO" => "Norway", + "OM" => "Oman", + "PC" => "Pacific Islands Trust Territory", + "PK" => "Pakistan", + "PW" => "Palau", + "PS" => "Palestinian Territories", + "PA" => "Panama", + "PZ" => "Panama Canal Zone", + "PG" => "Papua New Guinea", + "PY" => "Paraguay", + "YD" => "People's Democratic Republic of Yemen", + "PE" => "Peru", + "PH" => "Philippines", + "PN" => "Pitcairn Islands", + "PL" => "Poland", + "PT" => "Portugal", + "PR" => "Puerto Rico", + "QA" => "Qatar", + "RO" => "Romania", + "RU" => "Russia", + "RW" => "Rwanda", + "RE" => "Réunion", + "BL" => "Saint Barthélemy", + "SH" => "Saint Helena", + "KN" => "Saint Kitts and Nevis", + "LC" => "Saint Lucia", + "MF" => "Saint Martin", + "PM" => "Saint Pierre and Miquelon", + "VC" => "Saint Vincent and the Grenadines", + "WS" => "Samoa", + "SM" => "San Marino", + "SA" => "Saudi Arabia", + "SN" => "Senegal", + "RS" => "Serbia", + "CS" => "Serbia and Montenegro", + "SC" => "Seychelles", + "SL" => "Sierra Leone", + "SG" => "Singapore", + "SK" => "Slovakia", + "SI" => "Slovenia", + "SB" => "Solomon Islands", + "SO" => "Somalia", + "ZA" => "South Africa", + "GS" => "South Georgia and the South Sandwich Islands", + "KR" => "South Korea", + "ES" => "Spain", + "LK" => "Sri Lanka", + "SD" => "Sudan", + "SR" => "Suriname", + "SJ" => "Svalbard and Jan Mayen", + "SZ" => "Swaziland", + "SE" => "Sweden", + "CH" => "Switzerland", + "SY" => "Syria", + "ST" => "São Tomé and Príncipe", + "TW" => "Taiwan", + "TJ" => "Tajikistan", + "TZ" => "Tanzania", + "TH" => "Thailand", + "TL" => "Timor-Leste", + "TG" => "Togo", + "TK" => "Tokelau", + "TO" => "Tonga", + "TT" => "Trinidad and Tobago", + "TN" => "Tunisia", + "TR" => "Turkey", + "TM" => "Turkmenistan", + "TC" => "Turks and Caicos Islands", + "TV" => "Tuvalu", + "UM" => "U.S. Minor Outlying Islands", + "PU" => "U.S. Miscellaneous Pacific Islands", + "VI" => "U.S. Virgin Islands", + "UG" => "Uganda", + "UA" => "Ukraine", + "SU" => "Union of Soviet Socialist Republics", + "AE" => "United Arab Emirates", + "GB" => "United Kingdom", + "US" => "United States", + "ZZ" => "Unknown or Invalid Region", + "UY" => "Uruguay", + "UZ" => "Uzbekistan", + "VU" => "Vanuatu", + "VA" => "Vatican City", + "VE" => "Venezuela", + "VN" => "Vietnam", + "WK" => "Wake Island", + "WF" => "Wallis and Futuna", + "EH" => "Western Sahara", + "YE" => "Yemen", + "ZM" => "Zambia", + "ZW" => "Zimbabwe", + "AX" => "Åland Islands", + ); + + } + +} \ No newline at end of file