function startSubmission($websiteId, $dirId = '') { # get list of already submitted directories $sql = "select directory_id from dirsubmitinfo where website_id={$websiteId}"; $list = $this->db->select($sql); $dirList = array(); foreach ($list as $listInfo) { $dirList[] = $listInfo['directory_id']; } # to get skipped directories $skipDirList = $this->__getAllSkippedDir($websiteId); if (count($skipDirList) > 0) { $dirList = array_merge($dirList, $skipDirList); } $sql = "select * from directories where working=1"; if (!empty($_SESSION['no_captcha'])) { $sql .= " and is_captcha=0"; } if (!empty($_SESSION['dirsub_pr'])) { $sql .= " and google_pagerank={$_SESSION['dirsub_pr']}"; } if (!empty($_SESSION['dirsub_lang'])) { $sql .= " and lang_code='{$_SESSION['dirsub_lang']}'"; } if (!empty($dirId)) { $sql .= " and id={$dirId}"; } if (count($dirList) > 0) { $sql .= " and id not in (" . implode(',', $dirList) . ")"; } $sql .= " order by rank DESC, extra_val ASC, id ASC"; $dirInfo = $this->db->select($sql, true); $this->set('dirInfo', $dirInfo); # directory list is empty if (empty($dirInfo['id'])) { showErrorMsg($this->spTextDir['nodirnote'] . ". Please <a href='" . SP_CONTACT_LINK . "' target='_blank'>Contact</a> <b>Seo Panel Team</b> to get more <b>directories</b>."); } $websiteController = new WebsiteController(); $websiteInfo = $websiteController->__getWebsiteInfo($websiteId); $this->set('websiteId', $websiteId); $spider = new Spider(); $spider->_CURLOPT_HEADER = 1; $ret = $spider->getContent(addHttpToUrl($dirInfo['submit_url'])); if ($ret['error']) { $this->set('error', 1); $this->set('msg', $ret['errmsg']); } $page = $ret['page']; if (!empty($page)) { $matches = $this->isCategoryExists($page, $dirInfo['category_col']); } # if category exists proceed submission if (!empty($matches[0])) { $categorysel = $matches[0]; $catList = explode(',', $websiteInfo['category']); if (count($catList) > 0) { foreach ($catList as $category) { $category = trim($category); $categorysel = preg_replace("/<(option.*?{$category}.*?)>/si", '<$1 selected>', $categorysel, 1, $count); if ($count > 0) { break; } } if ($count <= 0) { $categorysel = $matches[0]; } } $this->set('categorySel', $categorysel); $captchaUrl = ''; if (stristr($page, $dirInfo['captcha_script'])) { $captchaUrl = $dirInfo['captcha_script']; } $imageHash = ""; if (preg_match('/name="' . $dirInfo['imagehash_col'] . '".*?value="(.*?)"/is', $page, $hashMatch)) { $imageHash = $hashMatch[1]; } $this->set('imageHash', $imageHash); $phpsessid = $spider->getSessionId($page); $this->set('phpsessid', $phpsessid); if (!empty($captchaUrl)) { $captchaUrl = preg_replace('/^\\//', '', $captchaUrl); $dirInfo['domain'] = addHttpToUrl($dirInfo['domain']); if (preg_match('/\\/$/', $dirInfo['domain'])) { $captchaUrl = $dirInfo['domain'] . $captchaUrl; } else { $captchaUrl = $dirInfo['domain'] . "/" . $captchaUrl; } if (!stristr($captchaUrl, '?')) { if (!empty($imageHash)) { $captchaUrl .= "?" . $dirInfo['imagehashurl_col'] . "=" . $imageHash; } else { $captchaUrl .= "?rand=" . rand(1, 1000); } } else { if (!empty($imageHash)) { $captchaUrl .= "&" . $dirInfo['imagehashurl_col'] . "=" . $imageHash; } else { $captchaUrl .= "&rand=" . rand(1, 1000); } } # to get stored image path if hot linking is prevented $captchaUrl = $this->__getCreatedCaptchaUrl($captchaUrl, $dirInfo['submit_url'], $phpsessid); } $this->set('captchaUrl', $captchaUrl); // function check whether recriprocal directory $scriptInfo = $this->getDirectoryScriptMetaInfo($dirInfo['script_type_id']); $checkArg = $scriptInfo['link_type_col'] . "=" . $scriptInfo['reciprocal']; $reciprocalUrl = false; if (stristr($dirInfo['extra_val'], $checkArg)) { $reciprocalUrl = $websiteInfo['reciprocal_url']; if (empty($reciprocalUrl)) { if (preg_match("/&{$scriptInfo['reciprocal_col']}=(.*)/", $dirInfo['extra_val'], $matches)) { if (!empty($matches[1])) { $reciprocalUrl = $matches[1]; } } } } $this->set('reciprocalUrl', $reciprocalUrl); } else { $this->set('error', 1); $this->set('msg', $this->spTextDir['nocatnote']); } $this->render('directory/showsubmissionform'); }